From 2630eefcc462b200c7bf748735387e7b055f300e Mon Sep 17 00:00:00 2001 From: Steven Haigh Date: Sat, 18 Sep 2021 16:33:18 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20STM32=20ADC=20Resolution=20=3D?= =?UTF-8?q?=2012=20bit=20(or=20ADC=5FRESOLUTION)=20(#22789)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/HAL/STM32/HAL.h | 7 ++++++- Marlin/src/HAL/STM32F1/HAL.h | 7 ++++++- ini/stm32-common.ini | 1 - 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index 7a04c9ceeb..a68e8a8c0e 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -183,8 +183,13 @@ static inline int freeMemory() { #define HAL_ANALOG_SELECT(pin) pinMode(pin, INPUT) +#ifdef ADC_RESOLUTION + #define HAL_ADC_RESOLUTION ADC_RESOLUTION +#else + #define HAL_ADC_RESOLUTION 12 +#endif + #define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION ADC_RESOLUTION // 12 #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_READ_ADC() HAL_adc_result #define HAL_ADC_READY() true diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 1d30f43c48..3bdfb9703c 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -237,8 +237,13 @@ static inline int freeMemory() { void HAL_adc_init(); +#ifdef ADC_RESOLUTION + #define HAL_ADC_RESOLUTION ADC_RESOLUTION +#else + #define HAL_ADC_RESOLUTION 12 +#endif + #define HAL_ADC_VREF 3.3 -#define HAL_ADC_RESOLUTION 10 #define HAL_START_ADC(pin) HAL_adc_start_conversion(pin) #define HAL_READ_ADC() HAL_adc_result #define HAL_ADC_READY() true diff --git a/ini/stm32-common.ini b/ini/stm32-common.ini index 1d3f858bf8..54bc746ff4 100644 --- a/ini/stm32-common.ini +++ b/ini/stm32-common.ini @@ -16,7 +16,6 @@ build_flags = ${common.build_flags} -std=gnu++14 -DHAL_STM32 -DUSBCON -DUSBD_USE_CDC -DTIM_IRQ_PRIO=13 - -DADC_RESOLUTION=12 build_unflags = -std=gnu++11 src_filter = ${common.default_src_filter} + + extra_scripts = ${common.extra_scripts}