Skip to content

Commit 1dbbf40

Browse files
committed
fix polarity
1 parent 5c059c2 commit 1dbbf40

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/timer/pwm.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,11 @@ impl<TIM: Instance + WithPwm, const C: u8, const COMP: bool> PwmChannel<TIM, C,
246246
pub fn set_duty(&mut self, duty: u16) {
247247
TIM::set_cc_value(C, duty as u32)
248248
}
249+
250+
#[inline]
251+
pub fn set_complementary_polarity(&mut self, p: Polarity) {
252+
TIM::set_nchannel_polarity(C, p);
253+
}
249254
}
250255

251256
impl<TIM: Instance + WithPwm + Advanced, const C: u8> PwmChannel<TIM, C, true> {
@@ -258,11 +263,6 @@ impl<TIM: Instance + WithPwm + Advanced, const C: u8> PwmChannel<TIM, C, true> {
258263
pub fn enable_complementary(&mut self) {
259264
TIM::enable_nchannel(C, true);
260265
}
261-
262-
#[inline]
263-
pub fn set_complementary_polarity(&mut self, p: Polarity) {
264-
TIM::set_nchannel_polarity(C, p);
265-
}
266266
}
267267

268268
pub struct PwmHz<TIM, P, PINS>
@@ -401,6 +401,10 @@ where
401401
self.tim.set_auto_reload(arr).unwrap();
402402
self.tim.cnt_reset();
403403
}
404+
405+
pub fn set_complementary_polarity(&mut self, channel: Channel, p: Polarity) {
406+
TIM::set_channel_polarity(PINS::check_complementary_used(channel) as u8, p);
407+
}
404408
}
405409

406410
impl<TIM, P, PINS> PwmHz<TIM, P, PINS>
@@ -415,10 +419,6 @@ where
415419
pub fn disable_complementary(&mut self, channel: Channel) {
416420
TIM::enable_nchannel(PINS::check_complementary_used(channel) as u8, false)
417421
}
418-
419-
pub fn set_complementary_polarity(&mut self, channel: Channel, p: Polarity) {
420-
TIM::set_channel_polarity(PINS::check_complementary_used(channel) as u8, p);
421-
}
422422
}
423423

424424
pub struct Pwm<TIM, P, PINS, const FREQ: u32>
@@ -558,6 +558,10 @@ where
558558
self.tim.set_auto_reload(period.ticks() - 1).unwrap();
559559
self.tim.cnt_reset();
560560
}
561+
562+
pub fn set_complementary_polarity(&mut self, channel: Channel, p: Polarity) {
563+
TIM::set_channel_polarity(PINS::check_complementary_used(channel) as u8, p);
564+
}
561565
}
562566

563567
impl<TIM, P, PINS, const FREQ: u32> Pwm<TIM, P, PINS, FREQ>
@@ -572,8 +576,4 @@ where
572576
pub fn disable_complementary(&mut self, channel: Channel) {
573577
TIM::enable_nchannel(PINS::check_complementary_used(channel) as u8, false)
574578
}
575-
576-
pub fn set_complementary_polarity(&mut self, channel: Channel, p: Polarity) {
577-
TIM::set_channel_polarity(PINS::check_complementary_used(channel) as u8, p);
578-
}
579579
}

0 commit comments

Comments
 (0)