From fb4d898f2e7ce04f78dad9ed34a0171410a52a2a Mon Sep 17 00:00:00 2001 From: Steven Cooreman Date: Tue, 9 Jul 2019 23:37:11 +0100 Subject: [PATCH] Allow re-initializing an I2C peripheral Allows the FPGA based test to pass, but requires #11004 before it will --- targets/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/targets/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c b/targets/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c index ab85acdb75..5b0717b374 100644 --- a/targets/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c +++ b/targets/TARGET_Silicon_Labs/TARGET_EFM32/i2c_api.c @@ -119,6 +119,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) /* Initializing the I2C */ /* Using default settings */ + i2c_reset(obj); I2C_Init_TypeDef i2cInit = I2C_INIT_DEFAULT; I2C_Init(obj->i2c.i2c, &i2cInit); @@ -315,6 +316,8 @@ int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop) void i2c_reset(i2c_t *obj) { + i2c_enable_interrupt(obj, 0, false); + i2c_enable(obj, false); /* EMLib function */ I2C_Reset(obj->i2c.i2c); }