diff options
| -rw-r--r-- | embassy-stm32/build.rs | 30 | ||||
| -rw-r--r-- | embassy-stm32/src/lib.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32/src/pwm/mod.rs | 269 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/complementary_pwm.rs (renamed from embassy-stm32/src/pwm/complementary_pwm.rs) | 0 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/mod.rs | 271 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/simple_pwm.rs (renamed from embassy-stm32/src/pwm/simple_pwm.rs) | 0 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/pwm.rs | 4 | ||||
| -rw-r--r-- | examples/stm32f4/src/bin/pwm_complementary.rs | 6 | ||||
| -rw-r--r-- | examples/stm32g4/src/bin/pwm.rs | 4 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/low_level_timer_api.rs | 2 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/pwm.rs | 4 |
11 files changed, 271 insertions, 320 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 0e9606ec3..409a943d2 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -572,21 +572,21 @@ fn main() { | |||
| 572 | (("fmc", "Clk"), quote!(crate::fmc::ClkPin)), | 572 | (("fmc", "Clk"), quote!(crate::fmc::ClkPin)), |
| 573 | (("fmc", "BA0"), quote!(crate::fmc::BA0Pin)), | 573 | (("fmc", "BA0"), quote!(crate::fmc::BA0Pin)), |
| 574 | (("fmc", "BA1"), quote!(crate::fmc::BA1Pin)), | 574 | (("fmc", "BA1"), quote!(crate::fmc::BA1Pin)), |
| 575 | (("timer", "CH1"), quote!(crate::pwm::Channel1Pin)), | 575 | (("timer", "CH1"), quote!(crate::timer::Channel1Pin)), |
| 576 | (("timer", "CH1N"), quote!(crate::pwm::Channel1ComplementaryPin)), | 576 | (("timer", "CH1N"), quote!(crate::timer::Channel1ComplementaryPin)), |
| 577 | (("timer", "CH2"), quote!(crate::pwm::Channel2Pin)), | 577 | (("timer", "CH2"), quote!(crate::timer::Channel2Pin)), |
| 578 | (("timer", "CH2N"), quote!(crate::pwm::Channel2ComplementaryPin)), | 578 | (("timer", "CH2N"), quote!(crate::timer::Channel2ComplementaryPin)), |
| 579 | (("timer", "CH3"), quote!(crate::pwm::Channel3Pin)), | 579 | (("timer", "CH3"), quote!(crate::timer::Channel3Pin)), |
| 580 | (("timer", "CH3N"), quote!(crate::pwm::Channel3ComplementaryPin)), | 580 | (("timer", "CH3N"), quote!(crate::timer::Channel3ComplementaryPin)), |
| 581 | (("timer", "CH4"), quote!(crate::pwm::Channel4Pin)), | 581 | (("timer", "CH4"), quote!(crate::timer::Channel4Pin)), |
| 582 | (("timer", "CH4N"), quote!(crate::pwm::Channel4ComplementaryPin)), | 582 | (("timer", "CH4N"), quote!(crate::timer::Channel4ComplementaryPin)), |
| 583 | (("timer", "ETR"), quote!(crate::pwm::ExternalTriggerPin)), | 583 | (("timer", "ETR"), quote!(crate::timer::ExternalTriggerPin)), |
| 584 | (("timer", "BKIN"), quote!(crate::pwm::BreakInputPin)), | 584 | (("timer", "BKIN"), quote!(crate::timer::BreakInputPin)), |
| 585 | (("timer", "BKIN_COMP1"), quote!(crate::pwm::BreakInputComparator1Pin)), | 585 | (("timer", "BKIN_COMP1"), quote!(crate::timer::BreakInputComparator1Pin)), |
| 586 | (("timer", "BKIN_COMP2"), quote!(crate::pwm::BreakInputComparator2Pin)), | 586 | (("timer", "BKIN_COMP2"), quote!(crate::timer::BreakInputComparator2Pin)), |
| 587 | (("timer", "BKIN2"), quote!(crate::pwm::BreakInput2Pin)), | 587 | (("timer", "BKIN2"), quote!(crate::timer::BreakInput2Pin)), |
| 588 | (("timer", "BKIN2_COMP1"), quote!(crate::pwm::BreakInput2Comparator1Pin)), | 588 | (("timer", "BKIN2_COMP1"), quote!(crate::timer::BreakInput2Comparator1Pin)), |
| 589 | (("timer", "BKIN2_COMP2"), quote!(crate::pwm::BreakInput2Comparator2Pin)), | 589 | (("timer", "BKIN2_COMP2"), quote!(crate::timer::BreakInput2Comparator2Pin)), |
| 590 | (("sdmmc", "CK"), quote!(crate::sdmmc::CkPin)), | 590 | (("sdmmc", "CK"), quote!(crate::sdmmc::CkPin)), |
| 591 | (("sdmmc", "CMD"), quote!(crate::sdmmc::CmdPin)), | 591 | (("sdmmc", "CMD"), quote!(crate::sdmmc::CmdPin)), |
| 592 | (("sdmmc", "D0"), quote!(crate::sdmmc::D0Pin)), | 592 | (("sdmmc", "D0"), quote!(crate::sdmmc::D0Pin)), |
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index ebd0e7cd5..bb2ef2fc0 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -43,7 +43,6 @@ pub mod flash; | |||
| 43 | pub mod i2s; | 43 | pub mod i2s; |
| 44 | #[cfg(stm32wb)] | 44 | #[cfg(stm32wb)] |
| 45 | pub mod ipcc; | 45 | pub mod ipcc; |
| 46 | pub mod pwm; | ||
| 47 | #[cfg(quadspi)] | 46 | #[cfg(quadspi)] |
| 48 | pub mod qspi; | 47 | pub mod qspi; |
| 49 | #[cfg(rng)] | 48 | #[cfg(rng)] |
diff --git a/embassy-stm32/src/pwm/mod.rs b/embassy-stm32/src/pwm/mod.rs deleted file mode 100644 index 5aba2663e..000000000 --- a/embassy-stm32/src/pwm/mod.rs +++ /dev/null | |||
| @@ -1,269 +0,0 @@ | |||
| 1 | pub mod complementary_pwm; | ||
| 2 | pub mod simple_pwm; | ||
| 3 | |||
| 4 | use stm32_metapac::timer::vals::Ckd; | ||
| 5 | |||
| 6 | #[cfg(feature = "unstable-pac")] | ||
| 7 | pub mod low_level { | ||
| 8 | pub use super::sealed::*; | ||
| 9 | } | ||
| 10 | |||
| 11 | #[derive(Clone, Copy)] | ||
| 12 | pub enum Channel { | ||
| 13 | Ch1, | ||
| 14 | Ch2, | ||
| 15 | Ch3, | ||
| 16 | Ch4, | ||
| 17 | } | ||
| 18 | |||
| 19 | impl Channel { | ||
| 20 | pub fn raw(&self) -> usize { | ||
| 21 | match self { | ||
| 22 | Channel::Ch1 => 0, | ||
| 23 | Channel::Ch2 => 1, | ||
| 24 | Channel::Ch3 => 2, | ||
| 25 | Channel::Ch4 => 3, | ||
| 26 | } | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | #[derive(Clone, Copy)] | ||
| 31 | pub enum OutputCompareMode { | ||
| 32 | Frozen, | ||
| 33 | ActiveOnMatch, | ||
| 34 | InactiveOnMatch, | ||
| 35 | Toggle, | ||
| 36 | ForceInactive, | ||
| 37 | ForceActive, | ||
| 38 | PwmMode1, | ||
| 39 | PwmMode2, | ||
| 40 | } | ||
| 41 | |||
| 42 | impl From<OutputCompareMode> for stm32_metapac::timer::vals::Ocm { | ||
| 43 | fn from(mode: OutputCompareMode) -> Self { | ||
| 44 | match mode { | ||
| 45 | OutputCompareMode::Frozen => stm32_metapac::timer::vals::Ocm::FROZEN, | ||
| 46 | OutputCompareMode::ActiveOnMatch => stm32_metapac::timer::vals::Ocm::ACTIVEONMATCH, | ||
| 47 | OutputCompareMode::InactiveOnMatch => stm32_metapac::timer::vals::Ocm::INACTIVEONMATCH, | ||
| 48 | OutputCompareMode::Toggle => stm32_metapac::timer::vals::Ocm::TOGGLE, | ||
| 49 | OutputCompareMode::ForceInactive => stm32_metapac::timer::vals::Ocm::FORCEINACTIVE, | ||
| 50 | OutputCompareMode::ForceActive => stm32_metapac::timer::vals::Ocm::FORCEACTIVE, | ||
| 51 | OutputCompareMode::PwmMode1 => stm32_metapac::timer::vals::Ocm::PWMMODE1, | ||
| 52 | OutputCompareMode::PwmMode2 => stm32_metapac::timer::vals::Ocm::PWMMODE2, | ||
| 53 | } | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | pub(crate) mod sealed { | ||
| 58 | use super::*; | ||
| 59 | |||
| 60 | pub trait CaptureCompare16bitInstance: crate::timer::sealed::GeneralPurpose16bitInstance { | ||
| 61 | /// Global output enable. Does not do anything on non-advanced timers. | ||
| 62 | fn enable_outputs(&mut self, enable: bool); | ||
| 63 | |||
| 64 | fn set_output_compare_mode(&mut self, channel: Channel, mode: OutputCompareMode); | ||
| 65 | |||
| 66 | fn enable_channel(&mut self, channel: Channel, enable: bool); | ||
| 67 | |||
| 68 | fn set_compare_value(&mut self, channel: Channel, value: u16); | ||
| 69 | |||
| 70 | fn get_max_compare_value(&self) -> u16; | ||
| 71 | } | ||
| 72 | |||
| 73 | pub trait ComplementaryCaptureCompare16bitInstance: CaptureCompare16bitInstance { | ||
| 74 | fn set_dead_time_clock_division(&mut self, value: Ckd); | ||
| 75 | |||
| 76 | fn set_dead_time_value(&mut self, value: u8); | ||
| 77 | |||
| 78 | fn enable_complementary_channel(&mut self, channel: Channel, enable: bool); | ||
| 79 | } | ||
| 80 | |||
| 81 | pub trait CaptureCompare32bitInstance: crate::timer::sealed::GeneralPurpose32bitInstance { | ||
| 82 | fn set_output_compare_mode(&mut self, channel: Channel, mode: OutputCompareMode); | ||
| 83 | |||
| 84 | fn enable_channel(&mut self, channel: Channel, enable: bool); | ||
| 85 | |||
| 86 | fn set_compare_value(&mut self, channel: Channel, value: u32); | ||
| 87 | |||
| 88 | fn get_max_compare_value(&self) -> u32; | ||
| 89 | } | ||
| 90 | } | ||
| 91 | |||
| 92 | pub trait CaptureCompare16bitInstance: | ||
| 93 | sealed::CaptureCompare16bitInstance + crate::timer::GeneralPurpose16bitInstance + 'static | ||
| 94 | { | ||
| 95 | } | ||
| 96 | |||
| 97 | pub trait ComplementaryCaptureCompare16bitInstance: | ||
| 98 | sealed::ComplementaryCaptureCompare16bitInstance + crate::timer::AdvancedControlInstance + 'static | ||
| 99 | { | ||
| 100 | } | ||
| 101 | |||
| 102 | pub trait CaptureCompare32bitInstance: | ||
| 103 | sealed::CaptureCompare32bitInstance + CaptureCompare16bitInstance + crate::timer::GeneralPurpose32bitInstance + 'static | ||
| 104 | { | ||
| 105 | } | ||
| 106 | |||
| 107 | #[allow(unused)] | ||
| 108 | macro_rules! impl_compare_capable_16bit { | ||
| 109 | ($inst:ident) => { | ||
| 110 | impl crate::pwm::sealed::CaptureCompare16bitInstance for crate::peripherals::$inst { | ||
| 111 | fn enable_outputs(&mut self, _enable: bool) {} | ||
| 112 | |||
| 113 | fn set_output_compare_mode(&mut self, channel: crate::pwm::Channel, mode: OutputCompareMode) { | ||
| 114 | use crate::timer::sealed::GeneralPurpose16bitInstance; | ||
| 115 | let r = Self::regs_gp16(); | ||
| 116 | let raw_channel: usize = channel.raw(); | ||
| 117 | r.ccmr_output(raw_channel / 2) | ||
| 118 | .modify(|w| w.set_ocm(raw_channel % 2, mode.into())); | ||
| 119 | } | ||
| 120 | |||
| 121 | fn enable_channel(&mut self, channel: Channel, enable: bool) { | ||
| 122 | use crate::timer::sealed::GeneralPurpose16bitInstance; | ||
| 123 | Self::regs_gp16() | ||
| 124 | .ccer() | ||
| 125 | .modify(|w| w.set_cce(channel.raw(), enable)); | ||
| 126 | } | ||
| 127 | |||
| 128 | fn set_compare_value(&mut self, channel: Channel, value: u16) { | ||
| 129 | use crate::timer::sealed::GeneralPurpose16bitInstance; | ||
| 130 | Self::regs_gp16().ccr(channel.raw()).modify(|w| w.set_ccr(value)); | ||
| 131 | } | ||
| 132 | |||
| 133 | fn get_max_compare_value(&self) -> u16 { | ||
| 134 | use crate::timer::sealed::GeneralPurpose16bitInstance; | ||
| 135 | Self::regs_gp16().arr().read().arr() | ||
| 136 | } | ||
| 137 | } | ||
| 138 | }; | ||
| 139 | } | ||
| 140 | |||
| 141 | foreach_interrupt! { | ||
| 142 | ($inst:ident, timer, TIM_GP16, UP, $irq:ident) => { | ||
| 143 | impl_compare_capable_16bit!($inst); | ||
| 144 | |||
| 145 | impl CaptureCompare16bitInstance for crate::peripherals::$inst { | ||
| 146 | |||
| 147 | } | ||
| 148 | }; | ||
| 149 | |||
| 150 | ($inst:ident, timer, TIM_GP32, UP, $irq:ident) => { | ||
| 151 | impl_compare_capable_16bit!($inst); | ||
| 152 | impl crate::pwm::sealed::CaptureCompare32bitInstance for crate::peripherals::$inst { | ||
| 153 | fn set_output_compare_mode( | ||
| 154 | &mut self, | ||
| 155 | channel: crate::pwm::Channel, | ||
| 156 | mode: OutputCompareMode, | ||
| 157 | ) { | ||
| 158 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 159 | let raw_channel = channel.raw(); | ||
| 160 | Self::regs_gp32().ccmr_output(raw_channel / 2).modify(|w| w.set_ocm(raw_channel % 2, mode.into())); | ||
| 161 | } | ||
| 162 | |||
| 163 | fn enable_channel(&mut self, channel: Channel, enable: bool) { | ||
| 164 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 165 | Self::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), enable)); | ||
| 166 | } | ||
| 167 | |||
| 168 | fn set_compare_value(&mut self, channel: Channel, value: u32) { | ||
| 169 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 170 | Self::regs_gp32().ccr(channel.raw()).modify(|w| w.set_ccr(value)); | ||
| 171 | } | ||
| 172 | |||
| 173 | fn get_max_compare_value(&self) -> u32 { | ||
| 174 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 175 | Self::regs_gp32().arr().read().arr() as u32 | ||
| 176 | } | ||
| 177 | } | ||
| 178 | impl CaptureCompare16bitInstance for crate::peripherals::$inst { | ||
| 179 | |||
| 180 | } | ||
| 181 | impl CaptureCompare32bitInstance for crate::peripherals::$inst { | ||
| 182 | |||
| 183 | } | ||
| 184 | }; | ||
| 185 | |||
| 186 | ($inst:ident, timer, TIM_ADV, UP, $irq:ident) => { | ||
| 187 | impl crate::pwm::sealed::CaptureCompare16bitInstance for crate::peripherals::$inst { | ||
| 188 | fn enable_outputs(&mut self, enable: bool) { | ||
| 189 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 190 | let r = Self::regs_advanced(); | ||
| 191 | r.bdtr().modify(|w| w.set_moe(enable)); | ||
| 192 | } | ||
| 193 | |||
| 194 | fn set_output_compare_mode( | ||
| 195 | &mut self, | ||
| 196 | channel: crate::pwm::Channel, | ||
| 197 | mode: OutputCompareMode, | ||
| 198 | ) { | ||
| 199 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 200 | let r = Self::regs_advanced(); | ||
| 201 | let raw_channel: usize = channel.raw(); | ||
| 202 | r.ccmr_output(raw_channel / 2) | ||
| 203 | .modify(|w| w.set_ocm(raw_channel % 2, mode.into())); | ||
| 204 | } | ||
| 205 | |||
| 206 | fn enable_channel(&mut self, channel: Channel, enable: bool) { | ||
| 207 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 208 | Self::regs_advanced() | ||
| 209 | .ccer() | ||
| 210 | .modify(|w| w.set_cce(channel.raw(), enable)); | ||
| 211 | } | ||
| 212 | |||
| 213 | fn set_compare_value(&mut self, channel: Channel, value: u16) { | ||
| 214 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 215 | Self::regs_advanced() | ||
| 216 | .ccr(channel.raw()) | ||
| 217 | .modify(|w| w.set_ccr(value)); | ||
| 218 | } | ||
| 219 | |||
| 220 | fn get_max_compare_value(&self) -> u16 { | ||
| 221 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 222 | Self::regs_advanced().arr().read().arr() | ||
| 223 | } | ||
| 224 | } | ||
| 225 | |||
| 226 | impl CaptureCompare16bitInstance for crate::peripherals::$inst { | ||
| 227 | |||
| 228 | } | ||
| 229 | |||
| 230 | impl crate::pwm::sealed::ComplementaryCaptureCompare16bitInstance for crate::peripherals::$inst { | ||
| 231 | fn set_dead_time_clock_division(&mut self, value: Ckd) { | ||
| 232 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 233 | Self::regs_advanced().cr1().modify(|w| w.set_ckd(value)); | ||
| 234 | } | ||
| 235 | |||
| 236 | fn set_dead_time_value(&mut self, value: u8) { | ||
| 237 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 238 | Self::regs_advanced().bdtr().modify(|w| w.set_dtg(value)); | ||
| 239 | } | ||
| 240 | |||
| 241 | fn enable_complementary_channel(&mut self, channel: Channel, enable: bool) { | ||
| 242 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 243 | Self::regs_advanced() | ||
| 244 | .ccer() | ||
| 245 | .modify(|w| w.set_ccne(channel.raw(), enable)); | ||
| 246 | } | ||
| 247 | } | ||
| 248 | |||
| 249 | impl ComplementaryCaptureCompare16bitInstance for crate::peripherals::$inst { | ||
| 250 | |||
| 251 | } | ||
| 252 | }; | ||
| 253 | } | ||
| 254 | |||
| 255 | pin_trait!(Channel1Pin, CaptureCompare16bitInstance); | ||
| 256 | pin_trait!(Channel1ComplementaryPin, CaptureCompare16bitInstance); | ||
| 257 | pin_trait!(Channel2Pin, CaptureCompare16bitInstance); | ||
| 258 | pin_trait!(Channel2ComplementaryPin, CaptureCompare16bitInstance); | ||
| 259 | pin_trait!(Channel3Pin, CaptureCompare16bitInstance); | ||
| 260 | pin_trait!(Channel3ComplementaryPin, CaptureCompare16bitInstance); | ||
| 261 | pin_trait!(Channel4Pin, CaptureCompare16bitInstance); | ||
| 262 | pin_trait!(Channel4ComplementaryPin, CaptureCompare16bitInstance); | ||
| 263 | pin_trait!(ExternalTriggerPin, CaptureCompare16bitInstance); | ||
| 264 | pin_trait!(BreakInputPin, CaptureCompare16bitInstance); | ||
| 265 | pin_trait!(BreakInputComparator1Pin, CaptureCompare16bitInstance); | ||
| 266 | pin_trait!(BreakInputComparator2Pin, CaptureCompare16bitInstance); | ||
| 267 | pin_trait!(BreakInput2Pin, CaptureCompare16bitInstance); | ||
| 268 | pin_trait!(BreakInput2Comparator1Pin, CaptureCompare16bitInstance); | ||
| 269 | pin_trait!(BreakInput2Comparator2Pin, CaptureCompare16bitInstance); | ||
diff --git a/embassy-stm32/src/pwm/complementary_pwm.rs b/embassy-stm32/src/timer/complementary_pwm.rs index 64bb32c39..64bb32c39 100644 --- a/embassy-stm32/src/pwm/complementary_pwm.rs +++ b/embassy-stm32/src/timer/complementary_pwm.rs | |||
diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs index 09b7a3776..6c2d6d827 100644 --- a/embassy-stm32/src/timer/mod.rs +++ b/embassy-stm32/src/timer/mod.rs | |||
| @@ -1,3 +1,6 @@ | |||
| 1 | pub mod complementary_pwm; | ||
| 2 | pub mod simple_pwm; | ||
| 3 | |||
| 1 | use stm32_metapac::timer::vals; | 4 | use stm32_metapac::timer::vals; |
| 2 | 5 | ||
| 3 | use crate::interrupt; | 6 | use crate::interrupt; |
| @@ -43,15 +46,123 @@ pub(crate) mod sealed { | |||
| 43 | pub trait AdvancedControlInstance: GeneralPurpose16bitInstance { | 46 | pub trait AdvancedControlInstance: GeneralPurpose16bitInstance { |
| 44 | fn regs_advanced() -> crate::pac::timer::TimAdv; | 47 | fn regs_advanced() -> crate::pac::timer::TimAdv; |
| 45 | } | 48 | } |
| 49 | |||
| 50 | pub trait CaptureCompare16bitInstance: GeneralPurpose16bitInstance { | ||
| 51 | /// Global output enable. Does not do anything on non-advanced timers. | ||
| 52 | fn enable_outputs(&mut self, enable: bool); | ||
| 53 | |||
| 54 | fn set_output_compare_mode(&mut self, channel: Channel, mode: OutputCompareMode); | ||
| 55 | |||
| 56 | fn enable_channel(&mut self, channel: Channel, enable: bool); | ||
| 57 | |||
| 58 | fn set_compare_value(&mut self, channel: Channel, value: u16); | ||
| 59 | |||
| 60 | fn get_max_compare_value(&self) -> u16; | ||
| 61 | } | ||
| 62 | |||
| 63 | pub trait ComplementaryCaptureCompare16bitInstance: CaptureCompare16bitInstance { | ||
| 64 | fn set_dead_time_clock_division(&mut self, value: vals::Ckd); | ||
| 65 | |||
| 66 | fn set_dead_time_value(&mut self, value: u8); | ||
| 67 | |||
| 68 | fn enable_complementary_channel(&mut self, channel: Channel, enable: bool); | ||
| 69 | } | ||
| 70 | |||
| 71 | pub trait CaptureCompare32bitInstance: GeneralPurpose32bitInstance { | ||
| 72 | fn set_output_compare_mode(&mut self, channel: Channel, mode: OutputCompareMode); | ||
| 73 | |||
| 74 | fn enable_channel(&mut self, channel: Channel, enable: bool); | ||
| 75 | |||
| 76 | fn set_compare_value(&mut self, channel: Channel, value: u32); | ||
| 77 | |||
| 78 | fn get_max_compare_value(&self) -> u32; | ||
| 79 | } | ||
| 80 | } | ||
| 81 | |||
| 82 | #[derive(Clone, Copy)] | ||
| 83 | pub enum Channel { | ||
| 84 | Ch1, | ||
| 85 | Ch2, | ||
| 86 | Ch3, | ||
| 87 | Ch4, | ||
| 46 | } | 88 | } |
| 47 | 89 | ||
| 90 | impl Channel { | ||
| 91 | pub fn raw(&self) -> usize { | ||
| 92 | match self { | ||
| 93 | Channel::Ch1 => 0, | ||
| 94 | Channel::Ch2 => 1, | ||
| 95 | Channel::Ch3 => 2, | ||
| 96 | Channel::Ch4 => 3, | ||
| 97 | } | ||
| 98 | } | ||
| 99 | } | ||
| 100 | |||
| 101 | #[derive(Clone, Copy)] | ||
| 102 | pub enum OutputCompareMode { | ||
| 103 | Frozen, | ||
| 104 | ActiveOnMatch, | ||
| 105 | InactiveOnMatch, | ||
| 106 | Toggle, | ||
| 107 | ForceInactive, | ||
| 108 | ForceActive, | ||
| 109 | PwmMode1, | ||
| 110 | PwmMode2, | ||
| 111 | } | ||
| 112 | |||
| 113 | impl From<OutputCompareMode> for stm32_metapac::timer::vals::Ocm { | ||
| 114 | fn from(mode: OutputCompareMode) -> Self { | ||
| 115 | match mode { | ||
| 116 | OutputCompareMode::Frozen => stm32_metapac::timer::vals::Ocm::FROZEN, | ||
| 117 | OutputCompareMode::ActiveOnMatch => stm32_metapac::timer::vals::Ocm::ACTIVEONMATCH, | ||
| 118 | OutputCompareMode::InactiveOnMatch => stm32_metapac::timer::vals::Ocm::INACTIVEONMATCH, | ||
| 119 | OutputCompareMode::Toggle => stm32_metapac::timer::vals::Ocm::TOGGLE, | ||
| 120 | OutputCompareMode::ForceInactive => stm32_metapac::timer::vals::Ocm::FORCEINACTIVE, | ||
| 121 | OutputCompareMode::ForceActive => stm32_metapac::timer::vals::Ocm::FORCEACTIVE, | ||
| 122 | OutputCompareMode::PwmMode1 => stm32_metapac::timer::vals::Ocm::PWMMODE1, | ||
| 123 | OutputCompareMode::PwmMode2 => stm32_metapac::timer::vals::Ocm::PWMMODE2, | ||
| 124 | } | ||
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | pub trait Basic16bitInstance: sealed::Basic16bitInstance + 'static {} | ||
| 129 | |||
| 48 | pub trait GeneralPurpose16bitInstance: sealed::GeneralPurpose16bitInstance + 'static {} | 130 | pub trait GeneralPurpose16bitInstance: sealed::GeneralPurpose16bitInstance + 'static {} |
| 49 | 131 | ||
| 50 | pub trait GeneralPurpose32bitInstance: sealed::GeneralPurpose32bitInstance + 'static {} | 132 | pub trait GeneralPurpose32bitInstance: sealed::GeneralPurpose32bitInstance + 'static {} |
| 51 | 133 | ||
| 52 | pub trait AdvancedControlInstance: sealed::AdvancedControlInstance + 'static {} | 134 | pub trait AdvancedControlInstance: sealed::AdvancedControlInstance + 'static {} |
| 53 | 135 | ||
| 54 | pub trait Basic16bitInstance: sealed::Basic16bitInstance + 'static {} | 136 | pub trait CaptureCompare16bitInstance: |
| 137 | sealed::CaptureCompare16bitInstance + GeneralPurpose16bitInstance + 'static | ||
| 138 | { | ||
| 139 | } | ||
| 140 | |||
| 141 | pub trait ComplementaryCaptureCompare16bitInstance: | ||
| 142 | sealed::ComplementaryCaptureCompare16bitInstance + AdvancedControlInstance + 'static | ||
| 143 | { | ||
| 144 | } | ||
| 145 | |||
| 146 | pub trait CaptureCompare32bitInstance: | ||
| 147 | sealed::CaptureCompare32bitInstance + CaptureCompare16bitInstance + GeneralPurpose32bitInstance + 'static | ||
| 148 | { | ||
| 149 | } | ||
| 150 | |||
| 151 | pin_trait!(Channel1Pin, CaptureCompare16bitInstance); | ||
| 152 | pin_trait!(Channel1ComplementaryPin, CaptureCompare16bitInstance); | ||
| 153 | pin_trait!(Channel2Pin, CaptureCompare16bitInstance); | ||
| 154 | pin_trait!(Channel2ComplementaryPin, CaptureCompare16bitInstance); | ||
| 155 | pin_trait!(Channel3Pin, CaptureCompare16bitInstance); | ||
| 156 | pin_trait!(Channel3ComplementaryPin, CaptureCompare16bitInstance); | ||
| 157 | pin_trait!(Channel4Pin, CaptureCompare16bitInstance); | ||
| 158 | pin_trait!(Channel4ComplementaryPin, CaptureCompare16bitInstance); | ||
| 159 | pin_trait!(ExternalTriggerPin, CaptureCompare16bitInstance); | ||
| 160 | pin_trait!(BreakInputPin, CaptureCompare16bitInstance); | ||
| 161 | pin_trait!(BreakInputComparator1Pin, CaptureCompare16bitInstance); | ||
| 162 | pin_trait!(BreakInputComparator2Pin, CaptureCompare16bitInstance); | ||
| 163 | pin_trait!(BreakInput2Pin, CaptureCompare16bitInstance); | ||
| 164 | pin_trait!(BreakInput2Comparator1Pin, CaptureCompare16bitInstance); | ||
| 165 | pin_trait!(BreakInput2Comparator2Pin, CaptureCompare16bitInstance); | ||
| 55 | 166 | ||
| 56 | #[allow(unused)] | 167 | #[allow(unused)] |
| 57 | macro_rules! impl_basic_16bit_timer { | 168 | macro_rules! impl_basic_16bit_timer { |
| @@ -140,33 +251,94 @@ macro_rules! impl_32bit_timer { | |||
| 140 | }; | 251 | }; |
| 141 | } | 252 | } |
| 142 | 253 | ||
| 254 | #[allow(unused)] | ||
| 255 | macro_rules! impl_compare_capable_16bit { | ||
| 256 | ($inst:ident) => { | ||
| 257 | impl sealed::CaptureCompare16bitInstance for crate::peripherals::$inst { | ||
| 258 | fn enable_outputs(&mut self, _enable: bool) {} | ||
| 259 | |||
| 260 | fn set_output_compare_mode(&mut self, channel: Channel, mode: OutputCompareMode) { | ||
| 261 | use sealed::GeneralPurpose16bitInstance; | ||
| 262 | let r = Self::regs_gp16(); | ||
| 263 | let raw_channel: usize = channel.raw(); | ||
| 264 | r.ccmr_output(raw_channel / 2) | ||
| 265 | .modify(|w| w.set_ocm(raw_channel % 2, mode.into())); | ||
| 266 | } | ||
| 267 | |||
| 268 | fn enable_channel(&mut self, channel: Channel, enable: bool) { | ||
| 269 | use sealed::GeneralPurpose16bitInstance; | ||
| 270 | Self::regs_gp16() | ||
| 271 | .ccer() | ||
| 272 | .modify(|w| w.set_cce(channel.raw(), enable)); | ||
| 273 | } | ||
| 274 | |||
| 275 | fn set_compare_value(&mut self, channel: Channel, value: u16) { | ||
| 276 | use sealed::GeneralPurpose16bitInstance; | ||
| 277 | Self::regs_gp16().ccr(channel.raw()).modify(|w| w.set_ccr(value)); | ||
| 278 | } | ||
| 279 | |||
| 280 | fn get_max_compare_value(&self) -> u16 { | ||
| 281 | use sealed::GeneralPurpose16bitInstance; | ||
| 282 | Self::regs_gp16().arr().read().arr() | ||
| 283 | } | ||
| 284 | } | ||
| 285 | }; | ||
| 286 | } | ||
| 287 | |||
| 143 | foreach_interrupt! { | 288 | foreach_interrupt! { |
| 144 | ($inst:ident, timer, TIM_BASIC, UP, $irq:ident) => { | 289 | ($inst:ident, timer, TIM_BASIC, UP, $irq:ident) => { |
| 145 | impl_basic_16bit_timer!($inst, $irq); | 290 | impl_basic_16bit_timer!($inst, $irq); |
| 146 | 291 | impl Basic16bitInstance for crate::peripherals::$inst {} | |
| 147 | impl Basic16bitInstance for crate::peripherals::$inst { | ||
| 148 | } | ||
| 149 | }; | 292 | }; |
| 150 | ($inst:ident, timer, TIM_GP16, UP, $irq:ident) => { | 293 | ($inst:ident, timer, TIM_GP16, UP, $irq:ident) => { |
| 151 | impl_basic_16bit_timer!($inst, $irq); | 294 | impl_basic_16bit_timer!($inst, $irq); |
| 152 | 295 | impl_compare_capable_16bit!($inst); | |
| 153 | impl Basic16bitInstance for crate::peripherals::$inst { | 296 | impl Basic16bitInstance for crate::peripherals::$inst {} |
| 154 | } | 297 | impl GeneralPurpose16bitInstance for crate::peripherals::$inst {} |
| 298 | impl CaptureCompare16bitInstance for crate::peripherals::$inst {} | ||
| 155 | 299 | ||
| 156 | impl sealed::GeneralPurpose16bitInstance for crate::peripherals::$inst { | 300 | impl sealed::GeneralPurpose16bitInstance for crate::peripherals::$inst { |
| 157 | fn regs_gp16() -> crate::pac::timer::TimGp16 { | 301 | fn regs_gp16() -> crate::pac::timer::TimGp16 { |
| 158 | crate::pac::$inst | 302 | crate::pac::$inst |
| 159 | } | 303 | } |
| 160 | } | 304 | } |
| 161 | |||
| 162 | impl GeneralPurpose16bitInstance for crate::peripherals::$inst { | ||
| 163 | } | ||
| 164 | }; | 305 | }; |
| 165 | 306 | ||
| 166 | ($inst:ident, timer, TIM_GP32, UP, $irq:ident) => { | 307 | ($inst:ident, timer, TIM_GP32, UP, $irq:ident) => { |
| 167 | impl_basic_16bit_timer!($inst, $irq); | 308 | impl_basic_16bit_timer!($inst, $irq); |
| 309 | impl_32bit_timer!($inst); | ||
| 310 | impl_compare_capable_16bit!($inst); | ||
| 311 | impl Basic16bitInstance for crate::peripherals::$inst {} | ||
| 312 | impl CaptureCompare16bitInstance for crate::peripherals::$inst {} | ||
| 313 | impl CaptureCompare32bitInstance for crate::peripherals::$inst {} | ||
| 314 | impl GeneralPurpose16bitInstance for crate::peripherals::$inst {} | ||
| 315 | impl GeneralPurpose32bitInstance for crate::peripherals::$inst {} | ||
| 316 | |||
| 317 | impl sealed::CaptureCompare32bitInstance for crate::peripherals::$inst { | ||
| 318 | fn set_output_compare_mode( | ||
| 319 | &mut self, | ||
| 320 | channel: Channel, | ||
| 321 | mode: OutputCompareMode, | ||
| 322 | ) { | ||
| 323 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 324 | let raw_channel = channel.raw(); | ||
| 325 | Self::regs_gp32().ccmr_output(raw_channel / 2).modify(|w| w.set_ocm(raw_channel % 2, mode.into())); | ||
| 326 | } | ||
| 327 | |||
| 328 | fn enable_channel(&mut self, channel: Channel, enable: bool) { | ||
| 329 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 330 | Self::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), enable)); | ||
| 331 | } | ||
| 168 | 332 | ||
| 169 | impl Basic16bitInstance for crate::peripherals::$inst { | 333 | fn set_compare_value(&mut self, channel: Channel, value: u32) { |
| 334 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 335 | Self::regs_gp32().ccr(channel.raw()).modify(|w| w.set_ccr(value)); | ||
| 336 | } | ||
| 337 | |||
| 338 | fn get_max_compare_value(&self) -> u32 { | ||
| 339 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 340 | Self::regs_gp32().arr().read().arr() as u32 | ||
| 341 | } | ||
| 170 | } | 342 | } |
| 171 | 343 | ||
| 172 | impl sealed::GeneralPurpose16bitInstance for crate::peripherals::$inst { | 344 | impl sealed::GeneralPurpose16bitInstance for crate::peripherals::$inst { |
| @@ -174,21 +346,16 @@ foreach_interrupt! { | |||
| 174 | unsafe { crate::pac::timer::TimGp16::from_ptr(crate::pac::$inst.as_ptr()) } | 346 | unsafe { crate::pac::timer::TimGp16::from_ptr(crate::pac::$inst.as_ptr()) } |
| 175 | } | 347 | } |
| 176 | } | 348 | } |
| 177 | |||
| 178 | impl GeneralPurpose16bitInstance for crate::peripherals::$inst { | ||
| 179 | } | ||
| 180 | |||
| 181 | impl_32bit_timer!($inst); | ||
| 182 | |||
| 183 | impl GeneralPurpose32bitInstance for crate::peripherals::$inst { | ||
| 184 | } | ||
| 185 | }; | 349 | }; |
| 186 | 350 | ||
| 187 | ($inst:ident, timer, TIM_ADV, UP, $irq:ident) => { | 351 | ($inst:ident, timer, TIM_ADV, UP, $irq:ident) => { |
| 188 | impl_basic_16bit_timer!($inst, $irq); | 352 | impl_basic_16bit_timer!($inst, $irq); |
| 189 | 353 | ||
| 190 | impl Basic16bitInstance for crate::peripherals::$inst { | 354 | impl Basic16bitInstance for crate::peripherals::$inst {} |
| 191 | } | 355 | impl GeneralPurpose16bitInstance for crate::peripherals::$inst {} |
| 356 | impl CaptureCompare16bitInstance for crate::peripherals::$inst {} | ||
| 357 | impl ComplementaryCaptureCompare16bitInstance for crate::peripherals::$inst {} | ||
| 358 | impl AdvancedControlInstance for crate::peripherals::$inst {} | ||
| 192 | 359 | ||
| 193 | impl sealed::GeneralPurpose16bitInstance for crate::peripherals::$inst { | 360 | impl sealed::GeneralPurpose16bitInstance for crate::peripherals::$inst { |
| 194 | fn regs_gp16() -> crate::pac::timer::TimGp16 { | 361 | fn regs_gp16() -> crate::pac::timer::TimGp16 { |
| @@ -196,16 +363,70 @@ foreach_interrupt! { | |||
| 196 | } | 363 | } |
| 197 | } | 364 | } |
| 198 | 365 | ||
| 199 | impl GeneralPurpose16bitInstance for crate::peripherals::$inst { | ||
| 200 | } | ||
| 201 | |||
| 202 | impl sealed::AdvancedControlInstance for crate::peripherals::$inst { | 366 | impl sealed::AdvancedControlInstance for crate::peripherals::$inst { |
| 203 | fn regs_advanced() -> crate::pac::timer::TimAdv { | 367 | fn regs_advanced() -> crate::pac::timer::TimAdv { |
| 204 | crate::pac::$inst | 368 | crate::pac::$inst |
| 205 | } | 369 | } |
| 206 | } | 370 | } |
| 207 | 371 | ||
| 208 | impl AdvancedControlInstance for crate::peripherals::$inst { | 372 | impl sealed::CaptureCompare16bitInstance for crate::peripherals::$inst { |
| 373 | fn enable_outputs(&mut self, enable: bool) { | ||
| 374 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 375 | let r = Self::regs_advanced(); | ||
| 376 | r.bdtr().modify(|w| w.set_moe(enable)); | ||
| 377 | } | ||
| 378 | |||
| 379 | fn set_output_compare_mode( | ||
| 380 | &mut self, | ||
| 381 | channel: Channel, | ||
| 382 | mode: OutputCompareMode, | ||
| 383 | ) { | ||
| 384 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 385 | let r = Self::regs_advanced(); | ||
| 386 | let raw_channel: usize = channel.raw(); | ||
| 387 | r.ccmr_output(raw_channel / 2) | ||
| 388 | .modify(|w| w.set_ocm(raw_channel % 2, mode.into())); | ||
| 389 | } | ||
| 390 | |||
| 391 | fn enable_channel(&mut self, channel: Channel, enable: bool) { | ||
| 392 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 393 | Self::regs_advanced() | ||
| 394 | .ccer() | ||
| 395 | .modify(|w| w.set_cce(channel.raw(), enable)); | ||
| 396 | } | ||
| 397 | |||
| 398 | fn set_compare_value(&mut self, channel: Channel, value: u16) { | ||
| 399 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 400 | Self::regs_advanced() | ||
| 401 | .ccr(channel.raw()) | ||
| 402 | .modify(|w| w.set_ccr(value)); | ||
| 403 | } | ||
| 404 | |||
| 405 | fn get_max_compare_value(&self) -> u16 { | ||
| 406 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 407 | Self::regs_advanced().arr().read().arr() | ||
| 408 | } | ||
| 409 | } | ||
| 410 | |||
| 411 | impl sealed::ComplementaryCaptureCompare16bitInstance for crate::peripherals::$inst { | ||
| 412 | fn set_dead_time_clock_division(&mut self, value: vals::Ckd) { | ||
| 413 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 414 | Self::regs_advanced().cr1().modify(|w| w.set_ckd(value)); | ||
| 415 | } | ||
| 416 | |||
| 417 | fn set_dead_time_value(&mut self, value: u8) { | ||
| 418 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 419 | Self::regs_advanced().bdtr().modify(|w| w.set_dtg(value)); | ||
| 420 | } | ||
| 421 | |||
| 422 | fn enable_complementary_channel(&mut self, channel: Channel, enable: bool) { | ||
| 423 | use crate::timer::sealed::AdvancedControlInstance; | ||
| 424 | Self::regs_advanced() | ||
| 425 | .ccer() | ||
| 426 | .modify(|w| w.set_ccne(channel.raw(), enable)); | ||
| 427 | } | ||
| 209 | } | 428 | } |
| 429 | |||
| 430 | |||
| 210 | }; | 431 | }; |
| 211 | } | 432 | } |
diff --git a/embassy-stm32/src/pwm/simple_pwm.rs b/embassy-stm32/src/timer/simple_pwm.rs index 514796930..514796930 100644 --- a/embassy-stm32/src/pwm/simple_pwm.rs +++ b/embassy-stm32/src/timer/simple_pwm.rs | |||
diff --git a/examples/stm32f4/src/bin/pwm.rs b/examples/stm32f4/src/bin/pwm.rs index 7c5902052..4f130c26b 100644 --- a/examples/stm32f4/src/bin/pwm.rs +++ b/examples/stm32f4/src/bin/pwm.rs | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; | ||
| 8 | use embassy_stm32::pwm::Channel; | ||
| 9 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | ||
| 9 | use embassy_stm32::timer::Channel; | ||
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::{Duration, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32f4/src/bin/pwm_complementary.rs b/examples/stm32f4/src/bin/pwm_complementary.rs index a8a68ed6e..8cc2a4117 100644 --- a/examples/stm32f4/src/bin/pwm_complementary.rs +++ b/examples/stm32f4/src/bin/pwm_complementary.rs | |||
| @@ -4,10 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::pwm::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; | ||
| 8 | use embassy_stm32::pwm::simple_pwm::PwmPin; | ||
| 9 | use embassy_stm32::pwm::Channel; | ||
| 10 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::complementary_pwm::{ComplementaryPwm, ComplementaryPwmPin}; | ||
| 9 | use embassy_stm32::timer::simple_pwm::PwmPin; | ||
| 10 | use embassy_stm32::timer::Channel; | ||
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::{Duration, Timer}; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
| 13 | 13 | ||
diff --git a/examples/stm32g4/src/bin/pwm.rs b/examples/stm32g4/src/bin/pwm.rs index 8f7842ed7..b5a9b9952 100644 --- a/examples/stm32g4/src/bin/pwm.rs +++ b/examples/stm32g4/src/bin/pwm.rs | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; | ||
| 8 | use embassy_stm32::pwm::Channel; | ||
| 9 | use embassy_stm32::time::khz; | 7 | use embassy_stm32::time::khz; |
| 8 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | ||
| 9 | use embassy_stm32::timer::Channel; | ||
| 10 | use embassy_time::{Duration, Timer}; | 10 | use embassy_time::{Duration, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 12 | 12 | ||
diff --git a/examples/stm32h7/src/bin/low_level_timer_api.rs b/examples/stm32h7/src/bin/low_level_timer_api.rs index d360df085..45b0872b5 100644 --- a/examples/stm32h7/src/bin/low_level_timer_api.rs +++ b/examples/stm32h7/src/bin/low_level_timer_api.rs | |||
| @@ -6,8 +6,8 @@ use defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::gpio::low_level::AFType; | 7 | use embassy_stm32::gpio::low_level::AFType; |
| 8 | use embassy_stm32::gpio::Speed; | 8 | use embassy_stm32::gpio::Speed; |
| 9 | use embassy_stm32::pwm::*; | ||
| 10 | use embassy_stm32::time::{khz, mhz, Hertz}; | 9 | use embassy_stm32::time::{khz, mhz, Hertz}; |
| 10 | use embassy_stm32::timer::*; | ||
| 11 | use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef}; | 11 | use embassy_stm32::{into_ref, Config, Peripheral, PeripheralRef}; |
| 12 | use embassy_time::{Duration, Timer}; | 12 | use embassy_time::{Duration, Timer}; |
| 13 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/stm32h7/src/bin/pwm.rs b/examples/stm32h7/src/bin/pwm.rs index c5c0dd290..adf2ea9ce 100644 --- a/examples/stm32h7/src/bin/pwm.rs +++ b/examples/stm32h7/src/bin/pwm.rs | |||
| @@ -4,9 +4,9 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::pwm::simple_pwm::{PwmPin, SimplePwm}; | ||
| 8 | use embassy_stm32::pwm::Channel; | ||
| 9 | use embassy_stm32::time::{khz, mhz}; | 7 | use embassy_stm32::time::{khz, mhz}; |
| 8 | use embassy_stm32::timer::simple_pwm::{PwmPin, SimplePwm}; | ||
| 9 | use embassy_stm32::timer::Channel; | ||
| 10 | use embassy_stm32::Config; | 10 | use embassy_stm32::Config; |
| 11 | use embassy_time::{Duration, Timer}; | 11 | use embassy_time::{Duration, Timer}; |
| 12 | use {defmt_rtt as _, panic_probe as _}; | 12 | use {defmt_rtt as _, panic_probe as _}; |
