1.39.18.27 SERCOMx_USART_ErrorGet Function

C

/* x = SERCOM instance number */

/* Blocking, non-blocking and ring buffer mode */

USART_ERROR SERCOMx_USART_ErrorGet( void )

Summary

Gets the error of the given USART peripheral instance.

Description

This function returns the errors associated with the given USART peripheral instance. Multiple error conditions may be active. The function return value should be matched against each member of the USART_ERROR enumeration to handle all error cases. Calling the SERCOMx_USART_Read will clear the errors. Hence error handling must be performed before these functions are called again.

Blocking mode

Calling this API clears the hardware errors

Non-blocking and ring-buffer mode

Error flags are saved in a register and hardware errors are cleared in the Error interrupt handler. Calling this API clears the error flags saved in the register.

Precondition

SERCOMx_USART_Initialize must have been called for the associated USART instance.

Parameters

None.

Returns

Errors occurred as listed by USART_ERROR. This function reports multiple FLEXCOM USART errors if occurred.

Example

if(USART_ERROR_NONE != SERCOM0_USART_ErrorGet())
{
    if (USART_ERROR_OVERRUN & SERCOM0_USART_ErrorGet())
    {
        // Handle overrun error.
    }
    
    if(USART_ERROR_PARITY & SERCOM0_USART_ErrorGet())
    {
        // Handle parity error.
    }
}

Remarks

USART errors are normally associated with the receiver. Hence, it is recommended to use this function in receive context only.