aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Smith <[email protected]>2025-03-28 17:20:36 +0000
committerGabriel Smith <[email protected]>2025-04-04 17:40:15 +0000
commiteee2d8c84d318b36a80759aad26e2303965c0565 (patch)
treed01d72bdafab5b32f0064c8bc787e0a2f3352ced
parentd097ccc68cce25c95ca2594c7c0bcd62c3c40640 (diff)
stm32/timer: Merge channel typestate structs
-rw-r--r--embassy-stm32/src/timer/input_capture.rs10
-rw-r--r--embassy-stm32/src/timer/mod.rs9
-rw-r--r--embassy-stm32/src/timer/qei.rs6
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};
15pub use super::{Ch1, Ch2, Ch3, Ch4};
15use crate::gpio::{AfType, AnyPin, Pull}; 16use crate::gpio::{AfType, AnyPin, Pull};
16use crate::interrupt::typelevel::{Binding, Interrupt}; 17use crate::interrupt::typelevel::{Binding, Interrupt};
17use crate::time::Hertz; 18use crate::time::Hertz;
18use crate::Peripheral; 19use crate::Peripheral;
19 20
20/// Channel 1 marker type.
21pub enum Ch1 {}
22/// Channel 2 marker type.
23pub enum Ch2 {}
24/// Channel 3 marker type.
25pub enum Ch3 {}
26/// Channel 4 marker type.
27pub 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.
45pub enum Ch1 {}
46/// Channel 2 marker type.
47pub enum Ch2 {}
48/// Channel 3 marker type.
49pub enum Ch3 {}
50/// Channel 4 marker type.
51pub 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};
6use stm32_metapac::timer::vals; 6use stm32_metapac::timer::vals;
7 7
8use super::low_level::Timer; 8use super::low_level::Timer;
9pub use super::{Ch1, Ch2};
9use super::{Channel1Pin, Channel2Pin, GeneralInstance4Channel}; 10use super::{Channel1Pin, Channel2Pin, GeneralInstance4Channel};
10use crate::gpio::{AfType, AnyPin, Pull}; 11use crate::gpio::{AfType, AnyPin, Pull};
11use crate::Peripheral; 12use crate::Peripheral;
@@ -18,11 +19,6 @@ pub enum Direction {
18 Downcounting, 19 Downcounting,
19} 20}
20 21
21/// Channel 1 marker type.
22pub enum Ch1 {}
23/// Channel 2 marker type.
24pub enum Ch2 {}
25
26/// Wrapper for using a pin with QEI. 22/// Wrapper for using a pin with QEI.
27pub struct QeiPin<'d, T, Channel> { 23pub struct QeiPin<'d, T, Channel> {
28 _pin: PeripheralRef<'d, AnyPin>, 24 _pin: PeripheralRef<'d, AnyPin>,