1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//! # AXP192 Power Management Chip Interface
//!
//! This crate provides a bisync-based driver for the AXP192 power management IC,
//! built upon the `device-driver` crate for robust, declarative register
//! definitions via a YAML manifest. It supports both asynchronous (`async`)
//! and blocking operation through a unified API, using the [`bisync`](https://docs.rs/bisync) crate
//! for seamless compatibility with both `embedded-hal` and `embedded-hal-async` traits.
//!
//! ## Features
//!
//! * **Declarative Register Map:** Full device configuration defined in `device.yaml`.
//! * **Unified Async/Blocking Support:** Write your code once and use it in both async and blocking contexts via bisync.
//! * **Type-Safe API:** High-level functions for common operations (e.g., setting voltages)
//! and a generated low-level API (`ll`) for direct register access.
//! * **Comprehensive Register Coverage:** Aims to support the full feature set of the AXP192.
//! * **`defmt` and `log` Integration:** Optional support for logging and debugging.
//!
//! ## Getting Started
//!
//! To use the driver, instantiate `Axp192` (blocking) or `Axp192Async` (async) with your I2C bus implementation:
//!
//! ```rust,no_run
//! # use embedded_hal::i2c::I2c;
//! # use axp192_dd::{Axp192, DcId};
//! let i2c_bus = todo!();
//! let mut axp = Axp192::new(i2c_bus);
//!
//! axp.set_dcdc_voltage(DcId::Dcdc1, 3300)?;
//! # Ok(())
//! ```
//!
//! For async environments, use `Axp192Async` (re-exported from the `asynchronous` module):
//!
//! ```rust,no_run
//! # use embedded_hal_async::i2c::I2c;
//! # use axp192_dd::{Axp192Async, DcId};
//! let i2c_bus = todo!();
//! let mut axp = Axp192Async::new(i2c_bus);
//!
//! axp.set_dcdc_voltage(DcId::Dcdc1, 3300).await?;
//! # Ok(())
//! ```
//!
//! For a detailed register map, please refer to the `device.yaml` file in the
//! [repository](https://github.com/okhsunrog/axp192-dd).
//!
//! ## Supported Devices
//!
//! The AXP192 is found in various embedded devices, including but not limited to:
//!
//! * [M5Stack Core 2](https://docs.m5stack.com/en/core/core2) (including the [Core 2 for
//! AWS](https://docs.m5stack.com/en/core/core2_for_aws) variant)
//! * [M5Stack Tough](https://docs.m5stack.com/en/core/tough)
//! * [M5StickC](https://docs.m5stack.com/en/core/m5stickc)
//! * [M5StickC PLUS](https://docs.m5stack.com/en/core/m5stickc_plus)
//!
//! ## Warning!
//!
//! ***Caution!*** This chip controls power to the microcontroller and other critical
//! components. Incorrect configuration can potentially damage or brick your device.
//! Proceed with care and always consult the AXP192 datasheet.
//!
//! ## Datasheet
//!
//! [AXP192 Datasheet v1.1 (English Draft)](https://github.com/m5stack/M5-Schematic/blob/master/Core/AXP192%20Datasheet_v1.1_en_draft_2211.pdf)
//!
pub
use Error;
create_device!;
pub const AXP192_I2C_ADDRESS: u8 = 0x34;
pub use Axp192 as Axp192Async;
pub use Axp192;