IoAbstraction
Public Types | Public Member Functions | List of all members
AW9523IoAbstraction Class Reference

#include <IoAbstractionWire.h>

Inheritance diagram for AW9523IoAbstraction:
Standard16BitDevice BasicIoAbstraction

Public Types

enum  AW9523CurrentControl : uint8_t { FULL_CURRENT = 0 , CURRENT_THREE_QUARTER = 1 , CURRENT_HALF = 2 , CURRENT_QUARTER = 3 }
 

Public Member Functions

 AW9523IoAbstraction (uint8_t addr, pinid_t intPin=IO_PIN_NOT_DEFINED, WireType wirePtr=nullptr)
 
uint8_t deviceId ()
 
void pinDirection (pinid_t pin, uint8_t mode) override
 
void attachInterrupt (pinid_t pin, RawIntHandler intHandler, uint8_t mode) override
 
bool runLoop () override
 
void setPinLedCurrent (pinid_t pin, uint8_t pwr)
 
void writeGlobalControl (bool pushPullP0, AW9523CurrentControl maxCurrentMode=FULL_CURRENT)
 
void softwareReset ()
 
- 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

The AW9523IoAbstraction class provides an Arduino like wrapper for the AW9523 I2C device providing access to most functions available on the device in an Arduino like way, implementing IoAbstraction so that it can be used with LCD units, switches, rotary encoders and matrix keyboards in the regular way. The LED current control facilities are also exposed using an extension.

Constructor & Destructor Documentation

◆ AW9523IoAbstraction()

AW9523IoAbstraction::AW9523IoAbstraction ( uint8_t  addr,
pinid_t  intPin = IO_PIN_NOT_DEFINED,
WireType  wirePtr = nullptr 
)
explicit

create an instance of the AW9523 abstraction that communicates with the device and extends Arduino like functions for the pins on the device. This constructor takes the I2C address, and optionally an interrupt pin and wire implementation. Any interrupt pin provided will be set up on your behalf automatically.

Parameters
addrthe address on the I2C bus of the device
intPinoptionally a pin on the board that the devices interrupt pin is connected to
wirePtroptionally an alternative wire implementation, EG Wire1, or other non standard I2C device.

Member Function Documentation

◆ deviceId()

uint8_t AW9523IoAbstraction::deviceId ( )

Gets the device ID from the chip from the ID register.

Returns
the device ID

◆ pinDirection()

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

Sets the pin direction similar to pinMode, pin direction on this device supports INPUT, OUTPUT and LED_CURRENT_OUTPUT which enables the onboard LED controller, and then you use the setPinLedCurrent to control instead of digital write.

Parameters
pinthe pin to set direction for on this device
modefor this device, INPUT, OUTPUT or LED_CURRENT_OUTPUT

Reimplemented from BasicIoAbstraction.

◆ attachInterrupt()

void AW9523IoAbstraction::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 AW9523IoAbstraction::runLoop ( )
overridevirtual

updates settings on the board after changes

Reimplemented from BasicIoAbstraction.

◆ setPinLedCurrent()

void AW9523IoAbstraction::setPinLedCurrent ( pinid_t  pin,
uint8_t  pwr 
)

Enable or disable the LED controller mode of the pin, the power parameter is a value between 0 and 255 that represents the dimming level for that pin.

Parameters
pinthe pin to control
pwrthe current to provide, based on the global control setting, default 0..37mA.

◆ writeGlobalControl()

void AW9523IoAbstraction::writeGlobalControl ( bool  pushPullP0,
AW9523CurrentControl  maxCurrentMode = FULL_CURRENT 
)

You can change the global control register using this function, setting P0 either as push pull or open drain, you can also change the max-current range setting for the chip. This is as per datasheet. Make sure you've called sync at least once before calling.

Parameters
pushPullP0true - enable push pull, false - open drain
maxCurrentMode- see the AW9523CurrentControl enumeration for appropriate values

◆ softwareReset()

void AW9523IoAbstraction::softwareReset ( )

Perform a software reset of the device. Make sure you've called sync at least once before calling.


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