Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
spi_flash_write

Functions

sint8 spi_flash_write (uint8 *pu8Buf, uint32 u32Offset, uint32 u32Sz)
 Write a specified portion of data to SPI Flash.
. More...
 

sint8 spi_flash_write ( uint8 pu8Buf,
uint32  u32Offset,
uint32  u32Sz 
)

Write a specified portion of data to SPI Flash.
.

Parameters
[in]pu8BufPointer to data buffer which contains the required to be written.
[in]u32OffsetAddress (Offset) to write at the SPI flash.
[in]u32SzTotal number of size of data bytes
Note
  • It is blocking function
  • It is user's responsibility to verify that data has been written successfully by reading data again and compare it with the original.
Warning
  • Address (offset) plus size of data must not exceed flash size.
  • No firmware is required for writing to SPI flash.
  • In case of there is a running firmware, it is required to pause your firmware first before any trial to access SPI flash to avoid any racing between host and running firmware on bus using m2m_wifi_download_mode.
  • Before writing to any section, it is required to erase it first.
See Also
m2m_wifi_download_mode, spi_flash_get_size, spi_flash_erase
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

References BSP_MIN, FLASH_PAGE_SZ, M2M_ERR, M2M_ERR_FAIL, M2M_PRINT, M2M_SUCCESS, and spi_flash_pp().