[riot-notifications] [RIOT-OS/RIOT] cpu/esp*: fix of the error code for I2C address ACK errors (#12134)

benpicco notifications at github.com
Thu Sep 5 00:25:11 CEST 2019


benpicco approved this pull request.

Tested this on the esp32 too and it works nicely.
It only changes how errors are reported, so nothing should break.

An additional comment would be nice to understand the code faster.

> +        return -ETIMEDOUT; \
+    }
+
+#define _i2c_return_on_error_write(dev) \
+    if (_i2c_bus[dev].results & I2C_ARBITRATION_LOST_INT_ENA) { \
+        LOG_TAG_DEBUG("i2c", "arbitration lost dev=%u\n", dev); \
+        _i2c_reset_hw (dev); \
+        __asm__ volatile ("isync"); \
+        return -EAGAIN; \
+    } \
+    else if (_i2c_bus[dev].results & I2C_ACK_ERR_INT_ENA) { \
+        LOG_TAG_DEBUG("i2c", "ack error dev=%u\n", dev); \
+        uint32_t _tx_fifo_cnt = _i2c_hw[dev].regs->status_reg.tx_fifo_cnt; \
+        _i2c_reset_hw (dev); \
+        __asm__ volatile ("isync"); \
+        if (_tx_fifo_cnt >= len) { \

It would be good if you added a comment to this macro explaining the reasoning behind this.
Just a short note that this is for discriminating data and address NACKs, so you don't have to look up error codes to understand the macro :wink:

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/12134#pullrequestreview-283928042
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190904/6c3ed5ac/attachment.htm>


More information about the notifications mailing list