1.1.8.4.13 DRV_SPI_ReadTransfer Function
C
void DRV_SPI_ReadTransfer ( const DRV_HANDLE handle, void* pReceiveData, size_t rxSize );
Summary
This is a blocking function that receives data over SPI.
Description
This function does a blocking read operation. The function blocks till the data receive is complete. Function will return true if the receive is successful or false in case of an error. The failure will occur for the following reasons:
if the handle is invalid
if the pointer to the receive buffer is NULL
if the receive size is 0
Precondition
DRV_SPI_Open must have been called to obtain a valid opened device handle.
DRV_SPI_TransferSetup must have been called if GPIO pin has to be used for
chip select or any of the setup parameters has to be changed dynamically.
Parameters
Param | Description |
---|---|
handle | Handle of the communication channel as returned by the DRV_SPI_Open function. |
*pReceiveData | Pointer to the buffer where the data is to be received. |
rxSize | Number of bytes to be received. The size must be specified in terms of the SPI data width. For example, if the data width is 8-bits, and if 10 bytes are being received, then the rxSize must be set to 10. If the data width is 16-bits then receiving 10 bytes requires specifying the rxSize as 10 (meaning 10 16-bit words). |
Returns
true - receive is successful
false - error has occurred
Example
MY_APP_OBJ myAppObj; uint8_t myRxBuffer[MY_RX_BUFFER_SIZE]; // mySPIHandle is the handle returned by the DRV_SPI_Open function. if (DRV_SPI_ReadTransfer(mySPIhandle, myRxBuffer, MY_RX_BUFFER_SIZE) == false) { // Handle error here }
Remarks
This function is thread safe in a RTOS application.
This function should not be called from an interrupt context.