Files
firmware/src/power/PowerHAL.h
phaseloop 57a3ff8dfc NRF52 - power management improvements (#9211)
* minor NRF52 test cleanup

* detect USB power input on ProMicro boards

* prevent booting on power failure detection

* introduce PowerHAL layer

* powerHAL basic implementation for NRF52

* prevent data saves on low power

* remove comment

* Update src/platform/nrf52/main-nrf52.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/power/PowerHAL.h

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/main.cpp

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Merge missing voltage threshold comparison

* add missing variable

* add missing function declaration

* remove debug strings

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
2026-01-24 08:39:03 -06:00

27 lines
1.0 KiB
C

/*
Power Hardware Abstraction Layer. Set of API calls to offload power management, measurements, reboots, etc
to the platform and variant code to avoid #ifdef spaghetti hell and limitless device-based edge cases
in the main firmware code
Functions declared here (with exception of powerHAL_init) should be defined in platform specific codebase.
Default function body does usually nothing.
*/
// Initialize HAL layer. Call it as early as possible during device boot
// do not overwrite it as it's not declared with "weak" attribute.
void powerHAL_init();
// platform specific init code if needed to be run early on boot
void powerHAL_platformInit();
// Return true if current battery level is safe for device operation (for example flash writes).
// This should be reported by power failure comparator (NRF52) or similar circuits on other platforms.
// Do not use battery ADC as improper ADC configuration may prevent device from booting.
bool powerHAL_isPowerLevelSafe();
// return if USB voltage is connected
bool powerHAL_isVBUSConnected();