Rename USBTX/RX to CONSOLE_TX/RX

pull/14381/head
George Psimenos 2021-03-10 14:14:26 +00:00
parent 3af96247a6
commit d239ef98cd
17 changed files with 70 additions and 47 deletions

View File

@ -17,8 +17,17 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef MBED_ARDUINO_UNO_H #ifndef MBED_PIN_NAME_ALIASES_H
#define MBED_ARDUINO_UNO_H #define MBED_PIN_NAME_ALIASES_H
/* Aliases for legacy reasons. To be removed in the next Mbed OS version */
#if defined (CONSOLE_TX) && (CONSOLE_RX)
#define USBTX CONSOLE_TX
#define USBRX CONSOLE_RX
#else
#define CONSOLE_TX USBTX
#define CONSOLE_RX USBRX
#endif
#if defined (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO) #if defined (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO)
@ -94,6 +103,6 @@
#endif // (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO) #endif // (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO)
#endif // MBED_ARDUINO_UNO_H #endif // MBED_PIN_NAME_ALIASES_H
/** @}*/ /** @}*/

View File

@ -17,6 +17,7 @@
#ifndef STATIC_PINMAP_H #ifndef STATIC_PINMAP_H
#define STATIC_PINMAP_H #define STATIC_PINMAP_H
#include "hal/PinNameAliases.h"
#include "PinNames.h" #include "PinNames.h"
#include "spi_api.h" #include "spi_api.h"
#include "pwmout_api.h" #include "pwmout_api.h"
@ -128,7 +129,7 @@ MSTD_CONSTEXPR_FN_14 serial_pinmap_t get_uart_pinmap(const PinName tx, const Pin
return {(int) NC, NC, (int) NC, NC, (int) NC, false}; return {(int) NC, NC, (int) NC, NC, (int) NC, false};
} }
if (tx_map->pin == USBTX && rx_map->pin == USBRX) { if (tx_map->pin == CONSOLE_TX && rx_map->pin == CONSOLE_RX) {
return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function, true}; return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function, true};
} else { } else {
return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function, false}; return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function, false};

View File

