![]() |
MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The MCUXpresso SDK provides a driver for the Flash In Application Programming (FLASHIAP).
It provides a set of functions to call the on chip in application flash programming interface. User code executing from on chip flash or ram can call these function to erase and write the flash memory.
FLASHIAP_PrepareSectorForWrite() prepares a sector for write or erase operation.
FLASHIAP_CopyRamToFlash() function programs the flash memory.
FLASHIAP_EraseSector() function erase a flash sector. A sector must be erased before write operation.
Files | |
file | fsl_flashiap.h |
Typedefs | |
typedef void(* | IAP_ENTRY_T )(uint32_t cmd[5], uint32_t stat[4]) |
IAP_ENTRY API function type. | |
Functions | |
static void | iap_entry (uint32_t *cmd_param, uint32_t *status_result) |
IAP_ENTRY API function type. More... | |
status_t | FLASHIAP_PrepareSectorForWrite (uint32_t startSector, uint32_t endSector) |
Prepare sector for write operation. More... | |
status_t | FLASHIAP_CopyRamToFlash (uint32_t dstAddr, uint32_t *srcAddr, uint32_t numOfBytes, uint32_t systemCoreClock) |
Copy RAM to flash. More... | |
status_t | FLASHIAP_EraseSector (uint32_t startSector, uint32_t endSector, uint32_t systemCoreClock) |
Erase sector. More... | |
status_t | FLASHIAP_ErasePage (uint32_t startPage, uint32_t endPage, uint32_t systemCoreClock) |
This function erases page(s). More... | |
status_t | FLASHIAP_BlankCheckSector (uint32_t startSector, uint32_t endSector) |
Blank check sector(s) More... | |
status_t | FLASHIAP_Compare (uint32_t dstAddr, uint32_t *srcAddr, uint32_t numOfBytes) |
Compare memory contents of flash with ram. More... | |
Driver version | |
#define | FSL_FLASHIAP_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
Version 2.0.0. More... | |
#define FSL_FLASHIAP_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) |
enum _flashiap_status |
enum _flashiap_commands |
|
inlinestatic |
Wrapper for rom iap call
cmd_param | IAP command and relevant parameter array. |
status_result | IAP status result array. |
None. | Status/Result is returned via status_result array. |
status_t FLASHIAP_PrepareSectorForWrite | ( | uint32_t | startSector, |
uint32_t | endSector | ||
) |
This function prepares sector(s) for write/erase operation. This function must be called before calling the FLASHIAP_CopyRamToFlash() or FLASHIAP_EraseSector() or FLASHIAP_ErasePage() function. The end sector must be greater than or equal to start sector number.
startSector | Start sector number. |
endSector | End sector number. |
kStatus_FLASHIAP_Success | Api was executed successfully. |
kStatus_FLASHIAP_NoPower | Flash memory block is powered down. |
kStatus_FLASHIAP_NoClock | Flash memory block or controller is not clocked. |
kStatus_FLASHIAP_InvalidSector | Sector number is invalid or end sector number is greater than start sector number. |
kStatus_FLASHIAP_Busy | Flash programming hardware interface is busy. |
status_t FLASHIAP_CopyRamToFlash | ( | uint32_t | dstAddr, |
uint32_t * | srcAddr, | ||
uint32_t | numOfBytes, | ||
uint32_t | systemCoreClock | ||
) |
This function programs the flash memory. Corresponding sectors must be prepared via FLASHIAP_PrepareSectorForWrite before calling calling this function. The addresses should be a 256 byte boundary and the number of bytes should be 256 | 512 | 1024 | 4096.
dstAddr | Destination flash address where data bytes are to be written. |
srcAddr | Source ram address from where data bytes are to be read. |
numOfBytes | Number of bytes to be written. |
systemCoreClock | SystemCoreClock in Hz. It is converted to KHz before calling the rom IAP function. |
kStatus_FLASHIAP_Success | Api was executed successfully. |
kStatus_FLASHIAP_NoPower | Flash memory block is powered down. |
kStatus_FLASHIAP_NoClock | Flash memory block or controller is not clocked. |
kStatus_FLASHIAP_SrcAddrError | Source address is not on word boundary. |
kStatus_FLASHIAP_DstAddrError | Destination address is not on a correct boundary. |
kStatus_FLASHIAP_SrcAddrNotMapped | Source address is not mapped in the memory map. |
kStatus_FLASHIAP_DstAddrNotMapped | Destination address is not mapped in the memory map. |
kStatus_FLASHIAP_CountError | Byte count is not multiple of 4 or is not a permitted value. |
kStatus_FLASHIAP_NotPrepared | Command to prepare sector for write operation was not executed. |
kStatus_FLASHIAP_Busy | Flash programming hardware interface is busy. |
status_t FLASHIAP_EraseSector | ( | uint32_t | startSector, |
uint32_t | endSector, | ||
uint32_t | systemCoreClock | ||
) |
This function erases sector(s). The end sector must be greater than or equal to start sector number. FLASHIAP_PrepareSectorForWrite must be called before calling this function.
startSector | Start sector number. |
endSector | End sector number. |
systemCoreClock | SystemCoreClock in Hz. It is converted to KHz before calling the rom IAP function. |
kStatus_FLASHIAP_Success | Api was executed successfully. |
kStatus_FLASHIAP_NoPower | Flash memory block is powered down. |
kStatus_FLASHIAP_NoClock | Flash memory block or controller is not clocked. |
kStatus_FLASHIAP_InvalidSector | Sector number is invalid or end sector number is greater than start sector number. |
kStatus_FLASHIAP_NotPrepared | Command to prepare sector for write operation was not executed. |
kStatus_FLASHIAP_Busy | Flash programming hardware interface is busy. |
status_t FLASHIAP_ErasePage | ( | uint32_t | startPage, |
uint32_t | endPage, | ||
uint32_t | systemCoreClock | ||
) |
The end page must be greater than or equal to start page number. Corresponding sectors must be prepared via FLASHIAP_PrepareSectorForWrite before calling calling this function.
startPage | Start page number |
endPage | End page number |
systemCoreClock | SystemCoreClock in Hz. It is converted to KHz before calling the rom IAP function. |
kStatus_FLASHIAP_Success | Api was executed successfully. |
kStatus_FLASHIAP_NoPower | Flash memory block is powered down. |
kStatus_FLASHIAP_NoClock | Flash memory block or controller is not clocked. |
kStatus_FLASHIAP_InvalidSector | Page number is invalid or end page number is greater than start page number |
kStatus_FLASHIAP_NotPrepared | Command to prepare sector for write operation was not executed. |
kStatus_FLASHIAP_Busy | Flash programming hardware interface is busy. |
status_t FLASHIAP_BlankCheckSector | ( | uint32_t | startSector, |
uint32_t | endSector | ||
) |
Blank check single or multiples sectors of flash memory. The end sector must be greater than or equal to start sector number. It can be used to verify the sector eraseure after FLASHIAP_EraseSector call.
startSector | : Start sector number. Must be greater than or equal to start sector number |
endSector | : End sector number |
kStatus_FLASHIAP_Success | One or more sectors are in erased state. |
kStatus_FLASHIAP_NoPower | Flash memory block is powered down. |
kStatus_FLASHIAP_NoClock | Flash memory block or controller is not clocked. |
kStatus_FLASHIAP_SectorNotblank | One or more sectors are not blank. |
status_t FLASHIAP_Compare | ( | uint32_t | dstAddr, |
uint32_t * | srcAddr, | ||
uint32_t | numOfBytes | ||
) |
This function compares the contents of flash and ram. It can be used to verify the flash memory contents after FLASHIAP_CopyRamToFlash call.
dstAddr | Destination flash address. |
srcAddr | Source ram address. |
numOfBytes | Number of bytes to be compared. |
kStatus_FLASHIAP_Success | Contents of flash and ram match. |
kStatus_FLASHIAP_NoPower | Flash memory block is powered down. |
kStatus_FLASHIAP_NoClock | Flash memory block or controller is not clocked. |
kStatus_FLASHIAP_AddrError | Address is not on word boundary. |
kStatus_FLASHIAP_AddrNotMapped | Address is not mapped in the memory map. |
kStatus_FLASHIAP_CountError | Byte count is not multiple of 4 or is not a permitted value. |
kStatus_FLASHIAP_CompareError | Destination and source memory contents do not match. |