Skip to content

Commit 88d887c

Browse files
committed
Rename USBTX/RX to CONSOLE_TX/RX
1 parent a385e34 commit 88d887c

File tree

17 files changed

+70
-47
lines changed

17 files changed

+70
-47
lines changed

hal/include/hal/ArduinoUnoAliases.h renamed to hal/include/hal/PinNameAliases.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,17 @@
1717
* See the License for the specific language governing permissions and
1818
* limitations under the License.
1919
*/
20-
#ifndef MBED_ARDUINO_UNO_H
21-
#define MBED_ARDUINO_UNO_H
20+
#ifndef MBED_PIN_NAME_ALIASES_H
21+
#define MBED_PIN_NAME_ALIASES_H
22+
23+
/* Aliases for legacy reasons. To be removed in the next Mbed OS version */
24+
#if defined (CONSOLE_TX) && (CONSOLE_RX)
25+
#define USBTX CONSOLE_TX
26+
#define USBRX CONSOLE_RX
27+
#else
28+
#define CONSOLE_TX USBTX
29+
#define CONSOLE_RX USBRX
30+
#endif
2231

2332
#if defined (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO)
2433

@@ -94,6 +103,6 @@
94103

95104
#endif // (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO)
96105

97-
#endif // MBED_ARDUINO_UNO_H
106+
#endif // MBED_PIN_NAME_ALIASES_H
98107

99108
/** @}*/

hal/include/hal/static_pinmap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#ifndef STATIC_PINMAP_H
1818
#define STATIC_PINMAP_H
1919

20+
#include "hal/PinNameAliases.h"
2021
#include "PinNames.h"
2122
#include "spi_api.h"
2223
#include "pwmout_api.h"
@@ -128,7 +129,7 @@ MSTD_CONSTEXPR_FN_14 serial_pinmap_t get_uart_pinmap(const PinName tx, const Pin
128129
return {(int) NC, NC, (int) NC, NC, (int) NC, false};
129130
}
130131

131-
if (tx_map->pin == USBTX && rx_map->pin == USBRX) {
132+
if (tx_map->pin == CONSOLE_TX && rx_map->pin == CONSOLE_RX) {
132133
return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function, true};
133134
} else {
134135
return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function, false};

hal/source/mbed_gpio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
#include "hal/gpio_api.h"
1818
#include "platform/mbed_toolchain.h"
19-
#include "hal/ArduinoUnoAliases.h"
19+
#include "hal/PinNameAliases.h"
2020

