diff --git a/targets/TARGET_NUVOTON/TARGET_M251/PeripheralNames.h b/targets/TARGET_NUVOTON/TARGET_M251/PeripheralNames.h index fc5bda4097..4c46ac66d5 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/PeripheralNames.h +++ b/targets/TARGET_NUVOTON/TARGET_M251/PeripheralNames.h @@ -20,6 +20,7 @@ #define MBED_PERIPHERALNAMES_H #include "cmsis.h" +#include "PinNames.h" #ifdef __cplusplus extern "C" { @@ -77,7 +78,16 @@ typedef enum { UART_2 = (int) NU_MODNAME(UART2_BASE, 2, 0), /* NOTE: board-specific */ - STDIO_UART = UART_0 +#if defined(MBED_CONF_TARGET_USB_UART) + USB_UART = MBED_CONF_TARGET_USB_UART, +#else + USB_UART = NC, +#endif +#if defined(MBED_CONF_TARGET_STDIO_UART) + STDIO_UART = MBED_CONF_TARGET_STDIO_UART +#else + STDIO_UART = USB_UART +#endif } UARTName; typedef enum { diff --git a/targets/TARGET_NUVOTON/TARGET_M251/PinNames.h b/targets/TARGET_NUVOTON/TARGET_M251/PinNames.h index 510528acf1..21db250878 100644 --- a/targets/TARGET_NUVOTON/TARGET_M251/PinNames.h +++ b/targets/TARGET_NUVOTON/TARGET_M251/PinNames.h @@ -70,7 +70,7 @@ typedef enum { typedef enum { /* Not connected */ NC = (int)0xFFFFFFFF, - + /* Generic naming */ PA_0 = NU_PINNAME(0, 0), PA_1, PA_2, PA_3, PA_4, PA_5, PA_6, PA_7, PA_8, PA_9, PA_10, PA_11, PA_12, PA_13, PA_14, PA_15, PB_0 = NU_PINNAME(1, 0), PB_1, PB_2, PB_3, PB_4, PB_5, PB_6, PB_7, PB_8, PB_9, PB_10, PB_11, PB_12, PB_13, PB_14, PB_15, @@ -103,21 +103,37 @@ typedef enum { D13 = PA_2, D14 = PC_0, D15 = PC_1, - + /* Other board-specific naming */ - + /* UART naming */ - USBTX = PB_13, - USBRX = PB_12, +#if defined(MBED_CONF_TARGET_USB_UART_TX) + USBTX = MBED_CONF_TARGET_USB_UART_TX, +#else + USBTX = NC, +#endif +#if defined(MBED_CONF_TARGET_USB_UART_RX) + USBRX = MBED_CONF_TARGET_USB_UART_RX, +#else + USBRX = NC, +#endif +#if defined(MBED_CONF_TARGET_STDIO_UART_TX) + STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX, +#else STDIO_UART_TX = USBTX, +#endif +#if defined(MBED_CONF_TARGET_STDIO_UART_RX) + STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX, +#else STDIO_UART_RX = USBRX, +#endif SERIAL_TX = D10, SERIAL_RX = D13, /* I2C naming */ I2C_SCL = D15, I2C_SDA = D14, - + /* LED naming */ LED_RED = PB_14, LED1 = LED_RED, @@ -126,7 +142,7 @@ typedef enum { LED4 = LED1, // No real LED. Just for passing ATS. /* Button naming */ - + /* Force PinName to 32-bit required by NU_PINNAME_BIND(...) */ FORCE_ENUM_PINNAME_32BIT = 0x7FFFFFFF, diff --git a/targets/targets.json b/targets/targets.json index 7ddc7b64f1..8b2bfdd410 100644 --- a/targets/targets.json +++ b/targets/targets.json @@ -5656,6 +5656,30 @@ "IAR" ], "config": { + "usb-uart": { + "help": "Configure USB_UART. USB_UART and USB_UART_TX/USB_UART_RX must be consistent.", + "value": null + }, + "usb-uart-tx": { + "help": "Configure USBTX. USB_UART and USBTX/USBRX must be consistent.", + "value": null + }, + "usb-uart-rx": { + "help": "Configure USBRX. USB_UART and USBTX/USBRX must be consistent.", + "value": null + }, + "stdio-uart": { + "help": "Configure STDIO_UART. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART defaults to USB_UART.", + "value": null + }, + "stdio-uart-tx": { + "help": "Configure STDIO_UART_TX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_TX defaults to USBTX.", + "value": null + }, + "stdio-uart-rx": { + "help": "Configure STDIO_UART_RX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_RX defaults to USBRX.", + "value": null + }, "gpio-irq-debounce-enable": { "help": "Enable GPIO IRQ debounce", "value": 0 @@ -5733,7 +5757,12 @@ "2", "5" ], - "device_name": "M252KG6AE" + "device_name": "M252KG6AE", + "overrides": { + "usb-uart": "UART_0", + "usb-uart-tx": "PB_13", + "usb-uart-rx": "PB_12" + } }, "TMPM4G9": { "inherits": [