@ -16,7 +16,7 @@
*/ */
#include "hal/gpio_api.h" #include "hal/gpio_api.h"
#include "platform/mbed_toolchain.h" #include "platform/mbed_toolchain.h"
#include "hal/ArduinoUnoAliases.h" #include "hal/PinNameAliases.h"
static inline void _gpio_init_in(gpio_t *gpio, PinName pin, PinMode mode) static inline void _gpio_init_in(gpio_t *gpio, PinName pin, PinMode mode)
{ {

View File

@ -21,7 +21,7 @@
#include "platform/mbed_assert.h" #include "platform/mbed_assert.h"
#include "device.h" #include "device.h"
#include "hal/serial_api.h" #include "hal/serial_api.h"
#include "hal/ArduinoUnoAliases.h" #include "hal/PinNameAliases.h"
//*** Common form factors *** //*** Common form factors ***
#if defined (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO) #if defined (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO)
@ -70,7 +70,7 @@ const char *pinmap_ff_arduino_uno_pin_to_string(PinName pin)
MBED_WEAK const PinList *pinmap_restricted_pins() MBED_WEAK const PinList *pinmap_restricted_pins()
{ {
static const PinName pins[] = { static const PinName pins[] = {
USBTX, USBRX CONSOLE_TX, CONSOLE_RX
}; };
static const PinList pin_list = { static const PinList pin_list = {
sizeof(pins) / sizeof(pins[0]), sizeof(pins) / sizeof(pins[0]),
@ -94,7 +94,7 @@ MBED_WEAK const PinList *pinmap_gpio_restricted_pins()
#if DEVICE_SERIAL #if DEVICE_SERIAL
MBED_WEAK const PeripheralList *pinmap_uart_restricted_peripherals() MBED_WEAK const PeripheralList *pinmap_uart_restricted_peripherals()
{ {
static const int stdio_uart = pinmap_peripheral(USBTX, serial_tx_pinmap()); static const int stdio_uart = pinmap_peripheral(CONSOLE_TX, serial_tx_pinmap());
static const int peripherals[] = { static const int peripherals[] = {
stdio_uart stdio_uart

View File

@ -35,8 +35,8 @@ void GPIO_test()
{ {
utest_printf("GPIO Pin 0x%x\n", TestedPin); utest_printf("GPIO Pin 0x%x\n", TestedPin);
TEST_SKIP_UNLESS_MESSAGE(TestedPin != USBTX, "ARDUINO_UNO pin shared with USBTX"); TEST_SKIP_UNLESS_MESSAGE(TestedPin != CONSOLE_TX, "ARDUINO_UNO pin shared with CONSOLE_TX");
TEST_SKIP_UNLESS_MESSAGE(TestedPin != USBRX, "ARDUINO_UNO pin shared with USBRX"); TEST_SKIP_UNLESS_MESSAGE(TestedPin != CONSOLE_RX, "ARDUINO_UNO pin shared with CONSOLE_RX");
const PinMap *maps = gpio_pinmap(); // hal/source/mbed_gpio.c const PinMap *maps = gpio_pinmap(); // hal/source/mbed_gpio.c
while (maps->pin != (PinName)NC) { // check each pin from PinMap table till NC pin while (maps->pin != (PinName)NC) { // check each pin from PinMap table till NC pin
@ -124,8 +124,8 @@ void UART_test()
{ {
utest_printf("UART TX Pin 0x%x RX Pin 0x%x\n", TX_pin, RX_pin); utest_printf("UART TX Pin 0x%x RX Pin 0x%x\n", TX_pin, RX_pin);
TEST_SKIP_UNLESS_MESSAGE(TX_pin != USBTX, "ARDUINO_UNO_UART pin shared with USBTX"); TEST_SKIP_UNLESS_MESSAGE(TX_pin != CONSOLE_TX, "ARDUINO_UNO_UART pin shared with CONSOLE_TX");
TEST_SKIP_UNLESS_MESSAGE(RX_pin != USBRX, "ARDUINO_UNO_UART pin shared with USBRX"); TEST_SKIP_UNLESS_MESSAGE(RX_pin != CONSOLE_RX, "ARDUINO_UNO_UART pin shared with CONSOLE_RX");
{ {
const PinMap *maps = serial_tx_pinmap(); const PinMap *maps = serial_tx_pinmap();

View File

@ -314,7 +314,7 @@ def identity_assignment_check(pin_name_dict):
def nc_assignment_check(pin_name_dict): def nc_assignment_check(pin_name_dict):
invalid_items = [] invalid_items = []
for key, val in pin_name_dict.items(): for key, val in pin_name_dict.items():
if re.match(r"^((LED|BUTTON)\d*|USBTX|USBRX)$", key): if re.match(r"^((LED|BUTTON)\d*|CONSOLE_TX|CONSOLE_RX|USBTX|USBRX)$", key):
if val == "NC": if val == "NC":
message = "cannot be NC" message = "cannot be NC"
invalid_items.append( invalid_items.append(
@ -329,7 +329,7 @@ def duplicate_assignment_check(pin_name_dict):
invalid_items = [] invalid_items = []
for key, val in pin_name_dict.items(): for key, val in pin_name_dict.items():
if re.match(r"^((LED|BUTTON)\d*|USBTX|USBRX)$", key): if re.match(r"^((LED|BUTTON)\d*|CONSOLE_TX|CONSOLE_RX|USBTX|USBRX)$", key):
if val == "NC": if val == "NC":
continue continue
# resolve to literal # resolve to literal
@ -438,6 +438,13 @@ def legacy_assignment_check(pin_name_content):
invalid_items.append({"key": key, "val": val, "message": message}) invalid_items.append({"key": key, "val": val, "message": message})
return invalid_items return invalid_items
def legacy_uart_check(pin_name_dict):
invalid_items = []
if "CONSOLE_TX" not in pin_name_dict or "CONSOLE_RX" not in pin_name_dict:
message = "CONSOLE_TX or CONSOLE_RX are not defined; USBTX and USBRX are deprecated"
invalid_items.append({"key": "", "val": "", "message": message})
return invalid_items
def print_summary(report): def print_summary(report):
targets = set([case["platform_name"] for case in report]) targets = set([case["platform_name"] for case in report])
@ -653,6 +660,12 @@ test_cases = [
"case_function": legacy_assignment_check, "case_function": legacy_assignment_check,
"case_input": "content", "case_input": "content",
}, },
{
"suite_name": "generic",
"case_name": "uart",
"case_function": legacy_uart_check,
"case_input": "content",
},
{ {
"suite_name": "arduino_uno", "suite_name": "arduino_uno",
"case_name": "duplicate", "case_name": "duplicate",

View File

@ -139,8 +139,8 @@ def test_pin_name_to_dict(pin_name_dict):
"ARDUINO_UNO_D13": "PA_5", "ARDUINO_UNO_D13": "PA_5",
"ARDUINO_UNO_D14": "PB_9", "ARDUINO_UNO_D14": "PB_9",
"ARDUINO_UNO_D15": "PB_8", "ARDUINO_UNO_D15": "PB_8",
"USBTX": "PB_6", "CONSOLE_TX": "PB_6",
"USBRX": "PB_7", "CONSOLE_RX": "PB_7",
"LED1": "PA_5", "LED1": "PA_5",
"BUTTON1": "PC_2", "BUTTON1": "PC_2",
"LED2": "PB_14", "LED2": "PB_14",

View File

@ -82,8 +82,8 @@ typedef enum {
LED3 = P1_21, LED3 = P1_21,
LED4 = P1_23, LED4 = P1_23,
#endif #endif
USBTX = P0_2, CONSOLE_TX = P0_2,
USBRX = P0_3, CONSOLE_RX = P0_3,
// Arch Pro Pin Names // Arch Pro Pin Names
D0 = P4_29, D0 = P4_29,

View File

@ -119,8 +119,8 @@ typedef enum {
ARDUINO_UNO_D15 = PB_8, // I2C SCL / GPIO ARDUINO_UNO_D15 = PB_8, // I2C SCL / GPIO
// valid STDIO definitions for console print // valid STDIO definitions for console print
USBTX = PB_6, CONSOLE_TX = PB_6,
USBRX = PB_7, CONSOLE_RX = PB_7,
// invalid legacy LED/BUTTON definitions // invalid legacy LED/BUTTON definitions
// these should be a #define, not in an enum // these should be a #define, not in an enum

View File

@ -82,8 +82,8 @@ typedef enum {
LED3 = P1_21, LED3 = P1_21,
LED4 = P1_23, LED4 = P1_23,
#endif #endif
USBTX = P0_2, CONSOLE_TX = P0_2,
USBRX = P0_3, CONSOLE_RX = P0_3,
// Arch Pro Pin Names // Arch Pro Pin Names
D0 = P4_29, D0 = P4_29,

View File

@ -82,8 +82,8 @@ typedef enum {
LED3 = P1_21, LED3 = P1_21,
LED4 = P1_23, LED4 = P1_23,
#endif #endif
USBTX = P0_2, CONSOLE_TX = P0_2,
USBRX = P0_3, CONSOLE_RX = P0_3,
// Arch Pro Pin Names // Arch Pro Pin Names
D0 = P4_29, D0 = P4_29,

View File

@ -82,8 +82,8 @@ typedef enum {
LED3 = P1_21, LED3 = P1_21,
LED4 = P1_23, LED4 = P1_23,
#endif #endif
USBTX = P0_2, CONSOLE_TX = P0_2,
USBRX = P0_3, CONSOLE_RX = P0_3,
// Arch Pro Pin Names // Arch Pro Pin Names
D0 = P4_29, D0 = P4_29,

View File

@ -80,8 +80,8 @@ typedef enum {
LED3 = P1_21, LED3 = P1_21,
LED4 = P1_23, LED4 = P1_23,
#endif #endif
USBTX = P0_2, CONSOLE_TX = P0_2,
USBRX = P0_3, CONSOLE_RX = P0_3,
// Arch Pro Pin Names // Arch Pro Pin Names
D0 = P4_29, D0 = P4_29,

View File

@ -82,8 +82,8 @@ typedef enum {
LED3 = P1_21, LED3 = P1_21,
LED4 = P1_23, LED4 = P1_23,
#endif #endif
USBTX = P0_2, CONSOLE_TX = P0_2,
USBRX = P0_3, CONSOLE_RX = P0_3,
// Arch Pro Pin Names // Arch Pro Pin Names
D0 = P4_29, D0 = P4_29,

View File

@ -28,7 +28,7 @@
#include "device.h" #include "device.h"
#include "PinNames.h" #include "PinNames.h"
#include "PeripheralNames.h" #include "PeripheralNames.h"
#include "hal/ArduinoUnoAliases.h" #include "hal/PinNameAliases.h"
/** \defgroup platform-public-api Platform /** \defgroup platform-public-api Platform
* \ingroup mbed-os-public * \ingroup mbed-os-public

View File

@ -181,7 +181,7 @@ DirectSerial::DirectSerial(PinName tx, PinName rx, int baud)
return; return;
} }
static const serial_pinmap_t console_pinmap = get_uart_pinmap(USBTX, USBRX); static const serial_pinmap_t console_pinmap = get_uart_pinmap(CONSOLE_TX, CONSOLE_RX);
serial_init_direct(&stdio_uart, &console_pinmap); serial_init_direct(&stdio_uart, &console_pinmap);
serial_baud(&stdio_uart, baud); serial_baud(&stdio_uart, baud);
@ -256,7 +256,7 @@ static void do_serial_init()
return; return;
} }
static const serial_pinmap_t console_pinmap = get_uart_pinmap(USBTX, USBRX); static const serial_pinmap_t console_pinmap = get_uart_pinmap(CONSOLE_TX, CONSOLE_RX);
serial_init_direct(&stdio_uart, &console_pinmap); serial_init_direct(&stdio_uart, &console_pinmap);
serial_baud(&stdio_uart, MBED_CONF_PLATFORM_STDIO_BAUD_RATE); serial_baud(&stdio_uart, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
#if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS #if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
@ -335,7 +335,7 @@ static FileHandle *default_console()
#if MBED_CONF_TARGET_CONSOLE_UART && DEVICE_SERIAL #if MBED_CONF_TARGET_CONSOLE_UART && DEVICE_SERIAL
# if MBED_CONF_PLATFORM_STDIO_BUFFERED_SERIAL # if MBED_CONF_PLATFORM_STDIO_BUFFERED_SERIAL
static const serial_pinmap_t console_pinmap = get_uart_pinmap(USBTX, USBRX); static const serial_pinmap_t console_pinmap = get_uart_pinmap(CONSOLE_TX, CONSOLE_RX);
static BufferedSerial console(console_pinmap, MBED_CONF_PLATFORM_STDIO_BAUD_RATE); static BufferedSerial console(console_pinmap, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
# if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS # if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, NC); static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, NC);
@ -348,7 +348,7 @@ static FileHandle *default_console()
console.serial_set_flow_control(SerialBase::RTSCTS, fc_pinmap); console.serial_set_flow_control(SerialBase::RTSCTS, fc_pinmap);
# endif # endif
# else # else
static const serial_pinmap_t console_pinmap = get_uart_pinmap(USBTX, USBRX); static const serial_pinmap_t console_pinmap = get_uart_pinmap(CONSOLE_TX, CONSOLE_RX);
static DirectSerial console(console_pinmap, MBED_CONF_PLATFORM_STDIO_BAUD_RATE); static DirectSerial console(console_pinmap, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
# endif # endif
#else // MBED_CONF_TARGET_CONSOLE_UART && DEVICE_SERIAL #else // MBED_CONF_TARGET_CONSOLE_UART && DEVICE_SERIAL

View File

@ -34,7 +34,7 @@
], ],
"config": { "config": {
"console-uart": { "console-uart": {
"help": "Target has UART console on pins USBTX, USBRX. Value is only significant if target has SERIAL device.", "help": "Target has UART console on pins CONSOLE_TX, CONSOLE_RX. Value is only significant if target has SERIAL device.",
"value": true "value": true
}, },
"console-uart-flow-control": { "console-uart-flow-control": {
@ -6370,11 +6370,11 @@
"value": null "value": null
}, },
"usb-uart-tx": { "usb-uart-tx": {
"help": "Configure USBTX. USB_UART and USBTX/USBRX must be consistent.", "help": "Configure CONSOLE_TX. USB_UART and CONSOLE_TX/CONSOLE_RX must be consistent.",
"value": null "value": null
}, },
"usb-uart-rx": { "usb-uart-rx": {
"help": "Configure USBRX. USB_UART and USBTX/USBRX must be consistent.", "help": "Configure CONSOLE_RX. USB_UART and CONSOLE_TX/CONSOLE_RX must be consistent.",
"value": null "value": null
}, },
"stdio-uart": { "stdio-uart": {
@ -6382,11 +6382,11 @@
"value": null "value": null
}, },
"stdio-uart-tx": { "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.", "help": "Configure STDIO_UART_TX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_TX defaults to CONSOLE_TX.",
"value": null "value": null
}, },
"stdio-uart-rx": { "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.", "help": "Configure STDIO_UART_RX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_RX defaults to CONSOLE_RX.",
"value": null "value": null
}, },
"gpio-irq-debounce-enable": { "gpio-irq-debounce-enable": {
@ -6719,11 +6719,11 @@
"value": null "value": null
}, },
"usb-uart-tx": { "usb-uart-tx": {
"help": "Configure USBTX. USB_UART and USBTX/USBRX must be consistent.", "help": "Configure CONSOLE_TX. USB_UART and CONSOLE_TX/CONSOLE_RX must be consistent.",
"value": null "value": null
}, },
"usb-uart-rx": { "usb-uart-rx": {
"help": "Configure USBRX. USB_UART and USBTX/USBRX must be consistent.", "help": "Configure CONSOLE_RX. USB_UART and CONSOLE_TX/CONSOLE_RX must be consistent.",
"value": null "value": null
}, },
"stdio-uart": { "stdio-uart": {
@ -6731,11 +6731,11 @@
"value": null "value": null
}, },
"stdio-uart-tx": { "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.", "help": "Configure STDIO_UART_TX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_TX defaults to CONSOLE_TX.",
"value": null "value": null
}, },
"stdio-uart-rx": { "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.", "help": "Configure STDIO_UART_RX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_RX defaults to CONSOLE_RX.",
"value": null "value": null
}, },
"gpio-irq-debounce-enable": { "gpio-irq-debounce-enable": {
@ -7642,11 +7642,11 @@
"value": null "value": null
}, },
"usb-uart-tx": { "usb-uart-tx": {
"help": "Configure USBTX. USB_UART and USBTX/USBRX must be consistent.", "help": "Configure CONSOLE_TX. USB_UART and CONSOLE_TX/CONSOLE_RX must be consistent.",
"value": null "value": null
}, },
"usb-uart-rx": { "usb-uart-rx": {
"help": "Configure USBRX. USB_UART and USBTX/USBRX must be consistent.", "help": "Configure CONSOLE_RX. USB_UART and CONSOLE_TX/CONSOLE_RX must be consistent.",
"value": null "value": null
}, },
"stdio-uart": { "stdio-uart": {
@ -7654,7 +7654,7 @@
"value": null "value": null
}, },
"stdio-uart-tx": { "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.", "help": "Configure STDIO_UART_TX. STDIO_UART and STDIO_UART_TX/STDIO_UART_RX must be consistent. STDIO_UART_TX defaults to CONSOLE_TX.",
"value": null "value": null
}, },
"stdio-uart-rx": { "stdio-uart-rx": {