adc: fixed the issue that ADC power is left on after the calibration is done

Also refactor the locks in the adc_common.c file.
This commit is contained in:
Michael (XIAO Xufeng)
2021-02-01 01:12:28 +08:00
parent 0700129c5a
commit 351ba5ff9e
6 changed files with 157 additions and 125 deletions

View File

@@ -828,10 +828,13 @@ static uint32_t adc_get_calibration_offset(adc_ll_num_t adc_n, adc_channel_t cha
s_adc_cali_param[0][atten] = init_code;
s_adc_cali_param[1][atten] = init_code;
} else {
const bool internal_gnd = true;
adc_power_acquire();
ADC_ENTER_CRITICAL();
const bool internal_gnd = true;
init_code = adc_hal_self_calibration(adc_n, channel, atten, internal_gnd);
ADC_EXIT_CRITICAL();
adc_power_release();
ESP_LOGD(ADC_TAG, "Calib(V%d) ADC%d atten=%d: %04X", version, adc_n, atten, init_code);
s_adc_cali_param[adc_n][atten] = init_code;
}