diff --git a/src/main/drivers/bus_i2c_hal_init.c b/src/main/drivers/bus_i2c_hal_init.c index 5b2137b270..71871fdb20 100644 --- a/src/main/drivers/bus_i2c_hal_init.c +++ b/src/main/drivers/bus_i2c_hal_init.c @@ -287,16 +287,13 @@ void i2cInit(I2CDevice device) i2cDevice_t *pDev = &i2cDevice[device]; const i2cHardware_t *hardware = pDev->hardware; + const IO_t scl = pDev->scl; + const IO_t sda = pDev->sda; - if (!hardware) { + if (!hardware || IOGetOwner(scl) || IOGetOwner(sda)) { return; } - IO_t scl = pDev->scl; - IO_t sda = pDev->sda; - - RCC_ClockCmd(hardware->rcc, ENABLE); - IOInit(scl, OWNER_I2C_SCL, RESOURCE_INDEX(device)); IOInit(sda, OWNER_I2C_SDA, RESOURCE_INDEX(device)); diff --git a/src/main/drivers/bus_i2c_stm32f10x.c b/src/main/drivers/bus_i2c_stm32f10x.c index 16b83f9519..673617474f 100644 --- a/src/main/drivers/bus_i2c_stm32f10x.c +++ b/src/main/drivers/bus_i2c_stm32f10x.c @@ -435,8 +435,10 @@ void i2cInit(I2CDevice device) i2cDevice_t *pDev = &i2cDevice[device]; const i2cHardware_t *hw = pDev->hardware; + const IO_t scl = pDev->scl; + const IO_t sda = pDev->sda; - if (!hw) { + if (!hw || IOGetOwner(scl) || IOGetOwner(sda)) { return; } @@ -447,9 +449,6 @@ void i2cInit(I2CDevice device) NVIC_InitTypeDef nvic; I2C_InitTypeDef i2cInit; - IO_t scl = pDev->scl; - IO_t sda = pDev->sda; - IOInit(scl, OWNER_I2C_SCL, RESOURCE_INDEX(device)); IOInit(sda, OWNER_I2C_SDA, RESOURCE_INDEX(device));