diff --git a/ChangeLog b/ChangeLog index d1930acca63..41bf078fdca 100755 --- a/ChangeLog +++ b/ChangeLog @@ -11372,4 +11372,6 @@ * drivers/i2c/i2c_writeread.c: Create a wrapper that uses I2C_TRANSFER to implement I2C_WRITEREAD functionality (2016-01-26). * I2C: Eliminate the I@C_WRITEREAD method (2016-01-26). + * drivers/i2c/i2c_read.c and i2c_write.c: Convert to use I2C_TRANSFER vs. + I2C_READ and I2C_WRITE which are not thread safe (2016-01-26). diff --git a/drivers/ioexpander/pca9555.c b/drivers/ioexpander/pca9555.c index 5d3843d7eaf..9f3fe58ebfb 100644 --- a/drivers/ioexpander/pca9555.c +++ b/drivers/ioexpander/pca9555.c @@ -72,7 +72,9 @@ * Private Function Prototypes ****************************************************************************/ -static int pca9555_writeread(FAR struct pca9555_dev_s *pca, +static inline int pca9555_write(FAR struct pca9555_dev_s *pca, + FAR const uint8_t *wbuffer, int wbuflen); +static inline int pca9555_writeread(FAR struct pca9555_dev_s *pca, FAR const uint8_t *wbuffer, int wbuflen, FAR uint8_t *rbuffer, int rbuflen); static int pca9555_direction(FAR struct ioexpander_dev_s *dev, uint8_t pin, @@ -129,6 +131,28 @@ static const struct ioexpander_ops_s g_pca9555_ops = * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: pca9555_writeread + * + * Description: + * Write to then read from the I2C device. + * + ****************************************************************************/ + +static inline int pca9555_write(FAR struct pca9555_dev_s *pca, + FAR const uint8_t *wbuffer, int wbuflen) +{ + struct i2c_config_s config; + + /* Set up the configuration and perform the write-read operation */ + + config.frequency = pca->config->frequency; + config.address = pca->config->address; + config.addrlen = 7; + + return i2c_write(pca->i2c, &config, wbuffer, wbuflen); +} + /**************************************************************************** * Name: pca9555_writeread * @@ -194,7 +218,7 @@ static int pca9555_setbit(FAR struct ioexpander_dev_s *dev, uint8_t addr, buf[1] &= ~(1 << pin); } - return I2C_WRITE(pca->i2c, buf, 2); + return pca9555_write(pca, buf, 2); } /**************************************************************************** @@ -418,7 +442,7 @@ static int pca9555_multiwritepin(FAR struct ioexpander_dev_s *dev, /* Now write back the new pins states */ buf[0] = addr; - return I2C_WRITE(pca->i2c, buf, 3); + return pca9555_write(pca, buf, 3); } /****************************************************************************