Crates.io | afe4404 |
lib.rs | afe4404 |
version | 0.2.4 |
source | src |
created_at | 2022-12-06 11:08:24.008287 |
updated_at | 2023-04-15 13:25:27.468523 |
description | AFE4404 driver for Rust embedded-hal. |
homepage | |
repository | https://github.com/pulse-loop/AFE4404 |
max_upload_size | |
id | 731069 |
size | 219,975 |
This is a AFE4404 driver for Rust embedded-hal. It allows a high level interaction with the AFE.
Initialise the AFE:
let mut frontend = AFE4404::with_three_leds(i2c, 0x58u8, Frequency::new::<megahertz>(4.0));
Set the LEDs current:
frontend
.set_leds_current(&LedCurrentConfiguration::<ThreeLedsMode>::new(
ElectricCurrent::new::<milliampere>(60.0),
ElectricCurrent::new::<milliampere>(10.0),
ElectricCurrent::new::<milliampere>(10.0),
))
.expect("Cannot set leds current");
Set the TIA resistors:
frontend
.set_tia_resistors(&ResistorConfiguration::<ThreeLedsMode>::new(
ElectricalResistance::new::<kiloohm>(250.0),
ElectricalResistance::new::<kiloohm>(100.0),
))
.expect("Cannot set tia resistors");
Set the clock source:
frontend
.set_clock_source(ClockConfiguration::Internal)
.expect("Cannot set clock source");
Read the sampled values:
let sample = frontend.read();