A comprehensive Rust driver for the Microchip MCP23017 IO expander.
- Split a device into individual
embedded-halpins. - Configure modes, pull-ups, and interrupt triggers with a type-level API.
- Service interrupts efficiently with a centralized controller.
For usage details and explanatory notes, see the documentation.
Overview
let i2c = todo!;
// Setup a device:
const ADDRESS: u8 = 0x20;
let mut device = new;
let = device.split?;
// Use a pin as an output:
let mut pin = pins.a0.into_push_pull_output?;
pin.set_high?;
pin.is_set_high?;
// Use another pin as an input:
let mut pin = pins.a1.into_pull_up_input?;
pin.is_high?;
// Configure an input pin for interrupts:
let pin = pin.enable_interrupt?;
// When an interrupt occurs,
// immediately notify the controller...
interrupt_controller.interrupt?;
// ...and later query it about the cause:
interrupt_controller.triggered;