#include <IoAbstractionWire.h>
Public Member Functions | |
MCP23017IoAbstraction (uint8_t address, Mcp23xInterruptMode intMode, pinid_t intPinA, pinid_t intPinB, WireType wireImpl=nullptr) | |
MCP23017IoAbstraction (uint8_t address, WireType wireImpl=nullptr) | |
MCP23017IoAbstraction (uint8_t address, Mcp23xInterruptMode intMode, pinid_t intPinA, WireType wireImpl=nullptr) | |
void | pinDirection (pinid_t pin, uint8_t mode) override |
void | attachInterrupt (pinid_t pin, RawIntHandler intHandler, uint8_t mode) override |
bool | runLoop () override |
void | setInvertInputPin (pinid_t pin, bool shouldInvert) |
void | resetDevice (int resetPin) |
Public Member Functions inherited from Standard16BitDevice | |
void | writeValue (pinid_t pin, uint8_t value) override |
uint8_t | readValue (pinid_t pin) override |
void | writePort (pinid_t pin, uint8_t port) override |
uint8_t | readPort (pinid_t pin) override |
void | clearChangeFlags () |
void | setReadPort (int port) |
bool | isReadPortSet (int port) const |
bool | isWritePortSet (int port) const |
bool | isInitNeeded () const |
void | markInitialised () |
Public Member Functions inherited from BasicIoAbstraction | |
uint8_t | digitalRead (pinid_t p) |
void | digitalWrite (pinid_t p, uint8_t v) |
uint8_t | digitalReadS (pinid_t p) |
void | digitalWriteS (pinid_t p, uint8_t v) |
void | writePortS (pinid_t p, uint8_t v) |
uint8_t | readPortS (pinid_t p) |
void | pinMode (pinid_t pin, uint8_t mode) |
bool | sync () |
Additional Inherited Members | |
Protected Attributes inherited from Standard16BitDevice | |
uint16_t | lastRead |
uint16_t | toWrite |
uint8_t | flags |
This abstaction supports most of the available features on the 23x17 range of IOExpanders. It supports most of the GPIO functions and nearly all of the interrupt modes, and is therefore very close to Arduino pins in terms of functionality.
MCP23017IoAbstraction::MCP23017IoAbstraction | ( | uint8_t | address, |
Mcp23xInterruptMode | intMode, | ||
pinid_t | intPinA, | ||
pinid_t | intPinB, | ||
WireType | wireImpl = nullptr |
||
) |
Most complete constructor, allows for either single or dual interrupt mode and all capabilities
|
explicit |
Simplest constructor: create a MCP23017 device with no interrupt mode enabled, only the I2C address needed.
address | the I2C address |
MCP23017IoAbstraction::MCP23017IoAbstraction | ( | uint8_t | address, |
Mcp23xInterruptMode | intMode, | ||
pinid_t | intPinA, | ||
WireType | wireImpl = nullptr |
||
) |
Create a MCP23017 device that will use a single interrupt mode and optionally provide the wire implementation
address | |
intPinA |
|
overridevirtual |
Sets the pin direction similar to pinMode, pin direction on this device supports INPUT_PULLUP, INPUT and OUTPUT.
pin | the pin to set direction for on this device |
mode | the mode such as INPUT, INPUT_PULLUP, OUTPUT |
Reimplemented from BasicIoAbstraction.
|
overridevirtual |
Attaches an interrupt to the device and links it to the arduino pin. On the MCP23017 nearly all interrupt modes are supported, including CHANGE, RISING, FALLING and are selective both per port and by pin.
Reimplemented from BasicIoAbstraction.
|
overridevirtual |
updates settings on the board after changes
Reimplemented from BasicIoAbstraction.
void MCP23017IoAbstraction::setInvertInputPin | ( | pinid_t | pin, |
bool | shouldInvert | ||
) |
This MCP23017 only function inverts the meaning of a given input pin. The pins for this are 0..15 and true will invert the meaning, whereas false will leave as is. regardless if you are using any other IO expanders, using this function requires that you have an actual MCP23017IoAbstraction reference. If you want to use this feature, instead of the variable being of type IoAbstractionRef, it should be of type MCP23017IoAbstraction*
pin | the input pin between 0..15 |
shouldInvert | true to invert the given pin, otherwise false. |
void MCP23017IoAbstraction::resetDevice | ( | int | resetPin | ) |
If you've connected the reset pin to a GPIO, then provide the pin to this function and it will reset the device then leave the pin in the right state for the device to function. It will yield to task manager for 100 microseconds. It also ensures that the pin is set as output first.
resetPin | the reset GPIO pin. |