Skip to content
OpenDevicePartnershipPublic

About

Driver for TI BQ40Z50 Li-ion battery pack manager

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

1 watching

Forks

Repository files navigation

no-std check test Documentation Crates.io Version LICENSE

BQ40Z50 Rust Device Driver

A #[no_std] platform-agnostic driver for the BQ40Z50 family of lithium-ion battery fuel/gas gauge, capable of managing a 1- to 4-cell battery, using the embedded-hal traits.

A higher level API exposing standard Smart Battery Specification functions is built on top of the lower level register accessor using the embedded-batteries traits.

Four revisions of the chip are currently supported:

Please choose which revision you are using by enabling the appropriate feature.

MSRV

Currently, rust 1.94 and up is supported.

Testing

The test workflow runs each chip revision with and without embassy-timeout and pec-lookup-table. To run tests locally, select a revision and any optional features:

cargo test --locked --features r1
cargo test --locked --features r1,embassy-timeout,pec-lookup-table

Data flash writes

write_dataflash commits data in chunks of up to 32 bytes and is not atomic. If a write fails, earlier chunks are not rolled back, and the failing chunk may also have reached the gauge. Errors do not report how many bytes were committed. Retrying the entire write rewrites earlier chunks; callers must verify the affected data and handle recovery.

License

Licensed under the terms of the MIT license.

Contribution

Unless you explicitly state otherwise, any contribution submitted for inclusion in the work by you shall be licensed under the terms of the MIT license.

License: MIT

About

Driver for TI BQ40Z50 Li-ion battery pack manager

Resources

Code of conduct

Contributing

Security policy

Stars

9 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages