From 61ff5bbb4cae80997562bcd4edd5c35a4f801b44 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 25 Oct 2018 15:01:23 +0200 Subject: softi2c: Work around MSP430 timing issues with softi2c_timer=1 --- src/driver/soft_i2c.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') 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() { -- cgit v1.2.3