Make interrupt module more standard.
- Move typelevel interrupts to a special-purpose mod: `embassy_xx::interrupt::typelevel`. - Reexport the PAC interrupt enum in `embassy_xx::interrupt`. This has a few advantages: - The `embassy_xx::interrupt` module is now more "standard". - It works with `cortex-m` functions for manipulating interrupts, for example. - It works with RTIC. - the interrupt enum allows holding value that can be "any interrupt at runtime", this can't be done with typelevel irqs. - When "const-generics on enums" is stable, we can remove the typelevel interrupts without disruptive changes to `embassy_xx::interrupt`.
This commit is contained in:
@ -3,14 +3,14 @@ use core::marker::PhantomData;
|
||||
use core::sync::atomic::{compiler_fence, Ordering};
|
||||
use core::task::Poll;
|
||||
|
||||
use embassy_cortex_m::interrupt::{Binding, Interrupt};
|
||||
use embassy_sync::waitqueue::AtomicWaker;
|
||||
use embedded_hal_02::adc::{Channel, OneShot};
|
||||
|
||||
use crate::gpio::Pin;
|
||||
use crate::interrupt::{self, ADC_IRQ_FIFO};
|
||||
use crate::interrupt::typelevel::Binding;
|
||||
use crate::interrupt::InterruptExt;
|
||||
use crate::peripherals::ADC;
|
||||
use crate::{pac, peripherals, Peripheral};
|
||||
use crate::{interrupt, pac, peripherals, Peripheral};
|
||||
static WAKER: AtomicWaker = AtomicWaker::new();
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
@ -47,7 +47,7 @@ impl<'d> Adc<'d> {
|
||||
|
||||
pub fn new(
|
||||
_inner: impl Peripheral<P = ADC> + 'd,
|
||||
_irq: impl Binding<ADC_IRQ_FIFO, InterruptHandler>,
|
||||
_irq: impl Binding<interrupt::typelevel::ADC_IRQ_FIFO, InterruptHandler>,
|
||||
_config: Config,
|
||||
) -> Self {
|
||||
unsafe {
|
||||
@ -62,10 +62,8 @@ impl<'d> Adc<'d> {
|
||||
}
|
||||
|
||||
// Setup IRQ
|
||||
unsafe {
|
||||
ADC_IRQ_FIFO::unpend();
|
||||
ADC_IRQ_FIFO::enable();
|
||||
};
|
||||
interrupt::ADC_IRQ_FIFO.unpend();
|
||||
unsafe { interrupt::ADC_IRQ_FIFO.enable() };
|
||||
|
||||
Self { phantom: PhantomData }
|
||||
}
|
||||
@ -164,7 +162,7 @@ pub struct InterruptHandler {
|
||||
_empty: (),
|
||||
}
|
||||
|
||||
impl interrupt::Handler<ADC_IRQ_FIFO> for InterruptHandler {
|
||||
impl interrupt::typelevel::Handler<interrupt::typelevel::ADC_IRQ_FIFO> for InterruptHandler {
|
||||
unsafe fn on_interrupt() {
|
||||
let r = Adc::regs();
|
||||
r.inte().write(|w| w.set_fifo(false));
|
||||
|
Reference in New Issue
Block a user