Skip to content

Commit bccdb75

Browse files
authored
fix(uart): prevent deinitializing another UART
If called from an uninitialized HardwareSerial, the code unintentionally deinit the UART at uart_handlers[0]
1 parent 227cec0 commit bccdb75

File tree

1 file changed

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

1 file changed

+3
-0
lines changed

libraries/SrcWrapper/src/stm32/uart.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,9 @@ bool uart_init(serial_t *obj, uint32_t baudrate, uint32_t databits, uint32_t par
594594
*/
595595
void uart_deinit(serial_t *obj)
596596
{
597+
/* Prevent deinitializing another UART in case this has not been initialized */
598+
if (!obj->uart) return;
599+
597600
/* Reset UART and disable clock */
598601
switch (obj->index) {
599602
#if defined(USART1_BASE)

0 commit comments

Comments
 (0)