aboutsummaryrefslogtreecommitdiff
path: root/examples/static.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-03-04 21:10:24 +0000
committerGitHub <noreply@github.com>2023-03-04 21:10:24 +0000
commit7c7d6558f6d9c50fbb4d2487c98c9a5be15f2f7b (patch)
tree80a47f0dc40059014e9448c4c2eb34c54dff45fe /examples/static.rs
parent1c5db277e4161470136dbd2a11e914ff1d383581 (diff)
parent98c5490d94950608d31cd5ad9dd260f2f853735c (diff)
Merge #694
694: RTIC 2 r=AfoHT a=korken89 Co-authored-by: Emil Fresk <emil.fresk@gmail.com> Co-authored-by: Per Lindgren <per.lindgren@ltu.se>
Diffstat (limited to 'examples/static.rs')
-rw-r--r--examples/static.rs60
1 files changed, 0 insertions, 60 deletions
diff --git a/examples/static.rs b/examples/static.rs
deleted file mode 100644
index efafcc7..0000000
--- a/examples/static.rs
+++ /dev/null
@@ -1,60 +0,0 @@
-//! examples/static.rs
-
-#![deny(unsafe_code)]
-#![deny(warnings)]
-#![deny(missing_docs)]
-#![no_main]
-#![no_std]
-
-use panic_semihosting as _;
-
-#[rtic::app(device = lm3s6965, dispatchers = [UART0])]
-mod app {
- use cortex_m_semihosting::{debug, hprintln};
- use heapless::spsc::{Consumer, Producer, Queue};
-
- #[shared]
- struct Shared {}
-
- #[local]
- struct Local {
- p: Producer<'static, u32, 5>,
- c: Consumer<'static, u32, 5>,
- }
-
- #[init(local = [q: Queue<u32, 5> = Queue::new()])]
- fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
- // q has 'static life-time so after the split and return of `init`
- // it will continue to exist and be allocated
- let (p, c) = cx.local.q.split();
-
- foo::spawn().unwrap();
-
- (Shared {}, Local { p, c }, init::Monotonics())
- }
-
- #[idle(local = [c])]
- fn idle(c: idle::Context) -> ! {
- loop {
- // Lock-free access to the same underlying queue!
- if let Some(data) = c.local.c.dequeue() {
- hprintln!("received message: {}", data);
-
- // Run foo until data
- if data == 3 {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
- } else {
- foo::spawn().unwrap();
- }
- }
- }
- }
-
- #[task(local = [p, state: u32 = 0])]
- fn foo(c: foo::Context) {
- *c.local.state += 1;
-
- // Lock-free access to the same underlying queue!
- c.local.p.enqueue(*c.local.state).unwrap();
- }
-}