struct __attribute__((packed))
Definition autonomy.c:55
power_off_cause_t
How the previous session ended, reconstructed at boot.
Definition power.h:170
void power_set_usb_route(power_usb_route_t route)
Route the USB-C mux to data or charge.
Definition power.c:145
void power_coredump_export(void)
Copy a pending panic core dump from flash to the SD card, then erase it.
Definition power.c:273
power_usb_route_t power_get_usb_route(void)
The route currently driven onto PIN_USB_DIR (for diagnostics).
Definition power.c:153
const char * power_last_crash_task(void)
Faulting task name when the cause is POWER_OFF_CRASH ("" otherwise).
Definition power.c:313
void(* power_shutdown_hook_t)(void)
Callback run by power_shutdown() before the rail is cut (e.g. amp+DAC power-down).
Definition power.h:51
uint32_t power_get_sleep_ms(void)
Idle time before the screen blanks (UI task). 0 = never sleep.
Definition power.c:205
power_usb_route_t
USB-C mux routing through the PI3USB221AZUAEX (PIN_USB_DIR).
Definition power.h:45
bool power_soc_at_shutdown(float soc_pct)
True when this SoC is at or below the graceful auto-off threshold.
Definition power.c:135
void power_set_poweroff_ms(uint32_t ms)
Set and persist the auto power-off timeout.
Definition power.c:230
uint32_t power_get_poweroff_ms(void)
Idle time before the board auto powers off (maintenance task). 0 = never.
Definition power.c:221
void power_tick(void)
Refresh the cached battery state and apply the low-battery policy.
Definition power.c:93
void power_shutdown(void) __attribute__((noreturn))
Run the shutdown hook (if any), release EnableReg, and power the board off.
Definition power.c:323
void power_set_sleep_ms(uint32_t ms)
Set and persist the screen-sleep timeout.
Definition power.c:214
void power_set_low_batt_shutdown(bool enable)
Enable or disable the built-in critical-battery auto-shutdown (default enabled).
Definition power.c:195
power_off_cause_t power_last_off_cause(void)
How the previous session ended. Valid after power_boot_off_check().
Definition power.c:268
void power_set_shutdown_hook(power_shutdown_hook_t hook)
Register a callback to run at the start of power_shutdown().
Definition power.c:200
void power_usb_autoroute_start(void)
USB mux hand-off: charger first, then console.
Definition power.c:182
uint32_t power_last_crash_pc(void)
Faulting program counter when the cause is POWER_OFF_CRASH (0 otherwise).
Definition power.c:318
power_level_t
Battery charge level band, derived from state of charge.
Definition power.h:37
void power_self_hold(void)
Latch the regulator on by driving EnableReg high.
Definition power.c:87
void power_boot_off_check(void)
Classify how the previous session ended (call once at boot, after NVS is up).
Definition power.c:237
void power_get_state(power_state_t *out)
Copy the latest cached battery snapshot.
Definition power.c:140
@ POWER_OFF_CLEAN
power_shutdown() ran (user off, critical battery, autonomy end)
Definition power.h:173
@ POWER_OFF_CRASH
a panic core dump was found in flash
Definition power.h:174
@ POWER_OFF_POWER_LOSS
Definition power.h:171
@ POWER_USB_DATA
LOW: route D+/D- to the CP2102N (console / flash).
Definition power.h:46
@ POWER_USB_CHARGE
HIGH: route to the MAX77757 charger (USB source current detection).
Definition power.h:47
@ POWER_LEVEL_CRITICAL
Definition power.h:40
@ POWER_LEVEL_LOW
at or below the low threshold (warn the user)
Definition power.h:39
@ POWER_LEVEL_NORMAL
above the low threshold
Definition power.h:38
Cached battery/charge snapshot, refreshed by power_tick().
Definition power.h:54
bool charging
current into the cell above the charge threshold
Definition power.h:59
float current_ma
Definition power.h:58
power_level_t level
charge band derived from soc_pct
Definition power.h:62
float voltage_v
cell voltage, V
Definition power.h:57
float soc_pct
state of charge, %
Definition power.h:56
bool external_power
input present (INOKB asserted): USB/charger plugged in
Definition power.h:60
float tte_s
time to empty, s (only meaningful while discharging; 0 otherwise)
Definition power.h:61
bool valid
false until the first successful fuel-gauge read
Definition power.h:55