mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feature: add wake up time cost info to deep_sleep_wake_stub example
This commit is contained in:
parent
38b036e9ae
commit
8820efe2e1
@ -1639,7 +1639,13 @@ static uint32_t get_power_down_flags(void)
|
|||||||
return pd_flags;
|
return pd_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esp_deep_sleep_disable_rom_logging(void)
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
|
/* APP core of esp32 can't access to RTC FAST MEMORY, do not define it with RTC_IRAM_ATTR */
|
||||||
|
void
|
||||||
|
#else
|
||||||
|
void RTC_IRAM_ATTR
|
||||||
|
#endif
|
||||||
|
esp_deep_sleep_disable_rom_logging(void)
|
||||||
{
|
{
|
||||||
rtc_suppress_rom_log();
|
rtc_suppress_rom_log();
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
|
#include "esp_cpu.h"
|
||||||
|
#include "esp_rom_sys.h"
|
||||||
#include "esp_wake_stub.h"
|
#include "esp_wake_stub.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
|
||||||
@ -33,15 +35,20 @@ static const uint32_t s_max_count = 20;
|
|||||||
// wakeup_cause stored in RTC memory
|
// wakeup_cause stored in RTC memory
|
||||||
static uint32_t wakeup_cause;
|
static uint32_t wakeup_cause;
|
||||||
|
|
||||||
|
// wakeup_time from CPU start to wake stub
|
||||||
|
static uint32_t wakeup_time;
|
||||||
|
|
||||||
// wake up stub function stored in RTC memory
|
// wake up stub function stored in RTC memory
|
||||||
void wake_stub_example(void)
|
void wake_stub_example(void)
|
||||||
{
|
{
|
||||||
|
// Get wakeup time.
|
||||||
|
wakeup_time = esp_cpu_get_cycle_count() / esp_rom_get_cpu_ticks_per_us();
|
||||||
// Get wakeup cause.
|
// Get wakeup cause.
|
||||||
wakeup_cause = esp_wake_stub_get_wakeup_cause();
|
wakeup_cause = esp_wake_stub_get_wakeup_cause();
|
||||||
// Increment the counter.
|
// Increment the counter.
|
||||||
s_count++;
|
s_count++;
|
||||||
// Print the counter value and wakeup cause.
|
// Print the counter value and wakeup cause.
|
||||||
ESP_RTC_LOGI("wake stub: wakeup count is %d, wakeup cause is %d", s_count, wakeup_cause);
|
ESP_RTC_LOGI("wake stub: wakeup count is %d, wakeup cause is %d, wakeup cost %ld us", s_count, wakeup_cause, wakeup_time);
|
||||||
|
|
||||||
if (s_count >= s_max_count) {
|
if (s_count >= s_max_count) {
|
||||||
// Reset s_count
|
// Reset s_count
|
||||||
|
Loading…
x
Reference in New Issue
Block a user