1.2.21.5 1.3.25.5 1.4.21.5 1.5.25.5 1.6.22.5 1.7.23.5 1.9.19.5 1.29.23.5 1.30.18.5 1.31.18.5 1.32.26.5 1.33.16.5 1.37.18.5 1.38.21.5 1.39.18.5 1.40.20.5 SERCOMx_USART_WriteCountGet Function

C

/* x = SERCOM instance number */

/* Non-blocking and ring buffer mode */

size_t SERCOMx_USART_WriteCountGet( void )

Summary

Non-blocking mode

Gets the byte count of processed bytes for a given USART write operation

Ring buffer mode

Returns the number of bytes pending to be transmitted out in the transmit buffer.

Description

Non-blocking mode

This function gets the count of processed bytes for an on-going or last completed USART Transmit operation. This function can be used to track the progress of the non-blocking transmit operation.

Ring buffer mode

This function returns the number of bytes of data pending for transmission.

Precondition

SERCOMx_USART_Initialize must have been called for the associated USART instance.

Parameters

None.

Returns

Non-blocking mode

Returns count of bytes currently completed/processed from the current Transmit buffer for interrupt non-blocking mode. In 9-bit mode, it returns the number of 9-bit data processed.

Ring buffer mode

The API returns the number of bytes that are pending for transmission in the internal transmit buffer. If 9-bit mode is enabled, then the return value indicates the number of 9-bit data pending transmission.

Example

Non-blocking mode

size_t count;

count = SERCOM0_USART_WriteCountGet();

if(count < COUNT_EXPECTED)
{
    //More bytes are expected to transmit, wait
}

Ring buffer mode

if (SERCOM0_USART_WriteCountGet() == 0)
{
    // All the data has been transmitted out.
}

Remarks

None