From 4d0bb251520c811db2bdb05aea981257cfc298b8 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 26 Feb 2021 19:25:07 +0100 Subject: softi2c: report NAKs during TX --- src/driver/soft_i2c.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') 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); -- cgit v1.2.3