aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32
diff options
context:
space:
mode:
authorIvan Li <[email protected]>2025-05-25 21:39:23 +0800
committerIvan Li <[email protected]>2025-05-25 21:39:23 +0800
commitcb1bccfd5cf528497e3be8e0da9928854ed8e081 (patch)
tree5c1b8f07a40cd6e8a9d35e926c004502effb380d /embassy-stm32
parent94f9b2707486ca3eade5bf4b237edf3d6aa90f35 (diff)
feat(stm32): Add DAC::new_unbuffered method.
Signed-off-by: Ivan Li <[email protected]>
Diffstat (limited to 'embassy-stm32')
-rw-r--r--embassy-stm32/src/dac/mod.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/embassy-stm32/src/dac/mod.rs b/embassy-stm32/src/dac/mod.rs
index 30046849b..d8f1f96f2 100644
--- a/embassy-stm32/src/dac/mod.rs
+++ b/embassy-stm32/src/dac/mod.rs
@@ -403,6 +403,46 @@ impl<'d, T: Instance> Dac<'d, T, Async> {
403 Mode::NormalExternalBuffered, 403 Mode::NormalExternalBuffered,
404 ) 404 )
405 } 405 }
406 /// Create a new `Dac` instance with external output pins and unbuffered mode.
407 ///
408 /// This function consumes the underlying DAC peripheral and allows access to both channels.
409 /// The channels are configured for external output with the buffer disabled.
410 ///
411 /// The channels are enabled on creation and begin to drive their output pins.
412 /// Note that some methods, such as `set_trigger()` and `set_mode()`, will
413 /// disable the channel; you must re-enable them with `enable()`.
414 ///
415 /// By default, triggering is disabled, but it can be enabled using the `set_trigger()`
416 /// method on the underlying channels.
417 ///
418 /// # Arguments
419 ///
420 /// * `peri` - The DAC peripheral instance.
421 /// * `dma_ch1` - The DMA channel for DAC channel 1.
422 /// * `dma_ch2` - The DMA channel for DAC channel 2.
423 /// * `pin_ch1` - The GPIO pin for DAC channel 1 output.
424 /// * `pin_ch2` - The GPIO pin for DAC channel 2 output.
425 ///
426 /// # Returns
427 ///
428 /// A new `Dac` instance in unbuffered mode.
429 pub fn new_unbuffered(
430 peri: Peri<'d, T>,
431 dma_ch1: Peri<'d, impl Dma<T, Ch1>>,
432 dma_ch2: Peri<'d, impl Dma<T, Ch2>>,
433 pin_ch1: Peri<'d, impl DacPin<T, Ch1> + crate::gpio::Pin>,
434 pin_ch2: Peri<'d, impl DacPin<T, Ch2> + crate::gpio::Pin>,
435 ) -> Self {
436 pin_ch1.set_as_analog();
437 pin_ch2.set_as_analog();
438 Self::new_inner(
439 peri,
440 new_dma!(dma_ch1),
441 new_dma!(dma_ch2),
442 #[cfg(any(dac_v3, dac_v4, dac_v5, dac_v6, dac_v7))]
443 Mode::NormalExternalUnbuffered,
444 )
445 }
406 446
407 /// Create a new `Dac` instance where the external output pins are not used, 447 /// Create a new `Dac` instance where the external output pins are not used,
408 /// so the DAC can only be used to generate internal signals but the GPIO 448 /// so the DAC can only be used to generate internal signals but the GPIO