Skip to content

Commit 15fcdb1

Browse files
committed
M263: Support configurability for USB/STDIO UART pins
- STDIO_UART and STDIO_UART_TX/STDIO_UART_RX - USB_UART and USBTX/USBRX
1 parent edcfcf0 commit 15fcdb1

File tree

3 files changed

+59
-4
lines changed

3 files changed

+59
-4
lines changed

targets/TARGET_NUVOTON/TARGET_M261/PeripheralNames.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#define MBED_PERIPHERALNAMES_H
2020

2121
#include "cmsis.h"
22+
#include "PinNames.h"
2223

2324
#ifdef __cplusplus
2425
extern "C" {
@@ -80,7 +81,16 @@ typedef enum {
8081
UART_4 = (int) NU_MODNAME(UART4_BASE, 4, 0),
8182
UART_5 = (int) NU_MODNAME(UART5_BASE, 5, 0),
8283
// NOTE: board-specific
83-
STDIO_UART = UART_0
84+
#if defined(MBED_CONF_TARGET_USB_UART)
85+
USB_UART = MBED_CONF_TARGET_USB_UART,
86+
#else
87+
USB_UART = NC,
88+
#endif
89+
#if defined(MBED_CONF_TARGET_STDIO_UART)
90+
STDIO_UART = MBED_CONF_TARGET_STDIO_UART
91+
#else
92+
STDIO_UART = USB_UART
93+
#endif
8494

8595
} UARTName;
8696

targets/TARGET_NUVOTON/TARGET_M261/PinNames.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,26 @@ typedef enum {
113113
// Other board-specific naming
114114

115115
// UART naming
116-
USBTX = PB_13,
117-
USBRX = PB_12,
116+
#if defined(MBED_CONF_TARGET_USB_UART_TX)
117+
USBTX = MBED_CONF_TARGET_USB_UART_TX,
118+
#else
119+
USBTX = NC,
120+
#endif
121+
#if defined(MBED_CONF_TARGET_USB_UART_RX)
122+
USBRX = MBED_CONF_TARGET_USB_UART_RX,
123+
#else
124+
USBRX = NC,
125+
#endif
126+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
127+
STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX,
128+
#else
118129
STDIO_UART_TX = USBTX,
130+
#endif
131+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
132+
STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX,
133+
#else
119134
STDIO_UART_RX = USBRX,
135+
#endif
120136
SERIAL_TX = D1,
121137
SERIAL_RX = D0,
122138

targets/targets.json

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14732,6 +14732,30 @@
1473214732
"IAR"
1473314733
],
1473414734
"config": {
14735+
"usb-uart": {
14736+
"help": "Configure USB_UART. USB_UART and USB_UART_TX/USB_UART_RX must be consistent.",
14737+
"value": null
14738+
},
14739+
"usb-uart-tx": {
14740+
"help": "Configure USBTX. USB_UART and USBTX/USBRX must be consistent.",
14741+
"value": null
14742+
},
14743+
"usb-uart-rx": {
14744+
"help": "Configure USBRX. USB_UART and USBTX/USBRX must be consistent.",
14745+
"value": null
14746+
},
14747+
"stdio-uart": {
14748+
"help": "Configure STDIO_UART. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART defaults to USB_UART.",
14749+
"value": null
14750+
},
14751+
"stdio-uart-tx": {
14752+
"help": "Configure STDIO_UART_TX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_TX defaults to USBTX.",
14753+
"value": null
14754+
},
14755+
"stdio-uart-rx": {
14756+
"help": "Configure STDIO_UART_RX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_RX defaults to USBRX.",
14757+
"value": null
14758+
},
1473514759
"gpio-irq-debounce-enable": {
1473614760
"help": "Enable GPIO IRQ debounce",
1473714761
"value": 0
@@ -14799,7 +14823,12 @@
1479914823
"device_name": "M263KIAAE",
1480014824
"detect_code": [
1480114825
"1310"
14802-
]
14826+
],
14827+
"overrides": {
14828+
"usb-uart": "UART_0",
14829+
"usb-uart-tx": "PB_13",
14830+
"usb-uart-rx": "PB_12"
14831+
}
1480314832
},
1480414833
"NUCLEO_G071RB": {
1480514834
"inherits": [

0 commit comments

Comments
 (0)