diff options
| author | melvdl <[email protected]> | 2025-06-27 01:08:28 +0200 |
|---|---|---|
| committer | melvdl <[email protected]> | 2025-06-27 01:08:28 +0200 |
| commit | 6f88c2c73caa63a6e534130f4a064cb95d3e9d7d (patch) | |
| tree | fdddad93e4f48f32ff15a3b8ad6cd0ae12095fd4 /embassy-stm32/src/timer/one_pulse.rs | |
| parent | cbd24bf2eece65a787fc085c255e9b2932ea73e3 (diff) | |
stm32: rename timer channel trait; replace impls via macro with impls generic over timer channels
Diffstat (limited to 'embassy-stm32/src/timer/one_pulse.rs')
| -rw-r--r-- | embassy-stm32/src/timer/one_pulse.rs | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/embassy-stm32/src/timer/one_pulse.rs b/embassy-stm32/src/timer/one_pulse.rs index e89ad8390..c8f0cafe7 100644 --- a/embassy-stm32/src/timer/one_pulse.rs +++ b/embassy-stm32/src/timer/one_pulse.rs | |||
| @@ -9,7 +9,7 @@ use core::task::{Context, Poll}; | |||
| 9 | use super::low_level::{ | 9 | use super::low_level::{ |
| 10 | CountingMode, FilterValue, InputCaptureMode, InputTISelection, SlaveMode, Timer, TriggerSource as Ts, | 10 | CountingMode, FilterValue, InputCaptureMode, InputTISelection, SlaveMode, Timer, TriggerSource as Ts, |
| 11 | }; | 11 | }; |
| 12 | use super::{CaptureCompareInterruptHandler, ExternalTriggerPin, GeneralInstance4Channel, TimerChannel, TimerPin}; | 12 | use super::{CaptureCompareInterruptHandler, Channel, ExternalTriggerPin, GeneralInstance4Channel, TimerPin}; |
| 13 | pub use super::{Ch1, Ch2}; | 13 | pub use super::{Ch1, Ch2}; |
| 14 | use crate::gpio::{AfType, AnyPin, Pull}; | 14 | use crate::gpio::{AfType, AnyPin, Pull}; |
| 15 | use crate::interrupt::typelevel::{Binding, Interrupt}; | 15 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| @@ -76,7 +76,7 @@ impl<T, P, C> TimerTriggerPin<T, C> for P | |||
| 76 | where | 76 | where |
| 77 | T: GeneralInstance4Channel, | 77 | T: GeneralInstance4Channel, |
| 78 | P: TimerPin<T, C>, | 78 | P: TimerPin<T, C>, |
| 79 | C: super::Channel + TriggerSource, | 79 | C: super::TimerChannel + TriggerSource, |
| 80 | { | 80 | { |
| 81 | fn af_num(&self) -> u8 { | 81 | fn af_num(&self) -> u8 { |
| 82 | TimerPin::af_num(self) | 82 | TimerPin::af_num(self) |
| @@ -97,7 +97,7 @@ impl<T, P, C> SealedTimerTriggerPin<T, C> for P | |||
| 97 | where | 97 | where |
| 98 | T: GeneralInstance4Channel, | 98 | T: GeneralInstance4Channel, |
| 99 | P: TimerPin<T, C>, | 99 | P: TimerPin<T, C>, |
| 100 | C: super::Channel + TriggerSource, | 100 | C: super::TimerChannel + TriggerSource, |
| 101 | { | 101 | { |
| 102 | } | 102 | } |
| 103 | 103 | ||
| @@ -143,9 +143,9 @@ impl<'d, T: GeneralInstance4Channel> OnePulse<'d, T> { | |||
| 143 | 143 | ||
| 144 | this.inner.set_trigger_source(Ts::TI1F_ED); | 144 | this.inner.set_trigger_source(Ts::TI1F_ED); |
| 145 | this.inner | 145 | this.inner |
| 146 | .set_input_ti_selection(TimerChannel::Ch1, InputTISelection::Normal); | 146 | .set_input_ti_selection(Channel::Ch1, InputTISelection::Normal); |
| 147 | this.inner | 147 | this.inner |
| 148 | .set_input_capture_filter(TimerChannel::Ch1, FilterValue::NO_FILTER); | 148 | .set_input_capture_filter(Channel::Ch1, FilterValue::NO_FILTER); |
| 149 | this.new_inner(freq, pulse_end, counting_mode); | 149 | this.new_inner(freq, pulse_end, counting_mode); |
| 150 | 150 | ||
| 151 | this | 151 | this |
| @@ -168,10 +168,10 @@ impl<'d, T: GeneralInstance4Channel> OnePulse<'d, T> { | |||
| 168 | 168 | ||
| 169 | this.inner.set_trigger_source(Ts::TI1FP1); | 169 | this.inner.set_trigger_source(Ts::TI1FP1); |
| 170 | this.inner | 170 | this.inner |
| 171 | .set_input_ti_selection(TimerChannel::Ch1, InputTISelection::Normal); | 171 | .set_input_ti_selection(Channel::Ch1, InputTISelection::Normal); |
| 172 | this.inner | 172 | this.inner |
| 173 | .set_input_capture_filter(TimerChannel::Ch1, FilterValue::NO_FILTER); | 173 | .set_input_capture_filter(Channel::Ch1, FilterValue::NO_FILTER); |
| 174 | this.inner.set_input_capture_mode(TimerChannel::Ch1, capture_mode); | 174 | this.inner.set_input_capture_mode(Channel::Ch1, capture_mode); |
| 175 | this.new_inner(freq, pulse_end, counting_mode); | 175 | this.new_inner(freq, pulse_end, counting_mode); |
| 176 | 176 | ||
| 177 | this | 177 | this |
| @@ -194,10 +194,10 @@ impl<'d, T: GeneralInstance4Channel> OnePulse<'d, T> { | |||
| 194 | 194 | ||
| 195 | this.inner.set_trigger_source(Ts::TI2FP2); | 195 | this.inner.set_trigger_source(Ts::TI2FP2); |
| 196 | this.inner | 196 | this.inner |
| 197 | .set_input_ti_selection(TimerChannel::Ch2, InputTISelection::Normal); | 197 | .set_input_ti_selection(Channel::Ch2, InputTISelection::Normal); |
| 198 | this.inner | 198 | this.inner |
| 199 | .set_input_capture_filter(TimerChannel::Ch2, FilterValue::NO_FILTER); | 199 | .set_input_capture_filter(Channel::Ch2, FilterValue::NO_FILTER); |
| 200 | this.inner.set_input_capture_mode(TimerChannel::Ch2, capture_mode); | 200 | this.inner.set_input_capture_mode(Channel::Ch2, capture_mode); |
| 201 | this.new_inner(freq, pulse_end, counting_mode); | 201 | this.new_inner(freq, pulse_end, counting_mode); |
| 202 | 202 | ||
| 203 | this | 203 | this |
| @@ -269,7 +269,7 @@ impl<'d, T: GeneralInstance4Channel> OnePulse<'d, T> { | |||
| 269 | /// Get a single channel | 269 | /// Get a single channel |
| 270 | /// | 270 | /// |
| 271 | /// If you need to use multiple channels, use [`Self::split`]. | 271 | /// If you need to use multiple channels, use [`Self::split`]. |
| 272 | pub fn channel(&mut self, channel: TimerChannel) -> OnePulseChannel<'_, T> { | 272 | pub fn channel(&mut self, channel: Channel) -> OnePulseChannel<'_, T> { |
| 273 | OnePulseChannel { | 273 | OnePulseChannel { |
| 274 | inner: unsafe { self.inner.clone_unchecked() }, | 274 | inner: unsafe { self.inner.clone_unchecked() }, |
| 275 | channel, | 275 | channel, |
| @@ -282,7 +282,7 @@ impl<'d, T: GeneralInstance4Channel> OnePulse<'d, T> { | |||
| 282 | /// | 282 | /// |
| 283 | /// If you need to use multiple channels, use [`Self::split`]. | 283 | /// If you need to use multiple channels, use [`Self::split`]. |
| 284 | pub fn ch1(&mut self) -> OnePulseChannel<'_, T> { | 284 | pub fn ch1(&mut self) -> OnePulseChannel<'_, T> { |
| 285 | self.channel(TimerChannel::Ch1) | 285 | self.channel(Channel::Ch1) |
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | /// Channel 2 | 288 | /// Channel 2 |
| @@ -291,7 +291,7 @@ impl<'d, T: GeneralInstance4Channel> OnePulse<'d, T> { | |||
| 291 | /// | 291 | /// |
| 292 | /// If you need to use multiple channels, use [`Self::split`]. | 292 | /// If you need to use multiple channels, use [`Self::split`]. |
| 293 | pub fn ch2(&mut self) -> OnePulseChannel<'_, T> { | 293 | pub fn ch2(&mut self) -> OnePulseChannel<'_, T> { |
| 294 | self.channel(TimerChannel::Ch2) | 294 | self.channel(Channel::Ch2) |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | /// Channel 3 | 297 | /// Channel 3 |
| @@ -300,7 +300,7 @@ impl<'d, T: GeneralInstance4Channel> OnePulse<'d, T> { | |||
| 300 | /// | 300 | /// |
| 301 | /// If you need to use multiple channels, use [`Self::split`]. | 301 | /// If you need to use multiple channels, use [`Self::split`]. |
| 302 | pub fn ch3(&mut self) -> OnePulseChannel<'_, T> { | 302 | pub fn ch3(&mut self) -> OnePulseChannel<'_, T> { |
| 303 | self.channel(TimerChannel::Ch3) | 303 | self.channel(Channel::Ch3) |
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | /// Channel 4 | 306 | /// Channel 4 |
| @@ -309,7 +309,7 @@ impl<'d, T: GeneralInstance4Channel> OnePulse<'d, T> { | |||
| 309 | /// | 309 | /// |
| 310 | /// If you need to use multiple channels, use [`Self::split`]. | 310 | /// If you need to use multiple channels, use [`Self::split`]. |
| 311 | pub fn ch4(&mut self) -> OnePulseChannel<'_, T> { | 311 | pub fn ch4(&mut self) -> OnePulseChannel<'_, T> { |
| 312 | self.channel(TimerChannel::Ch4) | 312 | self.channel(Channel::Ch4) |
| 313 | } | 313 | } |
| 314 | 314 | ||
| 315 | /// Splits a [`OnePulse`] into four output channels. | 315 | /// Splits a [`OnePulse`] into four output channels. |
| @@ -328,10 +328,10 @@ impl<'d, T: GeneralInstance4Channel> OnePulse<'d, T> { | |||
| 328 | }; | 328 | }; |
| 329 | 329 | ||
| 330 | OnePulseChannels { | 330 | OnePulseChannels { |
| 331 | ch1: ch(TimerChannel::Ch1), | 331 | ch1: ch(Channel::Ch1), |
| 332 | ch2: ch(TimerChannel::Ch2), | 332 | ch2: ch(Channel::Ch2), |
| 333 | ch3: ch(TimerChannel::Ch3), | 333 | ch3: ch(Channel::Ch3), |
| 334 | ch4: ch(TimerChannel::Ch4), | 334 | ch4: ch(Channel::Ch4), |
| 335 | } | 335 | } |
| 336 | } | 336 | } |
| 337 | } | 337 | } |
| @@ -355,7 +355,7 @@ pub struct OnePulseChannels<'d, T: GeneralInstance4Channel> { | |||
| 355 | /// configuration is shared with all four channels. | 355 | /// configuration is shared with all four channels. |
| 356 | pub struct OnePulseChannel<'d, T: GeneralInstance4Channel> { | 356 | pub struct OnePulseChannel<'d, T: GeneralInstance4Channel> { |
| 357 | inner: ManuallyDrop<Timer<'d, T>>, | 357 | inner: ManuallyDrop<Timer<'d, T>>, |
| 358 | channel: TimerChannel, | 358 | channel: Channel, |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | impl<'d, T: GeneralInstance4Channel> OnePulseChannel<'d, T> { | 361 | impl<'d, T: GeneralInstance4Channel> OnePulseChannel<'d, T> { |
| @@ -402,7 +402,7 @@ impl<'d, T: GeneralInstance4Channel> OnePulseChannel<'d, T> { | |||
| 402 | 402 | ||
| 403 | #[must_use = "futures do nothing unless you `.await` or poll them"] | 403 | #[must_use = "futures do nothing unless you `.await` or poll them"] |
| 404 | struct OnePulseFuture<T: GeneralInstance4Channel> { | 404 | struct OnePulseFuture<T: GeneralInstance4Channel> { |
| 405 | channel: TimerChannel, | 405 | channel: Channel, |
| 406 | phantom: PhantomData<T>, | 406 | phantom: PhantomData<T>, |
| 407 | } | 407 | } |
| 408 | 408 | ||
