MCUXpresso SDK API Reference Manual  Rev 2.16.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
MEM Driver

Overview

Data Structures

struct  memory_interface_t
 Interface to memory operations. More...
 
struct  memory_region_interface_t
 Interface to memory operations for one region of memory. More...
 
struct  memory_map_entry_t
 Structure of a memory map entry. More...
 
union  StandardVersion
 Structure of version property. More...
 
struct  kb_api_parameter_struct
 API initialization data structure. More...
 

Macros

#define DEVICE_ID_MASK   (0xffU)
 Bit mask for device ID. More...
 
#define DEVICE_ID_SHIFT   0U
 Bit position of device ID. More...
 
#define GROUP_ID_MASK   (0xf00U)
 Bit mask for group ID. More...
 
#define GROUP_ID_SHIFT   8U
 Bit position of group ID. More...
 
#define MAKE_MEMORYID(group, device)   ((((group) << GROUP_ID_SHIFT) & GROUP_ID_MASK) | (((device) << DEVICE_ID_SHIFT) & DEVICE_ID_MASK))
 Construct a memory ID from a given group ID and device ID. More...
 
#define GROUPID(memoryId)   (((memoryId) & GROUP_ID_MASK) >> GROUP_ID_SHIFT)
 Get group ID from a given memory ID. More...
 
#define DEVICEID(memoryId)   (((memoryId) & DEVICE_ID_MASK) >> DEVICE_ID_SHIFT)
 Get device ID from a given memory ID. More...
 

Typedefs

typedef union StandardVersion standard_version_t
 Structure of version property. More...
 
typedef struct
kb_api_parameter_struct 
kp_api_init_param_t
 API initialization data structure.
 

Enumerations

enum  {
  kMemoryGroup_Internal = 0U,
  kMemoryGroup_External = 1U
}
 Memory group definition. More...
 
enum  {
  kMemoryInternal = MAKE_MEMORYID(kMemoryGroup_Internal, 0U),
  kMemoryQuadSpi0 = MAKE_MEMORYID(kMemoryGroup_Internal, 1U),
  kMemoryIFR0,
  kMemoryFFR = MAKE_MEMORYID(kMemoryGroup_Internal, 5U),
  kMemorySemcNor = MAKE_MEMORYID(kMemoryGroup_Internal, 8U),
  kMemoryFlexSpiNor = MAKE_MEMORYID(kMemoryGroup_Internal, 9U),
  kMemorySpifiNor = MAKE_MEMORYID(kMemoryGroup_Internal, 0xAU),
  kMemoryFlashExecuteOnly = MAKE_MEMORYID(kMemoryGroup_Internal, 0x10U),
  kMemorySemcNand = MAKE_MEMORYID(kMemoryGroup_External, 0U),
  kMemorySpiNand = MAKE_MEMORYID(kMemoryGroup_External, 1U),
  kMemorySpiNorEeprom = MAKE_MEMORYID(kMemoryGroup_External, 0x10U),
  kMemoryI2cNorEeprom = MAKE_MEMORYID(kMemoryGroup_External, 0x11U),
  kMemorySDCard = MAKE_MEMORYID(kMemoryGroup_External, 0x20U),
  kMemoryMMCCard = MAKE_MEMORYID(kMemoryGroup_External, 0x21U)
}
 Memory device ID definition. More...
 
enum  {
  kStatusGroup_Bootloader = 100,
  kStatusGroup_MemoryInterface = 102
}
 Bootloader status group numbers. More...
 
