diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/periodic.rs | 2 | ||||
| -rw-r--r-- | examples/t-cfg-resources.rs | 52 | ||||
| -rw-r--r-- | examples/t-htask-main.rs | 20 | ||||
| -rw-r--r-- | examples/t-idle-main.rs | 20 | ||||
| -rw-r--r-- | examples/t-init-main.rs | 15 | ||||
| -rw-r--r-- | examples/t-stask-main.rs | 24 |
6 files changed, 104 insertions, 29 deletions
diff --git a/examples/periodic.rs b/examples/periodic.rs index dca0ad5..3d32bc2 100644 --- a/examples/periodic.rs +++ b/examples/periodic.rs @@ -18,7 +18,7 @@ const APP: () = { fn init(cx: init::Context) { // omitted: initialization of `CYCCNT` - cx.schedule.foo(Instant::now() + PERIOD.cycles()).unwrap(); + cx.schedule.foo(cx.start + PERIOD.cycles()).unwrap(); } #[task(schedule = [foo])] diff --git a/examples/t-cfg-resources.rs b/examples/t-cfg-resources.rs index 63c4124..a8efe79 100644 --- a/examples/t-cfg-resources.rs +++ b/examples/t-cfg-resources.rs @@ -5,36 +5,32 @@ use panic_halt as _; -#[cfg(rustc_is_nightly)] -mod example { +#[rtfm::app(device = lm3s6965)] +const APP: () = { + struct Resources { + // A resource + #[init(0)] + shared: u32, - #[rtfm::app(device = lm3s6965)] - const APP: () = { - struct Resources { - // A resource - #[init(0)] - shared: u32, + // A conditionally compiled resource behind feature_x + #[cfg(feature = "feature_x")] + x: u32, - // A conditionally compiled resource behind feature_x - #[cfg(feature = "feature_x")] - x: u32, - - dummy: (), - } + dummy: (), + } - #[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 - } + #[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 } + } - #[idle] - fn idle(_cx: idle::Context) -> ! { - loop {} - } - }; -} + #[idle] + fn idle(_cx: idle::Context) -> ! { + loop {} + } +}; diff --git a/examples/t-htask-main.rs b/examples/t-htask-main.rs new file mode 100644 index 0000000..d229d81 --- /dev/null +++ b/examples/t-htask-main.rs @@ -0,0 +1,20 @@ +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +use cortex_m_semihosting::debug; +use panic_semihosting as _; + +#[rtfm::app(device = lm3s6965)] +const APP: () = { + #[init] + fn init(_: init::Context) { + rtfm::pend(lm3s6965::Interrupt::UART0) + } + + #[task(binds = UART0)] + fn main(_: main::Context) { + debug::exit(debug::EXIT_SUCCESS); + } +}; diff --git a/examples/t-idle-main.rs b/examples/t-idle-main.rs new file mode 100644 index 0000000..d1bb148 --- /dev/null +++ b/examples/t-idle-main.rs @@ -0,0 +1,20 @@ +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +use cortex_m_semihosting::debug; +use panic_semihosting as _; + +#[rtfm::app(device = lm3s6965)] +const APP: () = { + #[init] + fn init(_: init::Context) { + } + + #[idle] + fn main(_: main::Context) -> ! { + debug::exit(debug::EXIT_SUCCESS); + loop {} + } +}; diff --git a/examples/t-init-main.rs b/examples/t-init-main.rs new file mode 100644 index 0000000..e0d94d5 --- /dev/null +++ b/examples/t-init-main.rs @@ -0,0 +1,15 @@ +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +use cortex_m_semihosting::debug; +use panic_semihosting as _; + +#[rtfm::app(device = lm3s6965)] +const APP: () = { + #[init] + fn main(_: main::Context) { + debug::exit(debug::EXIT_SUCCESS); + } +}; diff --git a/examples/t-stask-main.rs b/examples/t-stask-main.rs new file mode 100644 index 0000000..b55161e --- /dev/null +++ b/examples/t-stask-main.rs @@ -0,0 +1,24 @@ +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +use cortex_m_semihosting::debug; +use panic_semihosting as _; + +#[rtfm::app(device = lm3s6965)] +const APP: () = { + #[init(spawn = [main])] + fn init(cx: init::Context) { + cx.spawn.main().ok(); + } + + #[task] + fn main(_: main::Context) { + debug::exit(debug::EXIT_SUCCESS); + } + + extern "C" { + fn UART0(); + } +}; |
