FabGL
ESP32 Display Controller and Graphics Library
MCP23S17 Class Reference

MCP23S17 driver. More...

#include <MCP23S17.h>

Public Member Functions

bool available ()
 Determines MCP23S17 availability. More...
 
bool begin (int MISO=-1, int MOSI=-1, int CLK=-1, int CS=-1, int CSActiveState=-1, int host=HSPI_HOST)
 Initializes MCP23S17 driver. More...
 
void configureGPIO (int gpio, MCPDir dir, bool pullup=false, uint8_t hwAddr=0)
 Configure a pin direction and pullup. More...
 
void disableInterrupt (int gpio, uint8_t hwAddr=0)
 Disables any interrupt on the specified pin. More...
 
void enableInterrupt (int gpio, MCPIntTrigger trigger, bool defaultValue=false, uint8_t hwAddr=0)
 Enables interrupt on the specific pin. More...
 
void enableINTMirroring (bool value, uint8_t hwAddr=0)
 Enables/disables INTs pins mirroring. More...
 
void enableINTOpenDrain (bool value, uint8_t hwAddr=0)
 Enables/disables the INT pin open-drain. More...
 
void enablePortPullUp (int port, uint8_t value, uint8_t hwAddr=0)
 Enables/disables port pull-ups. More...
 
void end ()
 Deinitializes MCP23S17 driver. More...
 
bool getINTActiveHigh (uint8_t hwAddr=0)
 Gets the polarity of the INT pins. More...
 
uint8_t getPortDir (int port, uint8_t hwAddr=0)
 Gets port direction. More...
 
uint8_t getPortIntCaptured (int port, uint8_t hwAddr=0)
 Reads status of input port when last interrupt has been triggered. More...
 
uint8_t getPortIntFlags (int port, uint8_t hwAddr=0)
 Reads interrupt flags for the specified port. More...
 
uint8_t getPortPullUp (int port, uint8_t hwAddr=0)
 Gets port pull-ups. More...
 
bool initDevice (uint8_t hwAddr)
 Initializes additional MCP23S17 devices connected to the same SPI bus but with a different hardware address. More...
 
bool readGPIO (int gpio, uint8_t hwAddr=0)
 Reads input status of a pin. More...
 
uint8_t readPort (int port, uint8_t hwAddr=0)
 Gets status of input pins of specified port. More...
 
void readPort (int port, void *buffer, size_t length, uint8_t hwAddr=0)
 High speed reads en entire buffer from a specific port. More...
 
uint16_t readPort16 (uint8_t hwAddr=0)
 Gets status of input pins of combined port A and B. More...
 
uint8_t readReg (uint8_t addr, uint8_t hwAddr=0)
 Reads 8 bit value from an internal register. More...
 
uint16_t readReg16 (uint8_t addr, uint8_t hwAddr=0)
 Reads 16 bit value from two consecutive registers. More...
 
void setINTActiveHigh (bool value, uint8_t hwAddr=0)
 Sets the polarity of the INT pins. More...
 
void setPortDir (int port, uint8_t value, uint8_t hwAddr=0)
 Sets port direction. More...
 
void setPortInputPolarity (int port, uint8_t value, uint8_t hwAddr=0)
 Sets input polarity. More...
 
void writeGPIO (int gpio, bool value, uint8_t hwAddr=0)
 Sets output status of a pin. More...
 
void writePort (int port, uint8_t value, uint8_t hwAddr=0)
 Sets status of output pins of specified port. More...
 
void writePort (int port, void const *buffer, size_t length, uint8_t hwAddr=0)
 High speed writes an entire buffer to a specific port. More...
 
void writePort16 (uint16_t value, uint8_t hwAddr=0)
 Sets status of output pins of combined port A and B. More...
 
void writeReg (uint8_t addr, uint8_t value, uint8_t hwAddr=0)
 Writes 8 bit value to an internal register. More...
 
void writeReg16 (uint8_t addr, uint16_t value, uint8_t hwAddr=0)
 Writes 16 bit value to two consecutive registers. More...
 

Detailed Description

MCP23S17 driver.

This driver supports multiple devices attached at the same bus (with the same CS) using hardware selection.

Example:

MCP23S17 io;
io.begin(35, 12, 14, 13);                        // MISO = 35, MOSI = 12, CLK = 14, CS = 13
io.configureGPIO(MCP_B0, MCPDir::Output);        // B0 is an output
io.configureGPIO(MCP_A1, MCPDir::Input, true);   // A1 is an input with pullup
bool A1 = io.readGPIO(MCP_A1);                   // read A1
io.writeGPIO(MCP_B0, true);                      // sets B0 high
Examples
VGA/HardwareTest/HardwareTest.ino.

Definition at line 155 of file MCP23S17.h.


The documentation for this class was generated from the following files: