IoAbstraction
Public Member Functions | List of all members
MCP23017IoAbstraction Class Reference

#include <IoAbstractionWire.h>

Inheritance diagram for MCP23017IoAbstraction:
Standard16BitDevice BasicIoAbstraction

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ MCP23017IoAbstraction() [1/3]

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

See also
iofrom23017
iofrom23017IntPerPort

◆ MCP23017IoAbstraction() [2/3]

MCP23017IoAbstraction::MCP23017IoAbstraction ( uint8_t  address,
WireType  wireImpl = nullptr 
)
explicit

Simplest constructor: create a MCP23017 device with no interrupt mode enabled, only the I2C address needed.

Parameters
addressthe I2C address

◆ MCP23017IoAbstraction() [3/3]

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

Parameters
address
intPinA

Member Function Documentation

◆ pinDirection()

void MCP23017IoAbstraction::pinDirection ( pinid_t  pin,
uint8_t  mode 
)
overridevirtual

Sets the pin direction similar to pinMode, pin direction on this device supports INPUT_PULLUP, INPUT and OUTPUT.

Parameters
pinthe pin to set direction for on this device
modethe mode such as INPUT, INPUT_PULLUP, OUTPUT

Reimplemented from BasicIoAbstraction.

◆ attachInterrupt()

void MCP23017IoAbstraction::attachInterrupt ( pinid_t  pin,
RawIntHandler  intHandler,
uint8_t  mode 
)
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.

◆ runLoop()

bool MCP23017IoAbstraction::runLoop ( )
overridevirtual

updates settings on the board after changes

Reimplemented from BasicIoAbstraction.

◆ setInvertInputPin()

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*

Parameters
pinthe input pin between 0..15
shouldInverttrue to invert the given pin, otherwise false.

◆ resetDevice()

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.

Parameters
resetPinthe reset GPIO pin.

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