esp_pm: fix garbage on UART when CONFIG_PM_ENABLE=y

`uart_ll_get_txfifo_len` returns the number of bytes available in the
TX FIFO; The condition we need is "FIFO empty", not "FIFO has free
space". `uart_ll_is_tx_idle` does that, and also ensures that the last
character popped from the TX FIFO has been fully transmitted.
This commit is contained in:
Ivan Grokhotkov 2020-10-14 19:35:24 +02:00
parent b1ace5808d
commit 50ef2f97d6

View File

@ -680,7 +680,7 @@ void esp_pm_impl_dump_stats(FILE* out)
void esp_pm_impl_init(void)
{
#if defined(CONFIG_ESP_CONSOLE_UART)
while(!uart_ll_get_txfifo_len(UART_LL_GET_HW(CONFIG_ESP_CONSOLE_UART_NUM)));
while(!uart_ll_is_tx_idle(UART_LL_GET_HW(CONFIG_ESP_CONSOLE_UART_NUM)));
/* When DFS is enabled, override system setting and use REFTICK as UART clock source */
uart_ll_set_baudrate(UART_LL_GET_HW(CONFIG_ESP_CONSOLE_UART_NUM), UART_SCLK_REF_TICK, CONFIG_ESP_CONSOLE_UART_BAUDRATE);
#endif // CONFIG_ESP_CONSOLE_UART