Skip to content

Update UART pin names & add MBED_CONF_TARGET_STDIO_UART overrides #14457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion TEST_APPS/device/nanostack_mac_tester/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#endif

extern mac_api_s *mac_interface;
UnbufferedSerial pc(USBTX, USBRX);
UnbufferedSerial pc(CONSOLE_TX, CONSOLE_RX);
osThreadId_t main_thread;
static CircularBuffer<uint8_t, RX_BUFFER_SIZE> rx_buffer;
static uint8_t ns_heap[HEAP_FOR_MAC_TESTER_SIZE];
Expand Down
2 changes: 1 addition & 1 deletion drivers/docs/serial/serial.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Other alternatives to printing to stdout are by calling `puts` or `write`.
puts("Hello");
```
```C
BufferedSerial pc(USBTX, USBRX);
BufferedSerial pc(CONSOLE_TX, CONSOLE_RX);
pc.write("Hello", 6);
```

Expand Down
2 changes: 1 addition & 1 deletion drivers/tests/TESTS/mbed_drivers/buffered_serial/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ using namespace utest::v1;


static BufferedSerial buffered_serial_obj(
USBTX, USBRX, MBED_CONF_PLATFORM_STDIO_BAUD_RATE
CONSOLE_TX, CONSOLE_RX, MBED_CONF_PLATFORM_STDIO_BAUD_RATE
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using namespace utest::v1;


static UnbufferedSerial unbuffered_serial_obj(
USBTX, USBRX, MBED_CONF_PLATFORM_STDIO_BAUD_RATE
CONSOLE_TX, CONSOLE_RX, MBED_CONF_PLATFORM_STDIO_BAUD_RATE
);

static ssize_t unbuffered_serial_read(void *buffer, ssize_t length)
Expand Down
10 changes: 5 additions & 5 deletions features/frameworks/greentea-client/source/greentea_test_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ static void greentea_write_int(const int val)
* \brief Encapsulate and send key-value message from DUT to host
*
* This function uses underlying functions to write directly
* to the serial port, (USBTX). This allows KVs to be used
* to the serial port, (CONSOLE_TX). This allows KVs to be used
* from within interrupt context.
*
* \param key Message key (message/event name)
Expand All @@ -305,7 +305,7 @@ extern "C" void greentea_send_kv(const char *key, const char *val) {
* \brief Encapsulate and send key-value message from DUT to host
*
* This function uses underlying functions to write directly
* to the serial port, (USBTX). This allows KVs to be used
* to the serial port, (CONSOLE_TX). This allows KVs to be used
* from within interrupt context.
* Last value is an integer to avoid integer to string conversion
* made by the user.
Expand All @@ -328,7 +328,7 @@ void greentea_send_kv(const char *key, const int val) {
* \brief Encapsulate and send key-value-value message from DUT to host
*
* This function uses underlying functions to write directly
* to the serial port, (USBTX). This allows KVs to be used
* to the serial port, (CONSOLE_TX). This allows KVs to be used
* from within interrupt context.
* Last value is an integer to avoid integer to string conversion
* made by the user.
Expand All @@ -355,7 +355,7 @@ void greentea_send_kv(const char *key, const char *val, const int result) {
* \brief Encapsulate and send key-value-value-value message from DUT to host
*
* This function uses underlying functions to write directly
* to the serial port, (USBTX). This allows KVs to be used
* to the serial port, (CONSOLE_TX). This allows KVs to be used
* from within interrupt context.
* Last 2 values are integers to avoid integer to string conversion
* made by the user.
Expand Down Expand Up @@ -389,7 +389,7 @@ void greentea_send_kv(const char *key, const char *val, const int passes, const
* \brief Encapsulate and send key-value-value message from DUT to host
*
* This function uses underlying functions to write directly
* to the serial port, (USBTX). This allows key-value-value to be used
* to the serial port, (CONSOLE_TX). This allows key-value-value to be used
* from within interrupt context.
* Both values are integers to avoid integer to string conversion
* made by the user.
Expand Down
2 changes: 1 addition & 1 deletion hal/docs/0002-pinmap-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Some boards have pins which cannot be tested without causing problems elsewhere.
MBED_WEAK const PinList *pinmap_restricted_pins()
{
static const PinName pins[] = {
USBTX, USBRX
CONSOLE_TX, CONSOLE_RX
};
static const PinList pin_list = {
sizeof(pins) / sizeof(pins[0]),
Expand Down
5 changes: 0 additions & 5 deletions hal/include/hal/PinNameAliases.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@
#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)

Expand Down
2 changes: 1 addition & 1 deletion hal/include/hal/pinmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ bool pinmap_list_has_peripheral(const PeripheralList *list, int peripheral);
*
* The restricted pin list is used to indicate to testing
* that a pin should be skipped due to some caveat about it.
* For example, using USBRX and USBTX during tests will interfere
* For example, using CONSOLE_RX and CONSOLE_TX during tests will interfere
* with the test runner and should be avoided.
*
* Targets should override the weak implementation of this
Expand Down
16 changes: 12 additions & 4 deletions targets/TARGET_ARM_FM/TARGET_FVP_MPS2/PeripheralNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,23 @@ typedef enum {
PWM_11
} PWMName;

#define STDIO_UART_TX USBTX
#define STDIO_UART_RX USBRX
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
#else
#define STDIO_UART_TX CONSOLE_TX
#endif
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
#else
#define STDIO_UART_RX CONSOLE_RX
#endif
#define STDIO_UART UART_0

#define MBED_UART0 USBTX, USBRX
#define MBED_UART0 CONSOLE_TX, CONSOLE_RX
#define MBED_UART1 XB_TX, XB_RX
#define MBED_UART2 SH0_TX, SH0_RX
#define MBED_UART3 SH1_TX, SH1_RX
#define MBED_UARTUSB USBTX, USBRX
#define MBED_UARTUSB CONSOLE_TX, CONSOLE_RX

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions targets/TARGET_ARM_FM/TARGET_FVP_MPS2/PinNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ typedef enum {
ADC_SSEL = 653,

//MPS2 Uart
USBTX = 400,
USBRX = 401,
CONSOLE_TX = 400,
CONSOLE_RX = 401,
XB_TX = 402,
XB_RX = 403,
UART_TX2 = 404,
Expand Down
4 changes: 2 additions & 2 deletions targets/TARGET_ARM_FM/TARGET_FVP_MPS2/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
******************************************************************************/

static const PinMap PinMap_UART_TX[] = {
{USBTX, UART_0, 0},
{CONSOLE_TX, UART_0, 0},
{XB_TX, UART_1, 0},
{SH0_TX, UART_2, 0},
{SH1_TX, UART_3, 0},
{NC, NC, 0}
};

static const PinMap PinMap_UART_RX[] = {
{USBRX, UART_0, 0},
{CONSOLE_RX, UART_0, 0},
{XB_RX, UART_1, 0},
{SH0_RX, UART_2, 0},
{SH1_RX, UART_3, 0},
Expand Down
16 changes: 12 additions & 4 deletions targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/PinNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@
#include "cmsis.h"

/* Pins used by mbed OS to identify STDIO UART pins */
#define STDIO_UART_TX USBTX
#define STDIO_UART_RX USBRX
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
#else
#define STDIO_UART_TX CONSOLE_TX
#endif
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
#else
#define STDIO_UART_RX CONSOLE_RX
#endif

#ifdef __cplusplus
extern "C" {
Expand Down Expand Up @@ -156,8 +164,8 @@ typedef enum {
/* MPS2 UART */
MCC_TX = 400,
MCC_RX = 401,
USBTX = 402,
USBRX = 403,
CONSOLE_TX = 402,
CONSOLE_RX = 403,
XB_TX = EXP24,
XB_RX = EXP23,
SH0_TX = EXP4,
Expand Down
4 changes: 2 additions & 2 deletions targets/TARGET_ARM_SSG/TARGET_CM3DS_MPS2/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct uart_irq_t {

static const PinMap PinMap_UART_TX[] = {
{MCC_TX, UART_0, 0},
{USBTX, UART_1, 0},
{CONSOLE_TX, UART_1, 0},
{SH0_TX, UART_2, ALTERNATE_FUNC},
{SH1_TX, UART_3, ALTERNATE_FUNC},
{XB_TX, UART_4, ALTERNATE_FUNC},
Expand All @@ -50,7 +50,7 @@ static const PinMap PinMap_UART_TX[] = {

static const PinMap PinMap_UART_RX[] = {
{MCC_RX, UART_0, 0},
{USBRX, UART_1, 0},
{CONSOLE_RX, UART_1, 0},
{SH0_RX, UART_2, ALTERNATE_FUNC},
{SH1_RX, UART_3, ALTERNATE_FUNC},
{XB_RX, UART_4, ALTERNATE_FUNC},
Expand Down
16 changes: 12 additions & 4 deletions targets/TARGET_ARM_SSG/TARGET_MPS2/PeripheralNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,23 @@ typedef enum {
PWM_11
} PWMName;

#define STDIO_UART_TX USBTX
#define STDIO_UART_RX USBRX
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
#else
#define STDIO_UART_TX CONSOLE_TX
#endif
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
#else
#define STDIO_UART_RX CONSOLE_RX
#endif
#define STDIO_UART UART_0

#define MBED_UART0 USBTX, USBRX
#define MBED_UART0 CONSOLE_TX, CONSOLE_RX
#define MBED_UART1 XB_TX, XB_RX
#define MBED_UART2 SH0_TX, SH0_RX
#define MBED_UART3 SH1_TX, SH1_RX
#define MBED_UARTUSB USBTX, USBRX
#define MBED_UARTUSB CONSOLE_TX, CONSOLE_RX

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions targets/TARGET_ARM_SSG/TARGET_MPS2/PinNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ typedef enum {
ADC_SSEL = 653,

//MPS2 Uart
USBTX = 400,
USBRX = 401,
CONSOLE_TX = 400,
CONSOLE_RX = 401,
XB_TX = 402,
XB_RX = 403,
UART_TX2 = 404,
Expand Down
4 changes: 2 additions & 2 deletions targets/TARGET_ARM_SSG/TARGET_MPS2/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
******************************************************************************/

static const PinMap PinMap_UART_TX[] = {
{USBTX , UART_0, 0},
{CONSOLE_TX , UART_0, 0},
{XB_TX , UART_1, 0},
{SH0_TX , UART_2, 0},
{SH1_TX , UART_3, 0},
{NC , NC , 0}
};

static const PinMap PinMap_UART_RX[] = {
{USBRX , UART_0, 0},
{CONSOLE_RX , UART_0, 0},
{XB_RX , UART_1, 0},
{SH0_RX , UART_2, 0},
{SH1_RX , UART_3, 0},
Expand Down
16 changes: 12 additions & 4 deletions targets/TARGET_ARM_SSG/TARGET_MUSCA_B1/PeripheralNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,20 @@ typedef enum {
I2C_1
} I2CName;

#define STDIO_UART_TX UART1_TX
#define STDIO_UART_RX UART1_RX
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
#else
#define STDIO_UART_TX UART1_TX
#endif
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
#else
#define STDIO_UART_RX UART1_RX
#endif
#define STDIO_UART UART_1

#define USBTX STDIO_UART_TX
#define USBRX STDIO_UART_RX
#define CONSOLE_TX STDIO_UART_TX
#define CONSOLE_RX STDIO_UART_RX

#ifdef __cplusplus
}
Expand Down
16 changes: 12 additions & 4 deletions targets/TARGET_ARM_SSG/TARGET_MUSCA_S1/PeripheralNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,20 @@ typedef enum {
I2C_1
} I2CName;

#define STDIO_UART_TX UART1_TX
#define STDIO_UART_RX UART1_RX
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
#else
#define STDIO_UART_TX UART1_TX
#endif
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
#else
#define STDIO_UART_RX UART1_RX
#endif
#define STDIO_UART UART_1

#define USBTX STDIO_UART_TX
#define USBRX STDIO_UART_RX
#define CONSOLE_TX STDIO_UART_TX
#define CONSOLE_RX STDIO_UART_RX

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ typedef enum
// UART
SERIAL_TX = AM_BSP_PRIM_UART_TX_PIN,
SERIAL_RX = AM_BSP_PRIM_UART_RX_PIN,
USBTX = SERIAL_TX,
USBRX = SERIAL_RX,
CONSOLE_TX = SERIAL_TX,
CONSOLE_RX = SERIAL_RX,

SERIAL1_TX = D1,
SERIAL1_RX = D0,
Expand All @@ -111,8 +111,16 @@ typedef enum
NC = NC_VAL
} PinName;

#define STDIO_UART_TX USBTX
#define STDIO_UART_RX USBRX
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
#else
#define STDIO_UART_TX CONSOLE_TX
#endif
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
#else
#define STDIO_UART_RX CONSOLE_RX
#endif

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ typedef enum
// UART
SERIAL_TX = AM_BSP_PRIM_UART_TX_PIN,
SERIAL_RX = AM_BSP_PRIM_UART_RX_PIN,
USBTX = SERIAL_TX,
USBRX = SERIAL_RX,
CONSOLE_TX = SERIAL_TX,
CONSOLE_RX = SERIAL_RX,

SERIAL1_TX = D24,
SERIAL1_RX = D25,
Expand All @@ -131,8 +131,16 @@ typedef enum
NC = NC_VAL
} PinName;

#define STDIO_UART_TX USBTX
#define STDIO_UART_RX USBRX
#if defined(MBED_CONF_TARGET_STDIO_UART_TX)
#define STDIO_UART_TX MBED_CONF_TARGET_STDIO_UART_TX
#else
#define STDIO_UART_TX CONSOLE_TX
#endif
#if defined(MBED_CONF_TARGET_STDIO_UART_RX)
#define STDIO_UART_RX MBED_CONF_TARGET_STDIO_UART_RX
#else
#define STDIO_UART_RX CONSOLE_RX
#endif

#ifdef __cplusplus
}
Expand Down
Loading