Skip to content

Commit a79d4b4

Browse files
committed
HRTIM - Fix some clippy warnings and fmt
1 parent 87bb961 commit a79d4b4

File tree

5 files changed

+28
-39
lines changed

5 files changed

+28
-39
lines changed

src/hrtim/capture.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ pub struct Ch2;
1111
pub struct Dma;
1212
pub struct NoDma;
1313

14+
/// Type alias for the default capture for channel 1
15+
pub type HrCaptCh1<TIM, PSCL> = HrCapt<TIM, PSCL, Ch1, NoDma>;
16+
17+
/// Type alias for the default capture for channel 2
18+
pub type HrCaptCh2<TIM, PSCL> = HrCapt<TIM, PSCL, Ch2, NoDma>;
19+
1420
pub struct HrCapt<TIM, PSCL, CH, DMA> {
1521
_x: PhantomData<(TIM, PSCL, CH, DMA)>,
1622
}

src/hrtim/control.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,9 @@ impl HrTimOngoingCalibration {
137137
// Calibration is now done, it is safe to continue
138138
unsafe { self.init() };
139139

140-
(
141-
HrTimCalibrated,
142-
unsafe { FaultInputs::new() },
143-
unsafe { EevInputs::new() },
144-
)
140+
(HrTimCalibrated, unsafe { FaultInputs::new() }, unsafe {
141+
EevInputs::new()
142+
})
145143
}
146144

147145
pub fn set_adc1_trigger_psc(mut self, post_scaler: AdcTriggerPostscaler) -> Self {

src/hrtim/fault.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,4 @@ impl_flt_monitor!(
267267
FltMonitor4: (flt4, flt4c, flt4ie),
268268
FltMonitor5: (flt5, flt5c, flt5ie),
269269
FltMonitor6: (flt6, flt6c, flt6ie),
270-
);
270+
);

src/hrtim/mod.rs

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ pub mod timer_eev_cfg;
1313
use core::marker::PhantomData;
1414
use core::mem::MaybeUninit;
1515

16-
use crate::hrtim::capture::HrCapt;
1716
use crate::hrtim::compare_register::{HrCr1, HrCr2, HrCr3, HrCr4};
1817
use crate::hrtim::fault::{FaultAction, FaultSource};
1918
use crate::hrtim::timer::HrTim;
2019
use crate::stm32::{
2120
HRTIM_COMMON, HRTIM_MASTER, HRTIM_TIMA, HRTIM_TIMB, HRTIM_TIMC, HRTIM_TIMD, HRTIM_TIME,
2221
HRTIM_TIMF,
2322
};
23+
use capture::{HrCaptCh1, HrCaptCh2};
2424
use fugit::HertzU64;
2525

2626
use self::control::HrPwmControl;
@@ -188,6 +188,18 @@ pub struct HrPwmBuilder<TIM, PSCL, PS, PINS> {
188188
out2_polarity: Polarity,
189189
}
190190

191+
pub struct HrParts<TIM, PSCL, OUT> {
192+
pub timer: HrTim<TIM, PSCL, HrCaptCh1<TIM, PSCL>, HrCaptCh2<TIM, PSCL>>,
193+
194+
pub cr1: HrCr1<TIM, PSCL>,
195+
pub cr2: HrCr2<TIM, PSCL>,
196+
pub cr3: HrCr3<TIM, PSCL>,
197+
pub cr4: HrCr4<TIM, PSCL>,
198+
199+
pub out: OUT,
200+
pub dma_channel: timer::DmaChannel<TIM>,
201+
}
202+
191203
pub enum PreloadSource {
192204
/// Preloaded registers are updated on counter roll over or counter reset
193205
OnCounterReset,
@@ -249,7 +261,7 @@ macro_rules! hrtim_finalize_body {
249261
// Set counting direction
250262
w.udm().bit($this.counting_direction == HrCountingDirection::UpDown)
251263
);
252-
264+
253265
tim.cr().modify(|_r, w|
254266
// Push-Pull mode
255267
w.pshpll().bit($this.enable_push_pull)
@@ -552,20 +564,7 @@ macro_rules! hrtim_hal {
552564
PSCL: HrtimPrescaler,
553565
PINS: ToHrOut<$TIMX>,
554566
{
555-
pub fn finalize(self, _control: &mut HrPwmControl) -> (
556-
HrTim<$TIMX, PSCL,
557-
HrCapt<$TIMX, PSCL, capture::Ch1, capture::NoDma>,
558-
HrCapt<$TIMX, PSCL, capture::Ch2, capture::NoDma>
559-
>, (
560-
HrCr1<$TIMX, PSCL>,
561-
HrCr2<$TIMX, PSCL>,
562-
HrCr3<$TIMX, PSCL>,
563-
HrCr4<$TIMX, PSCL>
564-
),
565-
PINS::Out<PSCL>,
566-
timer::DmaChannel<$TIMX>,
567-
) {
568-
567+
pub fn finalize(self, _control: &mut HrPwmControl) -> HrParts<$TIMX, PSCL, PINS::Out<PSCL>> {
569568
hrtim_finalize_body!(
570569
self, PreloadSource,
571570
$TIMX, $($out)*
@@ -660,7 +659,6 @@ macro_rules! hrtim_hal {
660659
};
661660
}
662661

663-
664662
impl HrPwmAdvExt for HRTIM_MASTER {
665663
type PreloadSource = MasterPreloadSource;
666664

@@ -701,25 +699,12 @@ impl HrPwmAdvExt for HRTIM_MASTER {
701699
}
702700
}
703701

704-
impl<PSCL, PINS>
705-
HrPwmBuilder<HRTIM_MASTER, PSCL, MasterPreloadSource, PINS>
702+
impl<PSCL, PINS> HrPwmBuilder<HRTIM_MASTER, PSCL, MasterPreloadSource, PINS>
706703
where
707704
PSCL: HrtimPrescaler,
708705
PINS: ToHrOut<HRTIM_MASTER>,
709706
{
710-
pub fn finalize(self, _control: &mut HrPwmControl) -> (
711-
HrTim<HRTIM_MASTER, PSCL,
712-
HrCapt<HRTIM_MASTER, PSCL, capture::Ch1, capture::NoDma>,
713-
HrCapt<HRTIM_MASTER, PSCL, capture::Ch2, capture::NoDma>,
714-
>, (
715-
HrCr1<HRTIM_MASTER, PSCL>,
716-
HrCr2<HRTIM_MASTER, PSCL>,
717-
HrCr3<HRTIM_MASTER, PSCL>,
718-
HrCr4<HRTIM_MASTER, PSCL>
719-
),
720-
timer::DmaChannel<HRTIM_MASTER>,
721-
) {
722-
707+
pub fn finalize(self, _control: &mut HrPwmControl) -> HrParts<HRTIM_MASTER, PSCL, ()> {
723708
hrtim_finalize_body!(self, MasterPreloadSource, HRTIM_MASTER,)
724709
}
725710

src/hrtim/timer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,4 +352,4 @@ impl<DST, PSCL, CPT1, CPT2> super::event::EventSource<DST, PSCL>
352352
for HrTim<HRTIM_MASTER, PSCL, CPT1, CPT2>
353353
{
354354
const BITS: u32 = 1 << 7; // MSTPER
355-
}
355+
}

0 commit comments

Comments
 (0)