2121
static inline void _gpio_init_in(gpio_t *gpio, PinName pin, PinMode mode)
2222
{

hal/source/mbed_pinmap_default.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "platform/mbed_assert.h"
2222
#include "device.h"
2323
#include "hal/serial_api.h"
24-
#include "hal/ArduinoUnoAliases.h"
24+
#include "hal/PinNameAliases.h"
2525

2626
//*** Common form factors ***
2727
#if defined (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO)
@@ -70,7 +70,7 @@ const char *pinmap_ff_arduino_uno_pin_to_string(PinName pin)
7070
MBED_WEAK const PinList *pinmap_restricted_pins()
7171
{
7272
static const PinName pins[] = {
73-
USBTX, USBRX
73+
CONSOLE_TX, CONSOLE_RX
7474
};
7575
static const PinList pin_list = {
7676
sizeof(pins) / sizeof(pins[0]),
@@ -94,7 +94,7 @@ MBED_WEAK const PinList *pinmap_gpio_restricted_pins()
9494
#if DEVICE_SERIAL
9595
MBED_WEAK const PeripheralList *pinmap_uart_restricted_peripherals()
9696
{
97-
static const int stdio_uart = pinmap_peripheral(USBTX, serial_tx_pinmap());
97+
static const int stdio_uart = pinmap_peripheral(CONSOLE_TX, serial_tx_pinmap());
9898

9999
static const int peripherals[] = {
100100
stdio_uart

hal/tests/TESTS/pin_names/arduino_uno/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ void GPIO_test()
3535
{
3636
utest_printf("GPIO Pin 0x%x\n", TestedPin);
3737

38-
TEST_SKIP_UNLESS_MESSAGE(TestedPin != USBTX, "ARDUINO_UNO pin shared with USBTX");
39-
TEST_SKIP_UNLESS_MESSAGE(TestedPin != USBRX, "ARDUINO_UNO pin shared with USBRX");
38+
TEST_SKIP_UNLESS_MESSAGE(TestedPin != CONSOLE_TX, "ARDUINO_UNO pin shared with CONSOLE_TX");
39+
TEST_SKIP_UNLESS_MESSAGE(TestedPin != CONSOLE_RX, "ARDUINO_UNO pin shared with CONSOLE_RX");
4040

4141
const PinMap *maps = gpio_pinmap(); // hal/source/mbed_gpio.c
4242
while (maps->pin != (PinName)NC) { // check each pin from PinMap table till NC pin
@@ -124,8 +124,8 @@ void UART_test()
124124
{
125125
utest_printf("UART TX Pin 0x%x RX Pin 0x%x\n", TX_pin, RX_pin);
126126

127-
TEST_SKIP_UNLESS_MESSAGE(TX_pin != USBTX, "ARDUINO_UNO_UART pin shared with USBTX");
128-
TEST_SKIP_UNLESS_MESSAGE(RX_pin != USBRX, "ARDUINO_UNO_UART pin shared with USBRX");
127+
TEST_SKIP_UNLESS_MESSAGE(TX_pin != CONSOLE_TX, "ARDUINO_UNO_UART pin shared with CONSOLE_TX");
128+
TEST_SKIP_UNLESS_MESSAGE(RX_pin != CONSOLE_RX, "ARDUINO_UNO_UART pin shared with CONSOLE_RX");
129129

130130
{
131131
const PinMap *maps = serial_tx_pinmap();

hal/tests/pinvalidate/pinvalidate.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def identity_assignment_check(pin_name_dict):
314314
def nc_assignment_check(pin_name_dict):
315315
invalid_items = []
316316
for key, val in pin_name_dict.items():
317-
if re.match(r"^((LED|BUTTON)\d*|USBTX|USBRX)$", key):
317+
if re.match(r"^((LED|BUTTON)\d*|CONSOLE_TX|CONSOLE_RX|USBTX|USBRX)$", key):
318318
if val == "NC":
319319
message = "cannot be NC"
320320
invalid_items.append(
@@ -329,7 +329,7 @@ def duplicate_assignment_check(pin_name_dict):
329329
invalid_items = []
330330

331331
for key, val in pin_name_dict.items():
332-
if re.match(r"^((LED|BUTTON)\d*|USBTX|USBRX)$", key):
332+
if re.match(r"^((LED|BUTTON)\d*|CONSOLE_TX|CONSOLE_RX|USBTX|USBRX)$", key):
333333
if val == "NC":
334334
continue
335335
# resolve to literal
@@ -438,6 +438,13 @@ def legacy_assignment_check(pin_name_content):
438438
invalid_items.append({"key": key, "val": val, "message": message})
439439
return invalid_items
440440

441+
def legacy_uart_check(pin_name_dict):
442+
invalid_items = []
443+
if "CONSOLE_TX" not in pin_name_dict or "CONSOLE_RX" not in pin_name_dict:
444+
message = "CONSOLE_TX or CONSOLE_RX are not defined; USBTX and USBRX are deprecated"
445+
invalid_items.append({"key": "", "val": "", "message": message})
446+
return invalid_items
447+
441448

442449
def print_summary(report):
443450
targets = set([case["platform_name"] for case in report])
@@ -653,6 +660,12 @@ def has_passed_all_test_cases(report):
653660
"case_function": legacy_assignment_check,
654661
"case_input": "content",
655662
},
663+
{
664+
"suite_name": "generic",
665+
"case_name": "uart",
666+
"case_function": legacy_uart_check,
667+
"case_input": "content",
668+
},
656669
{
657670
"suite_name": "arduino_uno",
658671
"case_name": "duplicate",

hal/tests/pinvalidate/pinvalidate_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ def test_pin_name_to_dict(pin_name_dict):
139139
"ARDUINO_UNO_D13": "PA_5",
140140
"ARDUINO_UNO_D14": "PB_9",
141141
"ARDUINO_UNO_D15": "PB_8",
142-
"USBTX": "PB_6",
143-
"USBRX": "PB_7",
142+
"CONSOLE_TX": "PB_6",
143+
"CONSOLE_RX": "PB_7",
144144
"LED1": "PA_5",
145145
"BUTTON1": "PC_2",
146146
"LED2": "PB_14",

hal/tests/pinvalidate/test_files/PinNames.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ typedef enum {
8282
LED3 = P1_21,
8383
LED4 = P1_23,
8484
#endif
85-
USBTX = P0_2,
86-
USBRX = P0_3,
85+
CONSOLE_TX = P0_2,
86+
CONSOLE_RX = P0_3,
8787

8888
// Arch Pro Pin Names
8989
D0 = P4_29,

hal/tests/pinvalidate/test_files/PinNames_test.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ typedef enum {
119119
ARDUINO_UNO_D15 = PB_8, // I2C SCL / GPIO
120120

121121
// valid STDIO definitions for console print
122-
USBTX = PB_6,
123-
USBRX = PB_7,
122+
CONSOLE_TX = PB_6,
123+
CONSOLE_RX = PB_7,
124124

125125
// invalid legacy LED/BUTTON definitions
126126
// these should be a #define, not in an enum

hal/tests/pinvalidate/test_files/duplicate_file/PinNames.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ typedef enum {
8282
LED3 = P1_21,
8383
LED4 = P1_23,
8484
#endif
85-
USBTX = P0_2,
86-
USBRX = P0_3,
85+
CONSOLE_TX = P0_2,
86+
CONSOLE_RX = P0_3,
8787

8888
// Arch Pro Pin Names
8989
D0 = P4_29,

hal/tests/pinvalidate/test_files/duplicate_marker/PinNames.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ typedef enum {
8282
LED3 = P1_21,
8383
LED4 = P1_23,
8484
#endif
85-
USBTX = P0_2,
86-
USBRX = P0_3,
85+
CONSOLE_TX = P0_2,
86+
CONSOLE_RX = P0_3,
8787

8888
// Arch Pro Pin Names
8989
D0 = P4_29,

hal/tests/pinvalidate/test_files/misformatted_marker/PinNames.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ typedef enum {
8282
LED3 = P1_21,
8383
LED4 = P1_23,
8484
#endif
85-
USBTX = P0_2,
86-
USBRX = P0_3,
85+
CONSOLE_TX = P0_2,
86+
CONSOLE_RX = P0_3,
8787

8888
// Arch Pro Pin Names
8989
D0 = P4_29,

hal/tests/pinvalidate/test_files/missing_marker/PinNames.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ typedef enum {
8080
LED3 = P1_21,
8181
LED4 = P1_23,
8282
#endif
83-
USBTX = P0_2,
84-
USBRX = P0_3,
83+
CONSOLE_TX = P0_2,
84+
CONSOLE_RX = P0_3,
8585

8686
// Arch Pro Pin Names
8787
D0 = P4_29,

hal/tests/pinvalidate/test_files/nonexistent_target/PinNames.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ typedef enum {
8282
LED3 = P1_21,
8383
LED4 = P1_23,
8484
#endif
85-
USBTX = P0_2,
86-
USBRX = P0_3,
85+
CONSOLE_TX = P0_2,
86+
CONSOLE_RX = P0_3,
8787

8888
// Arch Pro Pin Names
8989
D0 = P4_29,

platform/include/platform/platform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include "device.h"
2929
#include "PinNames.h"
3030
#include "PeripheralNames.h"
31-
#include "hal/ArduinoUnoAliases.h"
31+
#include "hal/PinNameAliases.h"
3232

3333
/** \defgroup platform-public-api Platform
3434
* \ingroup mbed-os-public

platform/source/mbed_retarget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ DirectSerial::DirectSerial(PinName tx, PinName rx, int baud)
181181
return;
182182
}
183183

184-
static const serial_pinmap_t console_pinmap = get_uart_pinmap(USBTX, USBRX);
184+
static const serial_pinmap_t console_pinmap = get_uart_pinmap(CONSOLE_TX, CONSOLE_RX);
185185
serial_init_direct(&stdio_uart, &console_pinmap);
186186
serial_baud(&stdio_uart, baud);
187187

@@ -256,7 +256,7 @@ static void do_serial_init()
256256
return;
257257
}
258258

259-
static const serial_pinmap_t console_pinmap = get_uart_pinmap(USBTX, USBRX);
259+
static const serial_pinmap_t console_pinmap = get_uart_pinmap(CONSOLE_TX, CONSOLE_RX);
260260
serial_init_direct(&stdio_uart, &console_pinmap);
261261
serial_baud(&stdio_uart, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
262262
#if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
@@ -335,7 +335,7 @@ static FileHandle *default_console()
335335
#if MBED_CONF_TARGET_CONSOLE_UART && DEVICE_SERIAL
336336

337337
# if MBED_CONF_PLATFORM_STDIO_BUFFERED_SERIAL
338-
static const serial_pinmap_t console_pinmap = get_uart_pinmap(USBTX, USBRX);
338+
static const serial_pinmap_t console_pinmap = get_uart_pinmap(CONSOLE_TX, CONSOLE_RX);
339339
static BufferedSerial console(console_pinmap, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
340340
# if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
341341
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, NC);
@@ -348,7 +348,7 @@ static FileHandle *default_console()
348348
console.serial_set_flow_control(SerialBase::RTSCTS, fc_pinmap);
349349
# endif
350350
# else
351-
static const serial_pinmap_t console_pinmap = get_uart_pinmap(USBTX, USBRX);
351+
static const serial_pinmap_t console_pinmap = get_uart_pinmap(CONSOLE_TX, CONSOLE_RX);
352352
static DirectSerial console(console_pinmap, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
353353
# endif
354354
#else // MBED_CONF_TARGET_CONSOLE_UART && DEVICE_SERIAL

targets/targets.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
],
3535
"config": {
3636
"console-uart": {
37-
"help": "Target has UART console on pins USBTX, USBRX. Value is only significant if target has SERIAL device.",
37+
"help": "Target has UART console on pins CONSOLE_TX, CONSOLE_RX. Value is only significant if target has SERIAL device.",
3838
"value": true
3939
},
4040
"console-uart-flow-control": {
@@ -6371,23 +6371,23 @@
63716371
"value": null
63726372
},
63736373
"usb-uart-tx": {
6374-
"help": "Configure USBTX. USB_UART and USBTX/USBRX must be consistent.",
6374+
"help": "Configure CONSOLE_TX. USB_UART and CONSOLE_TX/CONSOLE_RX must be consistent.",
63756375
"value": null
63766376
},
63776377
"usb-uart-rx": {
6378-
"help": "Configure USBRX. USB_UART and USBTX/USBRX must be consistent.",
6378+
"help": "Configure CONSOLE_RX. USB_UART and CONSOLE_TX/CONSOLE_RX must be consistent.",
63796379
"value": null
63806380
},
63816381
"stdio-uart": {
63826382
"help": "Configure STDIO_UART. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART defaults to USB_UART.",
63836383
"value": null
63846384
},
63856385
"stdio-uart-tx": {
6386-
"help": "Configure STDIO_UART_TX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_TX defaults to USBTX.",
6386+
"help": "Configure STDIO_UART_TX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_TX defaults to CONSOLE_TX.",
63876387
"value": null
63886388
},
63896389
"stdio-uart-rx": {
6390-
"help": "Configure STDIO_UART_RX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_RX defaults to USBRX.",
6390+
"help": "Configure STDIO_UART_RX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_RX defaults to CONSOLE_RX.",
63916391
"value": null
63926392
},
63936393
"gpio-irq-debounce-enable": {
@@ -6720,23 +6720,23 @@
67206720
"value": null
67216721
},
67226722
"usb-uart-tx": {
6723-
"help": "Configure USBTX. USB_UART and USBTX/USBRX must be consistent.",
6723+
"help": "Configure CONSOLE_TX. USB_UART and CONSOLE_TX/CONSOLE_RX must be consistent.",
67246724
"value": null
67256725
},
67266726
"usb-uart-rx": {
6727-
"help": "Configure USBRX. USB_UART and USBTX/USBRX must be consistent.",
6727+
"help": "Configure CONSOLE_RX. USB_UART and CONSOLE_TX/CONSOLE_RX must be consistent.",
67286728
"value": null
67296729
},
67306730
"stdio-uart": {
67316731
"help": "Configure STDIO_UART. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART defaults to USB_UART.",
67326732
"value": null
67336733
},
67346734
"stdio-uart-tx": {
6735-
"help": "Configure STDIO_UART_TX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_TX defaults to USBTX.",
6735+
"help": "Configure STDIO_UART_TX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_TX defaults to CONSOLE_TX.",
67366736
"value": null
67376737
},
67386738
"stdio-uart-rx": {
6739-
"help": "Configure STDIO_UART_RX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_RX defaults to USBRX.",
6739+
"help": "Configure STDIO_UART_RX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_RX defaults to CONSOLE_RX.",
67406740
"value": null
67416741
},
67426742
"gpio-irq-debounce-enable": {
@@ -7643,19 +7643,19 @@
76437643
"value": null
76447644
},
76457645
"usb-uart-tx": {
7646-
"help": "Configure USBTX. USB_UART and USBTX/USBRX must be consistent.",
7646+
"help": "Configure CONSOLE_TX. USB_UART and CONSOLE_TX/CONSOLE_RX must be consistent.",
76477647
"value": null
76487648
},
76497649
"usb-uart-rx": {
7650-
"help": "Configure USBRX. USB_UART and USBTX/USBRX must be consistent.",
7650+
"help": "Configure CONSOLE_RX. USB_UART and CONSOLE_TX/CONSOLE_RX must be consistent.",
76517651
"value": null
76527652
},
76537653
"stdio-uart": {
76547654
"help": "Configure STDIO_UART. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART defaults to USB_UART.",
76557655
"value": null
76567656
},
76577657
"stdio-uart-tx": {
7658-
"help": "Configure STDIO_UART_TX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_TX defaults to USBTX.",
7658+
"help": "Configure STDIO_UART_TX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_TX defaults to CONSOLE_TX.",
76597659
"value": null
76607660
},
76617661
"stdio-uart-rx": {

0 commit comments

Comments
 (0)