mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 07:12:54 +08:00
arch/risc-v/src/mpfs/mpfs_i2c.c: Add more i2cerr traces
Add sanity checks for debugging possible errors in the driver. Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
committed by
Xiang Xiao
parent
120dfbd45f
commit
2b10b38c1d
@@ -721,6 +721,10 @@ static int mpfs_i2c_transfer(struct i2c_master_s *dev,
|
|||||||
{
|
{
|
||||||
struct mpfs_i2c_priv_s *priv = (struct mpfs_i2c_priv_s *)dev;
|
struct mpfs_i2c_priv_s *priv = (struct mpfs_i2c_priv_s *)dev;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
|
#ifdef CONFIG_DEBUG_I2C_ERROR
|
||||||
|
int sval;
|
||||||
|
uint32_t status;
|
||||||
|
#endif
|
||||||
|
|
||||||
i2cinfo("Starting transfer request of %d message(s):\n", count);
|
i2cinfo("Starting transfer request of %d message(s):\n", count);
|
||||||
|
|
||||||
@@ -735,6 +739,24 @@ static int mpfs_i2c_transfer(struct i2c_master_s *dev,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_I2C_ERROR
|
||||||
|
/* We should never start at transfer with semaphore already signalled */
|
||||||
|
|
||||||
|
sem_getvalue(&priv->sem_isr, &sval);
|
||||||
|
if (sval != 0)
|
||||||
|
{
|
||||||
|
i2cerr("Already signalled at start? %d\n", sval);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We should always be idle before transfer */
|
||||||
|
|
||||||
|
status = getreg32(MPFS_I2C_STATUS);
|
||||||
|
if (status != MPFS_I2C_ST_IDLE)
|
||||||
|
{
|
||||||
|
i2cerr("I2C bus not idle before transfer! Status: 0x%x\n", status);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
priv->msgv = msgs;
|
priv->msgv = msgs;
|
||||||
priv->msgc = count;
|
priv->msgc = count;
|
||||||
|
|
||||||
@@ -827,6 +849,16 @@ static int mpfs_i2c_transfer(struct i2c_master_s *dev,
|
|||||||
i2cinfo("Message %" PRIu8 " transfer complete.\n", priv->msgid);
|
i2cinfo("Message %" PRIu8 " transfer complete.\n", priv->msgid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG_I2C_ERROR
|
||||||
|
/* We should always be idle after the transfers */
|
||||||
|
|
||||||
|
status = getreg32(MPFS_I2C_STATUS);
|
||||||
|
if (status != MPFS_I2C_ST_IDLE)
|
||||||
|
{
|
||||||
|
i2cerr("I2C bus not idle after transfer! Status: 0x%x\n", status);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Irq was enabled at mpfs_i2c_sendstart() */
|
/* Irq was enabled at mpfs_i2c_sendstart() */
|
||||||
|
|
||||||
up_disable_irq(priv->plic_irq);
|
up_disable_irq(priv->plic_irq);
|
||||||
|
|||||||
Reference in New Issue
Block a user