diff options
author | 2020-10-15 18:27:48 +0200 | |
---|---|---|
committer | 2020-10-15 18:27:48 +0200 | |
commit | 6808cc7cdf1512a7b10dd43f268f430a676c606e (patch) | |
tree | 67c0eadf6d8a98a2691b816d46a5103d159d6bbc /ui/single/local-cfg-task-local-err.rs | |
parent | c5b5ea60e826a7b95bd04055a722ecdc332df1d0 (diff) | |
parent | f9303cef1cf5b2d57d26e7667289fbdccf959ea8 (diff) | |
download | rtic-6808cc7cdf1512a7b10dd43f268f430a676c606e.tar.gz rtic-6808cc7cdf1512a7b10dd43f268f430a676c606e.tar.zst rtic-6808cc7cdf1512a7b10dd43f268f430a676c606e.zip |
Merge branch 'master' into spawn_experiment
Diffstat (limited to 'ui/single/local-cfg-task-local-err.rs')
-rw-r--r-- | ui/single/local-cfg-task-local-err.rs | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/ui/single/local-cfg-task-local-err.rs b/ui/single/local-cfg-task-local-err.rs new file mode 100644 index 00000000..412f6142 --- /dev/null +++ b/ui/single/local-cfg-task-local-err.rs @@ -0,0 +1,66 @@ +//! examples/local-cfg-task-local.rs + +#![deny(unsafe_code)] +//#![deny(warnings)] +#![no_main] +#![no_std] + +use cortex_m_semihosting::debug; +use cortex_m_semihosting::hprintln; +use lm3s6965::Interrupt; +use panic_semihosting as _; + +#[rtic::app(device = lm3s6965)] +mod app { + #[resources] + struct Resources { + // A local (move), early resource + #[cfg(feature = "feature_l1")] + #[task_local] + #[init(1)] + l1: u32, + + // A local (move), late resource + #[task_local] + l2: u32, + } + + #[init] + fn init(_: init::Context) -> init::LateResources { + rtic::pend(Interrupt::UART0); + rtic::pend(Interrupt::UART1); + init::LateResources { + #[cfg(feature = "feature_l2")] + l2: 2, + #[cfg(not(feature = "feature_l2"))] + l2: 5, + } + } + + // l1 ok (task_local) + #[idle(resources =[#[cfg(feature = "feature_l1")]l1])] + fn idle(_cx: idle::Context) -> ! { + #[cfg(feature = "feature_l1")] + hprintln!("IDLE:l1 = {}", _cx.resources.l1).unwrap(); + debug::exit(debug::EXIT_SUCCESS); + loop {} + } + + // l2 ok (task_local) + #[task(priority = 1, binds = UART0, resources = [ + #[cfg(feature = "feature_l2")]l2, + ])] + fn uart0(_cx: uart0::Context) { + #[cfg(feature = "feature_l2")] + hprintln!("UART0:l2 = {}", _cx.resources.l2).unwrap(); + } + + // l2 error, conflicting with uart0 for l2 (task_local) + #[task(priority = 1, binds = UART1, resources = [ + #[cfg(not(feature = "feature_l2"))]l2 + ])] + fn uart1(_cx: uart1::Context) { + #[cfg(not(feature = "feature_l2"))] + hprintln!("UART0:l2 = {}", _cx.resources.l2).unwrap(); + } +} |