Adafruit AW9523 Library
Public Member Functions | Protected Attributes | List of all members
Adafruit_AW9523 Class Reference

Class that stores state and functions for interacting with the AW9523 I2C GPIO expander. More...

#include <Adafruit_AW9523.h>

Public Member Functions

 Adafruit_AW9523 ()
 Instantiates a new AW9523 class.
 
bool begin (uint8_t address=AW9523_DEFAULT_ADDR, TwoWire *wire=&Wire)
 Sets up the hardware and initializes I2C. More...
 
bool reset (void)
 Perform a soft reset over I2C. More...
 
bool openDrainPort0 (bool od)
 Turns on/off open drain output for ALL port 0 pins (GPIO 0-7) More...
 
bool outputGPIO (uint16_t pins)
 Sets output value (1 == high) for all 16 GPIO. More...
 
uint16_t inputGPIO (void)
 Reads input value (1 == high) for all 16 GPIO. More...
 
bool configureDirection (uint16_t pins)
 Sets direction for all 16 GPIO, 1 == output, 0 == input. More...
 
bool configureLEDMode (uint16_t pins)
 Sets constant-current mode for all 16 GPIO. More...
 
bool interruptEnableGPIO (uint16_t pins)
 Sets interrupt watch for all 16 GPIO, 1 == enabled. More...
 
void pinMode (uint8_t pin, uint8_t mode)
 Sets pin mode / direction for one pin. More...
 
void digitalWrite (uint8_t pin, bool val)
 Sets digital output for one pin. More...
 
bool digitalRead (uint8_t pin)
 Reads digital input for one pin. More...
 
void analogWrite (uint8_t pin, uint8_t val)
 Sets constant-current setting for one pin. More...
 
void enableInterrupt (uint8_t pin, bool en)
 Sets interrupt enable for one pin. More...
 

Protected Attributes

Adafruit_I2CDevice * i2c_dev = NULL
 Pointer to I2C bus interface.
 

Detailed Description

Class that stores state and functions for interacting with the AW9523 I2C GPIO expander.

Member Function Documentation

◆ begin()

bool Adafruit_AW9523::begin ( uint8_t  addr = AW9523_DEFAULT_ADDR,
TwoWire *  wire = &Wire 
)

Sets up the hardware and initializes I2C.

Parameters
addrThe I2C address for the expander
wireThe Wire object to be used for I2C connections.
Returns
True if initialization was successful, otherwise false.

◆ reset()

bool Adafruit_AW9523::reset ( void  )

Perform a soft reset over I2C.

Returns
True I2C reset command was acknowledged

◆ openDrainPort0()

bool Adafruit_AW9523::openDrainPort0 ( bool  od)

Turns on/off open drain output for ALL port 0 pins (GPIO 0-7)

Parameters
odTrue to enable open drain, False for push-pull
Returns
True if I2C write command was acknowledged, otherwise false

◆ outputGPIO()

bool Adafruit_AW9523::outputGPIO ( uint16_t  pins)

Sets output value (1 == high) for all 16 GPIO.

Parameters
pins16-bits of binary output settings
Returns
True I2C write command was acknowledged

◆ inputGPIO()

uint16_t Adafruit_AW9523::inputGPIO ( void  )

Reads input value (1 == high) for all 16 GPIO.

Returns
16-bits of binary input (0 == low & 1 == high)

◆ configureDirection()

bool Adafruit_AW9523::configureDirection ( uint16_t  pins)

Sets direction for all 16 GPIO, 1 == output, 0 == input.

Parameters
pins16-bits of pins we want to set direction
Returns
True I2C write command was acknowledged

◆ configureLEDMode()

bool Adafruit_AW9523::configureLEDMode ( uint16_t  pins)

Sets constant-current mode for all 16 GPIO.

Parameters
pins16-bits of pins we want to set CC mode (1 == enabled)
Returns
True I2C write command was acknowledged

◆ interruptEnableGPIO()

bool Adafruit_AW9523::interruptEnableGPIO ( uint16_t  pins)

Sets interrupt watch for all 16 GPIO, 1 == enabled.

Parameters
pins16-bits of pins we may want INT enabled
Returns
True I2C write command was acknowledged

◆ pinMode()

void Adafruit_AW9523::pinMode ( uint8_t  pin,
uint8_t  mode 
)

Sets pin mode / direction for one pin.

Parameters
pinGPIO to set, from 0 to 15 inclusive
modeCan be INPUT, OUTPUT for GPIO digital, or AW9523_LED_MODE for constant current LED drive

◆ digitalWrite()

void Adafruit_AW9523::digitalWrite ( uint8_t  pin,
bool  val 
)

Sets digital output for one pin.

Parameters
pinGPIO to set, from 0 to 15 inclusive
valTrue for high value, False for low value

◆ digitalRead()

bool Adafruit_AW9523::digitalRead ( uint8_t  pin)

Reads digital input for one pin.

Parameters
pinGPIO to set, from 0 to 15 inclusive
Returns
True for high value read, False for low value read

◆ analogWrite()

void Adafruit_AW9523::analogWrite ( uint8_t  pin,
uint8_t  val 
)

Sets constant-current setting for one pin.

Parameters
pinGPIO to set, from 0 to 15 inclusive
valRatio to set, from 0 (off) to 255 (max current)

◆ enableInterrupt()

void Adafruit_AW9523::enableInterrupt ( uint8_t  pin,
bool  en 
)

Sets interrupt enable for one pin.

Parameters
pinGPIO to set, from 0 to 15 inclusive
enTrue to enable Interrupt detect, False for ignore

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