Skip to content

Commit f6456d8

Browse files
committed
Add option to disable default UART console
New `target.console-uart` option added to indicate whether a target has a console UART on STDIO_UART_TX/RX/RTS/CTS pins. (The existing option `target.console-uart-flow-control` indicates whether RTS and or CTS is available in addition to TX and RX). The option defaults to true, and is currently true on all platforms. It only applies if DEVICE_SERIAL is true, so no need to go through and mark it false for non-SERIAL platforms. An application can turn off target.console-uart to save ROM/power/etc if they don't want to use the serial console. If this is turned off, the console won't be activated for stdin/stdout, but the application is still free to open `UARTSerial(STDIO_UART_TX, STDIO_UART_RX)` themselves.
1 parent 71c84e8 commit f6456d8

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

platform/mbed_lib.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
},
1313

1414
"stdio-buffered-serial": {
15-
"help": "Use UARTSerial driver to obtain buffered serial I/O on stdin/stdout/stderr. If false, unbuffered serial_getc and serial_putc are used directly.",
15+
"help": "(Applies if target.console-uart is true.) Use UARTSerial driver to obtain buffered serial I/O on stdin/stdout/stderr. If false, unbuffered serial_getc and serial_putc are used directly.",
1616
"value": false
1717
},
1818

1919
"stdio-baud-rate": {
20-
"help": "Baud rate for stdio",
20+
"help": "(Applies if target.console-uart is true.) Baud rate for stdio",
2121
"value": 9600
2222
},
2323

platform/mbed_retarget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ MBED_WEAK FileHandle *mbed::mbed_override_console(int fd)
261261

262262
static FileHandle *default_console()
263263
{
264-
#if DEVICE_SERIAL
264+
#if MBED_CONF_TARGET_CONSOLE_UART && DEVICE_SERIAL
265265
# if MBED_CONF_PLATFORM_STDIO_BUFFERED_SERIAL
266266
static UARTSerial console(STDIO_UART_TX, STDIO_UART_RX, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
267267
# if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
@@ -274,7 +274,7 @@ static FileHandle *default_console()
274274
# else
275275
static DirectSerial console(STDIO_UART_TX, STDIO_UART_RX, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
276276
# endif
277-
#else // DEVICE_SERIAL
277+
#else // MBED_CONF_TARGET_CONSOLE_UART && DEVICE_SERIAL
278278
static Sink console;
279279
#endif
280280
return &console;

targets/targets.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
"bootloader_supported": false,
1616
"static_memory_defines": true,
1717
"config": {
18+
"console-uart": {
19+
"help": "Target has UART console on pins STDIO_UART_TX, STDIO_UART_RX. Value is only significant if target has SERIAL device.",
20+
"value": true
21+
},
1822
"console-uart-flow-control": {
1923
"help": "Console hardware flow control. Options: null, RTS, CTS, RTSCTS.",
2024
"value": null

0 commit comments

Comments
 (0)