1.4.21.36 SERCOM_USART_CALLBACK Typedef

C

/* Non-blocking mode */

typedef void (*SERCOM_USART_CALLBACK)( uintptr_t context );

Summary

Defines the data type and function signature of the USART peripheral library callback function.

Description

This data type defines the function signature of the USART peripheral callback function. The USART peripheral will call back the client's function with this signature to notify the application when a transfer has completed or when a transfer error has occured.

Precondition

SERCOMx_USART_Initialize must have been called for the given USART peripheral instance and SERCOMx_USART_CallbackRegister must have been called to set the function to be called.

Parameters

Param Description
context Allows the caller to provide a context value (usually a pointer tothe callers context for multi-instance clients).

Returns

None.

Example

// Data tracking what each of my instances is doing.
MY_DATA myData[2];

void MyUsartReadCallback(uintptr_t context)
{
    // This function will be called when a USART read has completed.
}

void MyUsartWriteCallback(uintptr_t context)
{
    // This function will be called when a USART write has completed.
}

SERCOM0_USART_ReadCallbackRegister(MyUsartReadCallback, &myData[0]);
SERCOM0_USART_WriteCallbackRegister(MyUsartWriteCallback, &myData[1]);

Remarks

Code within the callback function will execute in an interrupt context. The application should avoid calling hardware blocking functions or interrupt in-sensitive code in this function.