Skip to content

Commit d1eacaf

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 be3ae5b commit d1eacaf

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
@@ -75,7 +75,7 @@ typedef enum {
7575
typedef enum {
7676
// Not connected
7777
NC = (int)0xFFFFFFFF,
78-
78+
7979
// Generic naming
8080
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,
8181
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,
@@ -85,7 +85,7 @@ typedef enum {
8585
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,
8686
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,
8787
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,
88-
88+
8989
// Arduino UNO naming
9090
A0 = PB_6,
9191
A1 = PB_7,
@@ -113,15 +113,32 @@ typedef enum {
113113

114114
I2C_SCL = D15,
115115
I2C_SDA = D14,
116-
116+
117117
// Note: board-specific
118118
// UART naming
119-
USBTX = PB_13,
120-
USBRX = PB_12,
119+
#if defined(MBED_CONF_TARGET_USB_UART_TX)
120+
USBTX = MBED_CONF_TARGET_USB_UART_TX,
121+
#else
122+
USBTX = NC,
123+
#endif
124+
#if defined(MBED_CONF_TARGET_USB_UART_RX)
125+
USBRX = MBED_CONF_TARGET_USB_UART_RX,
126+
#else
127+
USBRX = NC,
128+
#endif
129+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
130+
STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX,
131+
#else
121132
STDIO_UART_TX = USBTX,
133+
#endif
134+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
135+
STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX,
136+
#else
122137
STDIO_UART_RX = USBRX,
138+
#endif
123139
SERIAL_TX = D10,
124-
SERIAL_RX = D13,
140+
SERIAL_RX = D13,
141+
125142
// LED naming
126143
LED_RED = PH_0,
127144
LED_YELLOW = PH_1,
@@ -130,6 +147,7 @@ typedef enum {
130147
LED2 = LED_YELLOW,
131148
LED3 = LED_GREEN,
132149
LED4 = LED1, // No real LED. Just for passing ATS.
150+
133151
// Button naming
134152
#if TARGET_NUMAKER_PFM_M487
135153
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
"custom-pinname-file": {
1277012794
"help": "Header file to override PinName enum in PinNames.h",
1277112795
"value": null
@@ -12851,6 +12875,9 @@
1285112875
"1304"
1285212876
],
1285312877
"overrides": {
12878+
"usb-uart": "UART_0",
12879+
"usb-uart-tx": "PB_13",
12880+
"usb-uart-rx": "PB_12",
1285412881
"spim-ccm-enable": 1,
1285512882
"network-default-interface-type": "ETHERNET"
1285612883
}
@@ -12867,6 +12894,9 @@
1286712894
"1308"
1286812895
],
1286912896
"overrides": {
12897+
"usb-uart": "UART_0",
12898+
"usb-uart-tx": "PB_13",
12899+
"usb-uart-rx": "PB_12",
1287012900
"spim-ccm-enable": 1,
1287112901
"network-default-interface-type": "WIFI"
1287212902
}

0 commit comments

Comments
 (0)