From 953b580636362d4d24f9e322b5ffbabbd118b6e8 Mon Sep 17 00:00:00 2001 From: Eivind Alexander Bergem Date: Thu, 3 Oct 2024 04:05:10 +0200 Subject: [PATCH] Bugfix: `InterruptContext` used non-ISR function in `drop` (#78) `freertos_rs_isr_yield()` used `portYIELD()` instead of `portYIELD_FROM_ISR()`. --- freertos-rust/src/freertos/shim.c | 4 ++-- freertos-rust/src/isr.rs | 6 ++---- freertos-rust/src/shim.rs | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/freertos-rust/src/freertos/shim.c b/freertos-rust/src/freertos/shim.c index b5e544f..99a9240 100644 --- a/freertos-rust/src/freertos/shim.c +++ b/freertos-rust/src/freertos/shim.c @@ -277,8 +277,8 @@ UBaseType_t freertos_rs_queue_messages_waiting(QueueHandle_t queue) { return uxQueueMessagesWaiting( queue ); } -void freertos_rs_isr_yield() { - portYIELD(); +void freertos_rs_isr_yield(BaseType_t xHigherPriorityTaskWoken) { + portYIELD_FROM_ISR(xHigherPriorityTaskWoken); } TickType_t freertos_rs_max_wait() { diff --git a/freertos-rust/src/isr.rs b/freertos-rust/src/isr.rs index 4a35268..7dd21e9 100644 --- a/freertos-rust/src/isr.rs +++ b/freertos-rust/src/isr.rs @@ -27,10 +27,8 @@ impl InterruptContext { impl Drop for InterruptContext { fn drop(&mut self) { - if self.x_higher_priority_task_woken == 1 { - unsafe { - freertos_rs_isr_yield(); - } + unsafe { + freertos_rs_isr_yield(self.x_higher_priority_task_woken); } } } diff --git a/freertos-rust/src/shim.rs b/freertos-rust/src/shim.rs index 150fdff..d4cdecc 100644 --- a/freertos-rust/src/shim.rs +++ b/freertos-rust/src/shim.rs @@ -81,7 +81,7 @@ extern "C" { item: FreeRtosVoidPtr, xHigherPriorityTaskWoken: FreeRtosBaseTypeMutPtr, ) -> FreeRtosUBaseType; - pub fn freertos_rs_isr_yield(); + pub fn freertos_rs_isr_yield(xHigherPriorityTaskWoken: FreeRtosBaseType); pub fn freertos_rs_task_notify_take(clear_count: u8, wait: FreeRtosTickType) -> u32; pub fn freertos_rs_task_notify_wait(