diff options
| author | Gabriel Smith <[email protected]> | 2025-03-28 17:20:36 +0000 |
|---|---|---|
| committer | Gabriel Smith <[email protected]> | 2025-04-04 17:40:15 +0000 |
| commit | eee2d8c84d318b36a80759aad26e2303965c0565 (patch) | |
| tree | d01d72bdafab5b32f0064c8bc787e0a2f3352ced | |
| parent | d097ccc68cce25c95ca2594c7c0bcd62c3c40640 (diff) | |
stm32/timer: Merge channel typestate structs
| -rw-r--r-- | embassy-stm32/src/timer/input_capture.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/mod.rs | 9 | ||||
| -rw-r--r-- | embassy-stm32/src/timer/qei.rs | 6 |
3 files changed, 11 insertions, 14 deletions
diff --git a/embassy-stm32/src/timer/input_capture.rs b/embassy-stm32/src/timer/input_capture.rs index b7c13343c..4d59ac3dc 100644 --- a/embassy-stm32/src/timer/input_capture.rs +++ b/embassy-stm32/src/timer/input_capture.rs | |||
| @@ -12,20 +12,12 @@ use super::{ | |||
| 12 | CaptureCompareInterruptHandler, Channel, Channel1Pin, Channel2Pin, Channel3Pin, Channel4Pin, | 12 | CaptureCompareInterruptHandler, Channel, Channel1Pin, Channel2Pin, Channel3Pin, Channel4Pin, |
| 13 | GeneralInstance4Channel, | 13 | GeneralInstance4Channel, |
| 14 | }; | 14 | }; |
| 15 | pub use super::{Ch1, Ch2, Ch3, Ch4}; | ||
| 15 | use crate::gpio::{AfType, AnyPin, Pull}; | 16 | use crate::gpio::{AfType, AnyPin, Pull}; |
| 16 | use crate::interrupt::typelevel::{Binding, Interrupt}; | 17 | use crate::interrupt::typelevel::{Binding, Interrupt}; |
| 17 | use crate::time::Hertz; | 18 | use crate::time::Hertz; |
| 18 | use crate::Peripheral; | 19 | use crate::Peripheral; |
| 19 | 20 | ||
| 20 | /// Channel 1 marker type. | ||
| 21 | pub enum Ch1 {} | ||
| 22 | /// Channel 2 marker type. | ||
| 23 | pub enum Ch2 {} | ||
| 24 | /// Channel 3 marker type. | ||
| 25 | pub enum Ch3 {} | ||
| 26 | /// Channel 4 marker type. | ||
| 27 | pub enum Ch4 {} | ||
| 28 | |||
| 29 | /// Capture pin wrapper. | 21 | /// Capture pin wrapper. |
| 30 | /// | 22 | /// |
| 31 | /// This wraps a pin to make it usable with capture. | 23 | /// This wraps a pin to make it usable with capture. |
diff --git a/embassy-stm32/src/timer/mod.rs b/embassy-stm32/src/timer/mod.rs index 97740c2ed..645556e8c 100644 --- a/embassy-stm32/src/timer/mod.rs +++ b/embassy-stm32/src/timer/mod.rs | |||
| @@ -41,6 +41,15 @@ impl Channel { | |||
| 41 | } | 41 | } |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | /// Channel 1 marker type. | ||
| 45 | pub enum Ch1 {} | ||
| 46 | /// Channel 2 marker type. | ||
| 47 | pub enum Ch2 {} | ||
| 48 | /// Channel 3 marker type. | ||
| 49 | pub enum Ch3 {} | ||
| 50 | /// Channel 4 marker type. | ||
| 51 | pub enum Ch4 {} | ||
| 52 | |||
| 44 | /// Amount of bits of a timer. | 53 | /// Amount of bits of a timer. |
| 45 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] | 54 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
| 46 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 55 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
diff --git a/embassy-stm32/src/timer/qei.rs b/embassy-stm32/src/timer/qei.rs index fc5835414..4fd883540 100644 --- a/embassy-stm32/src/timer/qei.rs +++ b/embassy-stm32/src/timer/qei.rs | |||
| @@ -6,6 +6,7 @@ use embassy_hal_internal::{into_ref, PeripheralRef}; | |||
| 6 | use stm32_metapac::timer::vals; | 6 | use stm32_metapac::timer::vals; |
| 7 | 7 | ||
| 8 | use super::low_level::Timer; | 8 | use super::low_level::Timer; |
| 9 | pub use super::{Ch1, Ch2}; | ||
| 9 | use super::{Channel1Pin, Channel2Pin, GeneralInstance4Channel}; | 10 | use super::{Channel1Pin, Channel2Pin, GeneralInstance4Channel}; |
| 10 | use crate::gpio::{AfType, AnyPin, Pull}; | 11 | use crate::gpio::{AfType, AnyPin, Pull}; |
| 11 | use crate::Peripheral; | 12 | use crate::Peripheral; |
| @@ -18,11 +19,6 @@ pub enum Direction { | |||
| 18 | Downcounting, | 19 | Downcounting, |
| 19 | } | 20 | } |
| 20 | 21 | ||
| 21 | /// Channel 1 marker type. | ||
| 22 | pub enum Ch1 {} | ||
| 23 | /// Channel 2 marker type. | ||
| 24 | pub enum Ch2 {} | ||
| 25 | |||
| 26 | /// Wrapper for using a pin with QEI. | 22 | /// Wrapper for using a pin with QEI. |
| 27 | pub struct QeiPin<'d, T, Channel> { | 23 | pub struct QeiPin<'d, T, Channel> { |
| 28 | _pin: PeripheralRef<'d, AnyPin>, | 24 | _pin: PeripheralRef<'d, AnyPin>, |
