Ersa Wearable Platform
Embedded smartwatch firmware and application framework
Loading...
Searching...
No Matches
Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ersa::hal::Esp32PowerManagement Class Referencefinal

#include <esp32_power_management.h>

Inheritance diagram for ersa::hal::Esp32PowerManagement:
Inheritance graph
[legend]
Collaboration diagram for ersa::hal::Esp32PowerManagement:
Collaboration graph
[legend]

Public Member Functions

bool initialize () override
 
void tick () override
 
bool initializeWakeSources (const board::Pins &pins) override
 
void allowAutomaticSleep (bool allow) override
 
void waitForWake (uint32_t timeoutMs) override
 
void notifyWake () override
 
void enterDeepSleep (uint64_t timerUs) override
 
bool acquirePerformance (PerformanceProfile profile, const char *reason) override
 
void releasePerformance (PerformanceProfile profile, const char *reason) override
 Release a performance profile acquired earlier.
 
void reportPowerModes () override
 Emit a one-time power-mode diagnostic report.
 
bool getPowerModeReport (char *buffer, size_t capacity) override
 Copy a power-mode report into a caller-owned buffer.
 
bool setTestCpuFrequencyMHz (unsigned mhz) override
 Queue a development CPU-frequency override for the next controlled restart.
 
unsigned testCpuFrequencyMHz () const override
 Return the queued development CPU-frequency override, or zero for automatic mode.
 
- Public Member Functions inherited from ersa::hal::IPowerManagement
virtual ~IPowerManagement ()=default
 

Static Private Member Functions

static void buttonIsr ()
 

Private Attributes

void * uiTask_ {nullptr}
 
void * noSleepLock_ {nullptr}
 
int topButtonPin_ {-1}
 
int bottomButtonPin_ {-1}
 
bool initialized_ {false}
 
bool noSleepLockHeld_ {true}
 

Static Private Attributes

static Esp32PowerManagement * active_ = nullptr
 

Detailed Description

ESP-IDF power backend for automatic sleep, wake sources, and CPU profiles. It coordinates FreeRTOS tickless idle and PM locks with BLE/radio policy.

Member Function Documentation

◆ acquirePerformance()

bool ersa::hal::Esp32PowerManagement::acquirePerformance ( PerformanceProfile  profile,
const char *  reason 
)
overridevirtual

Acquire a temporary CPU/APB minimum for latency-sensitive work.

Parameters
profileWorkload class selecting the platform's performance guarantee.
reasonShort diagnostic label paired with releasePerformance().
Returns
False when the profile is unsupported or the platform lock failed.

Implements ersa::hal::IPowerManagement.

◆ allowAutomaticSleep()

void ersa::hal::Esp32PowerManagement::allowAutomaticSleep ( bool  allow)
overridevirtual

Permit FreeRTOS automatic sleep when true; false holds the platform's no-light-sleep guard for display, network, USB, or active interaction.

Implements ersa::hal::IPowerManagement.

◆ buttonIsr()

void ersa::hal::Esp32PowerManagement::buttonIsr ( )
staticprivate

◆ enterDeepSleep()

void ersa::hal::Esp32PowerManagement::enterDeepSleep ( uint64_t  timerUs)
overridevirtual

Enter deep sleep after configuring enabled GPIO/timer sources. This normally restarts firmware on wake, unlike light sleep.

Implements ersa::hal::IPowerManagement.

◆ getPowerModeReport()

bool ersa::hal::Esp32PowerManagement::getPowerModeReport ( char *  buffer,
size_t  capacity 
)
overridevirtual

Copy a power-mode report into a caller-owned buffer.

Implements ersa::hal::IPowerManagement.

◆ initialize()

bool ersa::hal::Esp32PowerManagement::initialize ( )
overridevirtual

Configure ESP-IDF dynamic frequency scaling and automatic light sleep.

Implements ersa::hal::IPowerManagement.

◆ initializeWakeSources()

bool ersa::hal::Esp32PowerManagement::initializeWakeSources ( const board::Pins &  pins)
overridevirtual

Configure Terra's GPIO wake sources from its board pinctrl contract.

Implements ersa::hal::IPowerManagement.

◆ notifyWake()

void ersa::hal::Esp32PowerManagement::notifyWake ( )
overridevirtual

Notify the task that new event/driver work is ready to process.

Implements ersa::hal::IPowerManagement.

◆ releasePerformance()

void ersa::hal::Esp32PowerManagement::releasePerformance ( PerformanceProfile  profile,
const char *  reason 
)
overridevirtual

Release a performance profile acquired earlier.

Implements ersa::hal::IPowerManagement.

◆ reportPowerModes()

void ersa::hal::Esp32PowerManagement::reportPowerModes ( )
overridevirtual

Emit a one-time power-mode diagnostic report.

Implements ersa::hal::IPowerManagement.

◆ setTestCpuFrequencyMHz()

bool ersa::hal::Esp32PowerManagement::setTestCpuFrequencyMHz ( unsigned  mhz)
overridevirtual

Queue a development CPU-frequency override for the next controlled restart.

Implements ersa::hal::IPowerManagement.

◆ testCpuFrequencyMHz()

unsigned ersa::hal::Esp32PowerManagement::testCpuFrequencyMHz ( ) const
overridevirtual

Return the queued development CPU-frequency override, or zero for automatic mode.

Implements ersa::hal::IPowerManagement.

◆ tick()

void ersa::hal::Esp32PowerManagement::tick ( )
overridevirtual

Sample/debug power state while the UI task is active.

Implements ersa::hal::IPowerManagement.

◆ waitForWake()

void ersa::hal::Esp32PowerManagement::waitForWake ( uint32_t  timeoutMs)
overridevirtual

Block the UI task until notifyWake() or timeout to reduce active polling.

Implements ersa::hal::IPowerManagement.

Member Data Documentation

◆ active_

Esp32PowerManagement * ersa::hal::Esp32PowerManagement::active_ = nullptr
staticprivate

◆ bottomButtonPin_

int ersa::hal::Esp32PowerManagement::bottomButtonPin_ {-1}
private

◆ initialized_

bool ersa::hal::Esp32PowerManagement::initialized_ {false}
private

◆ noSleepLock_

void* ersa::hal::Esp32PowerManagement::noSleepLock_ {nullptr}
private

◆ noSleepLockHeld_

bool ersa::hal::Esp32PowerManagement::noSleepLockHeld_ {true}
private

◆ topButtonPin_

int ersa::hal::Esp32PowerManagement::topButtonPin_ {-1}
private

◆ uiTask_

void* ersa::hal::Esp32PowerManagement::uiTask_ {nullptr}
private

The documentation for this class was generated from the following files: