diff options
| author | Emil Fresk <emil.fresk@gmail.com> | 2020-10-15 18:50:17 +0200 |
|---|---|---|
| committer | Emil Fresk <emil.fresk@gmail.com> | 2020-10-21 20:25:05 +0200 |
| commit | f96b25fdf2d7421cc16830a4ccac4ebb3e69cc5d (patch) | |
| tree | a782f21ca0659eda6b9b667e197c4927490a7bc4 /examples | |
| parent | 355cb82d0693fe108ac28ec8a0d77e8aab4e6e06 (diff) | |
Updated examples
More work
Diffstat (limited to 'examples')
36 files changed, 101 insertions, 77 deletions
diff --git a/examples/baseline.rs b/examples/baseline.rs index 0b7e3ea..82f1887 100644 --- a/examples/baseline.rs +++ b/examples/baseline.rs @@ -5,13 +5,14 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; -use lm3s6965::Interrupt; use panic_semihosting as _; // NOTE: does NOT properly work on QEMU #[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + use lm3s6965::Interrupt; + #[init] fn init(cx: init::Context) -> init::LateResources { // omitted: initialization of `CYCCNT` diff --git a/examples/binds.rs b/examples/binds.rs index 42010ae..f681aa5 100644 --- a/examples/binds.rs +++ b/examples/binds.rs @@ -5,13 +5,14 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; -use lm3s6965::Interrupt; use panic_semihosting as _; // `examples/interrupt.rs` rewritten to use `binds` #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + use lm3s6965::Interrupt; + #[init] fn init(_: init::Context) -> init::LateResources { rtic::pend(Interrupt::UART0); diff --git a/examples/capacity.rs b/examples/capacity.rs index f903acb..29b4f04 100644 --- a/examples/capacity.rs +++ b/examples/capacity.rs @@ -5,12 +5,13 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; -use lm3s6965::Interrupt; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + use lm3s6965::Interrupt; + #[init] fn init(_: init::Context) -> init::LateResources { rtic::pend(Interrupt::UART0); diff --git a/examples/cfg.rs b/examples/cfg.rs index c8892ea..f900286 100644 --- a/examples/cfg.rs +++ b/examples/cfg.rs @@ -5,13 +5,14 @@ #![no_main] #![no_std] -use cortex_m_semihosting::debug; -#[cfg(debug_assertions)] -use cortex_m_semihosting::hprintln; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::debug; + #[cfg(debug_assertions)] + use cortex_m_semihosting::hprintln; + #[resources] struct Resources { #[cfg(debug_assertions)] // <- `true` when using the `dev` profile diff --git a/examples/destructure.rs b/examples/destructure.rs index e7c5323..3c5eabf 100644 --- a/examples/destructure.rs +++ b/examples/destructure.rs @@ -5,12 +5,13 @@ #![no_main] #![no_std] -use cortex_m_semihosting::hprintln; -use lm3s6965::Interrupt; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::hprintln; + use lm3s6965::Interrupt; + #[resources] struct Resources { // Some resources to work with diff --git a/examples/double_schedule.rs b/examples/double_schedule.rs index d242c57..78eaac4 100644 --- a/examples/double_schedule.rs +++ b/examples/double_schedule.rs @@ -6,10 +6,10 @@ #![no_std] use panic_semihosting as _; -use rtic::cyccnt::U32Ext; #[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)] mod app { + use rtic::cyccnt::U32Ext; #[resources] struct Resources { diff --git a/examples/generics.rs b/examples/generics.rs index 3107dd1..b13baeb 100644 --- a/examples/generics.rs +++ b/examples/generics.rs @@ -5,13 +5,16 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; -use lm3s6965::Interrupt; +use cortex_m_semihosting::hprintln; use panic_semihosting as _; -use rtic::{Exclusive, Mutex}; +use rtic::Mutex; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + use lm3s6965::Interrupt; + use rtic::Exclusive; + #[resources] struct Resources { #[init(0)] diff --git a/examples/hardware.rs b/examples/hardware.rs index f6a2d37..99e8da2 100644 --- a/examples/hardware.rs +++ b/examples/hardware.rs @@ -5,12 +5,13 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; -use lm3s6965::Interrupt; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + use lm3s6965::Interrupt; + #[init] fn init(_: init::Context) -> init::LateResources { // Pends the UART0 interrupt but its handler won't run until *after* diff --git a/examples/idle.rs b/examples/idle.rs index 58c3c87..1aac56c 100644 --- a/examples/idle.rs +++ b/examples/idle.rs @@ -5,11 +5,12 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + #[init] fn init(_: init::Context) -> init::LateResources { hprintln!("init").unwrap(); diff --git a/examples/init.rs b/examples/init.rs index 6ac284a..ca67a2b 100644 --- a/examples/init.rs +++ b/examples/init.rs @@ -5,11 +5,12 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; use panic_semihosting as _; #[rtic::app(device = lm3s6965, peripherals = true)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + #[init] fn init(cx: init::Context) -> init::LateResources { static mut X: u32 = 0; diff --git a/examples/late.rs b/examples/late.rs index 761c68f..d20a69c 100644 --- a/examples/late.rs +++ b/examples/late.rs @@ -5,21 +5,18 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; -use heapless::{ - consts::*, - i, - spsc::{Consumer, Producer, Queue}, -}; -use lm3s6965::Interrupt; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; use heapless::{ consts::*, - spsc::{Consumer, Producer}, + i, + spsc::{Consumer, Producer, Queue}, }; + use lm3s6965::Interrupt; + // Late resources #[resources] struct Resources { diff --git a/examples/lock.rs b/examples/lock.rs index 669b1ae..c4930a2 100644 --- a/examples/lock.rs +++ b/examples/lock.rs @@ -5,12 +5,13 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; -use lm3s6965::Interrupt; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + use lm3s6965::Interrupt; + #[resources] struct Resources { #[init(0)] diff --git a/examples/message.rs b/examples/message.rs index 5ff6288..4306430 100644 --- a/examples/message.rs +++ b/examples/message.rs @@ -5,11 +5,12 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + #[init] fn init(_: init::Context) -> init::LateResources { foo::spawn(/* no message */).unwrap(); diff --git a/examples/not-sync.rs b/examples/not-sync.rs index 75412e6..d2616ee 100644 --- a/examples/not-sync.rs +++ b/examples/not-sync.rs @@ -6,8 +6,6 @@ #![no_std] use core::marker::PhantomData; - -use cortex_m_semihosting::debug; use panic_halt as _; pub struct NotSync { @@ -18,6 +16,7 @@ pub struct NotSync { mod app { use super::NotSync; use core::marker::PhantomData; + use cortex_m_semihosting::debug; #[resources] struct Resources { diff --git a/examples/only-shared-access.rs b/examples/only-shared-access.rs index 91d0b7a..8d42fd4 100644 --- a/examples/only-shared-access.rs +++ b/examples/only-shared-access.rs @@ -5,12 +5,13 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; -use lm3s6965::Interrupt; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + use lm3s6965::Interrupt; + #[resources] struct Resources { key: u32, diff --git a/examples/periodic.rs b/examples/periodic.rs index 95cd145..eedf720 100644 --- a/examples/periodic.rs +++ b/examples/periodic.rs @@ -5,15 +5,15 @@ #![no_main] #![no_std] -use cortex_m_semihosting::hprintln; use panic_semihosting as _; -use rtic::cyccnt::{Instant, U32Ext}; - -const PERIOD: u32 = 8_000_000; // NOTE: does NOT work on QEMU! #[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)] mod app { + use cortex_m_semihosting::hprintln; + use rtic::cyccnt::{Instant, U32Ext}; + + const PERIOD: u32 = 8_000_000; #[init] fn init(cx: init::Context) -> init::LateResources { diff --git a/examples/peripherals-taken.rs b/examples/peripherals-taken.rs index 09f9242..98f06b0 100644 --- a/examples/peripherals-taken.rs +++ b/examples/peripherals-taken.rs @@ -3,11 +3,12 @@ #![no_main] #![no_std] -use cortex_m_semihosting::debug; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::debug; + #[init] fn init(_: init::Context) -> init::LateResources { assert!(cortex_m::Peripherals::take().is_none()); diff --git a/examples/pool.rs b/examples/pool.rs index 2ad9984..fc740fe 100644 --- a/examples/pool.rs +++ b/examples/pool.rs @@ -5,12 +5,10 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; use heapless::{ pool, pool::singleton::{Box, Pool}, }; -use lm3s6965::Interrupt; use panic_semihosting as _; use rtic::app; @@ -19,7 +17,9 @@ pool!(P: [u8; 128]); #[app(device = lm3s6965)] mod app { - use crate::Box; + use crate::{Box, Pool}; + use cortex_m_semihosting::{debug, hprintln}; + use lm3s6965::Interrupt; // Import the memory pool into scope use super::P; diff --git a/examples/preempt.rs b/examples/preempt.rs index f6fc4b0..ee75c46 100644 --- a/examples/preempt.rs +++ b/examples/preempt.rs @@ -3,13 +3,14 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; -use lm3s6965::Interrupt; use panic_semihosting as _; use rtic::app; #[app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + use lm3s6965::Interrupt; + #[init] fn init(_: init::Context) -> init::LateResources { rtic::pend(Interrupt::GPIOA); diff --git a/examples/ramfunc.rs b/examples/ramfunc.rs index 84d633d..4d46c6d 100644 --- a/examples/ramfunc.rs +++ b/examples/ramfunc.rs @@ -5,11 +5,12 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + #[init] fn init(_: init::Context) -> init::LateResources { foo::spawn().unwrap(); diff --git a/examples/resource-user-struct.rs b/examples/resource-user-struct.rs index a5bd0dd..ca4ca2a 100644 --- a/examples/resource-user-struct.rs +++ b/examples/resource-user-struct.rs @@ -5,12 +5,13 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; -use lm3s6965::Interrupt; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + use lm3s6965::Interrupt; + #[resources] struct Resources { // A resource diff --git a/examples/resource.rs b/examples/resource.rs index 273af26..87ba336 100644 --- a/examples/resource.rs +++ b/examples/resource.rs @@ -5,12 +5,13 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; -use lm3s6965::Interrupt; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + use lm3s6965::Interrupt; + #[resources] struct Resources { // A resource diff --git a/examples/schedule.rs b/examples/schedule.rs index fa67a56..f57f53f 100644 --- a/examples/schedule.rs +++ b/examples/schedule.rs @@ -5,14 +5,15 @@ #![no_main] #![no_std] -use cortex_m::peripheral::DWT; -use cortex_m_semihosting::hprintln; use panic_halt as _; -use rtic::cyccnt::{Instant, U32Ext as _}; // NOTE: does NOT work on QEMU! #[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)] 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 { // Initialize (enable) the monotonic timer (CYCCNT) diff --git a/examples/shared-with-init.rs b/examples/shared-with-init.rs index 85c7276..049a38b 100644 --- a/examples/shared-with-init.rs +++ b/examples/shared-with-init.rs @@ -5,8 +5,6 @@ #![no_main] #![no_std] -use cortex_m_semihosting::debug; -use lm3s6965::Interrupt; use panic_halt as _; use rtic::app; @@ -14,6 +12,8 @@ pub struct MustBeSend; #[app(device = lm3s6965)] mod app { + use cortex_m_semihosting::debug; + use lm3s6965::Interrupt; use super::MustBeSend; #[resources] diff --git a/examples/spawn.rs b/examples/spawn.rs index 041018a..300b3b3 100644 --- a/examples/spawn.rs +++ b/examples/spawn.rs @@ -5,11 +5,12 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + #[init] fn init(_c: init::Context) -> init::LateResources { foo::spawn(1, 2).unwrap(); diff --git a/examples/spawn2.rs b/examples/spawn2.rs index b50a3ee..070223b 100644 --- a/examples/spawn2.rs +++ b/examples/spawn2.rs @@ -5,11 +5,12 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + #[init] fn init(_c: init::Context) -> init::LateResources { foo::spawn(1, 2).unwrap(); diff --git a/examples/static.rs b/examples/static.rs index 9c3110c..cd46145 100644 --- a/examples/static.rs +++ b/examples/static.rs @@ -5,20 +5,18 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; -use heapless::{ - consts::*, - i, - spsc::{Consumer, Producer, Queue}, -}; -use lm3s6965::Interrupt; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { - use crate::U4; - use crate::{Consumer, Producer}; + use cortex_m_semihosting::{debug, hprintln}; + use heapless::{ + consts::*, + i, + spsc::{Consumer, Producer, Queue}, + }; + use lm3s6965::Interrupt; // Late resources #[resources] diff --git a/examples/t-binds.rs b/examples/t-binds.rs index 3ca4c66..8d52f58 100644 --- a/examples/t-binds.rs +++ b/examples/t-binds.rs @@ -17,18 +17,18 @@ mod app { // Cortex-M exception #[task(binds = SVCall)] fn foo(c: foo::Context) { - foo_trampoline(c) + crate::foo_trampoline(c) } // LM3S6965 interrupt #[task(binds = UART0)] fn bar(c: bar::Context) { - bar_trampoline(c) + crate::bar_trampoline(c) } } #[allow(dead_code)] -fn foo_trampoline(_: foo::Context) {} +fn foo_trampoline(_: app::foo::Context) {} #[allow(dead_code)] -fn bar_trampoline(_: bar::Context) {} +fn bar_trampoline(_: app::bar::Context) {} diff --git a/examples/t-htask-main.rs b/examples/t-htask-main.rs index 1e38e31..57076ec 100644 --- a/examples/t-htask-main.rs +++ b/examples/t-htask-main.rs @@ -3,11 +3,12 @@ #![no_main] #![no_std] -use cortex_m_semihosting::debug; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::debug; + #[init] fn init(_: init::Context) -> init::LateResources { rtic::pend(lm3s6965::Interrupt::UART0); diff --git a/examples/t-idle-main.rs b/examples/t-idle-main.rs index 9078628..42dac90 100644 --- a/examples/t-idle-main.rs +++ b/examples/t-idle-main.rs @@ -3,11 +3,12 @@ #![no_main] #![no_std] -use cortex_m_semihosting::debug; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::debug; + #[init] fn init(_: init::Context) -> init::LateResources { init::LateResources {} diff --git a/examples/t-init-main.rs b/examples/t-init-main.rs index 7c23cc8..0456e87 100644 --- a/examples/t-init-main.rs +++ b/examples/t-init-main.rs @@ -3,11 +3,12 @@ #![no_main] #![no_std] -use cortex_m_semihosting::debug; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::debug; + #[init] fn init(_: init::Context) -> init::LateResources { debug::exit(debug::EXIT_SUCCESS); diff --git a/examples/t-late-not-send.rs b/examples/t-late-not-send.rs index 345d9ae..8b7b986 100644 --- a/examples/t-late-not-send.rs +++ b/examples/t-late-not-send.rs @@ -14,6 +14,7 @@ pub struct NotSend { #[rtic::app(device = lm3s6965)] mod app { use super::NotSend; + use core::marker::PhantomData; #[resources] struct Resources { diff --git a/examples/t-schedule.rs b/examples/t-schedule.rs index 7c2c420..b1faaa6 100644 --- a/examples/t-schedule.rs +++ b/examples/t-schedule.rs @@ -6,10 +6,11 @@ #![no_std] use panic_halt as _; -use rtic::cyccnt::{Instant, U32Ext as _}; #[rtic::app(device = lm3s6965, monotonic = rtic::cyccnt::CYCCNT)] mod app { + use rtic::cyccnt::{Instant, U32Ext as _}; + #[init] fn init(c: init::Context) -> init::LateResources { let _: Result<(), ()> = foo::schedule(c.start + 10.cycles()); diff --git a/examples/t-stask-main.rs b/examples/t-stask-main.rs index 3337c7d..56dc1af 100644 --- a/examples/t-stask-main.rs +++ b/examples/t-stask-main.rs @@ -3,11 +3,12 @@ #![no_main] #![no_std] -use cortex_m_semihosting::debug; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::debug; + #[init] fn init(_: init::Context) -> init::LateResources { taskmain::spawn().ok(); diff --git a/examples/task.rs b/examples/task.rs index f3d916f..60591b9 100644 --- a/examples/task.rs +++ b/examples/task.rs @@ -5,11 +5,12 @@ #![no_main] #![no_std] -use cortex_m_semihosting::{debug, hprintln}; use panic_semihosting as _; #[rtic::app(device = lm3s6965)] mod app { + use cortex_m_semihosting::{debug, hprintln}; + #[init] fn init(_: init::Context) -> init::LateResources { foo::spawn().unwrap(); diff --git a/examples/types.rs b/examples/types.rs index b55a98c..815d309 100644 --- a/examples/types.rs +++ b/examples/types.rs @@ -5,12 +5,13 @@ #![no_main] #![no_std] -use cortex_m_semihosting::debug; use panic_semihosting as _; -use rtic::cyccnt; #[rtic::app(device = lm3s6965, peripherals = true, monotonic = rtic::cyccnt::CYCCNT)] mod app { + use cortex_m_semihosting::debug; + use rtic::cyccnt; + #[resources] struct Resources { #[init(0)] |
