diff --git a/components/efuse/esp32c5/esp_efuse_rtc_calib.c b/components/efuse/esp32c5/esp_efuse_rtc_calib.c index d32944996bb..8edc3973bb0 100644 --- a/components/efuse/esp32c5/esp_efuse_rtc_calib.c +++ b/components/efuse/esp32c5/esp_efuse_rtc_calib.c @@ -9,6 +9,7 @@ #include "esp_efuse_table.h" #include "esp_efuse_rtc_calib.h" #include "hal/efuse_hal.h" +#include "hal/adc_ll.h" /** * @brief Get the signed value by the raw data that read from eFuse @@ -61,7 +62,7 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_ { /* Version validation should be guaranteed in the caller */ assert(atten < 4); - assert(adc_channel < SOC_ADC_CHANNEL_NUM(adc_unit)); + assert(adc_channel < ADC_LL_CHANNEL_NUM(adc_unit)); assert(adc_unit == 0); const esp_efuse_desc_t** chan_diff_efuse = NULL; diff --git a/components/efuse/esp32c6/esp_efuse_rtc_calib.c b/components/efuse/esp32c6/esp_efuse_rtc_calib.c index 5b1fba2914f..16e0ce9b41f 100644 --- a/components/efuse/esp32c6/esp_efuse_rtc_calib.c +++ b/components/efuse/esp32c6/esp_efuse_rtc_calib.c @@ -9,6 +9,7 @@ #include "esp_efuse_table.h" #include "esp_efuse_rtc_calib.h" #include "hal/efuse_hal.h" +#include "hal/adc_ll.h" /** * @brief Get the signed value by the raw data that read from eFuse @@ -61,7 +62,7 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_ { /* Version validation should be guaranteed in the caller */ assert(atten < 4); - assert(adc_channel < SOC_ADC_CHANNEL_NUM(adc_unit)); + assert(adc_channel < ADC_LL_CHANNEL_NUM(adc_unit)); const esp_efuse_desc_t** chan_diff_efuse = NULL; switch (adc_channel) { diff --git a/components/efuse/esp32c61/esp_efuse_rtc_calib.c b/components/efuse/esp32c61/esp_efuse_rtc_calib.c index b93feceb241..08c9b57e8d2 100644 --- a/components/efuse/esp32c61/esp_efuse_rtc_calib.c +++ b/components/efuse/esp32c61/esp_efuse_rtc_calib.c @@ -9,6 +9,7 @@ #include "esp_efuse_table.h" #include "esp_efuse_rtc_calib.h" #include "hal/efuse_hal.h" +#include "hal/adc_ll.h" /** * @brief Get the signed value by the raw data that read from eFuse @@ -60,7 +61,7 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_ { /* Version validation should be guaranteed in the caller */ assert(atten < 4); - assert(adc_channel < SOC_ADC_CHANNEL_NUM(adc_unit)); + assert(adc_channel < ADC_LL_CHANNEL_NUM(adc_unit)); assert(adc_unit == 0); const esp_efuse_desc_t** chan_diff_efuse = NULL; diff --git a/components/efuse/esp32h2/esp_efuse_rtc_calib.c b/components/efuse/esp32h2/esp_efuse_rtc_calib.c index d3cbf8e5a68..580abaabeac 100644 --- a/components/efuse/esp32h2/esp_efuse_rtc_calib.c +++ b/components/efuse/esp32h2/esp_efuse_rtc_calib.c @@ -9,6 +9,7 @@ #include "esp_efuse_table.h" #include "esp_efuse_rtc_calib.h" #include "hal/efuse_hal.h" +#include "hal/adc_ll.h" /** * @brief Get the signed value by the raw data that read from eFuse @@ -59,7 +60,7 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_ { /* Version validation should be guaranteed in the caller */ assert(atten < 4); - assert(adc_channel < SOC_ADC_CHANNEL_NUM(adc_unit)); + assert(adc_channel < ADC_LL_CHANNEL_NUM(adc_unit)); const esp_efuse_desc_t** chan_diff_efuse = NULL; switch (adc_channel) { diff --git a/components/efuse/esp32p4/esp_efuse_rtc_calib.c b/components/efuse/esp32p4/esp_efuse_rtc_calib.c index 57fe61f3f09..3c253c7e712 100644 --- a/components/efuse/esp32p4/esp_efuse_rtc_calib.c +++ b/components/efuse/esp32p4/esp_efuse_rtc_calib.c @@ -9,6 +9,7 @@ #include "esp_efuse_table.h" #include "esp_efuse_rtc_calib.h" #include "hal/efuse_hal.h" +#include "hal/adc_ll.h" #include "hal/adc_types.h" /** @@ -132,7 +133,7 @@ int esp_efuse_rtc_calib_get_chan_compens(int version, uint32_t adc_unit, uint32_ { /* Version validation should be guaranteed in the caller */ assert(atten < 4); - assert(adc_channel < SOC_ADC_CHANNEL_NUM(adc_unit)); + assert(adc_channel < ADC_LL_CHANNEL_NUM(adc_unit)); const esp_efuse_desc_t** chan_diff_efuse = NULL; if (adc_unit == ADC_UNIT_1) { diff --git a/components/esp_adc/adc_cali_curve_fitting.c b/components/esp_adc/adc_cali_curve_fitting.c index 9b6ec42d679..c3b1e902fd2 100644 --- a/components/esp_adc/adc_cali_curve_fitting.c +++ b/components/esp_adc/adc_cali_curve_fitting.c @@ -222,7 +222,7 @@ static esp_err_t check_valid(const adc_cali_curve_fitting_config_t *config) { ESP_RETURN_ON_FALSE(config->unit_id < SOC_ADC_PERIPH_NUM, ESP_ERR_INVALID_ARG, TAG, "invalid ADC unit"); ESP_RETURN_ON_FALSE(config->atten < SOC_ADC_ATTEN_NUM, ESP_ERR_INVALID_ARG, TAG, "invalid ADC attenuation"); - ESP_RETURN_ON_FALSE(config->chan < SOC_ADC_CHANNEL_NUM(config->unit_id), ESP_ERR_INVALID_ARG, TAG, "invalid ADC channel"); + ESP_RETURN_ON_FALSE(config->chan < ADC_LL_CHANNEL_NUM(config->unit_id), ESP_ERR_INVALID_ARG, TAG, "invalid ADC channel"); bool available_oneshot_bitwidth = (config->bitwidth >= ADC_LL_RTC_MIN_BITWIDTH && config->bitwidth <= ADC_LL_RTC_MAX_BITWIDTH); bool available_dma_bitwidth = (config->bitwidth >= SOC_ADC_DIGI_MIN_BITWIDTH && config->bitwidth <= SOC_ADC_DIGI_MAX_BITWIDTH); diff --git a/components/esp_adc/adc_common.c b/components/esp_adc/adc_common.c index 4f83de058fa..62818c530a1 100644 --- a/components/esp_adc/adc_common.c +++ b/components/esp_adc/adc_common.c @@ -45,7 +45,7 @@ esp_err_t adc_io_to_channel(int io_num, adc_unit_t * const unit_id, adc_channel_ esp_err_t adc_channel_to_io(adc_unit_t unit_id, adc_channel_t channel, int * const io_num) { ESP_RETURN_ON_FALSE(unit_id < SOC_ADC_PERIPH_NUM, ESP_ERR_INVALID_ARG, TAG, "invalid unit"); - ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(unit_id), ESP_ERR_INVALID_ARG, TAG, "invalid channel"); + ESP_RETURN_ON_FALSE(channel < ADC_LL_CHANNEL_NUM(unit_id), ESP_ERR_INVALID_ARG, TAG, "invalid channel"); ESP_RETURN_ON_FALSE(io_num, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); *io_num = adc_channel_io_map[unit_id][channel]; @@ -74,7 +74,7 @@ static __attribute__((constructor)) void adc_hw_calibration(void) adc_calc_hw_calibration_code(i, j); #if SOC_ADC_CALIB_CHAN_COMPENS_SUPPORTED /* Load the channel compensation from efuse */ - for (int k = 0; k < SOC_ADC_CHANNEL_NUM(i); k++) { + for (int k = 0; k < ADC_LL_CHANNEL_NUM(i); k++) { adc_load_hw_calibration_chan_compens(i, k, j); } #endif diff --git a/components/esp_adc/adc_continuous.c b/components/esp_adc/adc_continuous.c index ca764107ba7..97b8395a1b9 100644 --- a/components/esp_adc/adc_continuous.c +++ b/components/esp_adc/adc_continuous.c @@ -617,18 +617,18 @@ esp_err_t adc_continuous_parse_data(adc_continuous_handle_t handle, parsed_data[i].unit = ADC_UNIT_1; parsed_data[i].channel = p->type1.channel; parsed_data[i].raw_data = p->type1.data; - parsed_data[i].valid = (parsed_data[i].channel < SOC_ADC_CHANNEL_NUM(parsed_data[i].unit)); + parsed_data[i].valid = (parsed_data[i].channel < ADC_LL_CHANNEL_NUM(parsed_data[i].unit)); #elif CONFIG_IDF_TARGET_ESP32S2 if (handle->format == ADC_DIGI_OUTPUT_FORMAT_TYPE2) { parsed_data[i].unit = p->type2.unit ? ADC_UNIT_2 : ADC_UNIT_1; parsed_data[i].channel = p->type2.channel; parsed_data[i].raw_data = p->type2.data; - parsed_data[i].valid = (parsed_data[i].channel < SOC_ADC_CHANNEL_NUM(parsed_data[i].unit)); + parsed_data[i].valid = (parsed_data[i].channel < ADC_LL_CHANNEL_NUM(parsed_data[i].unit)); } else if (handle->format == ADC_DIGI_OUTPUT_FORMAT_TYPE1) { parsed_data[i].unit = handle->use_adc1 ? ADC_UNIT_1 : ADC_UNIT_2; parsed_data[i].channel = p->type1.channel; parsed_data[i].raw_data = p->type1.data; - parsed_data[i].valid = (parsed_data[i].channel < SOC_ADC_CHANNEL_NUM(parsed_data[i].unit)); + parsed_data[i].valid = (parsed_data[i].channel < ADC_LL_CHANNEL_NUM(parsed_data[i].unit)); } #else #if CONFIG_SOC_ADC_PERIPH_NUM == 1 @@ -638,7 +638,7 @@ esp_err_t adc_continuous_parse_data(adc_continuous_handle_t handle, #endif parsed_data[i].channel = (parsed_data[i].unit == ADC_UNIT_2) ? p->type2.channel - ADC_LL_UNIT2_CHANNEL_SUBSTRATION : p->type2.channel; parsed_data[i].raw_data = p->type2.data; - parsed_data[i].valid = (parsed_data[i].channel < SOC_ADC_CHANNEL_NUM(parsed_data[i].unit)); + parsed_data[i].valid = (parsed_data[i].channel < ADC_LL_CHANNEL_NUM(parsed_data[i].unit)); #endif } diff --git a/components/esp_adc/adc_oneshot.c b/components/esp_adc/adc_oneshot.c index abdce4c5d5e..898c14dc45f 100644 --- a/components/esp_adc/adc_oneshot.c +++ b/components/esp_adc/adc_oneshot.c @@ -198,7 +198,7 @@ esp_err_t adc_oneshot_config_channel(adc_oneshot_unit_handle_t handle, adc_chann ESP_RETURN_ON_FALSE(handle && config, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); ESP_RETURN_ON_FALSE(config->atten < SOC_ADC_ATTEN_NUM, ESP_ERR_INVALID_ARG, TAG, "invalid attenuation"); ESP_RETURN_ON_FALSE(((config->bitwidth >= ADC_LL_RTC_MIN_BITWIDTH && config->bitwidth <= ADC_LL_RTC_MAX_BITWIDTH) || config->bitwidth == ADC_BITWIDTH_DEFAULT), ESP_ERR_INVALID_ARG, TAG, "invalid bitwidth"); - ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(handle->unit_id), ESP_ERR_INVALID_ARG, TAG, "invalid channel"); + ESP_RETURN_ON_FALSE(channel < ADC_LL_CHANNEL_NUM(handle->unit_id), ESP_ERR_INVALID_ARG, TAG, "invalid channel"); ESP_RETURN_ON_ERROR(s_adc_io_init(handle->unit_id, channel), TAG, "adc io init failed"); @@ -220,7 +220,7 @@ esp_err_t adc_oneshot_config_channel(adc_oneshot_unit_handle_t handle, adc_chann esp_err_t adc_oneshot_read(adc_oneshot_unit_handle_t handle, adc_channel_t chan, int *out_raw) { ESP_RETURN_ON_FALSE(handle && out_raw, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); - ESP_RETURN_ON_FALSE(chan < SOC_ADC_CHANNEL_NUM(handle->unit_id), ESP_ERR_INVALID_ARG, TAG, "invalid channel"); + ESP_RETURN_ON_FALSE(chan < ADC_LL_CHANNEL_NUM(handle->unit_id), ESP_ERR_INVALID_ARG, TAG, "invalid channel"); if (adc_lock_try_acquire(handle->unit_id) != ESP_OK) { return ESP_ERR_TIMEOUT; @@ -254,7 +254,7 @@ esp_err_t adc_oneshot_read_isr(adc_oneshot_unit_handle_t handle, adc_channel_t c { ESP_RETURN_ON_FALSE_ISR(handle && out_raw, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); ESP_RETURN_ON_FALSE_ISR(out_raw, ESP_ERR_INVALID_ARG, TAG, "invalid argument: null pointer"); - ESP_RETURN_ON_FALSE_ISR(chan < SOC_ADC_CHANNEL_NUM(handle->unit_id), ESP_ERR_INVALID_ARG, TAG, "invalid channel"); + ESP_RETURN_ON_FALSE_ISR(chan < ADC_LL_CHANNEL_NUM(handle->unit_id), ESP_ERR_INVALID_ARG, TAG, "invalid channel"); portENTER_CRITICAL_SAFE(&rtc_spinlock); @@ -344,7 +344,7 @@ esp_err_t adc_oneshot_get_calibrated_result(adc_oneshot_unit_handle_t handle, ad static esp_err_t s_adc_io_init(adc_unit_t unit, adc_channel_t channel) { - ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(unit), ESP_ERR_INVALID_ARG, TAG, "invalid channel"); + ESP_RETURN_ON_FALSE(channel < ADC_LL_CHANNEL_NUM(unit), ESP_ERR_INVALID_ARG, TAG, "invalid channel"); return gpio_config_as_analog(ADC_GET_IO_NUM(unit, channel)); } diff --git a/components/esp_adc/test_apps/adc/main/test_adc_driver.c b/components/esp_adc/test_apps/adc/main/test_adc_driver.c index 92deafbf399..7a38f14f315 100644 --- a/components/esp_adc/test_apps/adc/main/test_adc_driver.c +++ b/components/esp_adc/test_apps/adc/main/test_adc_driver.c @@ -14,6 +14,7 @@ #include "esp_rom_sys.h" #include "esp_adc/adc_oneshot.h" #include "test_common_adc.h" +#include "hal/adc_ll.h" #include "esp_adc/adc_continuous.h" #include "esp_adc/adc_filter.h" @@ -295,7 +296,7 @@ TEST_CASE("ADC continuous test after restarting", "[adc_continuous][ignore]") for (int i = 0; i < ret_num; i += SOC_ADC_DIGI_RESULT_BYTES) { adc_digi_output_data_t *p = (void*)&result[i]; uint32_t chan_num = ADC_DRIVER_TEST_GET_CHANNEL(p); - TEST_ASSERT(chan_num < SOC_ADC_CHANNEL_NUM(ADC_UNIT_1)); + TEST_ASSERT(chan_num < ADC_LL_CHANNEL_NUM(ADC_UNIT_1)); } TEST_ESP_OK(adc_continuous_stop(handle)); } diff --git a/components/esp_adc/test_apps/adc/main/test_adc_tsens.c b/components/esp_adc/test_apps/adc/main/test_adc_tsens.c index a2072afeec1..512fd6c41cf 100644 --- a/components/esp_adc/test_apps/adc/main/test_adc_tsens.c +++ b/components/esp_adc/test_apps/adc/main/test_adc_tsens.c @@ -18,6 +18,7 @@ #include "esp_event.h" #include "esp_wifi.h" #include "test_common_adc.h" +#include "hal/adc_ll.h" #include "test_utils.h" #if SOC_TEMP_SENSOR_SUPPORTED && SOC_ADC_SUPPORTED @@ -138,7 +139,7 @@ TEST_CASE("Test temperature sensor work with ADC continuous", "[adc]") for (int i = 0; i < ret_num; i += SOC_ADC_DIGI_RESULT_BYTES) { adc_digi_output_data_t *p = (void*)&result[i]; uint32_t chan_num = ADC_DRIVER_TEST_GET_CHANNEL(p); - TEST_ASSERT(chan_num < SOC_ADC_CHANNEL_NUM(ADC_UNIT_1)); + TEST_ASSERT(chan_num < ADC_LL_CHANNEL_NUM(ADC_UNIT_1)); } //Temperature sensor work after ADC continuous read diff --git a/components/esp_adc/test_apps/adc/main/test_common_adc.c b/components/esp_adc/test_apps/adc/main/test_common_adc.c index 60a001ba19a..a1ccd47406c 100644 --- a/components/esp_adc/test_apps/adc/main/test_common_adc.c +++ b/components/esp_adc/test_apps/adc/main/test_common_adc.c @@ -99,7 +99,7 @@ void test_adc_calibration_deinit(adc_cali_handle_t handle) void test_adc_set_io_level(adc_unit_t unit, adc_channel_t channel, bool level) { - TEST_ASSERT(channel < SOC_ADC_CHANNEL_NUM(unit) && "invalid channel"); + TEST_ASSERT(channel < ADC_LL_CHANNEL_NUM(unit) && "invalid channel"); uint32_t io_num = ADC_GET_IO_NUM(unit, channel); TEST_ESP_OK(gpio_set_pull_mode(io_num, (level ? GPIO_PULLUP_ONLY : GPIO_PULLDOWN_ONLY))); @@ -118,7 +118,7 @@ void test_adc_set_io_level(adc_unit_t unit, adc_channel_t channel, bool level) void test_adc_set_io_middle(adc_unit_t unit, adc_channel_t channel) { - TEST_ASSERT(channel < SOC_ADC_CHANNEL_NUM(unit) && "invalid channel"); + TEST_ASSERT(channel < ADC_LL_CHANNEL_NUM(unit) && "invalid channel"); uint32_t io_num = ADC_GET_IO_NUM(unit, channel); TEST_ESP_OK(gpio_set_pull_mode(io_num, GPIO_PULLUP_PULLDOWN)); @@ -133,7 +133,7 @@ void test_adc_set_io_middle(adc_unit_t unit, adc_channel_t channel) void test_assert_adc_raw(adc_unit_t unit, adc_channel_t channel, bool level, int raw, bool dma_mode, bool loose_thresh) { - TEST_ASSERT(channel < SOC_ADC_CHANNEL_NUM(unit) && "invalid channel"); + TEST_ASSERT(channel < ADC_LL_CHANNEL_NUM(unit) && "invalid channel"); #if defined ADC_TEST_HIGH_VAL_DMA int expected_value = level ? (dma_mode ? ADC_TEST_HIGH_VAL_DMA : ADC_TEST_HIGH_VAL) : ADC_TEST_LOW_VAL; diff --git a/components/esp_hal_ana_conv/esp32/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32/include/hal/adc_ll.h index ccc2e81db90..476bb80d611 100644 --- a/components/esp_hal_ana_conv/esp32/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32/include/hal/adc_ll.h @@ -32,6 +32,7 @@ extern "C" { #define ADC_LL_UNIT2_CHANNEL_SUBSTRATION 0 #define ADC_LL_MAX_CHANNEL_NUM (10) +#define ADC_LL_CHANNEL_NUM(unit_id) (((unit_id) == ADC_UNIT_1) ? 8 : 10) /*--------------------------------------------------------------- * oneshot diff --git a/components/esp_hal_ana_conv/esp32c2/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32c2/include/hal/adc_ll.h index e8f41cb8bd3..8c35c327b98 100644 --- a/components/esp_hal_ana_conv/esp32c2/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32c2/include/hal/adc_ll.h @@ -34,6 +34,7 @@ extern "C" { #define ADC_LL_NEED_APB_PERIPH_CLAIM(ADC_UNIT) (1) #define ADC_LL_MAX_CHANNEL_NUM (5) +#define ADC_LL_CHANNEL_NUM(unit_id) (5) /*--------------------------------------------------------------- * oneshot diff --git a/components/esp_hal_ana_conv/esp32c3/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32c3/include/hal/adc_ll.h index acd727dc855..41a480c1757 100644 --- a/components/esp_hal_ana_conv/esp32c3/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32c3/include/hal/adc_ll.h @@ -44,6 +44,7 @@ extern "C" { #define ADC_LL_UNIT2_CHANNEL_SUBSTRATION 0 #define ADC_LL_MAX_CHANNEL_NUM (5) +#define ADC_LL_CHANNEL_NUM(unit_id) (((unit_id) == ADC_UNIT_1) ? 5 : 1) /*--------------------------------------------------------------- * oneshot diff --git a/components/esp_hal_ana_conv/esp32c5/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32c5/include/hal/adc_ll.h index 65729701213..9ae1b4ea92b 100644 --- a/components/esp_hal_ana_conv/esp32c5/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32c5/include/hal/adc_ll.h @@ -46,6 +46,7 @@ extern "C" { #define ADC_LL_UNIT2_CHANNEL_SUBSTRATION 0 #define ADC_LL_MAX_CHANNEL_NUM (6) +#define ADC_LL_CHANNEL_NUM(unit_id) (6) /*--------------------------------------------------------------- * oneshot diff --git a/components/esp_hal_ana_conv/esp32c6/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32c6/include/hal/adc_ll.h index 4ddad98a5b9..f5f7ead4c82 100644 --- a/components/esp_hal_ana_conv/esp32c6/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32c6/include/hal/adc_ll.h @@ -46,6 +46,7 @@ extern "C" { #define ADC_LL_UNIT2_CHANNEL_SUBSTRATION 0 #define ADC_LL_MAX_CHANNEL_NUM (7) +#define ADC_LL_CHANNEL_NUM(unit_id) (7) /*--------------------------------------------------------------- * oneshot diff --git a/components/esp_hal_ana_conv/esp32c61/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32c61/include/hal/adc_ll.h index 68bad7a24b3..0c61a44565a 100644 --- a/components/esp_hal_ana_conv/esp32c61/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32c61/include/hal/adc_ll.h @@ -46,6 +46,7 @@ extern "C" { #define ADC_LL_UNIT2_CHANNEL_SUBSTRATION 0 #define ADC_LL_MAX_CHANNEL_NUM (4) +#define ADC_LL_CHANNEL_NUM(unit_id) (4) /*--------------------------------------------------------------- * oneshot diff --git a/components/esp_hal_ana_conv/esp32h2/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32h2/include/hal/adc_ll.h index e39532e69e3..ba0688f5c6f 100644 --- a/components/esp_hal_ana_conv/esp32h2/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32h2/include/hal/adc_ll.h @@ -45,6 +45,7 @@ extern "C" { #define ADC_LL_UNIT2_CHANNEL_SUBSTRATION 0 #define ADC_LL_MAX_CHANNEL_NUM (5) +#define ADC_LL_CHANNEL_NUM(unit_id) (5) /*--------------------------------------------------------------- * oneshot diff --git a/components/esp_hal_ana_conv/esp32h21/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32h21/include/hal/adc_ll.h index e6f427c0c76..4430f0b8f6a 100644 --- a/components/esp_hal_ana_conv/esp32h21/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32h21/include/hal/adc_ll.h @@ -45,6 +45,7 @@ extern "C" { #define ADC_LL_UNIT2_CHANNEL_SUBSTRATION 0 #define ADC_LL_MAX_CHANNEL_NUM (5) +#define ADC_LL_CHANNEL_NUM(unit_id) (5) /*--------------------------------------------------------------- * oneshot diff --git a/components/esp_hal_ana_conv/esp32h4/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32h4/include/hal/adc_ll.h index 58937d3914a..e7b6c20503b 100644 --- a/components/esp_hal_ana_conv/esp32h4/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32h4/include/hal/adc_ll.h @@ -45,6 +45,7 @@ extern "C" { #define ADC_LL_UNIT2_CHANNEL_SUBSTRATION 0 #define ADC_LL_MAX_CHANNEL_NUM (5) +#define ADC_LL_CHANNEL_NUM(unit_id) (5) /*--------------------------------------------------------------- * oneshot diff --git a/components/esp_hal_ana_conv/esp32p4/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32p4/include/hal/adc_ll.h index b674ad5c9a1..fc2d5987096 100644 --- a/components/esp_hal_ana_conv/esp32p4/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32p4/include/hal/adc_ll.h @@ -39,6 +39,7 @@ extern "C" { // ESP32P4 ADC2 channel is 2-7, so we need to subtract 2 to get the correct channel #define ADC_LL_UNIT2_CHANNEL_SUBSTRATION 2 #define ADC_LL_MAX_CHANNEL_NUM (8) +#define ADC_LL_CHANNEL_NUM(unit_id) (((unit_id) == ADC_UNIT_1) ? 8 : 6) #define ADC_LL_NEED_APB_PERIPH_CLAIM(ADC_UNIT) (((ADC_UNIT) == ADC_UNIT_1) ? 0 : 1) diff --git a/components/esp_hal_ana_conv/esp32s2/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32s2/include/hal/adc_ll.h index b036be24de9..26388d080a8 100644 --- a/components/esp_hal_ana_conv/esp32s2/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32s2/include/hal/adc_ll.h @@ -42,6 +42,7 @@ extern "C" { #define ADC_LL_UNIT2_CHANNEL_SUBSTRATION 0 #define ADC_LL_MAX_CHANNEL_NUM (10) +#define ADC_LL_CHANNEL_NUM(unit_id) (10) /*--------------------------------------------------------------- * oneshot diff --git a/components/esp_hal_ana_conv/esp32s3/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32s3/include/hal/adc_ll.h index 3c3493b7e3a..c0ab0380ed9 100644 --- a/components/esp_hal_ana_conv/esp32s3/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32s3/include/hal/adc_ll.h @@ -44,6 +44,7 @@ extern "C" { #define ADC_LL_UNIT2_CHANNEL_SUBSTRATION 0 #define ADC_LL_MAX_CHANNEL_NUM (10) +#define ADC_LL_CHANNEL_NUM(unit_id) (10) /*--------------------------------------------------------------- * oneshot diff --git a/components/esp_hal_ana_conv/esp32s31/include/hal/adc_ll.h b/components/esp_hal_ana_conv/esp32s31/include/hal/adc_ll.h index 941cf558109..58662b27938 100644 --- a/components/esp_hal_ana_conv/esp32s31/include/hal/adc_ll.h +++ b/components/esp_hal_ana_conv/esp32s31/include/hal/adc_ll.h @@ -34,6 +34,7 @@ extern "C" { #define ADC_LL_NEED_APB_PERIPH_CLAIM(ADC_UNIT) (1) #define ADC_LL_UNIT2_CHANNEL_SUBSTRATION (0) #define ADC_LL_MAX_CHANNEL_NUM (8) +#define ADC_LL_CHANNEL_NUM(unit_id) (8) #define ADC_LL_DMA_USE_LP_AHB_GDMA 1 diff --git a/components/soc/esp32/include/soc/soc_caps.h b/components/soc/esp32/include/soc/soc_caps.h index 90a4f80e017..c1f66e754d0 100644 --- a/components/soc/esp32/include/soc/soc_caps.h +++ b/components/soc/esp32/include/soc/soc_caps.h @@ -132,7 +132,6 @@ #define SOC_ADC_DIG_CTRL_SUPPORTED 1 #define SOC_ADC_DMA_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (2) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) ((PERIPH_NUM==0)? 8: 10) #define SOC_ADC_ATTEN_NUM (4) /*!< Digital */ diff --git a/components/soc/esp32c2/include/soc/soc_caps.h b/components/soc/esp32c2/include/soc/soc_caps.h index d4cc4c3c40c..7b005d0030f 100644 --- a/components/soc/esp32c2/include/soc/soc_caps.h +++ b/components/soc/esp32c2/include/soc/soc_caps.h @@ -71,7 +71,6 @@ #define SOC_ADC_DIG_IIR_FILTER_SUPPORTED 1 #define SOC_ADC_MONITOR_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (1U) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) (5) #define SOC_ADC_ATTEN_NUM (4) /*!< Digital */ diff --git a/components/soc/esp32c3/include/soc/soc_caps.h b/components/soc/esp32c3/include/soc/soc_caps.h index 26194432be5..d10510aa1db 100644 --- a/components/soc/esp32c3/include/soc/soc_caps.h +++ b/components/soc/esp32c3/include/soc/soc_caps.h @@ -98,7 +98,6 @@ #define SOC_ADC_MONITOR_SUPPORTED 1 #define SOC_ADC_DMA_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (2) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) ((PERIPH_NUM==0)? 5 : 1) #define SOC_ADC_ATTEN_NUM (4) /*!< Digital */ diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index 9b7f1644588..3d481cb6f68 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -125,7 +125,6 @@ #define SOC_ADC_MONITOR_SUPPORTED 1 #define SOC_ADC_DMA_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (1U) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) (6) #define SOC_ADC_ATTEN_NUM (4) /*!< Digital */ diff --git a/components/soc/esp32c6/include/soc/soc_caps.h b/components/soc/esp32c6/include/soc/soc_caps.h index 1b463aee503..dd5cf8b57f6 100644 --- a/components/soc/esp32c6/include/soc/soc_caps.h +++ b/components/soc/esp32c6/include/soc/soc_caps.h @@ -110,7 +110,6 @@ #define SOC_ADC_MONITOR_SUPPORTED 1 #define SOC_ADC_DMA_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (1U) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) (7) #define SOC_ADC_ATTEN_NUM (4) /*!< Digital */ diff --git a/components/soc/esp32c61/include/soc/soc_caps.h b/components/soc/esp32c61/include/soc/soc_caps.h index 9c9797f7c6b..d6a5c95f701 100644 --- a/components/soc/esp32c61/include/soc/soc_caps.h +++ b/components/soc/esp32c61/include/soc/soc_caps.h @@ -84,7 +84,6 @@ #define SOC_ADC_MONITOR_SUPPORTED 1 #define SOC_ADC_DMA_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (1U) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) (4) #define SOC_ADC_ATTEN_NUM (4) /*!< Digital */ diff --git a/components/soc/esp32h2/include/soc/soc_caps.h b/components/soc/esp32h2/include/soc/soc_caps.h index 4a91a4f66d1..b165ab36a77 100644 --- a/components/soc/esp32h2/include/soc/soc_caps.h +++ b/components/soc/esp32h2/include/soc/soc_caps.h @@ -127,7 +127,6 @@ #define SOC_ADC_MONITOR_SUPPORTED 1 #define SOC_ADC_DMA_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (1U) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) (5) #define SOC_ADC_ATTEN_NUM (4) /*!< Digital */ diff --git a/components/soc/esp32h21/include/soc/soc_caps.h b/components/soc/esp32h21/include/soc/soc_caps.h index 42ebbd065b5..9234e0f5267 100644 --- a/components/soc/esp32h21/include/soc/soc_caps.h +++ b/components/soc/esp32h21/include/soc/soc_caps.h @@ -112,7 +112,6 @@ #define SOC_ADC_MONITOR_SUPPORTED 1 #define SOC_ADC_DMA_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (1U) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) (5) #define SOC_ADC_ATTEN_NUM (4) /*!< Digital */ diff --git a/components/soc/esp32h4/include/soc/soc_caps.h b/components/soc/esp32h4/include/soc/soc_caps.h index c16826801d2..bb928858d8c 100644 --- a/components/soc/esp32h4/include/soc/soc_caps.h +++ b/components/soc/esp32h4/include/soc/soc_caps.h @@ -119,7 +119,6 @@ #define SOC_ADC_MONITOR_SUPPORTED 1 #define SOC_ADC_DMA_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (1U) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) (5) #define SOC_ADC_ATTEN_NUM (4) /*!< Digital */ diff --git a/components/soc/esp32p4/include/soc/soc_caps.h b/components/soc/esp32p4/include/soc/soc_caps.h index ea8de0919ef..9bd4a3b45c8 100644 --- a/components/soc/esp32p4/include/soc/soc_caps.h +++ b/components/soc/esp32p4/include/soc/soc_caps.h @@ -146,7 +146,6 @@ // #define SOC_ADC_MONITOR_SUPPORTED 1 #define SOC_ADC_DMA_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (2) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) ((PERIPH_NUM==0)? 8: 6) #define SOC_ADC_ATTEN_NUM (4) /*!< Digital */ diff --git a/components/soc/esp32s2/include/soc/soc_caps.h b/components/soc/esp32s2/include/soc/soc_caps.h index 2b1e8874282..6e40e515635 100644 --- a/components/soc/esp32s2/include/soc/soc_caps.h +++ b/components/soc/esp32s2/include/soc/soc_caps.h @@ -118,7 +118,6 @@ #define SOC_ADC_MONITOR_SUPPORTED 1 #define SOC_ADC_DMA_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (2) -#define SOC_ADC_CHANNEL_NUM(UNIT) (10) #define SOC_ADC_ATTEN_NUM (4) /*!< Digital */ diff --git a/components/soc/esp32s3/include/soc/soc_caps.h b/components/soc/esp32s3/include/soc/soc_caps.h index dc142aea64f..c33afdda054 100644 --- a/components/soc/esp32s3/include/soc/soc_caps.h +++ b/components/soc/esp32s3/include/soc/soc_caps.h @@ -114,7 +114,6 @@ #define SOC_ADC_MONITOR_SUPPORTED 1 #define SOC_ADC_DMA_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (2) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) (10) #define SOC_ADC_ATTEN_NUM (4) /*!< Digital */ diff --git a/components/soc/esp32s31/include/soc/soc_caps.h b/components/soc/esp32s31/include/soc/soc_caps.h index f1c6274224f..1c095b038ef 100644 --- a/components/soc/esp32s31/include/soc/soc_caps.h +++ b/components/soc/esp32s31/include/soc/soc_caps.h @@ -146,7 +146,6 @@ /*!< SAR ADC Module*/ #define SOC_ADC_DIG_CTRL_SUPPORTED 1 #define SOC_ADC_PERIPH_NUM (2) -#define SOC_ADC_CHANNEL_NUM(PERIPH_NUM) (8) #define SOC_ADC_ATTEN_NUM (1U) #define SOC_ADC_DMA_SUPPORTED 1 diff --git a/components/ulp/lp_core/shared/ulp_lp_core_lp_adc_shared.c b/components/ulp/lp_core/shared/ulp_lp_core_lp_adc_shared.c index 9b630aeb573..306bc976499 100644 --- a/components/ulp/lp_core/shared/ulp_lp_core_lp_adc_shared.c +++ b/components/ulp/lp_core/shared/ulp_lp_core_lp_adc_shared.c @@ -43,7 +43,7 @@ static esp_err_t lp_adc_validate_unit(adc_unit_t unit_id) static esp_err_t lp_adc_validate_channel(adc_unit_t unit_id, adc_channel_t channel) { - if (channel >= SOC_ADC_CHANNEL_NUM(unit_id)) { + if (channel >= ADC_LL_CHANNEL_NUM(unit_id)) { return ESP_ERR_INVALID_ARG; } diff --git a/components/ulp/test_apps/lp_core/lp_core_basic_tests/main/test_lp_core_adc.c b/components/ulp/test_apps/lp_core/lp_core_basic_tests/main/test_lp_core_adc.c index e1cf9894e43..117f7526415 100644 --- a/components/ulp/test_apps/lp_core/lp_core_basic_tests/main/test_lp_core_adc.c +++ b/components/ulp/test_apps/lp_core/lp_core_basic_tests/main/test_lp_core_adc.c @@ -7,6 +7,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "hal/adc_types.h" +#include "hal/adc_ll.h" #include "lp_core_test_app_adc.h" #include "ulp_lp_core.h" #include "ulp_lp_core_lp_adc_shared.h" @@ -32,7 +33,7 @@ extern const uint8_t lp_core_main_adc_bin_end[] asm("_binary_lp_core_test_app_ static void test_adc_set_io_level(adc_unit_t unit, adc_channel_t channel, bool level) { - TEST_ASSERT(channel < SOC_ADC_CHANNEL_NUM(unit) && "invalid channel"); + TEST_ASSERT(channel < ADC_LL_CHANNEL_NUM(unit) && "invalid channel"); uint32_t io_num = ADC_GET_IO_NUM(unit, channel); TEST_ESP_OK(gpio_set_pull_mode(io_num, (level ? GPIO_PULLUP_ONLY : GPIO_PULLDOWN_ONLY))); @@ -106,7 +107,7 @@ void test_lp_adc(adc_unit_t unit_id) int *adc_raw = (int *)&ulp_adc_raw; /* Verify that the LP ADC values reflect a low-state of the input pins */ - for (int i = 0; i < SOC_ADC_CHANNEL_NUM(unit_id); i++) { + for (int i = 0; i < ADC_LL_CHANNEL_NUM(unit_id); i++) { printf("LP ADC low[%d] = %d\n", i, adc_raw[i]); TEST_ASSERT_LESS_THAN_INT(ADC_TEST_LOW_VAL, adc_raw[i]); } @@ -124,7 +125,7 @@ void test_lp_adc(adc_unit_t unit_id) vTaskDelay(10); /* Verify that the LP ADC values reflect a high-state of the input pins */ - for (int i = 0; i < SOC_ADC_CHANNEL_NUM(unit_id); i++) { + for (int i = 0; i < ADC_LL_CHANNEL_NUM(unit_id); i++) { printf("LP ADC high[%d] = %d\n", i, adc_raw[i]); TEST_ASSERT_GREATER_THAN_INT(ADC_TEST_HIGH_VAL, adc_raw[i]); }