Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: SDFileSystem app epson mbed msp430 pl tests
MCP23S17 Class Reference
Microchip MCP23S17 encapsulation. More...
#include <mcp23s17.h>
Public Member Functions | |
MCP23S17 (int address, SPI &spi, DigitalOut &cs) | |
Constructor. | |
int | Read (REG_MCP23S17 reg) |
Read a register. | |
void | Write (REG_MCP23S17 reg, int value) |
Write a register. |
Detailed Description
Microchip MCP23S17 encapsulation.
This chip is an SPI connected I/O expander.
Example usage:
SPI spi(p5, p6, p7); DigitalOut cs(p19); MCP23S17 mcp23s17(0x00, spi, cs); ... mcp23s17.Write(GPIOB, 0xaa);
The MCP23S17 uses pins 5, 6, 7 (SPI MOSI, MISO, SCK) and 19 (CS) and the write command sets GPIOB to 0xaa. The chip address is 0x00.
Note that this code example does not cover the setup of the chip configuration registers.
Definition at line 62 of file mcp23s17.h.
Constructor & Destructor Documentation
MCP23S17 | ( | int | address, |
SPI & | spi, | ||
DigitalOut & | cs | ||
) |
Constructor.
- Parameters:
-
address The SPI address offset of the chip. SPI the SPI to use for communication. cs The chip select pin.
Definition at line 11 of file mcp23s17.cpp.
Member Function Documentation
int Read | ( | REG_MCP23S17 | reg ) |
Read a register.
- Parameters:
-
address The SPI address of the MCP23S17. reg The register to read.
- Returns:
- The register value.
Definition at line 17 of file mcp23s17.cpp.
void Write | ( | REG_MCP23S17 | reg, |
int | value | ||
) |
Write a register.
- Parameters:
-
address The SPI address of the MCP23S17. reg The register to write. value The value to write to the register.
Definition at line 28 of file mcp23s17.cpp.
Generated on Tue Jul 12 2022 21:14:35 by
