aboutsummaryrefslogtreecommitdiff
path: root/examples/cfg.rs
diff options
context:
space:
mode:
authorJorge Aparicio <jorge@japaric.io>2019-08-21 10:17:27 +0200
committerJorge Aparicio <jorge@japaric.io>2019-08-21 10:17:27 +0200
commit07b2b4d83078d0fd260d5f0812e8d5a34d02b793 (patch)
treedba2a8e8316e8cd868ccb7b46a80d63c5f61a224 /examples/cfg.rs
parent0e146f8d1142672725b6abb38478f503a9261c80 (diff)
doc up
Diffstat (limited to 'examples/cfg.rs')
-rw-r--r--examples/cfg.rs27
1 files changed, 18 insertions, 9 deletions
diff --git a/examples/cfg.rs b/examples/cfg.rs
index fb812cb..2a43b5c 100644
--- a/examples/cfg.rs
+++ b/examples/cfg.rs
@@ -5,6 +5,7 @@
#![no_main]
#![no_std]
+use cortex_m_semihosting::debug;
#[cfg(debug_assertions)]
use cortex_m_semihosting::hprintln;
use panic_semihosting as _;
@@ -17,28 +18,36 @@ const APP: () = {
count: u32,
}
- #[init]
- fn init(_: init::Context) {
- // ..
+ #[init(spawn = [foo])]
+ fn init(cx: init::Context) {
+ cx.spawn.foo().unwrap();
+ cx.spawn.foo().unwrap();
+ }
+
+ #[idle]
+ fn idle(_: idle::Context) -> ! {
+ debug::exit(debug::EXIT_SUCCESS);
+
+ loop {}
}
- #[task(priority = 3, resources = [count], spawn = [log])]
- fn foo(_c: foo::Context) {
+ #[task(capacity = 2, resources = [count], spawn = [log])]
+ fn foo(_cx: foo::Context) {
#[cfg(debug_assertions)]
{
- *_c.resources.count += 1;
+ *_cx.resources.count += 1;
- _c.spawn.log(*_c.resources.count).ok();
+ _cx.spawn.log(*_cx.resources.count).unwrap();
}
// this wouldn't compile in `release` mode
- // *resources.count += 1;
+ // *_cx.resources.count += 1;
// ..
}
#[cfg(debug_assertions)]
- #[task]
+ #[task(capacity = 2)]
fn log(_: log::Context, n: u32) {
hprintln!(
"foo has been called {} time{}",