oveRTOS C API
Embedded RTOS framework — build system, configuration, and portable C API
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
Power Management

Unified power management with sleep state machine, peripheral power domains, wake source registration, and runtime statistics. More...

Data Structures

struct  ove_pm_cfg
 PM subsystem configuration. More...
 
struct  ove_pm_wake_src
 Wake source descriptor. More...
 
struct  ove_pm_stats
 Runtime power statistics. More...
 

Typedefs

typedef ove_pm_state_t(* ove_pm_policy_fn) (ove_pm_state_t current, uint32_t idle_ms, uint32_t next_timeout_ms, void *user_data)
 Power policy callback — returns recommended next state.
 
typedef void(* ove_pm_notify_fn) (ove_pm_event_t event, ove_pm_state_t from_state, ove_pm_state_t to_state, void *user_data)
 Transition notification callback.
 

Enumerations

enum  ove_pm_state_t {
  OVE_PM_STATE_ACTIVE = 0 , OVE_PM_STATE_IDLE = 1 , OVE_PM_STATE_STANDBY = 2 , OVE_PM_STATE_DEEP_SLEEP = 3 ,
  OVE_PM_STATE_COUNT = 4
}
 System power states, ordered by increasing sleep depth. More...
 
enum  ove_pm_wake_type_t { OVE_PM_WAKE_GPIO = 0 , OVE_PM_WAKE_TIMER = 1 , OVE_PM_WAKE_UART = 2 , OVE_PM_WAKE_RTC = 3 }
 Wake source types. More...
 
enum  ove_pm_domain_t {
  OVE_PM_DOMAIN_RADIO = 0 , OVE_PM_DOMAIN_SENSOR = 1 , OVE_PM_DOMAIN_DISPLAY = 2 , OVE_PM_DOMAIN_AUDIO = 3 ,
  OVE_PM_DOMAIN_STORAGE = 4 , OVE_PM_DOMAIN_COMMS = 5 , OVE_PM_DOMAIN_USER0 = 6 , OVE_PM_DOMAIN_USER1 = 7 ,
  OVE_PM_DOMAIN_COUNT = 8
}
 Peripheral power domain identifiers.
 
enum  ove_pm_event_t { OVE_PM_EVENT_PRE_SLEEP = 0 , OVE_PM_EVENT_POST_WAKE = 1 }
 Transition event type for notification callbacks. More...
 

Functions

static int ove_pm_init (const struct ove_pm_cfg *c)
 
static void ove_pm_deinit (void)
 
static int ove_pm_set_state (ove_pm_state_t s)
 
static ove_pm_state_t ove_pm_get_state (void)
 
static void ove_pm_activity (void)
 
static int ove_pm_wake_register (const struct ove_pm_wake_src *s)
 
static int ove_pm_wake_unregister (const struct ove_pm_wake_src *s)
 
static int ove_pm_domain_request (ove_pm_domain_t d)
 
static int ove_pm_domain_release (ove_pm_domain_t d)
 
static int ove_pm_domain_get_refcount (ove_pm_domain_t d)
 
static int ove_pm_set_policy (ove_pm_policy_fn p, void *u)
 
static int ove_pm_notify_register (ove_pm_notify_fn c, void *u)
 
static int ove_pm_notify_unregister (ove_pm_notify_fn c, void *u)
 
static int ove_pm_get_stats (struct ove_pm_stats *s)
 
static void ove_pm_reset_stats (void)
 
static int ove_pm_set_budget (uint32_t t)
 
static int ove_pm_get_budget_status (uint32_t *a)
 
static void ove_pm_idle_process (void)
 

Detailed Description

Unified power management with sleep state machine, peripheral power domains, wake source registration, and runtime statistics.

The PM subsystem is a singleton module (like GPIO and console) — there is exactly one system power state. Initialise with ove_pm_init() and tear down with ove_pm_deinit().

Four sleep states are defined, ordered by increasing depth:

A pluggable policy engine decides when to transition between states based on idle duration, next scheduled timeout, and registered wake sources. Peripheral power domains are reference-counted: power is gated when the last user releases a domain.

Note
Requires CONFIG_OVE_PM.

Typedef Documentation

◆ ove_pm_policy_fn

typedef ove_pm_state_t(* ove_pm_policy_fn) (ove_pm_state_t current, uint32_t idle_ms, uint32_t next_timeout_ms, void *user_data)

Power policy callback — returns recommended next state.

Parameters
[in]currentCurrent power state.
[in]idle_msMilliseconds since last activity.
[in]next_timeout_msMilliseconds until next scheduled event.
[in]user_dataOpaque pointer from ove_pm_set_policy().
Returns
Recommended next power state.

◆ ove_pm_notify_fn

typedef void(* ove_pm_notify_fn) (ove_pm_event_t event, ove_pm_state_t from_state, ove_pm_state_t to_state, void *user_data)

Transition notification callback.

Parameters
[in]eventPRE_SLEEP or POST_WAKE.
[in]from_stateState being left.
[in]to_stateState being entered.
[in]user_dataOpaque pointer from ove_pm_notify_register().

Enumeration Type Documentation

◆ ove_pm_state_t

System power states, ordered by increasing sleep depth.

Enumerator
OVE_PM_STATE_ACTIVE 

Full speed.

OVE_PM_STATE_IDLE 

Light sleep, fast wakeup.

OVE_PM_STATE_STANDBY 

Deep idle, some peripherals off.

OVE_PM_STATE_DEEP_SLEEP 

Lowest power, RAM retained.

◆ ove_pm_wake_type_t

Wake source types.

Enumerator
OVE_PM_WAKE_GPIO 

GPIO pin edge.

OVE_PM_WAKE_TIMER 

Timer expiry.

OVE_PM_WAKE_UART 

UART RX activity.

OVE_PM_WAKE_RTC 

RTC alarm.

◆ ove_pm_event_t

Transition event type for notification callbacks.

Enumerator
OVE_PM_EVENT_PRE_SLEEP 

About to enter low-power state.

OVE_PM_EVENT_POST_WAKE 

Just woke from low-power state.