stm32/dac: Make deinit disable the output buffer on H7 and L4 MCUs.

This commit is contained in:
Damien George 2018-05-02 12:07:10 +10:00
parent d4f8414ebd
commit dcfd2de5c2
1 changed files with 6 additions and 2 deletions

View File

@ -279,12 +279,16 @@ STATIC mp_obj_t pyb_dac_deinit(mp_obj_t self_in) {
pyb_dac_obj_t *self = self_in; pyb_dac_obj_t *self = self_in;
if (self->dac_channel == DAC_CHANNEL_1) { if (self->dac_channel == DAC_CHANNEL_1) {
DAC_Handle.Instance->CR &= ~DAC_CR_EN1; 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; DAC_Handle.Instance->CR |= DAC_CR_BOFF1;
#endif #endif
} else { } else {
DAC_Handle.Instance->CR &= ~DAC_CR_EN2; 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; DAC_Handle.Instance->CR |= DAC_CR_BOFF2;
#endif #endif
} }