Skip to content
Snippets Groups Projects
Commit 087553d8 authored by Anton's avatar Anton
Browse files

bare7_1

parent 0eba1402
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment