diff options
author | 2020-10-22 21:36:32 +0200 | |
---|---|---|
committer | 2020-10-23 08:38:18 +0200 | |
commit | e8eca4be37a2fe1af25b203ace5e99b31fcc3972 (patch) | |
tree | c70a80e9bcacb54838f09141bd1d2b27e844760f /examples/t-resource.rs | |
parent | b3aa9e99a975eca637582f31de20fe11ae8f7d64 (diff) | |
download | rtic-e8eca4be37a2fe1af25b203ace5e99b31fcc3972.tar.gz rtic-e8eca4be37a2fe1af25b203ace5e99b31fcc3972.tar.zst rtic-e8eca4be37a2fe1af25b203ace5e99b31fcc3972.zip |
Now all locks are symmetric
Test fixes
Fix test
Fix comment
Diffstat (limited to 'examples/t-resource.rs')
-rw-r--r-- | examples/t-resource.rs | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/examples/t-resource.rs b/examples/t-resource.rs index 91950d3e..0a9f3bad 100644 --- a/examples/t-resource.rs +++ b/examples/t-resource.rs @@ -31,29 +31,18 @@ mod app { s3: u32, // idle & uart0 } - #[init(resources = [o1, o4, o5, o6, s3])] - fn init(c: init::Context) -> init::LateResources { - // owned by `init` == `&'static mut` - let _: &'static mut u32 = c.resources.o1; - - // owned by `init` == `&'static` if read-only - let _: &'static u32 = c.resources.o6; - - // `init` has exclusive access to all resources - let _: &mut u32 = c.resources.o4; - let _: &mut u32 = c.resources.o5; - let _: &mut u32 = c.resources.s3; - + #[init] + fn init(_: init::Context) -> init::LateResources { init::LateResources {} } #[idle(resources = [o2, &o4, s1, &s3])] fn idle(mut c: idle::Context) -> ! { // owned by `idle` == `&'static mut` - let _: &'static mut u32 = c.resources.o2; + let _: resources::o2 = c.resources.o2; // owned by `idle` == `&'static` if read-only - let _: &'static u32 = c.resources.o4; + let _: &u32 = c.resources.o4; // shared with `idle` == `Mutex` c.resources.s1.lock(|_| {}); @@ -69,13 +58,13 @@ mod app { #[task(binds = UART0, resources = [o3, s1, s2, &s3])] fn uart0(c: uart0::Context) { // owned by interrupt == `&mut` - let _: &mut u32 = c.resources.o3; + let _: resources::o3 = c.resources.o3; // no `Mutex` proxy when access from highest priority task - let _: &mut u32 = c.resources.s1; + let _: resources::s1 = c.resources.s1; // no `Mutex` proxy when co-owned by cooperative (same priority) tasks - let _: &mut u32 = c.resources.s2; + let _: resources::s2 = c.resources.s2; // `&` if read-only let _: &u32 = c.resources.s3; @@ -87,6 +76,6 @@ mod app { let _: &u32 = c.resources.o5; // no `Mutex` proxy when co-owned by cooperative (same priority) tasks - let _: &mut u32 = c.resources.s2; + let _: resources::s2 = c.resources.s2; } } |