Skip to content

Commit

Permalink
Fix incorrect integer division in analogout_read
Browse files Browse the repository at this point in the history
Replace with multiplication by the floating point reciprocal, to
 produce a floating point result while being more efficient than
 floating point division.
Addresses the issue raised by kjbracey-arm in
ARMmbed#11324 (review)
  • Loading branch information
Kyle Kearney authored and romanjoe committed Sep 20, 2019
1 parent c8085d4 commit ecef36f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion targets/TARGET_Cypress/TARGET_PSOC6/cy_analogout_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void analogout_write_u16(dac_t *obj, uint16_t value)

float analogout_read(dac_t *obj)
{
return analogout_read_u16(obj) / UINT16_MAX;
return analogout_read_u16(obj) * (1.0f / UINT16_MAX);
}

uint16_t analogout_read_u16(dac_t *obj)
Expand Down

0 comments on commit ecef36f

Please sign in to comment.