diff --git a/examples/rtic_bare9.rs b/examples/rtic_bare9.rs index f39150e7c22c7393a7e1adb56bb50f5771c56ecd..2ee131035dcd9bb343cb9aac1b42d53a8b9a8013 100644 --- a/examples/rtic_bare9.rs +++ b/examples/rtic_bare9.rs @@ -10,6 +10,7 @@ use panic_rtt_target as _; use stm32f4xx_hal::nb::block; + use stm32f4xx_hal::{ prelude::*, serial::{config::Config, Event, Rx, Serial, Tx}, @@ -77,43 +78,51 @@ const APP: () = { } // capacity sets the size of the input buffer (# outstanding messages) - #[task(resources = [TX], priority = 1, capacity = 128)] + #[task(resources = [TX], priority = 2, capacity = 128)] fn rx(cx: rx::Context, data: u8) { let tx = cx.resources.TX; - rprintln!("data {:b}", data); - match block!(tx.write(data)) { - Ok(_val) => { - rprintln!("Ok {:b}", data); - } - Err(err) => { - rprintln!("Error {:?}", err); - } - } + block!(tx.write(data)).unwrap(); + //rprintln!("data {:b}", data); + } // Task bound to the USART2 interrupt. - #[task(binds = USART2, priority = 2, resources = [RX, ERR, RECV], spawn = [rx])] + #[task(binds = USART2, priority = 3, resources = [RX], spawn = [rx,traceing])] fn usart2(cx: usart2::Context) { let rx = cx.resources.RX; - let received = cx.resources.RECV; - let errors = cx.resources.ERR; match block!(rx.read()) { Ok(byte) => { - *received += 1; - rprintln!("Ok {:b} Nmbr {:?}", byte, received); cx.spawn.rx(byte).unwrap(); + let _res=cx.spawn.traceing(true); } - Err(err) => { - *errors += 1; - rprintln!("Error {:?} Nmbr {:?}", err, errors); + Err(_err) => { + let _res=cx.spawn.traceing(false); } } + } + // Handles prints + #[task(priority = 1, resources = [ERR, RECV])] + fn traceing(cx: traceing::Context, state: bool) { + let received = cx.resources.RECV; + let errors = cx.resources.ERR; + match state { + true => { + *received += 1; + rprintln!("Ok:s {:?}", received); + } + false => { + *errors += 1; + rprintln!("Errors {:?}", errors); + } + } + } extern "C" { fn EXTI0(); + fn USART1(); } };