mirror of https://github.com/ARMmbed/mbed-os.git
[STD-PIN] Replace STDIO_UART_TX by USBTX
parent
61248478c2
commit
a6c213bb10
|
@ -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 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
|
### Non-valid definitions
|
||||||
|
|
||||||
If either LEDs or buttons are not available, they should not be defined.
|
If either LEDs or buttons are not available, they should not be defined.
|
||||||
|
|
|
@ -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};
|
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};
|
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};
|
||||||
|
|
|
@ -93,7 +93,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(STDIO_UART_TX, serial_tx_pinmap());
|
static const int stdio_uart = pinmap_peripheral(USBTX, serial_tx_pinmap());
|
||||||
|
|
||||||
static const int peripherals[] = {
|
static const int peripherals[] = {
|
||||||
stdio_uart
|
stdio_uart
|
||||||
|
|
|
@ -180,7 +180,8 @@ DirectSerial::DirectSerial(PinName tx, PinName rx, int baud)
|
||||||
if (stdio_uart_inited) {
|
if (stdio_uart_inited) {
|
||||||
return;
|
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_init_direct(&stdio_uart, &console_pinmap);
|
||||||
serial_baud(&stdio_uart, baud);
|
serial_baud(&stdio_uart, baud);
|
||||||
|
|
||||||
|
@ -255,7 +256,7 @@ static void do_serial_init()
|
||||||
return;
|
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_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
|
||||||
|
@ -334,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(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);
|
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);
|
||||||
|
@ -347,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(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);
|
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
|
||||||
|
|
|
@ -183,19 +183,16 @@ typedef enum {
|
||||||
|
|
||||||
// STDIO for console print
|
// STDIO for console print
|
||||||
#ifdef MBED_CONF_TARGET_STDIO_UART_TX
|
#ifdef MBED_CONF_TARGET_STDIO_UART_TX
|
||||||
STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX,
|
USBTX = MBED_CONF_TARGET_STDIO_UART_TX,
|
||||||
#else
|
#else
|
||||||
STDIO_UART_TX = PB_6,
|
USBTX = PB_6,
|
||||||
#endif
|
#endif
|
||||||
#ifdef MBED_CONF_TARGET_STDIO_UART_RX
|
#ifdef MBED_CONF_TARGET_STDIO_UART_RX
|
||||||
STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX,
|
USBRX = MBED_CONF_TARGET_STDIO_UART_RX,
|
||||||
#else
|
#else
|
||||||
STDIO_UART_RX = PB_7,
|
USBRX = PB_7,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
USBTX = STDIO_UART_TX, // used for greentea tests
|
|
||||||
USBRX = STDIO_UART_RX, // used for greentea tests
|
|
||||||
|
|
||||||
// I2C signals aliases
|
// I2C signals aliases
|
||||||
I2C_SDA = D14,
|
I2C_SDA = D14,
|
||||||
I2C_SCL = D15,
|
I2C_SCL = D15,
|
||||||
|
|
|
@ -205,10 +205,10 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
|
||||||
|
|
||||||
uint8_t stdio_config = false;
|
uint8_t stdio_config = false;
|
||||||
|
|
||||||
if ((tx == STDIO_UART_TX) || (rx == STDIO_UART_RX)) {
|
if ((tx == USBTX) || (rx == USBRX)) {
|
||||||
stdio_config = true;
|
stdio_config = true;
|
||||||
} else {
|
} 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");
|
error("Error: new serial object is using same UART as STDIO");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
],
|
],
|
||||||
"config": {
|
"config": {
|
||||||
"console-uart": {
|
"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
|
"value": true
|
||||||
},
|
},
|
||||||
"console-uart-flow-control": {
|
"console-uart-flow-control": {
|
||||||
|
|
Loading…
Reference in New Issue