Skip to content

Commit

Permalink
Improve SYSTIMER API
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Fischer committed Jul 28, 2024
1 parent 237804e commit c6b1a79
Show file tree
Hide file tree
Showing 12 changed files with 690 additions and 329 deletions.
2 changes: 1 addition & 1 deletion esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Peripheral driver constructors don't take `InterruptHandler`s anymore. Use `set_interrupt_handler` to explicitly set the interrupt handler now. (#1819)
- Use the peripheral ref pattern for `OneShotTimer` and `PeriodicTimer` (#1855)

- Improve SYSTIMER API (#1870)
- Allow DMA to/from psram for esp32s3 (#1827)
- DMA buffers now don't require a static lifetime. Make sure to never `mem::forget` an in-progress DMA transfer (consider using `#[deny(clippy::mem_forget)]`) (#1837)

Expand Down
36 changes: 18 additions & 18 deletions esp-hal/src/timer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,17 +376,17 @@ pub enum ErasedTimer {
#[cfg(all(timg1, timg_timer1))]
Timg1Timer1(timg::Timer<timg::Timer1<crate::peripherals::TIMG1>, Blocking>),
#[cfg(systimer)]
SystimerAlarm0Periodic(systimer::Alarm<systimer::Periodic, Blocking, 0>),
SystimerAlarm0Periodic(systimer::Alarm<'static, systimer::Periodic, Blocking, 0, 0>),
#[cfg(systimer)]
SystimerAlarm1Periodic(systimer::Alarm<systimer::Periodic, Blocking, 1>),
SystimerAlarm1Periodic(systimer::Alarm<'static, systimer::Periodic, Blocking, 1, 0>),
#[cfg(systimer)]
SystimerAlarm2Periodic(systimer::Alarm<systimer::Periodic, Blocking, 2>),
SystimerAlarm2Periodic(systimer::Alarm<'static, systimer::Periodic, Blocking, 2, 0>),
#[cfg(systimer)]
SystimerAlarm0Target(systimer::Alarm<systimer::Target, Blocking, 0>),
SystimerAlarm0Target(systimer::Alarm<'static, systimer::Target, Blocking, 0, 0>),
#[cfg(systimer)]
SystimerAlarm1Target(systimer::Alarm<systimer::Target, Blocking, 1>),
SystimerAlarm1Target(systimer::Alarm<'static, systimer::Target, Blocking, 1, 0>),
#[cfg(systimer)]
SystimerAlarm2Target(systimer::Alarm<systimer::Target, Blocking, 2>),
SystimerAlarm2Target(systimer::Alarm<'static, systimer::Target, Blocking, 2, 0>),
}

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

#[cfg(systimer)]
impl From<systimer::Alarm<systimer::Periodic, Blocking, 0>> for ErasedTimer {
fn from(value: systimer::Alarm<systimer::Periodic, Blocking, 0>) -> Self {
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<systimer::Periodic, Blocking, 1>> for ErasedTimer {
fn from(value: systimer::Alarm<systimer::Periodic, Blocking, 1>) -> Self {
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<systimer::Periodic, Blocking, 2>> for ErasedTimer {
fn from(value: systimer::Alarm<systimer::Periodic, Blocking, 2>) -> Self {
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)
}
}

#[cfg(systimer)]
impl From<systimer::Alarm<systimer::Target, Blocking, 0>> for ErasedTimer {
fn from(value: systimer::Alarm<systimer::Target, Blocking, 0>) -> Self {
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<systimer::Target, Blocking, 1>> for ErasedTimer {
fn from(value: systimer::Alarm<systimer::Target, Blocking, 1>) -> Self {
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<systimer::Target, Blocking, 2>> for ErasedTimer {
fn from(value: systimer::Alarm<systimer::Target, Blocking, 2>) -> Self {
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)
}
}
Expand Down
Loading

0 comments on commit c6b1a79

Please sign in to comment.