Skip to content

Commit

Permalink
i2c_hal: mutex should not be locked/unlocked from an ISR
Browse files Browse the repository at this point in the history
  • Loading branch information
avtolstoy committed Dec 14, 2017
1 parent d5ecce3 commit 12d7eea
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions hal/src/stm32f2xx/i2c_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1087,18 +1087,22 @@ void I2C3_EV_irq(void)

int32_t HAL_I2C_Acquire(HAL_I2C_Interface i2c, void* reserved)
{
os_mutex_recursive_t mutex = i2cMap[i2c]->mutex;
if (mutex) {
return os_mutex_recursive_lock(mutex);
if (!HAL_IsISR()) {
os_mutex_recursive_t mutex = i2cMap[i2c]->mutex;
if (mutex) {
return os_mutex_recursive_lock(mutex);
}
}
return -1;
}

int32_t HAL_I2C_Release(HAL_I2C_Interface i2c, void* reserved)
{
os_mutex_recursive_t mutex = i2cMap[i2c]->mutex;
if (mutex) {
return os_mutex_recursive_unlock(mutex);
if (!HAL_IsISR()) {
os_mutex_recursive_t mutex = i2cMap[i2c]->mutex;
if (mutex) {
return os_mutex_recursive_unlock(mutex);
}
}
return -1;
}
Expand Down

0 comments on commit 12d7eea

Please sign in to comment.