mirror of
https://github.com/apache/nuttx.git
synced 2026-09-27 18:58:27 +08:00
Add I2C frequency to the i2c_msg_s structure
This commit is contained in:
+29
-22
@@ -315,20 +315,22 @@ static int mxt_getreg(FAR struct mxt_dev_s *priv, uint16_t regaddr,
|
||||
|
||||
/* Set up to write the address */
|
||||
|
||||
addrbuf[0] = regaddr & 0xff;
|
||||
addrbuf[1] = (regaddr >> 8) & 0xff;
|
||||
addrbuf[0] = regaddr & 0xff;
|
||||
addrbuf[1] = (regaddr >> 8) & 0xff;
|
||||
|
||||
msg[0].addr = priv->lower->address;
|
||||
msg[0].flags = 0;
|
||||
msg[0].buffer = addrbuf;
|
||||
msg[0].length = 2;
|
||||
msg[0].frequency = priv->frequency;
|
||||
msg[0].addr = priv->lower->address;
|
||||
msg[0].flags = 0;
|
||||
msg[0].buffer = addrbuf;
|
||||
msg[0].length = 2;
|
||||
|
||||
/* Followed by the read data */
|
||||
|
||||
msg[1].addr = priv->lower->address;
|
||||
msg[1].flags = I2C_M_READ;
|
||||
msg[1].buffer = buffer;
|
||||
msg[1].length = buflen;
|
||||
msg[1].frequency = priv->frequency;
|
||||
msg[1].addr = priv->lower->address;
|
||||
msg[1].flags = I2C_M_READ;
|
||||
msg[1].buffer = buffer;
|
||||
msg[1].length = buflen;
|
||||
|
||||
/* Read the register data. The returned value is the number messages
|
||||
* completed.
|
||||
@@ -387,20 +389,22 @@ static int mxt_putreg(FAR struct mxt_dev_s *priv, uint16_t regaddr,
|
||||
|
||||
/* Set up to write the address */
|
||||
|
||||
addrbuf[0] = regaddr & 0xff;
|
||||
addrbuf[1] = (regaddr >> 8) & 0xff;
|
||||
addrbuf[0] = regaddr & 0xff;
|
||||
addrbuf[1] = (regaddr >> 8) & 0xff;
|
||||
|
||||
msg[0].addr = priv->lower->address;
|
||||
msg[0].flags = 0;
|
||||
msg[0].buffer = addrbuf;
|
||||
msg[0].length = 2;
|
||||
msg[0].frequency = priv->frequency;
|
||||
msg[0].addr = priv->lower->address;
|
||||
msg[0].flags = 0;
|
||||
msg[0].buffer = addrbuf;
|
||||
msg[0].length = 2;
|
||||
|
||||
/* Followed by the write data (with no repeated start) */
|
||||
|
||||
msg[1].addr = priv->lower->address;
|
||||
msg[1].flags = I2C_M_NORESTART;
|
||||
msg[1].buffer = (FAR uint8_t *)buffer;
|
||||
msg[1].length = buflen;
|
||||
msg[1].frequency = priv->frequency;
|
||||
msg[1].addr = priv->lower->address;
|
||||
msg[1].flags = I2C_M_NORESTART;
|
||||
msg[1].buffer = (FAR uint8_t *)buffer;
|
||||
msg[1].length = buflen;
|
||||
|
||||
/* Write the register data. The returned value is the number messages
|
||||
* completed.
|
||||
@@ -1511,7 +1515,9 @@ static int mxt_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
FAR uint32_t *ptr = (FAR uint32_t *)((uintptr_t)arg);
|
||||
DEBUGASSERT(priv->lower != NULL && ptr != NULL);
|
||||
priv->frequency = I2C_SETFREQUENCY(priv->i2c, *ptr);
|
||||
|
||||
priv->frequency = *ptr;
|
||||
(void)I2C_SETFREQUENCY(priv->i2c, *ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1734,7 +1740,8 @@ static int mxt_hwinitialize(FAR struct mxt_dev_s *priv)
|
||||
|
||||
/* Set the selected I2C frequency */
|
||||
|
||||
priv->frequency = I2C_SETFREQUENCY(priv->i2c, priv->lower->frequency);
|
||||
priv->frequency = priv->lower->frequency;
|
||||
(void)I2C_SETFREQUENCY(priv->i2c, priv->lower->frequency);
|
||||
|
||||
/* Read the info registers from the device */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user