Skip to content
Snippets Groups Projects
Commit 7f46e4cb authored by Per Lindgren's avatar Per Lindgren
Browse files

blinky_msg123

parent 44f3a558
Branches
No related tags found
No related merge requests found
...@@ -55,7 +55,15 @@ name = "serial" ...@@ -55,7 +55,15 @@ name = "serial"
required-features = ["stm32f4xx-hal"] required-features = ["stm32f4xx-hal"]
[[example]] [[example]]
name = "rtfm_blinky" name = "rtfm_blinky_msg1"
required-features = ["rtfm"]
[[example]]
name = "rtfm_blinky_msg2"
required-features = ["rtfm"]
[[example]]
name = "rtfm_blinky_msg3"
required-features = ["rtfm"] required-features = ["rtfm"]
[profile.dev] [profile.dev]
......
#![deny(unsafe_code)] #![deny(unsafe_code)]
// #![deny(warnings)] #![deny(warnings)]
#![no_main] #![no_main]
#![no_std] #![no_std]
...@@ -16,9 +16,9 @@ const APP: () = { ...@@ -16,9 +16,9 @@ const APP: () = {
GPIOA: stm32::GPIOA, GPIOA: stm32::GPIOA,
} }
#[init(schedule = [toggle])] #[init(schedule = [toggle])]
fn init(mut cx: init::Context) -> init::LateResources { fn init(cx: init::Context) -> init::LateResources {
let mut core = cx.core; let mut core = cx.core;
let mut device = cx.device; let device = cx.device;
// Initialize (enable) the monotonic timer (CYCCNT) // Initialize (enable) the monotonic timer (CYCCNT)
core.DCB.enable_trace(); core.DCB.enable_trace();
......
#![deny(unsafe_code)] #![deny(unsafe_code)]
// #![deny(warnings)] #![deny(warnings)]
#![no_main] #![no_main]
#![no_std] #![no_std]
...@@ -16,9 +16,9 @@ const APP: () = { ...@@ -16,9 +16,9 @@ const APP: () = {
GPIOA: stm32::GPIOA, GPIOA: stm32::GPIOA,
} }
#[init(schedule = [toggle])] #[init(schedule = [toggle])]
fn init(mut cx: init::Context) -> init::LateResources { fn init(cx: init::Context) -> init::LateResources {
let mut core = cx.core; let mut core = cx.core;
let mut device = cx.device; let device = cx.device;
// Initialize (enable) the monotonic timer (CYCCNT) // Initialize (enable) the monotonic timer (CYCCNT)
core.DCB.enable_trace(); core.DCB.enable_trace();
......
#![deny(unsafe_code)] #![deny(unsafe_code)]
// #![deny(warnings)] #![deny(warnings)]
#![no_main] #![no_main]
#![no_std] #![no_std]
...@@ -12,9 +12,9 @@ use stm32f4xx_hal::stm32; ...@@ -12,9 +12,9 @@ use stm32f4xx_hal::stm32;
#[rtfm::app(device = stm32f4xx_hal::stm32, monotonic = rtfm::cyccnt::CYCCNT, peripherals = true)] #[rtfm::app(device = stm32f4xx_hal::stm32, monotonic = rtfm::cyccnt::CYCCNT, peripherals = true)]
const APP: () = { const APP: () = {
#[init(schedule = [toggle])] #[init(schedule = [toggle])]
fn init(mut cx: init::Context) { fn init(cx: init::Context) {
let mut core = cx.core; let mut core = cx.core;
let mut device = cx.device; let device = cx.device;
// Initialize (enable) the monotonic timer (CYCCNT) // Initialize (enable) the monotonic timer (CYCCNT)
core.DCB.enable_trace(); core.DCB.enable_trace();
...@@ -32,10 +32,11 @@ const APP: () = { ...@@ -32,10 +32,11 @@ const APP: () = {
device.GPIOA.moder.modify(|_, w| w.moder5().bits(1)); device.GPIOA.moder.modify(|_, w| w.moder5().bits(1));
cx.schedule cx.schedule
.toggle(now + 8_000_000.cycles(), true, device.GPIOA); .toggle(now + 8_000_000.cycles(), true, device.GPIOA)
.ok();
} }
#[task(schedule = [toggle])] #[task(schedule= [toggle])]
fn toggle(cx: toggle::Context, toggle: bool, gpioa: stm32::GPIOA) { fn toggle(cx: toggle::Context, toggle: bool, gpioa: stm32::GPIOA) {
hprintln!("toggle @ {:?}", Instant::now()).unwrap(); hprintln!("toggle @ {:?}", Instant::now()).unwrap();
...@@ -46,7 +47,8 @@ const APP: () = { ...@@ -46,7 +47,8 @@ const APP: () = {
} }
cx.schedule cx.schedule
.toggle(cx.scheduled + 8_000_000.cycles(), !toggle, gpioa); .toggle(cx.scheduled + 8_000_000.cycles(), !toggle, gpioa)
.ok();
} }
extern "C" { extern "C" {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment