Skip to content

Commit

Permalink
rp2040: Check for i2c NACK/Start NACK (Klipper3d#6692)
Browse files Browse the repository at this point in the history
Signed-off-by: Timofey Titovets <[email protected]>
  • Loading branch information
nefelim4ag authored Sep 22, 2024
1 parent b4aca12 commit 9426485
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/rp2040/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ i2c_do_write(i2c_hw_t *i2c, uint8_t addr, uint8_t write_len, uint8_t *write
if (!timer_is_before(timer_read_time(), timeout))
shutdown("i2c timeout");
}

if (i2c->raw_intr_stat & I2C_IC_RAW_INTR_STAT_TX_ABRT_BITS) {
uint32_t abort_source = i2c->tx_abrt_source;
if (abort_source & I2C_IC_TX_ABRT_SOURCE_ABRT_7B_ADDR_NOACK_BITS)
{
i2c->clr_tx_abrt;
shutdown("i2c Start NACK");
}
if (abort_source & I2C_IC_TX_ABRT_SOURCE_ABRT_TXDATA_NOACK_BITS)
{
i2c->clr_tx_abrt;
shutdown("i2c NACK");
}
}
}

static void
Expand Down Expand Up @@ -186,6 +200,14 @@ i2c_do_read(i2c_hw_t *i2c, uint8_t addr, uint8_t read_len, uint8_t *read
*read++ = i2c->data_cmd & 0xFF;
have_read++;
}

if (i2c->raw_intr_stat & I2C_IC_RAW_INTR_STAT_TX_ABRT_BITS) {
uint32_t abort_source = i2c->tx_abrt_source;
if (abort_source & I2C_IC_TX_ABRT_SOURCE_ABRT_7B_ADDR_NOACK_BITS) {
i2c->clr_tx_abrt;
shutdown("i2c Start Read NACK");
}
}
}
}

Expand Down

0 comments on commit 9426485

Please sign in to comment.