From ef50aeb2e8245b69843280fabb62589c0716ffdd Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Thu, 3 Dec 2020 21:04:06 +0100 Subject: Save, init generation fixed --- examples/test_new_monotonic.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 examples/test_new_monotonic.rs (limited to 'examples') diff --git a/examples/test_new_monotonic.rs b/examples/test_new_monotonic.rs new file mode 100644 index 0000000..5aac48b --- /dev/null +++ b/examples/test_new_monotonic.rs @@ -0,0 +1,21 @@ +//! examples/test_new_monotonic.rs + +#![no_main] +#![no_std] + +use panic_semihosting as _; // panic handler +use rtic::app; + +#[app(device = lm3s6965)] +mod app { + #[monotonic(binds = SomeISR1)] + type Mono1 = hal::Mono1; + + #[monotonic(binds = SomeISR2)] + type Mono2 = hal::Mono2; + + #[init] + fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { + } +} + -- cgit v1.2.3 From b23bb1192c8dc1f2e8f157db2147b1737abc1033 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Tue, 8 Dec 2020 20:49:13 +0100 Subject: TQ handlers being generated --- examples/test_new_monotonic.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/test_new_monotonic.rs b/examples/test_new_monotonic.rs index 5aac48b..b389058 100644 --- a/examples/test_new_monotonic.rs +++ b/examples/test_new_monotonic.rs @@ -6,7 +6,7 @@ use panic_semihosting as _; // panic handler use rtic::app; -#[app(device = lm3s6965)] +#[app(device = lm3s6965, dispatchers = [UART])] mod app { #[monotonic(binds = SomeISR1)] type Mono1 = hal::Mono1; @@ -17,5 +17,11 @@ mod app { #[init] fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { } + + #[task] + fn task1(_: task1::Context) {} + + #[task] + fn task2(_: task2::Context) {} } -- cgit v1.2.3 From 97a48983d2859740983cbf342e1287182426ed44 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Thu, 10 Dec 2020 20:33:13 +0100 Subject: More work --- examples/test_new_monotonic.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/test_new_monotonic.rs b/examples/test_new_monotonic.rs index b389058..d2530c6 100644 --- a/examples/test_new_monotonic.rs +++ b/examples/test_new_monotonic.rs @@ -9,10 +9,10 @@ use rtic::app; #[app(device = lm3s6965, dispatchers = [UART])] mod app { #[monotonic(binds = SomeISR1)] - type Mono1 = hal::Mono1; + type MyMono1 = hal::Mono1; - #[monotonic(binds = SomeISR2)] - type Mono2 = hal::Mono2; + #[monotonic(binds = SomeISR2, default = true)] + type MyMono2 = hal::Mono2; #[init] fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { -- cgit v1.2.3 From 1c8de78f6f6e9e265d9d894d2ebde622bf16d44e Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Sat, 12 Dec 2020 23:31:05 +0100 Subject: Cleanup --- examples/test_new_monotonic.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'examples') diff --git a/examples/test_new_monotonic.rs b/examples/test_new_monotonic.rs index d2530c6..3323c09 100644 --- a/examples/test_new_monotonic.rs +++ b/examples/test_new_monotonic.rs @@ -15,8 +15,7 @@ mod app { type MyMono2 = hal::Mono2; #[init] - fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { - } + fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {} #[task] fn task1(_: task1::Context) {} @@ -24,4 +23,3 @@ mod app { #[task] fn task2(_: task2::Context) {} } - -- cgit v1.2.3 From 62771839061aaa7dd518d40969bee609d7d2bda8 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Sun, 13 Dec 2020 14:52:16 +0100 Subject: Now handling SysTick as well --- examples/test_new_monotonic.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/test_new_monotonic.rs b/examples/test_new_monotonic.rs index 3323c09..6788346 100644 --- a/examples/test_new_monotonic.rs +++ b/examples/test_new_monotonic.rs @@ -8,7 +8,7 @@ use rtic::app; #[app(device = lm3s6965, dispatchers = [UART])] mod app { - #[monotonic(binds = SomeISR1)] + #[monotonic(binds = SysTick)] type MyMono1 = hal::Mono1; #[monotonic(binds = SomeISR2, default = true)] -- cgit v1.2.3 From 555f36857ec93bed26ff4249593992f500b7c4ab Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Sat, 20 Feb 2021 19:22:45 +0100 Subject: Test fixes --- examples/baseline.rs | 50 -------------------------------------- examples/big-struct-opt.rs | 13 ++++++---- examples/binds.rs | 4 +-- examples/capacity.rs | 4 +-- examples/cfg-whole-task.rs | 4 +-- examples/cfg.rs | 4 +-- examples/destructure.rs | 4 +-- examples/double_schedule.rs | 13 +++------- examples/extern_binds.rs | 4 +-- examples/extern_spawn.rs | 4 +-- examples/generics.rs | 4 +-- examples/hardware.rs | 4 +-- examples/idle.rs | 4 +-- examples/init.rs | 4 +-- examples/late.rs | 4 +-- examples/lock.rs | 4 +-- examples/message.rs | 4 +-- examples/multilock.rs | 4 +-- examples/not-sync.rs | 4 +-- examples/only-shared-access.rs | 4 +-- examples/periodic.rs | 6 ++--- examples/peripherals-taken.rs | 4 +-- examples/pool.rs | 4 +-- examples/preempt.rs | 4 +-- examples/ramfunc.rs | 4 +-- examples/resource-user-struct.rs | 4 +-- examples/resource.rs | 4 +-- examples/schedule.rs | 6 ++--- examples/spawn.rs | 4 +-- examples/spawn2.rs | 4 +-- examples/static.rs | 4 +-- examples/t-binds.rs | 4 +-- examples/t-cfg-resources.rs | 17 +++++++------ examples/t-cfg.rs | 6 ++--- examples/t-htask-main.rs | 4 +-- examples/t-idle-main.rs | 4 +-- examples/t-init-main.rs | 4 +-- examples/t-late-not-send.rs | 11 ++++++--- examples/t-resource.rs | 4 +-- examples/t-schedule-core-stable.rs | 8 +++--- examples/t-schedule.rs | 6 ++--- examples/t-spawn.rs | 4 +-- examples/t-stask-main.rs | 4 +-- examples/task-local-minimal.rs | 4 +-- examples/task-local.rs | 4 +-- examples/task.rs | 4 +-- examples/task_named_main.rs | 4 +-- examples/test_new_monotonic.rs | 25 ------------------- examples/types.rs | 7 +++--- 49 files changed, 121 insertions(+), 195 deletions(-) delete mode 100644 examples/baseline.rs delete mode 100644 examples/test_new_monotonic.rs (limited to 'examples') diff --git a/examples/baseline.rs b/examples/baseline.rs deleted file mode 100644 index 1727874..0000000 --- a/examples/baseline.rs +++ /dev/null @@ -1,50 +0,0 @@ -//! examples/baseline.rs - -#![deny(unsafe_code)] -#![deny(warnings)] -#![no_main] -#![no_std] - -use panic_semihosting as _; - -// NOTE: does NOT properly work on QEMU -#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT, dispatchers = [SSI0])] -mod app { - use cortex_m_semihosting::{debug, hprintln}; - use lm3s6965::Interrupt; - - #[init] - fn init(cx: init::Context) -> init::LateResources { - // omitted: initialization of `CYCCNT` - - hprintln!("init(baseline = {:?})", cx.start).unwrap(); - - // `foo` inherits the baseline of `init`: `Instant(0)` - foo::spawn().unwrap(); - - init::LateResources {} - } - - #[task] - fn foo(cx: foo::Context) { - static mut ONCE: bool = true; - - hprintln!("foo(baseline = {:?})", cx.scheduled).unwrap(); - - if *ONCE { - *ONCE = false; - - rtic::pend(Interrupt::UART0); - } else { - debug::exit(debug::EXIT_SUCCESS); - } - } - - #[task(binds = UART0)] - fn uart0(cx: uart0::Context) { - hprintln!("UART0(baseline = {:?})", cx.start).unwrap(); - - // `foo` inherits the baseline of `UART0`: its `start` time - foo::spawn().unwrap(); - } -} diff --git a/examples/big-struct-opt.rs b/examples/big-struct-opt.rs index 85ec5e6..dc6e72f 100644 --- a/examples/big-struct-opt.rs +++ b/examples/big-struct-opt.rs @@ -31,7 +31,7 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { let big_struct = unsafe { static mut BIG_STRUCT: MaybeUninit = MaybeUninit::uninit(); @@ -40,9 +40,12 @@ mod app { &mut *BIG_STRUCT.as_mut_ptr() }; - init::LateResources { - // assign the reference so we can use the resource - big_struct, - } + ( + init::LateResources { + // assign the reference so we can use the resource + big_struct, + }, + init::Monotonics(), + ) } } diff --git a/examples/binds.rs b/examples/binds.rs index f681aa5..9cbe299 100644 --- a/examples/binds.rs +++ b/examples/binds.rs @@ -14,12 +14,12 @@ mod app { use lm3s6965::Interrupt; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::UART0); hprintln!("init").unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[idle] diff --git a/examples/capacity.rs b/examples/capacity.rs index b25a758..06bd921 100644 --- a/examples/capacity.rs +++ b/examples/capacity.rs @@ -13,10 +13,10 @@ mod app { use lm3s6965::Interrupt; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::UART0); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task(binds = UART0)] diff --git a/examples/cfg-whole-task.rs b/examples/cfg-whole-task.rs index b19c280..47c3530 100644 --- a/examples/cfg-whole-task.rs +++ b/examples/cfg-whole-task.rs @@ -24,11 +24,11 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { foo::spawn().unwrap(); foo::spawn().unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[idle] diff --git a/examples/cfg.rs b/examples/cfg.rs index d3f2cea..43c2593 100644 --- a/examples/cfg.rs +++ b/examples/cfg.rs @@ -21,11 +21,11 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { foo::spawn().unwrap(); foo::spawn().unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[idle] diff --git a/examples/destructure.rs b/examples/destructure.rs index d843978..d085e4b 100644 --- a/examples/destructure.rs +++ b/examples/destructure.rs @@ -24,11 +24,11 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::UART0); rtic::pend(Interrupt::UART1); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } // Direct destructure diff --git a/examples/double_schedule.rs b/examples/double_schedule.rs index 32477ef..77a8e38 100644 --- a/examples/double_schedule.rs +++ b/examples/double_schedule.rs @@ -7,20 +7,13 @@ use panic_semihosting as _; -#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT, dispatchers = [SSI0])] +#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { - use rtic::cyccnt::U32Ext; - - #[resources] - struct Resources { - nothing: (), - } - #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { task1::spawn().ok(); - init::LateResources { nothing: () } + (init::LateResources {}, init::Monotonics()) } #[task] diff --git a/examples/extern_binds.rs b/examples/extern_binds.rs index 632f4ca..3c8786d 100644 --- a/examples/extern_binds.rs +++ b/examples/extern_binds.rs @@ -20,12 +20,12 @@ mod app { use lm3s6965::Interrupt; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::UART0); hprintln!("init").unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[idle] diff --git a/examples/extern_spawn.rs b/examples/extern_spawn.rs index 1be3d51..275ac53 100644 --- a/examples/extern_spawn.rs +++ b/examples/extern_spawn.rs @@ -22,10 +22,10 @@ mod app { use crate::foo; #[init] - fn init(_c: init::Context) -> init::LateResources { + fn init(_c: init::Context) -> (init::LateResources, init::Monotonics) { foo::spawn(1, 2).unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } extern "Rust" { diff --git a/examples/generics.rs b/examples/generics.rs index f3829a0..eabfff7 100644 --- a/examples/generics.rs +++ b/examples/generics.rs @@ -21,11 +21,11 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::UART0); rtic::pend(Interrupt::UART1); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task(binds = UART0, resources = [shared])] diff --git a/examples/hardware.rs b/examples/hardware.rs index 99e8da2..3cf9880 100644 --- a/examples/hardware.rs +++ b/examples/hardware.rs @@ -13,14 +13,14 @@ mod app { use lm3s6965::Interrupt; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { // Pends the UART0 interrupt but its handler won't run until *after* // `init` returns because interrupts are disabled rtic::pend(Interrupt::UART0); // equivalent to NVIC::pend hprintln!("init").unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[idle] diff --git a/examples/idle.rs b/examples/idle.rs index 1aac56c..db03dc7 100644 --- a/examples/idle.rs +++ b/examples/idle.rs @@ -12,10 +12,10 @@ mod app { use cortex_m_semihosting::{debug, hprintln}; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { hprintln!("init").unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[idle] diff --git a/examples/init.rs b/examples/init.rs index ca67a2b..9de7958 100644 --- a/examples/init.rs +++ b/examples/init.rs @@ -12,7 +12,7 @@ mod app { use cortex_m_semihosting::{debug, hprintln}; #[init] - fn init(cx: init::Context) -> init::LateResources { + fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { static mut X: u32 = 0; // Cortex-M peripherals @@ -32,6 +32,6 @@ mod app { debug::exit(debug::EXIT_SUCCESS); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } } diff --git a/examples/late.rs b/examples/late.rs index d4efaba..e65b6e6 100644 --- a/examples/late.rs +++ b/examples/late.rs @@ -25,13 +25,13 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { static mut Q: Queue = Queue(i::Queue::new()); let (p, c) = Q.split(); // Initialization of late resources - init::LateResources { p, c } + (init::LateResources { p, c }, init::Monotonics()) } #[idle(resources = [c])] diff --git a/examples/lock.rs b/examples/lock.rs index 2fbf760..75d47d2 100644 --- a/examples/lock.rs +++ b/examples/lock.rs @@ -19,10 +19,10 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::GPIOA); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } // when omitted priority is assumed to be `1` diff --git a/examples/message.rs b/examples/message.rs index 4c5d899..722e73a 100644 --- a/examples/message.rs +++ b/examples/message.rs @@ -12,10 +12,10 @@ mod app { use cortex_m_semihosting::{debug, hprintln}; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { foo::spawn(/* no message */).unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task] diff --git a/examples/multilock.rs b/examples/multilock.rs index a6985df..ad9d72a 100644 --- a/examples/multilock.rs +++ b/examples/multilock.rs @@ -25,10 +25,10 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::GPIOA); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } // when omitted priority is assumed to be `1` diff --git a/examples/not-sync.rs b/examples/not-sync.rs index 21c316a..8189da5 100644 --- a/examples/not-sync.rs +++ b/examples/not-sync.rs @@ -25,10 +25,10 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { debug::exit(debug::EXIT_SUCCESS); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task(resources = [&shared])] diff --git a/examples/only-shared-access.rs b/examples/only-shared-access.rs index 8d42fd4..2c6ad4c 100644 --- a/examples/only-shared-access.rs +++ b/examples/only-shared-access.rs @@ -18,11 +18,11 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::UART0); rtic::pend(Interrupt::UART1); - init::LateResources { key: 0xdeadbeef } + (init::LateResources { key: 0xdeadbeef }, init::Monotonics()) } #[task(binds = UART0, resources = [&key])] diff --git a/examples/periodic.rs b/examples/periodic.rs index 3ff9c90..29fa6bd 100644 --- a/examples/periodic.rs +++ b/examples/periodic.rs @@ -8,7 +8,7 @@ use panic_semihosting as _; // NOTE: does NOT work on QEMU! -#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT, dispatchers = [SSI0])] +#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { use cortex_m_semihosting::hprintln; use rtic::cyccnt::{Instant, U32Ext}; @@ -16,12 +16,12 @@ mod app { const PERIOD: u32 = 8_000_000; #[init] - fn init(cx: init::Context) -> init::LateResources { + fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { // omitted: initialization of `CYCCNT` foo::schedule(cx.start + PERIOD.cycles()).unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task] diff --git a/examples/peripherals-taken.rs b/examples/peripherals-taken.rs index 98f06b0..6b4a282 100644 --- a/examples/peripherals-taken.rs +++ b/examples/peripherals-taken.rs @@ -10,10 +10,10 @@ mod app { use cortex_m_semihosting::debug; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { assert!(cortex_m::Peripherals::take().is_none()); debug::exit(debug::EXIT_SUCCESS); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } } diff --git a/examples/pool.rs b/examples/pool.rs index eaad9c0..44405b4 100644 --- a/examples/pool.rs +++ b/examples/pool.rs @@ -25,7 +25,7 @@ mod app { use super::P; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { static mut MEMORY: [u8; 512] = [0; 512]; // Increase the capacity of the memory pool by ~4 @@ -33,7 +33,7 @@ mod app { rtic::pend(Interrupt::I2C0); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task(binds = I2C0, priority = 2)] diff --git a/examples/preempt.rs b/examples/preempt.rs index ee75c46..14b3a0a 100644 --- a/examples/preempt.rs +++ b/examples/preempt.rs @@ -12,10 +12,10 @@ mod app { use lm3s6965::Interrupt; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::GPIOA); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task(binds = GPIOA, priority = 1)] diff --git a/examples/ramfunc.rs b/examples/ramfunc.rs index b5aa17b..d9c8143 100644 --- a/examples/ramfunc.rs +++ b/examples/ramfunc.rs @@ -19,10 +19,10 @@ mod app { use cortex_m_semihosting::{debug, hprintln}; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { foo::spawn().unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[inline(never)] diff --git a/examples/resource-user-struct.rs b/examples/resource-user-struct.rs index a550bb2..6ad540b 100644 --- a/examples/resource-user-struct.rs +++ b/examples/resource-user-struct.rs @@ -27,11 +27,11 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::UART0); rtic::pend(Interrupt::UART1); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } // `shared` cannot be accessed from this context diff --git a/examples/resource.rs b/examples/resource.rs index 60aa52b..c8c57bf 100644 --- a/examples/resource.rs +++ b/examples/resource.rs @@ -20,11 +20,11 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::UART0); rtic::pend(Interrupt::UART1); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } // `shared` cannot be accessed from this context diff --git a/examples/schedule.rs b/examples/schedule.rs index 5f73c50..6f6f8cb 100644 --- a/examples/schedule.rs +++ b/examples/schedule.rs @@ -8,14 +8,14 @@ use panic_halt as _; // NOTE: does NOT work on QEMU! -#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT, dispatchers = [SSI0])] +#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { use cortex_m::peripheral::DWT; use cortex_m_semihosting::hprintln; use rtic::cyccnt::{Instant, U32Ext as _}; #[init()] - fn init(mut cx: init::Context) -> init::LateResources { + fn init(mut cx: init::Context) -> (init::LateResources, init::Monotonics) { // Initialize (enable) the monotonic timer (CYCCNT) cx.core.DCB.enable_trace(); // required on Cortex-M7 devices that software lock the DWT (e.g. STM32F7) @@ -34,7 +34,7 @@ mod app { // Schedule `bar` to run 4e6 cycles in the future bar::schedule(now + 4_000_000.cycles()).unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task] diff --git a/examples/spawn.rs b/examples/spawn.rs index 449fcfb..987ebf7 100644 --- a/examples/spawn.rs +++ b/examples/spawn.rs @@ -12,10 +12,10 @@ mod app { use cortex_m_semihosting::{debug, hprintln}; #[init] - fn init(_c: init::Context) -> init::LateResources { + fn init(_c: init::Context) -> (init::LateResources, init::Monotonics) { foo::spawn(1, 2).unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task()] diff --git a/examples/spawn2.rs b/examples/spawn2.rs index c485b92..be113f7 100644 --- a/examples/spawn2.rs +++ b/examples/spawn2.rs @@ -12,10 +12,10 @@ mod app { use cortex_m_semihosting::{debug, hprintln}; #[init] - fn init(_c: init::Context) -> init::LateResources { + fn init(_c: init::Context) -> (init::LateResources, init::Monotonics) { foo::spawn(1, 2).unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task] diff --git a/examples/static.rs b/examples/static.rs index 7626c71..cbbc539 100644 --- a/examples/static.rs +++ b/examples/static.rs @@ -26,13 +26,13 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { static mut Q: Queue = Queue(i::Queue::new()); let (p, c) = Q.split(); // Initialization of late resources - init::LateResources { p, c } + (init::LateResources { p, c }, init::Monotonics()) } #[idle(resources = [c])] diff --git a/examples/t-binds.rs b/examples/t-binds.rs index 8d52f58..60afa35 100644 --- a/examples/t-binds.rs +++ b/examples/t-binds.rs @@ -10,8 +10,8 @@ use panic_halt as _; #[rtic::app(device = lm3s6965)] mod app { #[init] - fn init(_: init::Context) -> init::LateResources { - init::LateResources {} + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { + (init::LateResources {}, init::Monotonics()) } // Cortex-M exception diff --git a/examples/t-cfg-resources.rs b/examples/t-cfg-resources.rs index 61eb4c7..990b01f 100644 --- a/examples/t-cfg-resources.rs +++ b/examples/t-cfg-resources.rs @@ -18,13 +18,16 @@ mod app { dummy: (), // dummy such that we have at least one late resource } #[init] - fn init(_: init::Context) -> init::LateResources { - init::LateResources { - // The feature needs to be applied everywhere x is defined or used - #[cfg(feature = "feature_x")] - x: 0, - dummy: (), // dummy such that we have at least one late resource - } + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { + ( + init::LateResources { + // The feature needs to be applied everywhere x is defined or used + #[cfg(feature = "feature_x")] + x: 0, + dummy: (), // dummy such that we have at least one late resource + }, + init::Monotonics(), + ) } #[idle] diff --git a/examples/t-cfg.rs b/examples/t-cfg.rs index 5bcef0a..ff06ee8 100644 --- a/examples/t-cfg.rs +++ b/examples/t-cfg.rs @@ -5,7 +5,7 @@ use panic_halt as _; -#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT, dispatchers = [SSI0, QEI0])] +#[rtic::app(device = lm3s6965, dispatchers = [SSI0, QEI0])] mod app { #[resources] struct Resources { @@ -15,11 +15,11 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { #[cfg(never)] static mut BAR: u32 = 0; - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[idle] diff --git a/examples/t-htask-main.rs b/examples/t-htask-main.rs index 57076ec..2d480d0 100644 --- a/examples/t-htask-main.rs +++ b/examples/t-htask-main.rs @@ -10,10 +10,10 @@ mod app { use cortex_m_semihosting::debug; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(lm3s6965::Interrupt::UART0); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task(binds = UART0)] diff --git a/examples/t-idle-main.rs b/examples/t-idle-main.rs index 42dac90..891896f 100644 --- a/examples/t-idle-main.rs +++ b/examples/t-idle-main.rs @@ -10,8 +10,8 @@ mod app { use cortex_m_semihosting::debug; #[init] - fn init(_: init::Context) -> init::LateResources { - init::LateResources {} + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { + (init::LateResources {}, init::Monotonics()) } #[idle] diff --git a/examples/t-init-main.rs b/examples/t-init-main.rs index 0456e87..b77a7df 100644 --- a/examples/t-init-main.rs +++ b/examples/t-init-main.rs @@ -10,9 +10,9 @@ mod app { use cortex_m_semihosting::debug; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { debug::exit(debug::EXIT_SUCCESS); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } } diff --git a/examples/t-late-not-send.rs b/examples/t-late-not-send.rs index ce3bcba..dae0aa9 100644 --- a/examples/t-late-not-send.rs +++ b/examples/t-late-not-send.rs @@ -24,10 +24,13 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { - init::LateResources { - x: NotSend { _0: PhantomData }, - } + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { + ( + init::LateResources { + x: NotSend { _0: PhantomData }, + }, + init::Monotonics(), + ) } #[idle(resources = [x, y])] diff --git a/examples/t-resource.rs b/examples/t-resource.rs index 0a9f3ba..164ea84 100644 --- a/examples/t-resource.rs +++ b/examples/t-resource.rs @@ -32,8 +32,8 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { - init::LateResources {} + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { + (init::LateResources {}, init::Monotonics()) } #[idle(resources = [o2, &o4, s1, &s3])] diff --git a/examples/t-schedule-core-stable.rs b/examples/t-schedule-core-stable.rs index 1053901..adcc0b6 100644 --- a/examples/t-schedule-core-stable.rs +++ b/examples/t-schedule-core-stable.rs @@ -7,13 +7,13 @@ use panic_halt as _; -#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT, dispatchers = [SSI0])] +#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { #[init] - fn init(c: init::Context) -> init::LateResources { - let _c: rtic::Peripherals = c.core; + fn init(c: init::Context) -> (init::LateResources, init::Monotonics) { + let _c: cortex_m::Peripherals = c.core; - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task] diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs index 9c94d1b..1771d41 100644 --- a/examples/t-schedule.rs +++ b/examples/t-schedule.rs @@ -7,17 +7,17 @@ use panic_halt as _; -#[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT, dispatchers = [SSI0])] +#[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { use rtic::cyccnt::{Instant, U32Ext as _}; #[init] - fn init(c: init::Context) -> init::LateResources { + fn init(c: init::Context) -> (init::LateResources, init::Monotonics) { let _: Result<(), ()> = foo::schedule(c.start + 10.cycles()); let _: Result<(), u32> = bar::schedule(c.start + 20.cycles(), 0); let _: Result<(), (u32, u32)> = baz::schedule(c.start + 30.cycles(), 0, 1); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[idle] diff --git a/examples/t-spawn.rs b/examples/t-spawn.rs index c9949ef..cc7754e 100644 --- a/examples/t-spawn.rs +++ b/examples/t-spawn.rs @@ -10,12 +10,12 @@ use panic_halt as _; #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { let _: Result<(), ()> = foo::spawn(); let _: Result<(), u32> = bar::spawn(0); let _: Result<(), (u32, u32)> = baz::spawn(0, 1); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[idle] diff --git a/examples/t-stask-main.rs b/examples/t-stask-main.rs index 034ad7c..cfc9342 100644 --- a/examples/t-stask-main.rs +++ b/examples/t-stask-main.rs @@ -10,10 +10,10 @@ mod app { use cortex_m_semihosting::debug; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { taskmain::spawn().ok(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task] diff --git a/examples/task-local-minimal.rs b/examples/task-local-minimal.rs index 6e25c10..f83493c 100644 --- a/examples/task-local-minimal.rs +++ b/examples/task-local-minimal.rs @@ -18,8 +18,8 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { - init::LateResources { l: 42 } + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { + (init::LateResources { l: 42 }, init::Monotonics()) } // l is task_local diff --git a/examples/task-local.rs b/examples/task-local.rs index e86197a..3020c3b 100644 --- a/examples/task-local.rs +++ b/examples/task-local.rs @@ -38,10 +38,10 @@ mod app { } #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { rtic::pend(Interrupt::UART0); rtic::pend(Interrupt::UART1); - init::LateResources { e2: 2, l2: 2 } + (init::LateResources { e2: 2, l2: 2 }, init::Monotonics()) } // `shared` cannot be accessed from this context diff --git a/examples/task.rs b/examples/task.rs index 5e4769a..9d4492f 100644 --- a/examples/task.rs +++ b/examples/task.rs @@ -12,10 +12,10 @@ mod app { use cortex_m_semihosting::{debug, hprintln}; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { foo::spawn().unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task] diff --git a/examples/task_named_main.rs b/examples/task_named_main.rs index c3d21b5..c2c4e62 100644 --- a/examples/task_named_main.rs +++ b/examples/task_named_main.rs @@ -12,10 +12,10 @@ mod app { use cortex_m_semihosting::{debug, hprintln}; #[init] - fn init(_: init::Context) -> init::LateResources { + fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { main::spawn().unwrap(); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[task] diff --git a/examples/test_new_monotonic.rs b/examples/test_new_monotonic.rs deleted file mode 100644 index 6788346..0000000 --- a/examples/test_new_monotonic.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! examples/test_new_monotonic.rs - -#![no_main] -#![no_std] - -use panic_semihosting as _; // panic handler -use rtic::app; - -#[app(device = lm3s6965, dispatchers = [UART])] -mod app { - #[monotonic(binds = SysTick)] - type MyMono1 = hal::Mono1; - - #[monotonic(binds = SomeISR2, default = true)] - type MyMono2 = hal::Mono2; - - #[init] - fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {} - - #[task] - fn task1(_: task1::Context) {} - - #[task] - fn task2(_: task2::Context) {} -} diff --git a/examples/types.rs b/examples/types.rs index bcdd30a..8411eec 100644 --- a/examples/types.rs +++ b/examples/types.rs @@ -7,10 +7,9 @@ use panic_semihosting as _; -#[rtic::app(device = lm3s6965, peripherals = true, monotonic = rtic::cyccnt::CYCCNT, dispatchers = [SSI0])] +#[rtic::app(device = lm3s6965, peripherals = true, dispatchers = [SSI0])] mod app { use cortex_m_semihosting::debug; - use rtic::cyccnt; #[resources] struct Resources { @@ -19,14 +18,14 @@ mod app { } #[init] - fn init(cx: init::Context) -> init::LateResources { + fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { let _: cyccnt::Instant = cx.start; let _: rtic::Peripherals = cx.core; let _: lm3s6965::Peripherals = cx.device; debug::exit(debug::EXIT_SUCCESS); - init::LateResources {} + (init::LateResources {}, init::Monotonics()) } #[idle] -- cgit v1.2.3 From cd3484cbab3c4cd7e483e8de19bcdd9498443412 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Tue, 23 Feb 2021 19:35:26 +0100 Subject: GHA update Fmt fixes Spawn_after did not work with parameters Examples working again Revert "GHA update" This reverts commit e0a71d4859966a6c5cf2629d3cb27e88acada9c0. Readd flags Only add DWT based dep with __v7 flag --- examples/double_schedule.rs | 23 ++++++++++++++++---- examples/periodic.rs | 28 +++++++++++++++---------- examples/schedule.rs | 40 ++++++++++++++++++----------------- examples/t-schedule.rs | 51 ++++++++++++++++++++------------------------- examples/types.rs | 20 +++++++++++++----- 5 files changed, 95 insertions(+), 67 deletions(-) (limited to 'examples') diff --git a/examples/double_schedule.rs b/examples/double_schedule.rs index 77a8e38..403f358 100644 --- a/examples/double_schedule.rs +++ b/examples/double_schedule.rs @@ -9,20 +9,35 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { + use dwt_systick_monotonic::{ + consts::{U0, U8}, + DwtSystick, + }; + use rtic::time::duration::Seconds; + + #[monotonic(binds = SysTick, default = true)] + type MyMono = DwtSystick; // 8 MHz + #[init] - fn init(_: init::Context) -> (init::LateResources, init::Monotonics) { + fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { task1::spawn().ok(); - (init::LateResources {}, init::Monotonics()) + let mut dcb = cx.core.DCB; + let dwt = cx.core.DWT; + let systick = cx.core.SYST; + + let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000); + + (init::LateResources {}, init::Monotonics(mono)) } #[task] fn task1(_cx: task1::Context) { - task2::schedule(_cx.scheduled + 100.cycles()).ok(); + task2::spawn_after(Seconds(1_u32)).ok(); } #[task] fn task2(_cx: task2::Context) { - task1::schedule(_cx.scheduled + 100.cycles()).ok(); + task1::spawn_after(Seconds(1_u32)).ok(); } } diff --git a/examples/periodic.rs b/examples/periodic.rs index 29fa6bd..82c2128 100644 --- a/examples/periodic.rs +++ b/examples/periodic.rs @@ -10,25 +10,31 @@ use panic_semihosting as _; // NOTE: does NOT work on QEMU! #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { - use cortex_m_semihosting::hprintln; - use rtic::cyccnt::{Instant, U32Ext}; + use dwt_systick_monotonic::{ + consts::{U0, U8}, + DwtSystick, + }; + use rtic::time::duration::Seconds; - const PERIOD: u32 = 8_000_000; + #[monotonic(binds = SysTick, default = true)] + type MyMono = DwtSystick; // 8 MHz #[init] fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { - // omitted: initialization of `CYCCNT` + let mut dcb = cx.core.DCB; + let dwt = cx.core.DWT; + let systick = cx.core.SYST; - foo::schedule(cx.start + PERIOD.cycles()).unwrap(); + let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000); - (init::LateResources {}, init::Monotonics()) + foo::spawn_after(Seconds(1_u32)).unwrap(); + + (init::LateResources {}, init::Monotonics(mono)) } #[task] - fn foo(cx: foo::Context) { - let now = Instant::now(); - hprintln!("foo(scheduled = {:?}, now = {:?})", cx.scheduled, now).unwrap(); - - foo::schedule(cx.scheduled + PERIOD.cycles()).unwrap(); + fn foo(_cx: foo::Context) { + // Periodic + foo::spawn_after(Seconds(1_u32)).unwrap(); } } diff --git a/examples/schedule.rs b/examples/schedule.rs index 6f6f8cb..cdbdc0d 100644 --- a/examples/schedule.rs +++ b/examples/schedule.rs @@ -10,40 +10,42 @@ use panic_halt as _; // NOTE: does NOT work on QEMU! #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { - use cortex_m::peripheral::DWT; use cortex_m_semihosting::hprintln; - use rtic::cyccnt::{Instant, U32Ext as _}; + use dwt_systick_monotonic::{ + consts::{U0, U8}, + DwtSystick, + }; + use rtic::time::duration::Seconds; + + #[monotonic(binds = SysTick, default = true)] + type MyMono = DwtSystick; // 8 MHz #[init()] - fn init(mut cx: init::Context) -> (init::LateResources, init::Monotonics) { - // Initialize (enable) the monotonic timer (CYCCNT) - cx.core.DCB.enable_trace(); - // required on Cortex-M7 devices that software lock the DWT (e.g. STM32F7) - DWT::unlock(); - cx.core.DWT.enable_cycle_counter(); + fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { + let mut dcb = cx.core.DCB; + let dwt = cx.core.DWT; + let systick = cx.core.SYST; - // semantically, the monotonic timer is frozen at time "zero" during `init` - // NOTE do *not* call `Instant::now` in this context; it will return a nonsense value - let now = cx.start; // the start time of the system + let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000); - hprintln!("init @ {:?}", now).unwrap(); + hprintln!("init").unwrap(); - // Schedule `foo` to run 8e6 cycles (clock cycles) in the future - foo::schedule(now + 8_000_000.cycles()).unwrap(); + // Schedule `foo` to run 1 second in the future + foo::spawn_after(Seconds(1_u32)).unwrap(); - // Schedule `bar` to run 4e6 cycles in the future - bar::schedule(now + 4_000_000.cycles()).unwrap(); + // Schedule `bar` to run 2 seconds in the future + bar::spawn_after(Seconds(2_u32)).unwrap(); - (init::LateResources {}, init::Monotonics()) + (init::LateResources {}, init::Monotonics(mono)) } #[task] fn foo(_: foo::Context) { - hprintln!("foo @ {:?}", Instant::now()).unwrap(); + hprintln!("foo").unwrap(); } #[task] fn bar(_: bar::Context) { - hprintln!("bar @ {:?}", Instant::now()).unwrap(); + hprintln!("bar").unwrap(); } } diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs index 1771d41..259b226 100644 --- a/examples/t-schedule.rs +++ b/examples/t-schedule.rs @@ -9,48 +9,43 @@ use panic_halt as _; #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { - use rtic::cyccnt::{Instant, U32Ext as _}; + use dwt_systick_monotonic::{ + consts::{U0, U8}, + DwtSystick, + }; + use rtic::time::duration::Seconds; + + #[monotonic(binds = SysTick, default = true)] + type MyMono = DwtSystick; // 8 MHz #[init] - fn init(c: init::Context) -> (init::LateResources, init::Monotonics) { - let _: Result<(), ()> = foo::schedule(c.start + 10.cycles()); - let _: Result<(), u32> = bar::schedule(c.start + 20.cycles(), 0); - let _: Result<(), (u32, u32)> = baz::schedule(c.start + 30.cycles(), 0, 1); + fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { + let mut dcb = cx.core.DCB; + let dwt = cx.core.DWT; + let systick = cx.core.SYST; + + let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000); - (init::LateResources {}, init::Monotonics()) + let _: Result<(), ()> = foo::spawn_after(Seconds(1_u32)); + let _: Result<(), u32> = bar::spawn_after(Seconds(2_u32), 0); + let _: Result<(), (u32, u32)> = baz::spawn_after(Seconds(3_u32), 0, 1); + + (init::LateResources {}, init::Monotonics(mono)) } #[idle] fn idle(_: idle::Context) -> ! { - let _: Result<(), ()> = foo::schedule(Instant::now() + 40.cycles()); - let _: Result<(), u32> = bar::schedule(Instant::now() + 50.cycles(), 0); - let _: Result<(), (u32, u32)> = baz::schedule(Instant::now() + 60.cycles(), 0, 1); + let _: Result<(), ()> = foo::spawn_at(MyMono::now() + Seconds(3_u32)); + let _: Result<(), u32> = bar::spawn_at(MyMono::now() + Seconds(4_u32), 0); + let _: Result<(), (u32, u32)> = baz::spawn_at(MyMono::now() + Seconds(5_u32), 0, 1); loop { cortex_m::asm::nop(); } } - #[task(binds = SVCall)] - fn svcall(c: svcall::Context) { - let _: Result<(), ()> = foo::schedule(c.start + 70.cycles()); - let _: Result<(), u32> = bar::schedule(c.start + 80.cycles(), 0); - let _: Result<(), (u32, u32)> = baz::schedule(c.start + 90.cycles(), 0, 1); - } - - #[task(binds = UART0)] - fn uart0(c: uart0::Context) { - let _: Result<(), ()> = foo::schedule(c.start + 100.cycles()); - let _: Result<(), u32> = bar::schedule(c.start + 110.cycles(), 0); - let _: Result<(), (u32, u32)> = baz::schedule(c.start + 120.cycles(), 0, 1); - } - #[task] - fn foo(c: foo::Context) { - let _: Result<(), ()> = foo::schedule(c.scheduled + 130.cycles()); - let _: Result<(), u32> = bar::schedule(c.scheduled + 140.cycles(), 0); - let _: Result<(), (u32, u32)> = baz::schedule(c.scheduled + 150.cycles(), 0, 1); - } + fn foo(_: foo::Context) {} #[task] fn bar(_: bar::Context, _x: u32) {} diff --git a/examples/types.rs b/examples/types.rs index 8411eec..ff7deb8 100644 --- a/examples/types.rs +++ b/examples/types.rs @@ -10,6 +10,13 @@ use panic_semihosting as _; #[rtic::app(device = lm3s6965, peripherals = true, dispatchers = [SSI0])] mod app { use cortex_m_semihosting::debug; + use dwt_systick_monotonic::{ + consts::{U0, U8}, + DwtSystick, + }; + + #[monotonic(binds = SysTick, default = true)] + type MyMono = DwtSystick; // 8 MHz #[resources] struct Resources { @@ -19,13 +26,18 @@ mod app { #[init] fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) { - let _: cyccnt::Instant = cx.start; - let _: rtic::Peripherals = cx.core; + let _: cortex_m::Peripherals = cx.core; let _: lm3s6965::Peripherals = cx.device; debug::exit(debug::EXIT_SUCCESS); - (init::LateResources {}, init::Monotonics()) + let mut dcb = cx.core.DCB; + let dwt = cx.core.DWT; + let systick = cx.core.SYST; + + let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000); + + (init::LateResources {}, init::Monotonics(mono)) } #[idle] @@ -37,13 +49,11 @@ mod app { #[task(binds = UART0, resources = [shared])] fn uart0(cx: uart0::Context) { - let _: cyccnt::Instant = cx.start; let _: resources::shared = cx.resources.shared; } #[task(priority = 2, resources = [shared])] fn foo(cx: foo::Context) { - let _: cyccnt::Instant = cx.scheduled; let _: resources::shared = cx.resources.shared; let _: foo::Resources = cx.resources; } -- cgit v1.2.3 From 612efaf0c436489e1cf09c2e87b329a7318f71b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Wed, 3 Mar 2021 08:53:03 +0100 Subject: Use panic_semihosting for all examples --- examples/big-struct-opt.rs | 2 +- examples/not-sync.rs | 2 +- examples/schedule.rs | 2 +- examples/t-binds.rs | 2 +- examples/t-cfg-resources.rs | 2 +- examples/t-cfg.rs | 2 +- examples/t-late-not-send.rs | 2 +- examples/t-resource.rs | 2 +- examples/t-schedule-core-stable.rs | 2 +- examples/t-schedule.rs | 2 +- examples/t-spawn.rs | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) (limited to 'examples') diff --git a/examples/big-struct-opt.rs b/examples/big-struct-opt.rs index dc6e72f..e6a5c17 100644 --- a/examples/big-struct-opt.rs +++ b/examples/big-struct-opt.rs @@ -6,7 +6,7 @@ #![no_main] #![no_std] -use panic_halt as _; +use panic_semihosting as _; /// Some big struct pub struct BigStruct { diff --git a/examples/not-sync.rs b/examples/not-sync.rs index 8189da5..f01d404 100644 --- a/examples/not-sync.rs +++ b/examples/not-sync.rs @@ -6,7 +6,7 @@ #![no_std] use core::marker::PhantomData; -use panic_halt as _; +use panic_semihosting as _; pub struct NotSync { _0: PhantomData<*const ()>, diff --git a/examples/schedule.rs b/examples/schedule.rs index cdbdc0d..d6d4499 100644 --- a/examples/schedule.rs +++ b/examples/schedule.rs @@ -5,7 +5,7 @@ #![no_main] #![no_std] -use panic_halt as _; +use panic_semihosting as _; // NOTE: does NOT work on QEMU! #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] diff --git a/examples/t-binds.rs b/examples/t-binds.rs index 60afa35..fbc89e8 100644 --- a/examples/t-binds.rs +++ b/examples/t-binds.rs @@ -5,7 +5,7 @@ #![no_main] #![no_std] -use panic_halt as _; +use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { diff --git a/examples/t-cfg-resources.rs b/examples/t-cfg-resources.rs index 990b01f..1adcb90 100644 --- a/examples/t-cfg-resources.rs +++ b/examples/t-cfg-resources.rs @@ -3,7 +3,7 @@ #![no_main] #![no_std] -use panic_halt as _; +use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { diff --git a/examples/t-cfg.rs b/examples/t-cfg.rs index ff06ee8..ef591c4 100644 --- a/examples/t-cfg.rs +++ b/examples/t-cfg.rs @@ -3,7 +3,7 @@ #![no_main] #![no_std] -use panic_halt as _; +use panic_semihosting as _; #[rtic::app(device = lm3s6965, dispatchers = [SSI0, QEI0])] mod app { diff --git a/examples/t-late-not-send.rs b/examples/t-late-not-send.rs index dae0aa9..579f843 100644 --- a/examples/t-late-not-send.rs +++ b/examples/t-late-not-send.rs @@ -5,7 +5,7 @@ use core::marker::PhantomData; -use panic_halt as _; +use panic_semihosting as _; pub struct NotSend { _0: PhantomData<*const ()>, diff --git a/examples/t-resource.rs b/examples/t-resource.rs index 164ea84..6e83069 100644 --- a/examples/t-resource.rs +++ b/examples/t-resource.rs @@ -5,7 +5,7 @@ #![no_main] #![no_std] -use panic_halt as _; +use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { diff --git a/examples/t-schedule-core-stable.rs b/examples/t-schedule-core-stable.rs index adcc0b6..98d42ce 100644 --- a/examples/t-schedule-core-stable.rs +++ b/examples/t-schedule-core-stable.rs @@ -5,7 +5,7 @@ #![no_main] #![no_std] -use panic_halt as _; +use panic_semihosting as _; #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs index 259b226..bd0ab66 100644 --- a/examples/t-schedule.rs +++ b/examples/t-schedule.rs @@ -5,7 +5,7 @@ #![no_main] #![no_std] -use panic_halt as _; +use panic_semihosting as _; #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { diff --git a/examples/t-spawn.rs b/examples/t-spawn.rs index cc7754e..ca5c61b 100644 --- a/examples/t-spawn.rs +++ b/examples/t-spawn.rs @@ -5,7 +5,7 @@ #![no_main] #![no_std] -use panic_halt as _; +use panic_semihosting as _; #[rtic::app(device = lm3s6965, dispatchers = [SSI0])] mod app { -- cgit v1.2.3