Skip to content

Commit 9d7725e

Browse files
committed
refactor(uart): check DEBUG_UART only if serial_debug is not initialized
It prevents to check this each time uart_debug_write is called as init is done once. Signed-off-by: Frederic Pillon <[email protected]>
1 parent 5f53d45 commit 9d7725e

File tree

1 file changed

+4
-3
lines changed
  • libraries/SrcWrapper/src/stm32

1 file changed

+4
-3
lines changed

libraries/SrcWrapper/src/stm32/uart.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -691,10 +691,11 @@ size_t uart_debug_write(uint8_t *data, uint32_t size)
691691
{
692692
uint32_t tickstart = HAL_GetTick();
693693

694-
if (DEBUG_UART == NP) {
695-
return 0;
696-
}
697694
if (serial_debug.index >= UART_NUM) {
695+
if (DEBUG_UART == NP) {
696+
return 0;
697+
}
698+
698699
/* Search if DEBUG_UART already initialized */
699700
for (serial_debug.index = 0; serial_debug.index < UART_NUM; serial_debug.index++) {
700701
if (uart_handlers[serial_debug.index] != NULL) {

0 commit comments

Comments
 (0)