diff options
| author | Daniel Berlin <[email protected]> | 2023-09-30 11:19:09 -0400 |
|---|---|---|
| committer | Daniel Berlin <[email protected]> | 2023-09-30 11:19:09 -0400 |
| commit | 55a0a15be21804814e97a065ba413f5474f5f3d2 (patch) | |
| tree | 39acffc6eba6e794ac2f5904a8e15f1e43b2e928 /embassy-stm32 | |
| parent | fc8f96fea5b0689b2ae9a152f2da2b91dfaea750 (diff) | |
Fix trait inconsistency between sealed traits and implementations
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/src/timer/mod.rs | 96 |
1 files changed, 1 insertions, 95 deletions
diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs index 1d642ed37..5beca1e40 100644 --- a/embassy-stm32/src/timer/mod.rs +++ b/embassy-stm32/src/timer/mod.rs | |||
| @@ -94,25 +94,7 @@ pub(crate) mod sealed { | |||
| 94 | fn enable_complementary_channel(&mut self, channel: Channel, enable: bool); | 94 | fn enable_complementary_channel(&mut self, channel: Channel, enable: bool); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | pub trait CaptureCompare32bitInstance: GeneralPurpose32bitInstance { | 97 | pub trait CaptureCompare32bitInstance: GeneralPurpose32bitInstance + CaptureCompare16bitInstance { |
| 98 | fn set_input_capture_filter(&mut self, channel: Channel, icf: vals::Icf); | ||
| 99 | |||
| 100 | fn clear_input_interrupt(&mut self, channel: Channel); | ||
| 101 | |||
| 102 | fn enable_input_interrupt(&mut self, channel: Channel, enable: bool); | ||
| 103 | |||
| 104 | fn set_input_capture_prescaler(&mut self, channel: Channel, val: u8); | ||
| 105 | |||
| 106 | fn set_input_ti_selection(&mut self, channel: Channel, tisel: InputTISelection); | ||
| 107 | |||
| 108 | fn set_input_capture_mode(&mut self, channel: Channel, mode: InputCaptureMode); | ||
| 109 | |||
| 110 | fn set_output_compare_mode(&mut self, channel: Channel, mode: OutputCompareMode); | ||
| 111 | |||
| 112 | fn set_output_polarity(&mut self, channel: Channel, polarity: OutputPolarity); | ||
| 113 | |||
| 114 | fn enable_channel(&mut self, channel: Channel, enable: bool); | ||
| 115 | |||
| 116 | fn set_compare_value(&mut self, channel: Channel, value: u32); | 98 | fn set_compare_value(&mut self, channel: Channel, value: u32); |
| 117 | 99 | ||
| 118 | fn get_capture_value(&mut self, channel: Channel) -> u32; | 100 | fn get_capture_value(&mut self, channel: Channel) -> u32; |
| @@ -228,7 +210,6 @@ pub trait CaptureCompare32bitInstance: | |||
| 228 | sealed::CaptureCompare32bitInstance + CaptureCompare16bitInstance + GeneralPurpose32bitInstance + 'static | 210 | sealed::CaptureCompare32bitInstance + CaptureCompare16bitInstance + GeneralPurpose32bitInstance + 'static |
| 229 | { | 211 | { |
| 230 | } | 212 | } |
| 231 | |||
| 232 | pin_trait!(Channel1Pin, CaptureCompare16bitInstance); | 213 | pin_trait!(Channel1Pin, CaptureCompare16bitInstance); |
| 233 | pin_trait!(Channel1ComplementaryPin, CaptureCompare16bitInstance); | 214 | pin_trait!(Channel1ComplementaryPin, CaptureCompare16bitInstance); |
| 234 | pin_trait!(Channel2Pin, CaptureCompare16bitInstance); | 215 | pin_trait!(Channel2Pin, CaptureCompare16bitInstance); |
| @@ -475,81 +456,6 @@ foreach_interrupt! { | |||
| 475 | impl GeneralPurpose32bitInstance for crate::peripherals::$inst {} | 456 | impl GeneralPurpose32bitInstance for crate::peripherals::$inst {} |
| 476 | 457 | ||
| 477 | impl sealed::CaptureCompare32bitInstance for crate::peripherals::$inst { | 458 | impl sealed::CaptureCompare32bitInstance for crate::peripherals::$inst { |
| 478 | fn set_input_capture_filter(&mut self, channel: Channel, icf: vals::Icf) { | ||
| 479 | use sealed::GeneralPurpose32bitInstance; | ||
| 480 | let raw_channel = channel.raw(); | ||
| 481 | Self::regs_gp32() | ||
| 482 | .ccmr_input(raw_channel / 2) | ||
| 483 | .modify(|r| r.set_icf(raw_channel % 2, icf)); | ||
| 484 | } | ||
| 485 | |||
| 486 | fn clear_input_interrupt(&mut self, channel: Channel) { | ||
| 487 | use sealed::GeneralPurpose32bitInstance; | ||
| 488 | Self::regs_gp32() | ||
| 489 | .sr() | ||
| 490 | .modify(|r| r.set_ccif(channel.raw(), false)); | ||
| 491 | } | ||
| 492 | fn enable_input_interrupt(&mut self, channel: Channel, enable: bool) { | ||
| 493 | use sealed::GeneralPurpose32bitInstance; | ||
| 494 | Self::regs_gp32() | ||
| 495 | .dier() | ||
| 496 | .modify(|r| r.set_ccie(channel.raw(), enable)); | ||
| 497 | } | ||
| 498 | fn set_input_capture_prescaler(&mut self, channel: Channel, factor: u8) { | ||
| 499 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 500 | let raw_channel = channel.raw(); | ||
| 501 | Self::regs_gp32() | ||
| 502 | .ccmr_input(raw_channel / 2) | ||
| 503 | .modify(|r| r.set_icpsc(raw_channel % 2, factor)); | ||
| 504 | } | ||
| 505 | |||
| 506 | fn set_input_ti_selection(&mut self, channel: Channel, tisel: InputTISelection) { | ||
| 507 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 508 | let raw_channel = channel.raw(); | ||
| 509 | Self::regs_gp32() | ||
| 510 | .ccmr_input(raw_channel / 2) | ||
| 511 | .modify(|r| r.set_ccs(raw_channel % 2, tisel.into())); | ||
| 512 | } | ||
| 513 | |||
| 514 | fn set_input_capture_mode(&mut self, channel: Channel, mode: InputCaptureMode) { | ||
| 515 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 516 | Self::regs_gp32().ccer().modify(|r| match mode { | ||
| 517 | InputCaptureMode::Rising => { | ||
| 518 | r.set_ccnp(channel.raw(), false); | ||
| 519 | r.set_ccp(channel.raw(), false); | ||
| 520 | } | ||
| 521 | InputCaptureMode::Falling => { | ||
| 522 | r.set_ccnp(channel.raw(), false); | ||
| 523 | r.set_ccp(channel.raw(), true); | ||
| 524 | } | ||
| 525 | InputCaptureMode::BothEdges => { | ||
| 526 | r.set_ccnp(channel.raw(), true); | ||
| 527 | r.set_ccp(channel.raw(), true); | ||
| 528 | } | ||
| 529 | }); | ||
| 530 | } | ||
| 531 | fn set_output_compare_mode( | ||
| 532 | &mut self, | ||
| 533 | channel: Channel, | ||
| 534 | mode: OutputCompareMode, | ||
| 535 | ) { | ||
| 536 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 537 | let raw_channel = channel.raw(); | ||
| 538 | Self::regs_gp32().ccmr_output(raw_channel / 2).modify(|w| w.set_ocm(raw_channel % 2, mode.into())); | ||
| 539 | } | ||
| 540 | |||
| 541 | fn set_output_polarity(&mut self, channel: Channel, polarity: OutputPolarity) { | ||
| 542 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 543 | Self::regs_gp32() | ||
| 544 | .ccer() | ||
| 545 | .modify(|w| w.set_ccp(channel.raw(), polarity.into())); | ||
| 546 | } | ||
| 547 | |||
| 548 | fn enable_channel(&mut self, channel: Channel, enable: bool) { | ||
| 549 | use crate::timer::sealed::GeneralPurpose32bitInstance; | ||
| 550 | Self::regs_gp32().ccer().modify(|w| w.set_cce(channel.raw(), enable)); | ||
| 551 | } | ||
| 552 | |||
| 553 | fn set_compare_value(&mut self, channel: Channel, value: u32) { | 459 | fn set_compare_value(&mut self, channel: Channel, value: u32) { |
| 554 | use crate::timer::sealed::GeneralPurpose32bitInstance; | 460 | use crate::timer::sealed::GeneralPurpose32bitInstance; |
| 555 | Self::regs_gp32().ccr(channel.raw()).modify(|w| w.set_ccr(value)); | 461 | Self::regs_gp32().ccr(channel.raw()).modify(|w| w.set_ccr(value)); |