enum  {
  kStatusMemoryRangeInvalid = MAKE_STATUS(kStatusGroup_MemoryInterface, 0),
  kStatusMemoryReadFailed = MAKE_STATUS(kStatusGroup_MemoryInterface, 1),
  kStatusMemoryWriteFailed = MAKE_STATUS(kStatusGroup_MemoryInterface, 2),
  kStatusMemoryCumulativeWrite = MAKE_STATUS(kStatusGroup_MemoryInterface, 3),
  kStatusMemoryAppOverlapWithExecuteOnlyRegion,
  kStatusMemoryNotConfigured = MAKE_STATUS(kStatusGroup_MemoryInterface, 5),
  kStatusMemoryAlignmentError = MAKE_STATUS(kStatusGroup_MemoryInterface, 6),
  kStatusMemoryVerifyFailed = MAKE_STATUS(kStatusGroup_MemoryInterface, 7),
  kStatusMemoryWriteProtected = MAKE_STATUS(kStatusGroup_MemoryInterface, 8),
  kStatusMemoryAddressError = MAKE_STATUS(kStatusGroup_MemoryInterface, 9),
  kStatusMemoryBlankCheckFailed,
  kStatusMemoryBlankPageReadDisallowed,
  kStatusMemoryProtectedPageReadDisallowed,
  kStatusMemoryFfrSpecRegionWriteBroken,
  kStatusMemoryUnsupportedCommand
}
 Memory interface status codes. More...
 
enum  {
  kStatus_UnknownCommand = MAKE_STATUS(kStatusGroup_Bootloader, 0),
  kStatus_SecurityViolation = MAKE_STATUS(kStatusGroup_Bootloader, 1),
  kStatus_AbortDataPhase = MAKE_STATUS(kStatusGroup_Bootloader, 2),
  kStatus_Ping = MAKE_STATUS(kStatusGroup_Bootloader, 3),
  kStatus_NoResponse = MAKE_STATUS(kStatusGroup_Bootloader, 4),
  kStatus_NoResponseExpected = MAKE_STATUS(kStatusGroup_Bootloader, 5),
  kStatus_CommandUnsupported = MAKE_STATUS(kStatusGroup_Bootloader, 6)
}
 Bootloader status codes. More...
 

Functions

status_t API_Init (api_core_context_t *coreCtx, const kp_api_init_param_t *param)
 Initialize the IAP API runtime environment.
 
status_t API_Deinit (api_core_context_t *coreCtx)
 Deinitialize the IAP API runtime environment.
 
status_t MEM_Init (api_core_context_t *coreCtx)
 Initialize memory interface. More...
 
status_t MEM_Config (api_core_context_t *coreCtx, uint32_t *config, uint32_t memoryId)
 Configure memory interface. More...
 
status_t MEM_Write (api_core_context_t *coreCtx, uint32_t start, uint32_t lengthInBytes, const uint8_t *buf, uint32_t memoryId)
 Write memory. More...
 
status_t MEM_Fill (api_core_context_t *coreCtx, uint32_t start, uint32_t lengthInBytes, uint32_t pattern, uint32_t memoryId)
 Fill memory with a word pattern. More...
 
status_t MEM_Flush (api_core_context_t *coreCtx)
 Flush memory. More...
 
status_t MEM_Erase (api_core_context_t *coreCtx, uint32_t start, uint32_t lengthInBytes, uint32_t memoryId)
 Erase memory. More...
 
status_t MEM_EraseAll (api_core_context_t *coreCtx, uint32_t memoryId)
 Erase entire memory based on memoryId. More...
 

Data Structure Documentation

struct memory_interface_t

This is the main abstract interface to all memory operations.

struct memory_region_interface_t
struct memory_map_entry_t
union StandardVersion

Data Fields

uint32_t version
 combined version numbers
 
uint8_t bugfix
 bugfix version [7:0]
 
uint8_t minor
 minor version [15:8]
 
uint8_t major
 major version [23:16]
 
char name
 name [31:24]
 
struct kb_api_parameter_struct

Macro Definition Documentation

