From 614482176cffcdf7f23d022e067a94b0f89ab601 Mon Sep 17 00:00:00 2001 From: Karl Palsson Date: Wed, 30 Mar 2016 17:15:06 +0000 Subject: adc: use single float literals Dramatic performance improvement on m4f cores, ~1600->80 cycles --- tests/adc-power/adc-power.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/adc-power/adc-power.c b/tests/adc-power/adc-power.c index 97a083a..2d7f310 100644 --- a/tests/adc-power/adc-power.c +++ b/tests/adc-power/adc-power.c @@ -117,12 +117,12 @@ static uint16_t read_adc_naiive(uint8_t channel) } static float adc_calc_tempf(unsigned int ts_v, unsigned int vref) { - float adjusted_vtemp = ts_v * ST_VREFINT_CAL * 1.0 / vref * 1.0; - float slope = (110-30) * 1.0 / (ST_TSENSE_CAL2_110C - ST_TSENSE_CAL1_30C) * 1.0; + float adjusted_vtemp = ts_v * ST_VREFINT_CAL * 1.0f / vref * 1.0f; + float slope = (110-30) * 1.0f / (ST_TSENSE_CAL2_110C - ST_TSENSE_CAL1_30C) * 1.0f; return slope * (adjusted_vtemp - ST_TSENSE_CAL1_30C) + 30; } -static float adc_calc_tempi(uint16_t ts, uint16_t vref) { +static int adc_calc_tempi(unsigned int ts, unsigned int vref) { int adjusted_vtemp = ts * ST_VREFINT_CAL / vref; int slope = (110-30) / (ST_TSENSE_CAL2_110C - ST_TSENSE_CAL1_30C); return slope * (adjusted_vtemp - ST_TSENSE_CAL1_30C) + 30; -- cgit