Skip to content

Commit

Permalink
Allow erasure of unit and comparator numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Fischer committed Aug 10, 2024
1 parent 2394d7d commit 527ca98
Show file tree
Hide file tree
Showing 4 changed files with 234 additions and 181 deletions.
64 changes: 10 additions & 54 deletions esp-hal/src/timer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,17 +376,9 @@ pub enum ErasedTimer {
#[cfg(all(timg1, timg_timer1))]
Timg1Timer1(timg::Timer<timg::Timer1<crate::peripherals::TIMG1>, Blocking>),
#[cfg(systimer)]
SystimerAlarm0Periodic(systimer::Alarm<'static, systimer::Periodic, Blocking, 0, 0>),
SystimerAlarmPeriodic(systimer::Alarm<'static, systimer::Periodic, Blocking>),
#[cfg(systimer)]
SystimerAlarm1Periodic(systimer::Alarm<'static, systimer::Periodic, Blocking, 1, 0>),
#[cfg(systimer)]
SystimerAlarm2Periodic(systimer::Alarm<'static, systimer::Periodic, Blocking, 2, 0>),
#[cfg(systimer)]
SystimerAlarm0Target(systimer::Alarm<'static, systimer::Target, Blocking, 0, 0>),
#[cfg(systimer)]
SystimerAlarm1Target(systimer::Alarm<'static, systimer::Target, Blocking, 1, 0>),
#[cfg(systimer)]
SystimerAlarm2Target(systimer::Alarm<'static, systimer::Target, Blocking, 2, 0>),
SystimerAlarmTarget(systimer::Alarm<'static, systimer::Target, Blocking>),
}

impl crate::private::Sealed for ErasedTimer {}
Expand Down Expand Up @@ -419,44 +411,16 @@ impl From<timg::Timer<timg::Timer1<crate::peripherals::TIMG1>, Blocking>> for Er
}

#[cfg(systimer)]
impl From<systimer::Alarm<'static, systimer::Periodic, Blocking, 0, 0>> for ErasedTimer {
fn from(value: systimer::Alarm<'static, systimer::Periodic, Blocking, 0, 0>) -> Self {
Self::SystimerAlarm0Periodic(value)
}
}

#[cfg(systimer)]
impl From<systimer::Alarm<'static, systimer::Periodic, Blocking, 1, 0>> for ErasedTimer {
fn from(value: systimer::Alarm<'static, systimer::Periodic, Blocking, 1, 0>) -> Self {
Self::SystimerAlarm1Periodic(value)
}
}

#[cfg(systimer)]
impl From<systimer::Alarm<'static, systimer::Periodic, Blocking, 2, 0>> for ErasedTimer {
fn from(value: systimer::Alarm<'static, systimer::Periodic, Blocking, 2, 0>) -> Self {
Self::SystimerAlarm2Periodic(value)
impl From<systimer::Alarm<'static, systimer::Periodic, Blocking>> for ErasedTimer {
fn from(value: systimer::Alarm<'static, systimer::Periodic, Blocking>) -> Self {
Self::SystimerAlarmPeriodic(value)
}
}

#[cfg(systimer)]
impl From<systimer::Alarm<'static, systimer::Target, Blocking, 0, 0>> for ErasedTimer {
fn from(value: systimer::Alarm<'static, systimer::Target, Blocking, 0, 0>) -> Self {
Self::SystimerAlarm0Target(value)
}
}

#[cfg(systimer)]
impl From<systimer::Alarm<'static, systimer::Target, Blocking, 1, 0>> for ErasedTimer {
fn from(value: systimer::Alarm<'static, systimer::Target, Blocking, 1, 0>) -> Self {
Self::SystimerAlarm1Target(value)
}
}

#[cfg(systimer)]
impl From<systimer::Alarm<'static, systimer::Target, Blocking, 2, 0>> for ErasedTimer {
fn from(value: systimer::Alarm<'static, systimer::Target, Blocking, 2, 0>) -> Self {
Self::SystimerAlarm2Target(value)
impl From<systimer::Alarm<'static, systimer::Target, Blocking>> for ErasedTimer {
fn from(value: systimer::Alarm<'static, systimer::Target, Blocking>) -> Self {
Self::SystimerAlarmTarget(value)
}
}

Expand All @@ -475,17 +439,9 @@ impl Timer for ErasedTimer {
#[cfg(all(timg1,timg_timer1))]
ErasedTimer::Timg1Timer1(inner) => inner,
#[cfg(systimer)]
ErasedTimer::SystimerAlarm0Periodic(inner) => inner,
#[cfg(systimer)]
ErasedTimer::SystimerAlarm1Periodic(inner) => inner,
#[cfg(systimer)]
ErasedTimer::SystimerAlarm2Periodic(inner) => inner,
#[cfg(systimer)]
ErasedTimer::SystimerAlarm0Target(inner) => inner,
#[cfg(systimer)]
ErasedTimer::SystimerAlarm1Target(inner) => inner,
ErasedTimer::SystimerAlarmPeriodic(inner) => inner,
#[cfg(systimer)]
ErasedTimer::SystimerAlarm2Target(inner) => inner,
ErasedTimer::SystimerAlarmTarget(inner) => inner,
} {
fn start(&self);
fn stop(&self);
Expand Down
Loading

0 comments on commit 527ca98

Please sign in to comment.