diff options
| -rw-r--r-- | embassy-stm32/src/dac/v2.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/embassy-stm32/src/dac/v2.rs b/embassy-stm32/src/dac/v2.rs index f46145b8d..55a881d89 100644 --- a/embassy-stm32/src/dac/v2.rs +++ b/embassy-stm32/src/dac/v2.rs | |||
| @@ -5,6 +5,17 @@ use core::marker::PhantomData; | |||
| 5 | use embassy::util::Unborrow; | 5 | use embassy::util::Unborrow; |
| 6 | use embassy_hal_common::unborrow; | 6 | use embassy_hal_common::unborrow; |
| 7 | 7 | ||
| 8 | /// Sadly we cannot use `RccPeripheral::enable` since devices are quite inconsistent DAC clock | ||
| 9 | /// configuration. | ||
| 10 | unsafe fn enable() { | ||
| 11 | #[cfg(rcc_h7)] | ||
| 12 | crate::pac::RCC.apb1lenr().modify(|w| w.set_dac12en(true)); | ||
| 13 | #[cfg(rcc_g0)] | ||
| 14 | crate::pac::RCC.apbenr1().modify(|w| w.set_dac1en(true)); | ||
| 15 | #[cfg(rcc_l4)] | ||
| 16 | crate::pac::RCC.apb1enr1().modify(|w| w.set_dac1en(true)); | ||
| 17 | } | ||
| 18 | |||
| 8 | #[derive(Debug)] | 19 | #[derive(Debug)] |
| 9 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 20 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 10 | pub enum Error { | 21 | pub enum Error { |
| @@ -91,6 +102,10 @@ impl<'d, T: Instance> Dac<'d, T> { | |||
| 91 | ) -> Self { | 102 | ) -> Self { |
| 92 | unborrow!(ch1, ch2); | 103 | unborrow!(ch1, ch2); |
| 93 | 104 | ||
| 105 | unsafe { | ||
| 106 | enable(); | ||
| 107 | } | ||
| 108 | |||
| 94 | let ch1 = ch1.degrade_optional(); | 109 | let ch1 = ch1.degrade_optional(); |
| 95 | if ch1.is_some() { | 110 | if ch1.is_some() { |
| 96 | unsafe { | 111 | unsafe { |
