From 5fd4dbad12082f83708d4d7478e4ac953d2cdfd9 Mon Sep 17 00:00:00 2001 From: Armando Date: Fri, 9 Sep 2022 17:37:26 +0800 Subject: [PATCH] esp_adc: improve adc continuous iram test aim This commit increases adc continuous iram test period of cache disabling time. Now time is: 1 second - The aim of this test is to make sure the continuous mode driver ISR callbacks can run in an IRAM-Safe context. - Closing cache takes time. WHereas the code to close the cache is updated. This time gets changed. --- .../test_apps/adc/main/test_adc_driver_iram.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 e1d7949a68..c48fc746a1 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 @@ -215,13 +215,11 @@ TEST_CASE("ADC continuous work with ISR and Flash", "[adc_oneshot]") }; TEST_ESP_OK(adc_continuous_register_event_callbacks(handle, &cbs, &isr_test_ctx)); -#if CONFIG_IDF_TARGET_ESP32 - //This may need to be bigger, when the sampling freq is low - uint32_t overhead_us = 150; -#else - uint32_t overhead_us = 50; -#endif - uint32_t wait_time_us = (1000 * 1000 / ADC_TEST_FREQ_HZ * ADC_TEST_PKG_SIZE / SOC_ADC_DIGI_RESULT_BYTES) + overhead_us; + /** + * Ideal time consumption for one conversion_frame done is `(1000 * 1000 / ADC_TEST_FREQ_HZ * ADC_TEST_PKG_SIZE / SOC_ADC_DIGI_RESULT_BYTES)` + * Here we just wait for 1 second + */ + uint32_t wait_time_us = 1 * 1000 * 1000; printf("period is %"PRId32" us\n", wait_time_us); //ADC IO tile low @@ -233,6 +231,7 @@ TEST_CASE("ADC continuous work with ISR and Flash", "[adc_oneshot]") //Checks TEST_ASSERT_INT_WITHIN(ADC_TEST_LOW_THRESH, ADC_TEST_LOW_VAL, isr_test_ctx.adc_raw_low); esp_rom_printf("callback runs %d times when $ disabled\n", isr_test_ctx.cb_exe_times_low); + //At least 1 time conv_done callback happens during this period is ok TEST_ASSERT_GREATER_OR_EQUAL(1, isr_test_ctx.cb_exe_times_low); vTaskDelay(10); @@ -245,8 +244,9 @@ TEST_CASE("ADC continuous work with ISR and Flash", "[adc_oneshot]") s_test_cache_disable_period_us(&isr_test_ctx, wait_time_us); TEST_ESP_OK(adc_continuous_stop(handle)); //Checks - // TEST_ASSERT_INT_WITHIN(ADC_TEST_HIGH_THRESH, ADC_TEST_HIGH_VAL_DMA, isr_test_ctx.adc_raw_high); + TEST_ASSERT_INT_WITHIN(ADC_TEST_HIGH_THRESH, ADC_TEST_HIGH_VAL_DMA, isr_test_ctx.adc_raw_high); esp_rom_printf("callback runs %d times when $ disabled\n", isr_test_ctx.cb_exe_times_high); + //At least 1 time conv_done callback happens during this period is ok TEST_ASSERT_GREATER_OR_EQUAL(1, isr_test_ctx.cb_exe_times_high); TEST_ESP_OK(adc_continuous_deinit(handle));