From 12b59dc610fb659a4d51ccc364865a7e154379d6 Mon Sep 17 00:00:00 2001 From: xoviat Date: Mon, 10 Nov 2025 09:56:42 -0600 Subject: adc: remove sample_time from struct --- tests/stm32/src/bin/dac.rs | 9 ++++++--- tests/stm32/src/bin/dac_l1.rs | 11 ++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/stm32/src/bin/dac.rs b/tests/stm32/src/bin/dac.rs index d34bbb255..747b11e7f 100644 --- a/tests/stm32/src/bin/dac.rs +++ b/tests/stm32/src/bin/dac.rs @@ -10,7 +10,7 @@ use core::f32::consts::PI; use common::*; use defmt::assert; use embassy_executor::Spawner; -use embassy_stm32::adc::Adc; +use embassy_stm32::adc::{Adc, SampleTime}; use embassy_stm32::dac::{DacCh1, Value}; use embassy_time::Timer; use micromath::F32Ext; @@ -37,7 +37,7 @@ async fn main(_spawner: Spawner) { dac.set(Value::Bit8(0)); // Now wait a little to obtain a stable value Timer::after_millis(30).await; - let offset = adc.blocking_read(&mut adc_pin); + let offset = adc.blocking_read(&mut adc_pin, SampleTime::from_bits(0)); for v in 0..=255 { // First set the DAC output value @@ -48,7 +48,10 @@ async fn main(_spawner: Spawner) { Timer::after_millis(30).await; // Need to steal the peripherals here because PA4 is obviously in use already - let measured = adc.blocking_read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4); + let measured = adc.blocking_read( + &mut unsafe { embassy_stm32::Peripherals::steal() }.PA4, + SampleTime::from_bits(0), + ); // Calibrate and normalize the measurement to get close to the dac_output_val let measured_normalized = ((measured as i32 - offset as i32) / normalization_factor) as i16; diff --git a/tests/stm32/src/bin/dac_l1.rs b/tests/stm32/src/bin/dac_l1.rs index e6400f28e..2fe0cf1f1 100644 --- a/tests/stm32/src/bin/dac_l1.rs +++ b/tests/stm32/src/bin/dac_l1.rs @@ -10,7 +10,7 @@ use core::f32::consts::PI; use common::*; use defmt::assert; use embassy_executor::Spawner; -use embassy_stm32::adc::Adc; +use embassy_stm32::adc::{Adc, SampleTime}; use embassy_stm32::dac::{DacCh1, Value}; use embassy_stm32::{bind_interrupts, peripherals}; use embassy_time::Timer; @@ -47,7 +47,7 @@ async fn main(_spawner: Spawner) { dac.set(Value::Bit8(0)); // Now wait a little to obtain a stable value Timer::after_millis(30).await; - let offset = adc.read(&mut adc_pin).await; + let offset = adc.read(&mut adc_pin, SampleTime::from_bits(0)).await; for v in 0..=255 { // First set the DAC output value @@ -58,7 +58,12 @@ async fn main(_spawner: Spawner) { Timer::after_millis(30).await; // Need to steal the peripherals here because PA4 is obviously in use already - let measured = adc.read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4).await; + let measured = adc + .read( + &mut unsafe { embassy_stm32::Peripherals::steal() }.PA4, + SampleTime::from_bits(0), + ) + .await; // Calibrate and normalize the measurement to get close to the dac_output_val let measured_normalized = ((measured as i32 - offset as i32) / normalization_factor) as i16; -- cgit