1.1.9.4.16 DRV_USART_ReadBuffer Function
C
bool DRV_USART_ReadBuffer ( const DRV_HANDLE handle, void* buffer, const size_t size );
Summary
This is a blocking function that reads data over USART.
Description
This function does a blocking read operation. The function blocks till the data read is complete or error has occurred during read. Function will return false to report failure. The failure will occur for the following reasons:
if the handle is invalid
if the input buffer pointer is NULL
if the buffer size is 0
Hardware errors
Precondition
DRV_USART_Open must have been called to obtain a valid opened device handle.
Parameters
Param | Description |
---|---|
handle | Handle of the communication channel as return by the DRV_USART_Open function. |
buffer | Pointer to the receive buffer. |
size | Buffer size in bytes. |
Returns
true - read is successful
false - error has occurred
Example
MY_APP_OBJ myAppObj; uint8_t myBuffer[MY_BUFFER_SIZE]; // myUSARTHandle is the handle returned // by the DRV_USART_Open function. if (DRV_USART_ReadBuffer(myUSARTHandle, myBuffer, MY_BUFFER_SIZE) == false) { // Error handling here }
Remarks
This function is thread safe in a RTOS application. This function should not be called from an interrupt context.