Base class for all MCP23XXX variants.
More...
#include <Adafruit_MCP23XXX.h>
|
| 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...
|
| |
|
| uint16_t | getRegister (uint8_t baseAddress, uint8_t port=0) |
| | helper to get register address More...
|
| |
|
|
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.
|
| |
Base class for all MCP23XXX variants.
◆ begin_I2C()
| bool Adafruit_MCP23XXX::begin_I2C |
( |
uint8_t |
i2c_addr = MCP23XXX_ADDR, |
|
|
TwoWire * |
wire = &Wire |
|
) |
| |
Initialize MCP using I2C.
- Parameters
-
| i2c_addr | I2C address |
| wire | Pointer to Wire instance |
- Returns
- true if initialization successful, otherwise false.
◆ begin_SPI() [1/2]
| bool Adafruit_MCP23XXX::begin_SPI |
( |
uint8_t |
cs_pin, |
|
|
SPIClass * |
theSPI = &SPI, |
|
|
uint8_t |
_hw_addr = 0x00 |
|
) |
| |
Initialize MCP using hardware SPI.
- Parameters
-
| cs_pin | Pin to use for SPI chip select |
| theSPI | Pointer to SPI instance |
| _hw_addr | Hardware address (pins A2, A1, A0) |
- Returns
- true if initialization successful, otherwise false.
◆ begin_SPI() [2/2]
| bool Adafruit_MCP23XXX::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.
- Parameters
-
| cs_pin | Pin to use for SPI chip select |
| sck_pin | Pin to use for SPI clock |
| miso_pin | Pin to use for SPI MISO |
| mosi_pin | Pin to use for SPI MOSI |
| _hw_addr | Hardware address (pins A2, A1, A0) |
- Returns
- true if initialization successful, otherwise false.
◆ pinMode()
| void Adafruit_MCP23XXX::pinMode |
( |
uint8_t |
pin, |
|
|
uint8_t |
mode |
|
) |
| |
Configures the specified pin to behave either as an input or an output.
- Parameters
-
| pin | the Arduino pin number to set the mode of |
| mode | INPUT, OUTPUT, or INPUT_PULLUP |
◆ digitalRead()
| uint8_t Adafruit_MCP23XXX::digitalRead |
( |
uint8_t |
pin | ) |
|
Reads the value from a specified digital pin, either HIGH or LOW.
- Parameters
-
| pin | the Arduino pin number you want to read |
- Returns
- HIGH or LOW
◆ digitalWrite()
| void Adafruit_MCP23XXX::digitalWrite |
( |
uint8_t |
pin, |
|
|
uint8_t |
value |
|
) |
| |
Write a HIGH or a LOW value to a digital pin.
- Parameters
-
| pin | the Arduino pin number |
| value | HIGH or LOW |
◆ readGPIO()
| uint8_t Adafruit_MCP23XXX::readGPIO |
( |
uint8_t |
port = 0 | ) |
|
Bulk read all pins on a port.
- Parameters
-
| port | 0 for Port A, 1 for Port B (MCP23X17 only). |
- Returns
- current pin states of port as a uint8_t.
◆ writeGPIO()
| void Adafruit_MCP23XXX::writeGPIO |
( |
uint8_t |
value, |
|
|
uint8_t |
port = 0 |
|
) |
| |
Bulk write all pins on a port.
- Parameters
-
| value | pin states to write as a uint8_t. |
| port | 0 for Port A, 1 for Port B (MCP23X17 only). |
◆ setupInterrupts()
| void Adafruit_MCP23XXX::setupInterrupts |
( |
bool |
mirroring, |
|
|
bool |
openDrain, |
|
|
uint8_t |
polarity |
|
) |
| |
Configure the interrupt system.
- Parameters
-
| mirroring | true to OR both INTA and INTB pins. |
| openDrain | true for open drain output, false for active drive output. |
| polarity | HIGH or LOW |
◆ setupInterruptPin()
| void Adafruit_MCP23XXX::setupInterruptPin |
( |
uint8_t |
pin, |
|
|
uint8_t |
mode = CHANGE |
|
) |
| |
Enable interrupt and set mode for given pin.
- Parameters
-
| pin | Pin to enable. |
| mode | CHANGE, LOW, HIGH |
◆ disableInterruptPin()
| void Adafruit_MCP23XXX::disableInterruptPin |
( |
uint8_t |
pin | ) |
|
Disable interrupt for given pin.
- Parameters
-
◆ getLastInterruptPin()
| uint8_t Adafruit_MCP23XXX::getLastInterruptPin |
( |
| ) |
|
Gets the pin that caused the latest interrupt, from INTF, without clearing any interrupt flags.
- Returns
- Pin that caused lastest interrupt.
◆ getCapturedInterrupt()
| uint16_t Adafruit_MCP23XXX::getCapturedInterrupt |
( |
| ) |
|
Get pin states captured at time of interrupt.
- Returns
- Mutli-bit value representing pin states.
◆ getRegister()
| uint16_t Adafruit_MCP23XXX::getRegister |
( |
uint8_t |
baseAddress, |
|
|
uint8_t |
port = 0 |
|
) |
| |
|
protected |
helper to get register address
- Parameters
-
| baseAddress | base register address |
| port | 0 for A, 1 for B (MCP23X17 only) |
- Returns
- calculated register address
The documentation for this class was generated from the following files: