Skip to content

Commit a6c213b

Browse files
jeromecoutantgpsimenos
authored andcommitted
[STD-PIN] Replace STDIO_UART_TX by USBTX
1 parent 6124847 commit a6c213b

File tree

7 files changed

+14
-22
lines changed

7 files changed

+14
-22
lines changed

docs/design-documents/hal/0004-pin-names-general-guidelines.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,6 @@ This is an example on how to define UART names in PinNames.h:
130130

131131
Note this document is proposing unifying the pin names used for UART communication between the MCU and the host PC.
132132

133-
Note Mbed OS expects to use these names internally (a fix might be needed during the implementation), for example:
134-
135-
mbed-os/platform/source/mbed_retarget.cpp
136-
mbed-os/hal/static_pinmap.h
137-
mbed-os/hal/mbed_pinmap_default.cpp
138-
139133
### Non-valid definitions
140134

141135
If either LEDs or buttons are not available, they should not be defined.

hal/include/hal/static_pinmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ MSTD_CONSTEXPR_FN_14 serial_pinmap_t get_uart_pinmap(const PinName tx, const Pin
128128
return {(int) NC, NC, (int) NC, NC, (int) NC, false};
129129
}
130130

131-
if (tx_map->pin == STDIO_UART_TX && rx_map->pin == STDIO_UART_RX) {
131+
if (tx_map->pin == USBTX && rx_map->pin == USBRX) {
132132
return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function, true};
133133
} else {
134134
return {tx_map->peripheral, tx_map->pin, tx_map->function, rx_map->pin, rx_map->function, false};

hal/source/mbed_pinmap_default.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ MBED_WEAK const PinList *pinmap_gpio_restricted_pins()
9393
#if DEVICE_SERIAL
9494
MBED_WEAK const PeripheralList *pinmap_uart_restricted_peripherals()
9595
{
96-
static const int stdio_uart = pinmap_peripheral(STDIO_UART_TX, serial_tx_pinmap());
96+
static const int stdio_uart = pinmap_peripheral(USBTX, serial_tx_pinmap());
9797

9898
static const int peripherals[] = {
9999
stdio_uart

platform/source/mbed_retarget.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ DirectSerial::DirectSerial(PinName tx, PinName rx, int baud)
180180
if (stdio_uart_inited) {
181181
return;
182182
}
183-
static const serial_pinmap_t console_pinmap = get_uart_pinmap(STDIO_UART_TX, STDIO_UART_RX);
183+
184+
static const serial_pinmap_t console_pinmap = get_uart_pinmap(USBTX, USBRX);
184185
serial_init_direct(&stdio_uart, &console_pinmap);
185186
serial_baud(&stdio_uart, baud);
186187

@@ -255,7 +256,7 @@ static void do_serial_init()
255256
return;
256257
}
257258

258-
static const serial_pinmap_t console_pinmap = get_uart_pinmap(STDIO_UART_TX, STDIO_UART_RX);
259+
static const serial_pinmap_t console_pinmap = get_uart_pinmap(USBTX, USBRX);
259260
serial_init_direct(&stdio_uart, &console_pinmap);
260261
serial_baud(&stdio_uart, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
261262
#if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
@@ -334,7 +335,7 @@ static FileHandle *default_console()
334335
#if MBED_CONF_TARGET_CONSOLE_UART && DEVICE_SERIAL
335336

336337
# if MBED_CONF_PLATFORM_STDIO_BUFFERED_SERIAL
337-
static const serial_pinmap_t console_pinmap = get_uart_pinmap(STDIO_UART_TX, STDIO_UART_RX);
338+
static const serial_pinmap_t console_pinmap = get_uart_pinmap(USBTX, USBRX);
338339
static BufferedSerial console(console_pinmap, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
339340
# if CONSOLE_FLOWCONTROL == CONSOLE_FLOWCONTROL_RTS
340341
static const serial_fc_pinmap_t fc_pinmap = get_uart_fc_pinmap(STDIO_UART_RTS, NC);
@@ -347,7 +348,7 @@ static FileHandle *default_console()
347348
console.serial_set_flow_control(SerialBase::RTSCTS, fc_pinmap);
348349
# endif
349350
# else
350-
static const serial_pinmap_t console_pinmap = get_uart_pinmap(STDIO_UART_TX, STDIO_UART_RX);
351+
static const serial_pinmap_t console_pinmap = get_uart_pinmap(USBTX, USBRX);
351352
static DirectSerial console(console_pinmap, MBED_CONF_PLATFORM_STDIO_BAUD_RATE);
352353
# endif
353354
#else // MBED_CONF_TARGET_CONSOLE_UART && DEVICE_SERIAL

targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L4S5xI/TARGET_B_L4S5I_IOT01A/PinNames.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,19 +183,16 @@ typedef enum {
183183

184184
// STDIO for console print
185185
#ifdef MBED_CONF_TARGET_STDIO_UART_TX
186-
STDIO_UART_TX = MBED_CONF_TARGET_STDIO_UART_TX,
186+
USBTX = MBED_CONF_TARGET_STDIO_UART_TX,
187187
#else
188-
STDIO_UART_TX = PB_6,
188+
USBTX = PB_6,
189189
#endif
190190
#ifdef MBED_CONF_TARGET_STDIO_UART_RX
191-
STDIO_UART_RX = MBED_CONF_TARGET_STDIO_UART_RX,
191+
USBRX = MBED_CONF_TARGET_STDIO_UART_RX,
192192
#else
193-
STDIO_UART_RX = PB_7,
193+
USBRX = PB_7,
194194
#endif
195195

196-
USBTX = STDIO_UART_TX, // used for greentea tests
197-
USBRX = STDIO_UART_RX, // used for greentea tests
198-
199196
// I2C signals aliases
200197
I2C_SDA = D14,
201198
I2C_SCL = D15,

targets/TARGET_STM/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ void serial_init(serial_t *obj, PinName tx, PinName rx)
205205

206206
uint8_t stdio_config = false;
207207

208-
if ((tx == STDIO_UART_TX) || (rx == STDIO_UART_RX)) {
208+
if ((tx == USBTX) || (rx == USBRX)) {
209209
stdio_config = true;
210210
} else {
211-
if (uart_tx == pinmap_peripheral(STDIO_UART_TX, PinMap_UART_TX)) {
211+
if (uart_tx == pinmap_peripheral(USBTX, PinMap_UART_TX)) {
212212
error("Error: new serial object is using same UART as STDIO");
213213
}
214214
}

targets/targets.json

Lines changed: 1 addition & 1 deletion
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 STDIO_UART_TX, STDIO_UART_RX. Value is only significant if target has SERIAL device.",
37+
"help": "Target has UART console on pins USBTX, USBRX. Value is only significant if target has SERIAL device.",
3838
"value": true
3939
},
4040
"console-uart-flow-control": {

0 commit comments

Comments
 (0)