From 70ed62437a1f6563b550d9c13c96acac40d731f3 Mon Sep 17 00:00:00 2001 From: Dominic Fischer Date: Thu, 8 Aug 2024 23:34:17 +0100 Subject: [PATCH] fix things --- esp-hal/src/timer/systimer.rs | 2 +- hil-test/tests/embassy_timers_executors.rs | 26 +++++++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/esp-hal/src/timer/systimer.rs b/esp-hal/src/timer/systimer.rs index 9506a1e3bdf..48838889dc0 100644 --- a/esp-hal/src/timer/systimer.rs +++ b/esp-hal/src/timer/systimer.rs @@ -887,7 +887,7 @@ mod asynch { } impl<'a, const COMP: u8, const UNIT: u8> AlarmFuture<'a, COMP, UNIT> { - pub(crate) fn new(alarm: &'a Alarm) -> Self { + pub(crate) fn new(alarm: &'a Alarm<'a, Periodic, crate::Async, COMP, UNIT>) -> Self { alarm.clear_interrupt(); let (interrupt, handler) = match COMP { diff --git a/hil-test/tests/embassy_timers_executors.rs b/hil-test/tests/embassy_timers_executors.rs index c5cd4861bc5..50c093e9101 100644 --- a/hil-test/tests/embassy_timers_executors.rs +++ b/hil-test/tests/embassy_timers_executors.rs @@ -36,7 +36,10 @@ use esp_hal::{ timer::{timg::TimerGroup, ErasedTimer, OneShotTimer, PeriodicTimer}, }; #[cfg(not(feature = "esp32"))] -use esp_hal::{interrupt::Priority, timer::systimer::SystemTimer}; +use esp_hal::{ + interrupt::Priority, + timer::systimer::{Alarm, FrozenUnit, Periodic, SystemTimer, Target}, +}; #[cfg(not(feature = "esp32"))] use esp_hal_embassy::InterruptExecutor; #[cfg(not(feature = "esp32"))] @@ -121,6 +124,8 @@ mod task_invokers { // List of the functions that are ACTUALLY TESTS but are called in the invokers mod test_helpers { + use esp_hal::timer::systimer::Target; + use crate::*; pub async fn test_one_shot_timg() { let peripherals = unsafe { Peripherals::steal() }; @@ -148,7 +153,7 @@ mod test_helpers { let system = SystemControl::new(peripherals.SYSTEM); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let systimer = SystemTimer::new(peripherals.SYSTIMER); + let systimer = SystemTimer::new(peripherals.SYSTIMER).split::(); let alarm0: ErasedTimer = systimer.alarm0.into(); let timers = [OneShotTimer::new(alarm0)]; let timers = mk_static!([OneShotTimer; 1], timers); @@ -189,7 +194,7 @@ mod test_helpers { let system = SystemControl::new(peripherals.SYSTEM); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); - let systimer = SystemTimer::new(peripherals.SYSTIMER); + let systimer = SystemTimer::new(peripherals.SYSTIMER).split::(); let alarm0: ErasedTimer = systimer.alarm0.into(); let timers = [OneShotTimer::new(alarm0)]; let timers = mk_static!([OneShotTimer; 1], timers); @@ -322,7 +327,7 @@ mod test { fn run_test_periodic_systimer() { let peripherals = Peripherals::take(); - let systimer = SystemTimer::new(peripherals.SYSTIMER); + let systimer = SystemTimer::new(peripherals.SYSTIMER).split::(); let mut periodic = PeriodicTimer::new(systimer.alarm0); @@ -384,7 +389,9 @@ mod test { let mut systimer = SystemTimer::new(&mut peripherals.SYSTIMER); - let mut periodic = PeriodicTimer::new(&mut systimer.alarm0); + let unit = FrozenUnit::new(&mut systimer.unit0); + let mut alarm: Alarm<'_, Periodic, _, 0, 0> = Alarm::new(systimer.comparator0, &unit); + let mut periodic = PeriodicTimer::new(&mut alarm); let t1 = esp_hal::time::current_time(); periodic.start(1.secs()).unwrap(); @@ -400,9 +407,11 @@ mod test { core::mem::drop(periodic); - let systimer = SystemTimer::new(&mut peripherals.SYSTIMER); + let mut systimer = SystemTimer::new(&mut peripherals.SYSTIMER); - let timer0 = OneShotTimer::new(systimer.alarm0); + let unit = FrozenUnit::new(&mut systimer.unit0); + let alarm: Alarm<'_, Target, _, 0, 0> = Alarm::new(systimer.comparator0, &unit); + let timer0 = OneShotTimer::new(alarm); let t1 = esp_hal::time::current_time(); timer0.delay_millis(500); @@ -448,7 +457,8 @@ mod test { let timer0 = OneShotTimer::new(timer0); let timer1 = { - let systimer = esp_hal::timer::systimer::SystemTimer::new(peripherals.SYSTIMER); + let systimer = + esp_hal::timer::systimer::SystemTimer::new(peripherals.SYSTIMER).split::(); let alarm0: ErasedTimer = systimer.alarm0.into(); OneShotTimer::new(alarm0) };