Skip to content

Commit

Permalink
[Driver] add UART read unblock
Browse files Browse the repository at this point in the history
  • Loading branch information
chipweinberger committed Nov 2, 2022
1 parent e411230 commit 5f610a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions components/driver/include/driver/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,17 @@ esp_err_t uart_wait_tx_idle_polling(uart_port_t uart_num);
*/
esp_err_t uart_set_loop_back(uart_port_t uart_num, bool loop_back_en);

/**
* @brief Unblocks uart_read_bytes() if it is currently waiting to receive bytes.
*
* This will cause uart_read_bytes() to return -1 with errno set to EWOULDBLOCK.
*
* @return
* - ESP_OK Success
* - ESP_INVALID_STATE If the Uart driver has not been installed
*/
esp_err_t uart_unblock_reads(uart_port_t uart_num);

/**
* @brief Configure behavior of UART RX timeout interrupt.
*
Expand Down
10 changes: 10 additions & 0 deletions components/driver/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -1797,6 +1797,16 @@ esp_err_t uart_set_loop_back(uart_port_t uart_num, bool loop_back_en)
return ESP_OK;
}

esp_err_t uart_unblock_reads(uart_port_t uart_num)
{
if (p_uart_obj[uart_num]->rx_ring_buf == NULL) {
return ESP_ERR_INVALID_STATE;
}

vRingbufferUnblockRx(pp_uart_obj[uart_num]->rx_ring_buf);
return ESP_OK;
}

void uart_set_always_rx_timeout(uart_port_t uart_num, bool always_rx_timeout)
{
uint16_t rx_tout = uart_hal_get_rx_tout_thr(&(uart_context[uart_num].hal));
Expand Down

0 comments on commit 5f610a0

Please sign in to comment.