tca95x5: Driver for TCA9535/TCA9555 remote 16-bit I/O expanders for I2C-bus
Defines
- TCA95X5_I2C_ADDR_BASE
Functions
- esp_err_t tca95x5_init_desc(i2c_dev_t *dev, uint8_t addr, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio)
Initialize device descriptor.
Default SCL frequency is 400kHz
- Parameters:
dev – Pointer to I2C device descriptor
addr – I2C address (
0b0100<A2><A1><A0>
)port – I2C port number
sda_gpio – SDA GPIO
scl_gpio – SCL GPIO
- Returns:
ESP_OK
on success
- esp_err_t tca95x5_free_desc(i2c_dev_t *dev)
Free device descriptor.
- Parameters:
dev – Pointer to I2C device descriptor
- Returns:
ESP_OK
on success
- esp_err_t tca95x5_port_get_mode(i2c_dev_t *dev, uint16_t *mode)
Get GPIO pins mode.
0 - output, 1 - input for each bit in
val
- Parameters:
dev – Pointer to device descriptor
mode – [out] Buffer to store mode, 0 bit for P0.0 .. 15 bit for P1.7
- Returns:
ESP_OK
on success
- esp_err_t tca95x5_port_set_mode(i2c_dev_t *dev, uint16_t mode)
Set GPIO pins mode.
0 - output, 1 - input for each bit in
val
- Parameters:
dev – Pointer to device descriptor
mode – Mode, 0 bit for P0.0 .. 15 bit for P1.7
- Returns:
ESP_OK
on success
- esp_err_t tca95x5_port_read(i2c_dev_t *dev, uint16_t *val)
Read GPIO port value.
- Parameters:
dev – Pointer to I2C device descriptor
val – 16-bit GPIO port value, 0 bit for P0.0 .. 15 bit for P1.7
- Returns:
ESP_OK
on success
- esp_err_t tca95x5_port_write(i2c_dev_t *dev, uint16_t val)
Write value to GPIO port.
- Parameters:
dev – Pointer to I2C device descriptor
val – GPIO port value, 0 bit for P0.0 .. 15 bit for P1.7
- Returns:
ESP_OK on success
- esp_err_t tca95x5_get_level(i2c_dev_t *dev, uint8_t pin, uint32_t *val)
Read GPIO pin level.
- Parameters:
dev – Pointer to device descriptor
pin – Pin number, 0 for P0.0 .. 15 for P1.7
val – [out]
true
if pin currently in high state- Returns:
ESP_OK
on success
- esp_err_t tca95x5_set_level(i2c_dev_t *dev, uint8_t pin, uint32_t val)
Set GPIO pin level.
Pin must be set up as output
- Parameters:
dev – Pointer to device descriptor
pin – Pin number, 0 for P0.0 .. 15 for P1.7
val – [out]
true
if pin currently in high state- Returns:
ESP_OK
on success