Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,14 @@ impl<'a> From<&'a mut HrPwmControl> for &'a mut HrPwmCtrl {
#[non_exhaustive]
pub struct HrPwmCtrl;

pub struct Foo<'a>(&'a mut pac::hrtim_master::cr::W);
pub struct W<'a>(&'a mut pac::hrtim_master::cr::W);

impl<'a> Foo<'a> {
impl<'a> W<'a> {
pub fn start<T: HrTimer>(self, _t: &mut T) -> Self {
use crate::timer::Instance;

let w = self.0;
Foo(match T::Timer::TIMX {
W(match T::Timer::TIMX {
timer::Timer::Master => w.mcen().set_bit(),
timer::Timer::Tim(v) => w.tcen(v as _).set_bit(),
})
Expand All @@ -285,7 +285,7 @@ impl<'a> Foo<'a> {
use crate::timer::Instance;

let w = self.0;
Foo(match T::Timer::TIMX {
W(match T::Timer::TIMX {
timer::Timer::Master => w.mcen().clear_bit(),
timer::Timer::Tim(v) => w.tcen(v as _).clear_bit(),
})
Expand All @@ -305,9 +305,9 @@ impl HrPwmCtrl {
/// .stop(&mut timer_c)
/// );
/// ```
pub fn start_stop_timers(&mut self, p: impl FnOnce(Foo) -> Foo) {
pub fn start_stop_timers(&mut self, p: impl FnOnce(W) -> W) {
let master = unsafe { pac::HRTIM_MASTER::steal() };
master.cr().modify(|_, w| p(Foo(w)).0);
master.cr().modify(|_, w| p(W(w)).0);
}
}

Expand Down Expand Up @@ -349,6 +349,8 @@ pub struct HrPwmControl {
}

#[cfg(feature = "stm32g4")]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum AdcTriggerPostscaler {
None = 0,
Div2 = 1,
Expand Down
Loading