mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-23 16:25:31 +03:00
Fixed pin ownership checks for I2C.
This commit is contained in:
parent
6aeac3caa6
commit
37209b4826
2 changed files with 6 additions and 10 deletions
|
@ -287,16 +287,13 @@ void i2cInit(I2CDevice device)
|
||||||
i2cDevice_t *pDev = &i2cDevice[device];
|
i2cDevice_t *pDev = &i2cDevice[device];
|
||||||
|
|
||||||
const i2cHardware_t *hardware = pDev->hardware;
|
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;
|
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(scl, OWNER_I2C_SCL, RESOURCE_INDEX(device));
|
||||||
IOInit(sda, OWNER_I2C_SDA, RESOURCE_INDEX(device));
|
IOInit(sda, OWNER_I2C_SDA, RESOURCE_INDEX(device));
|
||||||
|
|
||||||
|
|
|
@ -435,8 +435,10 @@ void i2cInit(I2CDevice device)
|
||||||
|
|
||||||
i2cDevice_t *pDev = &i2cDevice[device];
|
i2cDevice_t *pDev = &i2cDevice[device];
|
||||||
const i2cHardware_t *hw = pDev->hardware;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,9 +449,6 @@ void i2cInit(I2CDevice device)
|
||||||
NVIC_InitTypeDef nvic;
|
NVIC_InitTypeDef nvic;
|
||||||
I2C_InitTypeDef i2cInit;
|
I2C_InitTypeDef i2cInit;
|
||||||
|
|
||||||
IO_t scl = pDev->scl;
|
|
||||||
IO_t sda = pDev->sda;
|
|
||||||
|
|
||||||
IOInit(scl, OWNER_I2C_SCL, RESOURCE_INDEX(device));
|
IOInit(scl, OWNER_I2C_SCL, RESOURCE_INDEX(device));
|
||||||
IOInit(sda, OWNER_I2C_SDA, RESOURCE_INDEX(device));
|
IOInit(sda, OWNER_I2C_SDA, RESOURCE_INDEX(device));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue