An embedded-hal focused driver for the SX1509 I/O expander.
Find a file
2024-08-02 13:54:17 +12:00
src Fix output/input bug, inc version 2024-08-02 13:54:17 +12:00
.gitignore Upload initial version 2024-07-15 16:53:10 +12:00
Cargo.lock Upload initial version 2024-07-15 16:53:10 +12:00
Cargo.toml Fix output/input bug, inc version 2024-08-02 13:54:17 +12:00
LICENSE-APACHE Create LICENSE-APACHE 2024-07-15 16:43:02 +12:00
LICENSE-MIT Create LICENSE-MIT 2024-07-15 16:44:24 +12:00
README.md Upload initial version 2024-07-15 16:53:10 +12:00

An embedded-hal focused driver for the SX1509 I/O expander.

This crate allows you to use the expansion pins on the SX1509 as if they were simply GPIO pins on your microcontroller.

Portable Atomic

This crate uses portable-atomic to provide platform-agnostic atomic operations. This is necessary to implement the internal shared i2c bus. You may need to enable certain features of portable-atomic to get this crate to compile on platforms that don't natively support atomic operations.

Usage

// 0x3F is used here, the actual address will vary
// depending on the configuration of the ADDR
// pins on the chip.
let mut expander = Sx1509::new(i2c, 0x3F).unwrap();

// This borrows the expander, so the expander
// cannot be dropped before it's pins.
let sx1509::Pins {
    a0,
    a1,
    ..
} = expander.split();

let pin_0 = a0.into_output().unwrap();
let pin_1 = a1.into_input().unwrap();

pin_0.set_high().unwrap();
assert_eq!(pin_1.is_high().unwrap(), true);