Feature request: Expose abort reason in I2C #1049

Open
opened 2022-10-04 13:28:27 -05:00 by DubbaThony · 0 comments
DubbaThony commented 2022-10-04 13:28:27 -05:00 (Migrated from github.com)

While calling i2c functions, for example i2c_write_blocking_until(), internally i2c_write_blocking_internal is called, where uint32_t abort_reason = 0; gets defined, but there is no real way to get this value raw as caller. After reading it, i2c->hw->clr_tx_abrt; is used, so I can't read the value on my own after calling the function.

Only error that's checkable is I2C_IC_TX_ABRT_SOURCE_ABRT_TXDATA_NOACK_BITS, as it will return different value than length of data array. All other errors are hidden behind PICO_ERROR_GENERIC, which as name suggests, is generic, not specific.

Knowing specific error would come in handy (for example pooling AT24Cx write status - checking for I2C_IC_TX_ABRT_SOURCE_ABRT_7B_ADDR_NOACK_BITS).

Personally I would just add last_error to i2c_inst_t or add flag to disable calling of i2c->hw->clr_tx_abrt; (But I don't know if that would be good idea - I have next to zero expirience with this kind of low level programming).

While calling i2c functions, for example `i2c_write_blocking_until()`, internally `i2c_write_blocking_internal` is called, where `uint32_t abort_reason = 0;` gets defined, but there is no real way to get this value raw as caller. After reading it, `i2c->hw->clr_tx_abrt;` is used, so I can't read the value on my own after calling the function. Only error that's checkable is `I2C_IC_TX_ABRT_SOURCE_ABRT_TXDATA_NOACK_BITS`, as it will return different value than length of data array. All other errors are hidden behind `PICO_ERROR_GENERIC`, which as name suggests, is generic, not specific. Knowing specific error would come in handy (for example pooling `AT24Cx` write status - checking for `I2C_IC_TX_ABRT_SOURCE_ABRT_7B_ADDR_NOACK_BITS`). Personally I would just add `last_error` to `i2c_inst_t` or add flag to disable calling of `i2c->hw->clr_tx_abrt;` (But I don't know if that would be good idea - I have next to zero expirience with this kind of low level programming).
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#1049
No description provided.