adc: apply adc power API to adc driver

Closes https://github.com/espressif/esp-idf/issues/6269
Closes https://github.com/espressif/esp-idf/issues/6682
This commit is contained in:
Armando
2021-03-26 12:18:31 +08:00
parent 1dfa0e0aa1
commit cc6bfcd9ac
9 changed files with 19 additions and 23 deletions

View File

@@ -43,10 +43,6 @@ void adc_hal_init(void)
adc_ll_digi_set_clk_div(SOC_ADC_DIGI_SAR_CLK_DIV_DEFAULT);
}
void adc_hal_deinit(void)
{
adc_ll_set_power_manage(ADC_POWER_SW_OFF);
}
/*---------------------------------------------------------------
ADC calibration setting
---------------------------------------------------------------*/
@@ -381,6 +377,8 @@ esp_err_t adc_hal_convert(adc_ll_num_t adc_n, int channel, int *out_raw)
adc_hal_onetime_start();
while (!adc_hal_intr_get_raw(event));
ret = adc_hal_single_read(adc_n, out_raw);
//HW workaround: when enabling periph clock, this should be false
adc_ll_onetime_sample_enable(adc_n, false);
return ret;
}

View File

@@ -22,13 +22,10 @@ void adc_hal_digi_deinit(void)
{
adc_ll_digi_clear_pattern_table(ADC_NUM_1);
adc_ll_digi_clear_pattern_table(ADC_NUM_2);
adc_hal_deinit();
}
void adc_hal_digi_controller_config(const adc_digi_config_t *cfg)
{
/* If enable digital controller, adc xpd should always on. */
adc_ll_set_power_manage(ADC_POWER_SW_ON);
/* Single channel mode or multi channel mode. */
adc_ll_digi_set_convert_mode(cfg->conv_mode);
if (cfg->conv_mode & ADC_CONV_SINGLE_UNIT_1) {

View File

@@ -42,7 +42,6 @@ void adc_hal_digi_deinit(void)
adc_ll_digi_filter_reset(ADC_NUM_2);
adc_ll_digi_reset();
adc_ll_digi_controller_clk_disable();
adc_hal_deinit();
}
/**
@@ -62,8 +61,6 @@ void adc_hal_digi_controller_config(const adc_digi_config_t *cfg)
//only one pattern table is supported on C3, but LL still needs one argument.
const int pattern_both = 0;
/* If enable digtal controller, adc xpd should always on. */
adc_ll_set_power_manage(ADC_POWER_SW_ON);
if (cfg->adc_pattern_len) {
adc_ll_digi_clear_pattern_table(pattern_both);
adc_ll_digi_set_pattern_table_len(pattern_both, cfg->adc_pattern_len);

View File

@@ -33,13 +33,10 @@ void adc_hal_digi_deinit(void)
adc_ll_digi_filter_reset(ADC_NUM_2);
adc_ll_digi_reset();
adc_ll_digi_controller_clk_disable();
adc_hal_deinit();
}
void adc_hal_digi_controller_config(const adc_digi_config_t *cfg)
{
/* If enable digtal controller, adc xpd should always on. */
adc_ll_set_power_manage(ADC_POWER_SW_ON);
/* Single channel mode or multi channel mode. */
adc_ll_digi_set_convert_mode(cfg->conv_mode);
if (cfg->conv_mode & ADC_CONV_SINGLE_UNIT_1) {

View File

@@ -61,11 +61,6 @@ typedef struct adc_hal_context_t {
*/
void adc_hal_init(void);
/**
* ADC module deinitialization.
*/
void adc_hal_deinit(void);
/**
* Set ADC module power management.
*