axp2101_embedded/
lib.rs

1#![no_std]
2//! # AXP2101 Power Management IC Driver
3//!
4//! This crate provides a complete embedded driver for the AXP2101 Power Management IC (PMIC).
5//! It supports all features including:
6//! - Status monitoring (VBUS, battery, charging state)
7//! - DCDC1-5 voltage regulators
8//! - ALDO1-4, BLDO1-2, DLDO1-2, CPUSLDO voltage regulators
9//! - Battery charging control
10//! - ADC measurements
11//! - Interrupt handling
12//! - Watchdog timer
13//! - Power sequencing
14//!
15//! ## Example
16//!
17//! ```no_run
18//! use axp2101::{Axp2101, Error};
19//! # use embedded_hal::i2c::I2c;
20//! # fn example<I: I2c>(i2c: I) -> Result<(), Error<I::Error>> {
21//! let mut pmic = Axp2101::new(i2c);
22//!
23//! // Initialize and verify chip
24//! pmic.init()?;
25//!
26//! // Enable DC1 at 3.3V
27//! pmic.enable_dc1()?;
28//! pmic.set_dc1_voltage(3300)?;
29//!
30//! // Check battery status
31//! if pmic.is_battery_connected()? {
32//!     let voltage = pmic.get_battery_voltage()?;
33//!     // ... use battery voltage
34//! }
35//! # Ok(())
36//! # }
37//! ```
38//!
39//! ## Async Support
40//!
41//! When the `async` feature is enabled, the crate provides `AsyncAxp2101`
42//! with the same API but async/await support:
43//!
44//! ```no_run
45//! # #[cfg(feature = "async")]
46//! # async fn example<I: embedded_hal_async::i2c::I2c>(i2c: I) -> Result<(), axp2101::Error<I::Error>> {
47//! use axp2101::AsyncAxp2101;
48//!
49//! let mut pmic = AsyncAxp2101::new(i2c);
50//! pmic.init().await?;
51//! pmic.enable_dc1().await?;
52//! # Ok(())
53//! # }
54//! ```
55
56mod driver;
57#[cfg(feature = "async")]
58mod driver_async;
59mod error;
60mod registers;
61mod types;
62
63// Re-export main types
64pub use driver::Axp2101;
65#[cfg(feature = "async")]
66pub use driver_async::AsyncAxp2101;
67pub use error::Error;
68pub use registers::*;
69pub use types::*;