Module imxrt_hal::i2c[][src]

Expand description

I2C support

Example

use imxrt_hal;
use imxrt_hal::i2c::ClockSpeed;
use embedded_hal::blocking::i2c::WriteRead;

let mut peripherals = imxrt_hal::Peripherals::take().unwrap();

let (_, _, i2c3_builder, _) = peripherals.i2c.clock(
    &mut peripherals.ccm.handle,
    imxrt_hal::ccm::i2c::ClockSelect::OSC, // 24MHz clock...
    imxrt_hal::ccm::i2c::PrescalarSelect::DIVIDE_3, // Divide by 3
);

let mut i2c3 = i2c3_builder.build(
    peripherals.iomuxc.ad_b1.p07,
    peripherals.iomuxc.ad_b1.p06,
);

i2c3.set_bus_idle_timeout(core::time::Duration::from_micros(200)).unwrap();
i2c3.set_pin_low_timeout(core::time::Duration::from_millis(1)).unwrap();
i2c3.set_clock_speed(ClockSpeed::KHz400).unwrap();

let mut input = [0; 3];
let output = [0x74];

i2c3.write_read(MY_SLAVE_ADDRESS, &output, &mut input).unwrap();

Structs

An I2C builder that can build and I2C peripheral

Indicates an error when computing the parameters that control the bus idle timeout

Indicates an error when computing the parameters that control the clock speed.

An I2C master

Indicates an error when computing the parameters that control the pin low timeout

Unclocked I2C modules

Enums

I2C Clock speed