1.1.3.4.11 DRV_MEMORY_SyncWrite Function
C
bool DRV_MEMORY_SyncWrite ( const DRV_HANDLE handle, void *sourceBuffer, uint32_t blockStart, uint32_t nBlock );
Summary
Writes data for the specified number of memory blocks in Synchronous mode.
Description
This function schedules a blocking write operation for writing blocks of data into attached devices memory.
Preconditions
DRV_MEMORY_Open() routine must have been called to obtain a valid opened device handle. The memory block which has to be written, must have been erased before using the DRV_MEMORY_xxxErase() routine.
Parameters
Param | Description |
---|---|
handle | A valid open-instance handle, returned from the driver's open function |
sourceBuffer | The source buffer containing data to be programmed into media device memory |
blockStart | Block start from where the data should be written to. |
nBlock | Total number of blocks to be written. |
Returns
true
If the transfer request is successfully completed.
false
If the source buffer pointer is NULL
If the client opened the driver for read only
If the number of blocks to be written is either zero or more than the number of blocks actually available
If the driver handle is invalid
Example
#define BUFFER_SIZE 4096 uint8_t writeBuffer[BUFFER_SIZE]; // Use DRV_MEMORY_GeometryGet () to find the write region geometry. uint32_t blockStart = 0x0; uint32_t nBlock = BUFFER_SIZE / block_size; // block_size for write geometry // memoryHandle is the handle returned by the DRV_MEMORY_Open function. if(DRV_MEMORY_SyncErase(memoryHandle, blockStart, nBlock) == false) { // Error handling here } if(DRV_MEMORY_SyncWrite(memoryHandle, &writeBuffer, blockStart, nBlock) == false) { // Error handling here }
Remarks
This API is supported only in RTOS environment.