From 81007ee4edb750458b0b91322e66f19d107ccbf3 Mon Sep 17 00:00:00 2001 From: Armando Date: Mon, 22 Aug 2022 11:00:10 +0800 Subject: [PATCH] esp_adc: add adc ulp mode disable enum Prior to this commit, adc ulp is disabled by setting adc_oneshot_unit_init_cfg_t::ulp_mode to false. After this commit, a new enum `ADC_ULP_MODE_DISABLE` is added. So setting `ulp_mode` to `ADC_ULP_MODE_DISABLE`, instead of `false`, to disable the ulp mode. --- components/esp_adc/test_apps/adc/main/test_adc.c | 6 +++--- components/esp_adc/test_apps/adc/main/test_adc_driver.c | 2 +- .../esp_adc/test_apps/adc/main/test_adc_driver_iram.c | 2 +- .../esp_adc/test_apps/adc/main/test_adc_performance.c | 4 ++-- components/hal/include/hal/adc_types.h | 5 +++-- docs/en/api-reference/peripherals/adc_oneshot.rst | 2 +- .../peripherals/adc/oneshot_read/main/oneshot_read_main.c | 2 +- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/components/esp_adc/test_apps/adc/main/test_adc.c b/components/esp_adc/test_apps/adc/main/test_adc.c index b8896853e1..31fcd2d849 100644 --- a/components/esp_adc/test_apps/adc/main/test_adc.c +++ b/components/esp_adc/test_apps/adc/main/test_adc.c @@ -44,7 +44,7 @@ TEST_CASE("ADC oneshot high/low test", "[adc_oneshot]") adc_oneshot_unit_handle_t adc1_handle; adc_oneshot_unit_init_cfg_t init_config1 = { .unit_id = ADC_UNIT_1, - .ulp_mode = false, + .ulp_mode = ADC_ULP_MODE_DISABLE, }; TEST_ESP_OK(adc_oneshot_new_unit(&init_config1, &adc1_handle)); @@ -53,7 +53,7 @@ TEST_CASE("ADC oneshot high/low test", "[adc_oneshot]") adc_oneshot_unit_handle_t adc2_handle; adc_oneshot_unit_init_cfg_t init_config2 = { .unit_id = ADC_UNIT_2, - .ulp_mode = false, + .ulp_mode = ADC_ULP_MODE_DISABLE, }; TEST_ESP_OK(adc_oneshot_new_unit(&init_config2, &adc2_handle)); #endif //#if (SOC_ADC_PERIPH_NUM >= 2) @@ -135,7 +135,7 @@ static void s_adc_oneshot_with_sleep(adc_unit_t unit_id, adc_channel_t channel) adc_oneshot_unit_handle_t adc_handle; adc_oneshot_unit_init_cfg_t init_config = { .unit_id = unit_id, - .ulp_mode = false, + .ulp_mode = ADC_ULP_MODE_DISABLE, }; TEST_ESP_OK(adc_oneshot_new_unit(&init_config, &adc_handle)); 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 c5e2c4dfb4..a1e8a3e56c 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 @@ -72,7 +72,7 @@ TEST_CASE("ADC oneshot fast work with ISR", "[adc_oneshot]") //-------------ADC1 Init---------------// adc_oneshot_unit_init_cfg_t init_config1 = { .unit_id = ADC_UNIT_1, - .ulp_mode = false, + .ulp_mode = ADC_ULP_MODE_DISABLE, }; TEST_ESP_OK(adc_oneshot_new_unit(&init_config1, &isr_test_ctx.adc_handle)); diff --git a/components/esp_adc/test_apps/adc/main/test_adc_driver_iram.c b/components/esp_adc/test_apps/adc/main/test_adc_driver_iram.c index bfdf8822bf..74469d7323 100644 --- a/components/esp_adc/test_apps/adc/main/test_adc_driver_iram.c +++ b/components/esp_adc/test_apps/adc/main/test_adc_driver_iram.c @@ -78,7 +78,7 @@ TEST_CASE("ADC oneshot fast work with ISR and Flash", "[adc_oneshot]") //-------------ADC1 Init---------------// adc_oneshot_unit_init_cfg_t init_config1 = { .unit_id = ADC_UNIT_1, - .ulp_mode = false, + .ulp_mode = ADC_ULP_MODE_DISABLE, }; TEST_ESP_OK(adc_oneshot_new_unit(&init_config1, &oneshot_handle)); diff --git a/components/esp_adc/test_apps/adc/main/test_adc_performance.c b/components/esp_adc/test_apps/adc/main/test_adc_performance.c index bf4bbecdd4..8b4b1cebf5 100644 --- a/components/esp_adc/test_apps/adc/main/test_adc_performance.c +++ b/components/esp_adc/test_apps/adc/main/test_adc_performance.c @@ -134,7 +134,7 @@ TEST_CASE("ADC1 oneshot raw average / std_deviation", "[adc_oneshot][ignore][man adc_oneshot_unit_handle_t adc1_handle; adc_oneshot_unit_init_cfg_t init_config1 = { .unit_id = ADC_UNIT_1, - .ulp_mode = false, + .ulp_mode = ADC_ULP_MODE_DISABLE, }; TEST_ESP_OK(adc_oneshot_new_unit(&init_config1, &adc1_handle)); @@ -254,7 +254,7 @@ static void s_adc_cali_speed(adc_unit_t unit_id, adc_channel_t channel) adc_oneshot_unit_handle_t adc_handle; adc_oneshot_unit_init_cfg_t init_config = { .unit_id = unit_id, - .ulp_mode = false, + .ulp_mode = ADC_ULP_MODE_DISABLE, }; TEST_ESP_OK(adc_oneshot_new_unit(&init_config, &adc_handle)); diff --git a/components/hal/include/hal/adc_types.h b/components/hal/include/hal/adc_types.h index fd27771223..785ea76c97 100644 --- a/components/hal/include/hal/adc_types.h +++ b/components/hal/include/hal/adc_types.h @@ -55,8 +55,9 @@ typedef enum { } adc_bitwidth_t; typedef enum { - ADC_ULP_MODE_FSM = 1, ///< ADC is controlled by ULP FSM - ADC_ULP_MODE_RISCV = 2, ///< ADC is controlled by ULP RISCV + ADC_ULP_MODE_DISABLE = 0, ///< ADC ULP mode is disabled + ADC_ULP_MODE_FSM = 1, ///< ADC is controlled by ULP FSM + ADC_ULP_MODE_RISCV = 2, ///< ADC is controlled by ULP RISCV } adc_ulp_mode_t; /** diff --git a/docs/en/api-reference/peripherals/adc_oneshot.rst b/docs/en/api-reference/peripherals/adc_oneshot.rst index 506d922e88..c73198e429 100644 --- a/docs/en/api-reference/peripherals/adc_oneshot.rst +++ b/docs/en/api-reference/peripherals/adc_oneshot.rst @@ -62,7 +62,7 @@ Create an ADC Unit Handle under Normal Oneshot Mode adc_oneshot_unit_handle_t adc1_handle; adc_oneshot_unit_init_cfg_t init_config1 = { .unit_id = ADC_UNIT_1, - .ulp_mode = false, + .ulp_mode = ADC_ULP_MODE_DISABLE, }; ESP_ERROR_CHECK(adc_oneshot_new_unit(&init_config1, &adc1_handle)); diff --git a/examples/peripherals/adc/oneshot_read/main/oneshot_read_main.c b/examples/peripherals/adc/oneshot_read/main/oneshot_read_main.c index a7ac30a7b6..c71c50259b 100644 --- a/examples/peripherals/adc/oneshot_read/main/oneshot_read_main.c +++ b/examples/peripherals/adc/oneshot_read/main/oneshot_read_main.c @@ -70,7 +70,7 @@ void app_main(void) adc_oneshot_unit_handle_t adc2_handle; adc_oneshot_unit_init_cfg_t init_config2 = { .unit_id = ADC_UNIT_2, - .ulp_mode = false, + .ulp_mode = ADC_ULP_MODE_DISABLE, }; ESP_ERROR_CHECK(adc_oneshot_new_unit(&init_config2, &adc2_handle));