rtic/examples/binds.rs

47 lines
885 B
Rust
Raw Normal View History

2019-02-23 22:20:30 +01:00
//! examples/binds.rs
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
use lm3s6965::Interrupt;
use panic_semihosting as _;
2019-02-23 22:20:30 +01:00
// `examples/interrupt.rs` rewritten to use `binds`
2019-04-21 20:10:40 +02:00
#[rtfm::app(device = lm3s6965)]
2019-02-23 22:20:30 +01:00
const APP: () = {
#[init]
2019-04-21 20:10:40 +02:00
fn init(_: init::Context) {
2019-02-23 22:20:30 +01:00
rtfm::pend(Interrupt::UART0);
hprintln!("init").unwrap();
}
#[idle]
2019-04-21 20:10:40 +02:00
fn idle(_: idle::Context) -> ! {
2019-02-23 22:20:30 +01:00
hprintln!("idle").unwrap();
rtfm::pend(Interrupt::UART0);
debug::exit(debug::EXIT_SUCCESS);
loop {}
}
#[interrupt(binds = UART0)]
2019-04-21 20:10:40 +02:00
fn foo(_: foo::Context) {
2019-02-23 22:20:30 +01:00
static mut TIMES: u32 = 0;
*TIMES += 1;
hprintln!(
"foo called {} time{}",
*TIMES,
if *TIMES > 1 { "s" } else { "" }
)
.unwrap();
}
};