| Crates.io | bq25185 |
| lib.rs | bq25185 |
| version | 0.1.1 |
| created_at | 2025-12-01 23:33:27.797101+00 |
| updated_at | 2025-12-02 00:10:27.013167+00 |
| description | A basic and simple BQ25185 battey charging IC driver |
| homepage | |
| repository | https://github.com/acedogblast/bq25185 |
| max_upload_size | |
| id | 1960852 |
| size | 10,510 |
A basic and simple platform-agnostic driver for the Texas Instruments BQ25185 battery charger IC using [embedded-hal] traits.
Designed for use in no_std embedded environments.
Status emum.embedded-hal] traits.no_std support.Add this to your Cargo.toml:
[dependencies]
bq25185 = "=0.1.1"
#![no_std]
#![no_main]
use bq25185::driver::Bq25185;
use bq25185::Status;
use defmt::{error, info};
use esp_hal::clock::CpuClock;
use esp_hal::gpio::{Input, Output};
use esp_hal::main;
use esp_hal::time::{Duration, Instant};
#[panic_handler]
fn panic(_error: &core::panic::PanicInfo) -> ! {
error!("Panic occured!");
loop {}
}
esp_bootloader_esp_idf::esp_app_desc!();
#[main]
fn main() -> ! {
rtt_target::rtt_init_defmt!();
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
let peripherals = esp_hal::init(config);
// GPIO definitions
let charger_stat1 = peripherals.GPIO5;
let charger_stat2 = peripherals.GPIO7;
// Charger status GPIO
let config = esp_hal::gpio::InputConfig::default();
let charger_stat1 = Input::new(charger_stat1, config);
let charger_stat2 = Input::new(charger_stat2, config);
let mut charger: Bq25185<Input<'_>, Output<'_>> =
Bq25185::new(charger_stat1, charger_stat2, None); // Not using the charge enable pin.
loop {
match charger.get_status().unwrap() {
Status::ChargeComplete => info!("ChargeComplete"),
Status::NonRecoverableFault => info!("NonRecoverableFault"),
Status::RecoverableFault => info!("RecoverableFault"),
Status::NormalCharging => info!("NormalCharging"),
}
let delay_start = Instant::now();
while delay_start.elapsed() < Duration::from_secs(10) {}
}
}