summaryrefslogtreecommitdiff
path: root/tests/adc-power/adc-power.c
diff options
context:
space:
mode:
authorKarl Palsson <karlp@tweak.net.au>2016-03-30 17:15:06 +0000
committerKarl Palsson <karlp@tweak.net.au>2016-03-30 17:15:06 +0000
commit614482176cffcdf7f23d022e067a94b0f89ab601 (patch)
tree0ed646107685c7c504be069063da77135a17d759 /tests/adc-power/adc-power.c
parentfc590297eb56b5705c7879bc33cff6ee37629653 (diff)
downloadolsndot-614482176cffcdf7f23d022e067a94b0f89ab601.tar.gz
olsndot-614482176cffcdf7f23d022e067a94b0f89ab601.tar.bz2
olsndot-614482176cffcdf7f23d022e067a94b0f89ab601.zip
adc: use single float literals
Dramatic performance improvement on m4f cores, ~1600->80 cycles
Diffstat (limited to 'tests/adc-power/adc-power.c')
-rw-r--r--tests/adc-power/adc-power.c6
1 files changed, 3 insertions, 3 deletions
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;