Skip to content

Commit

Permalink
cpu/stm32_common/uart: Prevent uart from sending if not initialized
Browse files Browse the repository at this point in the history
Due to the stdio getting called after periph_init the uart may send before initialized.
This adds a simple check so the uart does not get into a locked-up state.
  • Loading branch information
MrKevinWeiss committed Dec 17, 2018
1 parent 5c4b398 commit be497c2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cpu/stm32_common/periph/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ static inline void wait_for_tx_complete(uart_t uart)
void uart_write(uart_t uart, const uint8_t *data, size_t len)
{
assert(uart < UART_NUMOF);

#if defined(DEVELHELP)
/* If tx is not enabled don't try to send */
if (!(dev(uart)->CR1 & USART_CR1_TE)) {
return;
}
#endif
#ifdef MODULE_PERIPH_DMA
if (!len) {
return;
Expand Down

0 comments on commit be497c2

Please sign in to comment.