Skip to content

Commit b8ab9fb

Browse files
mpolojarstevew817
authored andcommitted
SiLabs Pearl: Use any free UART for stdio
Remove limitation that only a specific UART can be used for the USB board controller serial line.
1 parent 8637649 commit b8ab9fb

File tree

1 file changed

+8
-2
lines changed
  • libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32

1 file changed

+8
-2
lines changed

libraries/mbed/targets/hal/TARGET_Silicon_Labs/TARGET_EFM32/serial_api.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
496496
{
497497
uint32_t baudrate;
498498
uint32_t allow_leuart = true;
499+
uint32_t uart_for_stdio = false;
499500

500501
#ifdef _SILICON_LABS_32B_PLATFORM_2
501502
if((tx == STDIO_UART_TX) && (rx == STDIO_UART_RX)) {
@@ -520,8 +521,13 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
520521
CMU_ClockEnable(serial_get_clock(obj), true);
521522

522523
/* Limitations of board controller: CDC port only supports 115kbaud */
523-
if((tx == STDIO_UART_TX) && (rx == STDIO_UART_RX) && (obj->serial.periph.uart == (USART_TypeDef*)STDIO_UART )) {
524+
if((tx == STDIO_UART_TX) && (rx == STDIO_UART_RX)
525+
#ifndef _SILICON_LABS_32B_PLATFORM_2
526+
&& (obj->serial.periph.uart == (USART_TypeDef*)STDIO_UART )
527+
#endif
528+
) {
524529
baudrate = 115200;
530+
uart_for_stdio = true;
525531
} else {
526532
baudrate = 9600;
527533
}
@@ -552,7 +558,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
552558
}
553559

554560
/* If this is the UART to be used for stdio, copy it to the stdio_uart struct */
555-
if (obj->serial.periph.uart == (USART_TypeDef*)STDIO_UART ) {
561+
if(uart_for_stdio) {
556562
stdio_uart_inited = 1;
557563
memcpy(&stdio_uart, obj, sizeof(serial_t));
558564
}

0 commit comments

Comments
 (0)