[STD-PIN] Replace STDIO_UART_TX by USBTX

pull/14381/head
jeromecoutant 2020-11-16 12:06:26 +01:00 committed by George Psimenos
parent 61248478c2
commit a6c213bb10
7 changed files with 14 additions and 22 deletions

View File

@ -130,12 +130,6 @@ This is an example on how to define UART names in PinNames.h:
Note this document is proposing unifying the pin names used for UART communication between the MCU and the host PC.
Note Mbed OS expects to use these names internally (a fix might be needed during the implementation), for example:
mbed-os/platform/source/mbed_retarget.cpp
mbed-os/hal/static_pinmap.h
mbed-os/hal/mbed_pinmap_default.cpp
### Non-valid definitions
If either LEDs or buttons are not available, they should not be defined.

View File

@ -128,7 +128,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};
}
if (tx_map->pin == STDIO_UART_TX && rx_map->pin == STDIO_UART_RX) {
if (tx_map->pin == USBTX && rx_map->pin == USBRX) {
return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function, true};
} else {
return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function, false};

View File

@ -93,7 +93,7 @@ MBED_WEAK const PinList *pinmap_gpio_restricted_pins()
#if DEVICE_SERIAL
MBED_WEAK const PeripheralList *pinmap_uart_restricted_peripherals()
{
static const int stdio_uart = pinmap_peripheral(STDIO_UART_TX, serial_tx_pinmap());
static const int stdio_uart = pinmap_peripheral(USBTX, serial_tx_pinmap());
static const int peripherals[] = {
stdio_uart

View File

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

View File

@ -183,19 +183,16 @@ typedef enum {
// STDIO for console print
#ifdef MBED_CONF_TARGET_STDIO_UART_TX
STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX,
USBTX = MBED_CONF_TARGET_STDIO_UART_TX,
#else
STDIO_UART_TX = PB_6,
USBTX = PB_6,
#endif
#ifdef MBED_CONF_TARGET_STDIO_UART_RX
STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX,
USBRX = MBED_CONF_TARGET_STDIO_UART_RX,
#else
STDIO_UART_RX = PB_7,
USBRX = PB_7,
#endif
USBTX = STDIO_UART_TX, // used for greentea tests
USBRX = STDIO_UART_RX, // used for greentea tests
// I2C signals aliases
I2C_SDA = D14,
I2C_SCL = D15,

View File

@ -205,10 +205,10 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
uint8_t stdio_config = false;
if ((tx == STDIO_UART_TX) || (rx == STDIO_UART_RX)) {
if ((tx == USBTX) || (rx == USBRX)) {
stdio_config = true;
} else {
if (uart_tx == pinmap_peripheral(STDIO_UART_TX, PinMap_UART_TX)) {
if (uart_tx == pinmap_peripheral(USBTX, PinMap_UART_TX)) {
error("Error: new serial object is using same UART as STDIO");
}
}

View File

@ -34,7 +34,7 @@
],
"config": {
"console-uart": {
"help": "Target has UART console on pins STDIO_UART_TX, STDIO_UART_RX. Value is only significant if target has SERIAL device.",
"help": "Target has UART console on pins USBTX, USBRX. Value is only significant if target has SERIAL device.",
"value": true
},
"console-uart-flow-control": {