Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion esp-hal-common/src/embassy/time_driver_systimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{

pub const ALARM_COUNT: usize = 3;

pub type TimerType = SystemTimer;
pub type TimerType = SystemTimer<'static>;

pub struct EmbassyTimer {
pub(crate) alarms: Mutex<[AlarmState; ALARM_COUNT]>,
Expand Down
1 change: 1 addition & 0 deletions esp-hal-common/src/peripherals/esp32c2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ mod peripherals {
SPI0,
SPI1,
SPI2,
SYSTIMER,
}
}
1 change: 1 addition & 0 deletions esp-hal-common/src/peripherals/esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ mod peripherals {
SPI0,
SPI1,
SPI2,
SYSTIMER,
}
}
1 change: 1 addition & 0 deletions esp-hal-common/src/peripherals/esp32s2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@ mod peripherals {
SPI2,
SPI3,
SPI4,
SYSTIMER,
}
}
1 change: 1 addition & 0 deletions esp-hal-common/src/peripherals/esp32s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ mod peripherals {
SPI1,
SPI2,
SPI3,
SYSTIMER,
}
}
27 changes: 15 additions & 12 deletions esp-hal-common/src/systimer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@ use core::{intrinsics::transmute, marker::PhantomData};

use fugit::MillisDurationU32;

use crate::pac::{
generic::Reg,
systimer::{
target0_conf::TARGET0_CONF_SPEC,
target0_hi::TARGET0_HI_SPEC,
target0_lo::TARGET0_LO_SPEC,
use crate::{
pac::{
generic::Reg,
systimer::{
target0_conf::TARGET0_CONF_SPEC,
target0_hi::TARGET0_HI_SPEC,
target0_lo::TARGET0_LO_SPEC,
},
},
SYSTIMER,
peripheral::{Peripheral, PeripheralRef},
peripherals::SYSTIMER,
};

// TODO this only handles unit0 of the systimer

#[derive(Debug)]
pub struct SystemTimer {
_inner: SYSTIMER,
pub struct SystemTimer<'d> {
_inner: PeripheralRef<'d, SYSTIMER>,
pub alarm0: Alarm<Target, 0>,
pub alarm1: Alarm<Target, 1>,
pub alarm2: Alarm<Target, 2>,
}

impl SystemTimer {
impl<'d> SystemTimer<'d> {
#[cfg(esp32s2)]
pub const BIT_MASK: u64 = u64::MAX;
#[cfg(any(esp32c2, esp32c3, esp32s3))]
Expand All @@ -33,7 +35,8 @@ impl SystemTimer {
#[cfg(any(esp32c2, esp32c3, esp32s3))]
pub const TICKS_PER_SECOND: u64 = 16_000_000;

pub fn new(p: SYSTIMER) -> Self {
pub fn new(p: impl Peripheral<P = SYSTIMER> + 'd) -> Self {
crate::into_ref!(p);
Self {
_inner: p,
alarm0: Alarm::new(),
Expand Down