diff options
Diffstat (limited to 'src/export.rs')
-rw-r--r-- | src/export.rs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/export.rs b/src/export.rs index ed51a9e9..42f3fe2e 100644 --- a/src/export.rs +++ b/src/export.rs @@ -315,3 +315,37 @@ 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 +} + +#[cfg(not(armv6m))] +pub const fn v6_panic() { + // For non-v6 all is fine +} + +#[cfg(armv6m)] +pub const fn v6_panic() { + panic!("Exceptions with shared resources are not allowed when compiling for thumbv6. Use local resources or `#[lock_free]` shared resources"); +} |