aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/timer
diff options
context:
space:
mode:
authorBruno Bousquet <[email protected]>2024-05-28 22:43:23 -0400
committerBruno Bousquet <[email protected]>2024-05-28 22:43:23 -0400
commitf1d5f4ca21629036f510e52aeee617ffb70db51b (patch)
treee7c89ddec8531d490f050581189bb1966eaee65e /embassy-stm32/src/timer
parenta52841041de7cbc6d315b3616768b531716056a0 (diff)
undo minor changes
Diffstat (limited to 'embassy-stm32/src/timer')
-rw-r--r--embassy-stm32/src/timer/input_capture.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/embassy-stm32/src/timer/input_capture.rs b/embassy-stm32/src/timer/input_capture.rs
index 5dadc9131..000938a70 100644
--- a/embassy-stm32/src/timer/input_capture.rs
+++ b/embassy-stm32/src/timer/input_capture.rs
@@ -26,10 +26,6 @@ pub enum Ch3 {}
26/// Channel 4 marker type. 26/// Channel 4 marker type.
27pub enum Ch4 {} 27pub enum Ch4 {}
28 28
29fn regs_gp16(ptr: *mut ()) -> crate::pac::timer::TimGp16 {
30 unsafe { crate::pac::timer::TimGp16::from_ptr(ptr) }
31}
32
33/// Capture pin wrapper. 29/// Capture pin wrapper.
34/// 30///
35/// This wraps a pin to make it usable with capture. 31/// This wraps a pin to make it usable with capture.
@@ -80,6 +76,10 @@ impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> {
80 freq: Hertz, 76 freq: Hertz,
81 counting_mode: CountingMode, 77 counting_mode: CountingMode,
82 ) -> Self { 78 ) -> Self {
79 Self::new_inner(tim, freq, counting_mode)
80 }
81
82 fn new_inner(tim: impl Peripheral<P = T> + 'd, freq: Hertz, counting_mode: CountingMode) -> Self {
83 let mut this = Self { inner: Timer::new(tim) }; 83 let mut this = Self { inner: Timer::new(tim) };
84 84
85 this.inner.set_counting_mode(counting_mode); 85 this.inner.set_counting_mode(counting_mode);
@@ -150,6 +150,7 @@ impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> {
150 fn new_future(&self, channel: Channel, mode: InputCaptureMode, tisel: InputTISelection) -> InputCaptureFuture<T> { 150 fn new_future(&self, channel: Channel, mode: InputCaptureMode, tisel: InputTISelection) -> InputCaptureFuture<T> {
151 use stm32_metapac::timer::vals::FilterValue; 151 use stm32_metapac::timer::vals::FilterValue;
152 152
153 // Configuration steps from ST RM0390 chapter 17.3.5 Input Capture Mode
153 self.inner.set_input_ti_selection(channel, tisel); 154 self.inner.set_input_ti_selection(channel, tisel);
154 self.inner.set_input_capture_filter(channel, FilterValue::NOFILTER); 155 self.inner.set_input_capture_filter(channel, FilterValue::NOFILTER);
155 self.inner.set_input_capture_mode(channel, mode); 156 self.inner.set_input_capture_mode(channel, mode);
@@ -200,6 +201,11 @@ impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> {
200 } 201 }
201} 202}
202 203
204/// Convert pointer to TIM instance to TimGp16 object
205fn regs_gp16(ptr: *mut ()) -> crate::pac::timer::TimGp16 {
206 unsafe { crate::pac::timer::TimGp16::from_ptr(ptr) }
207}
208
203#[must_use = "futures do nothing unless you `.await` or poll them"] 209#[must_use = "futures do nothing unless you `.await` or poll them"]
204struct InputCaptureFuture<T: GeneralInstance4Channel> { 210struct InputCaptureFuture<T: GeneralInstance4Channel> {
205 channel: Channel, 211 channel: Channel,