mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-29 15:04:32 +01:00
GHA update
Fmt fixes Spawn_after did not work with parameters Examples working again Revert "GHA update" This reverts commit e0a71d4859966a6c5cf2629d3cb27e88acada9c0. Readd flags Only add DWT based dep with __v7 flag
This commit is contained in:
parent
670cdb92d3
commit
cd3484cbab
8 changed files with 143 additions and 70 deletions
42
Cargo.toml
42
Cargo.toml
|
@ -18,6 +18,38 @@ version = "0.6.0-alpha.0"
|
||||||
[lib]
|
[lib]
|
||||||
name = "rtic"
|
name = "rtic"
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "periodic"
|
||||||
|
required-features = ["__v7"]
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "pool"
|
||||||
|
required-features = ["__v7"]
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "schedule"
|
||||||
|
required-features = ["__v7"]
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "t-cfg"
|
||||||
|
required-features = ["__v7"]
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "t-cfg-resources"
|
||||||
|
required-features = ["__min_r1_43"]
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "t-schedule"
|
||||||
|
required-features = ["__v7"]
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "types"
|
||||||
|
required-features = ["__v7"]
|
||||||
|
|
||||||
|
[[example]]
|
||||||
|
name = "double_schedule"
|
||||||
|
required-features = ["__v7"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cortex-m = "0.7.0"
|
cortex-m = "0.7.0"
|
||||||
cortex-m-rtic-macros = { path = "macros", version = "0.6.0-alpha.0" }
|
cortex-m-rtic-macros = { path = "macros", version = "0.6.0-alpha.0" }
|
||||||
|
@ -27,6 +59,11 @@ rtic-monotonic = { git = "https://github.com/rtic-rs/rtic-monotonic", branch = "
|
||||||
heapless = "0.5.0"
|
heapless = "0.5.0"
|
||||||
bare-metal = "1.0.0"
|
bare-metal = "1.0.0"
|
||||||
|
|
||||||
|
[dependencies.dwt-systick-monotonic]
|
||||||
|
git = "https://github.com/rtic-rs/dwt-systick-monotonic"
|
||||||
|
branch = "master"
|
||||||
|
optional = true
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
version_check = "0.9"
|
version_check = "0.9"
|
||||||
|
|
||||||
|
@ -42,6 +79,11 @@ version = "0.5.2"
|
||||||
[target.x86_64-unknown-linux-gnu.dev-dependencies]
|
[target.x86_64-unknown-linux-gnu.dev-dependencies]
|
||||||
trybuild = "1"
|
trybuild = "1"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
# used for testing this crate; do not use in applications
|
||||||
|
__v7 = ["dwt-systick-monotonic"]
|
||||||
|
__min_r1_43 = []
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
codegen-units = 1
|
codegen-units = 1
|
||||||
lto = true
|
lto = true
|
||||||
|
|
|
@ -9,20 +9,35 @@ use panic_semihosting as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
||||||
mod app {
|
mod app {
|
||||||
|
use dwt_systick_monotonic::{
|
||||||
|
consts::{U0, U8},
|
||||||
|
DwtSystick,
|
||||||
|
};
|
||||||
|
use rtic::time::duration::Seconds;
|
||||||
|
|
||||||
|
#[monotonic(binds = SysTick, default = true)]
|
||||||
|
type MyMono = DwtSystick<U8, U0, U0>; // 8 MHz
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(_: init::Context) -> (init::LateResources, init::Monotonics) {
|
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||||
task1::spawn().ok();
|
task1::spawn().ok();
|
||||||
|
|
||||||
(init::LateResources {}, init::Monotonics())
|
let mut dcb = cx.core.DCB;
|
||||||
|
let dwt = cx.core.DWT;
|
||||||
|
let systick = cx.core.SYST;
|
||||||
|
|
||||||
|
let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000);
|
||||||
|
|
||||||
|
(init::LateResources {}, init::Monotonics(mono))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[task]
|
||||||
fn task1(_cx: task1::Context) {
|
fn task1(_cx: task1::Context) {
|
||||||
task2::schedule(_cx.scheduled + 100.cycles()).ok();
|
task2::spawn_after(Seconds(1_u32)).ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[task]
|
||||||
fn task2(_cx: task2::Context) {
|
fn task2(_cx: task2::Context) {
|
||||||
task1::schedule(_cx.scheduled + 100.cycles()).ok();
|
task1::spawn_after(Seconds(1_u32)).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,25 +10,31 @@ use panic_semihosting as _;
|
||||||
// NOTE: does NOT work on QEMU!
|
// NOTE: does NOT work on QEMU!
|
||||||
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
||||||
mod app {
|
mod app {
|
||||||
use cortex_m_semihosting::hprintln;
|
use dwt_systick_monotonic::{
|
||||||
use rtic::cyccnt::{Instant, U32Ext};
|
consts::{U0, U8},
|
||||||
|
DwtSystick,
|
||||||
|
};
|
||||||
|
use rtic::time::duration::Seconds;
|
||||||
|
|
||||||
const PERIOD: u32 = 8_000_000;
|
#[monotonic(binds = SysTick, default = true)]
|
||||||
|
type MyMono = DwtSystick<U8, U0, U0>; // 8 MHz
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||||
// omitted: initialization of `CYCCNT`
|
let mut dcb = cx.core.DCB;
|
||||||
|
let dwt = cx.core.DWT;
|
||||||
|
let systick = cx.core.SYST;
|
||||||
|
|
||||||
foo::schedule(cx.start + PERIOD.cycles()).unwrap();
|
let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000);
|
||||||
|
|
||||||
(init::LateResources {}, init::Monotonics())
|
foo::spawn_after(Seconds(1_u32)).unwrap();
|
||||||
|
|
||||||
|
(init::LateResources {}, init::Monotonics(mono))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[task]
|
||||||
fn foo(cx: foo::Context) {
|
fn foo(_cx: foo::Context) {
|
||||||
let now = Instant::now();
|
// Periodic
|
||||||
hprintln!("foo(scheduled = {:?}, now = {:?})", cx.scheduled, now).unwrap();
|
foo::spawn_after(Seconds(1_u32)).unwrap();
|
||||||
|
|
||||||
foo::schedule(cx.scheduled + PERIOD.cycles()).unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,40 +10,42 @@ use panic_halt as _;
|
||||||
// NOTE: does NOT work on QEMU!
|
// NOTE: does NOT work on QEMU!
|
||||||
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
||||||
mod app {
|
mod app {
|
||||||
use cortex_m::peripheral::DWT;
|
|
||||||
use cortex_m_semihosting::hprintln;
|
use cortex_m_semihosting::hprintln;
|
||||||
use rtic::cyccnt::{Instant, U32Ext as _};
|
use dwt_systick_monotonic::{
|
||||||
|
consts::{U0, U8},
|
||||||
|
DwtSystick,
|
||||||
|
};
|
||||||
|
use rtic::time::duration::Seconds;
|
||||||
|
|
||||||
|
#[monotonic(binds = SysTick, default = true)]
|
||||||
|
type MyMono = DwtSystick<U8, U0, U0>; // 8 MHz
|
||||||
|
|
||||||
#[init()]
|
#[init()]
|
||||||
fn init(mut cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||||
// Initialize (enable) the monotonic timer (CYCCNT)
|
let mut dcb = cx.core.DCB;
|
||||||
cx.core.DCB.enable_trace();
|
let dwt = cx.core.DWT;
|
||||||
// required on Cortex-M7 devices that software lock the DWT (e.g. STM32F7)
|
let systick = cx.core.SYST;
|
||||||
DWT::unlock();
|
|
||||||
cx.core.DWT.enable_cycle_counter();
|
|
||||||
|
|
||||||
// semantically, the monotonic timer is frozen at time "zero" during `init`
|
let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000);
|
||||||
// NOTE do *not* call `Instant::now` in this context; it will return a nonsense value
|
|
||||||
let now = cx.start; // the start time of the system
|
|
||||||
|
|
||||||
hprintln!("init @ {:?}", now).unwrap();
|
hprintln!("init").unwrap();
|
||||||
|
|
||||||
// Schedule `foo` to run 8e6 cycles (clock cycles) in the future
|
// Schedule `foo` to run 1 second in the future
|
||||||
foo::schedule(now + 8_000_000.cycles()).unwrap();
|
foo::spawn_after(Seconds(1_u32)).unwrap();
|
||||||
|
|
||||||
// Schedule `bar` to run 4e6 cycles in the future
|
// Schedule `bar` to run 2 seconds in the future
|
||||||
bar::schedule(now + 4_000_000.cycles()).unwrap();
|
bar::spawn_after(Seconds(2_u32)).unwrap();
|
||||||
|
|
||||||
(init::LateResources {}, init::Monotonics())
|
(init::LateResources {}, init::Monotonics(mono))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[task]
|
||||||
fn foo(_: foo::Context) {
|
fn foo(_: foo::Context) {
|
||||||
hprintln!("foo @ {:?}", Instant::now()).unwrap();
|
hprintln!("foo").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task]
|
#[task]
|
||||||
fn bar(_: bar::Context) {
|
fn bar(_: bar::Context) {
|
||||||
hprintln!("bar @ {:?}", Instant::now()).unwrap();
|
hprintln!("bar").unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,48 +9,43 @@ use panic_halt as _;
|
||||||
|
|
||||||
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
#[rtic::app(device = lm3s6965, dispatchers = [SSI0])]
|
||||||
mod app {
|
mod app {
|
||||||
use rtic::cyccnt::{Instant, U32Ext as _};
|
use dwt_systick_monotonic::{
|
||||||
|
consts::{U0, U8},
|
||||||
|
DwtSystick,
|
||||||
|
};
|
||||||
|
use rtic::time::duration::Seconds;
|
||||||
|
|
||||||
|
#[monotonic(binds = SysTick, default = true)]
|
||||||
|
type MyMono = DwtSystick<U8, U0, U0>; // 8 MHz
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(c: init::Context) -> (init::LateResources, init::Monotonics) {
|
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||||
let _: Result<(), ()> = foo::schedule(c.start + 10.cycles());
|
let mut dcb = cx.core.DCB;
|
||||||
let _: Result<(), u32> = bar::schedule(c.start + 20.cycles(), 0);
|
let dwt = cx.core.DWT;
|
||||||
let _: Result<(), (u32, u32)> = baz::schedule(c.start + 30.cycles(), 0, 1);
|
let systick = cx.core.SYST;
|
||||||
|
|
||||||
(init::LateResources {}, init::Monotonics())
|
let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000);
|
||||||
|
|
||||||
|
let _: Result<(), ()> = foo::spawn_after(Seconds(1_u32));
|
||||||
|
let _: Result<(), u32> = bar::spawn_after(Seconds(2_u32), 0);
|
||||||
|
let _: Result<(), (u32, u32)> = baz::spawn_after(Seconds(3_u32), 0, 1);
|
||||||
|
|
||||||
|
(init::LateResources {}, init::Monotonics(mono))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[idle]
|
#[idle]
|
||||||
fn idle(_: idle::Context) -> ! {
|
fn idle(_: idle::Context) -> ! {
|
||||||
let _: Result<(), ()> = foo::schedule(Instant::now() + 40.cycles());
|
let _: Result<(), ()> = foo::spawn_at(MyMono::now() + Seconds(3_u32));
|
||||||
let _: Result<(), u32> = bar::schedule(Instant::now() + 50.cycles(), 0);
|
let _: Result<(), u32> = bar::spawn_at(MyMono::now() + Seconds(4_u32), 0);
|
||||||
let _: Result<(), (u32, u32)> = baz::schedule(Instant::now() + 60.cycles(), 0, 1);
|
let _: Result<(), (u32, u32)> = baz::spawn_at(MyMono::now() + Seconds(5_u32), 0, 1);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
cortex_m::asm::nop();
|
cortex_m::asm::nop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(binds = SVCall)]
|
|
||||||
fn svcall(c: svcall::Context) {
|
|
||||||
let _: Result<(), ()> = foo::schedule(c.start + 70.cycles());
|
|
||||||
let _: Result<(), u32> = bar::schedule(c.start + 80.cycles(), 0);
|
|
||||||
let _: Result<(), (u32, u32)> = baz::schedule(c.start + 90.cycles(), 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[task(binds = UART0)]
|
|
||||||
fn uart0(c: uart0::Context) {
|
|
||||||
let _: Result<(), ()> = foo::schedule(c.start + 100.cycles());
|
|
||||||
let _: Result<(), u32> = bar::schedule(c.start + 110.cycles(), 0);
|
|
||||||
let _: Result<(), (u32, u32)> = baz::schedule(c.start + 120.cycles(), 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[task]
|
#[task]
|
||||||
fn foo(c: foo::Context) {
|
fn foo(_: foo::Context) {}
|
||||||
let _: Result<(), ()> = foo::schedule(c.scheduled + 130.cycles());
|
|
||||||
let _: Result<(), u32> = bar::schedule(c.scheduled + 140.cycles(), 0);
|
|
||||||
let _: Result<(), (u32, u32)> = baz::schedule(c.scheduled + 150.cycles(), 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[task]
|
#[task]
|
||||||
fn bar(_: bar::Context, _x: u32) {}
|
fn bar(_: bar::Context, _x: u32) {}
|
||||||
|
|
|
@ -10,6 +10,13 @@ use panic_semihosting as _;
|
||||||
#[rtic::app(device = lm3s6965, peripherals = true, dispatchers = [SSI0])]
|
#[rtic::app(device = lm3s6965, peripherals = true, dispatchers = [SSI0])]
|
||||||
mod app {
|
mod app {
|
||||||
use cortex_m_semihosting::debug;
|
use cortex_m_semihosting::debug;
|
||||||
|
use dwt_systick_monotonic::{
|
||||||
|
consts::{U0, U8},
|
||||||
|
DwtSystick,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[monotonic(binds = SysTick, default = true)]
|
||||||
|
type MyMono = DwtSystick<U8, U0, U0>; // 8 MHz
|
||||||
|
|
||||||
#[resources]
|
#[resources]
|
||||||
struct Resources {
|
struct Resources {
|
||||||
|
@ -19,13 +26,18 @@ mod app {
|
||||||
|
|
||||||
#[init]
|
#[init]
|
||||||
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
fn init(cx: init::Context) -> (init::LateResources, init::Monotonics) {
|
||||||
let _: cyccnt::Instant = cx.start;
|
let _: cortex_m::Peripherals = cx.core;
|
||||||
let _: rtic::Peripherals = cx.core;
|
|
||||||
let _: lm3s6965::Peripherals = cx.device;
|
let _: lm3s6965::Peripherals = cx.device;
|
||||||
|
|
||||||
debug::exit(debug::EXIT_SUCCESS);
|
debug::exit(debug::EXIT_SUCCESS);
|
||||||
|
|
||||||
(init::LateResources {}, init::Monotonics())
|
let mut dcb = cx.core.DCB;
|
||||||
|
let dwt = cx.core.DWT;
|
||||||
|
let systick = cx.core.SYST;
|
||||||
|
|
||||||
|
let mono = DwtSystick::new(&mut dcb, dwt, systick, 8_000_000);
|
||||||
|
|
||||||
|
(init::LateResources {}, init::Monotonics(mono))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[idle]
|
#[idle]
|
||||||
|
@ -37,13 +49,11 @@ mod app {
|
||||||
|
|
||||||
#[task(binds = UART0, resources = [shared])]
|
#[task(binds = UART0, resources = [shared])]
|
||||||
fn uart0(cx: uart0::Context) {
|
fn uart0(cx: uart0::Context) {
|
||||||
let _: cyccnt::Instant = cx.start;
|
|
||||||
let _: resources::shared = cx.resources.shared;
|
let _: resources::shared = cx.resources.shared;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[task(priority = 2, resources = [shared])]
|
#[task(priority = 2, resources = [shared])]
|
||||||
fn foo(cx: foo::Context) {
|
fn foo(cx: foo::Context) {
|
||||||
let _: cyccnt::Instant = cx.scheduled;
|
|
||||||
let _: resources::shared = cx.resources.shared;
|
let _: resources::shared = cx.resources.shared;
|
||||||
let _: foo::Resources = cx.resources;
|
let _: foo::Resources = cx.resources;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,7 +116,10 @@ pub fn app(app: &App, analysis: &Analysis, extra: &Extra) -> TokenStream2 {
|
||||||
let ty = &monotonic.ty;
|
let ty = &monotonic.ty;
|
||||||
let mangled_name = util::mangle_monotonic_type(&name_str);
|
let mangled_name = util::mangle_monotonic_type(&name_str);
|
||||||
let ident = util::monotonic_ident(&name_str);
|
let ident = util::monotonic_ident(&name_str);
|
||||||
let panic_str = &format!("Use of monotonic '{}' before it was passed to the runtime", name_str);
|
let panic_str = &format!(
|
||||||
|
"Use of monotonic '{}' before it was passed to the runtime",
|
||||||
|
name_str
|
||||||
|
);
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
pub use rtic::Monotonic as _;
|
pub use rtic::Monotonic as _;
|
||||||
|
|
|
@ -263,7 +263,7 @@ pub fn codegen(
|
||||||
pub mod #m {
|
pub mod #m {
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
pub fn spawn_after<D>(
|
pub fn spawn_after<D>(
|
||||||
duration: D,
|
duration: D
|
||||||
#(,#args)*
|
#(,#args)*
|
||||||
) -> Result<(), #ty>
|
) -> Result<(), #ty>
|
||||||
where D: rtic::time::duration::Duration + rtic::time::fixed_point::FixedPoint,
|
where D: rtic::time::duration::Duration + rtic::time::fixed_point::FixedPoint,
|
||||||
|
@ -276,7 +276,7 @@ pub fn codegen(
|
||||||
#app_path::#m::now()
|
#app_path::#m::now()
|
||||||
};
|
};
|
||||||
|
|
||||||
spawn_at(instant + duration, #(,#untupled)*)
|
spawn_at(instant + duration #(,#untupled)*)
|
||||||
}
|
}
|
||||||
|
|
||||||
#(#cfgs)*
|
#(#cfgs)*
|
||||||
|
|
Loading…
Reference in a new issue