diff options
Diffstat (limited to 'embassy-rp/src/lib.rs')
| -rw-r--r-- | embassy-rp/src/lib.rs | 68 |
1 files changed, 65 insertions, 3 deletions
diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index 4e4542d70..d6f73219f 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs | |||
| @@ -16,7 +16,6 @@ pub mod flash; | |||
| 16 | mod float; | 16 | mod float; |
| 17 | pub mod gpio; | 17 | pub mod gpio; |
| 18 | pub mod i2c; | 18 | pub mod i2c; |
| 19 | pub mod interrupt; | ||
| 20 | pub mod multicore; | 19 | pub mod multicore; |
| 21 | pub mod pwm; | 20 | pub mod pwm; |
| 22 | mod reset; | 21 | mod reset; |
| @@ -37,14 +36,77 @@ pub mod pio_instr_util; | |||
| 37 | pub mod relocate; | 36 | pub mod relocate; |
| 38 | 37 | ||
| 39 | // Reexports | 38 | // Reexports |
| 40 | pub use embassy_cortex_m::executor; | ||
| 41 | pub use embassy_cortex_m::interrupt::_export::interrupt; | ||
| 42 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 39 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 43 | #[cfg(feature = "unstable-pac")] | 40 | #[cfg(feature = "unstable-pac")] |
| 44 | pub use rp_pac as pac; | 41 | pub use rp_pac as pac; |
| 45 | #[cfg(not(feature = "unstable-pac"))] | 42 | #[cfg(not(feature = "unstable-pac"))] |
| 46 | pub(crate) use rp_pac as pac; | 43 | pub(crate) use rp_pac as pac; |
| 47 | 44 | ||
| 45 | #[cfg(feature = "rt")] | ||
| 46 | pub use crate::pac::NVIC_PRIO_BITS; | ||
| 47 | |||
| 48 | embassy_hal_common::interrupt_mod!( | ||
| 49 | TIMER_IRQ_0, | ||
| 50 | TIMER_IRQ_1, | ||
| 51 | TIMER_IRQ_2, | ||
| 52 | TIMER_IRQ_3, | ||
| 53 | PWM_IRQ_WRAP, | ||
| 54 | USBCTRL_IRQ, | ||
| 55 | XIP_IRQ, | ||
| 56 | PIO0_IRQ_0, | ||
| 57 | PIO0_IRQ_1, | ||
| 58 | PIO1_IRQ_0, | ||
| 59 | PIO1_IRQ_1, | ||
| 60 | DMA_IRQ_0, | ||
| 61 | DMA_IRQ_1, | ||
| 62 | IO_IRQ_BANK0, | ||
| 63 | IO_IRQ_QSPI, | ||
| 64 | SIO_IRQ_PROC0, | ||
| 65 | SIO_IRQ_PROC1, | ||
| 66 | CLOCKS_IRQ, | ||
| 67 | SPI0_IRQ, | ||
| 68 | SPI1_IRQ, | ||
| 69 | UART0_IRQ, | ||
| 70 | UART1_IRQ, | ||
| 71 | ADC_IRQ_FIFO, | ||
| 72 | I2C0_IRQ, | ||
| 73 | I2C1_IRQ, | ||
| 74 | RTC_IRQ, | ||
| 75 | SWI_IRQ_0, | ||
| 76 | SWI_IRQ_1, | ||
| 77 | SWI_IRQ_2, | ||
| 78 | SWI_IRQ_3, | ||
| 79 | SWI_IRQ_4, | ||
| 80 | SWI_IRQ_5, | ||
| 81 | ); | ||
| 82 | |||
| 83 | /// Macro to bind interrupts to handlers. | ||
| 84 | /// | ||
| 85 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) | ||
| 86 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to | ||
| 87 | /// prove at compile-time that the right interrupts have been bound. | ||
| 88 | // developer note: this macro can't be in `embassy-hal-common` due to the use of `$crate`. | ||
| 89 | #[macro_export] | ||
| 90 | macro_rules! bind_interrupts { | ||
| 91 | ($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => { | ||
| 92 | $vis struct $name; | ||
| 93 | |||
| 94 | $( | ||
| 95 | #[allow(non_snake_case)] | ||
| 96 | #[no_mangle] | ||
| 97 | unsafe extern "C" fn $irq() { | ||
| 98 | $( | ||
| 99 | <$handler as $crate::interrupt::typelevel::Handler<$crate::interrupt::typelevel::$irq>>::on_interrupt(); | ||
| 100 | )* | ||
| 101 | } | ||
| 102 | |||
| 103 | $( | ||
| 104 | unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {} | ||
| 105 | )* | ||
| 106 | )* | ||
| 107 | }; | ||
| 108 | } | ||
| 109 | |||
| 48 | embassy_hal_common::peripherals! { | 110 | embassy_hal_common::peripherals! { |
| 49 | PIN_0, | 111 | PIN_0, |
| 50 | PIN_1, | 112 | PIN_1, |
