aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEmil Fresk <emil.fresk@gmail.com>2022-04-20 10:46:03 +0200
committerEmil Fresk <emil.fresk@gmail.com>2022-04-20 10:56:13 +0200
commit9f38a39377a7ff03d0f4371feda083ba09064f5e (patch)
treeca788e3724f37c2c53597bcdd94792f6a9bd6bfd /src
parent87074180034fb682f3945b1391b09060c7058424 (diff)
Masks take 3
Diffstat (limited to 'src')
-rw-r--r--src/export.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/export.rs b/src/export.rs
index ed51a9e..0358991 100644
--- a/src/export.rs
+++ b/src/export.rs
@@ -315,3 +315,27 @@ unsafe fn clear_enable_mask(mask: u32) {
pub fn logical2hw(logical: u8, nvic_prio_bits: u8) -> u8 {
((1 << nvic_prio_bits) - logical) << (8 - nvic_prio_bits)
}
+
+#[cfg(not(armv6m))]
+pub const fn create_mask<const N: usize>(_: [u32; N]) -> u32 {
+ 0
+}
+
+#[cfg(armv6m)]
+pub const fn create_mask<const N: usize>(list_of_shifts: [u32; N]) -> u32 {
+ let mut mask = 0;
+ let mut i = 0;
+
+ while i < N {
+ let shift = list_of_shifts[i];
+ i += 1;
+
+ if shift > 31 {
+ panic!("Generating masks for thumbv6 failed! Are you compiling for thumbv6 on an thumbv7 MCU?");
+ }
+
+ mask |= 1 << shift;
+ }
+
+ mask
+}