mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-27 14:04:56 +01:00
systic example for qemu
This commit is contained in:
parent
4d61437bb4
commit
43f11812a1
1 changed files with 41 additions and 0 deletions
41
examples/systic.rs
Normal file
41
examples/systic.rs
Normal file
|
@ -0,0 +1,41 @@
|
|||
//! examples/systic.rs
|
||||
|
||||
#![deny(unsafe_code)]
|
||||
#![deny(warnings)]
|
||||
#![no_main]
|
||||
#![no_std]
|
||||
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
use panic_semihosting as _;
|
||||
|
||||
#[rtic::app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init(cx: init::Context) {
|
||||
let mut syst = cx.core.SYST;
|
||||
syst.set_reload(1000);
|
||||
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();
|
||||
if *C == 10 {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue