Expand description
§INA3221 Triple-Channel Current/Voltage Monitor Interface
This crate provides a bisync-based driver for the INA3221 triple-channel, high-side
current and bus voltage monitor, 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
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 reading voltages and currents
and a generated low-level API (
ll) for direct register access. - Triple-Channel Monitoring: Simultaneously monitor 3 independent power rails.
defmtandlogIntegration: Optional support for logging and debugging.
§Getting Started
To use the driver, instantiate Ina3221 (blocking) or Ina3221Async (async) with your I2C bus implementation:
let i2c_bus = todo!();
let mut ina = Ina3221::new(i2c_bus);
let bus_voltage = ina.get_bus_voltage(ChannelId::Channel1)?;For async environments, use Ina3221Async (re-exported from the asynchronous module):
let i2c_bus = todo!();
let mut ina = Ina3221Async::new(i2c_bus);
let bus_voltage = ina.get_bus_voltage(ChannelId::Channel1).await?;For a detailed register map, please refer to the device.yaml file in the
repository.
§Supported Devices
The INA3221 is found in various embedded devices for power monitoring, including NVIDIA Jetson boards and other development platforms.
Modules§
- field_
sets - Module containing the generated fieldsets of the registers and commands
Structs§
- Alert
Flags - Alert flags from the Mask/Enable register
- Ina3221
- Ina3221
Async - Ina3221
Interface - Ina3221
LowLevel - Root block of the Ina3221LowLevel driver
Enums§
- Averaging
Mode - Averaging mode - number of samples to average for each measurement
- Channel
Id - Channel identifier for the INA3221’s three monitoring channels
- Conversion
Time - Conversion time for ADC measurements
- Ina3221
Error - Operating
Mode - Operating mode for the INA3221
Constants§
- BUS_
VOLTAGE_ LSB_ MV - Bus voltage LSB: 8mV
- INA3221_
I2C_ ADDR_ GND - INA3221 default I2C address (A0 pin = GND) Other addresses: 0x41 (A0=VS+), 0x42 (A0=SDA), 0x43 (A0=SCL)
- INA3221_
I2C_ ADDR_ SCL - INA3221_
I2C_ ADDR_ SDA - INA3221_
I2C_ ADDR_ VS - SHUNT_
VOLTAGE_ LSB_ UV - Shunt voltage LSB: 40µV