aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/adc/g4.rs2
-rw-r--r--embassy-stm32/src/adc/ringbuffered_v2.rs20
-rw-r--r--embassy-stm32/src/adc/v2.rs2
-rw-r--r--embassy-stm32/src/adc/v3.rs30
-rw-r--r--embassy-stm32/src/adc/v4.rs30
-rw-r--r--examples/stm32f4/src/bin/adc.rs8
-rw-r--r--examples/stm32f4/src/bin/adc_dma.rs4
-rw-r--r--examples/stm32f7/src/bin/adc.rs4
-rw-r--r--examples/stm32g0/src/bin/adc.rs4
-rw-r--r--examples/stm32g0/src/bin/adc_dma.rs2
-rw-r--r--examples/stm32g0/src/bin/adc_oversampling.rs2
-rw-r--r--examples/stm32g4/src/bin/adc.rs2
-rw-r--r--examples/stm32h7/src/bin/adc.rs4
-rw-r--r--examples/stm32h7/src/bin/adc_dma.rs2
-rw-r--r--examples/stm32l4/src/bin/adc.rs2
-rw-r--r--examples/stm32u0/src/bin/adc.rs2
-rw-r--r--tests/stm32/src/bin/dac.rs4
17 files changed, 86 insertions, 38 deletions
diff --git a/embassy-stm32/src/adc/g4.rs b/embassy-stm32/src/adc/g4.rs
index 6569361fe..c1e584f59 100644
--- a/embassy-stm32/src/adc/g4.rs
+++ b/embassy-stm32/src/adc/g4.rs
@@ -258,7 +258,7 @@ impl<'d, T: Instance> Adc<'d, T> {
258 } 258 }
259 259
260 /// Read an ADC pin. 260 /// Read an ADC pin.
261 pub fn read(&mut self, channel: &mut impl AdcChannel<T>) -> u16 { 261 pub fn blocking_read(&mut self, channel: &mut impl AdcChannel<T>) -> u16 {
262 channel.setup(); 262 channel.setup();
263 263
264 self.read_channel(channel.channel()) 264 self.read_channel(channel.channel())
diff --git a/embassy-stm32/src/adc/ringbuffered_v2.rs b/embassy-stm32/src/adc/ringbuffered_v2.rs
index 92b34c3fd..3b064044e 100644
--- a/embassy-stm32/src/adc/ringbuffered_v2.rs
+++ b/embassy-stm32/src/adc/ringbuffered_v2.rs
@@ -97,10 +97,10 @@ impl<'d, T: Instance> Adc<'d, T> {
97 /// The length of the `dma_buf` should be a multiple of the ADC channel count. 97 /// The length of the `dma_buf` should be a multiple of the ADC channel count.
98 /// For example, if 3 channels are measured, its length can be 3 * 40 = 120 measurements. 98 /// For example, if 3 channels are measured, its length can be 3 * 40 = 120 measurements.
99 /// 99 ///
100 /// `read_exact` method is used to read out measurements from the DMA ring buffer, and its buffer should be exactly half of the `dma_buf` length. 100 /// `read` method is used to read out measurements from the DMA ring buffer, and its buffer should be exactly half of the `dma_buf` length.
101 /// It is critical to call `read_exact` frequently to prevent DMA buffer overrun. 101 /// It is critical to call `read` frequently to prevent DMA buffer overrun.
102 /// 102 ///
103 /// [`read_exact`]: #method.read_exact 103 /// [`read`]: #method.read
104 pub fn into_ring_buffered( 104 pub fn into_ring_buffered(
105 self, 105 self,
106 dma: impl Peripheral<P = impl RxDma<T>> + 'd, 106 dma: impl Peripheral<P = impl RxDma<T>> + 'd,
@@ -331,7 +331,7 @@ impl<'d, T: Instance> RingBufferedAdc<'d, T> {
331 /// 331 ///
332 /// Receive in the background is terminated if an error is returned. 332 /// Receive in the background is terminated if an error is returned.
333 /// It must then manually be started again by calling `start()` or by re-calling `read()`. 333 /// It must then manually be started again by calling `start()` or by re-calling `read()`.
334 pub fn read<const N: usize>(&mut self, buf: &mut [u16; N]) -> Result<usize, OverrunError> { 334 pub fn blocking_read<const N: usize>(&mut self, buf: &mut [u16; N]) -> Result<usize, OverrunError> {
335 let r = T::regs(); 335 let r = T::regs();
336 336
337 // Start background receive if it was not already started 337 // Start background receive if it was not already started
@@ -362,14 +362,14 @@ impl<'d, T: Instance> RingBufferedAdc<'d, T> {
362 /// This method fills the provided `measurements` array with ADC readings from the DMA buffer. 362 /// This method fills the provided `measurements` array with ADC readings from the DMA buffer.
363 /// The length of the `measurements` array should be exactly half of the DMA buffer length. Because interrupts are only generated if half or full DMA transfer completes. 363 /// The length of the `measurements` array should be exactly half of the DMA buffer length. Because interrupts are only generated if half or full DMA transfer completes.
364 /// 364 ///
365 /// Each call to `read_exact` will populate the `measurements` array in the same order as the channels defined with `set_sample_sequence`. 365 /// Each call to `read` will populate the `measurements` array in the same order as the channels defined with `set_sample_sequence`.
366 /// There will be many sequences worth of measurements in this array because it only returns if at least half of the DMA buffer is filled. 366 /// There will be many sequences worth of measurements in this array because it only returns if at least half of the DMA buffer is filled.
367 /// For example if 3 channels are sampled `measurements` contain: `[sq0 sq1 sq3 sq0 sq1 sq3 sq0 sq1 sq3 sq0 sq1 sq3..]`. 367 /// For example if 3 channels are sampled `measurements` contain: `[sq0 sq1 sq3 sq0 sq1 sq3 sq0 sq1 sq3 sq0 sq1 sq3..]`.
368 /// 368 ///
369 /// If an error is returned, it indicates a DMA overrun, and the process must be restarted by calling `start` or `read_exact` again. 369 /// If an error is returned, it indicates a DMA overrun, and the process must be restarted by calling `start` or `read` again.
370 /// 370 ///
371 /// By default, the ADC fills the DMA buffer as quickly as possible. To control the sample rate, call `teardown_adc` after each readout, and then start the DMA again at the desired interval. 371 /// By default, the ADC fills the DMA buffer as quickly as possible. To control the sample rate, call `teardown_adc` after each readout, and then start the DMA again at the desired interval.
372 /// Note that even if using `teardown_adc` to control the sample rate, with each call to `read_exact`, measurements equivalent to half the size of the DMA buffer are still collected. 372 /// Note that even if using `teardown_adc` to control the sample rate, with each call to `read`, measurements equivalent to half the size of the DMA buffer are still collected.
373 /// 373 ///
374 /// Example: 374 /// Example:
375 /// ```rust,ignore 375 /// ```rust,ignore
@@ -383,7 +383,7 @@ impl<'d, T: Instance> RingBufferedAdc<'d, T> {
383 /// 383 ///
384 /// let mut measurements = [0u16; DMA_BUF_LEN / 2]; 384 /// let mut measurements = [0u16; DMA_BUF_LEN / 2];
385 /// loop { 385 /// loop {
386 /// match adc.read_exact(&mut measurements).await { 386 /// match adc.read(&mut measurements).await {
387 /// Ok(_) => { 387 /// Ok(_) => {
388 /// defmt::info!("adc1: {}", measurements); 388 /// defmt::info!("adc1: {}", measurements);
389 /// // Only needed to manually control sample rate. 389 /// // Only needed to manually control sample rate.
@@ -391,7 +391,7 @@ impl<'d, T: Instance> RingBufferedAdc<'d, T> {
391 /// } 391 /// }
392 /// Err(e) => { 392 /// Err(e) => {
393 /// defmt::warn!("Error: {:?}", e); 393 /// defmt::warn!("Error: {:?}", e);
394 /// // DMA overrun, next call to `read_exact` restart ADC. 394 /// // DMA overrun, next call to `read` restarts ADC.
395 /// } 395 /// }
396 /// } 396 /// }
397 /// 397 ///
@@ -404,7 +404,7 @@ impl<'d, T: Instance> RingBufferedAdc<'d, T> {
404 /// [`set_sample_sequence`]: #method.set_sample_sequence 404 /// [`set_sample_sequence`]: #method.set_sample_sequence
405 /// [`teardown_adc`]: #method.teardown_adc 405 /// [`teardown_adc`]: #method.teardown_adc
406 /// [`start`]: #method.start 406 /// [`start`]: #method.start
407 pub async fn read_exact<const N: usize>(&mut self, measurements: &mut [u16; N]) -> Result<usize, OverrunError> { 407 pub async fn read<const N: usize>(&mut self, measurements: &mut [u16; N]) -> Result<usize, OverrunError> {
408 assert_eq!( 408 assert_eq!(
409 self.ring_buf.capacity() / 2, 409 self.ring_buf.capacity() / 2,
410 N, 410 N,
diff --git a/embassy-stm32/src/adc/v2.rs b/embassy-stm32/src/adc/v2.rs
index ddeb7ea79..842a5ee6d 100644
--- a/embassy-stm32/src/adc/v2.rs
+++ b/embassy-stm32/src/adc/v2.rs
@@ -178,7 +178,7 @@ where
178 T::regs().dr().read().0 as u16 178 T::regs().dr().read().0 as u16
179 } 179 }
180 180
181 pub fn read(&mut self, channel: &mut impl AdcChannel<T>) -> u16 { 181 pub fn blocking_read(&mut self, channel: &mut impl AdcChannel<T>) -> u16 {
182 channel.setup(); 182 channel.setup();
183 183
184 // Configure ADC 184 // Configure ADC
diff --git a/embassy-stm32/src/adc/v3.rs b/embassy-stm32/src/adc/v3.rs
index c876bffea..9441e42ff 100644
--- a/embassy-stm32/src/adc/v3.rs
+++ b/embassy-stm32/src/adc/v3.rs
@@ -254,12 +254,36 @@ impl<'d, T: Instance> Adc<'d, T> {
254 } 254 }
255 255
256 /// Read an ADC channel. 256 /// Read an ADC channel.
257 pub fn read(&mut self, channel: &mut impl AdcChannel<T>) -> u16 { 257 pub fn blocking_read(&mut self, channel: &mut impl AdcChannel<T>) -> u16 {
258 self.read_channel(channel) 258 self.read_channel(channel)
259 } 259 }
260 260
261 /// Asynchronously read from sequence of ADC channels. 261 /// Read one or multiple ADC channels using DMA.
262 pub async fn read_async( 262 ///
263 /// `sequence` iterator and `readings` must have the same length.
264 ///
265 /// Example
266 /// ```rust,ignore
267 /// use embassy_stm32::adc::{Adc, AdcChannel}
268 ///
269 /// let mut adc = Adc::new(p.ADC1);
270 /// let mut adc_pin0 = p.PA0.degrade_adc();
271 /// let mut adc_pin1 = p.PA1.degrade_adc();
272 /// let mut measurements = [0u16; 2];
273 ///
274 /// adc.read_async(
275 /// p.DMA1_CH2,
276 /// [
277 /// (&mut *adc_pin0, SampleTime::CYCLES160_5),
278 /// (&mut *adc_pin1, SampleTime::CYCLES160_5),
279 /// ]
280 /// .into_iter(),
281 /// &mut measurements,
282 /// )
283 /// .await;
284 /// defmt::info!("measurements: {}", measurements);
285 /// ```
286 pub async fn read(
263 &mut self, 287 &mut self,
264 rx_dma: &mut impl RxDma<T>, 288 rx_dma: &mut impl RxDma<T>,
265 sequence: impl ExactSizeIterator<Item = (&mut AnyAdcChannel<T>, SampleTime)>, 289 sequence: impl ExactSizeIterator<Item = (&mut AnyAdcChannel<T>, SampleTime)>,
diff --git a/embassy-stm32/src/adc/v4.rs b/embassy-stm32/src/adc/v4.rs
index 7db6fa4a2..63b5b58ea 100644
--- a/embassy-stm32/src/adc/v4.rs
+++ b/embassy-stm32/src/adc/v4.rs
@@ -318,12 +318,36 @@ impl<'d, T: Instance> Adc<'d, T> {
318 } 318 }
319 319
320 /// Read an ADC channel. 320 /// Read an ADC channel.
321 pub fn read(&mut self, channel: &mut impl AdcChannel<T>) -> u16 { 321 pub fn blocking_read(&mut self, channel: &mut impl AdcChannel<T>) -> u16 {
322 self.read_channel(channel) 322 self.read_channel(channel)
323 } 323 }
324 324
325 /// Asynchronously read from sequence of ADC channels. 325 /// Read one or multiple ADC channels using DMA.
326 pub async fn read_async( 326 ///
327 /// `sequence` iterator and `readings` must have the same length.
328 ///
329 /// Example
330 /// ```rust,ignore
331 /// use embassy_stm32::adc::{Adc, AdcChannel}
332 ///
333 /// let mut adc = Adc::new(p.ADC1);
334 /// let mut adc_pin0 = p.PA0.degrade_adc();
335 /// let mut adc_pin2 = p.PA2.degrade_adc();
336 /// let mut measurements = [0u16; 2];
337 ///
338 /// adc.read_async(
339 /// p.DMA2_CH0,
340 /// [
341 /// (&mut *adc_pin0, SampleTime::CYCLES112),
342 /// (&mut *adc_pin2, SampleTime::CYCLES112),
343 /// ]
344 /// .into_iter(),
345 /// &mut measurements,
346 /// )
347 /// .await;
348 /// defmt::info!("measurements: {}", measurements);
349 /// ```
350 pub async fn read(
327 &mut self, 351 &mut self,
328 rx_dma: &mut impl RxDma<T>, 352 rx_dma: &mut impl RxDma<T>,
329 sequence: impl ExactSizeIterator<Item = (&mut AnyAdcChannel<T>, SampleTime)>, 353 sequence: impl ExactSizeIterator<Item = (&mut AnyAdcChannel<T>, SampleTime)>,
diff --git a/examples/stm32f4/src/bin/adc.rs b/examples/stm32f4/src/bin/adc.rs
index 9473b7b7f..423d29225 100644
--- a/examples/stm32f4/src/bin/adc.rs
+++ b/examples/stm32f4/src/bin/adc.rs
@@ -23,7 +23,7 @@ async fn main(_spawner: Spawner) {
23 // Startup delay can be combined to the maximum of either 23 // Startup delay can be combined to the maximum of either
24 delay.delay_us(Temperature::start_time_us().max(VrefInt::start_time_us())); 24 delay.delay_us(Temperature::start_time_us().max(VrefInt::start_time_us()));
25 25
26 let vrefint_sample = adc.read(&mut vrefint); 26 let vrefint_sample = adc.blocking_read(&mut vrefint);
27 27
28 let convert_to_millivolts = |sample| { 28 let convert_to_millivolts = |sample| {
29 // From http://www.st.com/resource/en/datasheet/DM00071990.pdf 29 // From http://www.st.com/resource/en/datasheet/DM00071990.pdf
@@ -50,16 +50,16 @@ async fn main(_spawner: Spawner) {
50 50
51 loop { 51 loop {
52 // Read pin 52 // Read pin
53 let v = adc.read(&mut pin); 53 let v = adc.blocking_read(&mut pin);
54 info!("PC1: {} ({} mV)", v, convert_to_millivolts(v)); 54 info!("PC1: {} ({} mV)", v, convert_to_millivolts(v));
55 55
56 // Read internal temperature 56 // Read internal temperature
57 let v = adc.read(&mut temp); 57 let v = adc.blocking_read(&mut temp);
58 let celcius = convert_to_celcius(v); 58 let celcius = convert_to_celcius(v);
59 info!("Internal temp: {} ({} C)", v, celcius); 59 info!("Internal temp: {} ({} C)", v, celcius);
60 60
61 // Read internal voltage reference 61 // Read internal voltage reference
62 let v = adc.read(&mut vrefint); 62 let v = adc.blocking_read(&mut vrefint);
63 info!("VrefInt: {}", v); 63 info!("VrefInt: {}", v);
64 64
65 Timer::after_millis(100).await; 65 Timer::after_millis(100).await;
diff --git a/examples/stm32f4/src/bin/adc_dma.rs b/examples/stm32f4/src/bin/adc_dma.rs
index 992bed573..43a761e6d 100644
--- a/examples/stm32f4/src/bin/adc_dma.rs
+++ b/examples/stm32f4/src/bin/adc_dma.rs
@@ -44,7 +44,7 @@ async fn adc_task(mut p: Peripherals) {
44 let _ = adc.start(); 44 let _ = adc.start();
45 let _ = adc2.start(); 45 let _ = adc2.start();
46 loop { 46 loop {
47 match adc.read_exact(&mut buffer1).await { 47 match adc.read(&mut buffer1).await {
48 Ok(_data) => { 48 Ok(_data) => {
49 let toc = Instant::now(); 49 let toc = Instant::now();
50 info!( 50 info!(
@@ -62,7 +62,7 @@ async fn adc_task(mut p: Peripherals) {
62 } 62 }
63 } 63 }
64 64
65 match adc2.read_exact(&mut buffer2).await { 65 match adc2.read(&mut buffer2).await {
66 Ok(_data) => { 66 Ok(_data) => {
67 let toc = Instant::now(); 67 let toc = Instant::now();
68 info!( 68 info!(
diff --git a/examples/stm32f7/src/bin/adc.rs b/examples/stm32f7/src/bin/adc.rs
index 641157960..6689e3b5d 100644
--- a/examples/stm32f7/src/bin/adc.rs
+++ b/examples/stm32f7/src/bin/adc.rs
@@ -16,7 +16,7 @@ async fn main(_spawner: Spawner) {
16 let mut pin = p.PA3; 16 let mut pin = p.PA3;
17 17
18 let mut vrefint = adc.enable_vrefint(); 18 let mut vrefint = adc.enable_vrefint();
19 let vrefint_sample = adc.read(&mut vrefint); 19 let vrefint_sample = adc.blocking_read(&mut vrefint);
20 let convert_to_millivolts = |sample| { 20 let convert_to_millivolts = |sample| {
21 // From http://www.st.com/resource/en/datasheet/DM00273119.pdf 21 // From http://www.st.com/resource/en/datasheet/DM00273119.pdf
22 // 6.3.27 Reference voltage 22 // 6.3.27 Reference voltage
@@ -26,7 +26,7 @@ async fn main(_spawner: Spawner) {
26 }; 26 };
27 27
28 loop { 28 loop {
29 let v = adc.read(&mut pin); 29 let v = adc.blocking_read(&mut pin);
30 info!("--> {} - {} mV", v, convert_to_millivolts(v)); 30 info!("--> {} - {} mV", v, convert_to_millivolts(v));
31 Timer::after_millis(100).await; 31 Timer::after_millis(100).await;
32 } 32 }
diff --git a/examples/stm32g0/src/bin/adc.rs b/examples/stm32g0/src/bin/adc.rs
index a35119e3d..6c7f3b48a 100644
--- a/examples/stm32g0/src/bin/adc.rs
+++ b/examples/stm32g0/src/bin/adc.rs
@@ -17,7 +17,7 @@ async fn main(_spawner: Spawner) {
17 let mut pin = p.PA1; 17 let mut pin = p.PA1;
18 18
19 let mut vrefint = adc.enable_vrefint(); 19 let mut vrefint = adc.enable_vrefint();
20 let vrefint_sample = adc.read(&mut vrefint); 20 let vrefint_sample = adc.blocking_read(&mut vrefint);
21 let convert_to_millivolts = |sample| { 21 let convert_to_millivolts = |sample| {
22 // From https://www.st.com/resource/en/datasheet/stm32g031g8.pdf 22 // From https://www.st.com/resource/en/datasheet/stm32g031g8.pdf
23 // 6.3.3 Embedded internal reference voltage 23 // 6.3.3 Embedded internal reference voltage
@@ -27,7 +27,7 @@ async fn main(_spawner: Spawner) {
27 }; 27 };
28 28
29 loop { 29 loop {
30 let v = adc.read(&mut pin); 30 let v = adc.blocking_read(&mut pin);
31 info!("--> {} - {} mV", v, convert_to_millivolts(v)); 31 info!("--> {} - {} mV", v, convert_to_millivolts(v));
32 Timer::after_millis(100).await; 32 Timer::after_millis(100).await;
33 } 33 }
diff --git a/examples/stm32g0/src/bin/adc_dma.rs b/examples/stm32g0/src/bin/adc_dma.rs
index 42d1e729b..3713e5a21 100644
--- a/examples/stm32g0/src/bin/adc_dma.rs
+++ b/examples/stm32g0/src/bin/adc_dma.rs
@@ -24,7 +24,7 @@ async fn main(_spawner: Spawner) {
24 let mut pa0 = p.PA0.degrade_adc(); 24 let mut pa0 = p.PA0.degrade_adc();
25 25
26 loop { 26 loop {
27 adc.read_async( 27 adc.read(
28 &mut dma, 28 &mut dma,
29 [ 29 [
30 (&mut vrefint_channel, SampleTime::CYCLES160_5), 30 (&mut vrefint_channel, SampleTime::CYCLES160_5),
diff --git a/examples/stm32g0/src/bin/adc_oversampling.rs b/examples/stm32g0/src/bin/adc_oversampling.rs
index 3c31eb206..9c5dd872a 100644
--- a/examples/stm32g0/src/bin/adc_oversampling.rs
+++ b/examples/stm32g0/src/bin/adc_oversampling.rs
@@ -36,7 +36,7 @@ async fn main(_spawner: Spawner) {
36 adc.oversampling_enable(true); 36 adc.oversampling_enable(true);
37 37
38 loop { 38 loop {
39 let v = adc.read(&mut pin); 39 let v = adc.blocking_read(&mut pin);
40 info!("--> {} ", v); //max 65520 = 0xFFF0 40 info!("--> {} ", v); //max 65520 = 0xFFF0
41 Timer::after_millis(100).await; 41 Timer::after_millis(100).await;
42 } 42 }
diff --git a/examples/stm32g4/src/bin/adc.rs b/examples/stm32g4/src/bin/adc.rs
index 3de38cbd6..adca846d8 100644
--- a/examples/stm32g4/src/bin/adc.rs
+++ b/examples/stm32g4/src/bin/adc.rs
@@ -32,7 +32,7 @@ async fn main(_spawner: Spawner) {
32 adc.set_sample_time(SampleTime::CYCLES24_5); 32 adc.set_sample_time(SampleTime::CYCLES24_5);
33 33
34 loop { 34 loop {
35 let measured = adc.read(&mut p.PA7); 35 let measured = adc.blocking_read(&mut p.PA7);
36 info!("measured: {}", measured); 36 info!("measured: {}", measured);
37 Timer::after_millis(500).await; 37 Timer::after_millis(500).await;
38 } 38 }
diff --git a/examples/stm32h7/src/bin/adc.rs b/examples/stm32h7/src/bin/adc.rs
index e9a857a74..98504ddf6 100644
--- a/examples/stm32h7/src/bin/adc.rs
+++ b/examples/stm32h7/src/bin/adc.rs
@@ -51,9 +51,9 @@ async fn main(_spawner: Spawner) {
51 let mut vrefint_channel = adc.enable_vrefint(); 51 let mut vrefint_channel = adc.enable_vrefint();
52 52
53 loop { 53 loop {
54 let vrefint = adc.read(&mut vrefint_channel); 54 let vrefint = adc.blocking_read(&mut vrefint_channel);
55 info!("vrefint: {}", vrefint); 55 info!("vrefint: {}", vrefint);
56 let measured = adc.read(&mut p.PC0); 56 let measured = adc.blocking_read(&mut p.PC0);
57 info!("measured: {}", measured); 57 info!("measured: {}", measured);
58 Timer::after_millis(500).await; 58 Timer::after_millis(500).await;
59 } 59 }
diff --git a/examples/stm32h7/src/bin/adc_dma.rs b/examples/stm32h7/src/bin/adc_dma.rs
index 6c0240453..0b905d227 100644
--- a/examples/stm32h7/src/bin/adc_dma.rs
+++ b/examples/stm32h7/src/bin/adc_dma.rs
@@ -56,7 +56,7 @@ async fn main(_spawner: Spawner) {
56 let mut pc0 = p.PC0.degrade_adc(); 56 let mut pc0 = p.PC0.degrade_adc();
57 57
58 loop { 58 loop {
59 adc.read_async( 59 adc.read(
60 &mut dma, 60 &mut dma,
61 [ 61 [
62 (&mut vrefint_channel, SampleTime::CYCLES387_5), 62 (&mut vrefint_channel, SampleTime::CYCLES387_5),
diff --git a/examples/stm32l4/src/bin/adc.rs b/examples/stm32l4/src/bin/adc.rs
index 7a89334e0..c557ac6d7 100644
--- a/examples/stm32l4/src/bin/adc.rs
+++ b/examples/stm32l4/src/bin/adc.rs
@@ -23,7 +23,7 @@ fn main() -> ! {
23 let mut channel = p.PC0; 23 let mut channel = p.PC0;
24 24
25 loop { 25 loop {
26 let v = adc.read(&mut channel); 26 let v = adc.blocking_read(&mut channel);
27 info!("--> {}", v); 27 info!("--> {}", v);
28 } 28 }
29} 29}
diff --git a/examples/stm32u0/src/bin/adc.rs b/examples/stm32u0/src/bin/adc.rs
index 4410448f1..c8252e4e1 100644
--- a/examples/stm32u0/src/bin/adc.rs
+++ b/examples/stm32u0/src/bin/adc.rs
@@ -23,7 +23,7 @@ fn main() -> ! {
23 let mut channel = p.PC0; 23 let mut channel = p.PC0;
24 24
25 loop { 25 loop {
26 let v = adc.read(&mut channel); 26 let v = adc.blocking_read(&mut channel);
27 info!("--> {}", v); 27 info!("--> {}", v);
28 embassy_time::block_for(Duration::from_millis(200)); 28 embassy_time::block_for(Duration::from_millis(200));
29 } 29 }
diff --git a/tests/stm32/src/bin/dac.rs b/tests/stm32/src/bin/dac.rs
index 06501ab14..86a68c530 100644
--- a/tests/stm32/src/bin/dac.rs
+++ b/tests/stm32/src/bin/dac.rs
@@ -38,7 +38,7 @@ async fn main(_spawner: Spawner) {
38 dac.set(Value::Bit8(0)); 38 dac.set(Value::Bit8(0));
39 // Now wait a little to obtain a stable value 39 // Now wait a little to obtain a stable value
40 Timer::after_millis(30).await; 40 Timer::after_millis(30).await;
41 let offset = adc.read(&mut adc_pin); 41 let offset = adc.blocking_read(&mut adc_pin);
42 42
43 for v in 0..=255 { 43 for v in 0..=255 {
44 // First set the DAC output value 44 // First set the DAC output value
@@ -49,7 +49,7 @@ async fn main(_spawner: Spawner) {
49 Timer::after_millis(30).await; 49 Timer::after_millis(30).await;
50 50
51 // Need to steal the peripherals here because PA4 is obviously in use already 51 // Need to steal the peripherals here because PA4 is obviously in use already
52 let measured = adc.read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4); 52 let measured = adc.blocking_read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4);
53 // Calibrate and normalize the measurement to get close to the dac_output_val 53 // Calibrate and normalize the measurement to get close to the dac_output_val
54 let measured_normalized = ((measured as i32 - offset as i32) / normalization_factor) as i16; 54 let measured_normalized = ((measured as i32 - offset as i32) / normalization_factor) as i16;
55 55