#define DEVICE_ID_MASK   (0xffU)
#define DEVICE_ID_SHIFT   0U
#define GROUP_ID_MASK   (0xf00U)
#define GROUP_ID_SHIFT   8U
#define MAKE_MEMORYID (   group,
  device 
)    ((((group) << GROUP_ID_SHIFT) & GROUP_ID_MASK) | (((device) << DEVICE_ID_SHIFT) & DEVICE_ID_MASK))
#define GROUPID (   memoryId)    (((memoryId) & GROUP_ID_MASK) >> GROUP_ID_SHIFT)
#define DEVICEID (   memoryId)    (((memoryId) & DEVICE_ID_MASK) >> DEVICE_ID_SHIFT)

Typedef Documentation

Enumeration Type Documentation

anonymous enum
Enumerator
kMemoryGroup_Internal 

Memory belongs internal 4G memory region.

kMemoryGroup_External 

Memory belongs external memory region.

anonymous enum
Enumerator
kMemoryInternal 

Internal memory (include all on chip memory)

kMemoryQuadSpi0 

Qsuad SPI memory 0.

kMemoryIFR0 

Nonvolatile information register 0.

Only used by SB loader.

kMemoryFFR 

LPCc040hd flash FFR region.

kMemorySemcNor 

SEMC Nor memory.

kMemoryFlexSpiNor 

Flex SPI Nor memory.

kMemorySpifiNor 

SPIFI Nor memory.

kMemoryFlashExecuteOnly 

Execute-only region on internal Flash.

kMemorySemcNand 

SEMC NAND memory.

kMemorySpiNand 

SPI NAND memory.

kMemorySpiNorEeprom 

SPI NOR/EEPROM memory.

kMemoryI2cNorEeprom 

I2C NOR/EEPROM memory.

kMemorySDCard 

eSD, SD, SDHC, SDXC memory Card

kMemoryMMCCard 

MMC, eMMC memory Card.

anonymous enum
Enumerator
kStatusGroup_Bootloader 

Bootloader status group number (100).

kStatusGroup_MemoryInterface 

Memory interface status group number (102).

anonymous enum
Enumerator
kStatusMemoryRangeInvalid 

Status: Memory Range Invalid.

kStatusMemoryReadFailed 

Status: Memory Read Failed.

kStatusMemoryWriteFailed 

Status: Memory Write Failed.

kStatusMemoryCumulativeWrite 

Status: Memory Cumulative Write.

kStatusMemoryAppOverlapWithExecuteOnlyRegion 

Status: Memory AppOverlapWithExecuteOnlyRegion.

kStatusMemoryNotConfigured 

Status: Memory Not Configured.

kStatusMemoryAlignmentError 

Status: Memory Alignment Error.

kStatusMemoryVerifyFailed 

Status: Memory Verify Failed.

kStatusMemoryWriteProtected 

Status: Memory Write Protected.

kStatusMemoryAddressError 

Status: Memory Address Error.

kStatusMemoryBlankCheckFailed 

Status: Memory Blank Check Failed.

kStatusMemoryBlankPageReadDisallowed 

Status: Memory Blank Page Read Disallowed.

kStatusMemoryProtectedPageReadDisallowed 

Status: Memory Protected Page Read Disallowed.

kStatusMemoryFfrSpecRegionWriteBroken 

Status: Memory Ffr Spec Region Write Broken.

kStatusMemoryUnsupportedCommand 

Status: Memory Unsupported Command.

anonymous enum
Enumerator
kStatus_UnknownCommand 

Status: Unknown Command.

kStatus_SecurityViolation 

Status: Security Violation.

kStatus_AbortDataPhase 

Status: Abort Data Phase.

kStatus_Ping 

Status: Ping.

kStatus_NoResponse 

Status: No Response.

kStatus_NoResponseExpected 

Status: No Response Expected.

kStatus_CommandUnsupported 

Status: Command Unsupported.

Function Documentation

