Skip to content

Commit cf69cf1

Browse files
committed
fix: core: uart: add missing half duplex init
Signed-off-by: Frederic Pillon <frederic.pillon@st.com>
1 parent 8a9fffb commit cf69cf1

File tree

1 file changed

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

1 file changed

+15
-3
lines changed

libraries/SrcWrapper/src/stm32/uart.c

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,11 @@ void uart_init(serial_t *obj, uint32_t baudrate, uint32_t databits, uint32_t par
334334
HAL_UARTEx_DisableStopMode(huart);
335335
}
336336
/* Trying default LPUART clock source */
337-
if (HAL_UART_Init(huart) == HAL_OK) {
337+
if (uart_rx == NP) {
338+
if (HAL_HalfDuplex_Init(huart) != HAL_OK) {
339+
return;
340+
}
341+
} else if (HAL_UART_Init(huart) != HAL_OK) {
338342
return;
339343
}
340344
/* Trying to change LPUART clock source */
@@ -363,7 +367,11 @@ void uart_init(serial_t *obj, uint32_t baudrate, uint32_t databits, uint32_t par
363367
__HAL_RCC_LPUART2_CONFIG(RCC_LPUART2CLKSOURCE_HSI);
364368
}
365369
#endif
366-
if (HAL_UART_Init(huart) == HAL_OK) {
370+
if (uart_rx == NP) {
371+
if (HAL_HalfDuplex_Init(huart) != HAL_OK) {
372+
return;
373+
}
374+
} else if (HAL_UART_Init(huart) != HAL_OK) {
367375
return;
368376
}
369377
}
@@ -381,7 +389,11 @@ void uart_init(serial_t *obj, uint32_t baudrate, uint32_t databits, uint32_t par
381389
__HAL_RCC_LPUART2_CONFIG(RCC_LPUART2CLKSOURCE_PCLK1);
382390
}
383391
#endif
384-
if (HAL_UART_Init(huart) == HAL_OK) {
392+
if (uart_rx == NP) {
393+
if (HAL_HalfDuplex_Init(huart) != HAL_OK) {
394+
return;
395+
}
396+
} else if (HAL_UART_Init(huart) != HAL_OK) {
385397
return;
386398
}
387399
#if defined(RCC_LPUART1CLKSOURCE_SYSCLK)

0 commit comments

Comments
 (0)