This project provides a Rust implementation of the Texas Instruments BQ76952 3‑to‑16‑cell battery monitor and protector.
It is based on TI’s reference documentation, rewritten to use no_std and embedded-hal traits with a mockable I²C interface.
The goal is to expose a safe, typed API for configuration, telemetry, protection, and FET/balancing control.
TI’s BQ76952 uses a command/data‑memory architecture that requires:
- structured subcommands
- checksummed data‑memory writes
- specific sequencing rules
Vendor examples often rely on blocking I²C and manual register handling.
This Rust port provides:
- a
no_stdRust API - safe data‑memory access with automatic checksum
- predictable behavior under concurrency
- compatibility with any
embedded-halI²C backend - a fully testable driver using mock I²C interfaces
The implementation follows the behavior and command structure described in the TI documentation.
This driver is based on:
- Monitor/Protector: Texas Instruments BQ76952
- Cells: 3–16 series Li‑ion / Li‑polymer / LiFePO₄
- Target MCU: STM32 (or any
embedded-halcompatible MCU) - Interfaces: I²C, ALERT pin, TSx thermistors, FET drivers, cell inputs
The driver uses:
embedded-halfor I²Cno_std- mockable I²C for testing
It exposes:
- register access
- subcommand access
- data‑memory read/write
- voltage, current, and temperature telemetry
- safety alert and status monitoring
- permanent fault monitoring
- battery, alarm, and FET status monitoring
- protection configuration
- FET and cell‑balancing control
- security/unseal handling
- sleep/shutdown mode control
The BQ76952 provides:
- Cell voltages (1–16)
- Stack voltage
- Min/max cell voltage
- Current measurement (CC2)
- Temperatures: internal die, TS1/TS2/TS3, HDQ, DCHG, DDSG
Kelvin‑to‑Celsius helpers included.
Supported protection categories:
- Cell overvoltage / undervoltage
- Charge/discharge overcurrent
- Short‑circuit protections
- Temperature protections
- Permanent Faults (PF)
The driver exposes:
- Safety Alert A/B/C
- Safety Status A/B/C
- Permanent Fault Status A
- Alarm Status
- Battery Status
- FET Status
- threshold and delay configuration
- recovery
The BQ76952 supports:
- Sealed
- Unsealed
- Full Access
The driver includes unseal key handling and state tracking.
Supported operations:
- Charge FET control
- Discharge FET control
- Combined FET control
- Manual cell balancing
- FET Status monitoring
- ALERT, DCHG, and DDSG pin status monitoring
Supported:
- Normal
- Sleep
- Shutdown
Driver includes helpers for entering/exiting modes.
The BQ76952 uses a structured data‑memory map with checksums.
The driver provides:
- safe read/write
- automatic checksum
- typed accessors
- raw access for advanced configuration
The driver provides typed accessors for the following BQ76952 status registers:
- Battery Status
- Alarm Status
- Safety Alert A/B/C
- Safety Status A/B/C
- Permanent Fault Status A
- FET Status
All bitfield mappings are implemented according to the TI BQ76952 Technical Reference Manual (SLUUBY2B).
monitor— full monitoring loop: voltages, current, temperatures, safety status
Run examples:
cargo run --example monitorThis driver is implemented using the official Texas Instruments BQ76952 documentation and follows the command mappings, direct-command bitfields, data-memory architecture, telemetry interfaces, protection mechanisms, permanent-fault model, FET control interfaces, and security model described by TI.
-
BQ76952 Technical Reference Manual (SLUUBY2B)
https://www.ti.com/lit/ug/sluuby2b/sluuby2b.pdf -
BQ76952 Datasheet
https://www.ti.com/lit/ds/symlink/bq76952.pdf -
BQ76952 Software Development Guide
https://www.ti.com/lit/an/sluaa11a/sluaa11a.pdf