diff options
| author | Ben Gamari <[email protected]> | 2021-09-28 20:56:19 -0400 |
|---|---|---|
| committer | Ben Gamari <[email protected]> | 2021-09-29 00:32:40 -0400 |
| commit | 5a38cc214079aed4c8778bd210c1ece2fe64fdf7 (patch) | |
| tree | ab05bc9386094b2e923a3778d2e8839079745b77 | |
| parent | 0b9961584b366e6d3cc83a218c8150800793cb1d (diff) | |
stm32/dac: Ensure that clock is enabled
| -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 { |
