From 1c47e974ff394f0864e859b8836430f727612a8e Mon Sep 17 00:00:00 2001 From: Mikko Polojarvi Date: Tue, 15 Dec 2015 14:22:10 +0200 Subject: [PATCH] SiLabs Zero: Fix clocking when using LEUART for USB board controller When initializing for use with the board controller, the LEUART must be clocked from HF clock as the baud rate is otherwise too high. Do this by first initializing to "standard" 9600, then call serial_baud which will handle setting up the clocks and dividers. --- .../hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c index feb1b91801..f02d30a398 100644 --- a/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c +++ b/libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c @@ -175,7 +175,7 @@ static void uart_init(serial_t *obj, uint32_t baudrate, SerialParity parity, int } init.enable = leuartDisable; - init.baudrate = baudrate; + init.baudrate = 9600; init.databits = leuartDatabits8; #ifdef LEUART_USING_LFXO init.refFreq = LEUART_LF_REF_FREQ; @@ -183,6 +183,10 @@ static void uart_init(serial_t *obj, uint32_t baudrate, SerialParity parity, int init.refFreq = LEUART_REF_FREQ; #endif LEUART_Init(obj->serial.periph.leuart, &init); + + if (baudrate != 9600) { + serial_baud(obj, baudrate); + } } else { USART_InitAsync_TypeDef init = USART_INITASYNC_DEFAULT;