mirror of https://github.com/ARMmbed/mbed-os.git
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 https://github.com/ARMmbed/mbed-os/pull/11324#pullrequestreview-282433989pull/11516/head
parent
83fca603f0
commit
1713e79ccf
|
@ -51,7 +51,7 @@ void analogout_write_u16(dac_t *obj, uint16_t value)
|
||||||
|
|
||||||
float analogout_read(dac_t *obj)
|
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)
|
uint16_t analogout_read_u16(dac_t *obj)
|
||||||
|
|
Loading…
Reference in New Issue