Possible to check UART0 Tx buffer empty before light sleep?
Possible to check UART0 Tx buffer empty before light sleep?
A call to esp_light_sleep_start(), immediately stops UART0 output, this can have a number of undesirable consequences. Is there any way to check whether the Tx buffer empty status so you can delay sleep entry until UART output is finished? I didn't see anything in the HardwareSerial class. If not, is there a recommended workaround? Thanks!
-
- Posts: 828
- Joined: Mon Jul 22, 2019 3:20 pm
Re: Possible to check UART0 Tx buffer empty before light sleep?
HardwareSerial::flush() will block until the uart queue is cleared.
Re: Possible to check UART0 Tx buffer empty before light sleep?
Thanks @lbernstone, that is indeed a good workaround in many cases. I was (and still am) hoping to find a non-blocking solution; the flush code eventually gets to this:
I'll check to see if it's feasible to grab the mutex lock and call uart_ll_is_tx_idle() externally.
Code: Select all
UART_MUTEX_LOCK();
while(!uart_ll_is_tx_idle(UART_LL_GET_HW(uart->num)));
if ( !txOnly ) {
ESP_ERROR_CHECK(uart_flush_input(uart->num));
}
UART_MUTEX_UNLOCK();
Who is online
Users browsing this forum: No registered users and 153 guests