]> granicus.if.org Git - esp-idf/commitdiff
esp32/test: fix usage of deprecated fields
authorIvan Grokhotkov <ivan@espressif.com>
Fri, 26 Oct 2018 11:52:49 +0000 (19:52 +0800)
committerAngus Gratton <gus@projectgus.com>
Thu, 12 Sep 2019 23:44:07 +0000 (09:44 +1000)
components/esp32/test/test_pm.c

index d19c6db882b657a973efc64e0b0c60125b4f555f..2f17202f1bfb0c59c5f05edbada2cd395185a5cc 100644 (file)
@@ -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) );
 }