oveRTOS C++ API
C++20 RAII wrappers for the oveRTOS C API
Loading...
Searching...
No Matches
pm.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 Kamil Lulko <kamil.lulko@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 *
6 * This file is part of oveRTOS.
7 */
8
15#pragma once
16
17#include <ove/pm.h>
18#include <ove/types.hpp>
19
20#ifdef CONFIG_OVE_PM
21
22namespace ove {
23
31namespace pm {
32
33/* ── Enums (re-export C types for convenience) ──────────────────────── */
34
35using State = ove_pm_state_t;
36using WakeType = ove_pm_wake_type_t;
37using Domain = ove_pm_domain_t;
38using Event = ove_pm_event_t;
39using WakeSrc = ove_pm_wake_src;
40using Cfg = ove_pm_cfg;
41using Stats = ove_pm_stats;
42
43/* ── Lifecycle ──────────────────────────────────────────────────────── */
44
50[[nodiscard]] inline int init(const Cfg &cfg) {
51 return ove_pm_init(&cfg);
52}
53
57inline void deinit() {
58 ove_pm_deinit();
59}
60
61/* ── State machine ──────────────────────────────────────────────────── */
62
68[[nodiscard]] inline int set_state(State state) {
69 return ove_pm_set_state(state);
70}
71
76inline State get_state() {
77 return ove_pm_get_state();
78}
79
86inline void activity() {
87 ove_pm_activity();
88}
89
90/* ── Wake sources ───────────────────────────────────────────────────── */
91
97[[nodiscard]] inline int wake_register(const WakeSrc &src) {
98 return ove_pm_wake_register(&src);
99}
100
106[[nodiscard]] inline int wake_unregister(const WakeSrc &src) {
107 return ove_pm_wake_unregister(&src);
108}
109
110/* ── Peripheral power domains ───────────────────────────────────────── */
111
117[[nodiscard]] inline int domain_request(Domain domain) {
118 return ove_pm_domain_request(domain);
119}
120
126[[nodiscard]] inline int domain_release(Domain domain) {
127 return ove_pm_domain_release(domain);
128}
129
135[[nodiscard]] inline int domain_get_refcount(Domain domain) {
136 return ove_pm_domain_get_refcount(domain);
137}
138
139/* ── Policy ─────────────────────────────────────────────────────────── */
140
147[[nodiscard]] inline int set_policy(ove_pm_policy_fn policy,
148 void *user_data = nullptr) {
149 return ove_pm_set_policy(policy, user_data);
150}
151
152/* ── Notifications ──────────────────────────────────────────────────── */
153
160[[nodiscard]] inline int notify_register(ove_pm_notify_fn cb,
161 void *user_data = nullptr) {
162 return ove_pm_notify_register(cb, user_data);
163}
164
171[[nodiscard]] inline int notify_unregister(ove_pm_notify_fn cb,
172 void *user_data = nullptr) {
173 return ove_pm_notify_unregister(cb, user_data);
174}
175
176/* ── Statistics ─────────────────────────────────────────────────────── */
177
183[[nodiscard]] inline int get_stats(Stats &stats) {
184 return ove_pm_get_stats(&stats);
185}
186
190inline void reset_stats() {
191 ove_pm_reset_stats();
192}
193
194/* ── Power budget ───────────────────────────────────────────────────── */
195
201[[nodiscard]] inline int set_budget(uint32_t target_pct_x100) {
202 return ove_pm_set_budget(target_pct_x100);
203}
204
210[[nodiscard]] inline int get_budget_status(uint32_t &actual_pct_x100) {
211 return ove_pm_get_budget_status(&actual_pct_x100);
212}
213
214/* ── Idle processing ────────────────────────────────────────────────── */
215
222inline void idle_process() {
223 ove_pm_idle_process();
224}
225
226} /* namespace pm */
227
228} /* namespace ove */
229
230#endif /* CONFIG_OVE_PM */
int init()
Initialises the board hardware (clocks, pin-mux, etc.).
Definition board.hpp:35
void deinit()
Deinitialises the NVS subsystem and frees associated resources.
Definition nvs.hpp:43
Top-level namespace for all oveRTOS C++ abstractions.
Definition app.hpp:19
Common type definitions and concepts for the C++ wrapper layer.