From b51d676dc0c79e1e1f22825d96dfff21b5fc4d8d Mon Sep 17 00:00:00 2001 From: Laurent MEUNIER Date: Mon, 12 Jun 2017 12:47:11 +0200 Subject: [PATCH] STM32: analog_out: Enable Buffer and switch ADC1 channel2 and ADC2 of few targets only have an output switch and no buffer. This switch needs to be enabled, and also the buffer can be enabled in order to reduce the output impedance on output, and to drive external loads directly without having to add an external operational amplifier. --- targets/TARGET_STM/TARGET_STM32F3/analogout_api.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32F3/analogout_api.c b/targets/TARGET_STM/TARGET_STM32F3/analogout_api.c index 9fb2cdd9f0..e72c5b65db 100644 --- a/targets/TARGET_STM/TARGET_STM32F3/analogout_api.c +++ b/targets/TARGET_STM/TARGET_STM32F3/analogout_api.c @@ -87,8 +87,15 @@ void analogout_init(dac_t *obj, PinName pin) { obj->handle.Instance = (DAC_TypeDef *)(obj->dac); sConfig.DAC_Trigger = DAC_TRIGGER_NONE; - sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_DISABLE; - + /* Enable both Buffer and Switch in the configuration, + * letting HAL layer in charge of selecting either one + * or the other depending on the actual DAC instance and + * channel being configured. + */ + sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE; +#if defined(DAC_OUTPUTSWITCH_ENABLE) + sConfig.DAC_OutputSwitch = DAC_OUTPUTSWITCH_ENABLE; +#endif if (pin == PA_4) { pa4_used = 1;