embassy_stm32_plus/builder/dac/
ch2.rs

1use embassy_stm32::dac::DacCh2;
2use embassy_stm32::dma::NoDma;
3use embassy_stm32::Peripheral;
4use embassy_stm32::peripherals::{DAC1, PA5};
5
6/// dac ch2 builder
7pub struct DacCh2Builder {
8    /// dac device
9    pub dac: DAC1,
10    /// dac ch2 pin
11    pub ch2_pin: PA5,
12}
13
14/// custom method
15impl DacCh2Builder {
16    /// create builder
17    #[inline]
18    pub fn new(dac: DAC1, ch2_pin: PA5) -> Self {
19        Self { dac, ch2_pin }
20    }
21
22    /// Create a new DacChannel instance, more see [DacCh2::new]
23    #[inline]
24    pub fn build<DMA>(self, dma: impl Peripheral<P=DMA> + 'static) -> DacCh2<'static, DAC1, DMA> {
25        DacCh2::new(self.dac, dma, self.ch2_pin)
26    }
27
28    /// using NoDma create a new DacChannel instance, more see [DacCh2::new]
29    #[inline]
30    pub fn build_no_dma(self) -> DacCh2<'static, DAC1> {
31        self.build(NoDma)
32    }
33}