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