aboutsummaryrefslogtreecommitdiff
path: root/rtic/examples/async-channel-try.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rtic/examples/async-channel-try.rs')
-rw-r--r--rtic/examples/async-channel-try.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/rtic/examples/async-channel-try.rs b/rtic/examples/async-channel-try.rs
index 54a51d9..2e2af52 100644
--- a/rtic/examples/async-channel-try.rs
+++ b/rtic/examples/async-channel-try.rs
@@ -18,7 +18,9 @@ mod app {
struct Shared {}
#[local]
- struct Local {}
+ struct Local {
+ sender: Sender<'static, u32, CAPACITY>,
+ }
const CAPACITY: usize = 1;
#[init]
@@ -28,7 +30,7 @@ mod app {
receiver::spawn(r).unwrap();
sender1::spawn(s.clone()).unwrap();
- (Shared {}, Local {})
+ (Shared {}, Local { sender: s.clone() })
}
#[task]
@@ -45,4 +47,11 @@ mod app {
hprintln!("Sender 1 try sending: 2 {:?}", sender.try_send(2));
debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
}
+
+ // This interrupt is never triggered, but is used to demonstrate that
+ // one can (try to) send data into a channel from a hardware task.
+ #[task(binds = GPIOA, local = [sender])]
+ fn hw_task(cx: hw_task::Context) {
+ cx.local.sender.try_send(3).ok();
+ }
}