diff options
author | Ben V. Brown <[email protected]> | 2020-08-02 16:17:41 +1000 |
---|---|---|
committer | Ben V. Brown <[email protected]> | 2020-08-02 16:17:41 +1000 |
commit | d47c28b7601eff10daf2feee5a6f514d68ee8a71 (patch) | |
tree | b790f43ea8edcf50c7d5e9c978bab1d9c5bdda96 | |
parent | e2c5e51fe19b2e4416e758590fbf71732dad6758 (diff) | |
download | IronOS-d47c28b7601eff10daf2feee5a6f514d68ee8a71.tar.gz IronOS-d47c28b7601eff10daf2feee5a6f514d68ee8a71.zip |
Use mutex for priority inversion prevention
-rw-r--r-- | workspace/TS100/Core/Drivers/I2CBB.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/workspace/TS100/Core/Drivers/I2CBB.cpp b/workspace/TS100/Core/Drivers/I2CBB.cpp index b878db58..c21a3a97 100644 --- a/workspace/TS100/Core/Drivers/I2CBB.cpp +++ b/workspace/TS100/Core/Drivers/I2CBB.cpp @@ -17,14 +17,19 @@ void I2CBB::init() { GPIO_InitTypeDef GPIO_InitStruct;
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
- GPIO_InitStruct.Pin = SDA2_Pin | SCL2_Pin;
+ GPIO_InitStruct.Pin = SDA2_Pin ;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
GPIO_InitStruct.Pull = GPIO_PULLUP;
HAL_GPIO_Init(SDA2_GPIO_Port, &GPIO_InitStruct);
+ GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;
+ GPIO_InitStruct.Pin = SCL2_Pin;
+ GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
+ GPIO_InitStruct.Pull = GPIO_PULLUP;
+ HAL_GPIO_Init(SCL2_GPIO_Port, &GPIO_InitStruct);
SOFT_SDA_HIGH();
SOFT_SCL_HIGH();
- I2CSemaphore = xSemaphoreCreateBinaryStatic(&xSemaphoreBuffer);
- I2CSemaphore2 = xSemaphoreCreateBinaryStatic(&xSemaphoreBuffer2);
+ I2CSemaphore = xSemaphoreCreateMutexStatic (&xSemaphoreBuffer);
+ I2CSemaphore2 = xSemaphoreCreateMutexStatic (&xSemaphoreBuffer2);
unlock();
unlock2();
@@ -274,9 +279,6 @@ bool I2CBB::lock() { asm("bkpt");
}
bool a = xSemaphoreTake(I2CSemaphore, (TickType_t) 100) == pdTRUE;
- if (!a) {
- asm("bkpt");
- }
return a;
}
@@ -302,9 +304,7 @@ bool I2CBB::lock2() { asm("bkpt");
}
bool a = xSemaphoreTake(I2CSemaphore2, (TickType_t) 500) == pdTRUE;
- if (!a) {
- asm("bkpt");
- }
+
return a;
}
#endif
|