X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=boards%2Fstm32-p103%2Fhw%2Fhw_adc.h;h=0313b2fc47a68939ceea41a1279460e78c26ca9b;hb=45b784ed8ed1b37ccd1fa56258fb9d082de55216;hp=c2c321f13b2826a2a118b319844879045728be12;hpb=13292fe21ffef5edef79eb339903a91d5dde6b93;p=bertos.git diff --git a/boards/stm32-p103/hw/hw_adc.h b/boards/stm32-p103/hw/hw_adc.h index c2c321f1..0313b2fc 100644 --- a/boards/stm32-p103/hw/hw_adc.h +++ b/boards/stm32-p103/hw/hw_adc.h @@ -43,7 +43,7 @@ #include /* - * Return the Vrefint voltage in mV + * Return the Vrefint voltage in mV. */ INLINE uint16_t hw_readVrefint(void) { @@ -51,12 +51,14 @@ INLINE uint16_t hw_readVrefint(void) } /* - * Return the cpu core temperature in degrees. + * Return the cpu core temperature in degrees * 100. */ -INLINE float hw_readIntTemp(void) +INLINE uint16_t hw_readIntTemp(void) { - float vsens = ADC_RANGECONV(adc_read(ADC_TEMP_CH), 0, 3.3); - return (float)(((ADC_TEMP_V25 - vsens) / ADC_TEMP_SLOPE) + ADC_TEMP_CONST); + uint16_t vsens = ADC_RANGECONV(adc_read(ADC_TEMP_CH), 0, 3300); + + uint16_t temp = (((ADC_TEMP_V25 - vsens) * 1000)/ ADC_TEMP_SLOPE) + ADC_TEMP_CONST; + return (temp / 10); } #endif /* HW_ADC_H */