diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-07-24 22:05:01 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-24 22:05:01 +0000 |
| commit | bb68f5593112376fa779d7f4a2d8bc2a3f12f0dc (patch) | |
| tree | 4060fdf10f24add81eaf216d5b60b76bda172025 /embassy-stm32 | |
| parent | 5b8340bdc43fdcce04429930dea4c21c4b1922c8 (diff) | |
| parent | cb1bccfd5cf528497e3be8e0da9928854ed8e081 (diff) | |
Merge pull request #4183 from IvanLi-CN/feat/stm32-dac-new-unbuffered
feat(stm32): Add DAC::new_unbuffered method.
Diffstat (limited to 'embassy-stm32')
| -rw-r--r-- | embassy-stm32/src/dac/mod.rs | 40 |
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 |
