summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-10-25 15:01:23 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-10-25 15:01:23 +0200
commit61ff5bbb4cae80997562bcd4edd5c35a4f801b44 (patch)
tree49e9d1d0615949d2c6d9b9d804ea8bbe56168723 /src
parent3e884d678b5bd2871452bdfb81be3d9ea4fa4431 (diff)
softi2c: Work around MSP430 timing issues with softi2c_timer=1
Diffstat (limited to 'src')
-rw-r--r--src/driver/soft_i2c.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/driver/soft_i2c.cc b/src/driver/soft_i2c.cc
index e16c4a1..de634b1 100644
--- a/src/driver/soft_i2c.cc
+++ b/src/driver/soft_i2c.cc
@@ -176,6 +176,15 @@ signed char SoftI2C::xmit(unsigned char address,
volatile unsigned char timer_done = 0;
+/*
+ * Note: On MSP430, if F_CPU / F_I2C < 60 (approx.), await_timer() does not
+ * work. Probably related to missed interrupts / not enough cycles between
+ * start and idle? We work around this for now by simulating an immediate
+ * return in these cases.
+ */
+#if MULTIPASS_ARCH_msp430fr5969lp && ((F_CPU / F_I2C) < 60)
+inline void await_timer() {}
+#else
inline void await_timer()
{
timer_done = 0;
@@ -185,6 +194,7 @@ inline void await_timer()
}
timer.stop();
}
+#endif
signed char SoftI2C::setup()
{