25static const char*
const s_tag =
"ra8_batt";
43 const uint8_t low_rearm =
45 const uint8_t crit_rearm =
49 if (charging || (soc > low_rearm)) {
52 if (charging || (soc > crit_rearm)) {
88 RA8_ASSERT(label !=
nullptr,
"nag label must be non-null");
static const char * s_tag
Logging / check tag.
ra8_err_t ra8_batt_update(ra8_batt_monitor_t *mon, uint8_t soc_pct, bool charging, ra8_batt_nag_t *out_nag)
Fold one SOC reading into the monitor and report the nag to raise.
ra8_err_t ra8_batt_monitor_init(ra8_batt_monitor_t *mon)
Reset a nag monitor to the un-nagged, fully-armed state.
const char * ra8_batt_nag_str(ra8_batt_nag_t nag)
Map a nag level to a short, stable upper-case label.
Bounded, allocation-free low-battery nag policy.
@ k_ra8_batt_pct_max
SOC clamp ceiling.
@ k_ra8_batt_critical_pct
Critical threshold (inclusive).
@ k_ra8_batt_low_pct
Low-battery threshold (inclusive).
@ k_ra8_batt_rearm_margin
Hysteresis above a band to re-arm it.
ra8_batt_nag_t
The low-battery warning a single ra8_batt_update step raises.
@ k_ra8_batt_nag_none
No new warning this step.
@ k_ra8_batt_nag_critical
SOC fell to the critical band (<=10%).
@ k_ra8_batt_nag_low
SOC fell to the low band (<=20%).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_ASSERT(condition, message)
Runtime invariant check.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Caller-owned nag state carried across ra8_batt_update calls.
bool low_raised
Low nag raised and not yet re-armed.
bool critical_raised
Critical nag raised and not yet re-armed.