From 14436ce1300a5d621b617d56ee037e09ce55ea0a Mon Sep 17 00:00:00 2001 From: xoviat Date: Fri, 21 Nov 2025 08:22:31 -0600 Subject: adc: add test for wba --- tests/stm32/src/bin/adc.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/stm32/src/bin/adc.rs (limited to 'tests/stm32/src/bin') diff --git a/tests/stm32/src/bin/adc.rs b/tests/stm32/src/bin/adc.rs new file mode 100644 index 000000000..6cedc6498 --- /dev/null +++ b/tests/stm32/src/bin/adc.rs @@ -0,0 +1,39 @@ +#![no_std] +#![no_main] + +// required-features: dac + +#[path = "../common.rs"] +mod common; + +use common::*; +use embassy_executor::Spawner; +use embassy_stm32::adc::{Adc, SampleTime}; +use embassy_time::Timer; +use {defmt_rtt as _, panic_probe as _}; + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + // Initialize the board and obtain a Peripherals instance + let p: embassy_stm32::Peripherals = init(); + + let adc = peri!(p, ADC); + let mut adc_pin = peri!(p, DAC_PIN); + + let mut adc = Adc::new_adc4(adc); + + // Now wait a little to obtain a stable value + Timer::after_millis(30).await; + let _ = adc.blocking_read(&mut adc_pin, SampleTime::from_bits(0)); + + for _ in 0..=255 { + // Now wait a little to obtain a stable value + Timer::after_millis(30).await; + + // Need to steal the peripherals here because PA4 is obviously in use already + let _ = adc.blocking_read(&mut adc_pin, SampleTime::from_bits(0)); + } + + info!("Test OK"); + cortex_m::asm::bkpt(); +} -- cgit