Skip to content

Commit bdf89b4

Browse files
committed
uartEnd: Unlock mutex before detaching rx and tx
This should solve the device freezing issue when Serial.end() is called
1 parent 9618eec commit bdf89b4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

cores/esp32/esp32-hal-uart.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx
197197
uart->dev->conf0.val = config;
198198
#define TWO_STOP_BITS_CONF 0x3
199199
#define ONE_STOP_BITS_CONF 0x1
200-
200+
201201
if ( uart->dev->conf0.stop_bit_num == TWO_STOP_BITS_CONF) {
202202
uart->dev->conf0.stop_bit_num = ONE_STOP_BITS_CONF;
203203
uart->dev->rs485_conf.dl1_en = 1;
@@ -227,12 +227,12 @@ void uartEnd(uart_t* uart)
227227
while(xQueueReceive(uart->queue, &c, 0));
228228
vQueueDelete(uart->queue);
229229
}
230+
UART_MUTEX_UNLOCK();
230231

231232
uartDetachRx(uart);
232233
uartDetachTx(uart);
233234

234235
uart->dev->conf0.val = 0;
235-
UART_MUTEX_UNLOCK();
236236
}
237237

238238
uint32_t uartAvailable(uart_t* uart)
@@ -419,4 +419,3 @@ int log_printf(const char *format, ...)
419419
}
420420
return len;
421421
}
422-

0 commit comments

Comments
 (0)