I2C: Fixes/improvements from last massive I2C commits

This commit is contained in:
Gregory Nutt 2016-02-02 07:13:03 -06:00
parent 4304405bba
commit 009e9f76cb
9 changed files with 99 additions and 65 deletions

2
arch

@ -1 +1 @@
Subproject commit cb55e3047693dca56aaf2aaa2e932f6b83d148c5
Subproject commit f80912e0ceb3ff4c83eb86a3d128df81b2bc9a85

View File

@ -88,4 +88,3 @@ int i2c_read(FAR struct i2c_master_s *dev,
return I2C_TRANSFER(dev, &msg, 1);
}

View File

@ -84,4 +84,3 @@ int i2c_write(FAR struct i2c_master_s *dev,
return I2C_TRANSFER(dev, &msg, 1);
}

View File

@ -136,17 +136,21 @@ static const struct ioexpander_ops_s g_pca9555_ops =
****************************************************************************/
static inline int pca9555_write(FAR struct pca9555_dev_s *pca,
FAR const uint8_t *wbuffer, int wbuflen)
FAR const uint8_t *, int wbuflen)
{
struct i2c_config_s config;
struct i2c_msg_s msg;
/* Set up the configuration and perform the write-read operation */
/* Setup for the transfer */
config.frequency = pca->config->frequency;
config.address = pca->config->address;
config.addrlen = 7;
msg.frequency = pca->config->frequency;
msg.addr = pca->config->address;
msg.flags = 0;
msg.buffer = (FAR uint8_t *)wbuffer; /* Override const */
msg.length = wbuflen;
return i2c_write(pca->i2c, &config, wbuffer, wbuflen);
/* Then perform the transfer. */
return I2C_TRANSFER((pca->i2c, &msg, 1);
}
/****************************************************************************

View File

@ -203,15 +203,19 @@ static struct at24c_dev_s g_at24c;
static int at24c_i2c_write(FAR struct at24c_dev_s *priv, uint16_t at24addr,
FAR const uint8_t *buffer, int buflen)
{
struct i2c_config_s config;
struct i2c_msg_s msg;
/* Set up the I2C configuration */
/* Setup for the transfer */
config.frequency = CONFIG_AT24XX_FREQUENCY;
config.address = at24addr;
config.addrlen = 7;
msg.frequency = CONFIG_AT24XX_FREQUENCY,
msg.addr = at24addr;
msg.flags = 0;
msg.buffer = (FAR uint8_t *)buffer; /* Override const */
msg.length = buflen;
return i2c_write(priv->dev, &config, buffer, buflen);
/* Then perform the transfer. */
return I2C_TRANSFER(priv->dev, &msg, 1);
}
/****************************************************************************
@ -225,15 +229,19 @@ static int at24c_i2c_write(FAR struct at24c_dev_s *priv, uint16_t at24addr,
static int at24c_i2c_read(FAR struct at24c_dev_s *priv, uint16_t at24addr,
FAR uint8_t *buffer, int buflen)
{
struct i2c_config_s config;
struct i2c_msg_s msg;
/* Set up the I2C configuration */
/* Setup for the transfer */
config.frequency = CONFIG_AT24XX_FREQUENCY;
config.address = at24addr;
config.addrlen = 7;
msg.frequency = CONFIG_AT24XX_FREQUENCY,
msg.addr = at24addr,
msg.flags = I2C_M_READ;
msg.buffer = buffer;
msg.length = buflen;
return i2c_read(priv->dev, &config, buffer, buflen);
/* Then perform the transfer. */
return I2C_TRANSFER(priv->dev, &msg, 1);
}
/************************************************************************************

View File

@ -24,7 +24,7 @@ config LIS331DL
select I2C
config LIS331DL_I2C_FREQUENCY
bool "LIS331DL I2C frequency"
int "LIS331DL I2C frequency"
default 100000
range 1 100000
depends on LIS331DL
@ -37,7 +37,7 @@ config SN_LSM9DS1
Enable driver support for the STMicro LSM9DS1.
config LSM9DS1_I2C_FREQUENCY
bool "LSM9DS1 I2C frequency"
int "LSM9DS1 I2C frequency"
default 400000
range 1 400000
depends on SN_LSM9DS1
@ -50,7 +50,7 @@ config MB7040
Enable driver support for the MaxBotix MB7040 sonar.
config MB7040_I2C_FREQUENCY
bool "MB7040 I2C frequency"
int "MB7040 I2C frequency"
default 400000
range 1 400000
depends on MB7040
@ -63,7 +63,7 @@ config MCP9844
Enable driver support for the MCP9844 I2C Temperature sensor.
config MCP9844_I2C_FREQUENCY
bool "MCP9844 I2C frequency"
int "MCP9844 I2C frequency"
default 400000
range 1 400000
depends on MCP9844
@ -76,7 +76,7 @@ config MS58XX
Enable driver support for MEAS MS58XX altimeters.
config MS58XX_I2C_FREQUENCY
bool "MS58XX I2C frequency"
int "MS58XX I2C frequency"
default 400000
range 1 400000
depends on MS58XX
@ -164,7 +164,7 @@ config LM75
the TI TMP100/101.
config LM75_I2C_FREQUENCY
bool "LM75 I2C frequency"
int "LM75 I2C frequency"
default 100000
range 1 100000
depends on I2C_LM75
@ -177,7 +177,7 @@ config LM92
Enable driver support for the TI LM92 Temperature Sensor.
config LM92_I2C_FREQUENCY
bool "LM92 I2C frequency"
int "LM92 I2C frequency"
default 400000
range 1 400000
depends on LM92

View File

@ -135,15 +135,19 @@ static const struct file_operations g_lm75fops =
static int lm75_i2c_write(FAR struct lm75_dev_s *priv,
FAR const uint8_t *buffer, int buflen)
{
struct i2c_config_s config;
struct i2c_msg_s msg;
/* Set up the I2C configuration */
/* Setup for the transfer */
config.frequency = CONFIG_LM75_I2C_FREQUENCY;
config.address = priv->addr;
config.addrlen = 7;
msg.frequency = CONFIG_LM75_I2C_FREQUENCY,
msg.addr = priv->addr;
msg.flags = 0;
msg.buffer = (FAR uint8_t *)buffer; /* Override const */
msg.length = buflen;
return i2c_write(priv->i2c, &config, buffer, buflen);
/* Then perform the transfer. */
return I2C_TRANSFER(priv->i2c, &msg, 1);
}
/****************************************************************************
@ -157,15 +161,19 @@ static int lm75_i2c_write(FAR struct lm75_dev_s *priv,
static int lm75_i2c_read(FAR struct lm75_dev_s *priv,
FAR uint8_t *buffer, int buflen)
{
struct i2c_config_s config;
struct i2c_msg_s msg;
/* Set up the I2C configuration */
/* Setup for the transfer */
config.frequency = CONFIG_LM75_I2C_FREQUENCY;
config.address = priv->addr;
config.addrlen = 7;
msg.frequency = CONFIG_LM75_I2C_FREQUENCY,
msg.addr = priv->addr,
msg.flags = I2C_M_READ;
msg.buffer = buffer;
msg.length = buflen;
return i2c_read(priv->i2c, &config, buffer, buflen);
/* Then perform the transfer. */
return I2C_TRANSFER(priv->i2c, &msg, 1);
}
/****************************************************************************

View File

@ -137,15 +137,19 @@ static const struct file_operations g_lm92fops =
static int lm92_i2c_write(FAR struct lm92_dev_s *priv,
FAR const uint8_t *buffer, int buflen)
{
struct i2c_config_s config;
struct i2c_msg_s msg;
/* Set up the I2C configuration */
/* Setup for the transfer */
config.frequency = CONFIG_LM92_I2C_FREQUENCY;
config.address = priv->addr;
config.addrlen = 7;
msg.frequency = CONFIG_LM92_I2C_FREQUENCY,
msg.addr = priv->addr;
msg.flags = 0;
msg.buffer = (FAR uint8_t *)buffer; /* Override const */
msg.length = buflen;
return i2c_write(priv->i2c, &config, buffer, buflen);
/* Then perform the transfer. */
return I2C_TRANSFER(priv->i2c, &msg, 1);
}
/****************************************************************************
@ -159,15 +163,19 @@ static int lm92_i2c_write(FAR struct lm92_dev_s *priv,
static int lm92_i2c_read(FAR struct lm92_dev_s *priv,
FAR uint8_t *buffer, int buflen)
{
struct i2c_config_s config;
struct i2c_msg_s msg;
/* Set up the I2C configuration */
/* Setup for the transfer */
config.frequency = CONFIG_LM92_I2C_FREQUENCY;
config.address = priv->addr;
config.addrlen = 7;
msg.frequency = CONFIG_LM92_I2C_FREQUENCY,
msg.addr = priv->addr,
msg.flags = I2C_M_READ;
msg.buffer = buffer;
msg.length = buflen;
return i2c_read(priv->i2c, &config, buffer, buflen);
/* Then perform the transfer. */
return I2C_TRANSFER(priv->i2c, &msg, 1);
}
/****************************************************************************

View File

@ -251,15 +251,19 @@ static uint8_t ms58xx_crc(FAR uint16_t *src, uint8_t crcIndex)
static int ms58xx_i2c_write(FAR struct ms58xx_dev_s *priv,
FAR const uint8_t *buffer, int buflen)
{
struct i2c_config_s config;
struct i2c_msg_s msg;
/* Set up the configuration and perform the write-read operation */
/* Setup for the transfer */
config.frequency = CONFIG_MS58XX_I2C_FREQUENCY;
config.address = priv->addr;
config.addrlen = 7;
msg.frequency = CONFIG_MS58XX_I2C_FREQUENCY,
msg.addr = priv->addr;
msg.flags = 0;
msg.buffer = (FAR uint8_t *)buffer; /* Override const */
msg.length = buflen;
return i2c_write(priv->i2c, &config, buffer, buflen);
/* Then perform the transfer. */
return I2C_TRANSFER(priv->i2c, &msg, 1);
}
/****************************************************************************
@ -273,15 +277,19 @@ static int ms58xx_i2c_write(FAR struct ms58xx_dev_s *priv,
static int ms58xx_i2c_read(FAR struct ms58xx_dev_s *priv,
FAR uint8_t *buffer, int buflen)
{
struct i2c_config_s config;
struct i2c_msg_s msg;
/* Set up the configuration and perform the write-read operation */
/* Setup for the transfer */
config.frequency = CONFIG_MS58XX_I2C_FREQUENCY;
config.address = priv->addr;
config.addrlen = 7;
msg.frequency = CONFIG_MS58XX_I2C_FREQUENCY,
msg.addr = priv->addr,
msg.flags = I2C_M_READ;
msg.buffer = buffer;
msg.length = buflen;
return i2c_read(priv->i2c, &config, buffer, buflen);
/* Then perform the transfer. */
return I2C_TRANSFER(priv->i2c, &msg, 1);
}
/****************************************************************************