e3c7201a20
* Furi: rename and move core * Furi: drop CMSIS_OS header and unused api, partially refactor and cleanup the rest * Furi: CMSIS_OS drop and refactoring. * Furi: refactoring, remove cmsis legacy * Furi: fix incorrect assert on queue deallocation, cleanup timer * Furi: improve delay api, get rid of floats * hal: dropped furi_hal_crc * Furi: move DWT based delay to cortex HAL * Furi: update core documentation Co-authored-by: hedger <hedger@nanode.su>
88 lines
1.7 KiB
C
88 lines
1.7 KiB
C
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <core/pubsub.h>
|
|
#include <stdbool.h>
|
|
|
|
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;
|
|
|
|
float current_charger;
|
|
float current_gauge;
|
|
|
|
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 mesage
|
|
*
|
|
* @param power Power instance
|
|
* @param enable true - enable, false - disable
|
|
*/
|
|
void power_enable_low_battery_level_notification(Power* power, bool enable);
|