Getting current transmit status of the UART driver

xgaroux
Posts: 4
Joined: Mon Oct 12, 2020 12:44 pm

Getting current transmit status of the UART driver

Postby xgaroux » Fri Apr 23, 2021 3:37 pm

Hi! I'm trying to figure out if there is a way to get current transmit status of UART driver?

I found a function in the HAL that fully matches my question:

Code: Select all

#define uart_hal_is_tx_idle(hal)  uart_ll_is_tx_idle((hal)->dev)
But it use only in block waiting for the transmission ends and internal ISR routine. May be there are some macros or any other API I missed? Is there a way to use it without breaking library hierarchy and jumping to HAL from my code?

Also I can't understand using of this API - FIFO space threshold or transmission timeout reached:

Code: Select all

uart_intr_config(), uart_enable_tx_intr()
I can configurate this interrupts, but no functions to use this interrupts or callbacks for it. How work with it? In case when I don't register a custom lower level interrupt handler using

Code: Select all

uart_isr_register()
Thanks in advance, Michael.

fevang
Posts: 6
Joined: Thu Jun 04, 2020 7:11 pm

Re: Getting current transmit status of the UART driver

Postby fevang » Wed Apr 28, 2021 12:13 am

You might be able to call

Code: Select all

/**
 * @brief Wait until UART TX FIFO is empty.
 *
 * @param uart_num      UART port number, the max port number is (UART_NUM_MAX -1).
 * @param ticks_to_wait Timeout, count in RTOS ticks
 *
 * @return
 *     - ESP_OK   Success
 *     - ESP_FAIL Parameter error
 *     - ESP_ERR_TIMEOUT  Timeout
 */
esp_err_t uart_wait_tx_done(uart_port_t uart_num, TickType_t ticks_to_wait);
with ticks_to_wait = 0, and check the return value.
If it returns ESP_ERR_TIMEOUT, then you know a transmission is happening.

For example

Code: Select all

if(uart_wait_tx_done(UART_NUM_1, 0) == ESP_ERR_TIMEOUT){
	// Transaction is currently taking place
}

xgaroux
Posts: 4
Joined: Mon Oct 12, 2020 12:44 pm

Re: Getting current transmit status of the UART driver

Postby xgaroux » Mon May 10, 2021 6:19 pm

fevang wrote: You might be able to call

Code: Select all

/**
 * @brief Wait until UART TX FIFO is empty.
 *
 * @param uart_num      UART port number, the max port number is (UART_NUM_MAX -1).
 * @param ticks_to_wait Timeout, count in RTOS ticks
 *
 * @return
 *     - ESP_OK   Success
 *     - ESP_FAIL Parameter error
 *     - ESP_ERR_TIMEOUT  Timeout
 */
esp_err_t uart_wait_tx_done(uart_port_t uart_num, TickType_t ticks_to_wait);
with ticks_to_wait = 0, and check the return value.
If it returns ESP_ERR_TIMEOUT, then you know a transmission is happening.
Thank you for your reply! I missed such a simple opportunity to solve my problem with transmit status.

But the second part of my question (FIFO space threshold API) is still not clear...

Who is online

Users browsing this forum: Bing [Bot] and 139 guests