ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_batt.h
Go to the documentation of this file.
1
35
36#pragma once
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42#include <stdint.h>
43
44#include "ra8_err.h"
45
59
74
85typedef struct {
89
116
146ra8_batt_update(ra8_batt_monitor_t* mon, uint8_t soc_pct, bool charging, ra8_batt_nag_t* out_nag);
147
165const char* ra8_batt_nag_str(ra8_batt_nag_t nag);
166
167#ifdef __cplusplus
168}
169#endif
ra8_batt_threshold_t
Nag thresholds and hysteresis margin, in whole percent.
Definition ra8_batt.h:68
@ k_ra8_batt_pct_max
SOC clamp ceiling.
Definition ra8_batt.h:72
@ k_ra8_batt_critical_pct
Critical threshold (inclusive).
Definition ra8_batt.h:70
@ k_ra8_batt_low_pct
Low-battery threshold (inclusive).
Definition ra8_batt.h:69
@ k_ra8_batt_rearm_margin
Hysteresis above a band to re-arm it.
Definition ra8_batt.h:71
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.
Definition ra8_batt.c:36
ra8_batt_nag_t
The low-battery warning a single ra8_batt_update step raises.
Definition ra8_batt.h:54
@ k_ra8_batt_nag_none
No new warning this step.
Definition ra8_batt.h:55
@ k_ra8_batt_nag_critical
SOC fell to the critical band (<=10%).
Definition ra8_batt.h:57
@ k_ra8_batt_nag_low
SOC fell to the low band (<=20%).
Definition ra8_batt.h:56
ra8_err_t ra8_batt_monitor_init(ra8_batt_monitor_t *mon)
Reset a nag monitor to the un-nagged, fully-armed state.
Definition ra8_batt.c:27
const char * ra8_batt_nag_str(ra8_batt_nag_t nag)
Map a nag level to a short, stable upper-case label.
Definition ra8_batt.c:71
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Caller-owned nag state carried across ra8_batt_update calls.
Definition ra8_batt.h:85
bool low_raised
Low nag raised and not yet re-armed.
Definition ra8_batt.h:86
bool critical_raised
Critical nag raised and not yet re-armed.
Definition ra8_batt.h:87