diff --git a/esp-hal/src/mcpwm/mod.rs b/esp-hal/src/mcpwm/mod.rs index d0d294a45bb..4573881bb46 100644 --- a/esp-hal/src/mcpwm/mod.rs +++ b/esp-hal/src/mcpwm/mod.rs @@ -282,11 +282,7 @@ impl<'a> PeripheralClockConfig<'a> { pub struct FrequencyError; /// A MCPWM peripheral -/// -/// # Safety -/// -/// ??? -pub unsafe trait PwmPeripheral: Deref { +pub trait PwmPeripheral: Deref + private::Sealed { /// Enable peripheral fn enable(); /// Get a pointer to the peripheral RegisterBlock @@ -296,7 +292,7 @@ pub unsafe trait PwmPeripheral: Deref { } #[cfg(mcpwm0)] -unsafe impl PwmPeripheral for crate::peripherals::MCPWM0 { +impl PwmPeripheral for crate::peripherals::MCPWM0 { fn enable() { PeripheralClockControl::enable(PeripheralEnable::Mcpwm0) } @@ -319,7 +315,7 @@ unsafe impl PwmPeripheral for crate::peripherals::MCPWM0 { } #[cfg(mcpwm1)] -unsafe impl PwmPeripheral for crate::peripherals::MCPWM1 { +impl PwmPeripheral for crate::peripherals::MCPWM1 { fn enable() { PeripheralClockControl::enable(PeripheralEnable::Mcpwm1) } @@ -340,3 +336,13 @@ unsafe impl PwmPeripheral for crate::peripherals::MCPWM1 { } } } + +mod private { + pub trait Sealed {} +} + +#[cfg(mcpwm0)] +impl private::Sealed for crate::peripherals::MCPWM0 {} + +#[cfg(mcpwm1)] +impl private::Sealed for crate::peripherals::MCPWM1 {}