aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-05-11 01:27:46 +0200
committerDario Nieuwenhuis <[email protected]>2021-05-11 01:34:24 +0200
commite0809ab0fb64ff71be23e2d041d4fbae67dca234 (patch)
tree3ac40e1f52a0ed3981d2983074fafe70563548e6 /embassy-stm32/src
parente6a8c8bfcce1e882d4cd6b37c83eb6662762810b (diff)
Switch to use PrioritX enums.
Diffstat (limited to 'embassy-stm32/src')
-rw-r--r--embassy-stm32/src/interrupt.rs57
1 files changed, 1 insertions, 56 deletions
diff --git a/embassy-stm32/src/interrupt.rs b/embassy-stm32/src/interrupt.rs
index 1d48dc584..76dea28f6 100644
--- a/embassy-stm32/src/interrupt.rs
+++ b/embassy-stm32/src/interrupt.rs
@@ -3,64 +3,9 @@
3//! This module implements an API for managing interrupts compatible with 3//! This module implements an API for managing interrupts compatible with
4//! nrf_softdevice::interrupt. Intended for switching between the two at compile-time. 4//! nrf_softdevice::interrupt. Intended for switching between the two at compile-time.
5 5
6use core::sync::atomic::{compiler_fence, Ordering};
7
8use crate::pac::NVIC_PRIO_BITS;
9
10// Re-exports 6// Re-exports
11pub use embassy::interrupt::{declare, take, Interrupt}; 7pub use embassy::interrupt::{declare, take, Interrupt};
12 8pub use embassy_extras::interrupt::Priority4 as Priority;
13#[derive(Debug, Copy, Clone, Eq, PartialEq, Ord, PartialOrd)]
14#[cfg_attr(feature = "defmt", derive(defmt::Format))]
15#[repr(u8)]
16pub enum Priority {
17 Level0 = 0,
18 Level1 = 1,
19 Level2 = 2,
20 Level3 = 3,
21 Level4 = 4,
22 Level5 = 5,
23 Level6 = 6,
24 Level7 = 7,
25 Level8 = 8,
26 Level9 = 9,
27 Level10 = 10,
28 Level11 = 11,
29 Level12 = 12,
30 Level13 = 13,
31 Level14 = 14,
32 Level15 = 15,
33}
34
35impl From<u8> for Priority {
36 fn from(priority: u8) -> Self {
37 match priority >> (8 - NVIC_PRIO_BITS) {
38 0 => Self::Level0,
39 1 => Self::Level1,
40 2 => Self::Level2,
41 3 => Self::Level3,
42 4 => Self::Level4,
43 5 => Self::Level5,
44 6 => Self::Level6,
45 7 => Self::Level7,
46 8 => Self::Level8,
47 9 => Self::Level9,
48 10 => Self::Level10,
49 11 => Self::Level11,
50 12 => Self::Level12,
51 13 => Self::Level13,
52 14 => Self::Level14,
53 15 => Self::Level15,
54 _ => unreachable!(),
55 }
56 }
57}
58
59impl From<Priority> for u8 {
60 fn from(p: Priority) -> Self {
61 (p as u8) << (8 - NVIC_PRIO_BITS)
62 }
63}
64 9
65#[cfg(feature = "stm32f401")] 10#[cfg(feature = "stm32f401")]
66mod irqs { 11mod irqs {