1.42.3.6 FLEXCOMx_USART_WriteCallbackRegister Function

C

/* x = FLEXCOM instance number */

/* Non-blocking mode */

void FLEXCOMx_USART_WriteCallbackRegister( FLEXCOM_USART_CALLBACK callback, uintptr_t context )

/* Ring buffer mode */

void FLEXCOMx_USART_WriteCallbackRegister( FLEXCOM_USART_RING_BUFFER_CALLBACK callback, uintptr_t context)

Summary

Sets the pointer to the function (and it's context) to be called when the given USART's write events occur.

Description

This function sets the pointer to a client function to be called "back" when the given USART's write events occur. It also passes a context value (usually a pointer to a context structure) that is passed into the function when it is called.

Precondition

FLEXCOMx_USART_Initialize must have been called for the associated USART instance.

Parameters

Param Description
callback Pointer to the function to be called when the write transfer has completed. Setting this to NULL will disable the callback feature.
context A value (usually a pointer) passed (unused) into the function identified by the callback parameter.

Returns

None.

Example

Non-blocking mode

void usartWriteEventHandler ( uintptr_t context )
{
    if(FLEXCOM0_USART_ErrorGet() != USART_ERROR_NONE)
    {
        //Handle error case
    }
    else
    {
        //Transfer completed successfully
    }
}

FLEXCOM0_USART_WriteCallbackRegister(usartWriteEventHandler, (uintptr_t)NULL);

Ring buffer mode

bool txThresholdEventReceived = false;

void usartWriteEventHandler(FLEXCOM_USART_EVENT event, uintptr_t context )
{
    if (event == FLEXCOM_USART_EVENT_WRITE_THRESHOLD_REACHED)
    {
        txThresholdEventReceived = true;
    }
}

FLEXCOM0_USART_WriteCallbackRegister(usartWriteEventHandler, (uintptr_t)NULL);

Remarks

None