From: Ivan Grokhotkov Date: Fri, 26 Oct 2018 11:52:49 +0000 (+0800) Subject: esp32/test: fix usage of deprecated fields X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=88548a9b4dc2762cd02093f75bc778073593d825;p=esp-idf esp32/test: fix usage of deprecated fields --- diff --git a/components/esp32/test/test_pm.c b/components/esp32/test/test_pm.c index d19c6db882..2f17202f1b 100644 --- a/components/esp32/test/test_pm.c +++ b/components/esp32/test/test_pm.c @@ -15,6 +15,8 @@ #include "esp32/ulp.h" #include "soc/rtc_periph.h" +#define MHZ 1000000 + TEST_CASE("Can dump power management lock stats", "[pm]") { esp_pm_dump_locks(stdout); @@ -31,15 +33,15 @@ static void switch_freq(int mhz) }; ESP_ERROR_CHECK( esp_pm_configure(&pm_config) ); printf("Waiting for frequency to be set to %d MHz...\n", mhz); - while (esp_clk_cpu_freq() / 1000000 != mhz) { + while (esp_clk_cpu_freq() / MHZ != mhz) { vTaskDelay(pdMS_TO_TICKS(200)); - printf("Frequency is %d MHz\n", esp_clk_cpu_freq() / 1000000); + printf("Frequency is %d MHz\n", esp_clk_cpu_freq() / MHZ); } } TEST_CASE("Can switch frequency using esp_pm_configure", "[pm]") { - int orig_freq_mhz = esp_clk_cpu_freq() / 1000000; + int orig_freq_mhz = esp_clk_cpu_freq() / MHZ; switch_freq(240); switch_freq(40); switch_freq(160); @@ -60,9 +62,12 @@ TEST_CASE("Can switch frequency using esp_pm_configure", "[pm]") static void light_sleep_enable(void) { + int cur_freq_mhz = esp_clk_cpu_freq() / MHZ; + int xtal_freq = (int) rtc_clk_xtal_freq_get(); + const esp_pm_config_esp32_t pm_config = { - .max_freq_mhz = esp_clk_cpu_freq() / 1000000, - .min_freq_mhz = esp_clk_xtal_freq() / MHZ, + .max_freq_mhz = cur_freq_mhz, + .min_freq_mhz = xtal_freq, .light_sleep_enable = true }; ESP_ERROR_CHECK( esp_pm_configure(&pm_config) ); @@ -70,9 +75,11 @@ static void light_sleep_enable(void) static void light_sleep_disable(void) { + int cur_freq_mhz = esp_clk_cpu_freq() / MHZ; + const esp_pm_config_esp32_t pm_config = { - .max_freq_mhz = esp_clk_cpu_freq() / 1000000, - .min_freq_mhz = esp_clk_cpu_freq() / 1000000, + .max_freq_mhz = cur_freq_mhz, + .min_freq_mhz = cur_freq_mhz, }; ESP_ERROR_CHECK( esp_pm_configure(&pm_config) ); }