diff --git a/examples/rtic_bare7.rs b/examples/rtic_bare7.rs index 0f2dea18411d7e7c80325ad9cff46836177451f1..300356c67cf7ced31109aefcef5edf1494c19bd0 100644 --- a/examples/rtic_bare7.rs +++ b/examples/rtic_bare7.rs @@ -17,7 +17,7 @@ use stm32f4xx_hal::{ gpio::{gpioa::PA5, Output, PushPull}, prelude::*, }; -; + use embedded_hal::digital::v2::{OutputPin, ToggleableOutputPin}; const OFFSET: u32 = 8_000_000; @@ -26,8 +26,8 @@ const OFFSET: u32 = 8_000_000; const APP: () = { struct Resources { // late resources - GPIOA: stm32::GPIOA, - // led: PA5<Output<PushPull>>, + //GPIOA: stm32::GPIOA, + led: PA5<Output<PushPull>>, } #[init(schedule = [toggle])] fn init(cx: init::Context) -> init::LateResources { @@ -53,9 +53,14 @@ const APP: () = { // configure PA5 as output, RM0368 8.4.1 device.GPIOA.moder.modify(|_, w| w.moder5().bits(1)); + let split = device.GPIOA.split(); + // pass on late resources init::LateResources { - GPIOA: device.GPIOA, + //GPIOA: device.GPIOA, + //led: device.GPIOA.PA5.into_pull_push_output() + //led: PA5<Output<PushPull>>.into_pull_push_output() + led : split.pa5.into_push_pull_output() } } @@ -67,15 +72,18 @@ const APP: () = { } } - #[task(resources = [GPIOA], schedule = [toggle])] + #[task(resources = [led], schedule = [toggle])] fn toggle(cx: toggle::Context) { static mut TOGGLE: bool = false; rprintln!("toggle @ {:?}", Instant::now()); + if *TOGGLE { - cx.resources.GPIOA.bsrr.write(|w| w.bs5().set_bit()); + //cx.resources.GPIOA.bsrr.write(|w| w.bs5().set_bit()); + cx.resources.led.set_high().unwrap(); } else { - cx.resources.GPIOA.bsrr.write(|w| w.br5().set_bit()); + cx.resources.led.set_low().unwrap(); + //cx.resources.GPIOA.bsrr.write(|w| w.br5().set_bit()); } *TOGGLE = !*TOGGLE;