diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2017-04-04 15:36:23 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2017-04-04 15:36:23 -0500 |
| commit | 00ef129f8703deca91e18fc663f7ec323dd4b6cc (patch) | |
| tree | 28a8c79578bf581ba60a5ddd6dc8217581a40052 /src | |
| parent | 4c1b6c8293ed44a6f4aab1b6861a234d6cccef18 (diff) | |
add a `queue` function
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -11,7 +11,7 @@ extern crate cortex_m; use cortex_m::ctxt::Context; -use cortex_m::interrupt::CriticalSection; +use cortex_m::interrupt::{CriticalSection, Nr}; use cortex_m::peripheral::{Peripheral, NVIC, SCB}; use cortex_m::register::{basepri, basepri_max}; @@ -362,6 +362,16 @@ pub fn logical(priority: u8) -> u8 { ((1 << PRIORITY_BITS) - priority) << (8 - PRIORITY_BITS) } +/// Puts `interrupt` in the "to execute" queue +/// +/// This function has no effect if the interrupt was already queued +pub fn queue<I>(interrupt: I) where I: Nr { + unsafe { + // NOTE(safe) atomic write + (*NVIC.get()).set_pending(interrupt) + } +} + /// Fake ceiling, indicates that the resource is shared by cooperative tasks pub struct C0 { _0: (), |
