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

rtfm_itm and spawn

parent 6dd5de07
No related branches found
No related tags found
No related merge requests found
......@@ -12,7 +12,6 @@ edition = "2018"
[dependencies]
panic-halt = "0.2"
panic-semihosting = "0.5"
cortex-m-rtfm = "0.5.1"
cortex-m-semihosting = "0.3.5"
cortex-m = "0.6.2"
aligned = "0.3.2"
......@@ -33,6 +32,13 @@ version = "0.6.0"
features = ["stm32f401", "rt"]
optional = true
[dependencies.cortex-m-rtfm]
version = "0.5.1"
optional = true
[features]
rtfm = ["cortex-m-rtfm", "stm32f4xx-hal"]
# this lets you use `cargo fix`!
[[bin]]
name = "app"
......@@ -48,6 +54,10 @@ required-features = ["stm32f4"]
name = "serial"
required-features = ["stm32f4xx-hal"]
[[example]]
name = "rtfm_blinky"
required-features = ["rtfm"]
[profile.dev]
opt-level = 1
codegen-units = 16
......
#![no_main]
#![no_std]
use cortex_m::{iprint, iprintln};
use pac::Interrupt;
use panic_semihosting as _;
use rtfm::app;
use stm32f4xx_hal::stm32 as pac;
#[app(device = stm32f4xx_hal::stm32, peripherals = true )]
const APP: () = {
struct Resources {
itm: cortex_m::peripheral::ITM,
}
#[init]
fn init(cx: init::Context) -> init::LateResources {
let mut itm = cx.core.ITM;
let stim = &mut itm.stim[0];
iprintln!(stim, "in init");
rtfm::pend(Interrupt::EXTI0);
init::LateResources { itm }
}
#[idle (resources = [itm])]
fn idle(mut cx: idle::Context) -> ! {
cx.resources.itm.lock(|itm| {
let stim = &mut itm.stim[0];
iprintln!(stim, "idle");
});
loop {
continue;
}
}
#[task(binds = EXTI0, resources = [itm])]
fn exti0(cx: exti0::Context) {
let stim = &mut cx.resources.itm.stim[0];
iprintln!(stim, "exti0");
}
};
#![no_main]
#![no_std]
use cortex_m::{iprint, iprintln};
use pac::Interrupt;
use panic_semihosting as _;
use rtfm::app;
use stm32f4xx_hal::stm32 as pac;
#[app(device = stm32f4xx_hal::stm32, peripherals = true )]
const APP: () = {
struct Resources {
itm: cortex_m::peripheral::ITM,
}
#[init(spawn = [task1])]
fn init(cx: init::Context) -> init::LateResources {
let mut itm = cx.core.ITM;
let stim = &mut itm.stim[0];
iprintln!(stim, "in init");
cx.spawn.task1("from init").unwrap();
init::LateResources { itm }
}
#[idle (resources = [itm], spawn = [task1])]
fn idle(mut cx: idle::Context) -> ! {
cx.resources.itm.lock(|itm| {
let stim = &mut itm.stim[0];
cx.spawn.task1("from idle, itm locked").unwrap();
iprintln!(stim, "idle");
});
cx.spawn.task1("from idle").unwrap();
loop {
continue;
}
}
#[task (resources = [itm])]
fn task1(cx: task1::Context, called_from: &'static str) {
let stim = &mut cx.resources.itm.stim[0];
iprintln!(stim, "task1 {}", called_from);
}
// Interrupt handlers used to dispatch software tasks
extern "C" {
fn EXTI0();
}
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment