stm32 adc: introduce blocking_read

This commit is contained in:
Andres Vahter
2024-07-03 14:39:10 +03:00
parent 914d7c7919
commit f851081e09
17 changed files with 86 additions and 38 deletions

View File

@@ -38,7 +38,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);
let offset = adc.blocking_read(&mut adc_pin);
for v in 0..=255 {
// First set the DAC output value
@@ -49,7 +49,7 @@ 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);
let measured = adc.blocking_read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4);
// 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;