[][src]Module lpc82x_hal::i2c

API for the I2C peripherals

Please be aware that this is a very basic implementation, with lots of important things missing. Please be careful when using this API.

The I2C peripherals are described in the user manual, chapter 15.

Examples

Write data to an I2C slave:

use lpc82x_hal::prelude::*;
use lpc82x_hal::Peripherals;

let mut p = Peripherals::take().unwrap();

let mut swm    = p.SWM.split();
let mut syscon = p.SYSCON.split();

let (i2c0_sda, _) = swm.fixed_functions.i2c0_sda.assign(
    swm.pins.pio0_11.into_swm_pin(),
    &mut swm.handle,
);
let (i2c0_scl, _) = swm.fixed_functions.i2c0_scl.assign(
    swm.pins.pio0_10.into_swm_pin(),
    &mut swm.handle,
);

let mut i2c = p.I2C0.enable(
    &mut syscon.handle,
    i2c0_sda,
    i2c0_scl,
);

i2c.write(address, &data)
    .expect("Failed to write data");

Please refer to the examples in the repository for more example code.

Structs

I2C

Interface to an I2C peripheral