Skip to content

Commit

Permalink
Merge pull request #453 from AxelLin/pca9557-fixes
Browse files Browse the repository at this point in the history
pca9557: fix base i2c address for tca9534, fix pca9557_get_mode()/pca9557_set_mode()
  • Loading branch information
UncleRus authored Sep 15, 2022
2 parents 425a3f9 + 0d33b08 commit fca4578
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions components/pca9557/pca9557.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static esp_err_t read_bit(i2c_dev_t *dev, uint8_t reg, uint8_t bit, uint32_t *va
CHECK_ARG(dev && val);

uint8_t v;
CHECK(read_reg_8(dev, REG_IN, &v));
CHECK(read_reg_8(dev, reg, &v));
*val = v & BIT(bit) ? 1 : 0;

return ESP_OK;
Expand All @@ -88,9 +88,9 @@ static esp_err_t write_bit(i2c_dev_t *dev, uint8_t reg, uint8_t bit, uint32_t va
uint8_t v;

I2C_DEV_TAKE_MUTEX(dev);
I2C_DEV_CHECK(dev, i2c_dev_read_reg(dev, REG_OUT, &v, 1));
I2C_DEV_CHECK(dev, i2c_dev_read_reg(dev, reg, &v, 1));
v = (v & ~BIT(bit)) | (val ? BIT(bit) : 0);
I2C_DEV_CHECK(dev, i2c_dev_write_reg(dev, REG_OUT, &v, 1));
I2C_DEV_CHECK(dev, i2c_dev_write_reg(dev, reg, &v, 1));
I2C_DEV_GIVE_MUTEX(dev);

return ESP_OK;
Expand Down
2 changes: 1 addition & 1 deletion components/pca9557/pca9557.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ extern "C" {

#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 0x38 ///< Base I2C address for TCA9534
#define TCA9534_I2C_ADDR_BASE 0x20 ///< Base I2C address for TCA9534

/**
* Pin modes (directions)
Expand Down
2 changes: 1 addition & 1 deletion examples/pca9557/default/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ menu "Example configuration"
PCA9537 has a fixed I2C address (`0x49`).

TCA9534 has three address pins (`A0`, `A1` and `A2`). The address
starts from `0x38` (all address pins are grounded)
starts from `0x20` (all address pins are grounded)

config EXAMPLE_I2C_MASTER_SCL
int "SCL GPIO Number"
Expand Down

0 comments on commit fca4578

Please sign in to comment.