aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp/src/usb.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-06-08 16:08:40 +0200
committerDario Nieuwenhuis <[email protected]>2023-06-08 18:00:48 +0200
commit921780e6bfb9bcb2cd087b8aa8b094d792c99fa2 (patch)
treebd21fba9800471b860ca44e05567588dcc1afef7 /embassy-rp/src/usb.rs
parent87ad66f2b4a5bfd36dfc8d8aad5492e9e3f915e6 (diff)
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`.
Diffstat (limited to 'embassy-rp/src/usb.rs')
-rw-r--r--embassy-rp/src/usb.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/embassy-rp/src/usb.rs b/embassy-rp/src/usb.rs
index cc88226df..9fb0dfb70 100644
--- a/embassy-rp/src/usb.rs
+++ b/embassy-rp/src/usb.rs
@@ -4,15 +4,14 @@ use core::slice;
4use core::sync::atomic::{compiler_fence, Ordering}; 4use core::sync::atomic::{compiler_fence, Ordering};
5use core::task::Poll; 5use core::task::Poll;
6 6
7use embassy_cortex_m::interrupt::{self, Binding};
8use embassy_sync::waitqueue::AtomicWaker; 7use embassy_sync::waitqueue::AtomicWaker;
9use embassy_usb_driver as driver; 8use embassy_usb_driver as driver;
10use embassy_usb_driver::{ 9use embassy_usb_driver::{
11 Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported, 10 Direction, EndpointAddress, EndpointAllocError, EndpointError, EndpointInfo, EndpointType, Event, Unsupported,
12}; 11};
13 12
14use crate::interrupt::Interrupt; 13use crate::interrupt::typelevel::{Binding, Interrupt};
15use crate::{pac, peripherals, Peripheral, RegExt}; 14use crate::{interrupt, pac, peripherals, Peripheral, RegExt};
16 15
17pub(crate) mod sealed { 16pub(crate) mod sealed {
18 pub trait Instance { 17 pub trait Instance {
@@ -22,7 +21,7 @@ pub(crate) mod sealed {
22} 21}
23 22
24pub trait Instance: sealed::Instance + 'static { 23pub trait Instance: sealed::Instance + 'static {
25 type Interrupt: Interrupt; 24 type Interrupt: interrupt::typelevel::Interrupt;
26} 25}
27 26
28impl crate::usb::sealed::Instance for peripherals::USB { 27impl crate::usb::sealed::Instance for peripherals::USB {
@@ -35,7 +34,7 @@ impl crate::usb::sealed::Instance for peripherals::USB {
35} 34}
36 35
37impl crate::usb::Instance for peripherals::USB { 36impl crate::usb::Instance for peripherals::USB {
38 type Interrupt = crate::interrupt::USBCTRL_IRQ; 37 type Interrupt = crate::interrupt::typelevel::USBCTRL_IRQ;
39} 38}
40 39
41const EP_COUNT: usize = 16; 40const EP_COUNT: usize = 16;
@@ -249,7 +248,7 @@ pub struct InterruptHandler<T: Instance> {
249 _uart: PhantomData<T>, 248 _uart: PhantomData<T>,
250} 249}
251 250
252impl<T: Instance> interrupt::Handler<T::Interrupt> for InterruptHandler<T> { 251impl<T: Instance> interrupt::typelevel::Handler<T::Interrupt> for InterruptHandler<T> {
253 unsafe fn on_interrupt() { 252 unsafe fn on_interrupt() {
254 let regs = T::regs(); 253 let regs = T::regs();
255 //let x = regs.istr().read().0; 254 //let x = regs.istr().read().0;