MCUXpresso SDK API Reference Manual  Rev 2.12.1
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
FLASH_Adapter

Overview

Macros

#define HAL_FLASH_TRANSFER_MODE   (0U)
 
More...
 

Enumerations

enum  hal_flash_status_t {
  kStatus_HAL_Flash_Success = kStatus_Success,
  kStatus_HAL_Flash_Fail = MAKE_STATUS(kStatusGroup_HAL_FLASH, 1),
  kStatus_HAL_Flash_InvalidArgument = MAKE_STATUS(kStatusGroup_HAL_FLASH, 2),
  kStatus_HAL_Flash_AlignmentError = MAKE_STATUS(kStatusGroup_HAL_FLASH, 3),
  kStatus_HAL_Flash_EccError = MAKE_STATUS(kStatusGroup_HAL_FLASH, 4),
  kStatus_HAL_Flash_Error = MAKE_STATUS(kStatusGroup_HAL_FLASH, 5),
  kStatus_HAL_Flash_NotSupport = MAKE_STATUS(kStatusGroup_HAL_FLASH, 6)
}
 
More...
 
enum  hal_flash_property_tag_t {
  kHAL_Flash_PropertyPflashSectorSize = 0x00U,
  kHAL_Flash_PropertyPflashTotalSize = 0x01U,
  kHAL_Flash_PropertyPflashBlockSize = 0x02U,
  kHAL_Flash_PropertyPflashBlockCount = 0x03U,
  kHAL_Flash_PropertyPflashBlockBaseAddr = 0x04U,
  kHAL_Flash_PropertyPflashFacSupport = 0x05U,
  kHAL_Flash_PropertyPflashAccessSegmentSize = 0x06U,
  kHAL_Flash_PropertyPflashAccessSegmentCount = 0x07U,
  kHAL_Flash_PropertyFlexRamBlockBaseAddr = 0x08U,
  kHAL_Flash_PropertyFlexRamTotalSize = 0x09U,
  kHAL_Flash_PropertyDflashSectorSize = 0x10U,
  kHAL_Flash_PropertyDflashTotalSize = 0x11U,
  kHAL_Flash_PropertyDflashBlockSize = 0x12U,
  kHAL_Flash_PropertyDflashBlockCount = 0x13U,
  kHAL_Flash_PropertyDflashBlockBaseAddr = 0x14U,
  kHAL_Flash_PropertyEepromTotalSize = 0x15U,
  kHAL_Flash_PropertyFlashMemoryIndex = 0x20U
}
 Hal flash property. More...
 
enum  hal_flash_security_state_t {
  kHAL_Flash_SecurityStateNotSecure = 0xc33cc33cU,
  kHAL_Flash_SecurityStateBackdoorEnabled = 0x5aa55aa5U,
  kHAL_Flash_SecurityStateBackdoorDisabled = 0x5ac33ca5U
}
 Hal flash security state. More...
 
enum  hal_flash_margin_value_t {
  kHAL_Flash_MarginValueNormal = 0,
  kHAL_Flash_MarginValueUser,
  kHAL_Flash_MarginValueFactory,
  kHAL_Flash_MarginValueInvalid
}
 Hal flash margin value. More...
 

Initialization


Public memory declarations


Public prototypes

hal_flash_status_t HAL_FlashInit (void)
 Initializes the flash hal adapter module. More...
 
hal_flash_status_t HAL_FlashProgram (uint32_t dest, uint32_t size, uint8_t *pData)
 Write aligned data to FLASH. More...
 
hal_flash_status_t HAL_FlashProgramUnaligned (uint32_t dest, uint32_t size, uint8_t *pData)
 Write data to FLASH. More...
 
hal_flash_status_t HAL_FlashEraseSector (uint32_t dest, uint32_t size)
 Erase the Flash memory which is specified by the parameter dest and parameter size, the content of the specified flash memory would be 0xFF. More...
 
hal_flash_status_t HAL_FlashVerifyErase (uint32_t start, uint32_t lengthInBytes, hal_flash_margin_value_t margin)
 Verify erase data in Flash. More...
 
hal_flash_status_t HAL_FlashRead (uint32_t src, uint32_t size, uint8_t *pData)
 Read data from FLASH. More...
 
hal_flash_status_t HAL_FlashGetProperty (hal_flash_property_tag_t property, uint32_t *value)
 Returns the desired hal flash property. More...
 
hal_flash_status_t HAL_FlashSetProperty (hal_flash_property_tag_t property, uint32_t value)
 Set the desired hal flash property. More...
 
hal_flash_status_t HAL_FlashGetSecurityState (hal_flash_security_state_t *state)
 Returns the security state via the pointer passed into the function. More...
 

Macro Definition Documentation

#define HAL_FLASH_TRANSFER_MODE   (0U)

Include


Public macros

Whether enable transactional function of the FLASH. (0 - disable, 1 - enable)

Enumeration Type Documentation

Public type definitions

Hal flash status.

Enumerator
kStatus_HAL_Flash_Success 

flash operation is successful

kStatus_HAL_Flash_Fail 

flash operation is not successful

kStatus_HAL_Flash_InvalidArgument 

Invalid argument.

kStatus_HAL_Flash_AlignmentError 

Alignment Error.

kStatus_HAL_Flash_EccError 

ECC error detected.

kStatus_HAL_Flash_Error 

Illegal command.

kStatus_HAL_Flash_NotSupport 

Not support.

Enumerator
kHAL_Flash_PropertyPflashSectorSize 

Pflash sector size property.

kHAL_Flash_PropertyPflashTotalSize 

Pflash total size property.

kHAL_Flash_PropertyPflashBlockSize 

Pflash block size property.

kHAL_Flash_PropertyPflashBlockCount 

