FlexBook / Mbed 2 deprecated FlexBook171204a

Dependencies:   SDFileSystem app epson mbed msp430 pl tests

Embed: (wiki syntax)

« Back to documentation index

MCP23S17 Class Reference

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:
addressThe SPI address offset of the chip.
SPIthe SPI to use for communication.
csThe chip select pin.

Definition at line 11 of file mcp23s17.cpp.


Member Function Documentation

int Read ( REG_MCP23S17  reg )

Read a register.

Parameters:
addressThe SPI address of the MCP23S17.
regThe 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:
addressThe SPI address of the MCP23S17.
regThe register to write.
valueThe value to write to the register.

Definition at line 28 of file mcp23s17.cpp.