From 754f041ae0f8e8effa855403deea1d2c00d22931 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 20 Apr 2018 16:30:42 +0200 Subject: [PATCH] add two more async calls --- examples/tq.rs | 14 ++++++++------ src/ll.rs | 14 ++------------ 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/examples/tq.rs b/examples/tq.rs index d46e232f4d..36dda82d78 100644 --- a/examples/tq.rs +++ b/examples/tq.rs @@ -14,12 +14,12 @@ use core::cmp; use cortex_m::peripheral::syst::SystClkSource; 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}; use rtfm::{app, Resource, Threshold}; use stm32f103xx::Interrupt; -const ACAP: usize = 2; +const ACAP: usize = 4; const MS: u32 = 8_000; @@ -28,11 +28,11 @@ app! { resources: { /* timer queue */ - static TQ: TimerQueue; 2]>; + static TQ: TimerQueue; ACAP]>; /* a */ // payloads w/ after - static AN: [Node; 2] = [Node::new(), Node::new()]; + static AN: [Node; ACAP] = unsafe { ll::uninitialized() }; static AFL: FreeList = FreeList::new(); /* exti0 */ @@ -59,7 +59,7 @@ app! { EXTI0: { path: exti0, resources: [Q1C, AFL], - priority: 1, + priority: 3, }, // timer queue @@ -123,6 +123,8 @@ fn exti1(t: &mut Threshold, r: EXTI1::Resources) { unsafe { iprintln!(&mut (*ITM::ptr()).stim[0], "EXTI0(bl={:?})", bl) } async.a(t, 100 * MS, 0).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 */ @@ -134,7 +136,7 @@ fn exti0(t: &mut Threshold, mut r: EXTI0::Resources) { 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); } } } diff --git a/src/ll.rs b/src/ll.rs index d51302aa52..85d0bfc779 100644 --- a/src/ll.rs +++ b/src/ll.rs @@ -37,16 +37,6 @@ impl PartialOrd for Node { } } -impl Node { - pub const fn new() -> Self { - Node { - baseline: Instant(0), - next: None, - payload: uninitialized(), - } - } -} - pub struct Slot where T: 'static, @@ -250,12 +240,12 @@ impl ops::Sub for Instant { } } -const fn uninitialized() -> T { +pub const unsafe fn uninitialized() -> T { #[allow(unions_with_drop_fields)] union U { some: T, none: (), } - unsafe { U { none: () }.some } + U { none: () }.some }