From 5400d9bd99c66790b746e9d7fce11a71d6f0bc6e Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Mon, 15 Mar 2021 15:39:24 +0100 Subject: [PATCH 1/2] DAC: STM32F3 dac may have output switch instead of output buffer For STM32F3 serie, depending on instance/channel used, output buffer may be replaced by output switch Both being exclusive, they can be both set in HAL structure. Fixes #1324 Signed-off-by: Alexandre Bourdiol --- libraries/SrcWrapper/src/stm32/analog.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/SrcWrapper/src/stm32/analog.cpp b/libraries/SrcWrapper/src/stm32/analog.cpp index 0871c25d4c..6c32da888f 100644 --- a/libraries/SrcWrapper/src/stm32/analog.cpp +++ b/libraries/SrcWrapper/src/stm32/analog.cpp @@ -404,6 +404,9 @@ void dac_write_value(PinName pin, uint32_t value, uint8_t do_init) dacChannelConf.DAC_Trigger = DAC_TRIGGER_NONE; dacChannelConf.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; +#if defined(DAC_OUTPUTSWITCH_ENABLE) + dacChannelConf.DAC_OutputSwitch = DAC_OUTPUTSWITCH_ENABLE; +#endif /*##-2- Configure DAC channel1 #############################################*/ if (HAL_DAC_ConfigChannel(&DacHandle, &dacChannelConf, dacChannel) != HAL_OK) { /* Channel configuration Error */ From 7ac20ed14a9f773bfe87867231eb216920c33aad Mon Sep 17 00:00:00 2001 From: Alexandre Bourdiol Date: Mon, 15 Mar 2021 16:44:04 +0100 Subject: [PATCH 2/2] DAC: remove HAL_DAC_DeInit to avoid other channel deconfiguration Fixes #1324 Signed-off-by: Alexandre Bourdiol --- libraries/SrcWrapper/src/stm32/analog.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/libraries/SrcWrapper/src/stm32/analog.cpp b/libraries/SrcWrapper/src/stm32/analog.cpp index 6c32da888f..085abd62b1 100644 --- a/libraries/SrcWrapper/src/stm32/analog.cpp +++ b/libraries/SrcWrapper/src/stm32/analog.cpp @@ -389,12 +389,6 @@ void dac_write_value(PinName pin, uint32_t value, uint8_t do_init) return; } if (do_init == 1) { - - if (HAL_DAC_DeInit(&DacHandle) != HAL_OK) { - /* DeInitialization Error */ - return; - } - /*##-1- Configure the DAC peripheral #######################################*/ g_current_pin = pin; if (HAL_DAC_Init(&DacHandle) != HAL_OK) {