diff options
author | Daniel Friesel <derf@finalrewind.org> | 2021-02-26 19:25:07 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2021-02-26 19:25:07 +0100 |
commit | 4d0bb251520c811db2bdb05aea981257cfc298b8 (patch) | |
tree | 30ccd8cb83de763a36f8d9c486c9e8adbb3431d8 /src | |
parent | bdb1590839e5962741140ce2f4db722219f9d6f6 (diff) |
softi2c: report NAKs during TX
Diffstat (limited to 'src')
-rw-r--r-- | src/driver/soft_i2c.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/driver/soft_i2c.cc b/src/driver/soft_i2c.cc index 8822fde..975fa2e 100644 --- a/src/driver/soft_i2c.cc +++ b/src/driver/soft_i2c.cc @@ -203,15 +203,21 @@ signed char SoftI2C::xmit(unsigned char address, if (tx_len) { start(); - tx((address << 1) | 0); + if (tx((address << 1) | 0) == false) { + return -1; + } for (i = 0; i < tx_len; i++) { - tx(tx_buf[i]); + if (tx(tx_buf[i]) == false) { + return -1; + } } } if (rx_len) { start(); - tx((address << 1) | 1); + if (tx((address << 1) | 1) == false) { + return -1; + } for (i = 1; i <= rx_len; i++) { rx_buf[i-1] = rx((i < rx_len) * 1); |