Merge pull request #1676 from adamgreig/fix-dac-example
stm32: Fix DAC examples
This commit is contained in:
commit
7fc138c91e
@ -216,8 +216,9 @@ impl<'d, T: Instance, Tx> DacCh1<'d, T, Tx> {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
peri: impl Peripheral<P = T> + 'd,
|
peri: impl Peripheral<P = T> + 'd,
|
||||||
dma: impl Peripheral<P = Tx> + 'd,
|
dma: impl Peripheral<P = Tx> + 'd,
|
||||||
_pin: impl Peripheral<P = impl DacPin<T, 1>> + 'd,
|
pin: impl Peripheral<P = impl DacPin<T, 1>> + crate::gpio::sealed::Pin + 'd,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
pin.set_as_analog();
|
||||||
into_ref!(peri, dma);
|
into_ref!(peri, dma);
|
||||||
T::enable();
|
T::enable();
|
||||||
T::reset();
|
T::reset();
|
||||||
@ -327,8 +328,9 @@ impl<'d, T: Instance, Tx> DacCh2<'d, T, Tx> {
|
|||||||
pub fn new(
|
pub fn new(
|
||||||
_peri: impl Peripheral<P = T> + 'd,
|
_peri: impl Peripheral<P = T> + 'd,
|
||||||
dma: impl Peripheral<P = Tx> + 'd,
|
dma: impl Peripheral<P = Tx> + 'd,
|
||||||
_pin: impl Peripheral<P = impl DacPin<T, 2>> + 'd,
|
pin: impl Peripheral<P = impl DacPin<T, 2>> + crate::gpio::sealed::Pin + 'd,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
pin.set_as_analog();
|
||||||
into_ref!(_peri, dma);
|
into_ref!(_peri, dma);
|
||||||
T::enable();
|
T::enable();
|
||||||
T::reset();
|
T::reset();
|
||||||
@ -442,9 +444,11 @@ impl<'d, T: Instance, TxCh1, TxCh2> Dac<'d, T, TxCh1, TxCh2> {
|
|||||||
peri: impl Peripheral<P = T> + 'd,
|
peri: impl Peripheral<P = T> + 'd,
|
||||||
dma_ch1: impl Peripheral<P = TxCh1> + 'd,
|
dma_ch1: impl Peripheral<P = TxCh1> + 'd,
|
||||||
dma_ch2: impl Peripheral<P = TxCh2> + 'd,
|
dma_ch2: impl Peripheral<P = TxCh2> + 'd,
|
||||||
_pin_ch1: impl Peripheral<P = impl DacPin<T, 1>> + 'd,
|
pin_ch1: impl Peripheral<P = impl DacPin<T, 1>> + crate::gpio::sealed::Pin + 'd,
|
||||||
_pin_ch2: impl Peripheral<P = impl DacPin<T, 2>> + 'd,
|
pin_ch2: impl Peripheral<P = impl DacPin<T, 2>> + crate::gpio::sealed::Pin + 'd,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
pin_ch1.set_as_analog();
|
||||||
|
pin_ch2.set_as_analog();
|
||||||
into_ref!(peri, dma_ch1, dma_ch2);
|
into_ref!(peri, dma_ch1, dma_ch2);
|
||||||
T::enable();
|
T::enable();
|
||||||
T::reset();
|
T::reset();
|
||||||
|
@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
|
|||||||
# Change stm32f429zi to your chip name, if necessary.
|
# Change stm32f429zi to your chip name, if necessary.
|
||||||
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc", "chrono"] }
|
embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "unstable-traits", "defmt", "stm32f429zi", "unstable-pac", "memory-x", "time-driver-any", "exti", "embedded-sdmmc", "chrono"] }
|
||||||
embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] }
|
embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] }
|
||||||
embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers", "arch-cortex-m", "executor-thread", "executor-interrupt"] }
|
embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
|
||||||
embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] }
|
embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "unstable-traits", "tick-hz-32_768"] }
|
||||||
embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
|
embassy-usb = { version = "0.1.0", path = "../../embassy-usb", features = ["defmt"] }
|
||||||
embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] }
|
embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] }
|
||||||
|
@ -14,11 +14,11 @@ async fn main(_spawner: Spawner) -> ! {
|
|||||||
info!("Hello World, dude!");
|
info!("Hello World, dude!");
|
||||||
|
|
||||||
let mut dac = DacCh1::new(p.DAC, NoDma, p.PA4);
|
let mut dac = DacCh1::new(p.DAC, NoDma, p.PA4);
|
||||||
|
unwrap!(dac.set_trigger_enable(false));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
for v in 0..=255 {
|
for v in 0..=255 {
|
||||||
unwrap!(dac.set(Value::Bit8(to_sine_wave(v))));
|
unwrap!(dac.set(Value::Bit8(to_sine_wave(v))));
|
||||||
dac.trigger();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,11 @@ fn main() -> ! {
|
|||||||
let p = embassy_stm32::init(config);
|
let p = embassy_stm32::init(config);
|
||||||
|
|
||||||
let mut dac = DacCh1::new(p.DAC1, NoDma, p.PA4);
|
let mut dac = DacCh1::new(p.DAC1, NoDma, p.PA4);
|
||||||
|
unwrap!(dac.set_trigger_enable(false));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
for v in 0..=255 {
|
for v in 0..=255 {
|
||||||
unwrap!(dac.set(Value::Bit8(to_sine_wave(v))));
|
unwrap!(dac.set(Value::Bit8(to_sine_wave(v))));
|
||||||
dac.trigger();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,11 +13,11 @@ fn main() -> ! {
|
|||||||
info!("Hello World!");
|
info!("Hello World!");
|
||||||
|
|
||||||
let mut dac = DacCh1::new(p.DAC1, NoDma, p.PA4);
|
let mut dac = DacCh1::new(p.DAC1, NoDma, p.PA4);
|
||||||
|
unwrap!(dac.set_trigger_enable(false));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
for v in 0..=255 {
|
for v in 0..=255 {
|
||||||
unwrap!(dac.set(Value::Bit8(to_sine_wave(v))));
|
unwrap!(dac.set(Value::Bit8(to_sine_wave(v))));
|
||||||
dac.trigger();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user