mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-21 10:13:10 +00:00
76e97b8d35
* FuriHal: refactor power gauge config * Format sources and move gauge DM load to separate method * FuriHal: bq27220 refactoring part 1 * Power: use SYSDWN battery status flag for system shutdown * Libs: bq27220 read DM before write, fix incorrect shift * FuriHal: cleanup gauge config, add flags, add ptr DM type, update symbols * FuriHal: 2 stage gauge DM verification and update, better detection routine * FuriHal: update gauge configuration, lower sleep current and deadband * FuriHal: gauge and charger health reporting * Lib: cleanup bq27220 sources * FuriHal: correct documentation for furi_hal_power_is_shutdown_requested * FuriHal: proper gauge config for f7
100 lines
1.9 KiB
C
100 lines
1.9 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <core/pubsub.h>
|
|
#include <stdbool.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#define RECORD_POWER "power"
|
|
|
|
typedef struct Power Power;
|
|
|
|
typedef enum {
|
|
PowerBootModeNormal,
|
|
PowerBootModeDfu,
|
|
PowerBootModeUpdateStart,
|
|
} PowerBootMode;
|
|
|
|
typedef enum {
|
|
PowerEventTypeStopCharging,
|
|
PowerEventTypeStartCharging,
|
|
PowerEventTypeFullyCharged,
|
|
PowerEventTypeBatteryLevelChanged,
|
|
} PowerEventType;
|
|
|
|
typedef union {
|
|
uint8_t battery_level;
|
|
} PowerEventData;
|
|
|
|
typedef struct {
|
|
PowerEventType type;
|
|
PowerEventData data;
|
|
} PowerEvent;
|
|
|
|
typedef struct {
|
|
bool gauge_is_ok;
|
|
bool is_charging;
|
|
bool is_shutdown_requested;
|
|
|
|
float current_charger;
|
|
float current_gauge;
|
|
|
|
float voltage_battery_charge_limit;
|
|
float voltage_charger;
|
|
float voltage_gauge;
|
|
float voltage_vbus;
|
|
|
|
uint32_t capacity_remaining;
|
|
uint32_t capacity_full;
|
|
|
|
float temperature_charger;
|
|
float temperature_gauge;
|
|
|
|
uint8_t charge;
|
|
uint8_t health;
|
|
} PowerInfo;
|
|
|
|
/** Power off device
|
|
*/
|
|
void power_off(Power* power);
|
|
|
|
/** Reboot device
|
|
*
|
|
* @param mode PowerBootMode
|
|
*/
|
|
void power_reboot(PowerBootMode mode);
|
|
|
|
/** Get power info
|
|
*
|
|
* @param power Power instance
|
|
* @param info PowerInfo instance
|
|
*/
|
|
void power_get_info(Power* power, PowerInfo* info);
|
|
|
|
/** Get power event pubsub handler
|
|
*
|
|
* @param power Power instance
|
|
*
|
|
* @return FuriPubSub instance
|
|
*/
|
|
FuriPubSub* power_get_pubsub(Power* power);
|
|
|
|
/** Check battery health
|
|
*
|
|
* @return true if battery is healthy
|
|
*/
|
|
bool power_is_battery_healthy(Power* power);
|
|
|
|
/** Enable or disable battery low level notification message
|
|
*
|
|
* @param power Power instance
|
|
* @param enable true - enable, false - disable
|
|
*/
|
|
void power_enable_low_battery_level_notification(Power* power, bool enable);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|