1.1.7.4.6 DRV_SDSPI_SyncRead Function
C
bool DRV_SDSPI_SyncRead ( const DRV_HANDLE handle, void* targetBuffer, uint32_t blockStart, uint32_t nBlock )
Summary
Reads blocks of data from the specified block address of the SD Card.
Description
This function performs a blocking read operation to read blocks of data from the SD Card. The function returns true if the request was successfully executed; returns false otherwise. The function returns false under following conditions:
if the driver handle is invalid
if the target buffer pointer is NULL
if the number of blocks to be read is zero or more than the actual number of blocks available.
Error during the read operation
Precondition
The DRV_SDSPI_Initialize routine must have been called for the specified SDSPI driver instance.
DRV_SDSPI_Open must have been called to obtain a valid opened device handle.
Parameters
Param | Description |
---|---|
handle | A valid open-instance handle, returned from the driver's open function |
targetBuffer | Buffer into which the data read from the SD Card will be placed |
blockStart | Starting block address of the SD Card from where the read should begin. |
nBlock | Total number of blocks to be read. |
Returns
true - If the request was executed successfully.
false - If there was an error executing the request.
Example
#define MY_BUFFER_SIZE 1024 uint8_t CACHE_ALIGN myBuffer[MY_BUFFER_SIZE]; // Address must be block aligned. uint32_t blockStart = 0x00; uint32_t nBlock = 2; // mySDSPIHandle is the handle returned by the DRV_SDSPI_Open function. if (DRV_SDSPI_SyncRead(mySDSPIHandle, myBuffer, blockStart, nBlock) == true) { // Read successful } else { // Error handling here }
Remarks
None.