[−][src]Module imxrt_hal::i2c
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
Builder | An I2C builder that can build and I2C peripheral |
BusIdleTimeoutError | Indicates an error when computing the parameters that control the bus idle timeout |
ClockSpeedError | Indicates an error when computing the parameters that control the clock speed. |
I2C | An I2C master |
PinLowTimeoutError | Indicates an error when computing the parameters that control the pin low timeout |
Unclocked | Unclocked I2C modules |
Enums
ClockSpeed | I2C Clock speed |
Error |