aboutsummaryrefslogtreecommitdiff
path: root/examples/periodic-at2.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/periodic-at2.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/periodic-at2.rs')
-rw-r--r--examples/periodic-at2.rs62
1 files changed, 0 insertions, 62 deletions
diff --git a/examples/periodic-at2.rs b/examples/periodic-at2.rs
deleted file mode 100644
index 4719bdb..0000000
--- a/examples/periodic-at2.rs
+++ /dev/null
@@ -1,62 +0,0 @@
-//! examples/periodic-at2.rs
-
-#![deny(unsafe_code)]
-#![deny(warnings)]
-#![deny(missing_docs)]
-#![no_main]
-#![no_std]
-
-use panic_semihosting as _;
-
-#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
-mod app {
- use cortex_m_semihosting::{debug, hprintln};
- use systick_monotonic::*;
-
- #[monotonic(binds = SysTick, default = true)]
- type MyMono = Systick<100>; // 100 Hz / 10 ms granularity
-
- #[shared]
- struct Shared {}
-
- #[local]
- struct Local {}
-
- #[init]
- fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
- let systick = cx.core.SYST;
-
- // Initialize the monotonic (SysTick rate in QEMU is 12 MHz)
- let mut mono = Systick::new(systick, 12_000_000);
-
- foo::spawn_after(1.secs(), mono.now()).unwrap();
-
- (Shared {}, Local {}, init::Monotonics(mono))
- }
-
- // Using the explicit type of the timer implementation
- #[task(local = [cnt: u32 = 0])]
- fn foo(cx: foo::Context, instant: fugit::TimerInstantU64<100>) {
- hprintln!("foo {:?}", instant);
- *cx.local.cnt += 1;
-
- if *cx.local.cnt == 4 {
- debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
- }
-
- // Spawn a new message with 100 ms offset to spawned time
- let next_instant = instant + 100.millis();
- bar::spawn_at(next_instant, next_instant).unwrap();
- }
-
- // Using the Instant from the Monotonic trait
- // This remains agnostic to the timer implementation
- #[task(local = [cnt: u32 = 0])]
- fn bar(_cx: bar::Context, instant: <MyMono as rtic_monotonic::Monotonic>::Instant) {
- hprintln!("bar {:?}", instant);
-
- // Spawn a new message with 1s offset to spawned time
- let next_instant = instant + 1.secs();
- foo::spawn_at(next_instant, next_instant).unwrap();
- }
-}