stm32/timer: docs.

This commit is contained in:
Dario Nieuwenhuis
2023-12-19 17:35:38 +01:00
parent b1c7c3f728
commit 322606b5b9
8 changed files with 247 additions and 61 deletions

View File

@ -110,7 +110,7 @@ async fn main(_spawner: Spawner) {
&mut dp.DMA1_CH2,
5,
color_list[color_list_index],
pac::TIM3.ccr(pwm_channel.raw()).as_ptr() as *mut _,
pac::TIM3.ccr(pwm_channel.index()).as_ptr() as *mut _,
dma_transfer_option,
)
.await;

View File

@ -85,7 +85,7 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> {
let mut this = Self { inner: tim };
this.set_freq(freq);
this.set_frequency(freq);
this.inner.start();
let r = T::regs_gp32();
@ -102,14 +102,14 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> {
}
pub fn enable(&mut self, channel: Channel) {
T::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), true));
T::regs_gp32().ccer().modify(|w| w.set_cce(channel.index(), true));
}
pub fn disable(&mut self, channel: Channel) {
T::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), false));
T::regs_gp32().ccer().modify(|w| w.set_cce(channel.index(), false));
}
pub fn set_freq(&mut self, freq: Hertz) {
pub fn set_frequency(&mut self, freq: Hertz) {
<T as embassy_stm32::timer::low_level::GeneralPurpose32bitInstance>::set_frequency(&mut self.inner, freq);
}
@ -119,6 +119,6 @@ impl<'d, T: CaptureCompare32bitInstance> SimplePwm32<'d, T> {
pub fn set_duty(&mut self, channel: Channel, duty: u32) {
defmt::assert!(duty < self.get_max_duty());
T::regs_gp32().ccr(channel.raw()).modify(|w| w.set_ccr(duty))
T::regs_gp32().ccr(channel.index()).modify(|w| w.set_ccr(duty))
}
}