# ESP IO Expander Chip TCA6424(C)
reference:esp_io_expander_pca9535
Implementation of the TCA6424(C) io expander chip with esp_io_expander component.
| Chip | Communication interface | Component name | Link to datasheet |
| :--------------: | :---------------------: | :------------: | :---------------: |
| TCA6424(C) | I2C | esp_io_expander_tca6424 | [datasheet](https://www.ti.com/lit/ds/symlink/tca6424.pdf?ts=1777541664478&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FTCA6424) |
## Add to project
git clone https://github.com/wzy-github123/esp_io_expander_tca6424.git
## Example use
Creation of the i2c bus.
```c
i2c_master_bus_handle_t i2c_handle = NULL;
const i2c_master_bus_config_t bus_config = {
.i2c_port = I2C_NUM_0,
.sda_io_num = 6,
.scl_io_num = 5,
.clk_source = I2C_CLK_SRC_DEFAULT,
};
i2c_new_master_bus(&bus_config, &i2c_handle);
```
Creation of the component.
```c
esp_io_expander_handle_t io_expander = NULL;
esp_io_expander_new_i2c_tca6424(i2c_handle, ESP_IO_EXPANDER_TCA6424A_I2C_ADDRESS_GND, &io_expander);
```
Print all pins's status to the log:
```c
esp_io_expander_print_state(io_expander);
```
Set pin 0 and pin 1 with output dircetion and low level:
```c
esp_io_expander_set_dir(io_expander, IO_EXPANDER_PIN_NUM_0 | IO_EXPANDER_PIN_NUM_1, IO_EXPANDER_OUTPUT);
esp_io_expander_set_level(io_expander, IO_EXPANDER_PIN_NUM_0 | IO_EXPANDER_PIN_NUM_1, 0);
```
Set pin 2 and pin 3 with input dircetion:
```c
uint32_t pin_levels = 0;
esp_io_expander_set_dir(io_expander, IO_EXPANDER_PIN_NUM_2 | IO_EXPANDER_PIN_NUM_3, IO_EXPANDER_INPUT);
esp_io_expander_get_level(io_expander, IO_EXPANDER_PIN_NUM_2 | IO_EXPANDER_PIN_NUM_3, &pin_levels);
```
idf.py add-dependency "wzy-github123/esp_io_expander_tca6424^1.0.0"