mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
adc: apply adc power API to adc driver
This commit is contained in:
parent
56cfd0b86b
commit
a129933ccd
@ -156,9 +156,11 @@ void adc_power_on(void) __attribute__((alias("adc_power_on_internal")));
|
||||
|
||||
static void adc_power_off_internal(void)
|
||||
{
|
||||
ADC_ENTER_CRITICAL();
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
adc_hal_set_power_manage(ADC_POWER_SW_OFF);
|
||||
ADC_EXIT_CRITICAL();
|
||||
#else
|
||||
adc_hal_set_power_manage(ADC_POWER_BY_FSM);
|
||||
#endif
|
||||
}
|
||||
|
||||
void adc_power_off(void) __attribute__((alias("adc_power_off_internal")));
|
||||
|
@ -137,6 +137,7 @@ esp_err_t adc_digi_init(void)
|
||||
|
||||
esp_err_t adc_digi_deinit(void)
|
||||
{
|
||||
adc_power_release();
|
||||
ADC_ENTER_CRITICAL();
|
||||
adc_hal_digi_deinit();
|
||||
ADC_EXIT_CRITICAL();
|
||||
@ -145,6 +146,8 @@ esp_err_t adc_digi_deinit(void)
|
||||
|
||||
esp_err_t adc_digi_controller_config(const adc_digi_config_t *config)
|
||||
{
|
||||
/* If enable digital controller, adc xpd should always on. */
|
||||
adc_power_acquire();
|
||||
ADC_ENTER_CRITICAL();
|
||||
adc_hal_digi_controller_config(config);
|
||||
ADC_EXIT_CRITICAL();
|
||||
|
@ -83,6 +83,7 @@ esp_err_t adc_digi_deinit(void)
|
||||
s_adc_digi_arbiter_lock = NULL;
|
||||
}
|
||||
#endif
|
||||
adc_power_release();
|
||||
ADC_ENTER_CRITICAL();
|
||||
adc_hal_digi_deinit();
|
||||
ADC_EXIT_CRITICAL();
|
||||
@ -107,6 +108,8 @@ esp_err_t adc_digi_controller_config(const adc_digi_config_t *config)
|
||||
}
|
||||
#endif //CONFIG_PM_ENABLE
|
||||
|
||||
/* If enable digtal controller, adc xpd should always on. */
|
||||
adc_power_acquire();
|
||||
ADC_ENTER_CRITICAL();
|
||||
adc_hal_digi_controller_config(config);
|
||||
ADC_EXIT_CRITICAL();
|
||||
|
@ -11,11 +11,6 @@
|
||||
*/
|
||||
void adc_hal_init(void);
|
||||
|
||||
/**
|
||||
* ADC module deinitialization.
|
||||
*/
|
||||
void adc_hal_deinit(void);
|
||||
|
||||
/**
|
||||
* Set adc sample cycle.
|
||||
*
|
||||
|
@ -27,13 +27,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) {
|
||||
|
@ -38,7 +38,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();
|
||||
}
|
||||
|
||||
static inline void adc_set_init_code(adc_ll_num_t adc_n, adc_channel_t channel, adc_atten_t atten)
|
||||
@ -49,8 +48,6 @@ static inline void adc_set_init_code(adc_ll_num_t adc_n, adc_channel_t channel,
|
||||
|
||||
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) {
|
||||
|
@ -25,11 +25,6 @@ void adc_hal_init(void)
|
||||
adc_ll_digi_output_invert(ADC_NUM_2, SOC_ADC_DIGI_DATA_INVERT_DEFAULT(ADC_NUM_2));
|
||||
}
|
||||
|
||||
void adc_hal_deinit(void)
|
||||
{
|
||||
adc_ll_set_power_manage(ADC_POWER_SW_OFF);
|
||||
}
|
||||
|
||||
int adc_hal_convert(adc_ll_num_t adc_n, int channel, int *value)
|
||||
{
|
||||
adc_ll_rtc_enable_channel(adc_n, channel);
|
||||
|
Loading…
x
Reference in New Issue
Block a user