From 876c3ffffdce78b1cdc976b572fe1eca9b97fe44 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 13 Dec 2022 00:07:20 -0500 Subject: [PATCH] stm32: No need to use hardware oversampling in stm32h7_adc.c Not all chips implement hardware oversampling. The software already implements oversampling, and additional hardware oversampling is unlikely to improve results. Remove the hardware oversampling to simplify the code. Signed-off-by: Kevin O'Connor --- src/stm32/stm32h7_adc.c | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/src/stm32/stm32h7_adc.c b/src/stm32/stm32h7_adc.c index 61e0c764..3100d205 100644 --- a/src/stm32/stm32h7_adc.c +++ b/src/stm32/stm32h7_adc.c @@ -24,11 +24,6 @@ #if CONFIG_MACH_STM32H723 #define PCSEL PCSEL_RES0 #endif - - // Number of samples is 2^OVERSAMPLES_EXPONENT (exponent can be 0-10) - #define OVERSAMPLES_EXPONENT 3 - #define OVERSAMPLES (1 << OVERSAMPLES_EXPONENT) - #elif CONFIG_MACH_STM32L4 #define ADCIN_BANK_SIZE (19) #define RCC_AHBENR_ADC (RCC->AHB2ENR) @@ -37,9 +32,6 @@ #define ADC_ATICKS (0b100) #define ADC_RES (0b00) #define ADC_TS (ADC12_COMMON) - - #define OVERSAMPLES (0) - #elif CONFIG_MACH_STM32G4 #define ADCIN_BANK_SIZE (19) #define RCC_AHBENR_ADC (RCC->AHB2ENR) @@ -49,8 +41,6 @@ #define ADC_RES (0b00) #define ADC_TS (ADC12_COMMON) #define ADC_CCR_TSEN (ADC_CCR_VSENSESEL) - - #define OVERSAMPLES (0) #endif #define ADC_TEMPERATURE_PIN 0xfe @@ -301,21 +291,6 @@ gpio_adc_setup(uint32_t pin) if (!is_stm32h723_adc3) { MODIFY_REG(adc->CFGR, ADC_CFGR_RES_Msk, ADC_RES<CFGR2, ADC_CFGR2_ROVSE_Msk, ADC_CFGR2_ROVSE); - if (is_stm32h723_adc3) { -#ifdef ADC3_CFGR2_OVSR - MODIFY_REG(adc->CFGR2, ADC3_CFGR2_OVSR_Msk, - (OVERSAMPLES_EXPONENT - 1) << ADC3_CFGR2_OVSR_Pos); -#endif - } else { - MODIFY_REG(adc->CFGR2, ADC_CFGR2_OVSR_Msk, - (OVERSAMPLES - 1) << ADC_CFGR2_OVSR_Pos); - } - MODIFY_REG(adc->CFGR2, ADC_CFGR2_OVSS_Msk, - OVERSAMPLES_EXPONENT << ADC_CFGR2_OVSS_Pos); -#endif } if (pin == ADC_TEMPERATURE_PIN) {