oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
Typedefs | Functions
ove::pm Namespace Reference

Thin C++ wrappers around the oveRTOS power management API. More...

Typedefs

using State = ove_pm_state_t
 System power state (active / sleep / deep-sleep / off).
 
using WakeType = ove_pm_wake_type_t
 Wake-source kind (GPIO, RTC, timer, …).
 
using Domain = ove_pm_domain_t
 Peripheral power domain identifier.
 
using Event = ove_pm_event_t
 PM event delivered to subscribers (entering/exiting a state, etc.).
 
using WakeSrc = ove_pm_wake_src
 Wake-source descriptor passed to enable_wake_src().
 
using Cfg = ove_pm_cfg
 Runtime configuration consumed by init().
 
using Stats = ove_pm_stats
 Aggregated runtime statistics (time in each state, etc.).
 

Functions

Result< void > init (const Cfg &cfg) noexcept
 Initialise the PM subsystem.
 
void deinit ()
 Tear down the PM subsystem and release resources.
 
Result< void > set_state (State state) noexcept
 Request an explicit power state transition.
 
State get_state ()
 Query the current power state.
 
void activity ()
 Report system activity (ISR-safe).
 
Result< void > wake_register (const WakeSrc &src) noexcept
 Register a wake source.
 
Result< void > wake_unregister (const WakeSrc &src) noexcept
 Unregister a previously registered wake source.
 
Result< void > domain_request (Domain domain) noexcept
 Increment the reference count for a peripheral power domain.
 
Result< void > domain_release (Domain domain) noexcept
 Decrement the reference count for a peripheral power domain.
 
Result< int > domain_get_refcount (Domain domain) noexcept
 Query the current reference count for a domain.
 
Result< void > set_policy (ove_pm_policy_fn policy, void *user_data=nullptr) noexcept
 Register a custom power policy callback.
 
Result< void > notify_register (ove_pm_notify_fn cb, void *user_data=nullptr) noexcept
 Register a transition notification callback.
 
Result< void > notify_unregister (ove_pm_notify_fn cb, void *user_data=nullptr) noexcept
 Unregister a transition notification callback.
 
Result< Statsget_stats () noexcept
 Query accumulated power statistics.
 
void reset_stats ()
 Reset all accumulated power statistics to zero.
 
Result< void > set_budget (uint32_t target_pct_x100) noexcept
 Set a target percentage of time in low-power states.
 
Result< uint32_t > get_budget_status () noexcept
 Query actual low-power percentage vs. budget target.
 
void idle_process ()
 Process idle — drive the PM state machine.
 

Detailed Description

Thin C++ wrappers around the oveRTOS power management API.

The PM subsystem is a singleton — there is one system-wide power state. Available when CONFIG_OVE_PM is enabled.

Function Documentation

◆ init()

Result< void > ove::pm::init ( const Cfg cfg)
inlinenoexcept

Initialise the PM subsystem.

Parameters
[in]cfgConfiguration parameters.
Returns
Empty Result<void> on success; unexpected Error on failure.

◆ set_state()

Result< void > ove::pm::set_state ( State  state)
inlinenoexcept

Request an explicit power state transition.

Parameters
[in]stateTarget power state.
Returns
Empty Result<void> on success; unexpected Error on failure.

◆ get_state()

State ove::pm::get_state ( )
inline

Query the current power state.

Returns
Current power state.

◆ activity()

void ove::pm::activity ( )
inline

Report system activity (ISR-safe).

Resets the idle timer, causing the PM subsystem to return to the ACTIVE state on the next idle check.

◆ wake_register()

Result< void > ove::pm::wake_register ( const WakeSrc src)
inlinenoexcept

Register a wake source.

Parameters
[in]srcWake source descriptor.
Returns
Empty Result<void> on success; unexpected Error::NoMemory if the wake-source table is full.

◆ wake_unregister()

Result< void > ove::pm::wake_unregister ( const WakeSrc src)
inlinenoexcept

Unregister a previously registered wake source.

Parameters
[in]srcWake source descriptor (must match a registered entry).
Returns
Empty Result<void> on success; unexpected Error on failure.

◆ domain_request()

Result< void > ove::pm::domain_request ( Domain  domain)
inlinenoexcept

Increment the reference count for a peripheral power domain.

Parameters
[in]domainDomain identifier.
Returns
Empty Result<void> on success; unexpected Error on failure.

◆ domain_release()

Result< void > ove::pm::domain_release ( Domain  domain)
inlinenoexcept

Decrement the reference count for a peripheral power domain.

Parameters
[in]domainDomain identifier.
Returns
Empty Result<void> on success; unexpected Error::InvalidParam on refcount underflow.

◆ domain_get_refcount()

Result< int > ove::pm::domain_get_refcount ( Domain  domain)
inlinenoexcept

Query the current reference count for a domain.

Parameters
[in]domainDomain identifier.
Returns
On success, the reference count. On failure, an unexpected Error.

◆ set_policy()

Result< void > ove::pm::set_policy ( ove_pm_policy_fn  policy,
void *  user_data = nullptr 
)
inlinenoexcept

Register a custom power policy callback.

Parameters
[in]policyPolicy function, or nullptr for default.
[in]user_dataOpaque pointer forwarded to the policy.
Returns
Empty Result<void> on success; unexpected Error on failure.

◆ notify_register()

Result< void > ove::pm::notify_register ( ove_pm_notify_fn  cb,
void *  user_data = nullptr 
)
inlinenoexcept

Register a transition notification callback.

Parameters
[in]cbCallback invoked on PRE_SLEEP and POST_WAKE.
[in]user_dataOpaque pointer forwarded to the callback.
Returns
Empty Result<void> on success; unexpected Error::NoMemory if the notification table is full.

◆ notify_unregister()

Result< void > ove::pm::notify_unregister ( ove_pm_notify_fn  cb,
void *  user_data = nullptr 
)
inlinenoexcept

Unregister a transition notification callback.

Parameters
[in]cbPreviously registered callback.
[in]user_dataPointer that was passed at registration time.
Returns
Empty Result<void> on success; unexpected Error on failure.

◆ get_stats()

Result< Stats > ove::pm::get_stats ( )
inlinenoexcept

Query accumulated power statistics.

Returns
On success, the populated Stats snapshot. On failure, an unexpected Error.

◆ set_budget()

Result< void > ove::pm::set_budget ( uint32_t  target_pct_x100)
inlinenoexcept

Set a target percentage of time in low-power states.

Parameters
[in]target_pct_x100Target in hundredths of percent.
Returns
Empty Result<void> on success; unexpected Error on failure.

◆ get_budget_status()

Result< uint32_t > ove::pm::get_budget_status ( )
inlinenoexcept

Query actual low-power percentage vs. budget target.

Returns
On success, the actual low-power percentage in hundredths of percent. On failure, an unexpected Error.

◆ idle_process()

void ove::pm::idle_process ( )
inline

Process idle — drive the PM state machine.

Called internally from the RTOS idle hook. Not normally called by application code.