pub fn reporting(
address: u8,
shunt_milliohms: u32,
max_microamps: u32,
bus_microvolts: u32,
microamps: i32,
) -> WordPartExpand description
An INA226 that reads what it is asked to.
§Arguments
address- the address it answers to.shunt_milliohms- the shunt, as the driver is told withwith_shunt.max_microamps- the largest current, as the driver is told withwith_shunt.bus_microvolts- the bus voltage it reports.microamps- the current it reports; negative flows the other way through the shunt.
§Returns
The part. Its readings land on the steps its registers count in: 1.25 mV of bus, 2.5 µV of shunt, and the calibration’s current step.
§Examples
use pamoja_hal::script::DelayLog;
use pamoja_sensors::ina226::{sim, Ina226, BASE_ADDRESS};
// 24 V on the bus and 1 A through a 100 mΩ shunt, for a part calibrated to 3.2 A.
let part = sim::reporting(BASE_ADDRESS, 100, 3_200_000, 24_000_000, 1_000_000);
let mut monitor = Ina226::new(part, BASE_ADDRESS, DelayLog::new());
let reading = monitor.measure().expect("the part answers");
assert_eq!(reading.bus_microvolts(), 24_000_000);