mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
MASK behind cfg
This commit is contained in:
parent
c6231d81d8
commit
33174ac65b
3 changed files with 63 additions and 1 deletions
62
examples/hardware_hi_irq.rs
Normal file
62
examples/hardware_hi_irq.rs
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
//! examples/hardware.rs
|
||||||
|
|
||||||
|
#![deny(unsafe_code)]
|
||||||
|
#![deny(warnings)]
|
||||||
|
#![allow(const_err)]
|
||||||
|
#![no_main]
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
|
use panic_semihosting as _;
|
||||||
|
|
||||||
|
#[rtic::app(device = lm3s6965)]
|
||||||
|
mod app {
|
||||||
|
use cortex_m_semihosting::{debug, hprintln};
|
||||||
|
use lm3s6965::Interrupt;
|
||||||
|
|
||||||
|
#[shared]
|
||||||
|
struct Shared {}
|
||||||
|
|
||||||
|
#[local]
|
||||||
|
struct Local {}
|
||||||
|
|
||||||
|
#[init]
|
||||||
|
fn init(_: init::Context) -> (Shared, Local, init::Monotonics) {
|
||||||
|
// Pends the I2C1 interrupt but its handler won't run until *after*
|
||||||
|
// `init` returns because interrupts are disabled
|
||||||
|
rtic::pend(Interrupt::I2C1); // equivalent to NVIC::pend
|
||||||
|
|
||||||
|
hprintln!("init").unwrap();
|
||||||
|
|
||||||
|
(Shared {}, Local {}, init::Monotonics())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[idle]
|
||||||
|
fn idle(_: idle::Context) -> ! {
|
||||||
|
// interrupts are enabled again; the `UART0` handler runs at this point
|
||||||
|
|
||||||
|
hprintln!("idle").unwrap();
|
||||||
|
|
||||||
|
rtic::pend(Interrupt::I2C1);
|
||||||
|
|
||||||
|
debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
|
||||||
|
|
||||||
|
loop {
|
||||||
|
cortex_m::asm::nop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ETHERNET has an interrupt vector index > 31
|
||||||
|
// This is a test to check codegen for such cases
|
||||||
|
#[task(binds = I2C1, local = [times: u32 = 0])]
|
||||||
|
fn t1(cx: t1::Context) {
|
||||||
|
// Safe access to local `static mut` variable
|
||||||
|
*cx.local.times += 1;
|
||||||
|
|
||||||
|
hprintln!(
|
||||||
|
"t1 called {} time{}",
|
||||||
|
*cx.local.times,
|
||||||
|
if *cx.local.times > 1 { "s" } else { "" }
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
|
@ -135,6 +135,7 @@ pub fn codegen(
|
||||||
let mask_arr: Vec<_> = mask_arr.iter().map(|(_, v)| v).collect();
|
let mask_arr: Vec<_> = mask_arr.iter().map(|(_, v)| v).collect();
|
||||||
|
|
||||||
mod_app.push(quote!(
|
mod_app.push(quote!(
|
||||||
|
#[cfg(not(armv7m))]
|
||||||
const MASKS: [u32; 3] = [#(#mask_arr),*];
|
const MASKS: [u32; 3] = [#(#mask_arr),*];
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,6 @@ pub unsafe fn lock<T, R>(
|
||||||
priority: &Priority,
|
priority: &Priority,
|
||||||
ceiling: u8,
|
ceiling: u8,
|
||||||
nvic_prio_bits: u8,
|
nvic_prio_bits: u8,
|
||||||
_mask: &[u32; 3],
|
|
||||||
f: impl FnOnce(&mut T) -> R,
|
f: impl FnOnce(&mut T) -> R,
|
||||||
) -> R {
|
) -> R {
|
||||||
let current = priority.get();
|
let current = priority.get();
|
||||||
|
|
Loading…
Reference in a new issue