TB2026-YDS Firmware
Loading...
Searching...
No Matches
GPIO expander (PI4IOE5V9554A)

I2C access to the 8 expander channels: per-pin output, input read. More...

Collaboration diagram for GPIO expander (PI4IOE5V9554A):

Functions

esp_err_t gpio_expander_init (i2c_master_bus_handle_t bus)
 Attach the expander to the shared I2C bus and set pin directions.
esp_err_t gpio_expander_set (uint8_t channel, bool level)
 Drive one output channel (read-modify-write of the cached output port).
esp_err_t gpio_expander_get (uint8_t channel, bool *level)
 Read one input channel's logic level.
esp_err_t gpio_expander_read_all (uint8_t *inputs)
 Read all 8 input-port levels in one transaction.

Detailed Description

I2C access to the 8 expander channels: per-pin output, input read.

Function Documentation

◆ gpio_expander_get()

esp_err_t gpio_expander_get ( uint8_t channel,
bool * level )

Read one input channel's logic level.

Parameters
channelEXP_* channel index (0..7).
[out]levelReceives the pin level.
Returns
ESP_OK on success, or the I2C error.

◆ gpio_expander_init()

esp_err_t gpio_expander_init ( i2c_master_bus_handle_t bus)

Attach the expander to the shared I2C bus and set pin directions.

Drives all outputs low, then configures IO0/IO1 as outputs and IO2..IO7 as inputs.

Parameters
busMaster bus handle from i2c_bus_init().
Returns
ESP_OK on success, or the I2C error (e.g. if the expander does not ACK).

◆ gpio_expander_read_all()

esp_err_t gpio_expander_read_all ( uint8_t * inputs)

Read all 8 input-port levels in one transaction.

Parameters
[out]inputsReceives the raw input port byte (bit n = channel n).
Returns
ESP_OK on success, or the I2C error.

◆ gpio_expander_set()

esp_err_t gpio_expander_set ( uint8_t channel,
bool level )

Drive one output channel (read-modify-write of the cached output port).

Parameters
channelEXP_* channel index (0..7); must be configured as an output.
leveltrue = high, false = low.
Returns
ESP_OK on success, or the I2C error.