Adafruit MCP23017 Library
Public Member Functions | List of all members
Adafruit_MCP23X17 Class Reference

Class for MCP23017 I2C and MCP23S17 SPI variants. More...

#include <Adafruit_MCP23X17.h>

Inheritance diagram for Adafruit_MCP23X17:
Adafruit_MCP23XXX

Public Member Functions

 Adafruit_MCP23X17 ()
 default ctor.
 
uint8_t readGPIOA ()
 Bulk read all pins on Port A. More...
 
void writeGPIOA (uint8_t value)
 Bulk write all pins on Port A. More...
 
uint8_t readGPIOB ()
 Bulk read all pins on Port B. More...
 
void writeGPIOB (uint8_t value)
 Bulk write all pins on Port B. More...
 
uint16_t readGPIOAB ()
 Bulk read all pins on Port A and B. More...
 
void writeGPIOAB (uint16_t value)
 Bulk write all pins on Port A and Port B. More...
 
void enableAddrPins ()
 Enable usage of HW address pins (A0, A1, A2) on MCP23S17. More...
 
- Public Member Functions inherited from Adafruit_MCP23XXX
bool begin_I2C (uint8_t i2c_addr=MCP23XXX_ADDR, TwoWire *wire=&Wire)
 Initialize MCP using I2C. More...
 
bool begin_SPI (uint8_t cs_pin, SPIClass *theSPI=&SPI, uint8_t _hw_addr=0x00)
 Initialize MCP using hardware SPI. More...
 
bool begin_SPI (int8_t cs_pin, int8_t sck_pin, int8_t miso_pin, int8_t mosi_pin, uint8_t _hw_addr=0x00)
 Initialize MCP using software SPI. More...
 
void pinMode (uint8_t pin, uint8_t mode)
 Configures the specified pin to behave either as an input or an output. More...
 
uint8_t digitalRead (uint8_t pin)
 Reads the value from a specified digital pin, either HIGH or LOW. More...
 
void digitalWrite (uint8_t pin, uint8_t value)
 Write a HIGH or a LOW value to a digital pin. More...
 
uint8_t readGPIO (uint8_t port=0)
 Bulk read all pins on a port. More...
 
void writeGPIO (uint8_t value, uint8_t port=0)
 Bulk write all pins on a port. More...
 
void setupInterrupts (bool mirroring, bool openDrain, uint8_t polarity)
 Configure the interrupt system. More...
 
void setupInterruptPin (uint8_t pin, uint8_t mode=CHANGE)
 Enable interrupt and set mode for given pin. More...
 
void disableInterruptPin (uint8_t pin)
 Disable interrupt for given pin. More...
 
void clearInterrupts ()
 Clear interrupts. NOTE:If using DEFVAL, INT clears only if interrupt condition does not exist. See Fig 1-7 in datasheet.
 
uint8_t getLastInterruptPin ()
 Gets the pin that caused the latest interrupt, from INTF, without clearing any interrupt flags. More...
 
uint16_t getCapturedInterrupt ()
 Get pin states captured at time of interrupt. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Adafruit_MCP23XXX
uint16_t getRegister (uint8_t baseAddress, uint8_t port=0)
 helper to get register address More...
 
- Protected Attributes inherited from Adafruit_MCP23XXX
Adafruit_I2CDevice * i2c_dev = nullptr
 Pointer to I2C bus interface.
 
Adafruit_SPIDevice * spi_dev = nullptr
 Pointer to SPI bus interface.
 
uint8_t pinCount
 Total number of GPIO pins.
 
uint8_t hw_addr
 HW address matching A2/A1/A0 pins.
 

Detailed Description

Class for MCP23017 I2C and MCP23S17 SPI variants.

Member Function Documentation

◆ readGPIOA()

uint8_t Adafruit_MCP23X17::readGPIOA ( )

Bulk read all pins on Port A.

Returns
current pin states of port as a uint8_t.

◆ writeGPIOA()

void Adafruit_MCP23X17::writeGPIOA ( uint8_t  value)

Bulk write all pins on Port A.

Parameters
valuepin states to write as uint8_t.

◆ readGPIOB()

uint8_t Adafruit_MCP23X17::readGPIOB ( )

Bulk read all pins on Port B.

Returns
current pin states of port as a uint8_t.

◆ writeGPIOB()

void Adafruit_MCP23X17::writeGPIOB ( uint8_t  value)

Bulk write all pins on Port B.

Parameters
valuepin states to write as uint8_t.

◆ readGPIOAB()

uint16_t Adafruit_MCP23X17::readGPIOAB ( )

Bulk read all pins on Port A and B.

Returns
current pin states of ports as a uint16_t.

◆ writeGPIOAB()

void Adafruit_MCP23X17::writeGPIOAB ( uint16_t  value)

Bulk write all pins on Port A and Port B.

Parameters
valuepin states to write as uint16_t.

◆ enableAddrPins()

void Adafruit_MCP23X17::enableAddrPins ( )

Enable usage of HW address pins (A0, A1, A2) on MCP23S17.

Send this message as first message after chip init, as it will set bits in IOCON register to default (except HAEN) By default pins are not used and disabled (see README for details) This message is sent to all devices on bus (no hw_addr is added to msg as it's not enabled yet) Due to HW bug in the chip message must be sent twice (to addr 0b000 and 0b1xx)


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