freertos_rust/
isr.rs

1use crate::base::*;
2use crate::shim::*;
3
4/// Keep track of whether we need to yield the execution to a different
5/// task at the end of the interrupt.
6///
7/// Should be dropped as the last thing inside a interrupt.
8pub struct InterruptContext {
9    x_higher_priority_task_woken: FreeRtosBaseType,
10}
11
12impl InterruptContext {
13    /// Instantiate a new context.
14    pub fn new() -> InterruptContext {
15        InterruptContext {
16            x_higher_priority_task_woken: 0,
17        }
18    }
19
20    pub fn get_task_field_mut(&mut self) -> FreeRtosBaseTypeMutPtr {
21        &mut self.x_higher_priority_task_woken as *mut _
22    }
23    pub fn higher_priority_task_woken(&self) -> FreeRtosBaseType {
24        self.x_higher_priority_task_woken
25    }
26}
27
28impl Drop for InterruptContext {
29    fn drop(&mut self) {
30        unsafe {
31            freertos_rs_isr_yield(self.x_higher_priority_task_woken);
32        }
33    }
34}