From f9f40fb98fa499a557e3b0acf27326e3fc0858b3 Mon Sep 17 00:00:00 2001 From: Petr Ledvina Date: Thu, 29 Jan 2015 14:48:21 +0100 Subject: [PATCH] Handle possible problem with unintentional I2C interrupt handler triggering Error handler may be called repeatedly during I2C unstucking. Not sure if this change is necessary, but it is safe --- src/main/drivers/bus_i2c_stm32f10x.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/drivers/bus_i2c_stm32f10x.c b/src/main/drivers/bus_i2c_stm32f10x.c index 20e1396985..026dccf507 100644 --- a/src/main/drivers/bus_i2c_stm32f10x.c +++ b/src/main/drivers/bus_i2c_stm32f10x.c @@ -325,6 +325,9 @@ void i2cInit(I2CDevice index) I2Cx_index = index; RCC_APB1PeriphClockCmd(i2cHardwareMap[index].peripheral, ENABLE); + // diable I2C interrrupts first to avoid ER handler triggering + I2C_ITConfig(I2Cx, I2C_IT_EVT | I2C_IT_ERR, DISABLE); + // clock out stuff to make sure slaves arent stuck // This will also configure GPIO as AF_OD at the end i2cUnstick();