Skip to content

Commit

Permalink
fix things
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Fischer committed Aug 8, 2024
1 parent 51ecfec commit 2394d7d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion esp-hal/src/timer/systimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Periodic, crate::Async, COMP, UNIT>) -> Self {
pub(crate) fn new(alarm: &'a Alarm<'a, Periodic, crate::Async, COMP, UNIT>) -> Self {
alarm.clear_interrupt();

let (interrupt, handler) = match COMP {
Expand Down
27 changes: 19 additions & 8 deletions hil-test/tests/embassy_timers_executors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down Expand Up @@ -121,6 +124,9 @@ mod task_invokers {

// List of the functions that are ACTUALLY TESTS but are called in the invokers
mod test_helpers {
#[cfg(not(feature = "esp32"))]
use esp_hal::timer::systimer::Target;

use crate::*;
pub async fn test_one_shot_timg() {
let peripherals = unsafe { Peripherals::steal() };
Expand Down Expand Up @@ -148,7 +154,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::<Target>();
let alarm0: ErasedTimer = systimer.alarm0.into();
let timers = [OneShotTimer::new(alarm0)];
let timers = mk_static!([OneShotTimer<ErasedTimer>; 1], timers);
Expand Down Expand Up @@ -189,7 +195,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::<Target>();
let alarm0: ErasedTimer = systimer.alarm0.into();
let timers = [OneShotTimer::new(alarm0)];
let timers = mk_static!([OneShotTimer<ErasedTimer>; 1], timers);
Expand Down Expand Up @@ -322,7 +328,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::<Periodic>();

let mut periodic = PeriodicTimer::new(systimer.alarm0);

Expand Down Expand Up @@ -384,7 +390,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();
Expand All @@ -400,9 +408,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);
Expand Down Expand Up @@ -448,7 +458,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::<Target>();
let alarm0: ErasedTimer = systimer.alarm0.into();
OneShotTimer::new(alarm0)
};
Expand Down

0 comments on commit 2394d7d

Please sign in to comment.