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;
|
2019-06-13 23:56:59 +02:00
|
|
|
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 {}
|
|
|
|
}
|
|
|
|
|
2019-06-20 06:19:59 +02:00
|
|
|
#[task(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();
|
|
|
|
}
|
|
|
|
};
|