move most interrupt methods to InterruptExt extension trait. Fixes #35
This commit is contained in:
@ -17,7 +17,7 @@ mod waker;
|
||||
|
||||
use self::util::UninitCell;
|
||||
use crate::fmt::panic;
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::interrupt::{Interrupt, InterruptExt};
|
||||
use crate::time::Alarm;
|
||||
|
||||
// repr(C) is needed to guarantee that the raw::Task is located at offset 0
|
||||
|
@ -37,7 +37,24 @@ pub unsafe trait Interrupt {
|
||||
/// Implementation detail, do not use outside embassy crates.
|
||||
#[doc(hidden)]
|
||||
unsafe fn __handler(&self) -> &'static Handler;
|
||||
}
|
||||
|
||||
pub trait InterruptExt: Interrupt {
|
||||
fn set_handler(&self, func: unsafe fn(*mut ()));
|
||||
fn remove_handler(&self);
|
||||
fn set_handler_context(&self, ctx: *mut ());
|
||||
fn enable(&self);
|
||||
fn disable(&self);
|
||||
fn is_active(&self) -> bool;
|
||||
fn is_enabled(&self) -> bool;
|
||||
fn is_pending(&self) -> bool;
|
||||
fn pend(&self);
|
||||
fn unpend(&self);
|
||||
fn get_priority(&self) -> Self::Priority;
|
||||
fn set_priority(&self, prio: Self::Priority);
|
||||
}
|
||||
|
||||
impl<T: Interrupt + ?Sized> InterruptExt for T {
|
||||
fn set_handler(&self, func: unsafe fn(*mut ())) {
|
||||
let handler = unsafe { self.__handler() };
|
||||
handler.func.store(func as *mut (), Ordering::Release);
|
||||
|
@ -1,6 +1,3 @@
|
||||
use crate::executor;
|
||||
use crate::fmt::panic;
|
||||
use crate::interrupt::Interrupt;
|
||||
use core::cell::UnsafeCell;
|
||||
use core::future::Future;
|
||||
use core::mem;
|
||||
@ -9,6 +6,10 @@ use core::task::{Context, Poll, Waker};
|
||||
use cortex_m::peripheral::NVIC;
|
||||
use cortex_m::peripheral::{scb, SCB};
|
||||
|
||||
use crate::executor;
|
||||
use crate::fmt::panic;
|
||||
use crate::interrupt::{Interrupt, InterruptExt};
|
||||
|
||||
pub struct Signal<T> {
|
||||
state: UnsafeCell<State<T>>,
|
||||
}
|
||||
|
Reference in New Issue
Block a user