1.1.8.4.12 DRV_SFDP_PageWrite Function
1.1.8.4.12 C
bool DRV_SFDP_PageWrite( const DRV_HANDLE handle, void *tx_data, uint32_t address );1.1.8.4.12 Summary
Writes one page of data starting at the specified address.
1.1.8.4.12 Description
This function schedules a non-blocking write operation for writing maximum one page of data into Flash memory. The page size is determined from SFDP discovery.
The requesting client should call DRV_SFDP_TransferStatusGet() API to know the current status of the request.
1.1.8.4.12 Preconditions
The DRV_SFDP_Open() routine must have been called for the specified SFDP driver instance. The Flash address location which has to be written, must have been erased before using the SFDP_xxxErase() routine. The Flash address has to be a Page aligned address.
1.1.8.4.12 Parameters
| Parameters | Description |
|---|---|
| handle | A valid open-instance handle, returned from the driver's open routine |
| *tx_data | The source buffer containing data to be programmed into SFDP Flash |
| address | Write memory start address from where the data should be written |
1.1.8.4.12 Returns
True:
- If the write request is successfully sent to the Flash
False:
- If Write enable fails before sending write command to Flash
- If write command itself fails
1.1.8.4.12 Example
#define PAGE_SIZE 256 #define BUFFER_SIZE 1024 #define MEM_ADDRESS 0x0 DRV_HANDLE handle; // Returned from DRV_SFDP_Open uint8_t CACHE_ALIGN writeBuffer[BUFFER_SIZE]; bool status = false; if(false == DRV_SFDP_SectorErase(handle, MEM_ADDRESS)) { // Error handling here } // Wait for erase to be completed while(DRV_SFDP_TransferStatusGet(handle) == DRV_SFDP_TRANSFER_BUSY); for (uint32_t j = 0; j < BUFFER_SIZE; j += PAGE_SIZE) { if (DRV_SFDP_PageWrite(handle, (void *)&writeBuffer[j], (MEM_ADDRESS + j)) == false) { status = false; break; } // Wait for write to be completed while(DRV_SFDP_TransferStatusGet(handle) == DRV_SFDP_TRANSFER_BUSY); status = true; } if(status == false) { // Error handling here }
1.1.8.4.12 Remarks
None.
