diff options
| author | goueslati <[email protected]> | 2023-06-12 14:27:53 +0100 |
|---|---|---|
| committer | goueslati <[email protected]> | 2023-06-12 14:27:53 +0100 |
| commit | 2d89cfb18f00aefbfa108728dfea3398e80ea3e4 (patch) | |
| tree | 6485dacac7e61c4378ac522e709edb0a86bd7523 /embassy-stm32/src/lib.rs | |
| parent | 2dd5ce83ec0421564e85b667f5dabd592f313e5c (diff) | |
| parent | ab86b060500ceda1c80e39f35af69cb08a7b63a2 (diff) | |
fix merge conflict
Diffstat (limited to 'embassy-stm32/src/lib.rs')
| -rw-r--r-- | embassy-stm32/src/lib.rs | 61 |
1 files changed, 28 insertions, 33 deletions
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 8c13774a0..6fde61c06 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -72,52 +72,47 @@ pub(crate) mod _generated { | |||
| 72 | include!(concat!(env!("OUT_DIR"), "/_generated.rs")); | 72 | include!(concat!(env!("OUT_DIR"), "/_generated.rs")); |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | pub mod interrupt { | 75 | pub use crate::_generated::interrupt; |
| 76 | //! Interrupt definitions and macros to bind them. | 76 | |
| 77 | pub use cortex_m::interrupt::{CriticalSection, Mutex}; | 77 | /// Macro to bind interrupts to handlers. |
| 78 | pub use embassy_cortex_m::interrupt::{Binding, Handler, Interrupt, Priority}; | 78 | /// |
| 79 | 79 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) | |
| 80 | pub use crate::_generated::interrupt::*; | 80 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to |
| 81 | 81 | /// prove at compile-time that the right interrupts have been bound. | |
| 82 | /// Macro to bind interrupts to handlers. | 82 | // developer note: this macro can't be in `embassy-hal-common` due to the use of `$crate`. |
| 83 | /// | 83 | #[macro_export] |
| 84 | /// This defines the right interrupt handlers, and creates a unit struct (like `struct Irqs;`) | 84 | macro_rules! bind_interrupts { |
| 85 | /// and implements the right [`Binding`]s for it. You can pass this struct to drivers to | 85 | ($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => { |
| 86 | /// prove at compile-time that the right interrupts have been bound. | 86 | $vis struct $name; |
| 87 | // developer note: this macro can't be in `embassy-cortex-m` due to the use of `$crate`. | 87 | |
| 88 | #[macro_export] | 88 | $( |
| 89 | macro_rules! bind_interrupts { | 89 | #[allow(non_snake_case)] |
| 90 | ($vis:vis struct $name:ident { $($irq:ident => $($handler:ty),*;)* }) => { | 90 | #[no_mangle] |
| 91 | $vis struct $name; | 91 | unsafe extern "C" fn $irq() { |
| 92 | |||
| 93 | $( | ||
| 94 | #[allow(non_snake_case)] | ||
| 95 | #[no_mangle] | ||
| 96 | unsafe extern "C" fn $irq() { | ||
| 97 | $( | ||
| 98 | <$handler as $crate::interrupt::Handler<$crate::interrupt::$irq>>::on_interrupt(); | ||
| 99 | )* | ||
| 100 | } | ||
| 101 | |||
| 102 | $( | 92 | $( |
| 103 | unsafe impl $crate::interrupt::Binding<$crate::interrupt::$irq, $handler> for $name {} | 93 | <$handler as $crate::interrupt::typelevel::Handler<$crate::interrupt::typelevel::$irq>>::on_interrupt(); |
| 104 | )* | 94 | )* |
| 95 | } | ||
| 96 | |||
| 97 | $( | ||
| 98 | unsafe impl $crate::interrupt::typelevel::Binding<$crate::interrupt::typelevel::$irq, $handler> for $name {} | ||
| 105 | )* | 99 | )* |
| 106 | }; | 100 | )* |
| 107 | } | 101 | }; |
| 108 | } | 102 | } |
| 109 | 103 | ||
| 110 | // Reexports | 104 | // Reexports |
| 111 | pub use _generated::{peripherals, Peripherals}; | 105 | pub use _generated::{peripherals, Peripherals}; |
| 112 | pub use embassy_cortex_m::executor; | ||
| 113 | use embassy_cortex_m::interrupt::Priority; | ||
| 114 | pub use embassy_cortex_m::interrupt::_export::interrupt; | ||
| 115 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | 106 | pub use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; |
| 116 | #[cfg(feature = "unstable-pac")] | 107 | #[cfg(feature = "unstable-pac")] |
| 117 | pub use stm32_metapac as pac; | 108 | pub use stm32_metapac as pac; |
| 118 | #[cfg(not(feature = "unstable-pac"))] | 109 | #[cfg(not(feature = "unstable-pac"))] |
| 119 | pub(crate) use stm32_metapac as pac; | 110 | pub(crate) use stm32_metapac as pac; |
| 120 | 111 | ||
| 112 | use crate::interrupt::Priority; | ||
| 113 | #[cfg(feature = "rt")] | ||
| 114 | pub use crate::pac::NVIC_PRIO_BITS; | ||
| 115 | |||
| 121 | #[non_exhaustive] | 116 | #[non_exhaustive] |
| 122 | pub struct Config { | 117 | pub struct Config { |
| 123 | pub rcc: rcc::Config, | 118 | pub rcc: rcc::Config, |
