1.1.3.4.9 DRV_MEMORY_SyncEraseWrite Function

C

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

Summary

Erase and Write data for the specified number of memory blocks in Synchronous mode.

Description

This function combines the step of erasing a sector and then writing the page. The application can use this function if it wants to avoid having to explicitly delete a sector in order to update the pages contained in the sector.

This function schedules a blocking operation to erase and write blocks of data into attached device memory.

Precondition

The DRV_MEMORY_Open() must have been called with DRV_IO_INTENT_WRITE or DRV_IO_INTENT_READWRITE as a parameter 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 programmed into media device memory
blockStartblock start where the write should begin.
nBlockTotal number of blocks to be written.

Returns

  • true

    • If the transfer request is successfully completed.

  • false

    • If the sourceBuffer 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 buffer[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_SyncEraseWrite(memoryHandle, &myBuffer, blockStart, nBlock) == false)
{
    // Error handling here
}

Remarks

This API is supported only in RTOS environment.