Pflash block count property.

kHAL_Flash_PropertyPflashBlockBaseAddr 

Pflash block base address property.

kHAL_Flash_PropertyPflashFacSupport 

Pflash fac support property.

kHAL_Flash_PropertyPflashAccessSegmentSize 

Pflash access segment size property.

kHAL_Flash_PropertyPflashAccessSegmentCount 

Pflash access segment count property.

kHAL_Flash_PropertyFlexRamBlockBaseAddr 

FlexRam block base address property.

kHAL_Flash_PropertyFlexRamTotalSize 

FlexRam total size property.

kHAL_Flash_PropertyDflashSectorSize 

Dflash sector size property.

kHAL_Flash_PropertyDflashTotalSize 

Dflash total size property.

kHAL_Flash_PropertyDflashBlockSize 

Dflash block size property.

kHAL_Flash_PropertyDflashBlockCount 

Dflash block count property.

kHAL_Flash_PropertyDflashBlockBaseAddr 

Dflash block base address property.

kHAL_Flash_PropertyEepromTotalSize 

EEPROM total size property.

kHAL_Flash_PropertyFlashMemoryIndex 

Flash memory index property.

Enumerator
kHAL_Flash_SecurityStateNotSecure 

Flash is not secure.

kHAL_Flash_SecurityStateBackdoorEnabled 

Flash backdoor is enabled.

kHAL_Flash_SecurityStateBackdoorDisabled 

Flash backdoor is disabled.

Enumerator
kHAL_Flash_MarginValueNormal 

Use the 'normal' read level for 1s.

kHAL_Flash_MarginValueUser 

Apply the 'User' margin to the normal read-1 level.

kHAL_Flash_MarginValueFactory 

Apply the 'Factory' margin to the normal read-1 level.

kHAL_Flash_MarginValueInvalid 

Not real margin level, Used to determine the range of valid margin level.

Function Documentation

hal_flash_status_t HAL_FlashInit ( void  )

This function initializes the Flash module for the other Flash APIs.

Return values
kStatus_HAL_Flash_SuccessAPI was executed successfully.
kStatus_HAL_Flash_InvalidArgumentAn invalid argument is provided.
#kStatus_HAL_Flash_ExecuteInRamFunctionNotReadyExecute-in-RAM function is not available.
#kStatus_HAL_Flash_PartitionStatusUpdateFailureFailed to update the partition status.
hal_flash_status_t HAL_FlashProgram ( uint32_t  dest,
uint32_t  size,
uint8_t *  pData 
)
Note
This API should be called after HAL_FlashEraseSector was called to make sure the flash was erased, and make sure the flash program address and flash program size is aligned with flash write unit size.
Parameters
destThe address of the Flash location
sizeThe number of bytes to be programed
pDataPointer to the data to be programmed to Flash
Return values
kStatus_HAL_Flash_SuccessAPI was executed successfully.
hal_flash_status_t HAL_FlashProgramUnaligned ( uint32_t  dest,
uint32_t  size,
uint8_t *  pData 
)
Note
This API should be called after HAL_FlashEraseSector was called to make sure the flash was erased.
Parameters
destThe address of the Flash location
sizeThe number of bytes to be programed
pDataPointer to the data to be programmed to Flash
Return values
kStatus_HAL_Flash_SuccessAPI was executed successfully.
hal_flash_status_t HAL_FlashEraseSector ( uint32_t  dest,
uint32_t  size 
)
Parameters
destThe start address of the first sector to be erased
sizeThe number of bytes to be erased
Return values
kStatus_HAL_Flash_SuccessAPI was executed successfully.
hal_flash_status_t HAL_FlashVerifyErase ( uint32_t  start,
uint32_t  lengthInBytes,
hal_flash_margin_value_t  margin 
)
Parameters
startThe address of the Flash location
lengthInBytesThe number of bytes to be checked
marginFlash margin value
Return values
kStatus_HAL_Flash_SuccessAPI was executed successfully.
hal_flash_status_t HAL_FlashRead ( uint32_t  src,
uint32_t  size,
uint8_t *  pData 
)
Parameters
scrThe address of the Flash location to be read
sizeThe number of bytes to be read
pDataPointer to the data to be read from Flash
Return values
kStatus_HAL_Flash_SuccessAPI was executed successfully.
hal_flash_status_t HAL_FlashGetProperty ( hal_flash_property_tag_t  property,
uint32_t *  value 
)
Parameters
PropertyThe desired property from the list of properties in enum hal_flash_property_tag_t
valueA pointer to the value returned for the desired flash property.
Return values
kStatus_HAL_Flash_SuccessAPI was executed successfully.
kStatus_HAL_Flash_InvalidArgumentAn invalid argument is provided.
kStatus_HAL_Flash_NotSupportFlash currently not support.
hal_flash_status_t HAL_FlashSetProperty ( hal_flash_property_tag_t  property,
uint32_t  value 
)
Parameters
PropertyThe desired property from the list of properties in enum hal_flash_property_tag_t
valueThe value would be set to the desired flash property.
Return values
kStatus_HAL_Flash_SuccessAPI was executed successfully.
kStatus_HAL_Flash_InvalidArgumentAn invalid argument is provided.
kStatus_HAL_Flash_NotSupportFlash currently not support.
hal_flash_status_t HAL_FlashGetSecurityState ( hal_flash_security_state_t state)

This function retrieves the current flash security status, including the security enabling state and the backdoor key enabling state.

Parameters
stateA pointer to the value returned for the current security status
Return values
kStatus_HAL_Flash_SuccessAPI was executed successfully.
kStatus_HAL_Flash_InvalidArgumentAn invalid argument is provided.
kStatus_HAL_Flash_NotSupportFlash currently not support.