From dcfd2de5c2319f026e53c0a63495823a5bb11706 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 2 May 2018 12:07:10 +1000 Subject: [PATCH] stm32/dac: Make deinit disable the output buffer on H7 and L4 MCUs. --- ports/stm32/dac.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ports/stm32/dac.c b/ports/stm32/dac.c index 1b68386412..7a72a2106b 100644 --- a/ports/stm32/dac.c +++ b/ports/stm32/dac.c @@ -279,12 +279,16 @@ STATIC mp_obj_t pyb_dac_deinit(mp_obj_t self_in) { pyb_dac_obj_t *self = self_in; if (self->dac_channel == DAC_CHANNEL_1) { DAC_Handle.Instance->CR &= ~DAC_CR_EN1; - #ifndef STM32H7 + #if defined(STM32H7) || defined(STM32L4) + DAC->MCR = (DAC->MCR & ~(7 << DAC_MCR_MODE1_Pos)) | 2 << DAC_MCR_MODE1_Pos; + #else DAC_Handle.Instance->CR |= DAC_CR_BOFF1; #endif } else { DAC_Handle.Instance->CR &= ~DAC_CR_EN2; - #ifndef STM32H7 + #if defined(STM32H7) || defined(STM32L4) + DAC->MCR = (DAC->MCR & ~(7 << DAC_MCR_MODE2_Pos)) | 2 << DAC_MCR_MODE2_Pos; + #else DAC_Handle.Instance->CR |= DAC_CR_BOFF2; #endif }