diff options
author | Timofey Titovets <nefelim4ag@gmail.com> | 2024-09-23 01:28:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-22 19:28:07 -0400 |
commit | 9426485bb6c3855b117e05b1927e0b7c1937e0a9 (patch) | |
tree | 29dade7fa5e963640155db479ac5658c26e702b1 /src/rp2040 | |
parent | b4aca122a15c7223defb251dc4d8b48ce1ccb897 (diff) | |
download | kutter-9426485bb6c3855b117e05b1927e0b7c1937e0a9.tar.gz kutter-9426485bb6c3855b117e05b1927e0b7c1937e0a9.tar.xz kutter-9426485bb6c3855b117e05b1927e0b7c1937e0a9.zip |
rp2040: Check for i2c NACK/Start NACK (#6692)
Signed-off-by: Timofey Titovets <nefelim4ag@gmail.com>
Diffstat (limited to 'src/rp2040')
-rw-r--r-- | src/rp2040/i2c.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/rp2040/i2c.c b/src/rp2040/i2c.c index 8a32417b..84b627ce 100644 --- a/src/rp2040/i2c.c +++ b/src/rp2040/i2c.c @@ -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 @@ -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"); + } + } } } |