|
TB2026-YDS Firmware
|
I2C access to the ModelGauge m5 EZ state-of-charge and analog measurements. More...

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. | |
I2C access to the ModelGauge m5 EZ state-of-charge and analog measurements.
| 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.
Reads the POR flag: if the gauge has already been configured (POR clear), the learned battery state is kept and only the device handle is registered. On a fresh power-up it loads the EZ model (design capacity, charge-termination current, empty voltage) and clears POR.
| bus | Master bus handle from i2c_bus_init(). |
| 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.
| [out] | out | Receives the converted measurements. |
| esp_err_t fuel_gauge_read_debug | ( | fuel_gauge_debug_t * | out | ) |
Read the configuration and learned-capacity registers for the debug page.
| [out] | out | Receives the snapshot. |
| esp_err_t fuel_gauge_reload_ez | ( | void | ) |
Re-run the EZ model load to purge the learned battery state.
Preserves the cycle counter across the reload; everything else learned (full capacity, hence health) restarts from the design values, and SOC is re-estimated from voltage — best done at rest, right after a charge the estimate overshoots for a few minutes.