Move bwm_battery_info_t into pm3_cmd.h (shared wire-protocol header)
bwm_charger.h is an armsrc-only header included after pm3_cmd.h in appmain.c, so a struct embedding bwm_battery_info_t by value (e.g. a future PM5 status command) couldn't see the type at the point it's needed. bwm_ble_status_t and bwm_autooff_status_t already live in pm3_cmd.h for the same reason - this just brings bwm_battery_info_t in line with them. bwm_charger.c/.h keep their function declarations unchanged; only the struct's home moves. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5661f21d60
commit
f2df3eba9d
2 files changed
+23
-21
No files matched your search
+6
-21
@@ -28,6 +28,7 @@
|
|||||||
#define __BWM_CHARGER_H
|
#define __BWM_CHARGER_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "pm3_cmd.h" // bwm_battery_info_t
|
||||||
|
|
||||||
// Reference design capacity for the fitted cell (VXE 502540, 500 mAh / 3.7 V).
|
// Reference design capacity for the fitted cell (VXE 502540, 500 mAh / 3.7 V).
|
||||||
// Used as the default target for `hw bwm setcap` and as the fall-back divisor for
|
// Used as the default target for `hw bwm setcap` and as the fall-back divisor for
|
||||||
@@ -51,27 +52,11 @@ void bwm_detect_and_init(void);
|
|||||||
// detected by bwm_detect_and_init().
|
// detected by bwm_detect_and_init().
|
||||||
void bwm_print_battery_status(void);
|
void bwm_print_battery_status(void);
|
||||||
|
|
||||||
// Compact battery telemetry for CMD_PM5_BWM_GET_BATTERY - a machine-readable
|
// Fills in bwm_battery_info_t (pm3_cmd.h) for CMD_PM5_BWM_GET_BATTERY - same
|
||||||
// subset of what bwm_print_battery_status() prints (same underlying reads,
|
// underlying reads as bwm_print_battery_status(), so the two can't drift on
|
||||||
// so the two can't drift on the numbers they share). All fields zeroed if
|
// the numbers they share. Returns false (all fields zeroed) if no BWM was
|
||||||
// bwm_present is false or gauge_ok is false.
|
// detected. A false gauge_ok with bwm_present true means the charger ACKed
|
||||||
typedef struct {
|
// but the fuel gauge didn't.
|
||||||
bool bwm_present;
|
|
||||||
bool gauge_ok;
|
|
||||||
uint16_t soc_pct;
|
|
||||||
uint16_t voltage_mv;
|
|
||||||
int16_t current_ma; // +charge / -discharge
|
|
||||||
uint16_t remaining_mah;
|
|
||||||
uint16_t full_charge_mah;
|
|
||||||
uint16_t design_cap_mah;
|
|
||||||
int16_t temp_c10; // tenths of a degree C
|
|
||||||
uint8_t charger_fault; // 0 = none, else AW32001E REG09 bits masked 0x3F
|
|
||||||
uint8_t charge_status; // 0=not charging,1=pre-charge,2=charging,3=done
|
|
||||||
uint8_t health_pct;
|
|
||||||
} PACKED bwm_battery_info_t;
|
|
||||||
|
|
||||||
// Returns false (all fields zeroed) if no BWM was detected. A false gauge_ok
|
|
||||||
// with bwm_present true means the charger ACKed but the fuel gauge didn't.
|
|
||||||
bool bwm_read_battery_info(bwm_battery_info_t *out);
|
bool bwm_read_battery_info(bwm_battery_info_t *out);
|
||||||
|
|
||||||
// One-time BQ27427 Design Capacity provisioning (CMD_PM5_BWM_SET_CAP /
|
// One-time BQ27427 Design Capacity provisioning (CMD_PM5_BWM_SET_CAP /
|
||||||
|
|||||||
@@ -987,6 +987,23 @@ typedef struct {
|
|||||||
uint8_t bonded_count;
|
uint8_t bonded_count;
|
||||||
uint8_t bonded[BWM_BLE_BONDED_MAX][7]; // addr[6] + type, first bonded_count valid
|
uint8_t bonded[BWM_BLE_BONDED_MAX][7]; // addr[6] + type, first bonded_count valid
|
||||||
} PACKED bwm_ble_status_t;
|
} PACKED bwm_ble_status_t;
|
||||||
|
// Compact battery telemetry shared by `hw status`'s underlying data source and
|
||||||
|
// any client (e.g. the Flipper Zero FAP) wanting raw numbers instead of free-text
|
||||||
|
// Dbprintf lines. All fields zeroed if bwm_present is false or gauge_ok is false.
|
||||||
|
typedef struct {
|
||||||
|
bool bwm_present;
|
||||||
|
bool gauge_ok;
|
||||||
|
uint16_t soc_pct;
|
||||||
|
uint16_t voltage_mv;
|
||||||
|
int16_t current_ma; // +charge / -discharge
|
||||||
|
uint16_t remaining_mah;
|
||||||
|
uint16_t full_charge_mah;
|
||||||
|
uint16_t design_cap_mah;
|
||||||
|
int16_t temp_c10; // tenths of a degree C
|
||||||
|
uint8_t charger_fault; // 0 = none, else AW32001E REG09 bits masked 0x3F
|
||||||
|
uint8_t charge_status; // 0=not charging,1=pre-charge,2=charging,3=done
|
||||||
|
uint8_t health_pct;
|
||||||
|
} PACKED bwm_battery_info_t;
|
||||||
// PM5, read compact BWM battery telemetry (bwm_battery_info_t). Used by `hw status`'s
|
// PM5, read compact BWM battery telemetry (bwm_battery_info_t). Used by `hw status`'s
|
||||||
// underlying data source and by clients (e.g. the Flipper Zero FAP) that want the raw
|
// underlying data source and by clients (e.g. the Flipper Zero FAP) that want the raw
|
||||||
// numbers instead of hw status's free-text Dbprintf lines.
|
// numbers instead of hw status's free-text Dbprintf lines.
|
||||||
|
|||||||
Reference in new issue
Block a user