From 082d8e85a90858ec02b6e530edb2c67f9325f5ca Mon Sep 17 00:00:00 2001 From: Michael Andersen Date: Wed, 7 Sep 2016 18:21:38 -0700 Subject: [PATCH] samd21: i2c: clear timeout_counter If not cleared, long writes timeout incorrectly --- cpu/samd21/periph/i2c.c | 1 + 1 file changed, 1 insertion(+) diff --git a/cpu/samd21/periph/i2c.c b/cpu/samd21/periph/i2c.c index 2f7ab14577..ab81aa6c2e 100644 --- a/cpu/samd21/periph/i2c.c +++ b/cpu/samd21/periph/i2c.c @@ -447,6 +447,7 @@ static inline int _write(SercomI2cm *dev, char *data, int length) dev->DATA.reg = data[buffer_counter++]; DEBUG("Wait for response.\n"); + timeout_counter = 0; while (!(dev->INTFLAG.reg & SERCOM_I2CM_INTFLAG_MB) && !(dev->INTFLAG.reg & SERCOM_I2CM_INTFLAG_SB)) { if (++timeout_counter >= SAMD21_I2C_TIMEOUT) {