Cleanup interrupt package naming. Fixes #40
The `interrupt` package previously tried to be drop-in compatible with the `interrupt` package from PACs. THis meant that there was both a PAC-style enum value `UARTE0` and an embassy-style owned `UARTE0Interrupt` type. This made things VERY confusing. This drops compatibility with the PAC, improving the names for embassy interrupts.
This commit is contained in:
@ -17,7 +17,7 @@ mod waker;
|
||||
|
||||
use self::util::UninitCell;
|
||||
use crate::fmt::panic;
|
||||
use crate::interrupt::OwnedInterrupt;
|
||||
use crate::interrupt::Interrupt;
|
||||
use crate::time::Alarm;
|
||||
|
||||
// repr(C) is needed to guarantee that the raw::Task is located at offset 0
|
||||
@ -215,13 +215,13 @@ fn pend_by_number(n: u16) {
|
||||
cortex_m::peripheral::NVIC::pend(N(n))
|
||||
}
|
||||
|
||||
pub struct IrqExecutor<I: OwnedInterrupt> {
|
||||
pub struct IrqExecutor<I: Interrupt> {
|
||||
irq: I,
|
||||
inner: raw::Executor,
|
||||
not_send: PhantomData<*mut ()>,
|
||||
}
|
||||
|
||||
impl<I: OwnedInterrupt> IrqExecutor<I> {
|
||||
impl<I: Interrupt> IrqExecutor<I> {
|
||||
pub fn new(irq: I) -> Self {
|
||||
let ctx = irq.number() as *mut ();
|
||||
Self {
|
||||
|
@ -29,7 +29,7 @@ unsafe impl cortex_m::interrupt::InterruptNumber for NrWrap {
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe trait OwnedInterrupt {
|
||||
pub unsafe trait Interrupt {
|
||||
type Priority: From<u8> + Into<u8> + Copy;
|
||||
fn number(&self) -> u16;
|
||||
unsafe fn steal() -> Self;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::executor;
|
||||
use crate::fmt::panic;
|
||||
use crate::interrupt::OwnedInterrupt;
|
||||
use crate::interrupt::Interrupt;
|
||||
use core::cell::UnsafeCell;
|
||||
use core::future::Future;
|
||||
use core::mem;
|
||||
@ -79,18 +79,18 @@ unsafe impl cortex_m::interrupt::Nr for NrWrap {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct InterruptFuture<'a, I: OwnedInterrupt> {
|
||||
pub struct InterruptFuture<'a, I: Interrupt> {
|
||||
interrupt: &'a mut I,
|
||||
}
|
||||
|
||||
impl<'a, I: OwnedInterrupt> Drop for InterruptFuture<'a, I> {
|
||||
impl<'a, I: Interrupt> Drop for InterruptFuture<'a, I> {
|
||||
fn drop(&mut self) {
|
||||
self.interrupt.disable();
|
||||
self.interrupt.remove_handler();
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, I: OwnedInterrupt> InterruptFuture<'a, I> {
|
||||
impl<'a, I: Interrupt> InterruptFuture<'a, I> {
|
||||
pub fn new(interrupt: &'a mut I) -> Self {
|
||||
interrupt.disable();
|
||||
interrupt.set_handler(Self::interrupt_handler, ptr::null_mut());
|
||||
@ -114,9 +114,9 @@ impl<'a, I: OwnedInterrupt> InterruptFuture<'a, I> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, I: OwnedInterrupt> Unpin for InterruptFuture<'a, I> {}
|
||||
impl<'a, I: Interrupt> Unpin for InterruptFuture<'a, I> {}
|
||||
|
||||
impl<'a, I: OwnedInterrupt> Future for InterruptFuture<'a, I> {
|
||||
impl<'a, I: Interrupt> Future for InterruptFuture<'a, I> {
|
||||
type Output = ();
|
||||
|
||||
fn poll(self: core::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()> {
|
||||
|
Reference in New Issue
Block a user