1.1.3.4.13 DRV_MEMORY_SyncRead Function
C
bool DRV_MEMORY_SyncRead ( const DRV_HANDLE handle, void *targetBuffer, uint32_t blockStart, uint32_t nBlock );
Summary
Reads data for the specified number of memory blocks in Synchronous mode.
Description
This function schedules a blocking read operation for reading blocks of data from the memory device attached.
Precondition
DRV_MEMORY_Open() must have been called with DRV_IO_INTENT_READ or DRV_IO_INTENT_READWRITE as the ioIntent 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 media device memory will be placed |
blockStart | Block start from where the data should be read. |
nBlock | Total number of blocks to be read. |
Returns
true
- If the transfer request is successfully completed.
false
- If the source buffer pointer is NULL
- If the client opened the driver for write only
- If the number of blocks to be read 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 readBuffer[BUFFER_SIZE]; // Use DRV_MEMORY_GeometryGet () to find the read region geometry. uint32_t blockStart = 0x0; uint32_t nBlock = BUFFER_SIZE / block_size; // block_size for read geometry // memoryHandle is the handle returned by the DRV_MEMORY_Open function. if(DRV_MEMORY_SyncRead(memoryHandle, &readBuffer, blockStart, nBlock) == false) { // Error handling here }
Remarks
This API is supported only in RTOS environment.