Jump to main content

##

# DRV_SST26_PageWrite Function

## C

    bool DRV_SST26_PageWrite( const DRV_HANDLE handle, void *tx_data, uint32_t tx_data_length, uint32_t address );

## Summary

Writes one page of data starting at the specified address.

## Description

This function schedules a non-blocking write operation for writing maximum one page of data into flash memory.

The requesting client should call DRV_SST26_TransferStatusGet() API to know the current status of the request.

## Preconditions

The DRV_SST26_Open() routine must have been called for the specified SST26 driver instance. The flash address location which has to be written, must have been erased before using the SST26_xxxErase() routine. The flash address has to be a Page aligned address.

## Parameters

Param | 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 SST26 Flash
tx_data_length | Total number of bytes to be written. should not be greater than page size
address | Write memory start address from where the data should be written

## Returns

true

- if the write request is successfully sent to the flash

false

- if Write enable fails before sending sector erase command to flash
- if write command itself fails

## Example

    #define PAGE_SIZE 256
    #define BUFFER_SIZE 1024
    #define MEM_ADDRESS 0x0

    DRV_HANDLE handle; // Returned from DRV_SST26_Open
    uint8_t CACHE_ALIGN writeBuffer[BUFFER_SIZE];
    bool status = false;

    if(false == DRV_SST26_SectorErase(handle))
    {
        // Error handling here
    }

    // Wait for erase to be completed
    while(DRV_SST26_TransferStatusGet(handle) == DRV_SST26_TRANSFER_BUSY);

    for (uint32_t j = 0; j < BUFFER_SIZE; j += PAGE_SIZE)
    {
        if (DRV_SST26_PageWrite(handle, (void *)&writeBuffer[j], (MEM_ADDRESS + j)) == false)
        {
            status = false;
            break;
        }

        // Wait for write to be completed
        while(DRV_SST26_TransferStatusGet(handle) == DRV_SST26_TRANSFER_BUSY);
        status = true;
    }

    if(status == false)
    {
        // Error handling here
    }

## Remarks

None.