1.1.7.4.8 DRV_SDSPI_SyncWrite Function

C

bool DRV_SDSPI_SyncWrite(
    const DRV_HANDLE handle,
    void* sourceBuffer,
    uint32_t blockStart,
    uint32_t nBlock
)

Summary

Writes blocks of data starting at the specified address of the SD Card.

Description

This function performs a blocking write operation to write blocks of data to the SD Card. The function returns true if the request was successfully executed. The function returns false under the following circumstances:

  • if the driver handle is invalid

  • if the source buffer pointer is NULL

  • if the number of blocks to be written is either zero or more than the number of blocks actually available

  • if the SD card is write-protected

  • if there was an error during the SD card write operation

Precondition

The DRV_SDSPI_Initialize routine must have been called for the specified SDSPI driver instance.

DRV_SDSPI_Open routine must have been called to obtain a valid opened device handle.

Parameters

ParamDescription
handleA valid open-instance handle, returned from the driver's open function
sourceBufferThe source buffer containing data to be written to the SD Card.
blockStartStarting block address of SD Card where the writes should begin.
nBlockTotal number of blocks to be written.

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_SyncWrite(mySDSPIHandle, myBuffer, blockStart, nBlock) == true)
{
    // Write is successful
}
else
{
    // Error handling here
}

Remarks

None.