Skip to content

Commit ea8329a

Browse files
Kyle Kearneyadbridge
authored andcommitted
Fix incorrect integer division in analogout_read
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 #11324 (review)
1 parent cc40280 commit ea8329a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/cy_analogout_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void analogout_write_u16(dac_t *obj, uint16_t value)
5151

5252
float analogout_read(dac_t *obj)
5353
{
54-
return analogout_read_u16(obj) / UINT16_MAX;
54+
return analogout_read_u16(obj) * (1.0f / UINT16_MAX);
5555
}
5656

5757
uint16_t analogout_read_u16(dac_t *obj)

0 commit comments

Comments
 (0)