summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-09-12 09:46:20 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-09-12 09:46:20 -0600
commit527a8b61f84554d93f565a24317bf69602045006 (patch)
treeb0005247087c22e06b80681b1f7df9f1c2d363f9
parente8e8b085701b8a2bc3effdef96affbae40eb4c4d (diff)
downloadnuttx-527a8b61f84554d93f565a24317bf69602045006.tar.gz
nuttx-527a8b61f84554d93f565a24317bf69602045006.tar.bz2
nuttx-527a8b61f84554d93f565a24317bf69602045006.zip
SAMA5 TWI: Cleanup compilation errors that occur when I2C debug is enabled
-rw-r--r--nuttx/ChangeLog2
-rw-r--r--nuttx/arch/arm/src/sama5/sam_twi.c52
2 files changed, 26 insertions, 28 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 1d8d2664d..0b5464710 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -5537,4 +5537,6 @@
* fs/nxffs: Clean up some compilation warnings (2013-9-12)
* drivers/mtd/at24xx.c: Add support for the AT 24C512 part
(2013-9-12).
+ * arch/arm/src/sama5/sama5_twi.c: Clean up some errors that
+ only occur with CONFIG_DEBUG_I2C (2013-9-12).
diff --git a/nuttx/arch/arm/src/sama5/sam_twi.c b/nuttx/arch/arm/src/sama5/sam_twi.c
index c2d5ce9aa..ff8b181ed 100644
--- a/nuttx/arch/arm/src/sama5/sam_twi.c
+++ b/nuttx/arch/arm/src/sama5/sam_twi.c
@@ -248,19 +248,19 @@ static struct twi_dev_s g_twi2;
struct i2c_ops_s g_twiops =
{
- .setfrequency = twi_setfrequency,
- .setaddress = twi_setaddress,
- .write = twi_write,
- .read = twi_read,
+ .setfrequency = twi_setfrequency,
+ .setaddress = twi_setaddress,
+ .write = twi_write,
+ .read = twi_read,
#ifdef CONFIG_I2C_WRITEREAD
- .writeread = twi_writeread,
+ .writeread = twi_writeread,
#endif
#ifdef CONFIG_I2C_TRANSFER
- .transfer = twi_transfer
+ .transfer = twi_transfer
#endif
#ifdef CONFIG_I2C_SLAVE
- int (*setownaddress)(FAR struct i2c_dev_s *dev, int addr, int nbits);
- int (*registercallback)(FAR struct i2c_dev_s *dev, int (*callback)(void) );
+ .setownaddress = twi_setownaddress
+ .registercallback = twi_registercallback
#endif
};
@@ -637,11 +637,7 @@ static int twi_startread(struct twi_dev_s *priv, struct i2c_msg_s *msg)
/* Enable read interrupt and send the START condition */
twi_putreg(priv, SAM_TWI_IER_OFFSET, TWI_INT_RXRDY);
-
- if ((msg->flags & I2C_M_NORESTART) == 0)
- {
- twi_putreg(priv, SAM_TWI_CR_OFFSET, TWI_CR_START);
- }
+ twi_putreg(priv, SAM_TWI_CR_OFFSET, TWI_CR_START);
ret = twi_wait(priv);
irqrestore(flags);
@@ -761,7 +757,7 @@ static int twi_setaddress(FAR struct i2c_dev_s *dev, int addr, int nbits)
twi_takesem(&priv->exclsem);
- /* Set the correctly shifted, 7-bit address */
+ /* Remember 7- or 10-bit address */
priv->address = addr;
priv->flags = (nbits == 10) ? I2C_M_TEN : 0;
@@ -779,7 +775,7 @@ static int twi_setaddress(FAR struct i2c_dev_s *dev, int addr, int nbits)
*
*******************************************************************************/
-static int twi_write(FAR struct i2c_dev_s *dev, const uint8_t *buffer, int buflen)
+static int twi_write(FAR struct i2c_dev_s *dev, const uint8_t *wbuffer, int wbuflen)
{
struct twi_dev_s *priv = (struct twi_dev_s *) dev;
int ret;
@@ -788,11 +784,11 @@ static int twi_write(FAR struct i2c_dev_s *dev, const uint8_t *buffer, int bufle
{
.addr = priv->address,
.flags = priv->flags,
- .buffer = (uint8_t *)buffer,
- .length = buflen
+ .buffer = (uint8_t *)wbuffer, /* Override const */
+ .length = wbuflen
};
- i2cvdbg("TWI%d buflen: %d\n", priv->twi, buflen);
+ i2cvdbg("TWI%d buflen: %d\n", priv->twi, wbuflen);
DEBUGASSERT(dev != NULL);
/* Get exclusive access to the device */
@@ -829,7 +825,7 @@ errout:
*
*******************************************************************************/
-static int twi_read(FAR struct i2c_dev_s *dev, uint8_t *buffer, int buflen)
+static int twi_read(FAR struct i2c_dev_s *dev, uint8_t *rbuffer, int rbuflen)
{
struct twi_dev_s *priv = (struct twi_dev_s *)dev;
int ret;
@@ -838,12 +834,12 @@ static int twi_read(FAR struct i2c_dev_s *dev, uint8_t *buffer, int buflen)
{
.addr = priv->address,
.flags = priv->flags | I2C_M_READ,
- .buffer = buffer,
- .length = buflen
+ .buffer = rbuffer,
+ .length = rbuflen
};
DEBUGASSERT(dev != NULL);
- i2cvdbg(TWI%d "buflen: %d\n", priv->twi, buflen);
+ i2cvdbg("TWI%d rbuflen: %d\n", priv->twi, rbuflen);
/* Get exclusive access to the device */
@@ -901,7 +897,7 @@ static int twi_writeread(FAR struct i2c_dev_s *dev, const uint8_t *wbuffer,
};
DEBUGASSERT(dev != NULL);
- i2cvdbg(TWI%d "wbuflen: %d rbuflen: %d\n", priv->twi, wbuflen, rbuflen);
+ i2cvdbg("TWI%d wbuflen: %d rbuflen: %d\n", priv->twi, wbuflen, rbuflen);
/* Get exclusive access to the device */
@@ -977,7 +973,7 @@ static int twi_transfer(FAR struct i2c_dev_s *dev,
int ret;
DEBUGASSERT(dev != NULL);
- i2cvdbg(TWI%d "count: %d\n", priv->twi, count);
+ i2cvdbg("TWI%d count: %d\n", priv->twi, count);
/* Get exclusive access to the device */
@@ -1075,7 +1071,7 @@ static void twi_hw_initialize(struct twi_dev_s *priv, unsigned int pid,
{
uint32_t regval;
- uvdbg("TWI%d Initializing\n", priv->twi);
+ i2cvdbg("TWI%d Initializing\n", priv->twi);
/* SVEN: TWI Slave Mode Enabled */
@@ -1125,7 +1121,7 @@ struct i2c_dev_s *up_i2cinitialize(int bus)
uint32_t frequency;
unsigned int pid;
- uvdbg("TWI%d Initializing\n", priv->twi);
+ i2cvdbg("TWI%d Initializing\n", priv->twi);
flags = irqsave();
@@ -1216,7 +1212,7 @@ struct i2c_dev_s *up_i2cinitialize(int bus)
return NULL;
}
- i2cvdbg("Initializing TWI%d\n", port);
+ i2cvdbg("Initializing TWI%d\n", bus);
/* Initialize the device structure */
@@ -1259,7 +1255,7 @@ int up_i2cuninitialize(FAR struct i2c_dev_s * dev)
{
struct twi_dev_s *priv = (struct twi_dev_s *) dev;
- uvdbg("TWI%d Un-initializing\n", priv->twi);
+ i2cvdbg("TWI%d Un-initializing\n", priv->twi);
/* Disable interrupts */