adafruit_pca9554

CircuitPython library for Adafruit PCA9554 GPIO expanders

  • Author(s): Melissa LeBlanc-Williams

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_pca9554.DigitalInOut(pin_number: int, pcf: PCA9554)

Digital input/output of the PCA9554. The interface is exactly the same as the digitalio.DigitalInOut class, however:

  • PCA9554 does not support pull-down resistors

  • PCA9554 does not actually have a sourcing transistor, instead there’s an internal pullup

Exceptions will be thrown when attempting to set unsupported pull configurations.

Specify the pin number of the PCA9554 0..7, and instance.

property direction: Direction

Setting a pin to OUTPUT drives it low, setting it to an INPUT enables the light pullup.

property pull: digitalio.Pull.UP

Pull-up is always activated so always return the same thing

switch_to_input(pull: Pull | None = None, **kwargs) None

Switch the pin state to a digital input which is the same as setting the light pullup on. Note that true tri-state or pull-down resistors are NOT supported!

switch_to_output(value: bool = False, **kwargs) None

Switch the pin state to a digital output with the provided starting value (True/False for high or low, default is False/low).

property value: bool

The value of the pin, either True for high or False for low.

class adafruit_pca9554.PCA9554(i2c_bus: I2C, address: int = PCA9554_I2CADDR_DEFAULT)

Interface library for PCA9554 GPIO expanders :param ~busio.I2C i2c_bus: The I2C bus the PCA9554 is connected to. :param int address: The I2C device address. Default is 0x3F

get_pin(pin: int) DigitalInOut

Convenience function to create an instance of the DigitalInOut class pointing at the specified pin of this PCA9554 device. :param int pin: pin to use for digital IO, 0 to 7

get_pin_mode(pin: int) bool

Get a single GPIO pin’s mode

read_gpio(register) int

Read the full 8-bits of data from the GPIO register

read_pin(pin: int) bool

Read a single GPIO pin as high/pulled-up or driven low

set_pin_mode(pin: int, val: bool) None

Set a single GPIO pin as input (pulled-up) or output

write_gpio(register: int, val: int) None

Write a full 8-bit value to the GPIO register

write_pin(pin: int, val: bool) None

Set a single GPIO pin high/pulled-up or driven low