aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/CHANGELOG.md1
-rw-r--r--embassy-stm32/src/timer/input_capture.rs42
2 files changed, 43 insertions, 0 deletions
diff --git a/embassy-stm32/CHANGELOG.md b/embassy-stm32/CHANGELOG.md
index d26f1acdd..67af79080 100644
--- a/embassy-stm32/CHANGELOG.md
+++ b/embassy-stm32/CHANGELOG.md
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 6and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7 7
8## Unreleased - ReleaseDate 8## Unreleased - ReleaseDate
9- Add `receive_waveform` method in `InputCapture`, allowing asynchronous input capture with DMA.
9 10
10- fix: stm32: GPDMA driver reset ignored during channel configuration 11- fix: stm32: GPDMA driver reset ignored during channel configuration
11- fix: stm32: SPI driver SSOE and SSM manegment, add `nss_output_disable` to SPI Config 12- fix: stm32: SPI driver SSOE and SSM manegment, add `nss_output_disable` to SPI Config
diff --git a/embassy-stm32/src/timer/input_capture.rs b/embassy-stm32/src/timer/input_capture.rs
index 3e1482b67..905f2de1a 100644
--- a/embassy-stm32/src/timer/input_capture.rs
+++ b/embassy-stm32/src/timer/input_capture.rs
@@ -156,6 +156,48 @@ impl<'d, T: GeneralInstance4Channel> InputCapture<'d, T> {
156 self.new_future(channel, InputCaptureMode::BothEdges, InputTISelection::Alternate) 156 self.new_future(channel, InputCaptureMode::BothEdges, InputTISelection::Alternate)
157 .await 157 .await
158 } 158 }
159
160 /// Capture a sequence of timer input edges into a buffer using DMA
161 pub async fn receive_waveform<M>(&mut self, dma: Peri<'_, impl super::Dma<T, M>>, buf: &mut [u16])
162 where
163 M: TimerChannel,
164 {
165 #[allow(clippy::let_unit_value)] // eg. stm32f334
166 let req = dma.request();
167
168 let original_enable_state = self.is_enabled(M::CHANNEL);
169 let original_cc_dma_enable_state = self.inner.get_cc_dma_enable_state(M::CHANNEL);
170
171 self.inner.set_input_ti_selection(M::CHANNEL, InputTISelection::Normal);
172 self.inner
173 .set_input_capture_mode(M::CHANNEL, InputCaptureMode::BothEdges);
174
175 if !original_cc_dma_enable_state {
176 self.inner.set_cc_dma_enable_state(M::CHANNEL, true);
177 }
178
179 if !original_enable_state {
180 self.enable(M::CHANNEL);
181 }
182
183 unsafe {
184 use crate::dma::{Transfer, TransferOptions};
185
186 Transfer::new_read(
187 dma,
188 req,
189 self.inner.regs_gp16().ccr(M::CHANNEL.index()).as_ptr() as *mut u16,
190 buf,
191 TransferOptions::default(),
192 )
193 .await
194 };
195
196 // restore output compare state
197 if !original_enable_state {
198 self.disable(M::CHANNEL);
199 }
200 }
159} 201}
160 202
161#[must_use = "futures do nothing unless you `.await` or poll them"] 203#[must_use = "futures do nothing unless you `.await` or poll them"]