embassy_stm32_plus/builder/dac/
ch1.rs

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