PCA9535
PCA9535 IO-Expander driver using embedded-hal.
Features
Two expander modes:
- Immediate
- Cached
Immediate mode issues an i2c bus transaction on each function call, behaving like a normal i2c device library does.
Cached mode takes advantage of the interrupt pin of the device, which indicates a change in the register value. The driver holds an internal representation of the device's registers; thus, it only issues a read if any data changed as indicated by the interrupt pin. This mode reduces read access on the bus significantly compared to immediate mode.
Two ways of interacting:
- Standard Interface
- HAL Pin Interface
The standard interface offers all the needed functions to interact with the device's GPIO pins.
The HAL Pin Interface offers a way to use the Expander GPIO as embedded-hal GPIO, which makes it possible to use them in any other libraries using embedded-hal. The pins are usable across threads using an ExpanderMutex.
Usage Example
This is a basic usage example; for more information, visit the docs.
Immediate expander using standard interface:
use ;
let i2c = new.unwrap;
let mut expander = new;
expander.pin_into_input.unwrap;
expander.pin_into_output.unwrap;
if expander.pin_is_high.unwrap
Cached expander using hal pin interface:
use Mutex;
use ;
use ;
let i2c = new.unwrap;
let interrupt_pin = new.unwrap.get.unwrap.into_input;
let expander = new.unwrap;
let io_expander: = new;
let mut input_pin = new.unwrap;
let mut output_pin = new.unwrap;
if input_pin.is_high.unwrap
Changelog
See CHANGELOG.md or release page for details.