diff options
Diffstat (limited to 'embassy-cortex-m/src')
| -rw-r--r-- | embassy-cortex-m/src/fmt.rs | 228 | ||||
| -rw-r--r-- | embassy-cortex-m/src/interrupt.rs | 758 | ||||
| -rw-r--r-- | embassy-cortex-m/src/lib.rs | 9 |
3 files changed, 0 insertions, 995 deletions
diff --git a/embassy-cortex-m/src/fmt.rs b/embassy-cortex-m/src/fmt.rs deleted file mode 100644 index f8bb0a035..000000000 --- a/embassy-cortex-m/src/fmt.rs +++ /dev/null | |||
| @@ -1,228 +0,0 @@ | |||
| 1 | #![macro_use] | ||
| 2 | #![allow(unused_macros)] | ||
| 3 | |||
| 4 | #[cfg(all(feature = "defmt", feature = "log"))] | ||
| 5 | compile_error!("You may not enable both `defmt` and `log` features."); | ||
| 6 | |||
| 7 | macro_rules! assert { | ||
| 8 | ($($x:tt)*) => { | ||
| 9 | { | ||
| 10 | #[cfg(not(feature = "defmt"))] | ||
| 11 | ::core::assert!($($x)*); | ||
| 12 | #[cfg(feature = "defmt")] | ||
| 13 | ::defmt::assert!($($x)*); | ||
| 14 | } | ||
| 15 | }; | ||
| 16 | } | ||
| 17 | |||
| 18 | macro_rules! assert_eq { | ||
| 19 | ($($x:tt)*) => { | ||
| 20 | { | ||
| 21 | #[cfg(not(feature = "defmt"))] | ||
| 22 | ::core::assert_eq!($($x)*); | ||
| 23 | #[cfg(feature = "defmt")] | ||
| 24 | ::defmt::assert_eq!($($x)*); | ||
| 25 | } | ||
| 26 | }; | ||
| 27 | } | ||
| 28 | |||
| 29 | macro_rules! assert_ne { | ||
| 30 | ($($x:tt)*) => { | ||
| 31 | { | ||
| 32 | #[cfg(not(feature = "defmt"))] | ||
| 33 | ::core::assert_ne!($($x)*); | ||
| 34 | #[cfg(feature = "defmt")] | ||
| 35 | ::defmt::assert_ne!($($x)*); | ||
| 36 | } | ||
| 37 | }; | ||
| 38 | } | ||
| 39 | |||
| 40 | macro_rules! debug_assert { | ||
| 41 | ($($x:tt)*) => { | ||
| 42 | { | ||
| 43 | #[cfg(not(feature = "defmt"))] | ||
| 44 | ::core::debug_assert!($($x)*); | ||
| 45 | #[cfg(feature = "defmt")] | ||
| 46 | ::defmt::debug_assert!($($x)*); | ||
| 47 | } | ||
| 48 | }; | ||
| 49 | } | ||
| 50 | |||
| 51 | macro_rules! debug_assert_eq { | ||
| 52 | ($($x:tt)*) => { | ||
| 53 | { | ||
| 54 | #[cfg(not(feature = "defmt"))] | ||
| 55 | ::core::debug_assert_eq!($($x)*); | ||
| 56 | #[cfg(feature = "defmt")] | ||
| 57 | ::defmt::debug_assert_eq!($($x)*); | ||
| 58 | } | ||
| 59 | }; | ||
| 60 | } | ||
| 61 | |||
| 62 | macro_rules! debug_assert_ne { | ||
| 63 | ($($x:tt)*) => { | ||
| 64 | { | ||
| 65 | #[cfg(not(feature = "defmt"))] | ||
| 66 | ::core::debug_assert_ne!($($x)*); | ||
| 67 | #[cfg(feature = "defmt")] | ||
| 68 | ::defmt::debug_assert_ne!($($x)*); | ||
| 69 | } | ||
| 70 | }; | ||
| 71 | } | ||
| 72 | |||
| 73 | macro_rules! todo { | ||
| 74 | ($($x:tt)*) => { | ||
| 75 | { | ||
| 76 | #[cfg(not(feature = "defmt"))] | ||
| 77 | ::core::todo!($($x)*); | ||
| 78 | #[cfg(feature = "defmt")] | ||
| 79 | ::defmt::todo!($($x)*); | ||
| 80 | } | ||
| 81 | }; | ||
| 82 | } | ||
| 83 | |||
| 84 | macro_rules! unreachable { | ||
| 85 | ($($x:tt)*) => { | ||
| 86 | { | ||
| 87 | #[cfg(not(feature = "defmt"))] | ||
| 88 | ::core::unreachable!($($x)*); | ||
| 89 | #[cfg(feature = "defmt")] | ||
| 90 | ::defmt::unreachable!($($x)*); | ||
| 91 | } | ||
| 92 | }; | ||
| 93 | } | ||
| 94 | |||
| 95 | macro_rules! panic { | ||
| 96 | ($($x:tt)*) => { | ||
| 97 | { | ||
| 98 | #[cfg(not(feature = "defmt"))] | ||
| 99 | ::core::panic!($($x)*); | ||
| 100 | #[cfg(feature = "defmt")] | ||
| 101 | ::defmt::panic!($($x)*); | ||
| 102 | } | ||
| 103 | }; | ||
| 104 | } | ||
| 105 | |||
| 106 | macro_rules! trace { | ||
| 107 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 108 | { | ||
| 109 | #[cfg(feature = "log")] | ||
| 110 | ::log::trace!($s $(, $x)*); | ||
| 111 | #[cfg(feature = "defmt")] | ||
| 112 | ::defmt::trace!($s $(, $x)*); | ||
| 113 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 114 | let _ = ($( & $x ),*); | ||
| 115 | } | ||
| 116 | }; | ||
| 117 | } | ||
| 118 | |||
| 119 | macro_rules! debug { | ||
| 120 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 121 | { | ||
| 122 | #[cfg(feature = "log")] | ||
| 123 | ::log::debug!($s $(, $x)*); | ||
| 124 | #[cfg(feature = "defmt")] | ||
| 125 | ::defmt::debug!($s $(, $x)*); | ||
| 126 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 127 | let _ = ($( & $x ),*); | ||
| 128 | } | ||
| 129 | }; | ||
| 130 | } | ||
| 131 | |||
| 132 | macro_rules! info { | ||
| 133 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 134 | { | ||
| 135 | #[cfg(feature = "log")] | ||
| 136 | ::log::info!($s $(, $x)*); | ||
| 137 | #[cfg(feature = "defmt")] | ||
| 138 | ::defmt::info!($s $(, $x)*); | ||
| 139 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 140 | let _ = ($( & $x ),*); | ||
| 141 | } | ||
| 142 | }; | ||
| 143 | } | ||
| 144 | |||
| 145 | macro_rules! warn { | ||
| 146 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 147 | { | ||
| 148 | #[cfg(feature = "log")] | ||
| 149 | ::log::warn!($s $(, $x)*); | ||
| 150 | #[cfg(feature = "defmt")] | ||
| 151 | ::defmt::warn!($s $(, $x)*); | ||
| 152 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 153 | let _ = ($( & $x ),*); | ||
| 154 | } | ||
| 155 | }; | ||
| 156 | } | ||
| 157 | |||
| 158 | macro_rules! error { | ||
| 159 | ($s:literal $(, $x:expr)* $(,)?) => { | ||
| 160 | { | ||
| 161 | #[cfg(feature = "log")] | ||
| 162 | ::log::error!($s $(, $x)*); | ||
| 163 | #[cfg(feature = "defmt")] | ||
| 164 | ::defmt::error!($s $(, $x)*); | ||
| 165 | #[cfg(not(any(feature = "log", feature="defmt")))] | ||
| 166 | let _ = ($( & $x ),*); | ||
| 167 | } | ||
| 168 | }; | ||
| 169 | } | ||
| 170 | |||
| 171 | #[cfg(feature = "defmt")] | ||
| 172 | macro_rules! unwrap { | ||
| 173 | ($($x:tt)*) => { | ||
| 174 | ::defmt::unwrap!($($x)*) | ||
| 175 | }; | ||
| 176 | } | ||
| 177 | |||
| 178 | #[cfg(not(feature = "defmt"))] | ||
| 179 | macro_rules! unwrap { | ||
| 180 | ($arg:expr) => { | ||
| 181 | match $crate::fmt::Try::into_result($arg) { | ||
| 182 | ::core::result::Result::Ok(t) => t, | ||
| 183 | ::core::result::Result::Err(e) => { | ||
| 184 | ::core::panic!("unwrap of `{}` failed: {:?}", ::core::stringify!($arg), e); | ||
| 185 | } | ||
| 186 | } | ||
| 187 | }; | ||
| 188 | ($arg:expr, $($msg:expr),+ $(,)? ) => { | ||
| 189 | match $crate::fmt::Try::into_result($arg) { | ||
| 190 | ::core::result::Result::Ok(t) => t, | ||
| 191 | ::core::result::Result::Err(e) => { | ||
| 192 | ::core::panic!("unwrap of `{}` failed: {}: {:?}", ::core::stringify!($arg), ::core::format_args!($($msg,)*), e); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | } | ||
| 196 | } | ||
| 197 | |||
| 198 | #[cfg(feature = "defmt-timestamp-uptime")] | ||
| 199 | defmt::timestamp! {"{=u64:us}", crate::time::Instant::now().as_micros() } | ||
| 200 | |||
| 201 | #[derive(Debug, Copy, Clone, Eq, PartialEq)] | ||
| 202 | pub struct NoneError; | ||
| 203 | |||
| 204 | pub trait Try { | ||
| 205 | type Ok; | ||
| 206 | type Error; | ||
| 207 | fn into_result(self) -> Result<Self::Ok, Self::Error>; | ||
| 208 | } | ||
| 209 | |||
| 210 | impl<T> Try for Option<T> { | ||
| 211 | type Ok = T; | ||
| 212 | type Error = NoneError; | ||
| 213 | |||
| 214 | #[inline] | ||
| 215 | fn into_result(self) -> Result<T, NoneError> { | ||
| 216 | self.ok_or(NoneError) | ||
| 217 | } | ||
| 218 | } | ||
| 219 | |||
| 220 | impl<T, E> Try for Result<T, E> { | ||
| 221 | type Ok = T; | ||
| 222 | type Error = E; | ||
| 223 | |||
| 224 | #[inline] | ||
| 225 | fn into_result(self) -> Self { | ||
| 226 | self | ||
| 227 | } | ||
| 228 | } | ||
diff --git a/embassy-cortex-m/src/interrupt.rs b/embassy-cortex-m/src/interrupt.rs deleted file mode 100644 index 0e790eaaf..000000000 --- a/embassy-cortex-m/src/interrupt.rs +++ /dev/null | |||
| @@ -1,758 +0,0 @@ | |||
| 1 | //! Interrupt handling for cortex-m devices. | ||
| 2 | use core::mem; | ||
| 3 | use core::sync::atomic::{compiler_fence, Ordering}; | ||
| 4 | |||
| 5 | use cortex_m::peripheral::NVIC; | ||
| 6 | |||
| 7 | /// Do not use. Used for macros and HALs only. Not covered by semver guarantees. | ||
| 8 | #[doc(hidden)] | ||
| 9 | pub mod _export { | ||
| 10 | pub use atomic_polyfill as atomic; | ||
| 11 | pub use embassy_macros::{cortex_m_interrupt as interrupt, cortex_m_interrupt_declare as declare}; | ||
| 12 | } | ||
| 13 | |||
| 14 | /// Interrupt handler trait. | ||
| 15 | /// | ||
| 16 | /// Drivers that need to handle interrupts implement this trait. | ||
| 17 | /// The user must ensure `on_interrupt()` is called every time the interrupt fires. | ||
| 18 | /// Drivers must use use [`Binding`] to assert at compile time that the user has done so. | ||
| 19 | pub trait Handler<I: Interrupt> { | ||
| 20 | /// Interrupt handler function. | ||
| 21 | /// | ||
| 22 | /// Must be called every time the `I` interrupt fires, synchronously from | ||
| 23 | /// the interrupt handler context. | ||
| 24 | /// | ||
| 25 | /// # Safety | ||
| 26 | /// | ||
| 27 | /// This function must ONLY be called from the interrupt handler for `I`. | ||
| 28 | unsafe fn on_interrupt(); | ||
| 29 | } | ||
| 30 | |||
| 31 | /// Compile-time assertion that an interrupt has been bound to a handler. | ||
| 32 | /// | ||
| 33 | /// For the vast majority of cases, you should use the `bind_interrupts!` | ||
| 34 | /// macro instead of writing `unsafe impl`s of this trait. | ||
| 35 | /// | ||
| 36 | /// # Safety | ||
| 37 | /// | ||
| 38 | /// By implementing this trait, you are asserting that you have arranged for `H::on_interrupt()` | ||
| 39 | /// to be called every time the `I` interrupt fires. | ||
| 40 | /// | ||
| 41 | /// This allows drivers to check bindings at compile-time. | ||
| 42 | pub unsafe trait Binding<I: Interrupt, H: Handler<I>> {} | ||
| 43 | |||
| 44 | #[derive(Clone, Copy)] | ||
| 45 | pub(crate) struct NrWrap(pub(crate) u16); | ||
| 46 | unsafe impl cortex_m::interrupt::InterruptNumber for NrWrap { | ||
| 47 | fn number(self) -> u16 { | ||
| 48 | self.0 | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | /// Represents an interrupt type that can be configured by embassy to handle | ||
| 53 | /// interrupts. | ||
| 54 | pub unsafe trait Interrupt { | ||
| 55 | /// Return the NVIC interrupt number for this interrupt. | ||
| 56 | fn number() -> u16; | ||
| 57 | |||
| 58 | /// Enable the interrupt. | ||
| 59 | #[inline] | ||
| 60 | unsafe fn enable() { | ||
| 61 | compiler_fence(Ordering::SeqCst); | ||
| 62 | NVIC::unmask(NrWrap(Self::number())) | ||
| 63 | } | ||
| 64 | |||
| 65 | /// Disable the interrupt. | ||
| 66 | #[inline] | ||
| 67 | fn disable() { | ||
| 68 | NVIC::mask(NrWrap(Self::number())); | ||
| 69 | compiler_fence(Ordering::SeqCst); | ||
| 70 | } | ||
| 71 | |||
| 72 | /// Check if interrupt is being handled. | ||
| 73 | #[inline] | ||
| 74 | #[cfg(not(armv6m))] | ||
| 75 | fn is_active() -> bool { | ||
| 76 | NVIC::is_active(NrWrap(Self::number())) | ||
| 77 | } | ||
| 78 | |||
| 79 | /// Check if interrupt is enabled. | ||
| 80 | #[inline] | ||
| 81 | fn is_enabled() -> bool { | ||
| 82 | NVIC::is_enabled(NrWrap(Self::number())) | ||
| 83 | } | ||
| 84 | |||
| 85 | /// Check if interrupt is pending. | ||
| 86 | #[inline] | ||
| 87 | fn is_pending() -> bool { | ||
| 88 | NVIC::is_pending(NrWrap(Self::number())) | ||
| 89 | } | ||
| 90 | |||
| 91 | /// Set interrupt pending. | ||
| 92 | #[inline] | ||
| 93 | fn pend() { | ||
| 94 | NVIC::pend(NrWrap(Self::number())) | ||
| 95 | } | ||
| 96 | |||
| 97 | /// Unset interrupt pending. | ||
| 98 | #[inline] | ||
| 99 | fn unpend() { | ||
| 100 | NVIC::unpend(NrWrap(Self::number())) | ||
| 101 | } | ||
| 102 | |||
| 103 | /// Get the priority of the interrupt. | ||
| 104 | #[inline] | ||
| 105 | fn get_priority() -> Priority { | ||
| 106 | Priority::from(NVIC::get_priority(NrWrap(Self::number()))) | ||
| 107 | } | ||
| 108 | |||
| 109 | /// Set the interrupt priority. | ||
| 110 | #[inline] | ||
| 111 | fn set_priority(prio: Priority) { | ||
| 112 | critical_section::with(|_| unsafe { | ||
| 113 | let mut nvic: cortex_m::peripheral::NVIC = mem::transmute(()); | ||
| 114 | nvic.set_priority(NrWrap(Self::number()), prio.into()) | ||
| 115 | }) | ||
| 116 | } | ||
| 117 | } | ||
| 118 | |||
| 119 | impl From<u8> for Priority { | ||
| 120 | fn from(priority: u8) -> Self { | ||
| 121 | unsafe { mem::transmute(priority & PRIO_MASK) } | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 125 | impl From<Priority> for u8 { | ||
| 126 | fn from(p: Priority) -> Self { | ||
| 127 | p as u8 | ||
| 128 | } | ||
| 129 | } | ||
| 130 | |||
| 131 | #[cfg(feature = "prio-bits-0")] | ||
| 132 | const PRIO_MASK: u8 = 0x00; | ||
| 133 | #[cfg(feature = "prio-bits-1")] | ||
| 134 | const PRIO_MASK: u8 = 0x80; | ||
| 135 | #[cfg(feature = "prio-bits-2")] | ||
| 136 | const PRIO_MASK: u8 = 0xc0; | ||
| 137 | #[cfg(feature = "prio-bits-3")] | ||
| 138 | const PRIO_MASK: u8 = 0xe0; | ||
| 139 | #[cfg(feature = "prio-bits-4")] | ||
| 140 | const PRIO_MASK: u8 = 0xf0; | ||
| 141 | #[cfg(feature = "prio-bits-5")] | ||
| 142 | const PRIO_MASK: u8 = 0xf8; | ||
| 143 | #[cfg(feature = "prio-bits-6")] | ||
| 144 | const PRIO_MASK: u8 = 0xfc; | ||
| 145 | #[cfg(feature = "prio-bits-7")] | ||
| 146 | const PRIO_MASK: u8 = 0xfe; | ||
| 147 | #[cfg(feature = "prio-bits-8")] | ||
| 148 | const PRIO_MASK: u8 = 0xff; | ||
| 149 | |||
| 150 | /// The interrupt priority level. | ||
| 151 | /// | ||
| 152 | /// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. | ||
| 153 | #[cfg(feature = "prio-bits-0")] | ||
| 154 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 155 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 156 | #[repr(u8)] | ||
| 157 | #[allow(missing_docs)] | ||
| 158 | pub enum Priority { | ||
| 159 | P0 = 0x0, | ||
| 160 | } | ||
| 161 | |||
| 162 | /// The interrupt priority level. | ||
| 163 | /// | ||
| 164 | /// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. | ||
| 165 | #[cfg(feature = "prio-bits-1")] | ||
| 166 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 167 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 168 | #[repr(u8)] | ||
| 169 | #[allow(missing_docs)] | ||
| 170 | pub enum Priority { | ||
| 171 | P0 = 0x0, | ||
| 172 | P1 = 0x80, | ||
| 173 | } | ||
| 174 | |||
| 175 | /// The interrupt priority level. | ||
| 176 | /// | ||
| 177 | /// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. | ||
| 178 | #[cfg(feature = "prio-bits-2")] | ||
| 179 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 180 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 181 | #[repr(u8)] | ||
| 182 | #[allow(missing_docs)] | ||
| 183 | pub enum Priority { | ||
| 184 | P0 = 0x0, | ||
| 185 | P1 = 0x40, | ||
| 186 | P2 = 0x80, | ||
| 187 | P3 = 0xc0, | ||
| 188 | } | ||
| 189 | |||
| 190 | /// The interrupt priority level. | ||
| 191 | /// | ||
| 192 | /// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. | ||
| 193 | #[cfg(feature = "prio-bits-3")] | ||
| 194 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 195 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 196 | #[repr(u8)] | ||
| 197 | #[allow(missing_docs)] | ||
| 198 | pub enum Priority { | ||
| 199 | P0 = 0x0, | ||
| 200 | P1 = 0x20, | ||
| 201 | P2 = 0x40, | ||
| 202 | P3 = 0x60, | ||
| 203 | P4 = 0x80, | ||
| 204 | P5 = 0xa0, | ||
| 205 | P6 = 0xc0, | ||
| 206 | P7 = 0xe0, | ||
| 207 | } | ||
| 208 | |||
| 209 | /// The interrupt priority level. | ||
| 210 | /// | ||
| 211 | /// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. | ||
| 212 | #[cfg(feature = "prio-bits-4")] | ||
| 213 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 214 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 215 | #[repr(u8)] | ||
| 216 | #[allow(missing_docs)] | ||
| 217 | pub enum Priority { | ||
| 218 | P0 = 0x0, | ||
| 219 | P1 = 0x10, | ||
| 220 | P2 = 0x20, | ||
| 221 | P3 = 0x30, | ||
| 222 | P4 = 0x40, | ||
| 223 | P5 = 0x50, | ||
| 224 | P6 = 0x60, | ||
| 225 | P7 = 0x70, | ||
| 226 | P8 = 0x80, | ||
| 227 | P9 = 0x90, | ||
| 228 | P10 = 0xa0, | ||
| 229 | P11 = 0xb0, | ||
| 230 | P12 = 0xc0, | ||
| 231 | P13 = 0xd0, | ||
| 232 | P14 = 0xe0, | ||
| 233 | P15 = 0xf0, | ||
| 234 | } | ||
| 235 | |||
| 236 | /// The interrupt priority level. | ||
| 237 | /// | ||
| 238 | /// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. | ||
| 239 | #[cfg(feature = "prio-bits-5")] | ||
| 240 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 241 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 242 | #[repr(u8)] | ||
| 243 | #[allow(missing_docs)] | ||
| 244 | pub enum Priority { | ||
| 245 | P0 = 0x0, | ||
| 246 | P1 = 0x8, | ||
| 247 | P2 = 0x10, | ||
| 248 | P3 = 0x18, | ||
| 249 | P4 = 0x20, | ||
| 250 | P5 = 0x28, | ||
| 251 | P6 = 0x30, | ||
| 252 | P7 = 0x38, | ||
| 253 | P8 = 0x40, | ||
| 254 | P9 = 0x48, | ||
| 255 | P10 = 0x50, | ||
| 256 | P11 = 0x58, | ||
| 257 | P12 = 0x60, | ||
| 258 | P13 = 0x68, | ||
| 259 | P14 = 0x70, | ||
| 260 | P15 = 0x78, | ||
| 261 | P16 = 0x80, | ||
| 262 | P17 = 0x88, | ||
| 263 | P18 = 0x90, | ||
| 264 | P19 = 0x98, | ||
| 265 | P20 = 0xa0, | ||
| 266 | P21 = 0xa8, | ||
| 267 | P22 = 0xb0, | ||
| 268 | P23 = 0xb8, | ||
| 269 | P24 = 0xc0, | ||
| 270 | P25 = 0xc8, | ||
| 271 | P26 = 0xd0, | ||
| 272 | P27 = 0xd8, | ||
| 273 | P28 = 0xe0, | ||
| 274 | P29 = 0xe8, | ||
| 275 | P30 = 0xf0, | ||
| 276 | P31 = 0xf8, | ||
| 277 | } | ||
| 278 | |||
| 279 | /// The interrupt priority level. | ||
| 280 | /// | ||
| 281 | /// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. | ||
| 282 | #[cfg(feature = "prio-bits-6")] | ||
| 283 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 284 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 285 | #[repr(u8)] | ||
| 286 | #[allow(missing_docs)] | ||
| 287 | pub enum Priority { | ||
| 288 | P0 = 0x0, | ||
| 289 | P1 = 0x4, | ||
| 290 | P2 = 0x8, | ||
| 291 | P3 = 0xc, | ||
| 292 | P4 = 0x10, | ||
| 293 | P5 = 0x14, | ||
| 294 | P6 = 0x18, | ||
| 295 | P7 = 0x1c, | ||
| 296 | P8 = 0x20, | ||
| 297 | P9 = 0x24, | ||
| 298 | P10 = 0x28, | ||
| 299 | P11 = 0x2c, | ||
| 300 | P12 = 0x30, | ||
| 301 | P13 = 0x34, | ||
| 302 | P14 = 0x38, | ||
| 303 | P15 = 0x3c, | ||
| 304 | P16 = 0x40, | ||
| 305 | P17 = 0x44, | ||
| 306 | P18 = 0x48, | ||
| 307 | P19 = 0x4c, | ||
| 308 | P20 = 0x50, | ||
| 309 | P21 = 0x54, | ||
| 310 | P22 = 0x58, | ||
| 311 | P23 = 0x5c, | ||
| 312 | P24 = 0x60, | ||
| 313 | P25 = 0x64, | ||
| 314 | P26 = 0x68, | ||
| 315 | P27 = 0x6c, | ||
| 316 | P28 = 0x70, | ||
| 317 | P29 = 0x74, | ||
| 318 | P30 = 0x78, | ||
| 319 | P31 = 0x7c, | ||
| 320 | P32 = 0x80, | ||
| 321 | P33 = 0x84, | ||
| 322 | P34 = 0x88, | ||
| 323 | P35 = 0x8c, | ||
| 324 | P36 = 0x90, | ||
| 325 | P37 = 0x94, | ||
| 326 | P38 = 0x98, | ||
| 327 | P39 = 0x9c, | ||
| 328 | P40 = 0xa0, | ||
| 329 | P41 = 0xa4, | ||
| 330 | P42 = 0xa8, | ||
| 331 | P43 = 0xac, | ||
| 332 | P44 = 0xb0, | ||
| 333 | P45 = 0xb4, | ||
| 334 | P46 = 0xb8, | ||
| 335 | P47 = 0xbc, | ||
| 336 | P48 = 0xc0, | ||
| 337 | P49 = 0xc4, | ||
| 338 | P50 = 0xc8, | ||
| 339 | P51 = 0xcc, | ||
| 340 | P52 = 0xd0, | ||
| 341 | P53 = 0xd4, | ||
| 342 | P54 = 0xd8, | ||
| 343 | P55 = 0xdc, | ||
| 344 | P56 = 0xe0, | ||
| 345 | P57 = 0xe4, | ||
| 346 | P58 = 0xe8, | ||
| 347 | P59 = 0xec, | ||
| 348 | P60 = 0xf0, | ||
| 349 | P61 = 0xf4, | ||
| 350 | P62 = 0xf8, | ||
| 351 | P63 = 0xfc, | ||
| 352 | } | ||
| 353 | |||
| 354 | /// The interrupt priority level. | ||
| 355 | /// | ||
| 356 | /// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. | ||
| 357 | #[cfg(feature = "prio-bits-7")] | ||
| 358 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 359 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 360 | #[repr(u8)] | ||
| 361 | #[allow(missing_docs)] | ||
| 362 | pub enum Priority { | ||
| 363 | P0 = 0x0, | ||
| 364 | P1 = 0x2, | ||
| 365 | P2 = 0x4, | ||
| 366 | P3 = 0x6, | ||
| 367 | P4 = 0x8, | ||
| 368 | P5 = 0xa, | ||
| 369 | P6 = 0xc, | ||
| 370 | P7 = 0xe, | ||
| 371 | P8 = 0x10, | ||
| 372 | P9 = 0x12, | ||
| 373 | P10 = 0x14, | ||
| 374 | P11 = 0x16, | ||
| 375 | P12 = 0x18, | ||
| 376 | P13 = 0x1a, | ||
| 377 | P14 = 0x1c, | ||
| 378 | P15 = 0x1e, | ||
| 379 | P16 = 0x20, | ||
| 380 | P17 = 0x22, | ||
| 381 | P18 = 0x24, | ||
| 382 | P19 = 0x26, | ||
| 383 | P20 = 0x28, | ||
| 384 | P21 = 0x2a, | ||
| 385 | P22 = 0x2c, | ||
| 386 | P23 = 0x2e, | ||
| 387 | P24 = 0x30, | ||
| 388 | P25 = 0x32, | ||
| 389 | P26 = 0x34, | ||
| 390 | P27 = 0x36, | ||
| 391 | P28 = 0x38, | ||
| 392 | P29 = 0x3a, | ||
| 393 | P30 = 0x3c, | ||
| 394 | P31 = 0x3e, | ||
| 395 | P32 = 0x40, | ||
| 396 | P33 = 0x42, | ||
| 397 | P34 = 0x44, | ||
| 398 | P35 = 0x46, | ||
| 399 | P36 = 0x48, | ||
| 400 | P37 = 0x4a, | ||
| 401 | P38 = 0x4c, | ||
| 402 | P39 = 0x4e, | ||
| 403 | P40 = 0x50, | ||
| 404 | P41 = 0x52, | ||
| 405 | P42 = 0x54, | ||
| 406 | P43 = 0x56, | ||
| 407 | P44 = 0x58, | ||
| 408 | P45 = 0x5a, | ||
| 409 | P46 = 0x5c, | ||
| 410 | P47 = 0x5e, | ||
| 411 | P48 = 0x60, | ||
| 412 | P49 = 0x62, | ||
| 413 | P50 = 0x64, | ||
| 414 | P51 = 0x66, | ||
| 415 | P52 = 0x68, | ||
| 416 | P53 = 0x6a, | ||
| 417 | P54 = 0x6c, | ||
| 418 | P55 = 0x6e, | ||
| 419 | P56 = 0x70, | ||
| 420 | P57 = 0x72, | ||
| 421 | P58 = 0x74, | ||
| 422 | P59 = 0x76, | ||
| 423 | P60 = 0x78, | ||
| 424 | P61 = 0x7a, | ||
| 425 | P62 = 0x7c, | ||
| 426 | P63 = 0x7e, | ||
| 427 | P64 = 0x80, | ||
| 428 | P65 = 0x82, | ||
| 429 | P66 = 0x84, | ||
| 430 | P67 = 0x86, | ||
| 431 | P68 = 0x88, | ||
| 432 | P69 = 0x8a, | ||
| 433 | P70 = 0x8c, | ||
| 434 | P71 = 0x8e, | ||
| 435 | P72 = 0x90, | ||
| 436 | P73 = 0x92, | ||
| 437 | P74 = 0x94, | ||
| 438 | P75 = 0x96, | ||
| 439 | P76 = 0x98, | ||
| 440 | P77 = 0x9a, | ||
| 441 | P78 = 0x9c, | ||
| 442 | P79 = 0x9e, | ||
| 443 | P80 = 0xa0, | ||
| 444 | P81 = 0xa2, | ||
| 445 | P82 = 0xa4, | ||
| 446 | P83 = 0xa6, | ||
| 447 | P84 = 0xa8, | ||
| 448 | P85 = 0xaa, | ||
| 449 | P86 = 0xac, | ||
| 450 | P87 = 0xae, | ||
| 451 | P88 = 0xb0, | ||
| 452 | P89 = 0xb2, | ||
| 453 | P90 = 0xb4, | ||
| 454 | P91 = 0xb6, | ||
| 455 | P92 = 0xb8, | ||
| 456 | P93 = 0xba, | ||
| 457 | P94 = 0xbc, | ||
| 458 | P95 = 0xbe, | ||
| 459 | P96 = 0xc0, | ||
| 460 | P97 = 0xc2, | ||
| 461 | P98 = 0xc4, | ||
| 462 | P99 = 0xc6, | ||
| 463 | P100 = 0xc8, | ||
| 464 | P101 = 0xca, | ||
| 465 | P102 = 0xcc, | ||
| 466 | P103 = 0xce, | ||
| 467 | P104 = 0xd0, | ||
| 468 | P105 = 0xd2, | ||
| 469 | P106 = 0xd4, | ||
| 470 | P107 = 0xd6, | ||
| 471 | P108 = 0xd8, | ||
| 472 | P109 = 0xda, | ||
| 473 | P110 = 0xdc, | ||
| 474 | P111 = 0xde, | ||
| 475 | P112 = 0xe0, | ||
| 476 | P113 = 0xe2, | ||
| 477 | P114 = 0xe4, | ||
| 478 | P115 = 0xe6, | ||
| 479 | P116 = 0xe8, | ||
| 480 | P117 = 0xea, | ||
| 481 | P118 = 0xec, | ||
| 482 | P119 = 0xee, | ||
| 483 | P120 = 0xf0, | ||
| 484 | P121 = 0xf2, | ||
| 485 | P122 = 0xf4, | ||
| 486 | P123 = 0xf6, | ||
| 487 | P124 = 0xf8, | ||
| 488 | P125 = 0xfa, | ||
| 489 | P126 = 0xfc, | ||
| 490 | P127 = 0xfe, | ||
| 491 | } | ||
| 492 | |||
| 493 | /// The interrupt priority level. | ||
| 494 | /// | ||
| 495 | /// NOTE: The contents of this enum differ according to the set `prio-bits-*` Cargo feature. | ||
| 496 | #[cfg(feature = "prio-bits-8")] | ||
| 497 | #[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)] | ||
| 498 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 499 | #[repr(u8)] | ||
| 500 | #[allow(missing_docs)] | ||
| 501 | pub enum Priority { | ||
| 502 | P0 = 0x0, | ||
| 503 | P1 = 0x1, | ||
| 504 | P2 = 0x2, | ||
| 505 | P3 = 0x3, | ||
| 506 | P4 = 0x4, | ||
| 507 | P5 = 0x5, | ||
| 508 | P6 = 0x6, | ||
| 509 | P7 = 0x7, | ||
| 510 | P8 = 0x8, | ||
| 511 | P9 = 0x9, | ||
| 512 | P10 = 0xa, | ||
| 513 | P11 = 0xb, | ||
| 514 | P12 = 0xc, | ||
| 515 | P13 = 0xd, | ||
| 516 | P14 = 0xe, | ||
| 517 | P15 = 0xf, | ||
| 518 | P16 = 0x10, | ||
| 519 | P17 = 0x11, | ||
| 520 | P18 = 0x12, | ||
| 521 | P19 = 0x13, | ||
| 522 | P20 = 0x14, | ||
| 523 | P21 = 0x15, | ||
| 524 | P22 = 0x16, | ||
| 525 | P23 = 0x17, | ||
| 526 | P24 = 0x18, | ||
| 527 | P25 = 0x19, | ||
| 528 | P26 = 0x1a, | ||
| 529 | P27 = 0x1b, | ||
| 530 | P28 = 0x1c, | ||
| 531 | P29 = 0x1d, | ||
| 532 | P30 = 0x1e, | ||
| 533 | P31 = 0x1f, | ||
| 534 | P32 = 0x20, | ||
| 535 | P33 = 0x21, | ||
| 536 | P34 = 0x22, | ||
| 537 | P35 = 0x23, | ||
| 538 | P36 = 0x24, | ||
| 539 | P37 = 0x25, | ||
| 540 | P38 = 0x26, | ||
| 541 | P39 = 0x27, | ||
| 542 | P40 = 0x28, | ||
| 543 | P41 = 0x29, | ||
| 544 | P42 = 0x2a, | ||
| 545 | P43 = 0x2b, | ||
| 546 | P44 = 0x2c, | ||
| 547 | P45 = 0x2d, | ||
| 548 | P46 = 0x2e, | ||
| 549 | P47 = 0x2f, | ||
| 550 | P48 = 0x30, | ||
| 551 | P49 = 0x31, | ||
| 552 | P50 = 0x32, | ||
| 553 | P51 = 0x33, | ||
| 554 | P52 = 0x34, | ||
| 555 | P53 = 0x35, | ||
| 556 | P54 = 0x36, | ||
| 557 | P55 = 0x37, | ||
| 558 | P56 = 0x38, | ||
| 559 | P57 = 0x39, | ||
| 560 | P58 = 0x3a, | ||
| 561 | P59 = 0x3b, | ||
| 562 | P60 = 0x3c, | ||
| 563 | P61 = 0x3d, | ||
| 564 | P62 = 0x3e, | ||
| 565 | P63 = 0x3f, | ||
| 566 | P64 = 0x40, | ||
| 567 | P65 = 0x41, | ||
| 568 | P66 = 0x42, | ||
| 569 | P67 = 0x43, | ||
| 570 | P68 = 0x44, | ||
| 571 | P69 = 0x45, | ||
| 572 | P70 = 0x46, | ||
| 573 | P71 = 0x47, | ||
| 574 | P72 = 0x48, | ||
| 575 | P73 = 0x49, | ||
| 576 | P74 = 0x4a, | ||
| 577 | P75 = 0x4b, | ||
| 578 | P76 = 0x4c, | ||
| 579 | P77 = 0x4d, | ||
| 580 | P78 = 0x4e, | ||
| 581 | P79 = 0x4f, | ||
| 582 | P80 = 0x50, | ||
| 583 | P81 = 0x51, | ||
| 584 | P82 = 0x52, | ||
| 585 | P83 = 0x53, | ||
| 586 | P84 = 0x54, | ||
| 587 | P85 = 0x55, | ||
| 588 | P86 = 0x56, | ||
| 589 | P87 = 0x57, | ||
| 590 | P88 = 0x58, | ||
| 591 | P89 = 0x59, | ||
| 592 | P90 = 0x5a, | ||
| 593 | P91 = 0x5b, | ||
| 594 | P92 = 0x5c, | ||
| 595 | P93 = 0x5d, | ||
| 596 | P94 = 0x5e, | ||
| 597 | P95 = 0x5f, | ||
| 598 | P96 = 0x60, | ||
| 599 | P97 = 0x61, | ||
| 600 | P98 = 0x62, | ||
| 601 | P99 = 0x63, | ||
| 602 | P100 = 0x64, | ||
| 603 | P101 = 0x65, | ||
| 604 | P102 = 0x66, | ||
| 605 | P103 = 0x67, | ||
| 606 | P104 = 0x68, | ||
| 607 | P105 = 0x69, | ||
| 608 | P106 = 0x6a, | ||
| 609 | P107 = 0x6b, | ||
| 610 | P108 = 0x6c, | ||
| 611 | P109 = 0x6d, | ||
| 612 | P110 = 0x6e, | ||
| 613 | P111 = 0x6f, | ||
| 614 | P112 = 0x70, | ||
| 615 | P113 = 0x71, | ||
| 616 | P114 = 0x72, | ||
| 617 | P115 = 0x73, | ||
| 618 | P116 = 0x74, | ||
| 619 | P117 = 0x75, | ||
| 620 | P118 = 0x76, | ||
| 621 | P119 = 0x77, | ||
| 622 | P120 = 0x78, | ||
| 623 | P121 = 0x79, | ||
| 624 | P122 = 0x7a, | ||
| 625 | P123 = 0x7b, | ||
| 626 | P124 = 0x7c, | ||
| 627 | P125 = 0x7d, | ||
| 628 | P126 = 0x7e, | ||
| 629 | P127 = 0x7f, | ||
| 630 | P128 = 0x80, | ||
| 631 | P129 = 0x81, | ||
| 632 | P130 = 0x82, | ||
| 633 | P131 = 0x83, | ||
| 634 | P132 = 0x84, | ||
| 635 | P133 = 0x85, | ||
| 636 | P134 = 0x86, | ||
| 637 | P135 = 0x87, | ||
| 638 | P136 = 0x88, | ||
| 639 | P137 = 0x89, | ||
| 640 | P138 = 0x8a, | ||
| 641 | P139 = 0x8b, | ||
| 642 | P140 = 0x8c, | ||
| 643 | P141 = 0x8d, | ||
| 644 | P142 = 0x8e, | ||
| 645 | P143 = 0x8f, | ||
| 646 | P144 = 0x90, | ||
| 647 | P145 = 0x91, | ||
| 648 | P146 = 0x92, | ||
| 649 | P147 = 0x93, | ||
| 650 | P148 = 0x94, | ||
| 651 | P149 = 0x95, | ||
| 652 | P150 = 0x96, | ||
| 653 | P151 = 0x97, | ||
| 654 | P152 = 0x98, | ||
| 655 | P153 = 0x99, | ||
| 656 | P154 = 0x9a, | ||
| 657 | P155 = 0x9b, | ||
| 658 | P156 = 0x9c, | ||
| 659 | P157 = 0x9d, | ||
| 660 | P158 = 0x9e, | ||
| 661 | P159 = 0x9f, | ||
| 662 | P160 = 0xa0, | ||
| 663 | P161 = 0xa1, | ||
| 664 | P162 = 0xa2, | ||
| 665 | P163 = 0xa3, | ||
| 666 | P164 = 0xa4, | ||
| 667 | P165 = 0xa5, | ||
| 668 | P166 = 0xa6, | ||
| 669 | P167 = 0xa7, | ||
| 670 | P168 = 0xa8, | ||
| 671 | P169 = 0xa9, | ||
| 672 | P170 = 0xaa, | ||
| 673 | P171 = 0xab, | ||
| 674 | P172 = 0xac, | ||
| 675 | P173 = 0xad, | ||
| 676 | P174 = 0xae, | ||
| 677 | P175 = 0xaf, | ||
| 678 | P176 = 0xb0, | ||
| 679 | P177 = 0xb1, | ||
| 680 | P178 = 0xb2, | ||
| 681 | P179 = 0xb3, | ||
| 682 | P180 = 0xb4, | ||
| 683 | P181 = 0xb5, | ||
| 684 | P182 = 0xb6, | ||
| 685 | P183 = 0xb7, | ||
| 686 | P184 = 0xb8, | ||
| 687 | P185 = 0xb9, | ||
| 688 | P186 = 0xba, | ||
| 689 | P187 = 0xbb, | ||
| 690 | P188 = 0xbc, | ||
| 691 | P189 = 0xbd, | ||
| 692 | P190 = 0xbe, | ||
| 693 | P191 = 0xbf, | ||
| 694 | P192 = 0xc0, | ||
| 695 | P193 = 0xc1, | ||
| 696 | P194 = 0xc2, | ||
| 697 | P195 = 0xc3, | ||
| 698 | P196 = 0xc4, | ||
| 699 | P197 = 0xc5, | ||
| 700 | P198 = 0xc6, | ||
| 701 | P199 = 0xc7, | ||
| 702 | P200 = 0xc8, | ||
| 703 | P201 = 0xc9, | ||
| 704 | P202 = 0xca, | ||
| 705 | P203 = 0xcb, | ||
| 706 | P204 = 0xcc, | ||
| 707 | P205 = 0xcd, | ||
| 708 | P206 = 0xce, | ||
| 709 | P207 = 0xcf, | ||
| 710 | P208 = 0xd0, | ||
| 711 | P209 = 0xd1, | ||
| 712 | P210 = 0xd2, | ||
| 713 | P211 = 0xd3, | ||
| 714 | P212 = 0xd4, | ||
| 715 | P213 = 0xd5, | ||
| 716 | P214 = 0xd6, | ||
| 717 | P215 = 0xd7, | ||
| 718 | P216 = 0xd8, | ||
| 719 | P217 = 0xd9, | ||
| 720 | P218 = 0xda, | ||
| 721 | P219 = 0xdb, | ||
| 722 | P220 = 0xdc, | ||
| 723 | P221 = 0xdd, | ||
| 724 | P222 = 0xde, | ||
| 725 | P223 = 0xdf, | ||
| 726 | P224 = 0xe0, | ||
| 727 | P225 = 0xe1, | ||
| 728 | P226 = 0xe2, | ||
| 729 | P227 = 0xe3, | ||
| 730 | P228 = 0xe4, | ||
| 731 | P229 = 0xe5, | ||
| 732 | P230 = 0xe6, | ||
| 733 | P231 = 0xe7, | ||
| 734 | P232 = 0xe8, | ||
| 735 | P233 = 0xe9, | ||
| 736 | P234 = 0xea, | ||
| 737 | P235 = 0xeb, | ||
| 738 | P236 = 0xec, | ||
| 739 | P237 = 0xed, | ||
| 740 | P238 = 0xee, | ||
| 741 | P239 = 0xef, | ||
| 742 | P240 = 0xf0, | ||
| 743 | P241 = 0xf1, | ||
| 744 | P242 = 0xf2, | ||
| 745 | P243 = 0xf3, | ||
| 746 | P244 = 0xf4, | ||
| 747 | P245 = 0xf5, | ||
| 748 | P246 = 0xf6, | ||
| 749 | P247 = 0xf7, | ||
| 750 | P248 = 0xf8, | ||
| 751 | P249 = 0xf9, | ||
| 752 | P250 = 0xfa, | ||
| 753 | P251 = 0xfb, | ||
| 754 | P252 = 0xfc, | ||
| 755 | P253 = 0xfd, | ||
| 756 | P254 = 0xfe, | ||
| 757 | P255 = 0xff, | ||
| 758 | } | ||
diff --git a/embassy-cortex-m/src/lib.rs b/embassy-cortex-m/src/lib.rs deleted file mode 100644 index 7bc16d3ba..000000000 --- a/embassy-cortex-m/src/lib.rs +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | //! Embassy executor and interrupt handling specific to cortex-m devices. | ||
| 2 | #![no_std] | ||
| 3 | #![warn(missing_docs)] | ||
| 4 | |||
| 5 | // This mod MUST go first, so that the others see its macros. | ||
| 6 | pub(crate) mod fmt; | ||
| 7 | |||
| 8 | pub use embassy_executor as executor; | ||
| 9 | pub mod interrupt; | ||
