From 885e2bd6e9c561bc708801fd36564bf3312e877f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Tue, 29 Oct 2024 13:24:51 +0100 Subject: [PATCH] ETM simplifications --- esp-hal/CHANGELOG.md | 5 + esp-hal/MIGRATING-0.21.md | 8 + esp-hal/src/gpio/etm.rs | 373 ++++++++++-------------- esp-hal/src/timer/systimer.rs | 14 +- esp-hal/src/timer/timg.rs | 56 ++-- examples/src/bin/etm_blinky_systimer.rs | 4 +- examples/src/bin/etm_timer.rs | 4 +- 7 files changed, 198 insertions(+), 266 deletions(-) diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index f4ada3c3101..eb3ab1dd09c 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -73,6 +73,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Removed the pin type parameters from `lcd_cam::cam::{RxEightBits, RxSixteenBits}` (#2388) - Most of the async-specific constructors (`new_async`, `new_async_no_transceiver`) have been removed. (#2430) - The `configure_for_async` DMA functions have been removed (#2430) +- The `GpioEtm` prefix has been removed from `gpio::etm` types (#2427) +- The `TimerEtm` prefix has been removed from `timer::timg::etm` types (#2427) +- The `SysTimerEtm` prefix has been removed from `timer::systimer::etm` types (#2427) +- The `GpioEtmEventRising`, `GpioEtmEventFalling`, `GpioEtmEventAny` types have been replaced with `Event` (#2427) +- The `TaskSet`, `TaskClear`, `TaskToggle` types have been replaced with `Event` (#2427) ## [0.21.1] diff --git a/esp-hal/MIGRATING-0.21.md b/esp-hal/MIGRATING-0.21.md index 46708dfa205..7c9ae5fab34 100644 --- a/esp-hal/MIGRATING-0.21.md +++ b/esp-hal/MIGRATING-0.21.md @@ -230,3 +230,11 @@ The previous signal function have been replaced by `split`. This change affects `into_peripheral_output`, `split` (for output pins only) and `peripheral_input` have been added to the GPIO drivers (`Input`, `Output`, `OutputOpenDrain` and `Flex`) instead. + +# ETM simplifications + +- The types are no longer prefixed with `GpioEtm`, `TimerEtm` or `SysTimerEtm`. You can still use + import aliasses in case you need to differentiate due to name collisions + (e.g. `use esp_hal::gpio::etm::Event as GpioEtmEvent`). +- The old task and event types have been replaced by `Task` and `Event`. +- GPIO tasks and events are no longer generic. diff --git a/esp-hal/src/gpio/etm.rs b/esp-hal/src/gpio/etm.rs index 262536ad1ee..bd255d469ee 100644 --- a/esp-hal/src/gpio/etm.rs +++ b/esp-hal/src/gpio/etm.rs @@ -26,10 +26,10 @@ //! ```rust, no_run #![doc = crate::before_snippet!()] //! # use esp_hal::gpio::Io; -//! # use esp_hal::gpio::etm::GpioEtmChannels; +//! # use esp_hal::gpio::etm::Channels; //! # use esp_hal::etm::Etm; -//! # use esp_hal::gpio::etm::GpioEtmInputConfig; -//! # use esp_hal::gpio::etm::GpioEtmOutputConfig; +//! # use esp_hal::gpio::etm::InputConfig; +//! # use esp_hal::gpio::etm::OutputConfig; //! # use esp_hal::gpio::Pull; //! # use esp_hal::gpio::Level; //! @@ -37,10 +37,10 @@ //! # let mut led = io.pins.gpio1; //! # let button = io.pins.gpio9; //! -//! let gpio_ext = GpioEtmChannels::new(peripherals.GPIO_SD); +//! let gpio_ext = Channels::new(peripherals.GPIO_SD); //! let led_task = gpio_ext.channel0_task.toggle( //! &mut led, -//! GpioEtmOutputConfig { +//! OutputConfig { //! open_drain: false, //! pull: Pull::None, //! initial_state: Level::Low, @@ -48,77 +48,80 @@ //! ); //! let button_event = gpio_ext //! .channel0_event -//! .falling_edge(button, GpioEtmInputConfig { pull: Pull::Down }); +//! .falling_edge(button, InputConfig { pull: Pull::Down }); //! # } //! ``` +use core::marker::PhantomData; + use crate::{ gpio::{Level, Pull}, peripheral::{Peripheral, PeripheralRef}, + peripherals::GPIO_SD, private, }; /// All the GPIO ETM channels #[non_exhaustive] -pub struct GpioEtmChannels<'d> { - _gpio_sd: PeripheralRef<'d, crate::peripherals::GPIO_SD>, +pub struct Channels<'d> { + _gpio_sd: PeripheralRef<'d, GPIO_SD>, /// Task channel 0 for triggering GPIO tasks. - pub channel0_task: GpioEtmTaskChannel<0>, + pub channel0_task: TaskChannel<0>, /// Event channel 0 for handling GPIO events. - pub channel0_event: GpioEtmEventChannel<0>, + pub channel0_event: EventChannel<0>, /// Task channel 1 for triggering GPIO tasks. - pub channel1_task: GpioEtmTaskChannel<1>, + pub channel1_task: TaskChannel<1>, /// Event channel 1 for handling GPIO events. - pub channel1_event: GpioEtmEventChannel<1>, + pub channel1_event: EventChannel<1>, /// Task channel 2 for triggering GPIO tasks. - pub channel2_task: GpioEtmTaskChannel<2>, + pub channel2_task: TaskChannel<2>, /// Event channel 2 for handling GPIO events. - pub channel2_event: GpioEtmEventChannel<2>, + pub channel2_event: EventChannel<2>, /// Task channel 3 for triggering GPIO tasks. - pub channel3_task: GpioEtmTaskChannel<3>, + pub channel3_task: TaskChannel<3>, /// Event channel 3 for handling GPIO events. - pub channel3_event: GpioEtmEventChannel<3>, + pub channel3_event: EventChannel<3>, /// Task channel 4 for triggering GPIO tasks. - pub channel4_task: GpioEtmTaskChannel<4>, + pub channel4_task: TaskChannel<4>, /// Event channel 4 for handling GPIO events. - pub channel4_event: GpioEtmEventChannel<4>, + pub channel4_event: EventChannel<4>, /// Task channel 5 for triggering GPIO tasks. - pub channel5_task: GpioEtmTaskChannel<5>, + pub channel5_task: TaskChannel<5>, /// Event channel 5 for handling GPIO events. - pub channel5_event: GpioEtmEventChannel<5>, + pub channel5_event: EventChannel<5>, /// Task channel 6 for triggering GPIO tasks. - pub channel6_task: GpioEtmTaskChannel<6>, + pub channel6_task: TaskChannel<6>, /// Event channel 6 for handling GPIO events. - pub channel6_event: GpioEtmEventChannel<6>, + pub channel6_event: EventChannel<6>, /// Task channel 7 for triggering GPIO tasks. - pub channel7_task: GpioEtmTaskChannel<7>, + pub channel7_task: TaskChannel<7>, /// Event channel 7 for handling GPIO events. - pub channel7_event: GpioEtmEventChannel<7>, + pub channel7_event: EventChannel<7>, } -impl<'d> GpioEtmChannels<'d> { +impl<'d> Channels<'d> { /// Create a new instance - pub fn new(peripheral: impl Peripheral

+ 'd) -> Self { + pub fn new(peripheral: impl Peripheral

+ 'd) -> Self { crate::into_ref!(peripheral); Self { _gpio_sd: peripheral, - channel0_task: GpioEtmTaskChannel {}, - channel0_event: GpioEtmEventChannel {}, - channel1_task: GpioEtmTaskChannel {}, - channel1_event: GpioEtmEventChannel {}, - channel2_task: GpioEtmTaskChannel {}, - channel2_event: GpioEtmEventChannel {}, - channel3_task: GpioEtmTaskChannel {}, - channel3_event: GpioEtmEventChannel {}, - channel4_task: GpioEtmTaskChannel {}, - channel4_event: GpioEtmEventChannel {}, - channel5_task: GpioEtmTaskChannel {}, - channel5_event: GpioEtmEventChannel {}, - channel6_task: GpioEtmTaskChannel {}, - channel6_event: GpioEtmEventChannel {}, - channel7_task: GpioEtmTaskChannel {}, - channel7_event: GpioEtmEventChannel {}, + channel0_task: TaskChannel {}, + channel0_event: EventChannel {}, + channel1_task: TaskChannel {}, + channel1_event: EventChannel {}, + channel2_task: TaskChannel {}, + channel2_event: EventChannel {}, + channel3_task: TaskChannel {}, + channel3_event: EventChannel {}, + channel4_task: TaskChannel {}, + channel4_event: EventChannel {}, + channel5_task: TaskChannel {}, + channel5_event: EventChannel {}, + channel6_task: TaskChannel {}, + channel6_event: EventChannel {}, + channel7_task: TaskChannel {}, + channel7_event: EventChannel {}, } } } @@ -126,143 +129,102 @@ impl<'d> GpioEtmChannels<'d> { /// Configuration for an ETM controlled GPIO input pin #[derive(Clone, Copy, Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] -pub struct GpioEtmInputConfig { +pub struct InputConfig { /// Configuration for the internal pull-up resistors pub pull: Pull, } -impl Default for GpioEtmInputConfig { +impl Default for InputConfig { fn default() -> Self { Self { pull: Pull::None } } } /// An ETM controlled GPIO event -pub struct GpioEtmEventChannel {} +pub struct EventChannel {} -impl GpioEtmEventChannel { +impl EventChannel { /// Trigger at rising edge - pub fn rising_edge<'d, PIN>( + pub fn rising_edge<'d>( self, - pin: impl Peripheral

+ 'd, - pin_config: GpioEtmInputConfig, - ) -> GpioEtmEventChannelRising<'d, PIN, C> - where - PIN: super::InputPin, - { - crate::into_ref!(pin); - - pin.init_input(pin_config.pull, private::Internal); - - enable_event_channel(C, pin.number()); - GpioEtmEventChannelRising { _pin: pin } + pin: impl Peripheral

+ 'd, + pin_config: InputConfig, + ) -> Event<'d> { + self.into_event(pin, pin_config, EventKind::Rising) } /// Trigger at falling edge - pub fn falling_edge<'d, PIN>( + pub fn falling_edge<'d>( self, - pin: impl Peripheral

+ 'd, - pin_config: GpioEtmInputConfig, - ) -> GpioEtmEventChannelFalling<'d, PIN, C> - where - PIN: super::InputPin, - { - crate::into_ref!(pin); - - pin.init_input(pin_config.pull, private::Internal); - - enable_event_channel(C, pin.number()); - GpioEtmEventChannelFalling { _pin: pin } + pin: impl Peripheral

+ 'd, + pin_config: InputConfig, + ) -> Event<'d> { + self.into_event(pin, pin_config, EventKind::Falling) } /// Trigger at any edge - pub fn any_edge<'d, PIN>( + pub fn any_edge<'d>( self, - pin: impl Peripheral

+ 'd, - pin_config: GpioEtmInputConfig, - ) -> GpioEtmEventChannelAny<'d, PIN, C> - where - PIN: super::InputPin, - { + pin: impl Peripheral

+ 'd, + pin_config: InputConfig, + ) -> Event<'d> { + self.into_event(pin, pin_config, EventKind::Any) + } + + fn into_event<'d>( + self, + pin: impl Peripheral

+ 'd, + pin_config: InputConfig, + kind: EventKind, + ) -> Event<'d> { crate::into_ref!(pin); pin.init_input(pin_config.pull, private::Internal); enable_event_channel(C, pin.number()); - GpioEtmEventChannelAny { _pin: pin } - } -} - -/// Event for rising edge -#[non_exhaustive] -pub struct GpioEtmEventChannelRising<'d, PIN, const C: u8> -where - PIN: super::Pin, -{ - _pin: PeripheralRef<'d, PIN>, -} - -impl private::Sealed for GpioEtmEventChannelRising<'_, PIN, C> where - PIN: super::Pin -{ -} - -impl crate::etm::EtmEvent for GpioEtmEventChannelRising<'_, PIN, C> -where - PIN: super::Pin, -{ - fn id(&self) -> u8 { - 1 + C + Event { + id: kind.id() + C, + _pin: PhantomData, + } } } -/// Event for falling edge -#[non_exhaustive] -pub struct GpioEtmEventChannelFalling<'d, PIN, const C: u8> -where - PIN: super::Pin, -{ - _pin: PeripheralRef<'d, PIN>, -} - -impl private::Sealed for GpioEtmEventChannelFalling<'_, PIN, C> where - PIN: super::Pin -{ +#[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +enum EventKind { + Rising, + Falling, + Any, } -impl crate::etm::EtmEvent for GpioEtmEventChannelFalling<'_, PIN, C> -where - PIN: super::Pin, -{ +impl EventKind { fn id(&self) -> u8 { - 9 + C + match self { + EventKind::Rising => 1, + EventKind::Falling => 9, + EventKind::Any => 17, + } } } -/// Event for any edge -#[non_exhaustive] -pub struct GpioEtmEventChannelAny<'d, PIN, const C: u8> -where - PIN: super::Pin, -{ - _pin: PeripheralRef<'d, PIN>, +/// Event for rising edge +pub struct Event<'d> { + _pin: PhantomData<&'d mut ()>, + id: u8, } -impl private::Sealed for GpioEtmEventChannelAny<'_, PIN, C> where PIN: super::Pin {} +impl private::Sealed for Event<'_> {} -impl crate::etm::EtmEvent for GpioEtmEventChannelAny<'_, PIN, C> -where - PIN: super::Pin, -{ +impl crate::etm::EtmEvent for Event<'_> { fn id(&self) -> u8 { - 17 + C + self.id } } /// Configuration for an ETM controlled GPIO output pin #[derive(Clone, Copy, Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] -pub struct GpioEtmOutputConfig { +pub struct OutputConfig { /// Set to open-drain output pub open_drain: bool, /// Only used when open-drain @@ -271,7 +233,7 @@ pub struct GpioEtmOutputConfig { pub initial_state: Level, } -impl Default for GpioEtmOutputConfig { +impl Default for OutputConfig { fn default() -> Self { Self { open_drain: false, @@ -282,69 +244,47 @@ impl Default for GpioEtmOutputConfig { } /// An ETM controlled GPIO task -pub struct GpioEtmTaskChannel {} +pub struct TaskChannel {} -impl GpioEtmTaskChannel { +impl TaskChannel { // In theory we could have multiple pins assigned to the same task. Not sure how // useful that would be. If we want to support it, the easiest would be // to offer additional functions like `set2`, `set3` etc. where the // number is the pin-count /// Task to set a high level - pub fn set<'d, PIN>( + pub fn set<'d>( self, - pin: impl Peripheral

+ 'd, - pin_config: GpioEtmOutputConfig, - ) -> GpioEtmTaskSet<'d, PIN, C> - where - PIN: super::OutputPin, - { - crate::into_ref!(pin); - - pin.set_output_high(pin_config.initial_state.into(), private::Internal); - if pin_config.open_drain { - pin.pull_direction(pin_config.pull, private::Internal); - pin.set_to_open_drain_output(private::Internal); - } else { - pin.set_to_push_pull_output(private::Internal); - } - - enable_task_channel(C, pin.number()); - GpioEtmTaskSet { _pin: pin } + pin: impl Peripheral

+ 'd, + pin_config: OutputConfig, + ) -> Task<'d> { + self.into_task(pin, pin_config, TaskKind::Set) } /// Task to set a low level - pub fn clear<'d, PIN>( + pub fn clear<'d>( self, - pin: impl Peripheral

+ 'd, - pin_config: GpioEtmOutputConfig, - ) -> GpioEtmTaskClear<'d, PIN, C> - where - PIN: super::OutputPin, - { - crate::into_ref!(pin); - - pin.set_output_high(pin_config.initial_state.into(), private::Internal); - if pin_config.open_drain { - pin.pull_direction(pin_config.pull, private::Internal); - pin.set_to_open_drain_output(private::Internal); - } else { - pin.set_to_push_pull_output(private::Internal); - } - - enable_task_channel(C, pin.number()); - GpioEtmTaskClear { _pin: pin } + pin: impl Peripheral

+ 'd, + pin_config: OutputConfig, + ) -> Task<'d> { + self.into_task(pin, pin_config, TaskKind::Clear) } /// Task to toggle the level - pub fn toggle<'d, PIN>( + pub fn toggle<'d>( self, - pin: impl Peripheral

+ 'd, - pin_config: GpioEtmOutputConfig, - ) -> GpioEtmTaskToggle<'d, PIN, C> - where - PIN: super::OutputPin, - { + pin: impl Peripheral

+ 'd, + pin_config: OutputConfig, + ) -> Task<'d> { + self.into_task(pin, pin_config, TaskKind::Toggle) + } + + fn into_task<'d>( + self, + pin: impl Peripheral

+ 'd, + pin_config: OutputConfig, + kind: TaskKind, + ) -> Task<'d> { crate::into_ref!(pin); pin.set_output_high(pin_config.initial_state.into(), private::Internal); @@ -356,66 +296,47 @@ impl GpioEtmTaskChannel { } enable_task_channel(C, pin.number()); - GpioEtmTaskToggle { _pin: pin } - } -} - -/// Task for set operation -#[non_exhaustive] -pub struct GpioEtmTaskSet<'d, PIN, const C: u8> -where - PIN: super::Pin, -{ - _pin: PeripheralRef<'d, PIN>, -} - -impl private::Sealed for GpioEtmTaskSet<'_, PIN, C> where PIN: super::Pin {} - -impl crate::etm::EtmTask for GpioEtmTaskSet<'_, PIN, C> -where - PIN: super::Pin, -{ - fn id(&self) -> u8 { - 1 + C + Task { + id: kind.id() + C, + _pin: PhantomData, + } } } -/// Task for clear operation -#[non_exhaustive] -pub struct GpioEtmTaskClear<'d, PIN, const C: u8> { - _pin: PeripheralRef<'d, PIN>, +#[derive(Clone, Copy, Debug)] +#[cfg_attr(feature = "defmt", derive(defmt::Format))] +enum TaskKind { + Set, + Clear, + Toggle, } -impl private::Sealed for GpioEtmTaskClear<'_, PIN, C> where PIN: super::Pin {} - -impl crate::etm::EtmTask for GpioEtmTaskClear<'_, PIN, C> -where - PIN: super::Pin, -{ +impl TaskKind { fn id(&self) -> u8 { - 9 + C + match self { + TaskKind::Set => 1, + TaskKind::Clear => 9, + TaskKind::Toggle => 17, + } } } -/// Task for toggle operation -#[non_exhaustive] -pub struct GpioEtmTaskToggle<'d, PIN, const C: u8> { - _pin: PeripheralRef<'d, PIN>, +/// Task for set operation +pub struct Task<'d> { + _pin: PhantomData<&'d mut ()>, + id: u8, } -impl private::Sealed for GpioEtmTaskToggle<'_, PIN, C> where PIN: super::Pin {} +impl private::Sealed for Task<'_> {} -impl crate::etm::EtmTask for GpioEtmTaskToggle<'_, PIN, C> -where - PIN: super::Pin, -{ +impl crate::etm::EtmTask for Task<'_> { fn id(&self) -> u8 { - 17 + C + self.id } } fn enable_task_channel(channel: u8, pin: u8) { - let gpio_sd = unsafe { crate::peripherals::GPIO_SD::steal() }; + let gpio_sd = unsafe { GPIO_SD::steal() }; let ptr = unsafe { gpio_sd.etm_task_p0_cfg().as_ptr().add(pin as usize / 4) }; let shift = 8 * (pin as usize % 4); // bit 0 = en, bit 1-3 = channel @@ -427,7 +348,7 @@ fn enable_task_channel(channel: u8, pin: u8) { } fn enable_event_channel(channel: u8, pin: u8) { - let gpio_sd = unsafe { crate::peripherals::GPIO_SD::steal() }; + let gpio_sd = unsafe { GPIO_SD::steal() }; gpio_sd .etm_event_ch_cfg(channel as usize) .modify(|_, w| w.event_en().clear_bit()); diff --git a/esp-hal/src/timer/systimer.rs b/esp-hal/src/timer/systimer.rs index 2a666c652e3..913d7141506 100644 --- a/esp-hal/src/timer/systimer.rs +++ b/esp-hal/src/timer/systimer.rs @@ -1147,27 +1147,25 @@ pub mod etm { //! ## Example //! ```rust, no_run #![doc = crate::before_snippet!()] - //! # use esp_hal::timer::systimer::{etm::SysTimerEtmEvent, SystemTimer}; + //! # use esp_hal::timer::systimer::{etm::Event, SystemTimer}; //! # use fugit::ExtU32; //! let syst = SystemTimer::new(peripherals.SYSTIMER); //! let syst_alarms = syst.split(); //! let mut alarm0 = syst_alarms.alarm0.into_periodic(); //! alarm0.set_period(1u32.secs()); //! - //! let timer_event = SysTimerEtmEvent::new(&mut alarm0); + //! let timer_event = Event::new(&mut alarm0); //! # } //! ``` use super::*; /// An ETM controlled SYSTIMER event - pub struct SysTimerEtmEvent<'a, 'd, M, DM: crate::Mode, COMP, UNIT> { + pub struct Event<'a, 'd, M, DM: crate::Mode, COMP, UNIT> { alarm: &'a mut Alarm<'d, M, DM, COMP, UNIT>, } - impl<'a, 'd, M, DM: crate::Mode, COMP: Comparator, UNIT: Unit> - SysTimerEtmEvent<'a, 'd, M, DM, COMP, UNIT> - { + impl<'a, 'd, M, DM: crate::Mode, COMP: Comparator, UNIT: Unit> Event<'a, 'd, M, DM, COMP, UNIT> { /// Creates an ETM event from the given [Alarm] pub fn new(alarm: &'a mut Alarm<'d, M, DM, COMP, UNIT>) -> Self { Self { alarm } @@ -1181,12 +1179,12 @@ pub mod etm { } impl crate::private::Sealed - for SysTimerEtmEvent<'_, '_, M, DM, COMP, UNIT> + for Event<'_, '_, M, DM, COMP, UNIT> { } impl crate::etm::EtmEvent - for SysTimerEtmEvent<'_, '_, M, DM, COMP, UNIT> + for Event<'_, '_, M, DM, COMP, UNIT> { fn id(&self) -> u8 { 50 + self.alarm.comparator.channel() diff --git a/esp-hal/src/timer/timg.rs b/esp-hal/src/timer/timg.rs index 60f4a4bc127..8f67b33db23 100644 --- a/esp-hal/src/timer/timg.rs +++ b/esp-hal/src/timer/timg.rs @@ -1349,87 +1349,87 @@ pub mod etm { use crate::etm::{EtmEvent, EtmTask}; /// Event Task Matrix event for a timer. - pub struct TimerEtmEvent { + pub struct Event { id: u8, } /// Event Task Matrix task for a timer. - pub struct TimerEtmTask { + pub struct Task { id: u8, } - impl EtmEvent for TimerEtmEvent { + impl EtmEvent for Event { fn id(&self) -> u8 { self.id } } - impl Sealed for TimerEtmEvent {} + impl Sealed for Event {} - impl EtmTask for TimerEtmTask { + impl EtmTask for Task { fn id(&self) -> u8 { self.id } } - impl Sealed for TimerEtmTask {} + impl Sealed for Task {} /// General purpose timer ETM events. - pub trait TimerEtmEvents { + pub trait Events { /// ETM event triggered on alarm - fn on_alarm(&self) -> TimerEtmEvent; + fn on_alarm(&self) -> Event; } /// General purpose timer ETM tasks - pub trait TimerEtmTasks { + pub trait Tasks { /// ETM task to start the counter - fn cnt_start(&self) -> TimerEtmTask; + fn cnt_start(&self) -> Task; /// ETM task to start the alarm - fn cnt_stop(&self) -> TimerEtmTask; + fn cnt_stop(&self) -> Task; /// ETM task to stop the counter - fn cnt_reload(&self) -> TimerEtmTask; + fn cnt_reload(&self) -> Task; /// ETM task to reload the counter - fn cnt_cap(&self) -> TimerEtmTask; + fn cnt_cap(&self) -> Task; /// ETM task to load the counter with the value stored when the last /// `now()` was called - fn alarm_start(&self) -> TimerEtmTask; + fn alarm_start(&self) -> Task; } - impl TimerEtmEvents for Timer0 + impl Events for Timer0 where TG: TimerGroupInstance, { - fn on_alarm(&self) -> TimerEtmEvent { - TimerEtmEvent { id: 48 + TG::id() } + fn on_alarm(&self) -> Event { + Event { id: 48 + TG::id() } } } - impl TimerEtmTasks for Timer0 + impl Tasks for Timer0 where TG: TimerGroupInstance, { - fn cnt_start(&self) -> TimerEtmTask { - TimerEtmTask { id: 88 + TG::id() } + fn cnt_start(&self) -> Task { + Task { id: 88 + TG::id() } } - fn alarm_start(&self) -> TimerEtmTask { - TimerEtmTask { id: 90 + TG::id() } + fn alarm_start(&self) -> Task { + Task { id: 90 + TG::id() } } - fn cnt_stop(&self) -> TimerEtmTask { - TimerEtmTask { id: 92 + TG::id() } + fn cnt_stop(&self) -> Task { + Task { id: 92 + TG::id() } } - fn cnt_reload(&self) -> TimerEtmTask { - TimerEtmTask { id: 94 + TG::id() } + fn cnt_reload(&self) -> Task { + Task { id: 94 + TG::id() } } - fn cnt_cap(&self) -> TimerEtmTask { - TimerEtmTask { id: 96 + TG::id() } + fn cnt_cap(&self) -> Task { + Task { id: 96 + TG::id() } } } } diff --git a/examples/src/bin/etm_blinky_systimer.rs b/examples/src/bin/etm_blinky_systimer.rs index 0a295c14ab1..afe20d18f47 100644 --- a/examples/src/bin/etm_blinky_systimer.rs +++ b/examples/src/bin/etm_blinky_systimer.rs @@ -18,7 +18,7 @@ use esp_hal::{ Pull, }, prelude::*, - timer::systimer::{etm::SysTimerEtmEvent, Periodic, SystemTimer}, + timer::systimer::{etm::Event, Periodic, SystemTimer}, }; use fugit::ExtU32; @@ -45,7 +45,7 @@ fn main() -> ! { }, ); - let timer_event = SysTimerEtmEvent::new(&mut alarm0); + let timer_event = Event::new(&mut alarm0); let etm = Etm::new(peripherals.SOC_ETM); let channel0 = etm.channel0; diff --git a/examples/src/bin/etm_timer.rs b/examples/src/bin/etm_timer.rs index d382c2755d3..34552926236 100644 --- a/examples/src/bin/etm_timer.rs +++ b/examples/src/bin/etm_timer.rs @@ -1,5 +1,5 @@ //! This shows how to use the general purpose timers ETM tasks and events -//! Notice you need to import the traits esp_hal::timer::etm::{TimerEtmEvents, TimerEtmTasks} +//! Notice you need to import the traits esp_hal::timer::etm::{Events, Tasks} //% CHIPS: esp32c6 esp32h2 @@ -16,7 +16,7 @@ use esp_hal::{ peripherals::TIMG0, prelude::*, timer::timg::{ - etm::{TimerEtmEvents, TimerEtmTasks}, + etm::{Events, Tasks}, Timer, Timer0, TimerGroup,