diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-09-06 00:11:59 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2025-09-06 00:14:03 +0200 |
| commit | a23c4b7bca15bc00f4b5c4af200f17eb0097e94b (patch) | |
| tree | f293891a3dad44dc808f31f7aa6fd7fcdb21bbe5 /embassy-stm32/src/timer | |
| parent | 35f4ae378cbc9a1263e46baaeac536cae2337896 (diff) | |
stm32/afio: make af_num() unavailable in afio chips.
Diffstat (limited to 'embassy-stm32/src/timer')
| -rw-r--r-- | embassy-stm32/src/timer/complementary_pwm.rs | 8 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/input_capture.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/one_pulse.rs | 8 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/pwm_input.rs | 8 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/qei.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/simple_pwm.rs | 18 |
6 files changed, 16 insertions, 32 deletions
diff --git a/embassy-stm32/src/timer/complementary_pwm.rs b/embassy-stm32/src/timer/complementary_pwm.rs index 693eb3456..484aae1d0 100644 --- a/embassy-stm32/src/timer/complementary_pwm.rs +++ b/embassy-stm32/src/timer/complementary_pwm.rs | |||
| @@ -27,12 +27,10 @@ impl<'d, T: AdvancedInstance4Channel, C: TimerChannel, #[cfg(afio)] A> if_afio!( | |||
| 27 | pub fn new(pin: Peri<'d, if_afio!(impl TimerComplementaryPin<T, C, A>)>, output_type: OutputType) -> Self { | 27 | pub fn new(pin: Peri<'d, if_afio!(impl TimerComplementaryPin<T, C, A>)>, output_type: OutputType) -> Self { |
| 28 | critical_section::with(|_| { | 28 | critical_section::with(|_| { |
| 29 | pin.set_low(); | 29 | pin.set_low(); |
| 30 | pin.set_as_af( | 30 | set_as_af!( |
| 31 | pin.af_num(), | 31 | pin, |
| 32 | crate::gpio::AfType::output(output_type, crate::gpio::Speed::VeryHigh), | 32 | crate::gpio::AfType::output(output_type, crate::gpio::Speed::VeryHigh) |
| 33 | ); | 33 | ); |
| 34 | #[cfg(afio)] | ||
| 35 | pin.afio_remap(); | ||
| 36 | }); | 34 | }); |
| 37 | ComplementaryPwmPin { | 35 | ComplementaryPwmPin { |
| 38 | pin: pin.into(), | 36 | pin: pin.into(), |
diff --git a/embassy-stm32/src/timer/input_capture.rs b/embassy-stm32/src/timer/input_capture.rs index 41391bd6d..7a25e6c21 100644 --- a/embassy-stm32/src/timer/input_capture.rs +++ b/embassy-stm32/src/timer/input_capture.rs | |||
| @@ -25,7 +25,7 @@ pub struct CapturePin<'d, T, C, #[cfg(afio)] A> { | |||
| 25 | impl<'d, T: GeneralInstance4Channel, C: TimerChannel, #[cfg(afio)] A> if_afio!(CapturePin<'d, T, C, A>) { | 25 | impl<'d, T: GeneralInstance4Channel, C: TimerChannel, #[cfg(afio)] A> if_afio!(CapturePin<'d, T, C, A>) { |
| 26 | /// Create a new capture pin instance. | 26 | /// Create a new capture pin instance. |
| 27 | pub fn new(pin: Peri<'d, if_afio!(impl TimerPin<T, C, A>)>, pull: Pull) -> Self { | 27 | pub fn new(pin: Peri<'d, if_afio!(impl TimerPin<T, C, A>)>, pull: Pull) -> Self { |
| 28 | pin.set_as_af(pin.af_num(), AfType::input(pull)); | 28 | set_as_af!(pin, AfType::input(pull)); |
| 29 | CapturePin { | 29 | CapturePin { |
| 30 | pin: pin.into(), | 30 | pin: pin.into(), |
| 31 | phantom: PhantomData, | 31 | phantom: PhantomData, |
diff --git a/embassy-stm32/src/timer/one_pulse.rs b/embassy-stm32/src/timer/one_pulse.rs index edab38022..a75b41bd7 100644 --- a/embassy-stm32/src/timer/one_pulse.rs +++ b/embassy-stm32/src/timer/one_pulse.rs | |||
| @@ -65,9 +65,7 @@ impl SealedTriggerSource for Ext {} | |||
| 65 | impl<'d, T: GeneralInstance4Channel, C: TriggerSource + TimerChannel> TriggerPin<'d, T, C> { | 65 | impl<'d, T: GeneralInstance4Channel, C: TriggerSource + TimerChannel> TriggerPin<'d, T, C> { |
| 66 | /// Create a new Channel trigger pin instance. | 66 | /// Create a new Channel trigger pin instance. |
| 67 | pub fn new<#[cfg(afio)] A>(pin: Peri<'d, if_afio!(impl TimerPin<T, C, A>)>, pull: Pull) -> Self { | 67 | pub fn new<#[cfg(afio)] A>(pin: Peri<'d, if_afio!(impl TimerPin<T, C, A>)>, pull: Pull) -> Self { |
| 68 | pin.set_as_af(pin.af_num(), AfType::input(pull)); | 68 | set_as_af!(pin, AfType::input(pull)); |
| 69 | #[cfg(afio)] | ||
| 70 | pin.afio_remap(); | ||
| 71 | TriggerPin { | 69 | TriggerPin { |
| 72 | pin: pin.into(), | 70 | pin: pin.into(), |
| 73 | phantom: PhantomData, | 71 | phantom: PhantomData, |
| @@ -78,9 +76,7 @@ impl<'d, T: GeneralInstance4Channel, C: TriggerSource + TimerChannel> TriggerPin | |||
| 78 | impl<'d, T: GeneralInstance4Channel> TriggerPin<'d, T, Ext> { | 76 | impl<'d, T: GeneralInstance4Channel> TriggerPin<'d, T, Ext> { |
| 79 | /// Create a new external trigger pin instance. | 77 | /// Create a new external trigger pin instance. |
| 80 | pub fn new_external<#[cfg(afio)] A>(pin: Peri<'d, if_afio!(impl ExternalTriggerPin<T, A>)>, pull: Pull) -> Self { | 78 | pub fn new_external<#[cfg(afio)] A>(pin: Peri<'d, if_afio!(impl ExternalTriggerPin<T, A>)>, pull: Pull) -> Self { |
| 81 | pin.set_as_af(pin.af_num(), AfType::input(pull)); | 79 | set_as_af!(pin, AfType::input(pull)); |
| 82 | #[cfg(afio)] | ||
| 83 | pin.afio_remap(); | ||
| 84 | TriggerPin { | 80 | TriggerPin { |
| 85 | pin: pin.into(), | 81 | pin: pin.into(), |
| 86 | phantom: PhantomData, | 82 | phantom: PhantomData, |
diff --git a/embassy-stm32/src/timer/pwm_input.rs b/embassy-stm32/src/timer/pwm_input.rs index 4c1df0316..159b5a177 100644 --- a/embassy-stm32/src/timer/pwm_input.rs +++ b/embassy-stm32/src/timer/pwm_input.rs | |||
| @@ -24,9 +24,7 @@ impl<'d, T: GeneralInstance4Channel> PwmInput<'d, T> { | |||
| 24 | pull: Pull, | 24 | pull: Pull, |
| 25 | freq: Hertz, | 25 | freq: Hertz, |
| 26 | ) -> Self { | 26 | ) -> Self { |
| 27 | pin.set_as_af(pin.af_num(), AfType::input(pull)); | 27 | set_as_af!(pin, AfType::input(pull)); |
| 28 | #[cfg(afio)] | ||
| 29 | pin.afio_remap(); | ||
| 30 | 28 | ||
| 31 | Self::new_inner(tim, freq, Channel::Ch1, Channel::Ch2) | 29 | Self::new_inner(tim, freq, Channel::Ch1, Channel::Ch2) |
| 32 | } | 30 | } |
| @@ -38,9 +36,7 @@ impl<'d, T: GeneralInstance4Channel> PwmInput<'d, T> { | |||
| 38 | pull: Pull, | 36 | pull: Pull, |
| 39 | freq: Hertz, | 37 | freq: Hertz, |
| 40 | ) -> Self { | 38 | ) -> Self { |
| 41 | pin.set_as_af(pin.af_num(), AfType::input(pull)); | 39 | set_as_af!(pin, AfType::input(pull)); |
| 42 | #[cfg(afio)] | ||
| 43 | pin.afio_remap(); | ||
| 44 | 40 | ||
| 45 | Self::new_inner(tim, freq, Channel::Ch2, Channel::Ch1) | 41 | Self::new_inner(tim, freq, Channel::Ch2, Channel::Ch1) |
| 46 | } | 42 | } |
diff --git a/embassy-stm32/src/timer/qei.rs b/embassy-stm32/src/timer/qei.rs index 528c4a904..82b5968b0 100644 --- a/embassy-stm32/src/timer/qei.rs +++ b/embassy-stm32/src/timer/qei.rs | |||
| @@ -31,9 +31,7 @@ impl<'d, T: GeneralInstance4Channel, C: QeiChannel, #[cfg(afio)] A> if_afio!(Qei | |||
| 31 | pub fn new(pin: Peri<'d, if_afio!(impl TimerPin<T, C, A>)>) -> Self { | 31 | pub fn new(pin: Peri<'d, if_afio!(impl TimerPin<T, C, A>)>) -> Self { |
| 32 | critical_section::with(|_| { | 32 | critical_section::with(|_| { |
| 33 | pin.set_low(); | 33 | pin.set_low(); |
| 34 | pin.set_as_af(pin.af_num(), AfType::input(Pull::None)); | 34 | set_as_af!(pin, AfType::input(Pull::None)); |
| 35 | #[cfg(afio)] | ||
| 36 | pin.afio_remap(); | ||
| 37 | }); | 35 | }); |
| 38 | QeiPin { | 36 | QeiPin { |
| 39 | pin: pin.into(), | 37 | pin: pin.into(), |
diff --git a/embassy-stm32/src/timer/simple_pwm.rs b/embassy-stm32/src/timer/simple_pwm.rs index c08a3939f..e6165e42b 100644 --- a/embassy-stm32/src/timer/simple_pwm.rs +++ b/embassy-stm32/src/timer/simple_pwm.rs | |||
| @@ -40,9 +40,7 @@ impl<'d, T: GeneralInstance4Channel, C: TimerChannel, #[cfg(afio)] A> if_afio!(P | |||
| 40 | pub fn new(pin: Peri<'d, if_afio!(impl TimerPin<T, C, A>)>, output_type: OutputType) -> Self { | 40 | pub fn new(pin: Peri<'d, if_afio!(impl TimerPin<T, C, A>)>, output_type: OutputType) -> Self { |
| 41 | critical_section::with(|_| { | 41 | critical_section::with(|_| { |
| 42 | pin.set_low(); | 42 | pin.set_low(); |
| 43 | pin.set_as_af(pin.af_num(), AfType::output(output_type, Speed::VeryHigh)); | 43 | set_as_af!(pin, AfType::output(output_type, Speed::VeryHigh)); |
| 44 | #[cfg(afio)] | ||
| 45 | pin.afio_remap(); | ||
| 46 | }); | 44 | }); |
| 47 | PwmPin { | 45 | PwmPin { |
| 48 | pin: pin.into(), | 46 | pin: pin.into(), |
| @@ -54,15 +52,13 @@ impl<'d, T: GeneralInstance4Channel, C: TimerChannel, #[cfg(afio)] A> if_afio!(P | |||
| 54 | pub fn new_with_config(pin: Peri<'d, if_afio!(impl TimerPin<T, C, A>)>, pin_config: PwmPinConfig) -> Self { | 52 | pub fn new_with_config(pin: Peri<'d, if_afio!(impl TimerPin<T, C, A>)>, pin_config: PwmPinConfig) -> Self { |
| 55 | critical_section::with(|_| { | 53 | critical_section::with(|_| { |
| 56 | pin.set_low(); | 54 | pin.set_low(); |
| 57 | pin.set_as_af( | 55 | #[cfg(gpio_v1)] |
| 58 | pin.af_num(), | 56 | set_as_af!(pin, AfType::output(pin_config.output_type, pin_config.speed)); |
| 59 | #[cfg(gpio_v1)] | 57 | #[cfg(gpio_v2)] |
| 60 | AfType::output(pin_config.output_type, pin_config.speed), | 58 | set_as_af!( |
| 61 | #[cfg(gpio_v2)] | 59 | pin, |
| 62 | AfType::output_pull(pin_config.output_type, pin_config.speed, pin_config.pull), | 60 | AfType::output_pull(pin_config.output_type, pin_config.speed, pin_config.pull) |
| 63 | ); | 61 | ); |
| 64 | #[cfg(afio)] | ||
| 65 | pin.afio_remap(); | ||
| 66 | }); | 62 | }); |
| 67 | PwmPin { | 63 | PwmPin { |
| 68 | pin: pin.into(), | 64 | pin: pin.into(), |
