Crates.io | pcf857x |
lib.rs | pcf857x |
version | 0.4.0 |
source | src |
created_at | 2018-08-22 16:28:03.472063 |
updated_at | 2021-05-22 10:49:01.107997 |
description | Platform-agnostic Rust driver for the PCF8574, PCF8574A and PCF8575 I/O expanders. |
homepage | https://github.com/eldruin/pcf857x-rs |
repository | https://github.com/eldruin/pcf857x-rs |
max_upload_size | |
id | 80768 |
size | 67,250 |
This is a platform agnostic Rust driver for the PCF8574, PCF8574A and PCF8575 I2C I/O expanders,
based on the embedded-hal
traits.
This driver allows you to:
0
or 1
at once. See set()
.get()
.write_array()
.read_array()
.split()
.The devices consist of 8 or 16 quasi-bidirectional ports, I²C-bus interface, three hardware address inputs and interrupt output. The quasi-bidirectional port can be independently assigned as an input to monitor interrupt status or keypads, or as an output to activate indicator devices such as LEDs.
The active LOW open-drain interrupt output (INT) can be connected to the interrupt logic of the microcontroller and is activated when any input state differs from its corresponding input port register state.
Datasheets:
Please find additional examples using hardware in this repository: driver-examples
use linux_embedded_hal::I2cdev;
use pcf857x::{Pcf8574, PinFlag, SlaveAddr};
fn main() {
let dev = I2cdev::new("/dev/i2c-1").unwrap();
let address = SlaveAddr::default();
let mut expander = Pcf8574::new(dev, address);
let output_pin_status = 0b1010_1010;
expander.set(output_pin_status).unwrap();
let pins_to_be_read = PinFlag::P0 | PinFlag::P7;
let status = expander.get(pins_to_be_read).unwrap();
println!("Input pin status: {}", status);
}
For questions, issues, feature requests, and other changes, please file an issue in the github project.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.