From 7881e68efeb20071772133d3b590362117951e64 Mon Sep 17 00:00:00 2001 From: Marc Emmers Date: Thu, 25 Jan 2018 17:24:57 +0100 Subject: [PATCH] STM32L0: Enable stop mode operation for the LPUART --- targets/TARGET_STM/serial_api.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/targets/TARGET_STM/serial_api.c b/targets/TARGET_STM/serial_api.c index 437560934b..a3209f1f6d 100644 --- a/targets/TARGET_STM/serial_api.c +++ b/targets/TARGET_STM/serial_api.c @@ -525,6 +525,18 @@ HAL_StatusTypeDef init_uart(serial_t *obj) huart->Init.Mode = UART_MODE_TX_RX; } +#if defined(LPUART1_BASE) + if (huart->Instance == LPUART1) { + if (obj_s->baudrate <= 9600) { + HAL_UARTEx_EnableClockStopMode(huart); + HAL_UARTEx_EnableStopMode(huart); + } else { + HAL_UARTEx_DisableClockStopMode(huart); + HAL_UARTEx_DisableStopMode(huart); + } + } +#endif + return HAL_UART_Init(huart); }