diff options
| author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-16 21:05:56 +0000 |
|---|---|---|
| committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-12-16 21:05:56 +0000 |
| commit | 3511e915b5261ca11928ced3c05fa5ce1cabb138 (patch) | |
| tree | 46081c204b0424802ed88ce61f6e750105aa91e2 /examples | |
| parent | c2fbb2848851e32b78e79ff9e919538b7d5ab8a0 (diff) | |
| parent | 22140fbc49b16e422652542371d3b389b2a5fbeb (diff) | |
Merge #116
116: v0.4.0 r=japaric a=japaric
Co-authored-by: Jorge Aparicio <jorge@japaric.io>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/cfg.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/examples/cfg.rs b/examples/cfg.rs new file mode 100644 index 0000000..3f4ca90 --- /dev/null +++ b/examples/cfg.rs @@ -0,0 +1,54 @@ +//! examples/cfg.rs + +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +extern crate panic_semihosting; + +#[cfg(debug_assertions)] +use cortex_m_semihosting::hprintln; +use rtfm::app; + +#[app(device = lm3s6965)] +const APP: () = { + #[cfg(debug_assertions)] // <- `true` when using the `dev` profile + static mut COUNT: u32 = 0; + + #[init] + fn init() { + // .. + } + + #[task(priority = 3, resources = [COUNT], spawn = [log])] + fn foo() { + #[cfg(debug_assertions)] + { + *resources.COUNT += 1; + + spawn.log(*resources.COUNT).ok(); + } + + // this wouldn't compile in `release` mode + // *resources.COUNT += 1; + + // .. + } + + #[cfg(debug_assertions)] + #[task] + fn log(n: u32) { + hprintln!( + "foo has been called {} time{}", + n, + if n == 1 { "" } else { "s" } + ) + .ok(); + } + + extern "C" { + fn UART0(); + fn UART1(); + } +}; |
