diff options
| author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-26 22:26:52 +0000 |
|---|---|---|
| committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-02-26 22:26:52 +0000 |
| commit | 6d1d84980a1f3212164dda5a890a90efd3c8583d (patch) | |
| tree | ee9aa60d3c109b4583299cf6a71277507a4be241 /examples | |
| parent | bbdc3221f6a76da5784ca0017a0f5ac1ca875597 (diff) | |
| parent | 8eccef7d9cda8a60594b86d31b656a3680d1ca16 (diff) | |
Merge #158
158: implement RFC #128: #[interrupt(binds = ..)] r=korken89 a=japaric
closes #128
r? @korken89 or @TeXitoi
suggestions for tests are welcome! (2 of the 3 tests I added hit bugs in my implementation)
Co-authored-by: Jorge Aparicio <jorge@japaric.io>
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/binds.rs | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/examples/binds.rs b/examples/binds.rs new file mode 100644 index 0000000..a8b386f --- /dev/null +++ b/examples/binds.rs @@ -0,0 +1,48 @@ +//! examples/binds.rs + +#![deny(unsafe_code)] +#![deny(warnings)] +#![no_main] +#![no_std] + +extern crate panic_semihosting; + +use cortex_m_semihosting::{debug, hprintln}; +use lm3s6965::Interrupt; +use rtfm::app; + +// `examples/interrupt.rs` rewritten to use `binds` +#[app(device = lm3s6965)] +const APP: () = { + #[init] + fn init() { + rtfm::pend(Interrupt::UART0); + + hprintln!("init").unwrap(); + } + + #[idle] + fn idle() -> ! { + hprintln!("idle").unwrap(); + + rtfm::pend(Interrupt::UART0); + + debug::exit(debug::EXIT_SUCCESS); + + loop {} + } + + #[interrupt(binds = UART0)] + fn foo() { + static mut TIMES: u32 = 0; + + *TIMES += 1; + + hprintln!( + "foo called {} time{}", + *TIMES, + if *TIMES > 1 { "s" } else { "" } + ) + .unwrap(); + } +}; |
