mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
arch/risc-v/src/mpfs/mpfs_i2c.c: Add more error status codes
Add more error status codes to help debugging in the future. Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
committed by
Xiang Xiao
parent
dae31dc866
commit
fc4b39b1dd
@@ -83,7 +83,10 @@ typedef enum mpfs_i2c_status
|
|||||||
MPFS_I2C_SUCCESS = 0u,
|
MPFS_I2C_SUCCESS = 0u,
|
||||||
MPFS_I2C_IN_PROGRESS,
|
MPFS_I2C_IN_PROGRESS,
|
||||||
MPFS_I2C_FAILED,
|
MPFS_I2C_FAILED,
|
||||||
MPFS_I2C_TIMED_OUT
|
MPFS_I2C_FAILED_SLAW_NACK,
|
||||||
|
MPFS_I2C_FAILED_SLAR_NACK,
|
||||||
|
MPFS_I2C_FAILED_TX_DATA_NACK,
|
||||||
|
MPFS_I2C_FAILED_BUS_ERROR,
|
||||||
} mpfs_i2c_status_t;
|
} mpfs_i2c_status_t;
|
||||||
|
|
||||||
typedef enum mpfs_i2c_clock_divider
|
typedef enum mpfs_i2c_clock_divider
|
||||||
@@ -468,7 +471,7 @@ static int mpfs_i2c_irq(int cpuint, void *context, void *arg)
|
|||||||
|
|
||||||
case MPFS_I2C_ST_SLAW_NACK:
|
case MPFS_I2C_ST_SLAW_NACK:
|
||||||
modifyreg32(MPFS_I2C_CTRL, 0, MPFS_I2C_CTRL_STO_MASK);
|
modifyreg32(MPFS_I2C_CTRL, 0, MPFS_I2C_CTRL_STO_MASK);
|
||||||
priv->status = MPFS_I2C_FAILED;
|
priv->status = MPFS_I2C_FAILED_SLAW_NACK;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MPFS_I2C_ST_SLAW_ACK:
|
case MPFS_I2C_ST_SLAW_ACK:
|
||||||
@@ -536,7 +539,7 @@ static int mpfs_i2c_irq(int cpuint, void *context, void *arg)
|
|||||||
|
|
||||||
case MPFS_I2C_ST_TX_DATA_NACK:
|
case MPFS_I2C_ST_TX_DATA_NACK:
|
||||||
modifyreg32(MPFS_I2C_CTRL, 0, MPFS_I2C_CTRL_STO_MASK);
|
modifyreg32(MPFS_I2C_CTRL, 0, MPFS_I2C_CTRL_STO_MASK);
|
||||||
priv->status = MPFS_I2C_FAILED;
|
priv->status = MPFS_I2C_FAILED_TX_DATA_NACK;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MPFS_I2C_ST_SLAR_ACK: /* SLA+R tx'ed. */
|
case MPFS_I2C_ST_SLAR_ACK: /* SLA+R tx'ed. */
|
||||||
@@ -558,7 +561,7 @@ static int mpfs_i2c_irq(int cpuint, void *context, void *arg)
|
|||||||
|
|
||||||
case MPFS_I2C_ST_SLAR_NACK: /* SLA+R tx'ed; send a stop condition */
|
case MPFS_I2C_ST_SLAR_NACK: /* SLA+R tx'ed; send a stop condition */
|
||||||
modifyreg32(MPFS_I2C_CTRL, 0, MPFS_I2C_CTRL_STO_MASK);
|
modifyreg32(MPFS_I2C_CTRL, 0, MPFS_I2C_CTRL_STO_MASK);
|
||||||
priv->status = MPFS_I2C_FAILED;
|
priv->status = MPFS_I2C_FAILED_SLAR_NACK;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MPFS_I2C_ST_RX_DATA_ACK:
|
case MPFS_I2C_ST_RX_DATA_ACK:
|
||||||
@@ -610,7 +613,6 @@ static int mpfs_i2c_irq(int cpuint, void *context, void *arg)
|
|||||||
|
|
||||||
priv->rx_buffer[priv->rx_idx] = (uint8_t)getreg32(MPFS_I2C_DATA);
|
priv->rx_buffer[priv->rx_idx] = (uint8_t)getreg32(MPFS_I2C_DATA);
|
||||||
priv->rx_idx++;
|
priv->rx_idx++;
|
||||||
|
|
||||||
priv->status = MPFS_I2C_SUCCESS;
|
priv->status = MPFS_I2C_SUCCESS;
|
||||||
modifyreg32(MPFS_I2C_CTRL, 0, MPFS_I2C_CTRL_STO_MASK);
|
modifyreg32(MPFS_I2C_CTRL, 0, MPFS_I2C_CTRL_STO_MASK);
|
||||||
break;
|
break;
|
||||||
@@ -651,7 +653,7 @@ static int mpfs_i2c_irq(int cpuint, void *context, void *arg)
|
|||||||
|
|
||||||
if (priv->status == MPFS_I2C_IN_PROGRESS)
|
if (priv->status == MPFS_I2C_IN_PROGRESS)
|
||||||
{
|
{
|
||||||
priv->status = MPFS_I2C_FAILED;
|
priv->status = MPFS_I2C_FAILED_BUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user