Crate ina3221_dd

Crate ina3221_dd 

Source
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.
  • defmt and log Integration: 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§

AlertFlags
Alert flags from the Mask/Enable register
Ina3221
Ina3221Async
Ina3221Interface
Ina3221LowLevel
Root block of the Ina3221LowLevel driver

Enums§

AveragingMode
Averaging mode - number of samples to average for each measurement
ChannelId
Channel identifier for the INA3221’s three monitoring channels
ConversionTime
Conversion time for ADC measurements
Ina3221Error
OperatingMode
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