aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAdam Greig <[email protected]>2023-11-21 03:12:36 +0000
committerDario Nieuwenhuis <[email protected]>2023-11-25 00:29:45 +0100
commit09d7950313427d25be255e4a46a29b6c21113826 (patch)
tree0273ab82171fff5cb0225ee2dfff7b50cbf12a2f /tests
parent267cbaebe6a4a7160c3bc9239fcbd3dfa4a0d9a9 (diff)
STM32 DAC: Rework DAC driver, support all families.
Diffstat (limited to 'tests')
-rw-r--r--tests/stm32/src/bin/dac.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/tests/stm32/src/bin/dac.rs b/tests/stm32/src/bin/dac.rs
index 10e3c3e81..824eb8803 100644
--- a/tests/stm32/src/bin/dac.rs
+++ b/tests/stm32/src/bin/dac.rs
@@ -10,7 +10,7 @@ use common::*;
10use defmt::assert; 10use defmt::assert;
11use embassy_executor::Spawner; 11use embassy_executor::Spawner;
12use embassy_stm32::adc::Adc; 12use embassy_stm32::adc::Adc;
13use embassy_stm32::dac::{DacCh1, DacChannel, Value}; 13use embassy_stm32::dac::{DacCh1, Value};
14use embassy_stm32::dma::NoDma; 14use embassy_stm32::dma::NoDma;
15use embassy_time::{Delay, Timer}; 15use embassy_time::{Delay, Timer};
16use {defmt_rtt as _, panic_probe as _}; 16use {defmt_rtt as _, panic_probe as _};
@@ -26,9 +26,7 @@ async fn main(_spawner: Spawner) {
26 #[cfg(any(feature = "stm32h755zi", feature = "stm32g071rb"))] 26 #[cfg(any(feature = "stm32h755zi", feature = "stm32g071rb"))]
27 let dac_peripheral = p.DAC1; 27 let dac_peripheral = p.DAC1;
28 28
29 let mut dac: DacCh1<'_, _, NoDma> = DacCh1::new(dac_peripheral, NoDma, p.PA4); 29 let mut dac = DacCh1::new(dac_peripheral, NoDma, p.PA4);
30 unwrap!(dac.set_trigger_enable(false));
31
32 let mut adc = Adc::new(p.ADC1, &mut Delay); 30 let mut adc = Adc::new(p.ADC1, &mut Delay);
33 31
34 #[cfg(feature = "stm32h755zi")] 32 #[cfg(feature = "stm32h755zi")]
@@ -36,7 +34,7 @@ async fn main(_spawner: Spawner) {
36 #[cfg(any(feature = "stm32f429zi", feature = "stm32g071rb"))] 34 #[cfg(any(feature = "stm32f429zi", feature = "stm32g071rb"))]
37 let normalization_factor: i32 = 16; 35 let normalization_factor: i32 = 16;
38 36
39 unwrap!(dac.set(Value::Bit8(0))); 37 dac.set(Value::Bit8(0));
40 // Now wait a little to obtain a stable value 38 // Now wait a little to obtain a stable value
41 Timer::after_millis(30).await; 39 Timer::after_millis(30).await;
42 let offset = adc.read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4); 40 let offset = adc.read(&mut unsafe { embassy_stm32::Peripherals::steal() }.PA4);
@@ -44,7 +42,7 @@ async fn main(_spawner: Spawner) {
44 for v in 0..=255 { 42 for v in 0..=255 {
45 // First set the DAC output value 43 // First set the DAC output value
46 let dac_output_val = to_sine_wave(v); 44 let dac_output_val = to_sine_wave(v);
47 unwrap!(dac.set(Value::Bit8(dac_output_val))); 45 dac.set(Value::Bit8(dac_output_val));
48 46
49 // Now wait a little to obtain a stable value 47 // Now wait a little to obtain a stable value
50 Timer::after_millis(30).await; 48 Timer::after_millis(30).await;