Skip to content

Commit

Permalink
feat: add PCA9536 support
Browse files Browse the repository at this point in the history
  • Loading branch information
QB4-dev committed Feb 1, 2024
1 parent 031278c commit c9ad31b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion components/pca9557/.eil.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: pca9557
description: Driver for PCA9537/PCA9557/TCA9534 remote 4/8-bit I/O expanders for I2C-bus
description: Driver for PCA9536/PCA9537/PCA9557/TCA9534 remote 4/8-bit I/O expanders for I2C-bus
version: 1.0.0
groups:
- gpio
Expand Down
4 changes: 2 additions & 2 deletions components/pca9557/pca9557.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/**
* @file pca9557.c
*
* ESP-IDF driver for PCA9537/PCA9557/TCA9534 remote 4/8-bit I/O expanders for I2C-bus
* ESP-IDF driver for PCA9536/PCA9537/PCA9557/TCA9534 remote 4/8-bit I/O expanders for I2C-bus
*
* Copyright (c) 2021 Ruslan V. Uss <[email protected]>
*
Expand Down Expand Up @@ -103,7 +103,7 @@ esp_err_t pca9557_init_desc(i2c_dev_t *dev, uint8_t addr, i2c_port_t port, gpio_
CHECK_ARG(dev && (
(addr & PCA9557_I2C_ADDR_BASE) == PCA9557_I2C_ADDR_BASE ||
(addr & TCA9534_I2C_ADDR_BASE) == TCA9534_I2C_ADDR_BASE ||
addr == PCA9537_I2C_ADDR));
addr == PCA9537_I2C_ADDR || addr == PCA9536_I2C_ADDR));

dev->port = port;
dev->addr = addr;
Expand Down
15 changes: 8 additions & 7 deletions components/pca9557/pca9557.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @defgroup pca9557 pca9557
* @{
*
* ESP-IDF driver for PCA9537/PCA9557/TCA9534 remote 4/8-bit I/O expanders for I2C-bus
* ESP-IDF driver for PCA9536/PCA9537/PCA9557/TCA9534 remote 4/8-bit I/O expanders for I2C-bus
*
* Copyright (c) 2021 Ruslan V. Uss <[email protected]>
*
Expand All @@ -47,6 +47,7 @@
extern "C" {
#endif

#define PCA9536_I2C_ADDR 0x41 ///< I2C address for PCA9536
#define PCA9537_I2C_ADDR 0x49 ///< I2C address for PCA9537
#define PCA9557_I2C_ADDR_BASE 0x18 ///< Base I2C address for PCA9557
#define TCA9534_I2C_ADDR_BASE 0x20 ///< Base I2C address for TCA9534
Expand Down Expand Up @@ -129,7 +130,7 @@ esp_err_t pca9557_port_set_polarity(i2c_dev_t *dev, uint8_t pol);
* @brief Read I/O port value
*
* @param dev Pointer to I2C device descriptor
* @param[out] val 8-bit GPIO port value for PCA9557 or 4-bit port value for PCA9537
* @param[out] val 8-bit GPIO port value for PCA9557 or 4-bit port value for PCA9536/PCA9537
* @return `ESP_OK` on success
*/
esp_err_t pca9557_port_read(i2c_dev_t *dev, uint8_t *val);
Expand All @@ -138,7 +139,7 @@ esp_err_t pca9557_port_read(i2c_dev_t *dev, uint8_t *val);
* @brief Write value to I/O port
*
* @param dev Pointer to I2C device descriptor
* @param val 8-bit GPIO port value for PCA9557 or 4-bit port value for PCA9537
* @param val 8-bit GPIO port value for PCA9557 or 4-bit port value for PCA9536/PCA9537
* @return ESP_OK on success
*/
esp_err_t pca9557_port_write(i2c_dev_t *dev, uint8_t val);
Expand All @@ -147,7 +148,7 @@ esp_err_t pca9557_port_write(i2c_dev_t *dev, uint8_t val);
* @brief Read I/O pin mode
*
* @param dev Pointer to device descriptor
* @param pin Pin number, 0..7 for PCA9557, 0..3 for PC9537
* @param pin Pin number, 0..7 for PCA9557, 0..3 for PCA9536/PC9537
* @param[out] mode Pin mode
* @return `ESP_OK` on success
*/
Expand All @@ -157,7 +158,7 @@ esp_err_t pca9557_get_mode(i2c_dev_t *dev, uint8_t pin, pca9557_mode_t *mode);
* @brief Set I/O pin mode
*
* @param dev Pointer to device descriptor
* @param pin Pin number, 0..7 for PCA9557, 0..3 for PC9537
* @param pin Pin number, 0..7 for PCA9557, 0..3 for PCA9536/PC9537
* @param mode Pin mode
* @return `ESP_OK` on success
*/
Expand All @@ -167,7 +168,7 @@ esp_err_t pca9557_set_mode(i2c_dev_t *dev, uint8_t pin, pca9557_mode_t mode);
* @brief Read I/O pin level
*
* @param dev Pointer to device descriptor
* @param pin Pin number, 0..7 for PCA9557, 0..3 for PC9537
* @param pin Pin number, 0..7 for PCA9557, 0..3 for PCA9536/PC9537
* @param[out] val 1 if pin currently in high state, 0 otherwise
* @return `ESP_OK` on success
*/
Expand All @@ -179,7 +180,7 @@ esp_err_t pca9557_get_level(i2c_dev_t *dev, uint8_t pin, uint32_t *val);
* Pin must be set up as output
*
* @param dev Pointer to device descriptor
* @param pin Pin number, 0..7 for PCA9557, 0..3 for PC9537
* @param pin Pin number, 0..7 for PCA9557, 0..3 for PCA9536/PC9537
* @param val Pin level. 1 - high, 0 - low
* @return `ESP_OK` on success
*/
Expand Down

0 comments on commit c9ad31b

Please sign in to comment.