I2C: Fix some compile time issues found with tools/testbuild.sh

This commit is contained in:
Gregory Nutt 2016-02-01 18:02:39 -06:00
parent 0693e76be8
commit c9a7d48cb2
8 changed files with 89 additions and 88 deletions

View File

@ -338,8 +338,6 @@ static const char *efm32_i2c_state_str(int i2c_state);
* Private Data
****************************************************************************/
/* Trace events strings */
/* I2C device structures */
#ifdef CONFIG_EFM32_I2C0

View File

@ -204,8 +204,6 @@ static void lpc11_i2c_setfrequency(struct lpc11_i2cdev_s *priv,
static int lpc11_i2c_start(struct lpc11_i2cdev_s *priv)
{
int ret = -1;
putreg32(I2C_CONCLR_STAC | I2C_CONCLR_SIC,
priv->base + LPC11_I2C_CONCLR_OFFSET);
putreg32(I2C_CONSET_STA, priv->base + LPC11_I2C_CONSET_OFFSET);

View File

@ -167,7 +167,7 @@ struct i2c_ops_s lpc17_i2c_ops =
****************************************************************************/
static void lpc17_i2c_setfrequency(struct lpc17_i2cdev_s *priv,
uint32_t frequency);
uint32_t frequency)
{
if (frequency != priv->frequency)
{
@ -204,8 +204,6 @@ static void lpc17_i2c_setfrequency(struct lpc17_i2cdev_s *priv,
static int lpc17_i2c_start(struct lpc17_i2cdev_s *priv)
{
int ret = -1;
putreg32(I2C_CONCLR_STAC | I2C_CONCLR_SIC,
priv->base + LPC17_I2C_CONCLR_OFFSET);
putreg32(I2C_CONSET_STA, priv->base + LPC17_I2C_CONSET_OFFSET);

View File

@ -209,8 +209,6 @@ static void lpc2378_i2c_setfrequency(struct lpc2378_i2cdev_s *priv,
static int lpc2378_i2c_start(struct lpc2378_i2cdev_s *priv)
{
int ret = -1;
putreg32(I2C_CONCLR_STAC | I2C_CONCLR_SIC,
priv->base + I2C_CONCLR_OFFSET);
putreg32(I2C_CONSET_STA, priv->base + I2C_CONSET_OFFSET);

View File

@ -120,7 +120,7 @@ static int i2c_transfer(FAR struct i2c_master_s *dev,
FAR struct i2c_msg_s *msgs, int count);
/****************************************************************************
* I2C device operations
* Private Data
****************************************************************************/
struct i2c_ops_s lpc31_i2c_ops =
@ -129,83 +129,11 @@ struct i2c_ops_s lpc31_i2c_ops =
};
/****************************************************************************
* Name: up_i2cinitialize
*
* Description:
* Initialise an I2C device
*
* Private Functions
****************************************************************************/
struct i2c_master_s *up_i2cinitialize(int port)
{
struct lpc31_i2cdev_s *priv = &i2cdevices[port];
priv->base = (port == 0) ? LPC31_I2C0_VBASE : LPC31_I2C1_VBASE;
priv->clkid = (port == 0) ? CLKID_I2C0PCLK : CLKID_I2C1PCLK;
priv->rstid = (port == 0) ? RESETID_I2C0RST : RESETID_I2C1RST;
priv->irqid = (port == 0) ? LPC31_IRQ_I2C0 : LPC31_IRQ_I2C1;
sem_init(&priv->mutex, 0, 1);
sem_init(&priv->wait, 0, 0);
/* Enable I2C system clocks */
lpc31_enableclock(priv->clkid);
/* Reset I2C blocks */
lpc31_softreset(priv->rstid);
/* Soft reset the device */
i2c_reset(priv);
/* Allocate a watchdog timer */
priv->timeout = wd_create();
DEBUGASSERT(priv->timeout != 0);
/* Attach Interrupt Handler */
irq_attach(priv->irqid, i2c_interrupt);
/* Enable Interrupt Handler */
up_enable_irq(priv->irqid);
/* Install our operations */
priv->dev.ops = &lpc31_i2c_ops;
return &priv->dev;
}
/****************************************************************************
* Name: up_i2cuninitalize
*
* Description:
* Uninitialise an I2C device
*
****************************************************************************/
void up_i2cuninitalize(struct lpc31_i2cdev_s *priv)
{
/* Disable All Interrupts, soft reset the device */
i2c_reset(priv);
/* Detach Interrupt Handler */
irq_detach(priv->irqid);
/* Reset I2C blocks */
lpc31_softreset(priv->rstid);
/* Disable I2C system clocks */
lpc31_disableclock(priv->clkid);
}
/****************************************************************************
* Name: lpc31_i2c_setfrequency
* Name: i2c_setfrequency
*
* Description:
* Set the frequency for the next transfer
@ -567,6 +495,7 @@ static void i2c_timeout(int argc, uint32_t arg, ...)
* Perform a soft reset of the I2C controller
*
****************************************************************************/
static void i2c_reset(struct lpc31_i2cdev_s *priv)
{
putreg32(I2C_CTRL_RESET, priv->base + LPC31_I2C_CTRL_OFFSET);
@ -576,3 +505,83 @@ static void i2c_reset(struct lpc31_i2cdev_s *priv)
while ((getreg32(priv->base + LPC31_I2C_CTRL_OFFSET) & I2C_CTRL_RESET) != 0)
;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_i2cinitialize
*
* Description:
* Initialise an I2C device
*
****************************************************************************/
struct i2c_master_s *up_i2cinitialize(int port)
{
struct lpc31_i2cdev_s *priv = &i2cdevices[port];
priv->base = (port == 0) ? LPC31_I2C0_VBASE : LPC31_I2C1_VBASE;
priv->clkid = (port == 0) ? CLKID_I2C0PCLK : CLKID_I2C1PCLK;
priv->rstid = (port == 0) ? RESETID_I2C0RST : RESETID_I2C1RST;
priv->irqid = (port == 0) ? LPC31_IRQ_I2C0 : LPC31_IRQ_I2C1;
sem_init(&priv->mutex, 0, 1);
sem_init(&priv->wait, 0, 0);
/* Enable I2C system clocks */
lpc31_enableclock(priv->clkid);
/* Reset I2C blocks */
lpc31_softreset(priv->rstid);
/* Soft reset the device */
i2c_reset(priv);
/* Allocate a watchdog timer */
priv->timeout = wd_create();
DEBUGASSERT(priv->timeout != 0);
/* Attach Interrupt Handler */
irq_attach(priv->irqid, i2c_interrupt);
/* Enable Interrupt Handler */
up_enable_irq(priv->irqid);
/* Install our operations */
priv->dev.ops = &lpc31_i2c_ops;
return &priv->dev;
}
/****************************************************************************
* Name: up_i2cuninitalize
*
* Description:
* Uninitialise an I2C device
*
****************************************************************************/
void up_i2cuninitalize(struct lpc31_i2cdev_s *priv)
{
/* Disable All Interrupts, soft reset the device */
i2c_reset(priv);
/* Detach Interrupt Handler */
irq_detach(priv->irqid);
/* Reset I2C blocks */
lpc31_softreset(priv->rstid);
/* Disable I2C system clocks */
lpc31_disableclock(priv->clkid);
}

View File

@ -191,8 +191,6 @@ static void lpc43_i2c_setfrequency(struct lpc43_i2cdev_s *priv,
static int lpc43_i2c_start(struct lpc43_i2cdev_s *priv)
{
int ret = -1;
putreg32(I2C_CONCLR_STAC | I2C_CONCLR_SIC,
priv->base + LPC43_I2C_CONCLR_OFFSET);
putreg32(I2C_CONSET_STA, priv->base + LPC43_I2C_CONSET_OFFSET);

View File

@ -237,7 +237,7 @@ static int twi_transfer(FAR struct i2c_master_s *dev,
/* Initialization */
static uint32_t twi_setfrequency(struct twi_dev_s *priv, uint32_t frequency);
static void twi_setfrequency(struct twi_dev_s *priv, uint32_t frequency);
static void twi_hw_initialize(struct twi_dev_s *priv, uint32_t frequency);
/****************************************************************************

View File

@ -1915,7 +1915,7 @@ static int tiva_i2c_process(struct i2c_master_s *dev, struct i2c_msg_s *msgv, in
* each message segment.
*/
tiva_i2c_setclock(priv, msgs->frequency);
tiva_i2c_setclock(priv, msgv->frequency);
/* Send the address, then the process moves into the ISR. I2C
* interrupts will be enabled within tiva_i2c_waitdone().
@ -2033,7 +2033,9 @@ static int tiva_i2c_transfer(struct i2c_master_s *dev, struct i2c_msg_s *msgv,
tiva_i2c_sem_wait(dev); /* Ensure that address or flags don't change meanwhile */
ret = tiva_i2c_process(dev, msgv, msgc);
tiva_i2c_sem_post(dev);
return ret;
}
/************************************************************************************