mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
esp32/test: fix usage of deprecated fields
This commit is contained in:
committed by
Angus Gratton
parent
a9fe3165c4
commit
5f8e5db268
@ -15,6 +15,8 @@
|
|||||||
#include "esp32/ulp.h"
|
#include "esp32/ulp.h"
|
||||||
#include "soc/rtc_periph.h"
|
#include "soc/rtc_periph.h"
|
||||||
|
|
||||||
|
#define MHZ 1000000
|
||||||
|
|
||||||
TEST_CASE("Can dump power management lock stats", "[pm]")
|
TEST_CASE("Can dump power management lock stats", "[pm]")
|
||||||
{
|
{
|
||||||
esp_pm_dump_locks(stdout);
|
esp_pm_dump_locks(stdout);
|
||||||
@ -31,15 +33,15 @@ static void switch_freq(int mhz)
|
|||||||
};
|
};
|
||||||
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
|
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
|
||||||
printf("Waiting for frequency to be set to %d MHz...\n", mhz);
|
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));
|
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]")
|
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(240);
|
||||||
switch_freq(40);
|
switch_freq(40);
|
||||||
switch_freq(160);
|
switch_freq(160);
|
||||||
@ -60,9 +62,12 @@ TEST_CASE("Can switch frequency using esp_pm_configure", "[pm]")
|
|||||||
|
|
||||||
static void light_sleep_enable()
|
static void light_sleep_enable()
|
||||||
{
|
{
|
||||||
|
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 = {
|
const esp_pm_config_esp32_t pm_config = {
|
||||||
.max_freq_mhz = esp_clk_cpu_freq() / 1000000,
|
.max_freq_mhz = cur_freq_mhz,
|
||||||
.min_freq_mhz = esp_clk_xtal_freq() / MHZ,
|
.min_freq_mhz = xtal_freq,
|
||||||
.light_sleep_enable = true
|
.light_sleep_enable = true
|
||||||
};
|
};
|
||||||
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
|
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
|
||||||
@ -70,9 +75,11 @@ static void light_sleep_enable()
|
|||||||
|
|
||||||
static void light_sleep_disable()
|
static void light_sleep_disable()
|
||||||
{
|
{
|
||||||
|
int cur_freq_mhz = esp_clk_cpu_freq() / MHZ;
|
||||||
|
|
||||||
const esp_pm_config_esp32_t pm_config = {
|
const esp_pm_config_esp32_t pm_config = {
|
||||||
.max_freq_mhz = esp_clk_cpu_freq() / 1000000,
|
.max_freq_mhz = cur_freq_mhz,
|
||||||
.min_freq_mhz = esp_clk_cpu_freq() / 1000000,
|
.min_freq_mhz = cur_freq_mhz,
|
||||||
};
|
};
|
||||||
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
|
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user