1.1.9.4.11 DRV_USART_BufferStatusGet Function

C

DRV_USART_BUFFER_EVENT DRV_USART_BufferStatusGet
(
    const DRV_USART_BUFFER_HANDLE bufferHandle
)

Summary

Returns the transmit/receive request status.

Description

This function can be used to poll the status of the queued buffer request if the application doesn't prefer to use the event handler (callback) function to get notified.

Precondition

DRV_USART_Open must have been called to obtain a valid opened device handle. Either the DRV_USART_ReadBufferAdd or DRV_USART_WriteBufferAdd function must have been called and a valid buffer handle returned.

Parameters

ParamDescription
bufferhandleHandle for the buffer of which the processed number of bytes to be obtained.

Returns

Returns either pending, success or error event for the buffer. Pending means the buffer is queued but not serviced yet.

Example

// myAppObj is an application specific object.
MY_APP_OBJ myAppObj;

uint8_t mybuffer[MY_BUFFER_SIZE];
DRV_USART_BUFFER_HANDLE bufferHandle;
DRV_USART_BUFFER_EVENT event;

// myUSARTHandle is the handle returned
// by the DRV_USART_Open function.

DRV_USART_ReadBufferAdd(
    myUSARThandle,
    myBuffer,
    MY_BUFFER_SIZE,
    bufferHandle
);

if(bufferHandle == DRV_USART_BUFFER_HANDLE_INVALID)
{
    // Error handling here
}

//Check the status of the buffer
//This call can be used to wait until the buffer is processed.

while ((event = DRV_USART_BufferStatusGet(bufferHandle)) == DRV_USART_BUFFER_EVENT_PENDING);

//Buffer is processed, check the event variable to determine if the buffer request
//is executed successfully or not.

Remarks

This function returns error event if the buffer handle is invalid.