A no_std
, async Rust driver for the Nordic nPM1300 Power Management IC (PMIC).
This crate provides both low-level register access and a high-level API for managing PMIC functions.
no_std
support for embedded environments- Async design
- Type-safe register access
defmt
support for logging (optional)- Generated low-level API using
device-driver
- Minimal dependencies
Important
The driver is currently under development, and the API may change before reaching 1.0.
Component | Low-Level API | High-Level API |
---|---|---|
SYSREG — System regulator | ✅ | ✅ |
CHARGER — Battery charger | ✅ | ✅ |
BUCK — Buck regulators | ✅ | ✅ |
LOADSW/LDO — Load switches/LDO regulators | ❌ | ❌ |
LEDDRV — LED drivers | ✅ | ✅ |
GPIO — General-purpose I/O | ✅ | ✅ |
ADC - System Monitor | ✅ | |
POF - Power-fail comparator | ✅ | ✅ |
TIMER — Timer/monitor | ❌ | ❌ |
Ship and hibernate modes | ✅ | ✅ |
Event and interrupt | ❌ | ❌ |
Reset and error | ❌ | ❌ |
Fuel gauge | ❌ | ❌ |
Legend:
- ✅ Fully implemented (at least should be)
⚠️ Implemented but has known issues (see Issues)- ❌ Not yet implemented
Warning
While core functionality has been tested, this driver is not yet production-ready. Contributions and bug reports are welcome!
Note
This crate is async-only and there are no plans to add synchronous APIs. Contributions are welcome!
Here's a minimal example using the Embassy framework on an nRF52840:
#![no_std]
#![no_main]
use embassy_executor::Spawner;
use embassy_nrf::{
bind_interrupts,
peripherals,
twim::{self, Twim},
};
use {defmt_rtt as _, panic_probe as _};
use npm1300_rs::{
types::BuckVoltage,
NPM1300,
};
bind_interrupts!(struct Irqs {
SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0 => twim::InterruptHandler<peripherals::TWISPI0>;
});
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_nrf::init(Default::default());
let config = twim::Config::default();
let twi = Twim::new(p.TWISPI0, Irqs, p.P0_07, p.P0_12, config);
let mut npm1300 = NPM1300::new(twi);
let _ = npm1300.set_buck2_normal_voltage(BuckVoltage::V1_8).await;
let _ = npm1300.enable_buck2().await;
}
More examples can be found in the examples
directory.
- GitHub Issues - Bug reports, feature requests, and questions
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
We welcome contributions! Please:
- Fork the repository
- Create a feature branch
- Follow conventional commits for commit messages
- Submit a Pull Request
By contributing, you agree that your work will be dual-licensed as above, without additional terms or conditions.