From 2df665da8ac601e043404e1ca6bd87a4fb01013f Mon Sep 17 00:00:00 2001 From: chemicstry Date: Tue, 12 Jul 2022 15:06:16 +0300 Subject: [PATCH] Revert "Make advanced timer trait not require general purpose timer trait as the timers are too different." This reverts commit 4988dfe98175f5d92d896edd2b9ee774a91b28d5. --- embassy-stm32/src/pwm/mod.rs | 4 ++-- embassy-stm32/src/timer/mod.rs | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/embassy-stm32/src/pwm/mod.rs b/embassy-stm32/src/pwm/mod.rs index 674740cc5..d3713391c 100644 --- a/embassy-stm32/src/pwm/mod.rs +++ b/embassy-stm32/src/pwm/mod.rs @@ -54,7 +54,7 @@ impl From for stm32_metapac::timer::vals::Ocm { pub(crate) mod sealed { use super::*; - pub trait CaptureCompare16bitInstance: crate::timer::sealed::Basic16bitInstance { + pub trait CaptureCompare16bitInstance: crate::timer::sealed::GeneralPurpose16bitInstance { /// Global output enable. Does not do anything on non-advanced timers. unsafe fn enable_outputs(&mut self, enable: bool); @@ -79,7 +79,7 @@ pub(crate) mod sealed { } pub trait CaptureCompare16bitInstance: - sealed::CaptureCompare16bitInstance + crate::timer::Basic16bitInstance + 'static + sealed::CaptureCompare16bitInstance + crate::timer::GeneralPurpose16bitInstance + 'static { } pub trait CaptureCompare32bitInstance: diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs index e92015ee9..772c67686 100644 --- a/embassy-stm32/src/timer/mod.rs +++ b/embassy-stm32/src/timer/mod.rs @@ -40,7 +40,7 @@ pub(crate) mod sealed { fn set_frequency(&mut self, frequency: Hertz); } - pub trait AdvancedControlInstance: Basic16bitInstance { + pub trait AdvancedControlInstance: GeneralPurpose16bitInstance { fn regs_advanced() -> crate::pac::timer::TimAdv; } } @@ -204,11 +204,21 @@ foreach_interrupt! { impl Basic16bitInstance for crate::peripherals::$inst { } + impl sealed::GeneralPurpose16bitInstance for crate::peripherals::$inst { + fn regs_gp16() -> crate::pac::timer::TimGp16 { + crate::pac::timer::TimGp16(crate::pac::$inst.0) + } + } + + impl GeneralPurpose16bitInstance for crate::peripherals::$inst { + } + impl sealed::AdvancedControlInstance for crate::peripherals::$inst { fn regs_advanced() -> crate::pac::timer::TimAdv { crate::pac::$inst } } + impl AdvancedControlInstance for crate::peripherals::$inst { } };