stm32 adc: introduce blocking_read
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user