status_t MEM_Init ( api_core_context_t *  coreCtx)
status_t MEM_Config ( api_core_context_t *  coreCtx,
uint32_t *  config,
uint32_t  memoryId 
)
Parameters
coreCtxA pointer to the storage for the driver runtime state.
configmemory configure struct.
memoryIdIndicates the index of the memory type. Please refer to "Memory group definition"
Return values
kStatus_Success
kStatus_CommandUnsupported
kStatus_InvalidArgument
kStatus_FLASH_ModifyProtectedAreaDisallowed
kStatusMemoryRangeInvalid
kStatus_Fail
kStatus_OutOfRange
status_t MEM_Write ( api_core_context_t *  coreCtx,
uint32_t  start,
uint32_t  lengthInBytes,
const uint8_t *  buf,
uint32_t  memoryId 
)
Parameters
coreCtxA pointer to the storage for the driver runtime state.
startThe start address of the desired flash memory to be programmed. For internal flash the address need to be 512bytes-aligned.
lengthInBytesNumber of bytes to be programmed.
bufA pointer to the source buffer of data that is to be programmed into the flash.
memoryIdIndicates the index of the memory type. Please refer to "Memory group definition"
Return values
kStatus_Success
kStatus_Fail
kStatusMemoryRangeInvalid
kStatus_CommandUnsupported
kStatus_FLASH_AlignmentError
kStatusMemoryCumulativeWrite
kStatus_FLASH_InvalidArgument
kStatus_FLASH_AddressError
kStatus_FLASH_ModifyProtectedAreaDisallowed
kStatus_FLASH_CommandFailure
kStatus_FLASH_CommandNotSupported
kStatus_FLASH_EccError
kStatus_FLASH_RegulationLoss
kStatus_FLASH_Success
kStatus_FLASH_ReadHidingAreaDisallowed
kStatus_FLASH_CompareError
kStatusMemoryNotConfigured
kStatusMemoryVerifyFailed
status_t MEM_Fill ( api_core_context_t *  coreCtx,
uint32_t  start,
uint32_t  lengthInBytes,
uint32_t  pattern,
uint32_t  memoryId 
)
Parameters
coreCtxA pointer to the storage for the driver runtime state.
startThe start address of the desired flash memory to be programmed. For internal flash the address need to be 512bytes-aligned.
lengthInBytesNumber of bytes to be programmed.
patternThe data to be written into the specified memory area.
memoryIdIndicates the index of the memory type. Please refer to "Memory group definition"
Return values
kStatus_CommandUnsupported
kStatus_Success
kStatus_FLASH_AlignmentError
kStatusMemoryCumulativeWrite
kStatus_Fail
kStatus_FLASH_InvalidArgument
kStatus_FLASH_AddressError
kStatus_FLASH_Success
kStatus_FLASH_ModifyProtectedAreaDisallowed
kStatus_FLASH_CommandFailure
kStatus_FLASH_CommandNotSupported
kStatus_FLASH_EccError
kStatus_FLASH_RegulationLoss
kStatus_FLASH_ReadHidingAreaDisallowed
status_t MEM_Erase ( api_core_context_t *  coreCtx,
uint32_t  start,
uint32_t  lengthInBytes,
uint32_t  memoryId 
)
Parameters
coreCtxA pointer to the storage for the driver runtime state.
startThe start address of the desired flash memory to be erased.
lengthInBytesNumber of bytes to be read.
memoryIdIndicates the index of the memory type. Please refer to "Memory group definition"
Return values
kStatus_Success
kStatusMemoryRangeInvalid
kStatusMemoryAddressError
kStatus_FLASH_InvalidArgument
kStatus_FLASH_AlignmentError
kStatus_FLASH_Success
kStatus_FLASH_AddressError
kStatus_FLASH_EraseKeyError
kStatus_FLASH_ModifyProtectedAreaDisallowed
kStatus_Fail
kStatus_FLASH_CommandFailure
kStatus_FLASH_CommandNotSupported
kStatus_FLASH_EccError
kStatus_FLASH_RegulationLoss
kStatusMemoryNotConfigured
kStatusMemoryVerifyFailed