From 57a5c4684c9f0e9b351fec6efa3fbdc5e03dab6f Mon Sep 17 00:00:00 2001 From: gaoxu Date: Fri, 24 Nov 2023 15:52:59 +0800 Subject: [PATCH] fix(adc): fix adc continuous get less results beacuse do not reset apb clk --- components/esp_adc/adc_continuous.c | 3 +++ components/hal/esp32c6/include/hal/clk_gate_ll.h | 2 +- components/hal/esp32h2/include/hal/clk_gate_ll.h | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/components/esp_adc/adc_continuous.c b/components/esp_adc/adc_continuous.c index 2e86afaeed..12af5c05c3 100644 --- a/components/esp_adc/adc_continuous.c +++ b/components/esp_adc/adc_continuous.c @@ -331,6 +331,9 @@ esp_err_t adc_continuous_start(adc_continuous_handle_t handle) ESP_RETURN_ON_FALSE(handle, ESP_ERR_INVALID_STATE, ADC_TAG, "The driver isn't initialised"); ESP_RETURN_ON_FALSE(handle->fsm == ADC_FSM_INIT, ESP_ERR_INVALID_STATE, ADC_TAG, "ADC continuous mode isn't in the init state, it's started already"); + //reset ADC digital part to reset ADC sampling EOF counter + periph_module_reset(PERIPH_SARADC_MODULE); + if (handle->pm_lock) { ESP_RETURN_ON_ERROR(esp_pm_lock_acquire(handle->pm_lock), ADC_TAG, "acquire pm_lock failed"); } diff --git a/components/hal/esp32c6/include/hal/clk_gate_ll.h b/components/hal/esp32c6/include/hal/clk_gate_ll.h index c8f9f87e19..4e7be20301 100644 --- a/components/hal/esp32c6/include/hal/clk_gate_ll.h +++ b/components/hal/esp32c6/include/hal/clk_gate_ll.h @@ -93,7 +93,7 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en switch (periph) { case PERIPH_SARADC_MODULE: - return PCR_SARADC_RST_EN; + return PCR_SARADC_REG_RST_EN; case PERIPH_RMT_MODULE: return PCR_RMT_RST_EN; case PERIPH_PCNT_MODULE: diff --git a/components/hal/esp32h2/include/hal/clk_gate_ll.h b/components/hal/esp32h2/include/hal/clk_gate_ll.h index 964754cdc3..64fb1475b7 100644 --- a/components/hal/esp32h2/include/hal/clk_gate_ll.h +++ b/components/hal/esp32h2/include/hal/clk_gate_ll.h @@ -101,7 +101,7 @@ static inline uint32_t periph_ll_get_rst_en_mask(periph_module_t periph, bool en switch (periph) { case PERIPH_SARADC_MODULE: - return PCR_SARADC_RST_EN; + return PCR_SARADC_REG_RST_EN; case PERIPH_RMT_MODULE: return PCR_RMT_RST_EN; case PERIPH_PCNT_MODULE: