TB2026-YDS Firmware
Loading...
Searching...
No Matches
fuel_gauge.h File Reference

MAX17260 ModelGauge m5 EZ 1-cell fuel gauge (I2C 0x36). More...

#include <stdbool.h>
#include <stdint.h>
#include "esp_err.h"
#include "driver/i2c_master.h"

Go to the source code of this file.

Data Structures

struct  fuel_gauge_data_t
 Snapshot of the gauge's application-facing outputs. More...
struct  fuel_gauge_debug_t
 Register-level snapshot for the debug page: config vs expected + learned state. More...

Functions

esp_err_t fuel_gauge_init (i2c_master_bus_handle_t bus)
 Attach the gauge to the shared I2C bus and run EZ config if needed.
esp_err_t fuel_gauge_read (fuel_gauge_data_t *out)
 Read and convert all fields of a fuel_gauge_data_t in one pass.
esp_err_t fuel_gauge_read_debug (fuel_gauge_debug_t *out)
 Read the configuration and learned-capacity registers for the debug page.
esp_err_t fuel_gauge_reload_ez (void)
 Re-run the EZ model load to purge the learned battery state.

Detailed Description

MAX17260 ModelGauge m5 EZ 1-cell fuel gauge (I2C 0x36).

One-shot EZ configuration on power-up (POR), then a snapshot read of the application-facing measurements. Current/capacity scaling assumes the board's 5 mOhm sense resistor; the cell parameters (design capacity, charge-termination current) are compile-time constants in fuel_gauge.c — change them with the cell.

No NTC is fitted, so the temperature field is the IC's internal die temperature, not the battery temperature.

Note
Développé avec l'assistance de Claude Opus 4.8 (Anthropic), sous la direction de Y. Dos Santos : spécification, revue et validation sur cible par l'auteur.