Skip to content

Commit 052a182

Browse files
committed
Move some methods on low_level timer to be available on simpler timers
1 parent 7a7527a commit 052a182

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

embassy-stm32/src/timer/low_level.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,18 @@ impl<'d, T: GeneralInstance1Channel> Timer<'d, T> {
505505
}
506506
}
507507
}
508+
509+
pub fn set_prescaler(&mut self, psc: u16) {
510+
self.regs_1ch().psc().write_value(psc);
511+
}
512+
513+
/// Set output compare mode.
514+
pub fn set_output_compare_mode(&self, channel: Channel, mode: OutputCompareMode) {
515+
let raw_channel: usize = channel.index();
516+
self.regs_1ch()
517+
.ccmr_output(raw_channel / 2)
518+
.modify(|w| w.set_ocm(raw_channel % 2, mode.into()));
519+
}
508520
}
509521

510522
impl<'d, T: GeneralInstance2Channel> Timer<'d, T> {
@@ -611,14 +623,6 @@ impl<'d, T: GeneralInstance4Channel> Timer<'d, T> {
611623
});
612624
}
613625

614-
/// Set output compare mode.
615-
pub fn set_output_compare_mode(&self, channel: Channel, mode: OutputCompareMode) {
616-
let raw_channel: usize = channel.index();
617-
self.regs_gp16()
618-
.ccmr_output(raw_channel / 2)
619-
.modify(|w| w.set_ocm(raw_channel % 2, mode.into()));
620-
}
621-
622626
/// Set output polarity.
623627
pub fn set_output_polarity(&self, channel: Channel, polarity: OutputPolarity) {
624628
self.regs_gp16()

0 commit comments

Comments
 (0)