1.40.20.4 SERCOMx_USART_WriteFreeBufferCountGet Function

C

/* x = SERCOM instance number */

/* Ring buffer mode */

size_t SERCOMx_USART_WriteFreeBufferCountGet(void)

Summary

Returns the number of bytes of free space available in the internal transmit buffer

Description

This function returns the number of bytes of free space available in the internal transmit buffer

Precondition

SERCOMx_USART_Initialize must have been called for the associated SERCOM_USART instance.

Parameters

None

Returns

The API returns the number of bytes of free space in the transmit buffer. If 9-bit mode is enabled, then the return value indicates the number of 9-bit data that can be copied into the ring buffer.

Example

uint8_t txBuffer[10];

// Check if there is space for writing at-least 10 characters to the transmit buffer
if (SERCOM0_USART_WriteFreeBufferCountGet() >= 10)
{
    SERCOM0_USART_Write((uint8_t*)txBuffer, 10);
}

Remarks

None