unleashed-firmware/firmware/targets/api-hal-include/api-hal-power.h

89 lines
2 KiB
C
Raw Normal View History

#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <m-string.h>
#ifdef __cplusplus
extern "C" {
#endif
2020-12-22 18:16:32 +00:00
typedef enum {
ApiHalPowerICCharger,
ApiHalPowerICFuelGauge,
} ApiHalPowerIC;
/* Initialize drivers */
void api_hal_power_init();
/* Get current insomnia level
* @return insomnia level: 0 - no insomnia, >0 - insomnia, bearer count.
*/
uint16_t api_hal_power_insomnia_level();
/* Enter insomnia mode
* Prevents device from going to sleep
* @warning Internally increases insomnia level
* Must be paired with api_hal_power_insomnia_exit
*/
void api_hal_power_insomnia_enter();
/* Exit insomnia mode
* Allow device to go to sleep
* @warning Internally decreases insomnia level.
* Must be paired with api_hal_power_insomnia_enter
*/
void api_hal_power_insomnia_exit();
[FL-781] FURI, CLI, stdlib: stdout hooks, integration between subsystems, uniform printf usage (#311) * FURI stdglue: stdout hooks, local and global, ISR safe printf. Uniform newlines for terminal/debug output. Power: prevent sleep while core 2 has not started. * Furi record, stdglue: check mutex allocation * remove unused test * Furi stdglue: buferized output, dynamically allocated state. Furi record: dynamically allocated state. Input dump: proper line ending. Hal VCP: dynamically allocated state. * Interrupt manager: explicitly init list. * Makefile: cleanup rules, fix broken dfu upload. F4: add compiler stack protection options. * BLE: call debug uart callback on transmission complete * FreeRTOS: add configUSE_NEWLIB_REENTRANT * API HAL Timebase: fix issue with idle thread stack corruption caused by systick interrupt. BT: cleanup debug info output. FreeRTOS: disable reentry for newlib. * F4: update stack protection CFLAGS to match used compiller * F4: disable compiller stack protection because of incompatibility with current compiller * Makefile: return openocd logs to gdb * BLE: fixed pin, moar power, ble trace info. * Prevent sleep when connection is active * Makefile: return serial port to upload rule, add workaround for mac os * Furi: prevent usage of stack for cmsis functions. * F4: add missing includes, add debugger breakpoints * Applications: per app stack size. * Furi: honor kernel state in stdglue * FreeRTOS: remove unused hooks * Cleanup and format sources Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
2021-01-29 00:09:33 +00:00
/* Check if deep sleep availble */
bool api_hal_power_deep_available();
/* Go to deep sleep */
void api_hal_power_deep_sleep();
/* Get predicted remaining battery capacity in percents */
uint8_t api_hal_power_get_pct();
/* Get battery health state in percents */
uint8_t api_hal_power_get_bat_health_pct();
/* Get charging status */
bool api_hal_power_is_charging();
/* Poweroff system */
void api_hal_power_off();
/* OTG enable */
void api_hal_power_enable_otg();
/* OTG disable */
void api_hal_power_disable_otg();
2020-12-22 18:16:32 +00:00
/* Get remaining battery battery capacity in mAh */
uint32_t api_hal_power_get_battery_remaining_capacity();
/* Get full charge battery capacity in mAh */
uint32_t api_hal_power_get_battery_full_capacity();
/* Get battery voltage in V */
2020-12-22 18:16:32 +00:00
float api_hal_power_get_battery_voltage(ApiHalPowerIC ic);
/* Get battery current in A */
2020-12-22 18:16:32 +00:00
float api_hal_power_get_battery_current(ApiHalPowerIC ic);
2020-12-18 18:03:28 +00:00
/* Get temperature in C */
2020-12-22 18:16:32 +00:00
float api_hal_power_get_battery_temperature(ApiHalPowerIC ic);
/* Get System voltage in V */
float api_hal_power_get_system_voltage();
/* Get USB voltage in V */
float api_hal_power_get_usb_voltage();
2020-12-18 18:03:28 +00:00
/* Get power system component state */
void api_hal_power_dump_state(string_t buffer);
#ifdef __cplusplus
}
#endif