Skip to content

Commit

Permalink
arch/risc-v/src/mpfs/mpfs_i2c.c: Add more error status codes
Browse files Browse the repository at this point in the history
Add more error status codes to help debugging in the future.

Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine committed Jan 11, 2024
1 parent 100136e commit ad3078d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions arch/risc-v/src/mpfs/mpfs_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ typedef enum mpfs_i2c_status
MPFS_I2C_SUCCESS = 0u,
MPFS_I2C_IN_PROGRESS,
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;

typedef enum mpfs_i2c_clock_divider
Expand Down Expand Up @@ -467,7 +470,7 @@ static int mpfs_i2c_irq(int cpuint, void *context, void *arg)

case MPFS_I2C_ST_SLAW_NACK:
modifyreg32(MPFS_I2C_CTRL, 0, MPFS_I2C_CTRL_STO_MASK);
priv->status = MPFS_I2C_FAILED;
priv->status = MPFS_I2C_FAILED_SLAW_NACK;
break;

case MPFS_I2C_ST_SLAW_ACK:
Expand Down Expand Up @@ -535,7 +538,7 @@ static int mpfs_i2c_irq(int cpuint, void *context, void *arg)

case MPFS_I2C_ST_TX_DATA_NACK:
modifyreg32(MPFS_I2C_CTRL, 0, MPFS_I2C_CTRL_STO_MASK);
priv->status = MPFS_I2C_FAILED;
priv->status = MPFS_I2C_FAILED_TX_DATA_NACK;
break;

case MPFS_I2C_ST_SLAR_ACK: /* SLA+R tx'ed. */
Expand All @@ -557,7 +560,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 */
modifyreg32(MPFS_I2C_CTRL, 0, MPFS_I2C_CTRL_STO_MASK);
priv->status = MPFS_I2C_FAILED;
priv->status = MPFS_I2C_FAILED_SLAR_NACK;
break;

case MPFS_I2C_ST_RX_DATA_ACK:
Expand Down Expand Up @@ -609,7 +612,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_idx++;

priv->status = MPFS_I2C_SUCCESS;
modifyreg32(MPFS_I2C_CTRL, 0, MPFS_I2C_CTRL_STO_MASK);
break;
Expand Down Expand Up @@ -650,7 +652,7 @@ static int mpfs_i2c_irq(int cpuint, void *context, void *arg)

if (priv->status == MPFS_I2C_IN_PROGRESS)
{
priv->status = MPFS_I2C_FAILED;
priv->status = MPFS_I2C_FAILED_BUS_ERROR;
}

break;
Expand Down

0 comments on commit ad3078d

Please sign in to comment.