mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-11-23 20:22:51 +01:00
add two more async calls
This commit is contained in:
parent
1f5f94bc31
commit
754f041ae0
2 changed files with 10 additions and 18 deletions
|
@ -14,12 +14,12 @@ use core::cmp;
|
||||||
|
|
||||||
use cortex_m::peripheral::syst::SystClkSource;
|
use cortex_m::peripheral::syst::SystClkSource;
|
||||||
use cortex_m::peripheral::ITM;
|
use cortex_m::peripheral::ITM;
|
||||||
use rtfm::ll::{Consumer, FreeList, Instant, Node, Producer, RingBuffer, Slot, TaggedPayload,
|
use rtfm::ll::{self, Consumer, FreeList, Instant, Node, Producer, RingBuffer, Slot, TaggedPayload,
|
||||||
TimerQueue};
|
TimerQueue};
|
||||||
use rtfm::{app, Resource, Threshold};
|
use rtfm::{app, Resource, Threshold};
|
||||||
use stm32f103xx::Interrupt;
|
use stm32f103xx::Interrupt;
|
||||||
|
|
||||||
const ACAP: usize = 2;
|
const ACAP: usize = 4;
|
||||||
|
|
||||||
const MS: u32 = 8_000;
|
const MS: u32 = 8_000;
|
||||||
|
|
||||||
|
@ -28,11 +28,11 @@ app! {
|
||||||
|
|
||||||
resources: {
|
resources: {
|
||||||
/* timer queue */
|
/* timer queue */
|
||||||
static TQ: TimerQueue<Task, [TaggedPayload<Task>; 2]>;
|
static TQ: TimerQueue<Task, [TaggedPayload<Task>; ACAP]>;
|
||||||
|
|
||||||
/* a */
|
/* a */
|
||||||
// payloads w/ after
|
// payloads w/ after
|
||||||
static AN: [Node<i32>; 2] = [Node::new(), Node::new()];
|
static AN: [Node<i32>; ACAP] = unsafe { ll::uninitialized() };
|
||||||
static AFL: FreeList<i32> = FreeList::new();
|
static AFL: FreeList<i32> = FreeList::new();
|
||||||
|
|
||||||
/* exti0 */
|
/* exti0 */
|
||||||
|
@ -59,7 +59,7 @@ app! {
|
||||||
EXTI0: {
|
EXTI0: {
|
||||||
path: exti0,
|
path: exti0,
|
||||||
resources: [Q1C, AFL],
|
resources: [Q1C, AFL],
|
||||||
priority: 1,
|
priority: 3,
|
||||||
},
|
},
|
||||||
|
|
||||||
// timer queue
|
// timer queue
|
||||||
|
@ -123,6 +123,8 @@ fn exti1(t: &mut Threshold, r: EXTI1::Resources) {
|
||||||
unsafe { iprintln!(&mut (*ITM::ptr()).stim[0], "EXTI0(bl={:?})", bl) }
|
unsafe { iprintln!(&mut (*ITM::ptr()).stim[0], "EXTI0(bl={:?})", bl) }
|
||||||
async.a(t, 100 * MS, 0).unwrap();
|
async.a(t, 100 * MS, 0).unwrap();
|
||||||
async.a(t, 50 * MS, 1).unwrap();
|
async.a(t, 50 * MS, 1).unwrap();
|
||||||
|
async.a(t, 75 * MS, 2).unwrap();
|
||||||
|
async.a(t, 75 * MS + 1, 3).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* auto generated */
|
/* auto generated */
|
||||||
|
@ -134,7 +136,7 @@ fn exti0(t: &mut Threshold, mut r: EXTI0::Resources) {
|
||||||
|
|
||||||
r.AFL.claim_mut(t, |afl, _| afl.push(slot));
|
r.AFL.claim_mut(t, |afl, _| afl.push(slot));
|
||||||
|
|
||||||
a(&mut unsafe { Threshold::new(1) }, bl, payload);
|
a(&mut unsafe { Threshold::new(3) }, bl, payload);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
src/ll.rs
14
src/ll.rs
|
@ -37,16 +37,6 @@ impl<T> PartialOrd for Node<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Node<T> {
|
|
||||||
pub const fn new() -> Self {
|
|
||||||
Node {
|
|
||||||
baseline: Instant(0),
|
|
||||||
next: None,
|
|
||||||
payload: uninitialized(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Slot<T>
|
pub struct Slot<T>
|
||||||
where
|
where
|
||||||
T: 'static,
|
T: 'static,
|
||||||
|
@ -250,12 +240,12 @@ impl ops::Sub for Instant {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fn uninitialized<T>() -> T {
|
pub const unsafe fn uninitialized<T>() -> T {
|
||||||
#[allow(unions_with_drop_fields)]
|
#[allow(unions_with_drop_fields)]
|
||||||
union U<T> {
|
union U<T> {
|
||||||
some: T,
|
some: T,
|
||||||
none: (),
|
none: (),
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe { U { none: () }.some }
|
U { none: () }.some
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue