Skip to content

Commit 2cf8282

Browse files
committed
M487: Support configurability of USB/STDIO UART pins
- STDIO_UART and STDIO_UART_TX/STDIO_UART_RX - USB_UART and USBTX/USBRX
1 parent 9d26390 commit 2cf8282

File tree

3 files changed

+65
-7
lines changed

3 files changed

+65
-7
lines changed

targets/TARGET_NUVOTON/TARGET_M480/PeripheralNames.h

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

2020
#include "cmsis.h"
21+
#include "PinNames.h"
2122

2223
#ifdef __cplusplus
2324
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
} UARTName;
8595

8696
typedef enum {

targets/TARGET_NUVOTON/TARGET_M480/PinNames.h

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ typedef enum {
7373
typedef enum {
7474
// Not connected
7575
NC = (int)0xFFFFFFFF,
76-
76+
7777
// Generic naming
7878
PA_0 = NU_PORT_N_PIN_TO_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,
7979
PB_0 = NU_PORT_N_PIN_TO_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,
@@ -83,7 +83,7 @@ typedef enum {
8383
PF_0 = NU_PORT_N_PIN_TO_PINNAME(5, 0), PF_1, PF_2, PF_3, PF_4, PF_5, PF_6, PF_7, PF_8, PF_9, PF_10, PF_11,
8484
PG_0 = NU_PORT_N_PIN_TO_PINNAME(6, 0), PG_1, PG_2, PG_3, PG_4, PG_5, PG_6, PG_7, PG_8, PG_9, PG_10, PG_11, PG_12, PG_13, PG_14, PG_15,
8585
PH_0 = NU_PORT_N_PIN_TO_PINNAME(7, 0), PH_1, PH_2, PH_3, PH_4, PH_5, PH_6, PH_7, PH_8, PH_9, PH_10, PH_11,
86-
86+
8787
// Arduino UNO naming
8888
A0 = PB_6,
8989
A1 = PB_7,
@@ -111,15 +111,32 @@ typedef enum {
111111

112112
I2C_SCL = D15,
113113
I2C_SDA = D14,
114-
114+
115115
// Note: board-specific
116116
// UART naming
117-
USBTX = PB_13,
118-
USBRX = PB_12,
117+
#if defined(MBED_CONF_TARGET_USB_UART_TX)
118+
USBTX = MBED_CONF_TARGET_USB_UART_TX,
119+
#else
120+
USBTX = NC,
121+
#endif
122+
#if defined(MBED_CONF_TARGET_USB_UART_RX)
123+
USBRX = MBED_CONF_TARGET_USB_UART_RX,
124+
#else
125+
USBRX = NC,
126+
#endif
127+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
128+
STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX,
129+
#else
119130
STDIO_UART_TX = USBTX,
131+
#endif
132+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
133+
STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX,
134+
#else
120135
STDIO_UART_RX = USBRX,
136+
#endif
121137
SERIAL_TX = D10,
122-
SERIAL_RX = D13,
138+
SERIAL_RX = D13,
139+
123140
// LED naming
124141
LED_RED = PH_0,
125142
LED_YELLOW = PH_1,
@@ -128,6 +145,7 @@ typedef enum {
128145
LED2 = LED_YELLOW,
129146
LED3 = LED_GREEN,
130147
LED4 = LED1, // No real LED. Just for passing ATS.
148+
131149
// Button naming
132150
#if TARGET_NUMAKER_PFM_M487
133151
SW2 = PG_15,

targets/targets.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12766,6 +12766,30 @@
1276612766
"help": "Enable SPIM CCM mode to spare 32KiB SRAM for normal use",
1276712767
"value": 0
1276812768
},
12769+
"usb-uart": {
12770+
"help": "Configure USB_UART. USB_UART and USB_UART_TX/USB_UART_RX must be consistent.",
12771+
"value": null
12772+
},
12773+
"usb-uart-tx": {
12774+
"help": "Configure USBTX. USB_UART and USBTX/USBRX must be consistent.",
12775+
"value": null
12776+
},
12777+
"usb-uart-rx": {
12778+
"help": "Configure USBRX. USB_UART and USBTX/USBRX must be consistent.",
12779+
"value": null
12780+
},
12781+
"stdio-uart": {
12782+
"help": "Configure STDIO_UART. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART defaults to USB_UART.",
12783+
"value": null
12784+
},
12785+
"stdio-uart-tx": {
12786+
"help": "Configure STDIO_UART_TX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_TX defaults to USBTX.",
12787+
"value": null
12788+
},
12789+
"stdio-uart-rx": {
12790+
"help": "Configure STDIO_UART_RX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_RX defaults to USBRX.",
12791+
"value": null
12792+
},
1276912793
"gpio-irq-debounce-enable": {
1277012794
"help": "Enable GPIO IRQ debounce",
1277112795
"value": 0
@@ -12847,6 +12871,9 @@
1284712871
"1304"
1284812872
],
1284912873
"overrides": {
12874+
"usb-uart": "UART_0",
12875+
"usb-uart-tx": "PB_13",
12876+
"usb-uart-rx": "PB_12",
1285012877
"spim-ccm-enable": 1,
1285112878
"network-default-interface-type": "ETHERNET"
1285212879
}
@@ -12863,6 +12890,9 @@
1286312890
"1308"
1286412891
],
1286512892
"overrides": {
12893+
"usb-uart": "UART_0",
12894+
"usb-uart-tx": "PB_13",
12895+
"usb-uart-rx": "PB_12",
1286612896
"spim-ccm-enable": 1,
1286712897
"network-default-interface-type": "WIFI"
1286812898
}

0 commit comments

Comments
 (0)