mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
use new cortex_m_semihosting::hprintln macro
This commit is contained in:
parent
22d758ddac
commit
a279218295
17 changed files with 56 additions and 217 deletions
|
@ -42,7 +42,7 @@ owned-singleton = "0.1.0"
|
|||
|
||||
[dev-dependencies]
|
||||
alloc-singleton = "0.1.0"
|
||||
cortex-m-semihosting = "0.3.1"
|
||||
cortex-m-semihosting = "0.3.2"
|
||||
lm3s6965 = "0.1.3"
|
||||
panic-halt = "0.2.0"
|
||||
|
||||
|
|
|
@ -7,26 +7,16 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
use rtfm::app;
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// NOTE: does NOT properly work on QEMU
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init(spawn = [foo])]
|
||||
fn init() {
|
||||
println!("init(baseline = {:?})", start);
|
||||
hprintln!("init(baseline = {:?})", start).unwrap();
|
||||
|
||||
// `foo` inherits the baseline of `init`: `Instant(0)`
|
||||
spawn.foo().unwrap();
|
||||
|
@ -36,7 +26,7 @@ const APP: () = {
|
|||
fn foo() {
|
||||
static mut ONCE: bool = true;
|
||||
|
||||
println!("foo(baseline = {:?})", scheduled);
|
||||
hprintln!("foo(baseline = {:?})", scheduled).unwrap();
|
||||
|
||||
if *ONCE {
|
||||
*ONCE = false;
|
||||
|
@ -49,7 +39,7 @@ const APP: () = {
|
|||
|
||||
#[interrupt(spawn = [foo])]
|
||||
fn UART0() {
|
||||
println!("UART0(baseline = {:?})", start);
|
||||
hprintln!("UART0(baseline = {:?})", start).unwrap();
|
||||
|
||||
// `foo` inherits the baseline of `UART0`: its `start` time
|
||||
spawn.foo().unwrap();
|
||||
|
|
|
@ -7,20 +7,10 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
use rtfm::app;
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
|
@ -40,12 +30,12 @@ const APP: () = {
|
|||
|
||||
#[task(capacity = 4)]
|
||||
fn foo(x: u32) {
|
||||
println!("foo({})", x);
|
||||
hprintln!("foo({})", x).unwrap();
|
||||
}
|
||||
|
||||
#[task]
|
||||
fn bar() {
|
||||
println!("bar");
|
||||
hprintln!("bar").unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -7,22 +7,10 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
use rtfm::{app, Mutex};
|
||||
|
||||
// NOTE: This convenience macro will appear in all the other examples and
|
||||
// will always look the same
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
static mut SHARED: u32 = 0;
|
||||
|
@ -37,7 +25,7 @@ const APP: () = {
|
|||
fn UART0() {
|
||||
static mut STATE: u32 = 0;
|
||||
|
||||
println!("UART0(STATE = {})", *STATE);
|
||||
hprintln!("UART0(STATE = {})", *STATE).unwrap();
|
||||
|
||||
advance(STATE, resources.SHARED);
|
||||
|
||||
|
@ -50,7 +38,7 @@ const APP: () = {
|
|||
fn UART1() {
|
||||
static mut STATE: u32 = 0;
|
||||
|
||||
println!("UART1(STATE = {})", *STATE);
|
||||
hprintln!("UART1(STATE = {})", *STATE).unwrap();
|
||||
|
||||
// just to show that `SHARED` can be accessed directly and ..
|
||||
*resources.SHARED += 0;
|
||||
|
@ -70,5 +58,5 @@ fn advance(state: &mut u32, mut shared: impl Mutex<T = u32>) {
|
|||
(old, *shared)
|
||||
});
|
||||
|
||||
println!("SHARED: {} -> {}", old, new);
|
||||
hprintln!("SHARED: {} -> {}", old, new).unwrap();
|
||||
}
|
||||
|
|
|
@ -7,24 +7,14 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use rtfm::app;
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
fn init() {
|
||||
println!("init");
|
||||
hprintln!("init").unwrap();
|
||||
}
|
||||
|
||||
#[idle]
|
||||
|
@ -34,7 +24,7 @@ const APP: () = {
|
|||
// Safe access to local `static mut` variable
|
||||
let _x: &'static mut u32 = X;
|
||||
|
||||
println!("idle");
|
||||
hprintln!("idle").unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
||||
|
|
|
@ -7,21 +7,9 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use rtfm::app;
|
||||
|
||||
// NOTE: This convenience macro will appear in all the other examples and
|
||||
// will always look the same
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
|
@ -37,7 +25,7 @@ const APP: () = {
|
|||
// Safe access to local `static mut` variable
|
||||
let _x: &'static mut u32 = X;
|
||||
|
||||
println!("init");
|
||||
hprintln!("init").unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -7,20 +7,10 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
use rtfm::app;
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init]
|
||||
|
@ -29,14 +19,14 @@ const APP: () = {
|
|||
// `init` returns because interrupts are disabled
|
||||
rtfm::pend(Interrupt::UART0);
|
||||
|
||||
println!("init");
|
||||
hprintln!("init").unwrap();
|
||||
}
|
||||
|
||||
#[idle]
|
||||
fn idle() -> ! {
|
||||
// interrupts are enabled again; the `UART0` handler runs at this point
|
||||
|
||||
println!("idle");
|
||||
hprintln!("idle").unwrap();
|
||||
|
||||
rtfm::pend(Interrupt::UART0);
|
||||
|
||||
|
@ -52,10 +42,11 @@ const APP: () = {
|
|||
// Safe access to local `static mut` variable
|
||||
*TIMES += 1;
|
||||
|
||||
println!(
|
||||
hprintln!(
|
||||
"UART0 called {} time{}",
|
||||
*TIMES,
|
||||
if *TIMES > 1 { "s" } else { "" }
|
||||
);
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use heapless::{
|
||||
consts::*,
|
||||
spsc::{Consumer, Producer, Queue},
|
||||
|
@ -15,16 +15,6 @@ use heapless::{
|
|||
use lm3s6965::Interrupt;
|
||||
use rtfm::app;
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
// Late resources
|
||||
|
@ -49,7 +39,7 @@ const APP: () = {
|
|||
fn idle() -> ! {
|
||||
loop {
|
||||
if let Some(byte) = resources.C.dequeue() {
|
||||
println!("received message: {}", byte);
|
||||
hprintln!("received message: {}", byte).unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
} else {
|
||||
|
|
|
@ -7,20 +7,10 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
use rtfm::app;
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
static mut SHARED: u32 = 0;
|
||||
|
@ -33,7 +23,7 @@ const APP: () = {
|
|||
// when omitted priority is assumed to be `1`
|
||||
#[interrupt(resources = [SHARED])]
|
||||
fn GPIOA() {
|
||||
println!("A");
|
||||
hprintln!("A").unwrap();
|
||||
|
||||
// the lower priority task requires a critical section to access the data
|
||||
resources.SHARED.lock(|shared| {
|
||||
|
@ -43,7 +33,7 @@ const APP: () = {
|
|||
// GPIOB will *not* run right now due to the critical section
|
||||
rtfm::pend(Interrupt::GPIOB);
|
||||
|
||||
println!("B - SHARED = {}", *shared);
|
||||
hprintln!("B - SHARED = {}", *shared).unwrap();
|
||||
|
||||
// GPIOC does not contend for `SHARED` so it's allowed to run now
|
||||
rtfm::pend(Interrupt::GPIOC);
|
||||
|
@ -51,7 +41,7 @@ const APP: () = {
|
|||
|
||||
// critical section is over: GPIOB can now start
|
||||
|
||||
println!("E");
|
||||
hprintln!("E").unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
@ -61,11 +51,11 @@ const APP: () = {
|
|||
// the higher priority task does *not* need a critical section
|
||||
*resources.SHARED += 1;
|
||||
|
||||
println!("D - SHARED = {}", *resources.SHARED);
|
||||
hprintln!("D - SHARED = {}", *resources.SHARED).unwrap();
|
||||
}
|
||||
|
||||
#[interrupt(priority = 3)]
|
||||
fn GPIOC() {
|
||||
println!("C");
|
||||
hprintln!("C").unwrap();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7,19 +7,9 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use rtfm::app;
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init(spawn = [foo])]
|
||||
|
@ -31,7 +21,7 @@ const APP: () = {
|
|||
fn foo() {
|
||||
static mut COUNT: u32 = 0;
|
||||
|
||||
println!("foo");
|
||||
hprintln!("foo").unwrap();
|
||||
|
||||
spawn.bar(*COUNT).unwrap();
|
||||
*COUNT += 1;
|
||||
|
@ -39,14 +29,14 @@ const APP: () = {
|
|||
|
||||
#[task(spawn = [baz])]
|
||||
fn bar(x: u32) {
|
||||
println!("bar({})", x);
|
||||
hprintln!("bar({})", x).unwrap();
|
||||
|
||||
spawn.baz(x + 1, x + 2).unwrap();
|
||||
}
|
||||
|
||||
#[task(spawn = [foo])]
|
||||
fn baz(x: u32, y: u32) {
|
||||
println!("baz({}, {})", x, y);
|
||||
hprintln!("baz({}, {})", x, y).unwrap();
|
||||
|
||||
if x + y > 4 {
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
|
|
|
@ -7,18 +7,9 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::hprintln;
|
||||
use rtfm::{app, Instant};
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const PERIOD: u32 = 8_000_000;
|
||||
|
||||
// NOTE: does NOT work on QEMU!
|
||||
|
@ -32,7 +23,7 @@ const APP: () = {
|
|||
#[task(schedule = [foo])]
|
||||
fn foo() {
|
||||
let now = Instant::now();
|
||||
println!("foo(scheduled = {:?}, now = {:?})", scheduled, now);
|
||||
hprintln!("foo(scheduled = {:?}, now = {:?})", scheduled, now).unwrap();
|
||||
|
||||
schedule.foo(scheduled + PERIOD.cycles()).unwrap();
|
||||
}
|
||||
|
|
|
@ -7,19 +7,9 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use rtfm::app;
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init(spawn = [bar])]
|
||||
|
@ -30,7 +20,7 @@ const APP: () = {
|
|||
#[inline(never)]
|
||||
#[task]
|
||||
fn foo() {
|
||||
println!("foo");
|
||||
hprintln!("foo").unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -7,20 +7,10 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
use rtfm::app;
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
// A resource
|
||||
|
@ -47,7 +37,7 @@ const APP: () = {
|
|||
fn UART0() {
|
||||
*resources.SHARED += 1;
|
||||
|
||||
println!("UART0: SHARED = {}", resources.SHARED);
|
||||
hprintln!("UART0: SHARED = {}", resources.SHARED).unwrap();
|
||||
}
|
||||
|
||||
// `SHARED` can be access from this context
|
||||
|
@ -55,6 +45,6 @@ const APP: () = {
|
|||
fn UART1() {
|
||||
*resources.SHARED += 1;
|
||||
|
||||
println!("UART1: SHARED = {}", resources.SHARED);
|
||||
hprintln!("UART1: SHARED = {}", resources.SHARED).unwrap();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7,18 +7,9 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::hprintln;
|
||||
use rtfm::{app, Instant};
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// NOTE: does NOT work on QEMU!
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
|
@ -26,7 +17,7 @@ const APP: () = {
|
|||
fn init() {
|
||||
let now = Instant::now();
|
||||
|
||||
println!("init @ {:?}", now);
|
||||
hprintln!("init @ {:?}", now).unwrap();
|
||||
|
||||
// Schedule `foo` to run 8e6 cycles (clock cycles) in the future
|
||||
schedule.foo(now + 8_000_000.cycles()).unwrap();
|
||||
|
@ -37,12 +28,12 @@ const APP: () = {
|
|||
|
||||
#[task]
|
||||
fn foo() {
|
||||
println!("foo @ {:?}", Instant::now());
|
||||
hprintln!("foo @ {:?}", Instant::now()).unwrap();
|
||||
}
|
||||
|
||||
#[task]
|
||||
fn bar() {
|
||||
println!("bar @ {:?}", Instant::now());
|
||||
hprintln!("bar @ {:?}", Instant::now()).unwrap();
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -8,20 +8,10 @@
|
|||
extern crate panic_semihosting;
|
||||
|
||||
use alloc_singleton::stable::pool::{Box, Pool};
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
use rtfm::app;
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[Singleton(Send)]
|
||||
|
@ -48,7 +38,7 @@ const APP: () = {
|
|||
|
||||
#[task(resources = [P])]
|
||||
fn foo(x: Box<M>) {
|
||||
println!("foo({})", x);
|
||||
hprintln!("foo({})", x).unwrap();
|
||||
|
||||
resources.P.lock(|p| p.dealloc(x));
|
||||
|
||||
|
@ -57,7 +47,7 @@ const APP: () = {
|
|||
|
||||
#[task(priority = 2, resources = [P])]
|
||||
fn bar(x: Box<M>) {
|
||||
println!("bar({})", x);
|
||||
hprintln!("bar({})", x).unwrap();
|
||||
|
||||
resources.P.dealloc(x);
|
||||
}
|
||||
|
|
|
@ -7,20 +7,10 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use lm3s6965::Interrupt;
|
||||
use rtfm::app;
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
static KEY: u32 = ();
|
||||
|
@ -35,13 +25,13 @@ const APP: () = {
|
|||
|
||||
#[interrupt(resources = [KEY])]
|
||||
fn UART0() {
|
||||
println!("UART0(KEY = {:#x})", resources.KEY);
|
||||
hprintln!("UART0(KEY = {:#x})", resources.KEY).unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
#[interrupt(priority = 2, resources = [KEY])]
|
||||
fn UART1() {
|
||||
println!("UART1(KEY = {:#x})", resources.KEY);
|
||||
hprintln!("UART1(KEY = {:#x})", resources.KEY).unwrap();
|
||||
}
|
||||
};
|
||||
|
|
|
@ -7,19 +7,9 @@
|
|||
|
||||
extern crate panic_semihosting;
|
||||
|
||||
use cortex_m_semihosting::debug;
|
||||
use cortex_m_semihosting::{debug, hprintln};
|
||||
use rtfm::app;
|
||||
|
||||
macro_rules! println {
|
||||
($($tt:tt)*) => {
|
||||
if let Ok(mut stdout) = cortex_m_semihosting::hio::hstdout() {
|
||||
use core::fmt::Write;
|
||||
|
||||
writeln!(stdout, $($tt)*).ok();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[app(device = lm3s6965)]
|
||||
const APP: () = {
|
||||
#[init(spawn = [foo])]
|
||||
|
@ -29,7 +19,7 @@ const APP: () = {
|
|||
|
||||
#[task(spawn = [bar, baz])]
|
||||
fn foo() {
|
||||
println!("foo");
|
||||
hprintln!("foo").unwrap();
|
||||
|
||||
// spawns `bar` onto the task scheduler
|
||||
// `foo` and `bar` have the same priority so `bar` will not run until
|
||||
|
@ -43,14 +33,14 @@ const APP: () = {
|
|||
|
||||
#[task]
|
||||
fn bar() {
|
||||
println!("bar");
|
||||
hprintln!("bar").unwrap();
|
||||
|
||||
debug::exit(debug::EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
#[task(priority = 2)]
|
||||
fn baz() {
|
||||
println!("baz");
|
||||
hprintln!("baz").unwrap();
|
||||
}
|
||||
|
||||
// Interrupt handlers used to dispatch software tasks
|
||||
|
|
Loading…
Reference in a new issue