Skip to content

Commit

Permalink
HRTIM: Avoid unneeded type parameters on HrTimer trait
Browse files Browse the repository at this point in the history
  • Loading branch information
usbalbin committed Feb 16, 2024
1 parent 47d7a43 commit 6887958
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/hrtim/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ pub struct HrTim<TIM, PSCL> {
capture_ch2: HrCapt<TIM, PSCL, capture::Ch2>,
}

pub trait HrTimer<TIM, PSCL>: Sized {
pub trait HrTimer {
type Timer;
type Prescaler;

/// Get period of timer in number of ticks
///
/// This is also the maximum duty usable for `HrCompareRegister::set_duty`
Expand All @@ -38,10 +41,10 @@ pub trait HrTimer<TIM, PSCL>: Sized {
fn clear_repetition_interrupt(&mut self);

/// Make a handle to this timers reset event to use as adc trigger
fn as_reset_adc_trigger(&self) -> super::adc_trigger::TimerReset<Self>;
fn as_reset_adc_trigger(&self) -> super::adc_trigger::TimerReset<Self::Timer>;

/// Make a handle to this timers period event to use as adc trigger
fn as_period_adc_trigger(&self) -> super::adc_trigger::TimerPeriod<Self>;
fn as_period_adc_trigger(&self) -> super::adc_trigger::TimerPeriod<Self::Timer>;
}

macro_rules! hrtim_timer {
Expand All @@ -60,7 +63,10 @@ macro_rules! hrtim_timer {
$repc:ident,
$(($rstXr:ident))*,
)+) => {$(
impl<PSCL> HrTimer<$TIMX, PSCL> for HrTim<$TIMX, PSCL> {
impl<PSCL> HrTimer for HrTim<$TIMX, PSCL> {
type Prescaler = PSCL;
type Timer = $TIMX;

fn get_period(&self) -> u16 {
let tim = unsafe { &*$TIMX::ptr() };

Expand Down Expand Up @@ -99,12 +105,12 @@ macro_rules! hrtim_timer {
}

/// Make a handle to this timers reset event to use as adc trigger
fn as_reset_adc_trigger(&self) -> super::adc_trigger::TimerReset<Self> {
fn as_reset_adc_trigger(&self) -> super::adc_trigger::TimerReset<Self::Timer> {
super::adc_trigger::TimerReset(PhantomData)
}

/// Make a handle to this timers period event to use as adc trigger
fn as_period_adc_trigger(&self) -> super::adc_trigger::TimerPeriod<Self> {
fn as_period_adc_trigger(&self) -> super::adc_trigger::TimerPeriod<Self::Timer> {
super::adc_trigger::TimerPeriod(PhantomData)
}

Expand Down

0 comments on commit 6887958

Please sign in to comment.