Replies: 2 comments
-
It seems to be that mutexes are generally not usable in interrupts as they can block. |
Beta Was this translation helpful? Give feedback.
0 replies
-
You could try using one of the other queues, such as the atomic one, or the 'locked' types. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For an embedded application (which also uses FreeRTOS) where we have multiple tasks that want to interface with devices on the same I2C bus (and thus using the same I2C peripheral), we were planning on putting a queue in front of the I2C HAL, so we can queue the actions from the different tasks and service them one by one.
Since the I2C peripherals will use interrupts to signal finished/failed I2C operations, and we have multiple tasks in the first place, we thought using
queue_mpmc_mutex
would be a good fit. Basically, the idea is that if nothing is busy and the queue is empty, we start the I2C operation immediately. When we get an interrupt that the operation is finished, we check the queue and start a new action.We were thinking about doing this directly from the interrupt, but upon checking the FreeRTOS mutex implementation, it seems that this uses
xSemaphoreTake
andxSemaphoreGive
. These functions are not allowed to be called from an ISR.So it seems like you can't actually use this queue to communicate with an interrupt, right? Or am I missing something?
Beta Was this translation helpful? Give feedback.
All reactions