Ersa Wearable Platform
Embedded smartwatch firmware and application framework
Loading...
Searching...
No Matches
esp32_power_management.h
Go to the documentation of this file.
1#pragma once
2
4#if defined(ARDUINO)
5#include <esp_pm.h>
6#include <freertos/FreeRTOS.h>
7#include <freertos/task.h>
8#endif
9
10namespace ersa::hal {
11
17public:
19 bool initialize() override;
21 void tick() override;
23 bool initializeWakeSources(const board::Pins& pins) override;
24 void allowAutomaticSleep(bool allow) override;
25 void waitForWake(uint32_t timeoutMs) override;
26 void notifyWake() override;
27 void enterDeepSleep(uint64_t timerUs) override;
28 bool acquirePerformance(PerformanceProfile profile, const char* reason) override;
29 void releasePerformance(PerformanceProfile profile, const char* reason) override;
30 void reportPowerModes() override;
31 bool getPowerModeReport(char* buffer, size_t capacity) override;
32 bool setTestCpuFrequencyMHz(unsigned mhz) override;
33 unsigned testCpuFrequencyMHz() const override;
34
35private:
36 static void buttonIsr();
38#if defined(ARDUINO)
39 TaskHandle_t uiTask_{nullptr};
40 esp_pm_lock_handle_t noSleepLock_{nullptr};
41#else
42 void* uiTask_{nullptr};
43 void* noSleepLock_{nullptr};
44#endif
47 bool initialized_{false};
48 bool noSleepLockHeld_{true};
49};
50
51} // namespace ersa::hal
Definition pins.h:57
Definition esp32_power_management.h:16
void notifyWake() override
Definition esp32_power_management.cpp:89
bool setTestCpuFrequencyMHz(unsigned mhz) override
Queue a development CPU-frequency override for the next controlled restart.
Definition esp32_power_management.cpp:114
bool getPowerModeReport(char *buffer, size_t capacity) override
Copy a power-mode report into a caller-owned buffer.
Definition esp32_power_management.cpp:113
bool initialized_
Definition esp32_power_management.h:47
static void buttonIsr()
Definition esp32_power_management.cpp:57
bool acquirePerformance(PerformanceProfile profile, const char *reason) override
Definition esp32_power_management.cpp:104
static Esp32PowerManagement * active_
Definition esp32_power_management.h:37
bool initializeWakeSources(const board::Pins &pins) override
Definition esp32_power_management.cpp:35
void tick() override
Definition esp32_power_management.cpp:33
int topButtonPin_
Definition esp32_power_management.h:45
void waitForWake(uint32_t timeoutMs) override
Definition esp32_power_management.cpp:80
bool noSleepLockHeld_
Definition esp32_power_management.h:48
void enterDeepSleep(uint64_t timerUs) override
Definition esp32_power_management.cpp:94
bool initialize() override
Definition esp32_power_management.cpp:17
void reportPowerModes() override
Emit a one-time power-mode diagnostic report.
Definition esp32_power_management.cpp:112
void allowAutomaticSleep(bool allow) override
Definition esp32_power_management.cpp:66
unsigned testCpuFrequencyMHz() const override
Return the queued development CPU-frequency override, or zero for automatic mode.
Definition esp32_power_management.cpp:115
void * uiTask_
Definition esp32_power_management.h:42
void releasePerformance(PerformanceProfile profile, const char *reason) override
Release a performance profile acquired earlier.
Definition esp32_power_management.cpp:108
int bottomButtonPin_
Definition esp32_power_management.h:46
void * noSleepLock_
Definition esp32_power_management.h:43
Definition power_management.h:27
Definition battery.h:7
PerformanceProfile
Definition power_management.h:11