summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-08-07 17:30:59 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-08-07 17:30:59 +0200
commit55786418160429b7e974336758dd785d9feeb5fa (patch)
treea50c2d27138da93e4a3fda503a88a6cca7eed1bb /src
parent34d55c304253fde0fc113f384f619171e3cf3167 (diff)
SoftI2C: Support Clock Stretching
Diffstat (limited to 'src')
-rw-r--r--src/driver/soft_i2c.cc4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/driver/soft_i2c.cc b/src/driver/soft_i2c.cc
index e7b8548..cebd8be 100644
--- a/src/driver/soft_i2c.cc
+++ b/src/driver/soft_i2c.cc
@@ -54,6 +54,7 @@ bool SoftI2C::tx(unsigned char byte)
byte <<= 1;
//
SCL_HIGH;
+ while (!gpio.read(scl)) ;
//
if (i == 8) {
if (!gpio.read(sda)) {
@@ -73,6 +74,7 @@ unsigned char SoftI2C::rx(bool send_ack)
for (unsigned char i = 0; i <= 8; i++) {
//
SCL_HIGH;
+ while (!gpio.read(scl)) ;
//
if ((i < 8) && gpio.read(sda)) {
byte |= 1 << (7 - i);
@@ -137,7 +139,7 @@ signed char SoftI2C::xmit(unsigned char address,
#ifdef MULTIPASS_ARCH_esp8266
SoftI2C i2c(GPIO::d7, GPIO::d8);
#elif MULTIPASS_ARCH_arduino_nano
-SoftI2C i2c(GPIO::pc5, GPIO::pc4);
+SoftI2C i2c(GPIO::pc4, GPIO::pc5);
#elif MULTIPASS_ARCH_msp430fr5969lp
SoftI2C i2c(GPIO::p1_6, GPIO::p1_7);
#endif