Skip to content

Commit 0742135

Browse files
authored
Merge pull request #14457 from ARMmbed/uart-stdio-alias
Update UART pin names & add MBED_CONF_TARGET_STDIO_UART overrides
2 parents 6d1a6da + 9cc2deb commit 0742135

File tree

176 files changed

+1007
-499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

176 files changed

+1007
-499
lines changed

TEST_APPS/device/nanostack_mac_tester/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#endif
4545

4646
extern mac_api_s *mac_interface;
47-
UnbufferedSerial pc(USBTX, USBRX);
47+
UnbufferedSerial pc(CONSOLE_TX, CONSOLE_RX);
4848
osThreadId_t main_thread;
4949
static CircularBuffer<uint8_t, RX_BUFFER_SIZE> rx_buffer;
5050
static uint8_t ns_heap[HEAP_FOR_MAC_TESTER_SIZE];

drivers/docs/serial/serial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ Other alternatives to printing to stdout are by calling `puts` or `write`.
232232
puts("Hello");
233233
```
234234
```C
235-
BufferedSerial pc(USBTX, USBRX);
235+
BufferedSerial pc(CONSOLE_TX, CONSOLE_RX);
236236
pc.write("Hello", 6);
237237
```
238238

drivers/tests/TESTS/mbed_drivers/buffered_serial/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ using namespace utest::v1;
4949

5050

5151
static BufferedSerial buffered_serial_obj(
52-
USBTX, USBRX, MBED_CONF_PLATFORM_STDIO_BAUD_RATE
52+
CONSOLE_TX, CONSOLE_RX, MBED_CONF_PLATFORM_STDIO_BAUD_RATE
5353
);
5454

5555

drivers/tests/TESTS/mbed_drivers/unbuffered_serial/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ using namespace utest::v1;
4747

4848

4949
static UnbufferedSerial unbuffered_serial_obj(
50-
USBTX, USBRX, MBED_CONF_PLATFORM_STDIO_BAUD_RATE
50+
CONSOLE_TX, CONSOLE_RX, MBED_CONF_PLATFORM_STDIO_BAUD_RATE
5151
);
5252

5353
static ssize_t unbuffered_serial_read(void *buffer, ssize_t length)

features/frameworks/greentea-client/source/greentea_test_env.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static void greentea_write_int(const int val)
284284
* \brief Encapsulate and send key-value message from DUT to host
285285
*
286286
* This function uses underlying functions to write directly
287-
* to the serial port, (USBTX). This allows KVs to be used
287+
* to the serial port, (CONSOLE_TX). This allows KVs to be used
288288
* from within interrupt context.
289289
*
290290
* \param key Message key (message/event name)
@@ -305,7 +305,7 @@ extern "C" void greentea_send_kv(const char *key, const char *val) {
305305
* \brief Encapsulate and send key-value message from DUT to host
306306
*
307307
* This function uses underlying functions to write directly
308-
* to the serial port, (USBTX). This allows KVs to be used
308+
* to the serial port, (CONSOLE_TX). This allows KVs to be used
309309
* from within interrupt context.
310310
* Last value is an integer to avoid integer to string conversion
311311
* made by the user.
@@ -328,7 +328,7 @@ void greentea_send_kv(const char *key, const int val) {
328328
* \brief Encapsulate and send key-value-value message from DUT to host
329329
*
330330
* This function uses underlying functions to write directly
331-
* to the serial port, (USBTX). This allows KVs to be used
331+
* to the serial port, (CONSOLE_TX). This allows KVs to be used
332332
* from within interrupt context.
333333
* Last value is an integer to avoid integer to string conversion
334334
* made by the user.
@@ -355,7 +355,7 @@ void greentea_send_kv(const char *key, const char *val, const int result) {
355355
* \brief Encapsulate and send key-value-value-value message from DUT to host
356356
*
357357
* This function uses underlying functions to write directly
358-
* to the serial port, (USBTX). This allows KVs to be used
358+
* to the serial port, (CONSOLE_TX). This allows KVs to be used
359359
* from within interrupt context.
360360
* Last 2 values are integers to avoid integer to string conversion
361361
* made by the user.
@@ -389,7 +389,7 @@ void greentea_send_kv(const char *key, const char *val, const int passes, const
389389
* \brief Encapsulate and send key-value-value message from DUT to host
390390
*
391391
* This function uses underlying functions to write directly
392-
* to the serial port, (USBTX). This allows key-value-value to be used
392+
* to the serial port, (CONSOLE_TX). This allows key-value-value to be used
393393
* from within interrupt context.
394394
* Both values are integers to avoid integer to string conversion
395395
* made by the user.

hal/docs/0002-pinmap-extension.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Some boards have pins which cannot be tested without causing problems elsewhere.
7474
MBED_WEAK const PinList *pinmap_restricted_pins()
7575
{
7676
static const PinName pins[] = {
77-
USBTX, USBRX
77+
CONSOLE_TX, CONSOLE_RX
7878
};
7979
static const PinList pin_list = {
8080
sizeof(pins) / sizeof(pins[0]),

hal/include/hal/PinNameAliases.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@
2121
#define MBED_PIN_NAME_ALIASES_H
2222

2323
/* Aliases for legacy reasons. To be removed in the next Mbed OS version */
24-
#if defined (CONSOLE_TX) && (CONSOLE_RX)
2524
#define USBTX CONSOLE_TX
2625
#define USBRX CONSOLE_RX
27-
#else
28-
#define CONSOLE_TX USBTX
29-
#define CONSOLE_RX USBRX
30-
#endif
3126

3227
#if defined (TARGET_FF_ARDUINO) || (TARGET_FF_ARDUINO_UNO)
3328

hal/include/hal/pinmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ bool pinmap_list_has_peripheral(const PeripheralList *list, int peripheral);
143143
*
144144
* The restricted pin list is used to indicate to testing
145145
* that a pin should be skipped due to some caveat about it.
146-
* For example, using USBRX and USBTX during tests will interfere
146+
* For example, using CONSOLE_RX and CONSOLE_TX during tests will interfere
147147
* with the test runner and should be avoided.
148148
*
149149
* Targets should override the weak implementation of this

targets/TARGET_ARM_FM/TARGET_FVP_MPS2/PeripheralNames.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,23 @@ typedef enum {
7575
PWM_11
7676
} PWMName;
7777

78-
#define STDIO_UART_TX USBTX
79-
#define STDIO_UART_RX USBRX
78+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
79+
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
80+
#else
81+
#define STDIO_UART_TX CONSOLE_TX
82+
#endif
83+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
84+
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
85+
#else
86+
#define STDIO_UART_RX CONSOLE_RX
87+
#endif
8088
#define STDIO_UART UART_0
8189

82-
#define MBED_UART0 USBTX, USBRX
90+
#define MBED_UART0 CONSOLE_TX, CONSOLE_RX
8391
#define MBED_UART1 XB_TX, XB_RX
8492
#define MBED_UART2 SH0_TX, SH0_RX
8593
#define MBED_UART3 SH1_TX, SH1_RX
86-
#define MBED_UARTUSB USBTX, USBRX
94+
#define MBED_UARTUSB CONSOLE_TX, CONSOLE_RX
8795

8896
#ifdef __cplusplus
8997
}

targets/TARGET_ARM_FM/TARGET_FVP_MPS2/PinNames.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ typedef enum {
156156
ADC_SSEL = 653,
157157

158158
//MPS2 Uart
159-
USBTX = 400,
160-
USBRX = 401,
159+
CONSOLE_TX = 400,
160+
CONSOLE_RX = 401,
161161
XB_TX = 402,
162162
XB_RX = 403,
163163
UART_TX2 = 404,

targets/TARGET_ARM_FM/TARGET_FVP_MPS2/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
******************************************************************************/
3232

3333
static const PinMap PinMap_UART_TX[] = {
34-
{USBTX, UART_0, 0},
34+
{CONSOLE_TX, UART_0, 0},
3535
{XB_TX, UART_1, 0},
3636
{SH0_TX, UART_2, 0},
3737
{SH1_TX, UART_3, 0},
3838
{NC, NC, 0}
3939
};
4040

4141
static const PinMap PinMap_UART_RX[] = {
42-
{USBRX, UART_0, 0},
42+
{CONSOLE_RX, UART_0, 0},
4343
{XB_RX, UART_1, 0},
4444
{SH0_RX, UART_2, 0},
4545
{SH1_RX, UART_3, 0},

targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/PinNames.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@
2323
#include "cmsis.h"
2424

2525
/* Pins used by mbed OS to identify STDIO UART pins */
26-
#define STDIO_UART_TX USBTX
27-
#define STDIO_UART_RX USBRX
26+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
27+
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
28+
#else
29+
#define STDIO_UART_TX CONSOLE_TX
30+
#endif
31+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
32+
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
33+
#else
34+
#define STDIO_UART_RX CONSOLE_RX
35+
#endif
2836

2937
#ifdef __cplusplus
3038
extern "C" {
@@ -156,8 +164,8 @@ typedef enum {
156164
/* MPS2 UART */
157165
MCC_TX = 400,
158166
MCC_RX = 401,
159-
USBTX = 402,
160-
USBRX = 403,
167+
CONSOLE_TX = 402,
168+
CONSOLE_RX = 403,
161169
XB_TX = EXP24,
162170
XB_RX = EXP23,
163171
SH0_TX = EXP4,

targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct uart_irq_t {
4141

4242
static const PinMap PinMap_UART_TX[] = {
4343
{MCC_TX, UART_0, 0},
44-
{USBTX, UART_1, 0},
44+
{CONSOLE_TX, UART_1, 0},
4545
{SH0_TX, UART_2, ALTERNATE_FUNC},
4646
{SH1_TX, UART_3, ALTERNATE_FUNC},
4747
{XB_TX, UART_4, ALTERNATE_FUNC},
@@ -50,7 +50,7 @@ static const PinMap PinMap_UART_TX[] = {
5050

5151
static const PinMap PinMap_UART_RX[] = {
5252
{MCC_RX, UART_0, 0},
53-
{USBRX, UART_1, 0},
53+
{CONSOLE_RX, UART_1, 0},
5454
{SH0_RX, UART_2, ALTERNATE_FUNC},
5555
{SH1_RX, UART_3, ALTERNATE_FUNC},
5656
{XB_RX, UART_4, ALTERNATE_FUNC},

targets/TARGET_ARM_SSG/TARGET_MPS2/PeripheralNames.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,23 @@ typedef enum {
7575
PWM_11
7676
} PWMName;
7777

78-
#define STDIO_UART_TX USBTX
79-
#define STDIO_UART_RX USBRX
78+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
79+
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
80+
#else
81+
#define STDIO_UART_TX CONSOLE_TX
82+
#endif
83+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
84+
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
85+
#else
86+
#define STDIO_UART_RX CONSOLE_RX
87+
#endif
8088
#define STDIO_UART UART_0
8189

82-
#define MBED_UART0 USBTX, USBRX
90+
#define MBED_UART0 CONSOLE_TX, CONSOLE_RX
8391
#define MBED_UART1 XB_TX, XB_RX
8492
#define MBED_UART2 SH0_TX, SH0_RX
8593
#define MBED_UART3 SH1_TX, SH1_RX
86-
#define MBED_UARTUSB USBTX, USBRX
94+
#define MBED_UARTUSB CONSOLE_TX, CONSOLE_RX
8795

8896
#ifdef __cplusplus
8997
}

targets/TARGET_ARM_SSG/TARGET_MPS2/PinNames.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,8 @@ typedef enum {
156156
ADC_SSEL = 653,
157157

158158
//MPS2 Uart
159-
USBTX = 400,
160-
USBRX = 401,
159+
CONSOLE_TX = 400,
160+
CONSOLE_RX = 401,
161161
XB_TX = 402,
162162
XB_RX = 403,
163163
UART_TX2 = 404,

targets/TARGET_ARM_SSG/TARGET_MPS2/serial_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@
3131
******************************************************************************/
3232

3333
static const PinMap PinMap_UART_TX[] = {
34-
{USBTX , UART_0, 0},
34+
{CONSOLE_TX , UART_0, 0},
3535
{XB_TX , UART_1, 0},
3636
{SH0_TX , UART_2, 0},
3737
{SH1_TX , UART_3, 0},
3838
{NC , NC , 0}
3939
};
4040

4141
static const PinMap PinMap_UART_RX[] = {
42-
{USBRX , UART_0, 0},
42+
{CONSOLE_RX , UART_0, 0},
4343
{XB_RX , UART_1, 0},
4444
{SH0_RX , UART_2, 0},
4545
{SH1_RX , UART_3, 0},

targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/PeripheralNames.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,20 @@ typedef enum {
3535
I2C_1
3636
} I2CName;
3737

38-
#define STDIO_UART_TX UART1_TX
39-
#define STDIO_UART_RX UART1_RX
38+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
39+
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
40+
#else
41+
#define STDIO_UART_TX UART1_TX
42+
#endif
43+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
44+
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
45+
#else
46+
#define STDIO_UART_RX UART1_RX
47+
#endif
4048
#define STDIO_UART UART_1
4149

42-
#define USBTX STDIO_UART_TX
43-
#define USBRX STDIO_UART_RX
50+
#define CONSOLE_TX STDIO_UART_TX
51+
#define CONSOLE_RX STDIO_UART_RX
4452

4553
#ifdef __cplusplus
4654
}

targets/TARGET_ARM_SSG/TARGET_MUSCA_S1/PeripheralNames.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,20 @@ typedef enum {
3535
I2C_1
3636
} I2CName;
3737

38-
#define STDIO_UART_TX UART1_TX
39-
#define STDIO_UART_RX UART1_RX
38+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
39+
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
40+
#else
41+
#define STDIO_UART_TX UART1_TX
42+
#endif
43+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
44+
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
45+
#else
46+
#define STDIO_UART_RX UART1_RX
47+
#endif
4048
#define STDIO_UART UART_1
4149

42-
#define USBTX STDIO_UART_TX
43-
#define USBRX STDIO_UART_RX
50+
#define CONSOLE_TX STDIO_UART_TX
51+
#define CONSOLE_RX STDIO_UART_RX
4452

4553
#ifdef __cplusplus
4654
}

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS/PinNames.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ typedef enum
101101
// UART
102102
SERIAL_TX = AM_BSP_PRIM_UART_TX_PIN,
103103
SERIAL_RX = AM_BSP_PRIM_UART_RX_PIN,
104-
USBTX = SERIAL_TX,
105-
USBRX = SERIAL_RX,
104+
CONSOLE_TX = SERIAL_TX,
105+
CONSOLE_RX = SERIAL_RX,
106106

107107
SERIAL1_TX = D1,
108108
SERIAL1_RX = D0,
@@ -111,8 +111,16 @@ typedef enum
111111
NC = NC_VAL
112112
} PinName;
113113

114-
#define STDIO_UART_TX USBTX
115-
#define STDIO_UART_RX USBRX
114+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
115+
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
116+
#else
117+
#define STDIO_UART_TX CONSOLE_TX
118+
#endif
119+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
120+
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
121+
#else
122+
#define STDIO_UART_RX CONSOLE_RX
123+
#endif
116124

117125
#ifdef __cplusplus
118126
}

targets/TARGET_Ambiq_Micro/TARGET_Apollo3/TARGET_SFE_ARTEMIS_ATP/PinNames.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ typedef enum
121121
// UART
122122
SERIAL_TX = AM_BSP_PRIM_UART_TX_PIN,
123123
SERIAL_RX = AM_BSP_PRIM_UART_RX_PIN,
124-
USBTX = SERIAL_TX,
125-
USBRX = SERIAL_RX,
124+
CONSOLE_TX = SERIAL_TX,
125+
CONSOLE_RX = SERIAL_RX,
126126

127127
SERIAL1_TX = D24,
128128
SERIAL1_RX = D25,
@@ -131,8 +131,16 @@ typedef enum
131131
NC = NC_VAL
132132
} PinName;
133133

134-
#define STDIO_UART_TX USBTX
135-
#define STDIO_UART_RX USBRX
134+
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
135+
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
136+
#else
137+
#define STDIO_UART_TX CONSOLE_TX
138+
#endif
139+
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
140+
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
141+
#else
142+
#define STDIO_UART_RX CONSOLE_RX
143+
#endif
136144

137145
#ifdef __cplusplus
138146
}

0 commit comments

Comments
 (0)