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::{ ...@@ -17,7 +17,7 @@ use stm32f4xx_hal::{
gpio::{gpioa::PA5, Output, PushPull}, gpio::{gpioa::PA5, Output, PushPull},
prelude::*, prelude::*,
}; };
;
use embedded_hal::digital::v2::{OutputPin, ToggleableOutputPin}; use embedded_hal::digital::v2::{OutputPin, ToggleableOutputPin};
const OFFSET: u32 = 8_000_000; const OFFSET: u32 = 8_000_000;
...@@ -26,8 +26,8 @@ const OFFSET: u32 = 8_000_000; ...@@ -26,8 +26,8 @@ const OFFSET: u32 = 8_000_000;
const APP: () = { const APP: () = {
struct Resources { struct Resources {
// late resources // late resources
GPIOA: stm32::GPIOA, //GPIOA: stm32::GPIOA,
// led: PA5<Output<PushPull>>, led: PA5<Output<PushPull>>,
} }
#[init(schedule = [toggle])] #[init(schedule = [toggle])]
fn init(cx: init::Context) -> init::LateResources { fn init(cx: init::Context) -> init::LateResources {
...@@ -53,9 +53,14 @@ const APP: () = { ...@@ -53,9 +53,14 @@ const APP: () = {
// configure PA5 as output, RM0368 8.4.1 // configure PA5 as output, RM0368 8.4.1
device.GPIOA.moder.modify(|_, w| w.moder5().bits(1)); device.GPIOA.moder.modify(|_, w| w.moder5().bits(1));
let split = device.GPIOA.split();
// pass on late resources // pass on late resources
init::LateResources { 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: () = { ...@@ -67,15 +72,18 @@ const APP: () = {
} }
} }
#[task(resources = [GPIOA], schedule = [toggle])] #[task(resources = [led], schedule = [toggle])]
fn toggle(cx: toggle::Context) { fn toggle(cx: toggle::Context) {
static mut TOGGLE: bool = false; static mut TOGGLE: bool = false;
rprintln!("toggle @ {:?}", Instant::now()); rprintln!("toggle @ {:?}", Instant::now());
if *TOGGLE { 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 { } 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; *TOGGLE = !*TOGGLE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment