Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
fsl_flash.h
00001 /* 00002 * Copyright (c) 2013-2015, Freescale Semiconductor, Inc. 00003 * All rights reserved. 00004 * 00005 * Redistribution and use in source and binary forms, with or without modification, 00006 * are permitted provided that the following conditions are met: 00007 * 00008 * o Redistributions of source code must retain the above copyright notice, this list 00009 * of conditions and the following disclaimer. 00010 * 00011 * o Redistributions in binary form must reproduce the above copyright notice, this 00012 * list of conditions and the following disclaimer in the documentation and/or 00013 * other materials provided with the distribution. 00014 * 00015 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its 00016 * contributors may be used to endorse or promote products derived from this 00017 * software without specific prior written permission. 00018 * 00019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00020 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00021 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00022 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 00023 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00026 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00028 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 */ 00030 00031 #ifndef _FSL_FLASH_H_ 00032 #define _FSL_FLASH_H_ 00033 00034 #if (defined(BL_TARGET_FLASH) || defined(BL_TARGET_ROM) || defined(BL_TARGET_RAM)) 00035 #include <assert.h> 00036 #include <string.h> 00037 #include "fsl_device_registers.h" 00038 #include "bootloader_common.h" 00039 #else 00040 #include "fsl_common.h" 00041 #endif 00042 00043 /******************************************************************************* 00044 * Definitions 00045 ******************************************************************************/ 00046 00047 /*! 00048 * @addtogroup flash_driver 00049 * @{ 00050 */ 00051 00052 /*! 00053 * @name Flash version 00054 * @{ 00055 */ 00056 /*! @brief Construct the version number for drivers. */ 00057 #if !defined(MAKE_VERSION) 00058 #define MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix)) 00059 #endif 00060 00061 /*! @brief FLASH driver version for SDK*/ 00062 #define FSL_FLASH_DRIVER_VERSION (MAKE_VERSION(2, 0, 0)) /*!< Version 2.0.0. */ 00063 00064 /*! @brief FLASH driver version for ROM*/ 00065 enum _flash_driver_version_constants 00066 { 00067 kFLASH_driverVersionName = 'F', /*!< Flash driver version name.*/ 00068 kFLASH_driverVersionMajor = 2, /*!< Major flash driver version.*/ 00069 kFLASH_driverVersionMinor = 0, /*!< Minor flash driver version.*/ 00070 kFLASH_driverVersionBugfix = 0 /*!< Bugfix for flash driver version.*/ 00071 }; 00072 /*@}*/ 00073 00074 /*! 00075 * @name Flash configuration 00076 * @{ 00077 */ 00078 /*! @brief Whether to support FlexNVM in flash driver */ 00079 #if !defined(FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT) 00080 #define FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT 1 /*!< Enable FlexNVM support by default. */ 00081 #endif 00082 00083 /*! @brief Whether the FlexNVM is enabled in flash driver */ 00084 #define FLASH_SSD_IS_FLEXNVM_ENABLED (FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT && FSL_FEATURE_FLASH_HAS_FLEX_NVM) 00085 00086 /*! @brief Flash driver location. */ 00087 #if !defined(FLASH_DRIVER_IS_FLASH_RESIDENT) 00088 #if (!defined(BL_TARGET_ROM) && !defined(BL_TARGET_RAM)) 00089 #define FLASH_DRIVER_IS_FLASH_RESIDENT 1 /*!< Used for flash resident application. */ 00090 #else 00091 #define FLASH_DRIVER_IS_FLASH_RESIDENT 0 /*!< Used for non-flash resident application. */ 00092 #endif 00093 #endif 00094 00095 /*! @brief Flash Driver Export option */ 00096 #if !defined(FLASH_DRIVER_IS_EXPORTED) 00097 #if (defined(BL_TARGET_ROM) || defined(BL_TARGET_FLASH)) 00098 #define FLASH_DRIVER_IS_EXPORTED 1 /*!< Used for ROM bootloader. */ 00099 #else 00100 #define FLASH_DRIVER_IS_EXPORTED 0 /*!< Used for SDK application. */ 00101 #endif 00102 #endif 00103 /*@}*/ 00104 00105 /*! 00106 * @name Flash status 00107 * @{ 00108 */ 00109 /*! @brief Flash driver status group. */ 00110 #if defined(kStatusGroup_FlashDriver) 00111 #define kStatusGroupGeneric kStatusGroup_Generic 00112 #define kStatusGroupFlashDriver kStatusGroup_FlashDriver 00113 #elif defined(kStatusGroup_FLASH) 00114 #define kStatusGroupGeneric kStatusGroup_Generic 00115 #define kStatusGroupFlashDriver kStatusGroup_FLASH 00116 #else 00117 #define kStatusGroupGeneric 0 00118 #define kStatusGroupFlashDriver 1 00119 #endif 00120 00121 /*! @brief Construct a status code value from a group and code number. */ 00122 #if !defined(MAKE_STATUS) 00123 #define MAKE_STATUS(group, code) ((((group)*100) + (code))) 00124 #endif 00125 00126 /*! 00127 * @brief Flash driver status codes. 00128 */ 00129 enum _flash_status 00130 { 00131 kStatus_FLASH_Success = MAKE_STATUS(kStatusGroupGeneric, 0), /*!< Api is executed successfully*/ 00132 kStatus_FLASH_InvalidArgument = MAKE_STATUS(kStatusGroupGeneric, 4), /*!< Invalid argument*/ 00133 kStatus_FLASH_SizeError = MAKE_STATUS(kStatusGroupFlashDriver, 0), /*!< Error size*/ 00134 kStatus_FLASH_AlignmentError = 00135 MAKE_STATUS(kStatusGroupFlashDriver, 1), /*!< Parameter is not aligned with specified baseline*/ 00136 kStatus_FLASH_AddressError = MAKE_STATUS(kStatusGroupFlashDriver, 2), /*!< Address is out of range */ 00137 kStatus_FLASH_AccessError = 00138 MAKE_STATUS(kStatusGroupFlashDriver, 3), /*!< Invalid instruction codes and out-of bounds addresses */ 00139 kStatus_FLASH_ProtectionViolation = MAKE_STATUS( 00140 kStatusGroupFlashDriver, 4), /*!< The program/erase operation is requested to execute on protected areas */ 00141 kStatus_FLASH_CommandFailure = 00142 MAKE_STATUS(kStatusGroupFlashDriver, 5), /*!< Run-time error during command execution. */ 00143 kStatus_FLASH_UnknownProperty = MAKE_STATUS(kStatusGroupFlashDriver, 6), /*!< Unknown property.*/ 00144 kStatus_FLASH_EraseKeyError = MAKE_STATUS(kStatusGroupFlashDriver, 7), /*!< Api erase key is invalid.*/ 00145 kStatus_FLASH_RegionExecuteOnly = MAKE_STATUS(kStatusGroupFlashDriver, 8), /*!< Current region is execute only.*/ 00146 kStatus_FLASH_ExecuteInRamFunctionNotReady = 00147 MAKE_STATUS(kStatusGroupFlashDriver, 9), /*!< Execute-in-ram function is not available.*/ 00148 kStatus_FLASH_PartitionStatusUpdateFailure = 00149 MAKE_STATUS(kStatusGroupFlashDriver, 10), /*!< Failed to update partition status.*/ 00150 kStatus_FLASH_SetFlexramAsEepromError = 00151 MAKE_STATUS(kStatusGroupFlashDriver, 11), /*!< Failed to set flexram as eeprom.*/ 00152 kStatus_FLASH_RecoverFlexramAsRamError = 00153 MAKE_STATUS(kStatusGroupFlashDriver, 12), /*!< Failed to recover flexram as ram.*/ 00154 kStatus_FLASH_SetFlexramAsRamError = MAKE_STATUS(kStatusGroupFlashDriver, 13), /*!< Failed to set flexram as ram.*/ 00155 kStatus_FLASH_RecoverFlexramAsEepromError = 00156 MAKE_STATUS(kStatusGroupFlashDriver, 14), /*!< Failed to recover flexram as eeprom.*/ 00157 kStatus_FLASH_CommandNotSupported = MAKE_STATUS(kStatusGroupFlashDriver, 15), /*!< Flash api is not supported.*/ 00158 kStatus_FLASH_SwapSystemNotInUninitialized = 00159 MAKE_STATUS(kStatusGroupFlashDriver, 16), /*!< Swap system is not in uninitialzed state.*/ 00160 kStatus_FLASH_SwapIndicatorAddressError = 00161 MAKE_STATUS(kStatusGroupFlashDriver, 17), /*!< Swap indicator address is invalid.*/ 00162 }; 00163 /*@}*/ 00164 00165 /*! 00166 * @name Flash API key 00167 * @{ 00168 */ 00169 /*! @brief Construct the four char code for flash driver API key. */ 00170 #if !defined(FOUR_CHAR_CODE) 00171 #define FOUR_CHAR_CODE(a, b, c, d) (((d) << 24) | ((c) << 16) | ((b) << 8) | ((a))) 00172 #endif 00173 00174 /*! 00175 * @brief Enumeration for flash driver API keys. 00176 * 00177 * @note The resulting value is built with a byte order such that the string 00178 * being readable in expected order when viewed in a hex editor, if the value 00179 * is treated as a 32-bit little endian value. 00180 */ 00181 enum _flash_driver_api_keys 00182 { 00183 kFLASH_apiEraseKey = FOUR_CHAR_CODE('k', 'f', 'e', 'k') /*!< Key value used to validate all flash erase APIs.*/ 00184 }; 00185 /*@}*/ 00186 00187 /*! 00188 * @brief Enumeration for supported flash margin levels. 00189 */ 00190 typedef enum _flash_margin_value 00191 { 00192 kFLASH_marginValueNormal , /*!< Use the 'normal' read level for 1s.*/ 00193 kFLASH_marginValueUser , /*!< Apply the 'User' margin to the normal read-1 level.*/ 00194 kFLASH_marginValueFactory , /*!< Apply the 'Factory' margin to the normal read-1 level.*/ 00195 kFLASH_marginValueInvalid /*!< Not real margin level, Used to determine the range of valid margin level. */ 00196 } flash_margin_value_t; 00197 00198 /*! 00199 * @brief Enumeration for the three possible flash security states. 00200 */ 00201 typedef enum _flash_security_state 00202 { 00203 kFLASH_securityStateNotSecure , /*!< Flash is not secure.*/ 00204 kFLASH_securityStateBackdoorEnabled , /*!< Flash backdoor is enabled.*/ 00205 kFLASH_securityStateBackdoorDisabled /*!< Flash backdoor is disabled.*/ 00206 } flash_security_state_t; 00207 00208 /*! 00209 * @brief Enumeration for the three possible flash protection levels. 00210 */ 00211 typedef enum _flash_protection_state 00212 { 00213 kFLASH_protectionStateUnprotected , /*!< Flash region is not protected.*/ 00214 kFLASH_protectionStateProtected , /*!< Flash region is protected.*/ 00215 kFLASH_protectionStateMixed /*!< Flash is mixed with protected and unprotected region.*/ 00216 } flash_protection_state_t; 00217 00218 /*! 00219 * @brief Enumeration for the three possible flash execute access levels. 00220 */ 00221 typedef enum _flash_execute_only_access_state 00222 { 00223 kFLASH_accessStateUnLimited , /*!< Flash region is unLimited.*/ 00224 kFLASH_accessStateExecuteOnly , /*!< Flash region is execute only.*/ 00225 kFLASH_accessStateMixed /*!< Flash is mixed with unLimited and execute only region.*/ 00226 } flash_execute_only_access_state_t; 00227 00228 /*! 00229 * @brief Enumeration for various flash properties. 00230 */ 00231 typedef enum _flash_property_tag 00232 { 00233 kFLASH_propertyPflashSectorSize = 0x00U, /*!< Pflash sector size property.*/ 00234 kFLASH_propertyPflashTotalSize = 0x01U, /*!< Pflash total size property.*/ 00235 kFLASH_propertyPflashBlockSize = 0x02U, /*!< Pflash block size property.*/ 00236 kFLASH_propertyPflashBlockCount = 0x03U, /*!< Pflash block count property.*/ 00237 kFLASH_propertyPflashBlockBaseAddr = 0x04U, /*!< Pflash block base address property.*/ 00238 kFLASH_propertyPflashFacSupport = 0x05U, /*!< Pflash fac support property.*/ 00239 kFLASH_propertyPflashAccessSegmentSize = 0x06U, /*!< Pflash access segment size property.*/ 00240 kFLASH_propertyPflashAccessSegmentCount = 0x07U, /*!< Pflash access segment count property.*/ 00241 kFLASH_propertyFlexRamBlockBaseAddr = 0x08U, /*!< FlexRam block base address property.*/ 00242 kFLASH_propertyFlexRamTotalSize = 0x09U, /*!< FlexRam total size property.*/ 00243 kFLASH_propertyDflashSectorSize = 0x10U, /*!< Dflash sector size property.*/ 00244 kFLASH_propertyDflashTotalSize = 0x11U, /*!< Dflash total size property.*/ 00245 kFLASH_propertyDflashBlockSize = 0x12U, /*!< Dflash block count property.*/ 00246 kFLASH_propertyDflashBlockCount = 0x13U, /*!< Dflash block base address property.*/ 00247 kFLASH_propertyDflashBlockBaseAddr = 0x14U, /*!< Eeprom total size property.*/ 00248 kFLASH_propertyEepromTotalSize = 0x15U 00249 } flash_property_tag_t; 00250 00251 /*! 00252 * @brief Constants for execute-in-ram flash function. 00253 */ 00254 enum _flash_execute_in_ram_function_constants 00255 { 00256 kFLASH_executeInRamFunctionMaxSize = 64U, /*!< Max size of execute-in-ram function.*/ 00257 kFLASH_executeInRamFunctionTotalNum = 2U /*!< Total number of execute-in-ram functions.*/ 00258 }; 00259 00260 /*! 00261 * @brief Flash execute-in-ram function information. 00262 */ 00263 typedef struct _flash_execute_in_ram_function_config 00264 { 00265 uint32_t activeFunctionCount ; /*!< Number of available execute-in-ram functions.*/ 00266 uint8_t *flashRunCommand ; /*!< execute-in-ram function: flash_run_command.*/ 00267 uint8_t *flashCacheClearCommand ; /*!< execute-in-ram function: flash_cache_clear_command.*/ 00268 } flash_execute_in_ram_function_config_t; 00269 00270 /*! 00271 * @brief Enumeration for the two possible options of flash read resource command. 00272 */ 00273 typedef enum _flash_read_resource_option 00274 { 00275 kFLASH_resourceOptionFlashIfr = 00276 0x00U, /*!< Select code for Program flash 0 IFR, Program flash swap 0 IFR, Data flash 0 IFR */ 00277 kFLASH_resourceOptionVersionId = 0x01U /*!< Select code for Version ID*/ 00278 } flash_read_resource_option_t; 00279 00280 /*! 00281 * @brief Enumeration for the range of special-purpose flash resource 00282 */ 00283 enum _flash_read_resource_range 00284 { 00285 #if (FSL_FEATURE_FLASH_IS_FTFE == 1) 00286 kFLASH_resourceRangePflashIfrSizeInBytes = 1024U, /*!< Pflash IFR size in byte.*/ 00287 kFLASH_resourceRangeVersionIdSizeInBytes = 8U, /*!< Version ID IFR size in byte.*/ 00288 kFLASH_resourceRangeVersionIdStart = 0x08U, /*!< Version ID IFR start address.*/ 00289 kFLASH_resourceRangeVersionIdEnd = 0x0FU, /*!< Version ID IFR end address.*/ 00290 #else /* FSL_FEATURE_FLASH_IS_FTFL == 1 or FSL_FEATURE_FLASH_IS_FTFA = =1 */ 00291 kFLASH_resourceRangePflashIfrSizeInBytes = 256U, /*!< Pflash IFR size in byte.*/ 00292 kFLASH_resourceRangeVersionIdSizeInBytes = 8U, /*!< Version ID IFR size in byte.*/ 00293 kFLASH_resourceRangeVersionIdStart = 0x00U, /*!< Version ID IFR start address.*/ 00294 kFLASH_resourceRangeVersionIdEnd = 0x07U, /*!< Version ID IFR end address.*/ 00295 #endif 00296 kFLASH_resourceRangePflashSwapIfrStart = 0x40000U, /*!< Pflash swap IFR start address.*/ 00297 kFLASH_resourceRangePflashSwapIfrEnd = 0x403FFU, /*!< Pflash swap IFR end address.*/ 00298 kFLASH_resourceRangeDflashIfrStart = 0x800000U, /*!< Dflash IFR start address.*/ 00299 kFLASH_resourceRangeDflashIfrEnd = 0x8003FFU, /*!< Dflash IFR end address.*/ 00300 }; 00301 00302 /*! 00303 * @brief Enumeration for the two possilbe options of set flexram function command. 00304 */ 00305 typedef enum _flash_flexram_function_option 00306 { 00307 kFLASH_flexramFunctionOptionAvailableAsRam = 0xFFU, /*!< Option used to make FlexRAM available as RAM */ 00308 kFLASH_flexramFunctionOptionAvailableForEeprom = 0x00U /*!< Option used to make FlexRAM available for EEPROM */ 00309 } flash_flexram_function_option_t; 00310 00311 /*! 00312 * @brief Enumeration for the possible options of Swap function 00313 */ 00314 typedef enum _flash_swap_function_option 00315 { 00316 kFLASH_swapFunctionOptionEnable = 0x00U, /*!< Option used to enable Swap function */ 00317 kFLASH_swapFunctionOptionDisable = 0x01U /*!< Option used to Disable Swap function */ 00318 } flash_swap_function_option_t; 00319 00320 /*! 00321 * @brief Enumeration for the possible options of Swap Control commands 00322 */ 00323 typedef enum _flash_swap_control_option 00324 { 00325 kFLASH_swapControlOptionIntializeSystem = 0x01U, /*!< Option used to Intialize Swap System */ 00326 kFLASH_swapControlOptionSetInUpdateState = 0x02U, /*!< Option used to Set Swap in Update State */ 00327 kFLASH_swapControlOptionSetInCompleteState = 0x04U, /*!< Option used to Set Swap in Complete State */ 00328 kFLASH_swapControlOptionReportStatus = 0x08U, /*!< Option used to Report Swap Status */ 00329 kFLASH_swapControlOptionDisableSystem = 0x10U /*!< Option used to Disable Swap Status */ 00330 } flash_swap_control_option_t; 00331 00332 /*! 00333 * @brief Enumeration for the possible flash swap status. 00334 */ 00335 typedef enum _flash_swap_state 00336 { 00337 kFLASH_swapStateUninitialized = 0x00U, /*!< Flash swap system is in uninitialized state.*/ 00338 kFLASH_swapStateReady = 0x01U, /*!< Flash swap system is in ready state.*/ 00339 kFLASH_swapStateUpdate = 0x02U, /*!< Flash swap system is in update state.*/ 00340 kFLASH_swapStateUpdateErased = 0x03U, /*!< Flash swap system is in updateErased state.*/ 00341 kFLASH_swapStateComplete = 0x04U, /*!< Flash swap system is in complete state.*/ 00342 kFLASH_swapStateDisabled = 0x05U /*!< Flash swap system is in disabled state.*/ 00343 } flash_swap_state_t; 00344 00345 /*! 00346 * @breif Enumeration for the possible flash swap block status 00347 */ 00348 typedef enum _flash_swap_block_status 00349 { 00350 kFLASH_swapBlockStatusLowerHalfProgramBlocksAtZero = 00351 0x00U, /*!< Swap block status is that lower half program block at zero.*/ 00352 kFLASH_swapBlockStatusUpperHalfProgramBlocksAtZero = 00353 0x01U, /*!< Swap block status is that upper half program block at zero.*/ 00354 } flash_swap_block_status_t ; 00355 00356 /*! 00357 * @brief Flash Swap information. 00358 */ 00359 typedef struct _flash_swap_state_config 00360 { 00361 flash_swap_state_t flashSwapState ; /*!< Current swap system status.*/ 00362 flash_swap_block_status_t currentSwapBlockStatus ; /*!< Current swap block status.*/ 00363 flash_swap_block_status_t nextSwapBlockStatus ; /*!< Next swap block status.*/ 00364 } flash_swap_state_config_t; 00365 00366 /*! 00367 * @brief Flash Swap IFR fileds. 00368 */ 00369 typedef struct _flash_swap_ifr_field_config 00370 { 00371 uint16_t swapIndicatorAddress ; /*!< Swap indicator address field.*/ 00372 uint16_t swapEnableWord ; /*!< Swap enable word field.*/ 00373 uint8_t reserved0 [6]; /*!< Reserved field.*/ 00374 uint16_t swapDisableWord ; /*!< Swap disable word field.*/ 00375 uint8_t reserved1 [4]; /*!< Reserved field.*/ 00376 } flash_swap_ifr_field_config_t; 00377 00378 /*! 00379 * @brief Enumeration for FlexRAM load during reset option. 00380 */ 00381 typedef enum _flash_partition_flexram_load_option 00382 { 00383 kFLASH_partitionFlexramLoadOptionLoadedWithValidEepromData = 00384 0x00U, /*!< FlexRAM is loaded with valid EEPROM data during reset sequence.*/ 00385 kFLASH_partitionFlexramLoadOptionNotLoaded = 0x01U /*!< FlexRAM is not loaded during reset sequence.*/ 00386 } flash_partition_flexram_load_option_t; 00387 00388 /*! @brief callback type used for pflash block*/ 00389 typedef void (*flash_callback_t)(void); 00390 00391 /*! 00392 * @brief Active flash information for current operation. 00393 */ 00394 typedef struct _flash_operation_config 00395 { 00396 uint32_t convertedAddress ; /*!< Converted address for current flash type.*/ 00397 uint32_t activeSectorSize ; /*!< Sector size of current flash type.*/ 00398 uint32_t activeBlockSize ; /*!< Block size of current flash type.*/ 00399 uint32_t blockWriteUnitSize ; /*!< write unit size.*/ 00400 uint32_t sectorCmdAddressAligment ; /*!< Erase sector command address alignment.*/ 00401 uint32_t sectionCmdAddressAligment ; /*!< Program/Verify section command address alignment.*/ 00402 uint32_t resourceCmdAddressAligment ; /*!< Read resource command address alignment.*/ 00403 uint32_t checkCmdAddressAligment ; /*!< Program check command address alignment.*/ 00404 } flash_operation_config_t; 00405 00406 /*! @brief Flash driver state information. 00407 * 00408 * An instance of this structure is allocated by the user of the flash driver and 00409 * passed into each of the driver APIs. 00410 */ 00411 typedef struct _flash_config 00412 { 00413 uint32_t PFlashBlockBase ; /*!< Base address of the first PFlash block */ 00414 uint32_t PFlashTotalSize ; /*!< Size of all combined PFlash block. */ 00415 uint32_t PFlashBlockCount ; /*!< Number of PFlash blocks. */ 00416 uint32_t PFlashSectorSize ; /*!< Size in bytes of a sector of PFlash. */ 00417 flash_callback_t PFlashCallback ; /*!< Callback function for flash API. */ 00418 uint32_t PFlashAccessSegmentSize ; /*!< Size in bytes of a access segment of PFlash. */ 00419 uint32_t PFlashAccessSegmentCount ; /*!< Number of PFlash access segments. */ 00420 uint32_t *flashExecuteInRamFunctionInfo ; /*!< Info struct of flash execute-in-ram function. */ 00421 uint32_t FlexRAMBlockBase ; /*!< For FlexNVM device, this is the base address of FlexRAM 00422 For non-FlexNVM device, this is the base address of acceleration RAM memory */ 00423 uint32_t FlexRAMTotalSize ; /*!< For FlexNVM device, this is the size of FlexRAM 00424 For non-FlexNVM device, this is the size of acceleration RAM memory */ 00425 uint32_t DFlashBlockBase ; /*!< For FlexNVM device, this is the base address of D-Flash memory (FlexNVM memory); 00426 For non-FlexNVM device, this field is unused */ 00427 uint32_t DFlashTotalSize ; /*!< For FlexNVM device, this is total size of the FlexNVM memory; 00428 For non-FlexNVM device, this field is unused */ 00429 uint32_t EEpromTotalSize ; /*!< For FlexNVM device, this is the size in byte of EEPROM area which was partitioned 00430 from FlexRAM; 00431 For non-FlexNVM device, this field is unused */ 00432 } flash_config_t; 00433 00434 /******************************************************************************* 00435 * API 00436 ******************************************************************************/ 00437 00438 #if defined(__cplusplus) 00439 extern "C" { 00440 #endif 00441 00442 /*! 00443 * @name Initialization 00444 * @{ 00445 */ 00446 00447 /*! 00448 * @brief Initializes global flash properties structure members 00449 * 00450 * This function checks and initializes Flash module for the other Flash APIs. 00451 * 00452 * @param config Pointer to storage for the driver runtime state. 00453 * 00454 * @retval #kStatus_FLASH_Success Api was executed successfully. 00455 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00456 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00457 * @retval #kStatus_FLASH_PartitionStatusUpdateFailure Failed to update partition status. 00458 */ 00459 status_t FLASH_Init(flash_config_t *config); 00460 00461 /*! 00462 * @brief Set the desired flash callback function 00463 * 00464 * @param config Pointer to storage for the driver runtime state. 00465 * @param callback callback function to be stored in driver 00466 * 00467 * @retval #kStatus_FLASH_Success Api was executed successfully. 00468 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00469 */ 00470 status_t FLASH_SetCallback(flash_config_t *config, flash_callback_t callback); 00471 00472 /*! 00473 * @brief Prepare flash execute-in-ram functions 00474 * 00475 * @param config Pointer to storage for the driver runtime state. 00476 * 00477 * @retval #kStatus_FLASH_Success Api was executed successfully. 00478 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00479 */ 00480 #if FLASH_DRIVER_IS_FLASH_RESIDENT 00481 status_t FLASH_PrepareExecuteInRamFunctions(flash_config_t *config); 00482 #endif 00483 00484 /*@}*/ 00485 00486 /*! 00487 * @name Erasing 00488 * @{ 00489 */ 00490 00491 /*! 00492 * @brief Erases entire flash 00493 * 00494 * @param config Pointer to storage for the driver runtime state. 00495 * @param key value used to validate all flash erase APIs. 00496 * 00497 * @retval #kStatus_FLASH_Success Api was executed successfully. 00498 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00499 * @retval #kStatus_FLASH_EraseKeyError Api erase key is invalid. 00500 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00501 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00502 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00503 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00504 * @retval #kStatus_FLASH_PartitionStatusUpdateFailure Failed to update partition status 00505 */ 00506 status_t FLASH_EraseAll(flash_config_t *config, uint32_t key); 00507 00508 /*! 00509 * @brief Erases flash sectors encompassed by parameters passed into function 00510 * 00511 * This function erases the appropriate number of flash sectors based on the 00512 * desired start address and length. 00513 * 00514 * @param config Pointer to storage for the driver runtime state. 00515 * @param start The start address of the desired flash memory to be erased. 00516 * The start address does not need to be sector aligned but must be word-aligned. 00517 * @param lengthInBytes The length, given in bytes (not words or long-words) 00518 * to be erased. Must be word aligned. 00519 * @param key value used to validate all flash erase APIs. 00520 * 00521 * @retval #kStatus_FLASH_Success Api was executed successfully. 00522 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00523 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 00524 * @retval #kStatus_FLASH_AddressError Address is out of range. 00525 * @retval #kStatus_FLASH_EraseKeyError Api erase key is invalid. 00526 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00527 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00528 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00529 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00530 */ 00531 status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key); 00532 00533 /*! 00534 * @brief Erases entire flash, including protected sectors. 00535 * 00536 * @param config Pointer to storage for the driver runtime state. 00537 * @param key value used to validate all flash erase APIs. 00538 * 00539 * @retval #kStatus_FLASH_Success Api was executed successfully. 00540 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00541 * @retval #kStatus_FLASH_EraseKeyError Api erase key is invalid. 00542 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00543 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00544 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00545 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00546 * @retval #kStatus_FLASH_PartitionStatusUpdateFailure Failed to update partition status 00547 */ 00548 #if defined(FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD) && FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD 00549 status_t FLASH_EraseAllUnsecure(flash_config_t *config, uint32_t key); 00550 #endif 00551 00552 /*! 00553 * @brief Erases all program flash execute-only segments defined by the FXACC registers. 00554 * 00555 * @param config Pointer to storage for the driver runtime state. 00556 * @param key value used to validate all flash erase APIs. 00557 * 00558 * @retval #kStatus_FLASH_Success Api was executed successfully. 00559 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00560 * @retval #kStatus_FLASH_EraseKeyError Api erase key is invalid. 00561 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00562 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00563 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00564 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00565 */ 00566 status_t FLASH_EraseAllExecuteOnlySegments(flash_config_t *config, uint32_t key); 00567 00568 /*@}*/ 00569 00570 /*! 00571 * @name Programming 00572 * @{ 00573 */ 00574 00575 /*! 00576 * @brief Programs flash with data at locations passed in through parameters 00577 * 00578 * This function programs the flash memory with desired data for a given 00579 * flash area as determined by the start address and length. 00580 * 00581 * @param config Pointer to storage for the driver runtime state. 00582 * @param start The start address of the desired flash memory to be programmed. Must be 00583 * word-aligned. 00584 * @param src Pointer to the source buffer of data that is to be programmed 00585 * into the flash. 00586 * @param lengthInBytes The length, given in bytes (not words or long-words) 00587 * to be programmed. Must be word-aligned. 00588 * 00589 * @retval #kStatus_FLASH_Success Api was executed successfully. 00590 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00591 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 00592 * @retval #kStatus_FLASH_AddressError Address is out of range. 00593 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00594 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00595 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00596 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00597 */ 00598 status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes); 00599 00600 /*! 00601 * @brief Programs Program Once Field through parameters 00602 * 00603 * This function programs the Program Once Field with desired data for a given 00604 * flash area as determined by the index and length. 00605 * 00606 * @param config Pointer to storage for the driver runtime state. 00607 * @param index The index indicating which area of Program Once Field to be programmed. 00608 * @param src Pointer to the source buffer of data that is to be programmed 00609 * into the Program Once Field. 00610 * @param lengthInBytes The length, given in bytes (not words or long-words) 00611 * to be programmed. Must be word-aligned. 00612 * 00613 * @retval #kStatus_FLASH_Success Api was executed successfully. 00614 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00615 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00616 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00617 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00618 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00619 */ 00620 status_t FLASH_ProgramOnce(flash_config_t *config, uint32_t index, uint32_t *src, uint32_t lengthInBytes); 00621 00622 /*! 00623 * @brief Programs flash with data at locations passed in through parameters via Program Section command 00624 * 00625 * This function programs the flash memory with desired data for a given 00626 * flash area as determined by the start address and length. 00627 * 00628 * @param config Pointer to storage for the driver runtime state. 00629 * @param start The start address of the desired flash memory to be programmed. Must be 00630 * word-aligned. 00631 * @param src Pointer to the source buffer of data that is to be programmed 00632 * into the flash. 00633 * @param lengthInBytes The length, given in bytes (not words or long-words) 00634 * to be programmed. Must be word-aligned. 00635 * 00636 * @retval #kStatus_FLASH_Success Api was executed successfully. 00637 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00638 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 00639 * @retval #kStatus_FLASH_AddressError Address is out of range. 00640 * @retval #kStatus_FLASH_SetFlexramAsRamError Failed to set flexram as ram 00641 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00642 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00643 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00644 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00645 * @retval #kStatus_FLASH_RecoverFlexramAsEepromError Failed to recover flexram as eeprom 00646 */ 00647 #if defined(FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD) && FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD 00648 status_t FLASH_ProgramSection(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes); 00649 #endif 00650 00651 /*! 00652 * @brief Programs EEPROM with data at locations passed in through parameters 00653 * 00654 * This function programs the Emulated EEPROM with desired data for a given 00655 * flash area as determined by the start address and length. 00656 * 00657 * @param config Pointer to storage for the driver runtime state. 00658 * @param start The start address of the desired flash memory to be programmed. Must be 00659 * word-aligned. 00660 * @param src Pointer to the source buffer of data that is to be programmed 00661 * into the flash. 00662 * @param lengthInBytes The length, given in bytes (not words or long-words) 00663 * to be programmed. Must be word-aligned. 00664 * 00665 * @retval #kStatus_FLASH_Success Api was executed successfully. 00666 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00667 * @retval #kStatus_FLASH_AddressError Address is out of range. 00668 * @retval #kStatus_FLASH_SetFlexramAsEepromError Failed to set flexram as eeprom. 00669 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00670 * @retval #kStatus_FLASH_RecoverFlexramAsRamError Failed to recover flexram as ram 00671 */ 00672 #if FLASH_SSD_IS_FLEXNVM_ENABLED 00673 status_t FLASH_EepromWrite(flash_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes); 00674 #endif 00675 00676 /*@}*/ 00677 00678 /*! 00679 * @name Reading 00680 * @{ 00681 */ 00682 00683 /*! 00684 * @brief Read resource with data at locations passed in through parameters 00685 * 00686 * This function reads the flash memory with desired location for a given 00687 * flash area as determined by the start address and length. 00688 * 00689 * @param config Pointer to storage for the driver runtime state. 00690 * @param start The start address of the desired flash memory to be programmed. Must be 00691 * word-aligned. 00692 * @param dst Pointer to the destination buffer of data that is used to store 00693 * data to be read. 00694 * @param lengthInBytes The length, given in bytes (not words or long-words) 00695 * to be read. Must be word-aligned. 00696 * @param option The resource option which indicates which area should be read back. 00697 * 00698 * @retval #kStatus_FLASH_Success Api was executed successfully. 00699 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00700 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 00701 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00702 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00703 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00704 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00705 */ 00706 #if defined(FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD) && FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD 00707 status_t FLASH_ReadResource( 00708 flash_config_t *config, uint32_t start, uint32_t *dst, uint32_t lengthInBytes, flash_read_resource_option_t option); 00709 #endif 00710 00711 /*! 00712 * @brief Read Program Once Field through parameters 00713 * 00714 * This function reads the read once feild with given index and length 00715 * 00716 * @param config Pointer to storage for the driver runtime state. 00717 * @param index The index indicating the area of program once field to be read. 00718 * @param dst Pointer to the destination buffer of data that is used to store 00719 * data to be read. 00720 * @param lengthInBytes The length, given in bytes (not words or long-words) 00721 * to be programmed. Must be word-aligned. 00722 * 00723 * @retval #kStatus_FLASH_Success Api was executed successfully. 00724 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00725 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00726 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00727 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00728 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00729 */ 00730 status_t FLASH_ReadOnce(flash_config_t *config, uint32_t index, uint32_t *dst, uint32_t lengthInBytes); 00731 00732 /*@}*/ 00733 00734 /*! 00735 * @name Security 00736 * @{ 00737 */ 00738 00739 /*! 00740 * @brief Returns the security state via the pointer passed into the function 00741 * 00742 * This function retrieves the current Flash security status, including the 00743 * security enabling state and the backdoor key enabling state. 00744 * 00745 * @param config Pointer to storage for the driver runtime state. 00746 * @param state Pointer to the value returned for the current security status code: 00747 * 00748 * @retval #kStatus_FLASH_Success Api was executed successfully. 00749 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00750 */ 00751 status_t FLASH_GetSecurityState(flash_config_t *config, flash_security_state_t *state); 00752 00753 /*! 00754 * @brief Allows user to bypass security with a backdoor key 00755 * 00756 * If the MCU is in secured state, this function will unsecure the MCU by 00757 * comparing the provided backdoor key with ones in the Flash Configuration 00758 * Field. 00759 * 00760 * @param config Pointer to storage for the driver runtime state. 00761 * @param backdoorKey Pointer to the user buffer containing the backdoor key. 00762 * 00763 * @retval #kStatus_FLASH_Success Api was executed successfully. 00764 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00765 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00766 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00767 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00768 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00769 */ 00770 status_t FLASH_SecurityBypass(flash_config_t *config, const uint8_t *backdoorKey); 00771 00772 /*@}*/ 00773 00774 /*! 00775 * @name Verification 00776 * @{ 00777 */ 00778 00779 /*! 00780 * @brief Verifies erasure of entire flash at specified margin level 00781 * 00782 * This function will check to see if the flash have been erased to the 00783 * specified read margin level. 00784 * 00785 * @param config Pointer to storage for the driver runtime state. 00786 * @param margin Read margin choice 00787 * 00788 * @retval #kStatus_FLASH_Success Api was executed successfully. 00789 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00790 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00791 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00792 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00793 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00794 */ 00795 status_t FLASH_VerifyEraseAll(flash_config_t *config, flash_margin_value_t margin); 00796 00797 /*! 00798 * @brief Verifies erasure of desired flash area at specified margin level 00799 * 00800 * This function will check the appropriate number of flash sectors based on 00801 * the desired start address and length to see if the flash have been erased 00802 * to the specified read margin level. 00803 * 00804 * @param config Pointer to storage for the driver runtime state. 00805 * @param start The start address of the desired flash memory to be verified. 00806 * The start address does not need to be sector aligned but must be word-aligned. 00807 * @param lengthInBytes The length, given in bytes (not words or long-words) 00808 * to be verified. Must be word-aligned. 00809 * @param margin Read margin choice 00810 * 00811 * @retval #kStatus_FLASH_Success Api was executed successfully. 00812 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00813 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 00814 * @retval #kStatus_FLASH_AddressError Address is out of range. 00815 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00816 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00817 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00818 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00819 */ 00820 status_t FLASH_VerifyErase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, flash_margin_value_t margin); 00821 00822 /*! 00823 * @brief Verifies programming of desired flash area at specified margin level 00824 * 00825 * This function verifies the data programed in the flash memory using the 00826 * Flash Program Check Command and compares it with expected data for a given 00827 * flash area as determined by the start address and length. 00828 * 00829 * @param config Pointer to storage for the driver runtime state. 00830 * @param start The start address of the desired flash memory to be verified. Must be word-aligned. 00831 * @param lengthInBytes The length, given in bytes (not words or long-words) 00832 * to be verified. Must be word-aligned. 00833 * @param expectedData Pointer to the expected data that is to be 00834 * verified against. 00835 * @param margin Read margin choice 00836 * @param failedAddress Pointer to returned failing address. 00837 * @param failedData Pointer to returned failing data. Some derivitives do 00838 * not included failed data as part of the FCCOBx registers. In this 00839 * case, zeros are returned upon failure. 00840 * 00841 * @retval #kStatus_FLASH_Success Api was executed successfully. 00842 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00843 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 00844 * @retval #kStatus_FLASH_AddressError Address is out of range. 00845 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00846 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00847 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00848 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00849 */ 00850 status_t FLASH_VerifyProgram(flash_config_t *config, 00851 uint32_t start, 00852 uint32_t lengthInBytes, 00853 const uint32_t *expectedData, 00854 flash_margin_value_t margin, 00855 uint32_t *failedAddress, 00856 uint32_t *failedData); 00857 00858 /*! 00859 * @brief Verifies if the program flash executeonly segments have been erased to 00860 * the specified read margin level 00861 * 00862 * @param config Pointer to storage for the driver runtime state. 00863 * @param margin Read margin choice 00864 * 00865 * @retval #kStatus_FLASH_Success Api was executed successfully. 00866 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00867 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00868 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00869 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00870 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00871 */ 00872 status_t FLASH_VerifyEraseAllExecuteOnlySegments(flash_config_t *config, flash_margin_value_t margin); 00873 00874 /*@}*/ 00875 00876 /*! 00877 * @name Protection 00878 * @{ 00879 */ 00880 00881 /*! 00882 * @brief Returns the protection state of desired flash area via the pointer passed into the function 00883 * 00884 * This function retrieves the current Flash protect status for a given 00885 * flash area as determined by the start address and length. 00886 * 00887 * @param config Pointer to storage for the driver runtime state. 00888 * @param start The start address of the desired flash memory to be checked. Must be word-aligned. 00889 * @param lengthInBytes The length, given in bytes (not words or long-words) 00890 * to be checked. Must be word-aligned. 00891 * @param protection_state Pointer to the value returned for the current 00892 * protection status code for the desired flash area. 00893 * 00894 * @retval #kStatus_FLASH_Success Api was executed successfully. 00895 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00896 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 00897 * @retval #kStatus_FLASH_AddressError Address is out of range. 00898 */ 00899 status_t FLASH_IsProtected(flash_config_t *config, 00900 uint32_t start, 00901 uint32_t lengthInBytes, 00902 flash_protection_state_t *protection_state); 00903 00904 /*! 00905 * @brief Returns the access state of desired flash area via the pointer passed into the function 00906 * 00907 * This function retrieves the current Flash access status for a given 00908 * flash area as determined by the start address and length. 00909 * 00910 * @param config Pointer to storage for the driver runtime state. 00911 * @param start The start address of the desired flash memory to be checked. Must be word-aligned. 00912 * @param lengthInBytes The length, given in bytes (not words or long-words) 00913 * to be checked. Must be word-aligned. 00914 * @param access_state Pointer to the value returned for the current 00915 * access status code for the desired flash area. 00916 * 00917 * @retval #kStatus_FLASH_Success Api was executed successfully. 00918 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00919 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 00920 * @retval #kStatus_FLASH_AddressError Address is out of range. 00921 */ 00922 status_t FLASH_IsExecuteOnly(flash_config_t *config, 00923 uint32_t start, 00924 uint32_t lengthInBytes, 00925 flash_execute_only_access_state_t *access_state); 00926 00927 /*@}*/ 00928 00929 /*! 00930 * @name Properties 00931 * @{ 00932 */ 00933 00934 /*! 00935 * @brief Returns the desired flash property. 00936 * 00937 * @param config Pointer to storage for the driver runtime state. 00938 * @param whichProperty The desired property from the list of properties in 00939 * enum flash_property_tag_t 00940 * @param value Pointer to the value returned for the desired flash property 00941 * 00942 * @retval #kStatus_FLASH_Success Api was executed successfully. 00943 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00944 * @retval #kStatus_FLASH_UnknownProperty unknown property tag 00945 */ 00946 status_t FLASH_GetProperty(flash_config_t *config, flash_property_tag_t whichProperty, uint32_t *value); 00947 00948 /*@}*/ 00949 00950 /*! 00951 * @name FlexRAM 00952 * @{ 00953 */ 00954 00955 /*! 00956 * @brief Set FlexRAM Function command 00957 * 00958 * @param config Pointer to storage for the driver runtime state. 00959 * @param option The option used to set work mode of FlexRAM 00960 * 00961 * @retval #kStatus_FLASH_Success Api was executed successfully. 00962 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00963 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00964 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00965 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00966 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00967 */ 00968 #if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD 00969 status_t FLASH_SetFlexramFunction(flash_config_t *config, flash_flexram_function_option_t option); 00970 #endif 00971 00972 /*@}*/ 00973 00974 /*! 00975 * @name Swap 00976 * @{ 00977 */ 00978 00979 /*! 00980 * @brief Configure Swap function or Check the swap state of Flash Module 00981 * 00982 * @param config Pointer to storage for the driver runtime state. 00983 * @param address Address used to configure the flash swap function 00984 * @param option The possible option used to configure Flash Swap function or check the flash swap status 00985 * @param returnInfo Pointer to the data which is used to return the information of flash swap. 00986 * 00987 * @retval #kStatus_FLASH_Success Api was executed successfully. 00988 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 00989 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 00990 * @retval #kStatus_FLASH_SwapIndicatorAddressError Swap indicator address is invalid 00991 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 00992 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 00993 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 00994 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 00995 */ 00996 #if defined(FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD) && FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD 00997 status_t FLASH_SwapControl(flash_config_t *config, 00998 uint32_t address, 00999 flash_swap_control_option_t option, 01000 flash_swap_state_config_t *returnInfo); 01001 #endif 01002 01003 /*! 01004 * @brief Swap the lower half flash with the higher half flaock 01005 * 01006 * @param config Pointer to storage for the driver runtime state. 01007 * @param address Address used to configure the flash swap function 01008 * @param option The possible option used to configure Flash Swap function or check the flash swap status 01009 * 01010 * @retval #kStatus_FLASH_Success Api was executed successfully. 01011 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 01012 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 01013 * @retval #kStatus_FLASH_SwapIndicatorAddressError Swap indicator address is invalid 01014 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 01015 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 01016 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 01017 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 01018 * @retval #kStatus_FLASH_SwapSystemNotInUninitialized Swap system is not in uninitialzed state 01019 */ 01020 #if defined(FSL_FEATURE_FLASH_HAS_PFLASH_BLOCK_SWAP) && FSL_FEATURE_FLASH_HAS_PFLASH_BLOCK_SWAP 01021 status_t FLASH_Swap(flash_config_t *config, uint32_t address, flash_swap_function_option_t option); 01022 #endif 01023 01024 /*! 01025 * @name FlexNVM 01026 * @{ 01027 */ 01028 01029 /*! 01030 * @brief Prepares the FlexNVM block for use as data flash, EEPROM backup, or a combination of both and initializes the 01031 * FlexRAM. 01032 * 01033 * @param config Pointer to storage for the driver runtime state. 01034 * @param option The option used to set FlexRAM load behavior during reset. 01035 * @param eepromDataSizeCode Determines the amount of FlexRAM used in each of the available EEPROM subsystems. 01036 * @param flexnvmPartitionCode Specifies how to split the FlexNVM block between data flash memory and EEPROM backup 01037 * memory supporting EEPROM functions. 01038 * 01039 * @retval #kStatus_FLASH_Success Api was executed successfully. 01040 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 01041 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-ram function is not available. 01042 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 01043 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas. 01044 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 01045 */ 01046 #if defined(FSL_FEATURE_FLASH_HAS_PROGRAM_PARTITION_CMD) && FSL_FEATURE_FLASH_HAS_PROGRAM_PARTITION_CMD 01047 status_t FLASH_ProgramPartition(flash_config_t *config, 01048 flash_partition_flexram_load_option_t option, 01049 uint32_t eepromDataSizeCode, 01050 uint32_t flexnvmPartitionCode); 01051 #endif 01052 01053 /*@}*/ 01054 01055 /*! 01056 * @name Flash Protection Utilities 01057 * @{ 01058 */ 01059 01060 /*! 01061 * @brief Set PFLASH Protection to the intended protection status. 01062 * 01063 * @param config Pointer to storage for the driver runtime state. 01064 * @param protectStatus The expected protect status user wants to set to PFlash protection register. Each bit is 01065 * corresponding to protection of 1/32 of the total PFlash. The least significant bit is corresponding to the lowest 01066 * address area of P-Flash. The most significant bit is corresponding to the highest address area of PFlash. There are 01067 * two possible cases as shown below: 01068 * 0: this area is protected. 01069 * 1: this area is unprotected. 01070 * 01071 * @retval #kStatus_FLASH_Success Api was executed successfully. 01072 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 01073 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 01074 */ 01075 status_t FLASH_PflashSetProtection(flash_config_t *config, uint32_t protectStatus); 01076 01077 /*! 01078 * @brief Get PFLASH Protection Status. 01079 * 01080 * @param config Pointer to storage for the driver runtime state. 01081 * @param protectStatus Protect status returned by PFlash IP. Each bit is corresponding to protection of 1/32 of the 01082 * total PFlash. The least significant bit is corresponding to the lowest address area of PFlash. The most significant 01083 * bit is corresponding to the highest address area of PFlash. Thee are two possible cases as below: 01084 * 0: this area is protected. 01085 * 1: this area is unprotected. 01086 * 01087 * @retval #kStatus_FLASH_Success Api was executed successfully. 01088 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 01089 */ 01090 status_t FLASH_PflashGetProtection(flash_config_t *config, uint32_t *protectStatus); 01091 01092 /*! 01093 * @brief Set DFLASH Protection to the intended protection status. 01094 * 01095 * @param config Pointer to storage for the driver runtime state. 01096 * @param protectStatus The expected protect status user wants to set to DFlash protection register. Each bit is 01097 * corresponding to protection of 1/8 of the total DFlash. The least significant bit is corresponding to the lowest 01098 * address area of DFlash. The most significant bit is corresponding to the highest address area of DFlash. There are 01099 * two possible cases as shown below: 01100 * 0: this area is protected. 01101 * 1: this area is unprotected. 01102 * 01103 * @retval #kStatus_FLASH_Success Api was executed successfully. 01104 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 01105 * @retval #kStatus_FLASH_CommandNotSupported Flash api is not supported 01106 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 01107 */ 01108 #if FLASH_SSD_IS_FLEXNVM_ENABLED 01109 status_t FLASH_DflashSetProtection(flash_config_t *config, uint8_t protectStatus); 01110 #endif 01111 01112 /*! 01113 * @brief Get DFLASH Protection Status. 01114 * 01115 * @param config Pointer to storage for the driver runtime state. 01116 * @param protectStatus DFlash Protect status returned by PFlash IP. Each bit is corresponding to protection of 1/8 of 01117 * the total DFlash. The least significant bit is corresponding to the lowest address area of DFlash. The most 01118 * significant bit is corresponding to the highest address area of DFlash and so on. There are two possible cases as 01119 * below: 01120 * 0: this area is protected. 01121 * 1: this area is unprotected. 01122 * 01123 * @retval #kStatus_FLASH_Success Api was executed successfully. 01124 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 01125 * @retval #kStatus_FLASH_CommandNotSupported Flash api is not supported 01126 */ 01127 #if FLASH_SSD_IS_FLEXNVM_ENABLED 01128 status_t FLASH_DflashGetProtection(flash_config_t *config, uint8_t *protectStatus); 01129 #endif 01130 01131 /*! 01132 * @brief Set EEPROM Protection to the intended protection status. 01133 * 01134 * @param config Pointer to storage for the driver runtime state. 01135 * @param protectStatus The expected protect status user wants to set to EEPROM protection register. Each bit is 01136 * corresponding to protection of 1/8 of the total EEPROM. The least significant bit is corresponding to the lowest 01137 * address area of EEPROM. The most significant bit is corresponding to the highest address area of EEPROM, and so on. 01138 * There are two possible cases as shown below: 01139 * 0: this area is protected. 01140 * 1: this area is unprotected. 01141 * 01142 * @retval #kStatus_FLASH_Success Api was executed successfully. 01143 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 01144 * @retval #kStatus_FLASH_CommandNotSupported Flash api is not supported 01145 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution. 01146 */ 01147 #if FLASH_SSD_IS_FLEXNVM_ENABLED 01148 status_t FLASH_EepromSetProtection(flash_config_t *config, uint8_t protectStatus); 01149 #endif 01150 01151 /*! 01152 * @brief Get DFLASH Protection Status. 01153 * 01154 * @param config Pointer to storage for the driver runtime state. 01155 * @param protectStatus DFlash Protect status returned by PFlash IP. Each bit is corresponding to protection of 1/8 of 01156 * the total EEPROM. The least significant bit is corresponding to the lowest address area of EEPROM. The most 01157 * significant bit is corresponding to the highest address area of EEPROM. There are two possible cases as below: 01158 * 0: this area is protected. 01159 * 1: this area is unprotected. 01160 * 01161 * @retval #kStatus_FLASH_Success Api was executed successfully. 01162 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided. 01163 * @retval #kStatus_FLASH_CommandNotSupported Flash api is not supported. 01164 */ 01165 #if FLASH_SSD_IS_FLEXNVM_ENABLED 01166 status_t FLASH_EepromGetProtection(flash_config_t *config, uint8_t *protectStatus); 01167 #endif 01168 01169 /*@}*/ 01170 01171 #if defined(__cplusplus) 01172 } 01173 #endif 01174 01175 /*! @}*/ 01176 01177 #endif /* _FSL_FLASH_H_ */
Generated on Tue Jul 12 2022 15:37:18 by
