diff options
author | 2022-04-20 11:35:08 +0000 | |
---|---|---|
committer | 2022-04-20 11:35:08 +0000 | |
commit | d1aa20643d39d033d43e4ab919c4a83601388c53 (patch) | |
tree | 42fe0077801e832320d23322f2259332e6d88d1f /src/export.rs | |
parent | 87074180034fb682f3945b1391b09060c7058424 (diff) | |
parent | 0f8bdbdd3f2739e37d788493cb83cf2d9c557f4e (diff) | |
download | rtic-d1aa20643d39d033d43e4ab919c4a83601388c53.tar.gz rtic-d1aa20643d39d033d43e4ab919c4a83601388c53.tar.zst rtic-d1aa20643d39d033d43e4ab919c4a83601388c53.zip |
Merge #635
635: Masks take 3 r=AfoHT a=korken89
This solves the `MASKS` generation issue by having `rtic::export` do the feature gating.
Co-authored-by: Emil Fresk <emil.fresk@gmail.com>
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"); +} |