diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-11-12 10:59:38 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-11-12 10:59:38 +0100 |
commit | 96462e6b5be917a5146eaae62234432f1030898f (patch) | |
tree | ef95030da8e8768bacc8bf9d42427dfe247b0960 /src/arch/msp430fr5969lp | |
parent | 8d19dd775c642ebb5662d25f3a27d992ebdeb1ea (diff) |
wat
Diffstat (limited to 'src/arch/msp430fr5969lp')
-rw-r--r-- | src/arch/msp430fr5969lp/driver/i2c.cc | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/arch/msp430fr5969lp/driver/i2c.cc b/src/arch/msp430fr5969lp/driver/i2c.cc index f807d00..fe5b37b 100644 --- a/src/arch/msp430fr5969lp/driver/i2c.cc +++ b/src/arch/msp430fr5969lp/driver/i2c.cc @@ -8,16 +8,25 @@ volatile unsigned short old_ifg = 0; +#if (F_CPU / F_I2C) < 45 +inline void await_i2c_int(unsigned int ie_flags, unsigned int ifg_flags) { + while (!(UCB0IFG & ifg_flags)) ; + if (UCB0IFG & (UCNACKIFG | UCCLTOIFG)) { + UCB0IFG &= ~(UCNACKIFG | UCCLTOIFG); + } +} +#else inline void await_i2c_int(unsigned int ie_flags, unsigned int ifg_flags) { UCB0IFG = 0; old_ifg = 0; UCB0IE = ie_flags; - while (!(old_ifg & ifg_flags)) { + do { arch.idle(); - } + } while (!(old_ifg & ifg_flags)); UCB0IE = 0; } +#endif signed char I2C::setup() { |