feat(adc): move adc periph enable/reset functions to ll layer

This commit is contained in:
gaoxu
2024-03-28 15:19:45 +08:00
committed by Gao Xu
parent c1edeca849
commit 6d82c324bb
14 changed files with 209 additions and 46 deletions
+3 -1
View File
@@ -245,7 +245,9 @@ esp_err_t adc_continuous_start(adc_continuous_handle_t handle)
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);
ADC_BUS_CLK_ATOMIC() {
adc_ll_reset_register();
}
if (handle->pm_lock) {
ESP_RETURN_ON_ERROR(esp_pm_lock_acquire(handle->pm_lock), ADC_TAG, "acquire pm_lock failed");
-7
View File
@@ -115,7 +115,6 @@ esp_err_t adc_oneshot_new_unit(const adc_oneshot_unit_init_cfg_t *init_config, a
};
adc_oneshot_hal_init(&(unit->hal), &config);
#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
//To enable the APB_SARADC periph if needed
_lock_acquire(&s_ctx.mutex);
s_ctx.apb_periph_ref_cnts++;
@@ -123,12 +122,6 @@ esp_err_t adc_oneshot_new_unit(const adc_oneshot_unit_init_cfg_t *init_config, a
adc_apb_periph_claim();
}
_lock_release(&s_ctx.mutex);
#endif
//TODO: refactor clock enable/reset functions, add adc_digi_clk_enable/reset and adc_rtc_clk_enable/reset
#if CONFIG_IDF_TARGET_ESP32P4
adc_ll_rtc_reset();
#endif
if (init_config->ulp_mode == ADC_ULP_MODE_DISABLE) {
sar_periph_ctrl_adc_oneshot_power_acquire();
@@ -28,6 +28,7 @@ __attribute__((unused)) static const char *TAG = "TEST_ADC";
#define TEST_STD_ADC1_CHANNEL0 ADC_CHANNEL_2
#endif
#if !CONFIG_IDF_TARGET_ESP32P4 // TODO: IDF-6497
static int s_adc_count_size;
static int *s_p_adc_count;
static int s_adc_offset = -1;
@@ -131,6 +132,8 @@ static float s_print_summary(bool figure)
return sqrt(variation_square / count);
}
#endif
#if SOC_ADC_DMA_SUPPORTED
/*---------------------------------------------------------------
ADC Continuous Average / STD_Deviation Test