From 0256967defb760d2dc99c13728a0b969ae549f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Mon, 20 Jun 2022 18:13:02 +0200 Subject: [PATCH] stm32: support stm32f401 adc_temperature sensor (#5572) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > The temperature sensor is internally connected to the ADC_IN18 > The TSVREFE bit must be set to enable the conversion of both internal channels: the ADC1_IN16 or ADC1_IN18 (temperature sensor) and the ADC1_IN17 (VREFINT). Ref.: https://www.st.com/resource/en/reference_manual/dm00096844-stm32f401xb-c-and-stm32f401xd-e-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf Signed-off-by: Kamil TrzciƄski --- src/stm32/adc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/stm32/adc.c b/src/stm32/adc.c index 02e54fba..39d4f643 100644 --- a/src/stm32/adc.c +++ b/src/stm32/adc.c @@ -28,7 +28,7 @@ static const uint8_t adc_pins[] = { ADC_TEMPERATURE_PIN, #elif CONFIG_MACH_STM32F2 || CONFIG_MACH_STM32F4x5 ADC_TEMPERATURE_PIN, 0x00, 0x00, -#elif CONFIG_MACH_STM32F446 +#elif CONFIG_MACH_STM32F401 || CONFIG_MACH_STM32F446 0x00, 0x00, ADC_TEMPERATURE_PIN, #endif @@ -108,7 +108,9 @@ gpio_adc_setup(uint32_t pin) } if (pin == ADC_TEMPERATURE_PIN) { -#if !(CONFIG_MACH_STM32F1 || CONFIG_MACH_STM32F401) +#if CONFIG_MACH_STM32F401 + ADC1_COMMON->CCR = ADC_CCR_TSVREFE; +#elif !CONFIG_MACH_STM32F1 ADC123_COMMON->CCR = ADC_CCR_TSVREFE; #endif } else {