From 066883340bb685b1dfce449cd538418579d3d0ce Mon Sep 17 00:00:00 2001 From: asterix Date: Mon, 28 Jun 2010 18:01:35 +0000 Subject: [PATCH] Add some adc function hw specific. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3961 38d2e660-2303-0410-9eaa-f027e97ec537 --- boards/stm32-p103/hw/hw_adc.h | 56 +++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 boards/stm32-p103/hw/hw_adc.h diff --git a/boards/stm32-p103/hw/hw_adc.h b/boards/stm32-p103/hw/hw_adc.h new file mode 100644 index 00000000..3c6e4bbc --- /dev/null +++ b/boards/stm32-p103/hw/hw_adc.h @@ -0,0 +1,56 @@ +/** + * \file + * + * + * \brief Some ADC utilis. + * + * \author Daniele Basile + */ + +#ifndef HW_ADC_H +#define HW_ADC_H + +#include + +#include + +INLINE uint16_t hw_readVrefint(void) +{ + return ADC_RANGECONV(adc_read(ADC_VREFINT_CH), 0, 3.3); +} + +INLINE float 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); +} + +#endif /* HW_ADC_H */ -- 2.25.1