freertos_next/
isr.rs

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