fix(adc): fix P4 ADC2 oneshot error and refactor apb claim macor

This commit is contained in:
gaoxu
2025-06-17 18:48:28 +08:00
parent 704a4fd610
commit 216cf17fc1
10 changed files with 45 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -16,6 +16,7 @@
#include "hal/adc_hal.h"
#include "hal/adc_hal_common.h"
#include "soc/adc_periph.h"
#include "hal/adc_ll.h"
static const char *TAG = "adc_common";
@@ -56,9 +57,12 @@ esp_err_t adc_channel_to_io(adc_unit_t unit_id, adc_channel_t channel, int * con
---------------------------------------------------------------*/
static __attribute__((constructor)) void adc_hw_calibration(void)
{
adc_apb_periph_claim();
//Calculate all ICode
for (int i = 0; i < SOC_ADC_PERIPH_NUM; i++) {
if (ADC_LL_NEED_APB_PERIPH_CLAIM(i)) {
adc_apb_periph_claim();
}
adc_hal_calibration_init(i);
for (int j = 0; j < SOC_ADC_ATTEN_NUM; j++) {
/**
@@ -73,7 +77,9 @@ static __attribute__((constructor)) void adc_hw_calibration(void)
}
#endif
}
if (ADC_LL_NEED_APB_PERIPH_CLAIM(i)) {
adc_apb_periph_free();
}
}
adc_apb_periph_free();
}
#endif //#if SOC_ADC_CALIBRATION_V1_SUPPORTED