8000 Fix CoreMutex FreeRTOS ISR logic (#1510) · esphome/arduino-pico@5204dab · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 5204dab

Browse files
Fix CoreMutex FreeRTOS ISR logic (earlephilhower#1510)
1 parent 273fb84 commit 5204dab

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

cores/rp2040/CoreMutex.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ CoreMutex::CoreMutex(mutex_t *mutex, uint8_t option) {
3030
_option = option;
3131
if (__isFreeRTOS) {
3232
auto m = __get_freertos_mutex_for_ptr(mutex);
33-
if (__freertos_check_if_in_isr() && !__freertos_mutex_take_from_isr(m)) {
34-
return;
33+
if (__freertos_check_if_in_isr()) {
34+
if (!__freertos_mutex_take_from_isr(m)) {
35+
return;
36+
}
37+
// At this point we have the mutex in ISR
38+
} else {
39+
// Grab the mutex normally, possibly waking other tasks to get it
40+
__freertos_mutex_take(m);
3541
}
36-
__freertos_mutex_take(m);
3742
} else {
3843
uint32_t owner;
3944
if (!mutex_try_enter(_mutex, &owner)) {

0 commit comments

Comments
 (0)
0