diff options
| author | Andres Vahter <[email protected]> | 2024-07-03 14:39:10 +0300 |
|---|---|---|
| committer | Andres Vahter <[email protected]> | 2024-07-03 15:20:31 +0300 |
| commit | f851081e09982a3edefd23082bb23143a0172464 (patch) | |
| tree | de03c185f2aa3317cd413bab7fc9efde4581f480 /tests/stm32 | |
| parent | 914d7c7919a8eac88f474d658a8078272318731b (diff) | |
stm32 adc: introduce blocking_read
Diffstat (limited to 'tests/stm32')
| -rw-r--r-- | tests/stm32/src/bin/dac.rs | 4 |
1 files changed, 2 insertions, 2 deletions
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 | ||
