Crate afe4404

source ·
Expand description

AFE4404 Rust driver

crates.io build docs.rs crates.io crates.io

This is a AFE4404 driver for Rust embedded-hal. It allows a high level interaction with the AFE.

Usage

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();

Modules

This module contains the ADC related functions.
This module contains the clock related functions.
This module contains the device initialization functions.
This module contains the LEDs current and offset current related functions.
This module contains the measurement window related functions.
This module contains the [AFE4404] lighting modes.
This module contains the system related functions.
This module contains the TIA related functions.
This module contains the value reading related functions.