Skip to content
JaskRendixPublic

About

Async, no_std Rust driver for the TI BQ76952 battery monitor using embedded-hal. Supports typed data‑memory access, telemetry, protection, FET control, balancing, and power modes, with mockable I²C backends and embedded examples.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

24 Commits

Folders and files

Repository files navigation

BQ76952 Battery Monitor Library (STM32, no_std, Rust)

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.


Purpose of the Library

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_std Rust API
  • safe data‑memory access with automatic checksum
  • predictable behavior under concurrency
  • compatibility with any embedded-hal I²C backend
  • a fully testable driver using mock I²C interfaces

The implementation follows the behavior and command structure described in the TI documentation.


Upstream Source

This driver is based on:


Hardware

  • Monitor/Protector: Texas Instruments BQ76952
  • Cells: 3–16 series Li‑ion / Li‑polymer / LiFePO₄
  • Target MCU: STM32 (or any embedded-hal compatible MCU)
  • Interfaces: I²C, ALERT pin, TSx thermistors, FET drivers, cell inputs

Rust Setup

The driver uses:

  • embedded-hal for I²C
  • no_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

Telemetry

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.


Protection Modes

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

Security States

The BQ76952 supports:

  • Sealed
  • Unsealed
  • Full Access

The driver includes unseal key handling and state tracking.


FET & Balancing Control

Supported operations:

  • Charge FET control
  • Discharge FET control
  • Combined FET control
  • Manual cell balancing
  • FET Status monitoring
  • ALERT, DCHG, and DDSG pin status monitoring

Power Modes

Supported:

  • Normal
  • Sleep
  • Shutdown

Driver includes helpers for entering/exiting modes.


Data Memory Access

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

Status Register Support

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).


Examples

  • monitor — full monitoring loop: voltages, current, temperatures, safety status

Run examples:

cargo run --example monitor

Documentation

This 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.

References

About

Async, no_std Rust driver for the TI BQ76952 battery monitor using embedded-hal. Supports typed data‑memory access, telemetry, protection, FET control, balancing, and power modes, with mockable I²C backends and embedded examples.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages