rtic/examples/systic.rs

42 lines
875 B
Rust
Raw Permalink Normal View History

2020-09-29 23:07:37 +02:00
//! examples/systic.rs
#![deny(unsafe_code)]
#![deny(warnings)]
#![no_main]
#![no_std]
use cortex_m_semihosting::{debug, hprintln};
2020-09-29 23:10:50 +02:00
// use lm3s6965::Interrupt;
2020-09-29 23:07:37 +02:00
use panic_semihosting as _;
#[rtic::app(device = lm3s6965)]
const APP: () = {
#[init]
fn init(cx: init::Context) {
let mut syst = cx.core.SYST;
2020-09-29 23:12:19 +02:00
syst.set_reload(100000);
2020-09-29 23:07:37 +02:00
syst.enable_interrupt();
syst.enable_counter();
hprintln!("init").unwrap();
}
#[idle]
fn idle(_: idle::Context) -> ! {
hprintln!("idle").unwrap();
loop {
cortex_m::asm::nop();
}
}
#[task(binds = SysTick)]
fn t(_: t::Context) {
static mut COUNTER: i32 = 0;
*COUNTER += 1;
hprintln!("SysTick #{}", COUNTER).unwrap();
2020-09-29 23:10:50 +02:00
if *COUNTER == 10 {
2020-09-29 23:07:37 +02:00
debug::exit(debug::EXIT_SUCCESS);
}
}
};