Skip to content

Commit 41e36a7

Browse files
Raienryu97me-no-dev
authored andcommitted
uartEnd: Unlock mutex before detaching rx and tx (espressif#554)
* uartEnd: Unlock mutex before detaching rx and tx This should solve the device freezing issue when Serial.end() is called * Unlock UART MUTEX only for detaching Rx and Tx * Thanks to @me-no-dev for pointing it out that uart->dev->conf0.val can be inside mutex lock
1 parent 9618eec commit 41e36a7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

cores/esp32/esp32-hal-uart.c

+5-5
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;
@@ -228,11 +228,12 @@ void uartEnd(uart_t* uart)
228228
vQueueDelete(uart->queue);
229229
}
230230

231-
uartDetachRx(uart);
232-
uartDetachTx(uart);
233-
234231
uart->dev->conf0.val = 0;
232+
235233
UART_MUTEX_UNLOCK();
234+
235+
uartDetachRx(uart);
236+
uartDetachTx(uart);
236237
}
237238

238239
uint32_t uartAvailable(uart_t* uart)
@@ -419,4 +420,3 @@ int log_printf(const char *format, ...)
419420
}
420421
return len;
421422
}
422-

0 commit comments

Comments
 (0)