Skip to content

Commit

Permalink
examples: update adc internal channels to support STM32C0xx
Browse files Browse the repository at this point in the history
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
  • Loading branch information
fpistm committed Jan 23, 2023
1 parent 6c82fb2 commit b875d3a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions examples/Peripherals/ADC/Internal_channels/Internal_channels.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,22 @@
#include "stm32yyxx_ll_adc.h"

/* Values available in datasheet */
#if defined(STM32C0xx)
#define CALX_TEMP 30
#else
#define CALX_TEMP 25
#if defined(STM32F1xx)
#define V25 1430
#endif

#if defined(STM32C0xx)
#define VTEMP 760
#define AVG_SLOPE 2530
#define VREFINT 1212
#elif defined(STM32F1xx)
#define VTEMP 1430
#define AVG_SLOPE 4300
#define VREFINT 1200
#elif defined(STM32F2xx) || defined(STM32F4xx)
#define V25 760
#define VTEMP 760
#define AVG_SLOPE 2500
#define VREFINT 1210
#endif
Expand Down Expand Up @@ -66,7 +75,7 @@ static int32_t readTempSensor(int32_t VRef)
return (__LL_ADC_CALC_TEMPERATURE(VRef, analogRead(ATEMP), LL_ADC_RESOLUTION));
#endif
#elif defined(__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS)
return (__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(AVG_SLOPE, V25, CALX_TEMP, VRef, analogRead(ATEMP), LL_ADC_RESOLUTION));
return (__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(AVG_SLOPE, VTEMP, CALX_TEMP, VRef, analogRead(ATEMP), LL_ADC_RESOLUTION));
#else
return 0;
#endif
Expand Down

0 comments on commit b875d3a

Please sign in to comment.