mcp23s17

Crates.iomcp23s17
lib.rsmcp23s17
version0.1.0
sourcesrc
created_at2023-11-06 09:54:07.433777
updated_at2023-11-06 09:54:07.433777
descriptionMCP23S17 driver A driver for the MCP23S17 16 bit I/O expander chip addressed over the SPI bus.
homepage
repository
max_upload_size
id1026665
size28,941
(Fundevoge)

documentation

README

MCP23S17 driver

Crates.io Crates.io Crates.io

A driver for the MCP23S17 I/O expander which is accessed over an SPI bus.

Example usage

// spi implements the SPI traits from embedded_hal 
// cs_pin implements the OutputPin embedded_hal
// The hardware address corresponds to the way the pins A0, A1, A2 are physically connected
let mut mcp23s17 = mcp23s17::Mcp23s17::new(spi, cs_pin, 0b000).ok().unwrap();

// Configure pin GPA0 as an output
mcp23s17.pin_mode(0, mcp23s17::PinMode::Output).ok().unwrap();
// Set pin GPA0 high
mcp23s17.set_high(0);

// Configure pin GPA1 as an pullup input
mcp23s17.pin_mode(1, mcp23s17::PinMode::InputPullup).ok().unwrap();
// Read GPA1's level
let is_high = mcp23s17.read(1);

Acknowledgements

Many of the documentation comments in this library are taken direct from the MCP23S17 datasheet and are © 2005-2022 Microchip Technology Inc. and its subsidiaries.

Inspired by this Arduino MCP23S17 Library and the RPPAL MCP23S17 Library

Commit count: 0

cargo fmt