Skip to content

Commit

Permalink
Merge branch 'bugfix/uart_wait_idle' into 'master'
Browse files Browse the repository at this point in the history
uart: fix uart_tx_wait_idle to wait for fifo empty

See merge request idf/esp-idf!3489
  • Loading branch information
igrr committed Oct 18, 2018
2 parents 9b566a8 + 508fb79 commit 18684f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions components/esp32/include/rom/uart.h
Expand Up @@ -267,9 +267,11 @@ void uart_tx_flush(uint8_t uart_no);
* here for compatibility.
*/
static inline void IRAM_ATTR uart_tx_wait_idle(uint8_t uart_no) {
while(REG_GET_FIELD(UART_STATUS_REG(uart_no), UART_ST_UTX_OUT)) {
;
}
uint32_t status;
do {
status = READ_PERI_REG(UART_STATUS_REG(uart_no));
/* either tx count or state is non-zero */
} while ((status & (UART_ST_UTX_OUT_M | UART_TXFIFO_CNT_M)) != 0);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion components/esp32/sleep_modes.c
Expand Up @@ -159,7 +159,9 @@ static void IRAM_ATTR suspend_uarts()
{
for (int i = 0; i < 3; ++i) {
REG_SET_BIT(UART_FLOW_CONF_REG(i), UART_FORCE_XOFF);
uart_tx_wait_idle(i);
while (REG_GET_FIELD(UART_STATUS_REG(i), UART_ST_UTX_OUT) != 0) {
;
}
}
}

Expand Down

0 comments on commit 18684f5

Please sign in to comment.