Skip to content

Commit 9df0c97

Browse files
committed
Review UART_DEBUG definition
By default, UART_DEBUG is linked to Serial generic instance. So it is not required to define it. It could be redefined in the variant.h to print on another instance than Serial Signed-off-by: Frederic.Pillon <frederic.pillon@st.com>
1 parent a698f17 commit 9df0c97

File tree

18 files changed

+13
-35
lines changed

18 files changed

+13
-35
lines changed

cores/arduino/stm32/uart.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,15 @@
5454
extern "C" {
5555
#endif
5656

57+
// if DEBUG_UART is not defined assume this is the one
58+
// linked to PIN_SERIAL_TX
59+
#if !defined(DEBUG_UART)
60+
#if defined(PIN_SERIAL_TX)
61+
#define DEBUG_UART pinmap_peripheral(digitalPinToPinName(PIN_SERIAL_TX), PinMap_UART_TX)
62+
#else
63+
#define DEBUG_UART NP
64+
#endif
65+
#endif
5766
// @brief uart caracteristics
5867
#if defined(STM32F4xx)
5968
#define UART_NUM (10)
@@ -398,11 +407,11 @@ size_t uart_write(serial_t *obj, uint8_t data, uint16_t size)
398407
size_t uart_debug_write(uint8_t *data, uint32_t size)
399408
{
400409
uint8_t index = 0;
410+
USART_TypeDef* dbg_uart = DEBUG_UART;
401411
uint32_t tickstart = HAL_GetTick();
402-
403412
for(index = 0; index < UART_NUM; index++) {
404413
if(uart_handlers[index] != NULL) {
405-
if(DEBUG_UART == uart_handlers[index]->Instance) {
414+
if(dbg_uart == uart_handlers[index]->Instance) {
406415
break;
407416
}
408417
}

variants/DISCO_F100RB/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ enum {
153153
#define TIMER_SERVO TIM17 //TODO: advanced-control timers don't work
154154

155155
// UART Definitions
156-
#define DEBUG_UART ((USART_TypeDef *) USART2)
157-
158156
// Default pin used for 'Serial' instance (ex: ST-Link)
159157
// Mandatory for Firmata
160158
#define PIN_SERIAL_RX 8

variants/DISCO_F407VG/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,6 @@ enum {
178178
#define TIMER_UART_EMULATED TIM6
179179

180180
// UART Definitions
181-
#define DEBUG_UART ((USART_TypeDef *) USART2)
182-
183181
// UART Emulation
184182
#define UART_EMUL_RX PE_9
185183
#define UART_EMUL_TX PE_11

variants/DISCO_F746NG/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@ enum {
110110
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
111111

112112
// UART Definitions
113-
#define DEBUG_UART ((USART_TypeDef *) USART1)
114-
115113
// Default pin used for 'Serial' instance (ex: ST-Link)
116114
// Mandatory for Firmata
117115
#define PIN_SERIAL_RX PB7

variants/DISCO_L475VG_IOT/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ enum {
180180
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
181181

182182
// UART Definitions
183-
#define DEBUG_UART ((USART_TypeDef *) USART1)
184-
185183
// Default pin used for 'Serial' instance (ex: ST-Link)
186184
// Mandatory for Firmata
187185
#define PIN_SERIAL_RX 0

variants/NUCLEO_F030R8/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ enum {
151151
#define TIMER_SERVO TIM3 //TODO: advanced-control timers don't work
152152

153153
// UART Definitions
154-
#define DEBUG_UART ((USART_TypeDef *) USART2)
155-
156154
// Default pin used for 'Serial' instance (ex: ST-Link)
157155
// Mandatory for Firmata
158156
#define PIN_SERIAL_RX 0

variants/NUCLEO_F091RC/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ enum {
150150
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
151151

152152
// UART Definitions
153-
#define DEBUG_UART ((USART_TypeDef *) USART2)
154-
155153
// UART Emulation
156154
#define UART_EMUL_RX PB_14
157155
#define UART_EMUL_TX PB_13

variants/NUCLEO_F103RB/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ enum {
150150
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
151151

152152
// UART Definitions
153-
#define DEBUG_UART ((USART_TypeDef *) USART2)
154-
155153
// Default pin used for 'Serial' instance (ex: ST-Link)
156154
// Mandatory for Firmata
157155
#define PIN_SERIAL_RX 0

variants/NUCLEO_F207ZG/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,6 @@ enum {
195195
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
196196

197197
// UART Definitions
198-
#define DEBUG_UART ((USART_TypeDef *) USART3)
199-
200198
// Default pin used for 'Serial' instance (ex: ST-Link)
201199
// Mandatory for Firmata
202200
#define PIN_SERIAL_RX PD9

variants/NUCLEO_F303RE/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ enum {
150150
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
151151

152152
// UART Definitions
153-
#define DEBUG_UART ((USART_TypeDef *) USART2)
154-
155153
// UART Emulation
156154
#define UART_EMUL_RX PC_1
157155
#define UART_EMUL_TX PC_3

variants/NUCLEO_F401RE/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ enum {
151151
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
152152

153153
// UART Definitions
154-
#define DEBUG_UART ((USART_TypeDef *) USART2)
155-
156154
// UART Emulation
157155
#define UART_EMUL_RX PC_1
158156
#define UART_EMUL_TX PC_3

variants/NUCLEO_F411RE/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ enum {
151151
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
152152

153153
// UART Definitions
154-
#define DEBUG_UART ((USART_TypeDef *) USART2)
155-
156154
// Default pin used for 'Serial' instance (ex: ST-Link)
157155
// Mandatory for Firmata
158156
#define PIN_SERIAL_RX 0

variants/NUCLEO_F429ZI/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ enum {
185185
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
186186

187187
// UART Definitions
188-
#define DEBUG_UART ((USART_TypeDef *) USART3)
189-
190188
// UART Emulation
191189
#define UART_EMUL_RX PF_15
192190
#define UART_EMUL_TX PE_13

variants/NUCLEO_L053R8/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ enum {
150150
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
151151

152152
// UART Definitions
153-
#define DEBUG_UART ((USART_TypeDef *) USART2)
154-
155153
// Default pin used for 'Serial' instance (ex: ST-Link)
156154
// Mandatory for Firmata
157155
#define PIN_SERIAL_RX 0

variants/NUCLEO_L152RE/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ enum {
155155
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
156156

157157
// UART Definitions
158-
#define DEBUG_UART ((USART_TypeDef *) USART2)
159-
160158
// Default pin used for 'Serial' instance (ex: ST-Link)
161159
// Mandatory for Firmata
162160
#define PIN_SERIAL_RX 0

variants/NUCLEO_L432KC/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ enum {
104104
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
105105

106106
// UART Definitions
107-
#define DEBUG_UART ((USART_TypeDef *) USART2)
108-
109107
// Default pin used for 'Serial' instance (ex: ST-Link)
110108
// Mandatory for Firmata
111109
#define PIN_SERIAL_RX PA15

variants/NUCLEO_L476RG/variant.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ enum {
150150
#define TIMER_SERVO TIM2 //TODO: advanced-control timers don't work
151151

152152
// UART Definitions
153-
#define DEBUG_UART ((USART_TypeDef *) USART2)
154-
155153
// UART Emulation
156154
#define UART_EMUL_RX PB_13
157155
#define UART_EMUL_TX PB_14

variants/board_template/variant.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ enum {
107107
#define TIMER_SERVO TIMx //TODO: advanced-control timers don't work
108108

109109
// UART Definitions
110-
#define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3
110+
// DEBUG_UART could be redefined to print on another instance than 'Serial'
111+
//#define DEBUG_UART ((USART_TypeDef *) U(S)ARTX) // ex: USART3
111112

112113
// UART Emulation (uncomment if needed, required TIM1)
113114
//#define UART_EMUL_RX PX_n // PinName used for RX

0 commit comments

Comments
 (0)