Manh Pham / Mbed OS Nucleo_rtos_basic_ir_controller
Committer:
manhpham
Date:
Sat Apr 07 09:22:54 2018 +0000
Revision:
0:c8673aa96267
Nucleo_rtos_basic_ir_controller

Who changed what in which revision?

UserRevisionLine numberNew contents of line
manhpham 0:c8673aa96267 1 /*
manhpham 0:c8673aa96267 2 * Copyright (c) 2013-2016, Freescale Semiconductor, Inc.
manhpham 0:c8673aa96267 3 * All rights reserved.
manhpham 0:c8673aa96267 4 *
manhpham 0:c8673aa96267 5 * Redistribution and use in source and binary forms, with or without modification,
manhpham 0:c8673aa96267 6 * are permitted provided that the following conditions are met:
manhpham 0:c8673aa96267 7 *
manhpham 0:c8673aa96267 8 * o Redistributions of source code must retain the above copyright notice, this list
manhpham 0:c8673aa96267 9 * of conditions and the following disclaimer.
manhpham 0:c8673aa96267 10 *
manhpham 0:c8673aa96267 11 * o Redistributions in binary form must reproduce the above copyright notice, this
manhpham 0:c8673aa96267 12 * list of conditions and the following disclaimer in the documentation and/or
manhpham 0:c8673aa96267 13 * other materials provided with the distribution.
manhpham 0:c8673aa96267 14 *
manhpham 0:c8673aa96267 15 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
manhpham 0:c8673aa96267 16 * contributors may be used to endorse or promote products derived from this
manhpham 0:c8673aa96267 17 * software without specific prior written permission.
manhpham 0:c8673aa96267 18 *
manhpham 0:c8673aa96267 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
manhpham 0:c8673aa96267 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
manhpham 0:c8673aa96267 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
manhpham 0:c8673aa96267 22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
manhpham 0:c8673aa96267 23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
manhpham 0:c8673aa96267 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
manhpham 0:c8673aa96267 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
manhpham 0:c8673aa96267 26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
manhpham 0:c8673aa96267 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
manhpham 0:c8673aa96267 28 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
manhpham 0:c8673aa96267 29 */
manhpham 0:c8673aa96267 30
manhpham 0:c8673aa96267 31 #ifndef _FSL_FLASH_H_
manhpham 0:c8673aa96267 32 #define _FSL_FLASH_H_
manhpham 0:c8673aa96267 33
manhpham 0:c8673aa96267 34 #if (defined(BL_TARGET_FLASH) || defined(BL_TARGET_ROM) || defined(BL_TARGET_RAM))
manhpham 0:c8673aa96267 35 #include <assert.h>
manhpham 0:c8673aa96267 36 #include <string.h>
manhpham 0:c8673aa96267 37 #include "fsl_device_registers.h"
manhpham 0:c8673aa96267 38 #include "bootloader_common.h"
manhpham 0:c8673aa96267 39 #else
manhpham 0:c8673aa96267 40 #include "fsl_common.h"
manhpham 0:c8673aa96267 41 #endif
manhpham 0:c8673aa96267 42
manhpham 0:c8673aa96267 43 /*******************************************************************************
manhpham 0:c8673aa96267 44 * Definitions
manhpham 0:c8673aa96267 45 ******************************************************************************/
manhpham 0:c8673aa96267 46
manhpham 0:c8673aa96267 47 /*!
manhpham 0:c8673aa96267 48 * @addtogroup flash_driver
manhpham 0:c8673aa96267 49 * @{
manhpham 0:c8673aa96267 50 */
manhpham 0:c8673aa96267 51
manhpham 0:c8673aa96267 52 /*!
manhpham 0:c8673aa96267 53 * @name Flash version
manhpham 0:c8673aa96267 54 * @{
manhpham 0:c8673aa96267 55 */
manhpham 0:c8673aa96267 56 /*! @brief Constructs the version number for drivers. */
manhpham 0:c8673aa96267 57 #if !defined(MAKE_VERSION)
manhpham 0:c8673aa96267 58 #define MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix))
manhpham 0:c8673aa96267 59 #endif
manhpham 0:c8673aa96267 60
manhpham 0:c8673aa96267 61 /*! @brief Flash driver version for SDK*/
manhpham 0:c8673aa96267 62 #define FSL_FLASH_DRIVER_VERSION (MAKE_VERSION(2, 2, 0)) /*!< Version 2.2.0. */
manhpham 0:c8673aa96267 63
manhpham 0:c8673aa96267 64 /*! @brief Flash driver version for ROM*/
manhpham 0:c8673aa96267 65 enum _flash_driver_version_constants
manhpham 0:c8673aa96267 66 {
manhpham 0:c8673aa96267 67 kFLASH_DriverVersionName = 'F', /*!< Flash driver version name.*/
manhpham 0:c8673aa96267 68 kFLASH_DriverVersionMajor = 2, /*!< Major flash driver version.*/
manhpham 0:c8673aa96267 69 kFLASH_DriverVersionMinor = 2, /*!< Minor flash driver version.*/
manhpham 0:c8673aa96267 70 kFLASH_DriverVersionBugfix = 0 /*!< Bugfix for flash driver version.*/
manhpham 0:c8673aa96267 71 };
manhpham 0:c8673aa96267 72 /*@}*/
manhpham 0:c8673aa96267 73
manhpham 0:c8673aa96267 74 /*!
manhpham 0:c8673aa96267 75 * @name Flash configuration
manhpham 0:c8673aa96267 76 * @{
manhpham 0:c8673aa96267 77 */
manhpham 0:c8673aa96267 78 /*! @brief Indicates whether to support FlexNVM in the Flash driver */
manhpham 0:c8673aa96267 79 #if !defined(FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT)
manhpham 0:c8673aa96267 80 #define FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT 1 /*!< Enables the FlexNVM support by default. */
manhpham 0:c8673aa96267 81 #endif
manhpham 0:c8673aa96267 82
manhpham 0:c8673aa96267 83 /*! @brief Indicates whether the FlexNVM is enabled in the Flash driver */
manhpham 0:c8673aa96267 84 #define FLASH_SSD_IS_FLEXNVM_ENABLED (FLASH_SSD_CONFIG_ENABLE_FLEXNVM_SUPPORT && FSL_FEATURE_FLASH_HAS_FLEX_NVM)
manhpham 0:c8673aa96267 85
manhpham 0:c8673aa96267 86 /*! @brief Indicates whether the secondary flash is supported in the Flash driver */
manhpham 0:c8673aa96267 87 #if defined(FSL_FEATURE_FLASH_HAS_MULTIPLE_FLASH) || defined(FSL_FEATURE_FLASH_PFLASH_1_START_ADDRESS)
manhpham 0:c8673aa96267 88 #define FLASH_SSD_IS_SECONDARY_FLASH_SUPPORTED (1)
manhpham 0:c8673aa96267 89 #else
manhpham 0:c8673aa96267 90 #define FLASH_SSD_IS_SECONDARY_FLASH_SUPPORTED (0)
manhpham 0:c8673aa96267 91 #endif
manhpham 0:c8673aa96267 92
manhpham 0:c8673aa96267 93 /*! @brief Indicates whether the secondary flash has its own protection register in flash module */
manhpham 0:c8673aa96267 94 #if defined(FSL_FEATURE_FLASH_HAS_MULTIPLE_FLASH) && defined(FTFE_FPROTS_PROTS_MASK)
manhpham 0:c8673aa96267 95 #define FLASH_SSD_SECONDARY_FLASH_HAS_ITS_OWN_PROTECTION_REGISTER (1)
manhpham 0:c8673aa96267 96 #else
manhpham 0:c8673aa96267 97 #define FLASH_SSD_SECONDARY_FLASH_HAS_ITS_OWN_PROTECTION_REGISTER (0)
manhpham 0:c8673aa96267 98 #endif
manhpham 0:c8673aa96267 99
manhpham 0:c8673aa96267 100 /*! @brief Indicates whether the secondary flash has its own Execute-Only access register in flash module */
manhpham 0:c8673aa96267 101 #if defined(FSL_FEATURE_FLASH_HAS_MULTIPLE_FLASH) && defined(FTFE_FACSSS_SGSIZE_S_MASK)
manhpham 0:c8673aa96267 102 #define FLASH_SSD_SECONDARY_FLASH_HAS_ITS_OWN_ACCESS_REGISTER (1)
manhpham 0:c8673aa96267 103 #else
manhpham 0:c8673aa96267 104 #define FLASH_SSD_SECONDARY_FLASH_HAS_ITS_OWN_ACCESS_REGISTER (0)
manhpham 0:c8673aa96267 105 #endif
manhpham 0:c8673aa96267 106
manhpham 0:c8673aa96267 107 /*! @brief Flash driver location. */
manhpham 0:c8673aa96267 108 #if !defined(FLASH_DRIVER_IS_FLASH_RESIDENT)
manhpham 0:c8673aa96267 109 #if (!defined(BL_TARGET_ROM) && !defined(BL_TARGET_RAM))
manhpham 0:c8673aa96267 110 #define FLASH_DRIVER_IS_FLASH_RESIDENT 1 /*!< Used for the flash resident application. */
manhpham 0:c8673aa96267 111 #else
manhpham 0:c8673aa96267 112 #define FLASH_DRIVER_IS_FLASH_RESIDENT 0 /*!< Used for the non-flash resident application. */
manhpham 0:c8673aa96267 113 #endif
manhpham 0:c8673aa96267 114 #endif
manhpham 0:c8673aa96267 115
manhpham 0:c8673aa96267 116 /*! @brief Flash Driver Export option */
manhpham 0:c8673aa96267 117 #if !defined(FLASH_DRIVER_IS_EXPORTED)
manhpham 0:c8673aa96267 118 #if (defined(BL_TARGET_ROM) || defined(BL_TARGET_FLASH))
manhpham 0:c8673aa96267 119 #define FLASH_DRIVER_IS_EXPORTED 1 /*!< Used for the ROM bootloader. */
manhpham 0:c8673aa96267 120 #else
manhpham 0:c8673aa96267 121 #define FLASH_DRIVER_IS_EXPORTED 0 /*!< Used for the KSDK application. */
manhpham 0:c8673aa96267 122 #endif
manhpham 0:c8673aa96267 123 #endif
manhpham 0:c8673aa96267 124 /*@}*/
manhpham 0:c8673aa96267 125
manhpham 0:c8673aa96267 126 /*!
manhpham 0:c8673aa96267 127 * @name Flash status
manhpham 0:c8673aa96267 128 * @{
manhpham 0:c8673aa96267 129 */
manhpham 0:c8673aa96267 130 /*! @brief Flash driver status group. */
manhpham 0:c8673aa96267 131 #if defined(kStatusGroup_FlashDriver)
manhpham 0:c8673aa96267 132 #define kStatusGroupGeneric kStatusGroup_Generic
manhpham 0:c8673aa96267 133 #define kStatusGroupFlashDriver kStatusGroup_FlashDriver
manhpham 0:c8673aa96267 134 #elif defined(kStatusGroup_FLASH)
manhpham 0:c8673aa96267 135 #define kStatusGroupGeneric kStatusGroup_Generic
manhpham 0:c8673aa96267 136 #define kStatusGroupFlashDriver kStatusGroup_FLASH
manhpham 0:c8673aa96267 137 #else
manhpham 0:c8673aa96267 138 #define kStatusGroupGeneric 0
manhpham 0:c8673aa96267 139 #define kStatusGroupFlashDriver 1
manhpham 0:c8673aa96267 140 #endif
manhpham 0:c8673aa96267 141
manhpham 0:c8673aa96267 142 /*! @brief Constructs a status code value from a group and a code number. */
manhpham 0:c8673aa96267 143 #if !defined(MAKE_STATUS)
manhpham 0:c8673aa96267 144 #define MAKE_STATUS(group, code) ((((group)*100) + (code)))
manhpham 0:c8673aa96267 145 #endif
manhpham 0:c8673aa96267 146
manhpham 0:c8673aa96267 147 /*!
manhpham 0:c8673aa96267 148 * @brief Flash driver status codes.
manhpham 0:c8673aa96267 149 */
manhpham 0:c8673aa96267 150 enum _flash_status
manhpham 0:c8673aa96267 151 {
manhpham 0:c8673aa96267 152 kStatus_FLASH_Success = MAKE_STATUS(kStatusGroupGeneric, 0), /*!< API is executed successfully*/
manhpham 0:c8673aa96267 153 kStatus_FLASH_InvalidArgument = MAKE_STATUS(kStatusGroupGeneric, 4), /*!< Invalid argument*/
manhpham 0:c8673aa96267 154 kStatus_FLASH_SizeError = MAKE_STATUS(kStatusGroupFlashDriver, 0), /*!< Error size*/
manhpham 0:c8673aa96267 155 kStatus_FLASH_AlignmentError =
manhpham 0:c8673aa96267 156 MAKE_STATUS(kStatusGroupFlashDriver, 1), /*!< Parameter is not aligned with the specified baseline*/
manhpham 0:c8673aa96267 157 kStatus_FLASH_AddressError = MAKE_STATUS(kStatusGroupFlashDriver, 2), /*!< Address is out of range */
manhpham 0:c8673aa96267 158 kStatus_FLASH_AccessError =
manhpham 0:c8673aa96267 159 MAKE_STATUS(kStatusGroupFlashDriver, 3), /*!< Invalid instruction codes and out-of bound addresses */
manhpham 0:c8673aa96267 160 kStatus_FLASH_ProtectionViolation = MAKE_STATUS(
manhpham 0:c8673aa96267 161 kStatusGroupFlashDriver, 4), /*!< The program/erase operation is requested to execute on protected areas */
manhpham 0:c8673aa96267 162 kStatus_FLASH_CommandFailure =
manhpham 0:c8673aa96267 163 MAKE_STATUS(kStatusGroupFlashDriver, 5), /*!< Run-time error during command execution. */
manhpham 0:c8673aa96267 164 kStatus_FLASH_UnknownProperty = MAKE_STATUS(kStatusGroupFlashDriver, 6), /*!< Unknown property.*/
manhpham 0:c8673aa96267 165 kStatus_FLASH_EraseKeyError = MAKE_STATUS(kStatusGroupFlashDriver, 7), /*!< API erase key is invalid.*/
manhpham 0:c8673aa96267 166 kStatus_FLASH_RegionExecuteOnly =
manhpham 0:c8673aa96267 167 MAKE_STATUS(kStatusGroupFlashDriver, 8), /*!< The current region is execute-only.*/
manhpham 0:c8673aa96267 168 kStatus_FLASH_ExecuteInRamFunctionNotReady =
manhpham 0:c8673aa96267 169 MAKE_STATUS(kStatusGroupFlashDriver, 9), /*!< Execute-in-RAM function is not available.*/
manhpham 0:c8673aa96267 170 kStatus_FLASH_PartitionStatusUpdateFailure =
manhpham 0:c8673aa96267 171 MAKE_STATUS(kStatusGroupFlashDriver, 10), /*!< Failed to update partition status.*/
manhpham 0:c8673aa96267 172 kStatus_FLASH_SetFlexramAsEepromError =
manhpham 0:c8673aa96267 173 MAKE_STATUS(kStatusGroupFlashDriver, 11), /*!< Failed to set FlexRAM as EEPROM.*/
manhpham 0:c8673aa96267 174 kStatus_FLASH_RecoverFlexramAsRamError =
manhpham 0:c8673aa96267 175 MAKE_STATUS(kStatusGroupFlashDriver, 12), /*!< Failed to recover FlexRAM as RAM.*/
manhpham 0:c8673aa96267 176 kStatus_FLASH_SetFlexramAsRamError = MAKE_STATUS(kStatusGroupFlashDriver, 13), /*!< Failed to set FlexRAM as RAM.*/
manhpham 0:c8673aa96267 177 kStatus_FLASH_RecoverFlexramAsEepromError =
manhpham 0:c8673aa96267 178 MAKE_STATUS(kStatusGroupFlashDriver, 14), /*!< Failed to recover FlexRAM as EEPROM.*/
manhpham 0:c8673aa96267 179 kStatus_FLASH_CommandNotSupported = MAKE_STATUS(kStatusGroupFlashDriver, 15), /*!< Flash API is not supported.*/
manhpham 0:c8673aa96267 180 kStatus_FLASH_SwapSystemNotInUninitialized =
manhpham 0:c8673aa96267 181 MAKE_STATUS(kStatusGroupFlashDriver, 16), /*!< Swap system is not in an uninitialzed state.*/
manhpham 0:c8673aa96267 182 kStatus_FLASH_SwapIndicatorAddressError =
manhpham 0:c8673aa96267 183 MAKE_STATUS(kStatusGroupFlashDriver, 17), /*!< The swap indicator address is invalid.*/
manhpham 0:c8673aa96267 184 kStatus_FLASH_ReadOnlyProperty = MAKE_STATUS(kStatusGroupFlashDriver, 18), /*!< The flash property is read-only.*/
manhpham 0:c8673aa96267 185 kStatus_FLASH_InvalidPropertyValue =
manhpham 0:c8673aa96267 186 MAKE_STATUS(kStatusGroupFlashDriver, 19), /*!< The flash property value is out of range.*/
manhpham 0:c8673aa96267 187 kStatus_FLASH_InvalidSpeculationOption =
manhpham 0:c8673aa96267 188 MAKE_STATUS(kStatusGroupFlashDriver, 20), /*!< The option of flash prefetch speculation is invalid.*/
manhpham 0:c8673aa96267 189 };
manhpham 0:c8673aa96267 190 /*@}*/
manhpham 0:c8673aa96267 191
manhpham 0:c8673aa96267 192 /*!
manhpham 0:c8673aa96267 193 * @name Flash API key
manhpham 0:c8673aa96267 194 * @{
manhpham 0:c8673aa96267 195 */
manhpham 0:c8673aa96267 196 /*! @brief Constructs the four character code for the Flash driver API key. */
manhpham 0:c8673aa96267 197 #if !defined(FOUR_CHAR_CODE)
manhpham 0:c8673aa96267 198 #define FOUR_CHAR_CODE(a, b, c, d) (((d) << 24) | ((c) << 16) | ((b) << 8) | ((a)))
manhpham 0:c8673aa96267 199 #endif
manhpham 0:c8673aa96267 200
manhpham 0:c8673aa96267 201 /*!
manhpham 0:c8673aa96267 202 * @brief Enumeration for Flash driver API keys.
manhpham 0:c8673aa96267 203 *
manhpham 0:c8673aa96267 204 * @note The resulting value is built with a byte order such that the string
manhpham 0:c8673aa96267 205 * being readable in expected order when viewed in a hex editor, if the value
manhpham 0:c8673aa96267 206 * is treated as a 32-bit little endian value.
manhpham 0:c8673aa96267 207 */
manhpham 0:c8673aa96267 208 enum _flash_driver_api_keys
manhpham 0:c8673aa96267 209 {
manhpham 0:c8673aa96267 210 kFLASH_ApiEraseKey = FOUR_CHAR_CODE('k', 'f', 'e', 'k') /*!< Key value used to validate all flash erase APIs.*/
manhpham 0:c8673aa96267 211 };
manhpham 0:c8673aa96267 212 /*@}*/
manhpham 0:c8673aa96267 213
manhpham 0:c8673aa96267 214 /*!
manhpham 0:c8673aa96267 215 * @brief Enumeration for supported flash margin levels.
manhpham 0:c8673aa96267 216 */
manhpham 0:c8673aa96267 217 typedef enum _flash_margin_value
manhpham 0:c8673aa96267 218 {
manhpham 0:c8673aa96267 219 kFLASH_MarginValueNormal, /*!< Use the 'normal' read level for 1s.*/
manhpham 0:c8673aa96267 220 kFLASH_MarginValueUser, /*!< Apply the 'User' margin to the normal read-1 level.*/
manhpham 0:c8673aa96267 221 kFLASH_MarginValueFactory, /*!< Apply the 'Factory' margin to the normal read-1 level.*/
manhpham 0:c8673aa96267 222 kFLASH_MarginValueInvalid /*!< Not real margin level, Used to determine the range of valid margin level. */
manhpham 0:c8673aa96267 223 } flash_margin_value_t;
manhpham 0:c8673aa96267 224
manhpham 0:c8673aa96267 225 /*!
manhpham 0:c8673aa96267 226 * @brief Enumeration for the three possible flash security states.
manhpham 0:c8673aa96267 227 */
manhpham 0:c8673aa96267 228 typedef enum _flash_security_state
manhpham 0:c8673aa96267 229 {
manhpham 0:c8673aa96267 230 kFLASH_SecurityStateNotSecure, /*!< Flash is not secure.*/
manhpham 0:c8673aa96267 231 kFLASH_SecurityStateBackdoorEnabled, /*!< Flash backdoor is enabled.*/
manhpham 0:c8673aa96267 232 kFLASH_SecurityStateBackdoorDisabled /*!< Flash backdoor is disabled.*/
manhpham 0:c8673aa96267 233 } flash_security_state_t;
manhpham 0:c8673aa96267 234
manhpham 0:c8673aa96267 235 /*!
manhpham 0:c8673aa96267 236 * @brief Enumeration for the three possible flash protection levels.
manhpham 0:c8673aa96267 237 */
manhpham 0:c8673aa96267 238 typedef enum _flash_protection_state
manhpham 0:c8673aa96267 239 {
manhpham 0:c8673aa96267 240 kFLASH_ProtectionStateUnprotected, /*!< Flash region is not protected.*/
manhpham 0:c8673aa96267 241 kFLASH_ProtectionStateProtected, /*!< Flash region is protected.*/
manhpham 0:c8673aa96267 242 kFLASH_ProtectionStateMixed /*!< Flash is mixed with protected and unprotected region.*/
manhpham 0:c8673aa96267 243 } flash_protection_state_t;
manhpham 0:c8673aa96267 244
manhpham 0:c8673aa96267 245 /*!
manhpham 0:c8673aa96267 246 * @brief Enumeration for the three possible flash execute access levels.
manhpham 0:c8673aa96267 247 */
manhpham 0:c8673aa96267 248 typedef enum _flash_execute_only_access_state
manhpham 0:c8673aa96267 249 {
manhpham 0:c8673aa96267 250 kFLASH_AccessStateUnLimited, /*!< Flash region is unlimited.*/
manhpham 0:c8673aa96267 251 kFLASH_AccessStateExecuteOnly, /*!< Flash region is execute only.*/
manhpham 0:c8673aa96267 252 kFLASH_AccessStateMixed /*!< Flash is mixed with unlimited and execute only region.*/
manhpham 0:c8673aa96267 253 } flash_execute_only_access_state_t;
manhpham 0:c8673aa96267 254
manhpham 0:c8673aa96267 255 /*!
manhpham 0:c8673aa96267 256 * @brief Enumeration for various flash properties.
manhpham 0:c8673aa96267 257 */
manhpham 0:c8673aa96267 258 typedef enum _flash_property_tag
manhpham 0:c8673aa96267 259 {
manhpham 0:c8673aa96267 260 kFLASH_PropertyPflashSectorSize = 0x00U, /*!< Pflash sector size property.*/
manhpham 0:c8673aa96267 261 kFLASH_PropertyPflashTotalSize = 0x01U, /*!< Pflash total size property.*/
manhpham 0:c8673aa96267 262 kFLASH_PropertyPflashBlockSize = 0x02U, /*!< Pflash block size property.*/
manhpham 0:c8673aa96267 263 kFLASH_PropertyPflashBlockCount = 0x03U, /*!< Pflash block count property.*/
manhpham 0:c8673aa96267 264 kFLASH_PropertyPflashBlockBaseAddr = 0x04U, /*!< Pflash block base address property.*/
manhpham 0:c8673aa96267 265 kFLASH_PropertyPflashFacSupport = 0x05U, /*!< Pflash fac support property.*/
manhpham 0:c8673aa96267 266 kFLASH_PropertyPflashAccessSegmentSize = 0x06U, /*!< Pflash access segment size property.*/
manhpham 0:c8673aa96267 267 kFLASH_PropertyPflashAccessSegmentCount = 0x07U, /*!< Pflash access segment count property.*/
manhpham 0:c8673aa96267 268 kFLASH_PropertyFlexRamBlockBaseAddr = 0x08U, /*!< FlexRam block base address property.*/
manhpham 0:c8673aa96267 269 kFLASH_PropertyFlexRamTotalSize = 0x09U, /*!< FlexRam total size property.*/
manhpham 0:c8673aa96267 270 kFLASH_PropertyDflashSectorSize = 0x10U, /*!< Dflash sector size property.*/
manhpham 0:c8673aa96267 271 kFLASH_PropertyDflashTotalSize = 0x11U, /*!< Dflash total size property.*/
manhpham 0:c8673aa96267 272 kFLASH_PropertyDflashBlockSize = 0x12U, /*!< Dflash block size property.*/
manhpham 0:c8673aa96267 273 kFLASH_PropertyDflashBlockCount = 0x13U, /*!< Dflash block count property.*/
manhpham 0:c8673aa96267 274 kFLASH_PropertyDflashBlockBaseAddr = 0x14U, /*!< Dflash block base address property.*/
manhpham 0:c8673aa96267 275 kFLASH_PropertyEepromTotalSize = 0x15U, /*!< EEPROM total size property.*/
manhpham 0:c8673aa96267 276 kFLASH_PropertyFlashMemoryIndex = 0x20U /*!< Flash memory index property.*/
manhpham 0:c8673aa96267 277 } flash_property_tag_t;
manhpham 0:c8673aa96267 278
manhpham 0:c8673aa96267 279 /*!
manhpham 0:c8673aa96267 280 * @brief Constants for execute-in-RAM flash function.
manhpham 0:c8673aa96267 281 */
manhpham 0:c8673aa96267 282 enum _flash_execute_in_ram_function_constants
manhpham 0:c8673aa96267 283 {
manhpham 0:c8673aa96267 284 kFLASH_ExecuteInRamFunctionMaxSizeInWords = 16U, /*!< The maximum size of execute-in-RAM function.*/
manhpham 0:c8673aa96267 285 kFLASH_ExecuteInRamFunctionTotalNum = 2U /*!< Total number of execute-in-RAM functions.*/
manhpham 0:c8673aa96267 286 };
manhpham 0:c8673aa96267 287
manhpham 0:c8673aa96267 288 /*!
manhpham 0:c8673aa96267 289 * @brief Flash execute-in-RAM function information.
manhpham 0:c8673aa96267 290 */
manhpham 0:c8673aa96267 291 typedef struct _flash_execute_in_ram_function_config
manhpham 0:c8673aa96267 292 {
manhpham 0:c8673aa96267 293 uint32_t activeFunctionCount; /*!< Number of available execute-in-RAM functions.*/
manhpham 0:c8673aa96267 294 uint32_t *flashRunCommand; /*!< Execute-in-RAM function: flash_run_command.*/
manhpham 0:c8673aa96267 295 uint32_t *flashCommonBitOperation; /*!< Execute-in-RAM function: flash_common_bit_operation.*/
manhpham 0:c8673aa96267 296 } flash_execute_in_ram_function_config_t;
manhpham 0:c8673aa96267 297
manhpham 0:c8673aa96267 298 /*!
manhpham 0:c8673aa96267 299 * @brief Enumeration for the two possible options of flash read resource command.
manhpham 0:c8673aa96267 300 */
manhpham 0:c8673aa96267 301 typedef enum _flash_read_resource_option
manhpham 0:c8673aa96267 302 {
manhpham 0:c8673aa96267 303 kFLASH_ResourceOptionFlashIfr =
manhpham 0:c8673aa96267 304 0x00U, /*!< Select code for Program flash 0 IFR, Program flash swap 0 IFR, Data flash 0 IFR */
manhpham 0:c8673aa96267 305 kFLASH_ResourceOptionVersionId = 0x01U /*!< Select code for the version ID*/
manhpham 0:c8673aa96267 306 } flash_read_resource_option_t;
manhpham 0:c8673aa96267 307
manhpham 0:c8673aa96267 308 /*!
manhpham 0:c8673aa96267 309 * @brief Enumeration for the range of special-purpose flash resource
manhpham 0:c8673aa96267 310 */
manhpham 0:c8673aa96267 311 enum _flash_read_resource_range
manhpham 0:c8673aa96267 312 {
manhpham 0:c8673aa96267 313 #if (FSL_FEATURE_FLASH_IS_FTFE == 1)
manhpham 0:c8673aa96267 314 kFLASH_ResourceRangePflashIfrSizeInBytes = 1024U, /*!< Pflash IFR size in byte.*/
manhpham 0:c8673aa96267 315 kFLASH_ResourceRangeVersionIdSizeInBytes = 8U, /*!< Version ID IFR size in byte.*/
manhpham 0:c8673aa96267 316 kFLASH_ResourceRangeVersionIdStart = 0x08U, /*!< Version ID IFR start address.*/
manhpham 0:c8673aa96267 317 kFLASH_ResourceRangeVersionIdEnd = 0x0FU, /*!< Version ID IFR end address.*/
manhpham 0:c8673aa96267 318 kFLASH_ResourceRangePflashSwapIfrStart = 0x40000U, /*!< Pflash swap IFR start address.*/
manhpham 0:c8673aa96267 319 kFLASH_ResourceRangePflashSwapIfrEnd =
manhpham 0:c8673aa96267 320 (kFLASH_ResourceRangePflashSwapIfrStart + 0x3FFU), /*!< Pflash swap IFR end address.*/
manhpham 0:c8673aa96267 321 #else /* FSL_FEATURE_FLASH_IS_FTFL == 1 or FSL_FEATURE_FLASH_IS_FTFA = =1 */
manhpham 0:c8673aa96267 322 kFLASH_ResourceRangePflashIfrSizeInBytes = 256U, /*!< Pflash IFR size in byte.*/
manhpham 0:c8673aa96267 323 kFLASH_ResourceRangeVersionIdSizeInBytes = 8U, /*!< Version ID IFR size in byte.*/
manhpham 0:c8673aa96267 324 kFLASH_ResourceRangeVersionIdStart = 0x00U, /*!< Version ID IFR start address.*/
manhpham 0:c8673aa96267 325 kFLASH_ResourceRangeVersionIdEnd = 0x07U, /*!< Version ID IFR end address.*/
manhpham 0:c8673aa96267 326 #if 0x20000U == (FSL_FEATURE_FLASH_PFLASH_BLOCK_COUNT * FSL_FEATURE_FLASH_PFLASH_BLOCK_SIZE)
manhpham 0:c8673aa96267 327 kFLASH_ResourceRangePflashSwapIfrStart = 0x8000U, /*!< Pflash swap IFR start address.*/
manhpham 0:c8673aa96267 328 #elif 0x40000U == (FSL_FEATURE_FLASH_PFLASH_BLOCK_COUNT * FSL_FEATURE_FLASH_PFLASH_BLOCK_SIZE)
manhpham 0:c8673aa96267 329 kFLASH_ResourceRangePflashSwapIfrStart = 0x10000U, /*!< Pflash swap IFR start address.*/
manhpham 0:c8673aa96267 330 #elif 0x80000U == (FSL_FEATURE_FLASH_PFLASH_BLOCK_COUNT * FSL_FEATURE_FLASH_PFLASH_BLOCK_SIZE)
manhpham 0:c8673aa96267 331 kFLASH_ResourceRangePflashSwapIfrStart = 0x20000U, /*!< Pflash swap IFR start address.*/
manhpham 0:c8673aa96267 332 #else
manhpham 0:c8673aa96267 333 kFLASH_ResourceRangePflashSwapIfrStart = 0,
manhpham 0:c8673aa96267 334 #endif
manhpham 0:c8673aa96267 335 kFLASH_ResourceRangePflashSwapIfrEnd =
manhpham 0:c8673aa96267 336 (kFLASH_ResourceRangePflashSwapIfrStart + 0xFFU), /*!< Pflash swap IFR end address.*/
manhpham 0:c8673aa96267 337 #endif
manhpham 0:c8673aa96267 338 kFLASH_ResourceRangeDflashIfrStart = 0x800000U, /*!< Dflash IFR start address.*/
manhpham 0:c8673aa96267 339 kFLASH_ResourceRangeDflashIfrEnd = 0x8003FFU, /*!< Dflash IFR end address.*/
manhpham 0:c8673aa96267 340 };
manhpham 0:c8673aa96267 341
manhpham 0:c8673aa96267 342 /*!
manhpham 0:c8673aa96267 343 * @brief Enumeration for the two possilbe options of set FlexRAM function command.
manhpham 0:c8673aa96267 344 */
manhpham 0:c8673aa96267 345 typedef enum _flash_flexram_function_option
manhpham 0:c8673aa96267 346 {
manhpham 0:c8673aa96267 347 kFLASH_FlexramFunctionOptionAvailableAsRam = 0xFFU, /*!< An option used to make FlexRAM available as RAM */
manhpham 0:c8673aa96267 348 kFLASH_FlexramFunctionOptionAvailableForEeprom = 0x00U /*!< An option used to make FlexRAM available for EEPROM */
manhpham 0:c8673aa96267 349 } flash_flexram_function_option_t;
manhpham 0:c8673aa96267 350
manhpham 0:c8673aa96267 351 /*!
manhpham 0:c8673aa96267 352 * @brief Enumeration for acceleration RAM property.
manhpham 0:c8673aa96267 353 */
manhpham 0:c8673aa96267 354 enum _flash_acceleration_ram_property
manhpham 0:c8673aa96267 355 {
manhpham 0:c8673aa96267 356 kFLASH_AccelerationRamSize = 0x400U
manhpham 0:c8673aa96267 357 };
manhpham 0:c8673aa96267 358
manhpham 0:c8673aa96267 359 /*!
manhpham 0:c8673aa96267 360 * @brief Enumeration for the possible options of Swap function
manhpham 0:c8673aa96267 361 */
manhpham 0:c8673aa96267 362 typedef enum _flash_swap_function_option
manhpham 0:c8673aa96267 363 {
manhpham 0:c8673aa96267 364 kFLASH_SwapFunctionOptionEnable = 0x00U, /*!< An option used to enable the Swap function */
manhpham 0:c8673aa96267 365 kFLASH_SwapFunctionOptionDisable = 0x01U /*!< An option used to disable the Swap function */
manhpham 0:c8673aa96267 366 } flash_swap_function_option_t;
manhpham 0:c8673aa96267 367
manhpham 0:c8673aa96267 368 /*!
manhpham 0:c8673aa96267 369 * @brief Enumeration for the possible options of Swap control commands
manhpham 0:c8673aa96267 370 */
manhpham 0:c8673aa96267 371 typedef enum _flash_swap_control_option
manhpham 0:c8673aa96267 372 {
manhpham 0:c8673aa96267 373 kFLASH_SwapControlOptionIntializeSystem = 0x01U, /*!< An option used to initialize the Swap system */
manhpham 0:c8673aa96267 374 kFLASH_SwapControlOptionSetInUpdateState = 0x02U, /*!< An option used to set the Swap in an update state */
manhpham 0:c8673aa96267 375 kFLASH_SwapControlOptionSetInCompleteState = 0x04U, /*!< An option used to set the Swap in a complete state */
manhpham 0:c8673aa96267 376 kFLASH_SwapControlOptionReportStatus = 0x08U, /*!< An option used to report the Swap status */
manhpham 0:c8673aa96267 377 kFLASH_SwapControlOptionDisableSystem = 0x10U /*!< An option used to disable the Swap status */
manhpham 0:c8673aa96267 378 } flash_swap_control_option_t;
manhpham 0:c8673aa96267 379
manhpham 0:c8673aa96267 380 /*!
manhpham 0:c8673aa96267 381 * @brief Enumeration for the possible flash Swap status.
manhpham 0:c8673aa96267 382 */
manhpham 0:c8673aa96267 383 typedef enum _flash_swap_state
manhpham 0:c8673aa96267 384 {
manhpham 0:c8673aa96267 385 kFLASH_SwapStateUninitialized = 0x00U, /*!< Flash Swap system is in an uninitialized state.*/
manhpham 0:c8673aa96267 386 kFLASH_SwapStateReady = 0x01U, /*!< Flash Swap system is in a ready state.*/
manhpham 0:c8673aa96267 387 kFLASH_SwapStateUpdate = 0x02U, /*!< Flash Swap system is in an update state.*/
manhpham 0:c8673aa96267 388 kFLASH_SwapStateUpdateErased = 0x03U, /*!< Flash Swap system is in an updateErased state.*/
manhpham 0:c8673aa96267 389 kFLASH_SwapStateComplete = 0x04U, /*!< Flash Swap system is in a complete state.*/
manhpham 0:c8673aa96267 390 kFLASH_SwapStateDisabled = 0x05U /*!< Flash Swap system is in a disabled state.*/
manhpham 0:c8673aa96267 391 } flash_swap_state_t;
manhpham 0:c8673aa96267 392
manhpham 0:c8673aa96267 393 /*!
manhpham 0:c8673aa96267 394 * @breif Enumeration for the possible flash Swap block status
manhpham 0:c8673aa96267 395 */
manhpham 0:c8673aa96267 396 typedef enum _flash_swap_block_status
manhpham 0:c8673aa96267 397 {
manhpham 0:c8673aa96267 398 kFLASH_SwapBlockStatusLowerHalfProgramBlocksAtZero =
manhpham 0:c8673aa96267 399 0x00U, /*!< Swap block status is that lower half program block at zero.*/
manhpham 0:c8673aa96267 400 kFLASH_SwapBlockStatusUpperHalfProgramBlocksAtZero =
manhpham 0:c8673aa96267 401 0x01U, /*!< Swap block status is that upper half program block at zero.*/
manhpham 0:c8673aa96267 402 } flash_swap_block_status_t;
manhpham 0:c8673aa96267 403
manhpham 0:c8673aa96267 404 /*!
manhpham 0:c8673aa96267 405 * @brief Flash Swap information
manhpham 0:c8673aa96267 406 */
manhpham 0:c8673aa96267 407 typedef struct _flash_swap_state_config
manhpham 0:c8673aa96267 408 {
manhpham 0:c8673aa96267 409 flash_swap_state_t flashSwapState; /*!<The current Swap system status.*/
manhpham 0:c8673aa96267 410 flash_swap_block_status_t currentSwapBlockStatus; /*!< The current Swap block status.*/
manhpham 0:c8673aa96267 411 flash_swap_block_status_t nextSwapBlockStatus; /*!< The next Swap block status.*/
manhpham 0:c8673aa96267 412 } flash_swap_state_config_t;
manhpham 0:c8673aa96267 413
manhpham 0:c8673aa96267 414 /*!
manhpham 0:c8673aa96267 415 * @brief Flash Swap IFR fields
manhpham 0:c8673aa96267 416 */
manhpham 0:c8673aa96267 417 typedef struct _flash_swap_ifr_field_config
manhpham 0:c8673aa96267 418 {
manhpham 0:c8673aa96267 419 uint16_t swapIndicatorAddress; /*!< A Swap indicator address field.*/
manhpham 0:c8673aa96267 420 uint16_t swapEnableWord; /*!< A Swap enable word field.*/
manhpham 0:c8673aa96267 421 uint8_t reserved0[4]; /*!< A reserved field.*/
manhpham 0:c8673aa96267 422 #if (FSL_FEATURE_FLASH_IS_FTFE == 1)
manhpham 0:c8673aa96267 423 uint8_t reserved1[2]; /*!< A reserved field.*/
manhpham 0:c8673aa96267 424 uint16_t swapDisableWord; /*!< A Swap disable word field.*/
manhpham 0:c8673aa96267 425 uint8_t reserved2[4]; /*!< A reserved field.*/
manhpham 0:c8673aa96267 426 #endif
manhpham 0:c8673aa96267 427 } flash_swap_ifr_field_config_t;
manhpham 0:c8673aa96267 428
manhpham 0:c8673aa96267 429 /*!
manhpham 0:c8673aa96267 430 * @brief Flash Swap IFR field data
manhpham 0:c8673aa96267 431 */
manhpham 0:c8673aa96267 432 typedef union _flash_swap_ifr_field_data
manhpham 0:c8673aa96267 433 {
manhpham 0:c8673aa96267 434 uint32_t flashSwapIfrData[2]; /*!< A flash Swap IFR field data .*/
manhpham 0:c8673aa96267 435 flash_swap_ifr_field_config_t flashSwapIfrField; /*!< A flash Swap IFR field structure.*/
manhpham 0:c8673aa96267 436 } flash_swap_ifr_field_data_t;
manhpham 0:c8673aa96267 437
manhpham 0:c8673aa96267 438 /*!
manhpham 0:c8673aa96267 439 * @brief PFlash protection status - low 32bit
manhpham 0:c8673aa96267 440 */
manhpham 0:c8673aa96267 441 typedef union _pflash_protection_status_low
manhpham 0:c8673aa96267 442 {
manhpham 0:c8673aa96267 443 uint32_t protl32b; /*!< PROT[31:0] .*/
manhpham 0:c8673aa96267 444 struct
manhpham 0:c8673aa96267 445 {
manhpham 0:c8673aa96267 446 uint8_t protsl; /*!< PROTS[7:0] .*/
manhpham 0:c8673aa96267 447 uint8_t protsh; /*!< PROTS[15:8] .*/
manhpham 0:c8673aa96267 448 uint8_t reserved[2];
manhpham 0:c8673aa96267 449 } prots16b;
manhpham 0:c8673aa96267 450 } pflash_protection_status_low_t;
manhpham 0:c8673aa96267 451
manhpham 0:c8673aa96267 452 /*!
manhpham 0:c8673aa96267 453 * @brief PFlash protection status - full
manhpham 0:c8673aa96267 454 */
manhpham 0:c8673aa96267 455 typedef struct _pflash_protection_status
manhpham 0:c8673aa96267 456 {
manhpham 0:c8673aa96267 457 pflash_protection_status_low_t valueLow32b; /*!< PROT[31:0] or PROTS[15:0].*/
manhpham 0:c8673aa96267 458 #if ((FSL_FEATURE_FLASH_IS_FTFA == 1) && (defined(FTFA_FPROT_PROT_MASK))) || \
manhpham 0:c8673aa96267 459 ((FSL_FEATURE_FLASH_IS_FTFE == 1) && (defined(FTFE_FPROT_PROT_MASK))) || \
manhpham 0:c8673aa96267 460 ((FSL_FEATURE_FLASH_IS_FTFL == 1) && (defined(FTFL_FPROT_PROT_MASK)))
manhpham 0:c8673aa96267 461 // uint32_t protHigh; /*!< PROT[63:32].*/
manhpham 0:c8673aa96267 462 struct
manhpham 0:c8673aa96267 463 {
manhpham 0:c8673aa96267 464 uint32_t proth32b;
manhpham 0:c8673aa96267 465 } valueHigh32b;
manhpham 0:c8673aa96267 466 #endif
manhpham 0:c8673aa96267 467 } pflash_protection_status_t;
manhpham 0:c8673aa96267 468
manhpham 0:c8673aa96267 469 /*!
manhpham 0:c8673aa96267 470 * @brief Enumeration for the FlexRAM load during reset option.
manhpham 0:c8673aa96267 471 */
manhpham 0:c8673aa96267 472 typedef enum _flash_partition_flexram_load_option
manhpham 0:c8673aa96267 473 {
manhpham 0:c8673aa96267 474 kFLASH_PartitionFlexramLoadOptionLoadedWithValidEepromData =
manhpham 0:c8673aa96267 475 0x00U, /*!< FlexRAM is loaded with valid EEPROM data during reset sequence.*/
manhpham 0:c8673aa96267 476 kFLASH_PartitionFlexramLoadOptionNotLoaded = 0x01U /*!< FlexRAM is not loaded during reset sequence.*/
manhpham 0:c8673aa96267 477 } flash_partition_flexram_load_option_t;
manhpham 0:c8673aa96267 478
manhpham 0:c8673aa96267 479 /*!
manhpham 0:c8673aa96267 480 * @brief Enumeration for the flash memory index.
manhpham 0:c8673aa96267 481 */
manhpham 0:c8673aa96267 482 typedef enum _flash_memory_index
manhpham 0:c8673aa96267 483 {
manhpham 0:c8673aa96267 484 kFLASH_MemoryIndexPrimaryFlash = 0x00U, /*!< Current flash memory is primary flash.*/
manhpham 0:c8673aa96267 485 kFLASH_MemoryIndexSecondaryFlash = 0x01U, /*!< Current flash memory is secondary flash.*/
manhpham 0:c8673aa96267 486 } flash_memory_index_t;
manhpham 0:c8673aa96267 487
manhpham 0:c8673aa96267 488 /*! @brief A callback type used for the Pflash block*/
manhpham 0:c8673aa96267 489 typedef void (*flash_callback_t)(void);
manhpham 0:c8673aa96267 490
manhpham 0:c8673aa96267 491 /*!
manhpham 0:c8673aa96267 492 * @brief Enumeration for the two possible options of flash prefetch speculation.
manhpham 0:c8673aa96267 493 */
manhpham 0:c8673aa96267 494 typedef enum _flash_prefetch_speculation_option
manhpham 0:c8673aa96267 495 {
manhpham 0:c8673aa96267 496 kFLASH_prefetchSpeculationOptionEnable = 0x00000000U,
manhpham 0:c8673aa96267 497 kFLASH_prefetchSpeculationOptionDisable = 0xFFFFFFFFU
manhpham 0:c8673aa96267 498 } flash_prefetch_speculation_option_t;
manhpham 0:c8673aa96267 499
manhpham 0:c8673aa96267 500 /*!
manhpham 0:c8673aa96267 501 * @brief Flash prefetch speculation status.
manhpham 0:c8673aa96267 502 */
manhpham 0:c8673aa96267 503 typedef struct _flash_prefetch_speculation_status
manhpham 0:c8673aa96267 504 {
manhpham 0:c8673aa96267 505 flash_prefetch_speculation_option_t instructionOption; /*!< Instruction speculation.*/
manhpham 0:c8673aa96267 506 flash_prefetch_speculation_option_t dataOption; /*!< Data speculation.*/
manhpham 0:c8673aa96267 507 } flash_prefetch_speculation_status_t;
manhpham 0:c8673aa96267 508
manhpham 0:c8673aa96267 509 /*!
manhpham 0:c8673aa96267 510 * @brief Active flash protection information for the current operation.
manhpham 0:c8673aa96267 511 */
manhpham 0:c8673aa96267 512 typedef struct _flash_protection_config
manhpham 0:c8673aa96267 513 {
manhpham 0:c8673aa96267 514 uint32_t regionBase; /*!< Base address of flash protection region.*/
manhpham 0:c8673aa96267 515 uint32_t regionSize; /*!< size of flash protection region.*/
manhpham 0:c8673aa96267 516 uint32_t regionCount; /*!< flash protection region count.*/
manhpham 0:c8673aa96267 517 } flash_protection_config_t;
manhpham 0:c8673aa96267 518
manhpham 0:c8673aa96267 519 /*!
manhpham 0:c8673aa96267 520 * @brief Active flash Execute-Only access information for the current operation.
manhpham 0:c8673aa96267 521 */
manhpham 0:c8673aa96267 522 typedef struct _flash_access_config
manhpham 0:c8673aa96267 523 {
manhpham 0:c8673aa96267 524 uint32_t SegmentBase; /*!< Base address of flash Execute-Only segment.*/
manhpham 0:c8673aa96267 525 uint32_t SegmentSize; /*!< size of flash Execute-Only segment.*/
manhpham 0:c8673aa96267 526 uint32_t SegmentCount; /*!< flash Execute-Only segment count.*/
manhpham 0:c8673aa96267 527 } flash_access_config_t;
manhpham 0:c8673aa96267 528
manhpham 0:c8673aa96267 529 /*!
manhpham 0:c8673aa96267 530 * @brief Active flash information for the current operation.
manhpham 0:c8673aa96267 531 */
manhpham 0:c8673aa96267 532 typedef struct _flash_operation_config
manhpham 0:c8673aa96267 533 {
manhpham 0:c8673aa96267 534 uint32_t convertedAddress; /*!< A converted address for the current flash type.*/
manhpham 0:c8673aa96267 535 uint32_t activeSectorSize; /*!< A sector size of the current flash type.*/
manhpham 0:c8673aa96267 536 uint32_t activeBlockSize; /*!< A block size of the current flash type.*/
manhpham 0:c8673aa96267 537 uint32_t blockWriteUnitSize; /*!< The write unit size.*/
manhpham 0:c8673aa96267 538 uint32_t sectorCmdAddressAligment; /*!< An erase sector command address alignment.*/
manhpham 0:c8673aa96267 539 uint32_t sectionCmdAddressAligment; /*!< A program/verify section command address alignment.*/
manhpham 0:c8673aa96267 540 uint32_t resourceCmdAddressAligment; /*!< A read resource command address alignment.*/
manhpham 0:c8673aa96267 541 uint32_t checkCmdAddressAligment; /*!< A program check command address alignment.*/
manhpham 0:c8673aa96267 542 } flash_operation_config_t;
manhpham 0:c8673aa96267 543
manhpham 0:c8673aa96267 544 /*! @brief Flash driver state information.
manhpham 0:c8673aa96267 545 *
manhpham 0:c8673aa96267 546 * An instance of this structure is allocated by the user of the flash driver and
manhpham 0:c8673aa96267 547 * passed into each of the driver APIs.
manhpham 0:c8673aa96267 548 */
manhpham 0:c8673aa96267 549 typedef struct _flash_config
manhpham 0:c8673aa96267 550 {
manhpham 0:c8673aa96267 551 uint32_t PFlashBlockBase; /*!< A base address of the first PFlash block */
manhpham 0:c8673aa96267 552 uint32_t PFlashTotalSize; /*!< The size of the combined PFlash block. */
manhpham 0:c8673aa96267 553 uint32_t PFlashBlockCount; /*!< A number of PFlash blocks. */
manhpham 0:c8673aa96267 554 uint32_t PFlashSectorSize; /*!< The size in bytes of a sector of PFlash. */
manhpham 0:c8673aa96267 555 flash_callback_t PFlashCallback; /*!< The callback function for the flash API. */
manhpham 0:c8673aa96267 556 uint32_t PFlashAccessSegmentSize; /*!< A size in bytes of an access segment of PFlash. */
manhpham 0:c8673aa96267 557 uint32_t PFlashAccessSegmentCount; /*!< A number of PFlash access segments. */
manhpham 0:c8673aa96267 558 uint32_t *flashExecuteInRamFunctionInfo; /*!< An information structure of the flash execute-in-RAM function. */
manhpham 0:c8673aa96267 559 uint32_t
manhpham 0:c8673aa96267 560 FlexRAMBlockBase; /*!< For the FlexNVM device, this is the base address of the FlexRAM
manhpham 0:c8673aa96267 561 For the non-FlexNVM device, this is the base address of the acceleration RAM memory */
manhpham 0:c8673aa96267 562 uint32_t FlexRAMTotalSize; /*!< For the FlexNVM device, this is the size of the FlexRAM
manhpham 0:c8673aa96267 563 For the non-FlexNVM device, this is the size of the acceleration RAM memory */
manhpham 0:c8673aa96267 564 uint32_t
manhpham 0:c8673aa96267 565 DFlashBlockBase; /*!< For the FlexNVM device, this is the base address of the D-Flash memory (FlexNVM memory)
manhpham 0:c8673aa96267 566 For the non-FlexNVM device, this field is unused */
manhpham 0:c8673aa96267 567 uint32_t DFlashTotalSize; /*!< For the FlexNVM device, this is the total size of the FlexNVM memory;
manhpham 0:c8673aa96267 568 For the non-FlexNVM device, this field is unused */
manhpham 0:c8673aa96267 569 uint32_t
manhpham 0:c8673aa96267 570 EEpromTotalSize; /*!< For the FlexNVM device, this is the size in bytes of the EEPROM area which was partitioned
manhpham 0:c8673aa96267 571 from FlexRAM
manhpham 0:c8673aa96267 572 For the non-FlexNVM device, this field is unused */
manhpham 0:c8673aa96267 573 uint32_t FlashMemoryIndex; /*!< 0 - primary flash; 1 - secondary flash*/
manhpham 0:c8673aa96267 574 } flash_config_t;
manhpham 0:c8673aa96267 575
manhpham 0:c8673aa96267 576 /*******************************************************************************
manhpham 0:c8673aa96267 577 * API
manhpham 0:c8673aa96267 578 ******************************************************************************/
manhpham 0:c8673aa96267 579
manhpham 0:c8673aa96267 580 #if defined(__cplusplus)
manhpham 0:c8673aa96267 581 extern "C" {
manhpham 0:c8673aa96267 582 #endif
manhpham 0:c8673aa96267 583
manhpham 0:c8673aa96267 584 /*!
manhpham 0:c8673aa96267 585 * @name Initialization
manhpham 0:c8673aa96267 586 * @{
manhpham 0:c8673aa96267 587 */
manhpham 0:c8673aa96267 588
manhpham 0:c8673aa96267 589 /*!
manhpham 0:c8673aa96267 590 * @brief Initializes the global flash properties structure members.
manhpham 0:c8673aa96267 591 *
manhpham 0:c8673aa96267 592 * This function checks and initializes the Flash module for the other Flash APIs.
manhpham 0:c8673aa96267 593 *
manhpham 0:c8673aa96267 594 * @param config Pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 595 *
manhpham 0:c8673aa96267 596 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 597 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 598 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 599 * @retval #kStatus_FLASH_PartitionStatusUpdateFailure Failed to update the partition status.
manhpham 0:c8673aa96267 600 */
manhpham 0:c8673aa96267 601 status_t FLASH_Init(flash_config_t *config);
manhpham 0:c8673aa96267 602
manhpham 0:c8673aa96267 603 /*!
manhpham 0:c8673aa96267 604 * @brief Sets the desired flash callback function.
manhpham 0:c8673aa96267 605 *
manhpham 0:c8673aa96267 606 * @param config Pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 607 * @param callback A callback function to be stored in the driver.
manhpham 0:c8673aa96267 608 *
manhpham 0:c8673aa96267 609 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 610 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 611 */
manhpham 0:c8673aa96267 612 status_t FLASH_SetCallback(flash_config_t *config, flash_callback_t callback);
manhpham 0:c8673aa96267 613
manhpham 0:c8673aa96267 614 /*!
manhpham 0:c8673aa96267 615 * @brief Prepares flash execute-in-RAM functions.
manhpham 0:c8673aa96267 616 *
manhpham 0:c8673aa96267 617 * @param config Pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 618 *
manhpham 0:c8673aa96267 619 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 620 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 621 */
manhpham 0:c8673aa96267 622 #if FLASH_DRIVER_IS_FLASH_RESIDENT
manhpham 0:c8673aa96267 623 status_t FLASH_PrepareExecuteInRamFunctions(flash_config_t *config);
manhpham 0:c8673aa96267 624 #endif
manhpham 0:c8673aa96267 625
manhpham 0:c8673aa96267 626 /*@}*/
manhpham 0:c8673aa96267 627
manhpham 0:c8673aa96267 628 /*!
manhpham 0:c8673aa96267 629 * @name Erasing
manhpham 0:c8673aa96267 630 * @{
manhpham 0:c8673aa96267 631 */
manhpham 0:c8673aa96267 632
manhpham 0:c8673aa96267 633 /*!
manhpham 0:c8673aa96267 634 * @brief Erases entire flash
manhpham 0:c8673aa96267 635 *
manhpham 0:c8673aa96267 636 * @param config Pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 637 * @param key A value used to validate all flash erase APIs.
manhpham 0:c8673aa96267 638 *
manhpham 0:c8673aa96267 639 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 640 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 641 * @retval #kStatus_FLASH_EraseKeyError API erase key is invalid.
manhpham 0:c8673aa96267 642 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 643 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 644 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 645 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
manhpham 0:c8673aa96267 646 * @retval #kStatus_FLASH_PartitionStatusUpdateFailure Failed to update the partition status.
manhpham 0:c8673aa96267 647 */
manhpham 0:c8673aa96267 648 status_t FLASH_EraseAll(flash_config_t *config, uint32_t key);
manhpham 0:c8673aa96267 649
manhpham 0:c8673aa96267 650 /*!
manhpham 0:c8673aa96267 651 * @brief Erases the flash sectors encompassed by parameters passed into function.
manhpham 0:c8673aa96267 652 *
manhpham 0:c8673aa96267 653 * This function erases the appropriate number of flash sectors based on the
manhpham 0:c8673aa96267 654 * desired start address and length.
manhpham 0:c8673aa96267 655 *
manhpham 0:c8673aa96267 656 * @param config The pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 657 * @param start The start address of the desired flash memory to be erased.
manhpham 0:c8673aa96267 658 * The start address does not need to be sector-aligned but must be word-aligned.
manhpham 0:c8673aa96267 659 * @param lengthInBytes The length, given in bytes (not words or long-words)
manhpham 0:c8673aa96267 660 * to be erased. Must be word-aligned.
manhpham 0:c8673aa96267 661 * @param key The value used to validate all flash erase APIs.
manhpham 0:c8673aa96267 662 *
manhpham 0:c8673aa96267 663 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 664 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 665 * @retval #kStatus_FLASH_AlignmentError The parameter is not aligned with the specified baseline.
manhpham 0:c8673aa96267 666 * @retval #kStatus_FLASH_AddressError The address is out of range.
manhpham 0:c8673aa96267 667 * @retval #kStatus_FLASH_EraseKeyError The API erase key is invalid.
manhpham 0:c8673aa96267 668 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 669 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 670 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 671 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 672 */
manhpham 0:c8673aa96267 673 status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key);
manhpham 0:c8673aa96267 674
manhpham 0:c8673aa96267 675 /*!
manhpham 0:c8673aa96267 676 * @brief Erases the entire flash, including protected sectors.
manhpham 0:c8673aa96267 677 *
manhpham 0:c8673aa96267 678 * @param config Pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 679 * @param key A value used to validate all flash erase APIs.
manhpham 0:c8673aa96267 680 *
manhpham 0:c8673aa96267 681 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 682 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 683 * @retval #kStatus_FLASH_EraseKeyError API erase key is invalid.
manhpham 0:c8673aa96267 684 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 685 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 686 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 687 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
manhpham 0:c8673aa96267 688 * @retval #kStatus_FLASH_PartitionStatusUpdateFailure Failed to update the partition status.
manhpham 0:c8673aa96267 689 */
manhpham 0:c8673aa96267 690 #if defined(FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD) && FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD
manhpham 0:c8673aa96267 691 status_t FLASH_EraseAllUnsecure(flash_config_t *config, uint32_t key);
manhpham 0:c8673aa96267 692 #endif
manhpham 0:c8673aa96267 693
manhpham 0:c8673aa96267 694 /*!
manhpham 0:c8673aa96267 695 * @brief Erases all program flash execute-only segments defined by the FXACC registers.
manhpham 0:c8673aa96267 696 *
manhpham 0:c8673aa96267 697 * @param config Pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 698 * @param key A value used to validate all flash erase APIs.
manhpham 0:c8673aa96267 699 *
manhpham 0:c8673aa96267 700 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 701 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 702 * @retval #kStatus_FLASH_EraseKeyError API erase key is invalid.
manhpham 0:c8673aa96267 703 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 704 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 705 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 706 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 707 */
manhpham 0:c8673aa96267 708 status_t FLASH_EraseAllExecuteOnlySegments(flash_config_t *config, uint32_t key);
manhpham 0:c8673aa96267 709
manhpham 0:c8673aa96267 710 /*@}*/
manhpham 0:c8673aa96267 711
manhpham 0:c8673aa96267 712 /*!
manhpham 0:c8673aa96267 713 * @name Programming
manhpham 0:c8673aa96267 714 * @{
manhpham 0:c8673aa96267 715 */
manhpham 0:c8673aa96267 716
manhpham 0:c8673aa96267 717 /*!
manhpham 0:c8673aa96267 718 * @brief Programs flash with data at locations passed in through parameters.
manhpham 0:c8673aa96267 719 *
manhpham 0:c8673aa96267 720 * This function programs the flash memory with the desired data for a given
manhpham 0:c8673aa96267 721 * flash area as determined by the start address and the length.
manhpham 0:c8673aa96267 722 *
manhpham 0:c8673aa96267 723 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 724 * @param start The start address of the desired flash memory to be programmed. Must be
manhpham 0:c8673aa96267 725 * word-aligned.
manhpham 0:c8673aa96267 726 * @param src A pointer to the source buffer of data that is to be programmed
manhpham 0:c8673aa96267 727 * into the flash.
manhpham 0:c8673aa96267 728 * @param lengthInBytes The length, given in bytes (not words or long-words),
manhpham 0:c8673aa96267 729 * to be programmed. Must be word-aligned.
manhpham 0:c8673aa96267 730 *
manhpham 0:c8673aa96267 731 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 732 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 733 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with the specified baseline.
manhpham 0:c8673aa96267 734 * @retval #kStatus_FLASH_AddressError Address is out of range.
manhpham 0:c8673aa96267 735 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 736 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 737 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 738 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 739 */
manhpham 0:c8673aa96267 740 status_t FLASH_Program(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes);
manhpham 0:c8673aa96267 741
manhpham 0:c8673aa96267 742 /*!
manhpham 0:c8673aa96267 743 * @brief Programs Program Once Field through parameters.
manhpham 0:c8673aa96267 744 *
manhpham 0:c8673aa96267 745 * This function programs the Program Once Field with the desired data for a given
manhpham 0:c8673aa96267 746 * flash area as determined by the index and length.
manhpham 0:c8673aa96267 747 *
manhpham 0:c8673aa96267 748 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 749 * @param index The index indicating which area of the Program Once Field to be programmed.
manhpham 0:c8673aa96267 750 * @param src A pointer to the source buffer of data that is to be programmed
manhpham 0:c8673aa96267 751 * into the Program Once Field.
manhpham 0:c8673aa96267 752 * @param lengthInBytes The length, given in bytes (not words or long-words),
manhpham 0:c8673aa96267 753 * to be programmed. Must be word-aligned.
manhpham 0:c8673aa96267 754 *
manhpham 0:c8673aa96267 755 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 756 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 757 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 758 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 759 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 760 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 761 */
manhpham 0:c8673aa96267 762 status_t FLASH_ProgramOnce(flash_config_t *config, uint32_t index, uint32_t *src, uint32_t lengthInBytes);
manhpham 0:c8673aa96267 763
manhpham 0:c8673aa96267 764 /*!
manhpham 0:c8673aa96267 765 * @brief Programs flash with data at locations passed in through parameters via the Program Section command.
manhpham 0:c8673aa96267 766 *
manhpham 0:c8673aa96267 767 * This function programs the flash memory with the desired data for a given
manhpham 0:c8673aa96267 768 * flash area as determined by the start address and length.
manhpham 0:c8673aa96267 769 *
manhpham 0:c8673aa96267 770 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 771 * @param start The start address of the desired flash memory to be programmed. Must be
manhpham 0:c8673aa96267 772 * word-aligned.
manhpham 0:c8673aa96267 773 * @param src A pointer to the source buffer of data that is to be programmed
manhpham 0:c8673aa96267 774 * into the flash.
manhpham 0:c8673aa96267 775 * @param lengthInBytes The length, given in bytes (not words or long-words),
manhpham 0:c8673aa96267 776 * to be programmed. Must be word-aligned.
manhpham 0:c8673aa96267 777 *
manhpham 0:c8673aa96267 778 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 779 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 780 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline.
manhpham 0:c8673aa96267 781 * @retval #kStatus_FLASH_AddressError Address is out of range.
manhpham 0:c8673aa96267 782 * @retval #kStatus_FLASH_SetFlexramAsRamError Failed to set flexram as RAM.
manhpham 0:c8673aa96267 783 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 784 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 785 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 786 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
manhpham 0:c8673aa96267 787 * @retval #kStatus_FLASH_RecoverFlexramAsEepromError Failed to recover FlexRAM as EEPROM.
manhpham 0:c8673aa96267 788 */
manhpham 0:c8673aa96267 789 #if defined(FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD) && FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD
manhpham 0:c8673aa96267 790 status_t FLASH_ProgramSection(flash_config_t *config, uint32_t start, uint32_t *src, uint32_t lengthInBytes);
manhpham 0:c8673aa96267 791 #endif
manhpham 0:c8673aa96267 792
manhpham 0:c8673aa96267 793 /*!
manhpham 0:c8673aa96267 794 * @brief Programs the EEPROM with data at locations passed in through parameters.
manhpham 0:c8673aa96267 795 *
manhpham 0:c8673aa96267 796 * This function programs the emulated EEPROM with the desired data for a given
manhpham 0:c8673aa96267 797 * flash area as determined by the start address and length.
manhpham 0:c8673aa96267 798 *
manhpham 0:c8673aa96267 799 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 800 * @param start The start address of the desired flash memory to be programmed. Must be
manhpham 0:c8673aa96267 801 * word-aligned.
manhpham 0:c8673aa96267 802 * @param src A pointer to the source buffer of data that is to be programmed
manhpham 0:c8673aa96267 803 * into the flash.
manhpham 0:c8673aa96267 804 * @param lengthInBytes The length, given in bytes (not words or long-words),
manhpham 0:c8673aa96267 805 * to be programmed. Must be word-aligned.
manhpham 0:c8673aa96267 806 *
manhpham 0:c8673aa96267 807 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 808 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 809 * @retval #kStatus_FLASH_AddressError Address is out of range.
manhpham 0:c8673aa96267 810 * @retval #kStatus_FLASH_SetFlexramAsEepromError Failed to set flexram as eeprom.
manhpham 0:c8673aa96267 811 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 812 * @retval #kStatus_FLASH_RecoverFlexramAsRamError Failed to recover the FlexRAM as RAM.
manhpham 0:c8673aa96267 813 */
manhpham 0:c8673aa96267 814 #if FLASH_SSD_IS_FLEXNVM_ENABLED
manhpham 0:c8673aa96267 815 status_t FLASH_EepromWrite(flash_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes);
manhpham 0:c8673aa96267 816 #endif
manhpham 0:c8673aa96267 817
manhpham 0:c8673aa96267 818 /*@}*/
manhpham 0:c8673aa96267 819
manhpham 0:c8673aa96267 820 /*!
manhpham 0:c8673aa96267 821 * @name Reading
manhpham 0:c8673aa96267 822 * @{
manhpham 0:c8673aa96267 823 */
manhpham 0:c8673aa96267 824
manhpham 0:c8673aa96267 825 /*!
manhpham 0:c8673aa96267 826 * @brief Reads the resource with data at locations passed in through parameters.
manhpham 0:c8673aa96267 827 *
manhpham 0:c8673aa96267 828 * This function reads the flash memory with the desired location for a given
manhpham 0:c8673aa96267 829 * flash area as determined by the start address and length.
manhpham 0:c8673aa96267 830 *
manhpham 0:c8673aa96267 831 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 832 * @param start The start address of the desired flash memory to be programmed. Must be
manhpham 0:c8673aa96267 833 * word-aligned.
manhpham 0:c8673aa96267 834 * @param dst A pointer to the destination buffer of data that is used to store
manhpham 0:c8673aa96267 835 * data to be read.
manhpham 0:c8673aa96267 836 * @param lengthInBytes The length, given in bytes (not words or long-words),
manhpham 0:c8673aa96267 837 * to be read. Must be word-aligned.
manhpham 0:c8673aa96267 838 * @param option The resource option which indicates which area should be read back.
manhpham 0:c8673aa96267 839 *
manhpham 0:c8673aa96267 840 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 841 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 842 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with the specified baseline.
manhpham 0:c8673aa96267 843 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 844 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 845 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 846 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 847 */
manhpham 0:c8673aa96267 848 #if defined(FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD) && FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD
manhpham 0:c8673aa96267 849 status_t FLASH_ReadResource(
manhpham 0:c8673aa96267 850 flash_config_t *config, uint32_t start, uint32_t *dst, uint32_t lengthInBytes, flash_read_resource_option_t option);
manhpham 0:c8673aa96267 851 #endif
manhpham 0:c8673aa96267 852
manhpham 0:c8673aa96267 853 /*!
manhpham 0:c8673aa96267 854 * @brief Reads the Program Once Field through parameters.
manhpham 0:c8673aa96267 855 *
manhpham 0:c8673aa96267 856 * This function reads the read once feild with given index and length.
manhpham 0:c8673aa96267 857 *
manhpham 0:c8673aa96267 858 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 859 * @param index The index indicating the area of program once field to be read.
manhpham 0:c8673aa96267 860 * @param dst A pointer to the destination buffer of data that is used to store
manhpham 0:c8673aa96267 861 * data to be read.
manhpham 0:c8673aa96267 862 * @param lengthInBytes The length, given in bytes (not words or long-words),
manhpham 0:c8673aa96267 863 * to be programmed. Must be word-aligned.
manhpham 0:c8673aa96267 864 *
manhpham 0:c8673aa96267 865 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 866 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 867 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 868 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 869 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 870 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 871 */
manhpham 0:c8673aa96267 872 status_t FLASH_ReadOnce(flash_config_t *config, uint32_t index, uint32_t *dst, uint32_t lengthInBytes);
manhpham 0:c8673aa96267 873
manhpham 0:c8673aa96267 874 /*@}*/
manhpham 0:c8673aa96267 875
manhpham 0:c8673aa96267 876 /*!
manhpham 0:c8673aa96267 877 * @name Security
manhpham 0:c8673aa96267 878 * @{
manhpham 0:c8673aa96267 879 */
manhpham 0:c8673aa96267 880
manhpham 0:c8673aa96267 881 /*!
manhpham 0:c8673aa96267 882 * @brief Returns the security state via the pointer passed into the function.
manhpham 0:c8673aa96267 883 *
manhpham 0:c8673aa96267 884 * This function retrieves the current flash security status, including the
manhpham 0:c8673aa96267 885 * security enabling state and the backdoor key enabling state.
manhpham 0:c8673aa96267 886 *
manhpham 0:c8673aa96267 887 * @param config A pointer to storage for the driver runtime state.
manhpham 0:c8673aa96267 888 * @param state A pointer to the value returned for the current security status code:
manhpham 0:c8673aa96267 889 *
manhpham 0:c8673aa96267 890 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 891 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 892 */
manhpham 0:c8673aa96267 893 status_t FLASH_GetSecurityState(flash_config_t *config, flash_security_state_t *state);
manhpham 0:c8673aa96267 894
manhpham 0:c8673aa96267 895 /*!
manhpham 0:c8673aa96267 896 * @brief Allows users to bypass security with a backdoor key.
manhpham 0:c8673aa96267 897 *
manhpham 0:c8673aa96267 898 * If the MCU is in secured state, this function unsecures the MCU by
manhpham 0:c8673aa96267 899 * comparing the provided backdoor key with ones in the flash configuration
manhpham 0:c8673aa96267 900 * field.
manhpham 0:c8673aa96267 901 *
manhpham 0:c8673aa96267 902 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 903 * @param backdoorKey A pointer to the user buffer containing the backdoor key.
manhpham 0:c8673aa96267 904 *
manhpham 0:c8673aa96267 905 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 906 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 907 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 908 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 909 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 910 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 911 */
manhpham 0:c8673aa96267 912 status_t FLASH_SecurityBypass(flash_config_t *config, const uint8_t *backdoorKey);
manhpham 0:c8673aa96267 913
manhpham 0:c8673aa96267 914 /*@}*/
manhpham 0:c8673aa96267 915
manhpham 0:c8673aa96267 916 /*!
manhpham 0:c8673aa96267 917 * @name Verification
manhpham 0:c8673aa96267 918 * @{
manhpham 0:c8673aa96267 919 */
manhpham 0:c8673aa96267 920
manhpham 0:c8673aa96267 921 /*!
manhpham 0:c8673aa96267 922 * @brief Verifies erasure of the entire flash at a specified margin level.
manhpham 0:c8673aa96267 923 *
manhpham 0:c8673aa96267 924 * This function checks whether the flash is erased to the
manhpham 0:c8673aa96267 925 * specified read margin level.
manhpham 0:c8673aa96267 926 *
manhpham 0:c8673aa96267 927 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 928 * @param margin Read margin choice.
manhpham 0:c8673aa96267 929 *
manhpham 0:c8673aa96267 930 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 931 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 932 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 933 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 934 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 935 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 936 */
manhpham 0:c8673aa96267 937 status_t FLASH_VerifyEraseAll(flash_config_t *config, flash_margin_value_t margin);
manhpham 0:c8673aa96267 938
manhpham 0:c8673aa96267 939 /*!
manhpham 0:c8673aa96267 940 * @brief Verifies an erasure of the desired flash area at a specified margin level.
manhpham 0:c8673aa96267 941 *
manhpham 0:c8673aa96267 942 * This function checks the appropriate number of flash sectors based on
manhpham 0:c8673aa96267 943 * the desired start address and length to check whether the flash is erased
manhpham 0:c8673aa96267 944 * to the specified read margin level.
manhpham 0:c8673aa96267 945 *
manhpham 0:c8673aa96267 946 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 947 * @param start The start address of the desired flash memory to be verified.
manhpham 0:c8673aa96267 948 * The start address does not need to be sector-aligned but must be word-aligned.
manhpham 0:c8673aa96267 949 * @param lengthInBytes The length, given in bytes (not words or long-words),
manhpham 0:c8673aa96267 950 * to be verified. Must be word-aligned.
manhpham 0:c8673aa96267 951 * @param margin Read margin choice.
manhpham 0:c8673aa96267 952 *
manhpham 0:c8673aa96267 953 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 954 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 955 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline.
manhpham 0:c8673aa96267 956 * @retval #kStatus_FLASH_AddressError Address is out of range.
manhpham 0:c8673aa96267 957 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 958 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 959 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 960 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 961 */
manhpham 0:c8673aa96267 962 status_t FLASH_VerifyErase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, flash_margin_value_t margin);
manhpham 0:c8673aa96267 963
manhpham 0:c8673aa96267 964 /*!
manhpham 0:c8673aa96267 965 * @brief Verifies programming of the desired flash area at a specified margin level.
manhpham 0:c8673aa96267 966 *
manhpham 0:c8673aa96267 967 * This function verifies the data programed in the flash memory using the
manhpham 0:c8673aa96267 968 * Flash Program Check Command and compares it to the expected data for a given
manhpham 0:c8673aa96267 969 * flash area as determined by the start address and length.
manhpham 0:c8673aa96267 970 *
manhpham 0:c8673aa96267 971 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 972 * @param start The start address of the desired flash memory to be verified. Must be word-aligned.
manhpham 0:c8673aa96267 973 * @param lengthInBytes The length, given in bytes (not words or long-words),
manhpham 0:c8673aa96267 974 * to be verified. Must be word-aligned.
manhpham 0:c8673aa96267 975 * @param expectedData A pointer to the expected data that is to be
manhpham 0:c8673aa96267 976 * verified against.
manhpham 0:c8673aa96267 977 * @param margin Read margin choice.
manhpham 0:c8673aa96267 978 * @param failedAddress A pointer to the returned failing address.
manhpham 0:c8673aa96267 979 * @param failedData A pointer to the returned failing data. Some derivatives do
manhpham 0:c8673aa96267 980 * not include failed data as part of the FCCOBx registers. In this
manhpham 0:c8673aa96267 981 * case, zeros are returned upon failure.
manhpham 0:c8673aa96267 982 *
manhpham 0:c8673aa96267 983 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 984 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 985 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline.
manhpham 0:c8673aa96267 986 * @retval #kStatus_FLASH_AddressError Address is out of range.
manhpham 0:c8673aa96267 987 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 988 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 989 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 990 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 991 */
manhpham 0:c8673aa96267 992 status_t FLASH_VerifyProgram(flash_config_t *config,
manhpham 0:c8673aa96267 993 uint32_t start,
manhpham 0:c8673aa96267 994 uint32_t lengthInBytes,
manhpham 0:c8673aa96267 995 const uint32_t *expectedData,
manhpham 0:c8673aa96267 996 flash_margin_value_t margin,
manhpham 0:c8673aa96267 997 uint32_t *failedAddress,
manhpham 0:c8673aa96267 998 uint32_t *failedData);
manhpham 0:c8673aa96267 999
manhpham 0:c8673aa96267 1000 /*!
manhpham 0:c8673aa96267 1001 * @brief Verifies whether the program flash execute-only segments have been erased to
manhpham 0:c8673aa96267 1002 * the specified read margin level.
manhpham 0:c8673aa96267 1003 *
manhpham 0:c8673aa96267 1004 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1005 * @param margin Read margin choice.
manhpham 0:c8673aa96267 1006 *
manhpham 0:c8673aa96267 1007 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1008 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1009 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 1010 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 1011 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 1012 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 1013 */
manhpham 0:c8673aa96267 1014 status_t FLASH_VerifyEraseAllExecuteOnlySegments(flash_config_t *config, flash_margin_value_t margin);
manhpham 0:c8673aa96267 1015
manhpham 0:c8673aa96267 1016 /*@}*/
manhpham 0:c8673aa96267 1017
manhpham 0:c8673aa96267 1018 /*!
manhpham 0:c8673aa96267 1019 * @name Protection
manhpham 0:c8673aa96267 1020 * @{
manhpham 0:c8673aa96267 1021 */
manhpham 0:c8673aa96267 1022
manhpham 0:c8673aa96267 1023 /*!
manhpham 0:c8673aa96267 1024 * @brief Returns the protection state of the desired flash area via the pointer passed into the function.
manhpham 0:c8673aa96267 1025 *
manhpham 0:c8673aa96267 1026 * This function retrieves the current flash protect status for a given
manhpham 0:c8673aa96267 1027 * flash area as determined by the start address and length.
manhpham 0:c8673aa96267 1028 *
manhpham 0:c8673aa96267 1029 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1030 * @param start The start address of the desired flash memory to be checked. Must be word-aligned.
manhpham 0:c8673aa96267 1031 * @param lengthInBytes The length, given in bytes (not words or long-words)
manhpham 0:c8673aa96267 1032 * to be checked. Must be word-aligned.
manhpham 0:c8673aa96267 1033 * @param protection_state A pointer to the value returned for the current
manhpham 0:c8673aa96267 1034 * protection status code for the desired flash area.
manhpham 0:c8673aa96267 1035 *
manhpham 0:c8673aa96267 1036 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1037 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1038 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline.
manhpham 0:c8673aa96267 1039 * @retval #kStatus_FLASH_AddressError The address is out of range.
manhpham 0:c8673aa96267 1040 */
manhpham 0:c8673aa96267 1041 status_t FLASH_IsProtected(flash_config_t *config,
manhpham 0:c8673aa96267 1042 uint32_t start,
manhpham 0:c8673aa96267 1043 uint32_t lengthInBytes,
manhpham 0:c8673aa96267 1044 flash_protection_state_t *protection_state);
manhpham 0:c8673aa96267 1045
manhpham 0:c8673aa96267 1046 /*!
manhpham 0:c8673aa96267 1047 * @brief Returns the access state of the desired flash area via the pointer passed into the function.
manhpham 0:c8673aa96267 1048 *
manhpham 0:c8673aa96267 1049 * This function retrieves the current flash access status for a given
manhpham 0:c8673aa96267 1050 * flash area as determined by the start address and length.
manhpham 0:c8673aa96267 1051 *
manhpham 0:c8673aa96267 1052 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1053 * @param start The start address of the desired flash memory to be checked. Must be word-aligned.
manhpham 0:c8673aa96267 1054 * @param lengthInBytes The length, given in bytes (not words or long-words),
manhpham 0:c8673aa96267 1055 * to be checked. Must be word-aligned.
manhpham 0:c8673aa96267 1056 * @param access_state A pointer to the value returned for the current
manhpham 0:c8673aa96267 1057 * access status code for the desired flash area.
manhpham 0:c8673aa96267 1058 *
manhpham 0:c8673aa96267 1059 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1060 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1061 * @retval #kStatus_FLASH_AlignmentError The parameter is not aligned to the specified baseline.
manhpham 0:c8673aa96267 1062 * @retval #kStatus_FLASH_AddressError The address is out of range.
manhpham 0:c8673aa96267 1063 */
manhpham 0:c8673aa96267 1064 status_t FLASH_IsExecuteOnly(flash_config_t *config,
manhpham 0:c8673aa96267 1065 uint32_t start,
manhpham 0:c8673aa96267 1066 uint32_t lengthInBytes,
manhpham 0:c8673aa96267 1067 flash_execute_only_access_state_t *access_state);
manhpham 0:c8673aa96267 1068
manhpham 0:c8673aa96267 1069 /*@}*/
manhpham 0:c8673aa96267 1070
manhpham 0:c8673aa96267 1071 /*!
manhpham 0:c8673aa96267 1072 * @name Properties
manhpham 0:c8673aa96267 1073 * @{
manhpham 0:c8673aa96267 1074 */
manhpham 0:c8673aa96267 1075
manhpham 0:c8673aa96267 1076 /*!
manhpham 0:c8673aa96267 1077 * @brief Returns the desired flash property.
manhpham 0:c8673aa96267 1078 *
manhpham 0:c8673aa96267 1079 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1080 * @param whichProperty The desired property from the list of properties in
manhpham 0:c8673aa96267 1081 * enum flash_property_tag_t
manhpham 0:c8673aa96267 1082 * @param value A pointer to the value returned for the desired flash property.
manhpham 0:c8673aa96267 1083 *
manhpham 0:c8673aa96267 1084 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1085 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1086 * @retval #kStatus_FLASH_UnknownProperty An unknown property tag.
manhpham 0:c8673aa96267 1087 */
manhpham 0:c8673aa96267 1088 status_t FLASH_GetProperty(flash_config_t *config, flash_property_tag_t whichProperty, uint32_t *value);
manhpham 0:c8673aa96267 1089
manhpham 0:c8673aa96267 1090 /*!
manhpham 0:c8673aa96267 1091 * @brief Sets the desired flash property.
manhpham 0:c8673aa96267 1092 *
manhpham 0:c8673aa96267 1093 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1094 * @param whichProperty The desired property from the list of properties in
manhpham 0:c8673aa96267 1095 * enum flash_property_tag_t
manhpham 0:c8673aa96267 1096 * @param value A to set for the desired flash property.
manhpham 0:c8673aa96267 1097 *
manhpham 0:c8673aa96267 1098 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1099 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1100 * @retval #kStatus_FLASH_UnknownProperty An unknown property tag.
manhpham 0:c8673aa96267 1101 * @retval #kStatus_FLASH_InvalidPropertyValue An invalid property value.
manhpham 0:c8673aa96267 1102 * @retval #kStatus_FLASH_ReadOnlyProperty An read-only property tag.
manhpham 0:c8673aa96267 1103 */
manhpham 0:c8673aa96267 1104 #if FLASH_SSD_IS_SECONDARY_FLASH_SUPPORTED
manhpham 0:c8673aa96267 1105 status_t FLASH_SetProperty(flash_config_t *config, flash_property_tag_t whichProperty, uint32_t value);
manhpham 0:c8673aa96267 1106 #endif
manhpham 0:c8673aa96267 1107
manhpham 0:c8673aa96267 1108 /*@}*/
manhpham 0:c8673aa96267 1109
manhpham 0:c8673aa96267 1110 /*!
manhpham 0:c8673aa96267 1111 * @name FlexRAM
manhpham 0:c8673aa96267 1112 * @{
manhpham 0:c8673aa96267 1113 */
manhpham 0:c8673aa96267 1114
manhpham 0:c8673aa96267 1115 /*!
manhpham 0:c8673aa96267 1116 * @brief Sets the FlexRAM function command.
manhpham 0:c8673aa96267 1117 *
manhpham 0:c8673aa96267 1118 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1119 * @param option The option used to set the work mode of FlexRAM.
manhpham 0:c8673aa96267 1120 *
manhpham 0:c8673aa96267 1121 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1122 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1123 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 1124 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 1125 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 1126 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 1127 */
manhpham 0:c8673aa96267 1128 #if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD
manhpham 0:c8673aa96267 1129 status_t FLASH_SetFlexramFunction(flash_config_t *config, flash_flexram_function_option_t option);
manhpham 0:c8673aa96267 1130 #endif
manhpham 0:c8673aa96267 1131
manhpham 0:c8673aa96267 1132 /*@}*/
manhpham 0:c8673aa96267 1133
manhpham 0:c8673aa96267 1134 /*!
manhpham 0:c8673aa96267 1135 * @name Swap
manhpham 0:c8673aa96267 1136 * @{
manhpham 0:c8673aa96267 1137 */
manhpham 0:c8673aa96267 1138
manhpham 0:c8673aa96267 1139 /*!
manhpham 0:c8673aa96267 1140 * @brief Configures the Swap function or checks the the swap state of the Flash module.
manhpham 0:c8673aa96267 1141 *
manhpham 0:c8673aa96267 1142 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1143 * @param address Address used to configure the flash Swap function.
manhpham 0:c8673aa96267 1144 * @param option The possible option used to configure Flash Swap function or check the flash Swap status
manhpham 0:c8673aa96267 1145 * @param returnInfo A pointer to the data which is used to return the information of flash Swap.
manhpham 0:c8673aa96267 1146 *
manhpham 0:c8673aa96267 1147 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1148 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1149 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline.
manhpham 0:c8673aa96267 1150 * @retval #kStatus_FLASH_SwapIndicatorAddressError Swap indicator address is invalid.
manhpham 0:c8673aa96267 1151 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 1152 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 1153 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 1154 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution.
manhpham 0:c8673aa96267 1155 */
manhpham 0:c8673aa96267 1156 #if defined(FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD) && FSL_FEATURE_FLASH_HAS_SWAP_CONTROL_CMD
manhpham 0:c8673aa96267 1157 status_t FLASH_SwapControl(flash_config_t *config,
manhpham 0:c8673aa96267 1158 uint32_t address,
manhpham 0:c8673aa96267 1159 flash_swap_control_option_t option,
manhpham 0:c8673aa96267 1160 flash_swap_state_config_t *returnInfo);
manhpham 0:c8673aa96267 1161 #endif
manhpham 0:c8673aa96267 1162
manhpham 0:c8673aa96267 1163 /*!
manhpham 0:c8673aa96267 1164 * @brief Swaps the lower half flash with the higher half flash.
manhpham 0:c8673aa96267 1165 *
manhpham 0:c8673aa96267 1166 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1167 * @param address Address used to configure the flash swap function
manhpham 0:c8673aa96267 1168 * @param option The possible option used to configure the Flash Swap function or check the flash Swap status.
manhpham 0:c8673aa96267 1169 *
manhpham 0:c8673aa96267 1170 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1171 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1172 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline.
manhpham 0:c8673aa96267 1173 * @retval #kStatus_FLASH_SwapIndicatorAddressError Swap indicator address is invalid.
manhpham 0:c8673aa96267 1174 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 1175 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 1176 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 1177 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
manhpham 0:c8673aa96267 1178 * @retval #kStatus_FLASH_SwapSystemNotInUninitialized Swap system is not in an uninitialzed state.
manhpham 0:c8673aa96267 1179 */
manhpham 0:c8673aa96267 1180 #if defined(FSL_FEATURE_FLASH_HAS_PFLASH_BLOCK_SWAP) && FSL_FEATURE_FLASH_HAS_PFLASH_BLOCK_SWAP
manhpham 0:c8673aa96267 1181 status_t FLASH_Swap(flash_config_t *config, uint32_t address, flash_swap_function_option_t option);
manhpham 0:c8673aa96267 1182 #endif
manhpham 0:c8673aa96267 1183
manhpham 0:c8673aa96267 1184 /*!
manhpham 0:c8673aa96267 1185 * @name FlexNVM
manhpham 0:c8673aa96267 1186 * @{
manhpham 0:c8673aa96267 1187 */
manhpham 0:c8673aa96267 1188
manhpham 0:c8673aa96267 1189 /*!
manhpham 0:c8673aa96267 1190 * @brief Prepares the FlexNVM block for use as data flash, EEPROM backup, or a combination of both and initializes the
manhpham 0:c8673aa96267 1191 * FlexRAM.
manhpham 0:c8673aa96267 1192 *
manhpham 0:c8673aa96267 1193 * @param config Pointer to storage for the driver runtime state.
manhpham 0:c8673aa96267 1194 * @param option The option used to set FlexRAM load behavior during reset.
manhpham 0:c8673aa96267 1195 * @param eepromDataSizeCode Determines the amount of FlexRAM used in each of the available EEPROM subsystems.
manhpham 0:c8673aa96267 1196 * @param flexnvmPartitionCode Specifies how to split the FlexNVM block between data flash memory and EEPROM backup
manhpham 0:c8673aa96267 1197 * memory supporting EEPROM functions.
manhpham 0:c8673aa96267 1198 *
manhpham 0:c8673aa96267 1199 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1200 * @retval #kStatus_FLASH_InvalidArgument Invalid argument is provided.
manhpham 0:c8673aa96267 1201 * @retval #kStatus_FLASH_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available.
manhpham 0:c8673aa96267 1202 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses.
manhpham 0:c8673aa96267 1203 * @retval #kStatus_FLASH_ProtectionViolation The program/erase operation is requested to execute on protected areas.
manhpham 0:c8673aa96267 1204 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
manhpham 0:c8673aa96267 1205 */
manhpham 0:c8673aa96267 1206 #if defined(FSL_FEATURE_FLASH_HAS_PROGRAM_PARTITION_CMD) && FSL_FEATURE_FLASH_HAS_PROGRAM_PARTITION_CMD
manhpham 0:c8673aa96267 1207 status_t FLASH_ProgramPartition(flash_config_t *config,
manhpham 0:c8673aa96267 1208 flash_partition_flexram_load_option_t option,
manhpham 0:c8673aa96267 1209 uint32_t eepromDataSizeCode,
manhpham 0:c8673aa96267 1210 uint32_t flexnvmPartitionCode);
manhpham 0:c8673aa96267 1211 #endif
manhpham 0:c8673aa96267 1212
manhpham 0:c8673aa96267 1213 /*@}*/
manhpham 0:c8673aa96267 1214
manhpham 0:c8673aa96267 1215 /*!
manhpham 0:c8673aa96267 1216 * @name Flash Protection Utilities
manhpham 0:c8673aa96267 1217 * @{
manhpham 0:c8673aa96267 1218 */
manhpham 0:c8673aa96267 1219
manhpham 0:c8673aa96267 1220 /*!
manhpham 0:c8673aa96267 1221 * @brief Sets the PFlash Protection to the intended protection status.
manhpham 0:c8673aa96267 1222 *
manhpham 0:c8673aa96267 1223 * @param config A pointer to storage for the driver runtime state.
manhpham 0:c8673aa96267 1224 * @param protectStatus The expected protect status to set to the PFlash protection register. Each bit is
manhpham 0:c8673aa96267 1225 * corresponding to protection of 1/32(64) of the total PFlash. The least significant bit is corresponding to the lowest
manhpham 0:c8673aa96267 1226 * address area of PFlash. The most significant bit is corresponding to the highest address area of PFlash. There are
manhpham 0:c8673aa96267 1227 * two possible cases as shown below:
manhpham 0:c8673aa96267 1228 * 0: this area is protected.
manhpham 0:c8673aa96267 1229 * 1: this area is unprotected.
manhpham 0:c8673aa96267 1230 *
manhpham 0:c8673aa96267 1231 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1232 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1233 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
manhpham 0:c8673aa96267 1234 */
manhpham 0:c8673aa96267 1235 status_t FLASH_PflashSetProtection(flash_config_t *config, pflash_protection_status_t *protectStatus);
manhpham 0:c8673aa96267 1236
manhpham 0:c8673aa96267 1237 /*!
manhpham 0:c8673aa96267 1238 * @brief Gets the PFlash protection status.
manhpham 0:c8673aa96267 1239 *
manhpham 0:c8673aa96267 1240 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1241 * @param protectStatus Protect status returned by the PFlash IP. Each bit is corresponding to the protection of
manhpham 0:c8673aa96267 1242 * 1/32(64)
manhpham 0:c8673aa96267 1243 * of the
manhpham 0:c8673aa96267 1244 * total PFlash. The least significant bit corresponds to the lowest address area of the PFlash. The most significant
manhpham 0:c8673aa96267 1245 * bit corresponds to the highest address area of PFlash. There are two possible cases as shown below:
manhpham 0:c8673aa96267 1246 * 0: this area is protected.
manhpham 0:c8673aa96267 1247 * 1: this area is unprotected.
manhpham 0:c8673aa96267 1248 *
manhpham 0:c8673aa96267 1249 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1250 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1251 */
manhpham 0:c8673aa96267 1252 status_t FLASH_PflashGetProtection(flash_config_t *config, pflash_protection_status_t *protectStatus);
manhpham 0:c8673aa96267 1253
manhpham 0:c8673aa96267 1254 /*!
manhpham 0:c8673aa96267 1255 * @brief Sets the DFlash protection to the intended protection status.
manhpham 0:c8673aa96267 1256 *
manhpham 0:c8673aa96267 1257 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1258 * @param protectStatus The expected protect status to set to the DFlash protection register. Each bit
manhpham 0:c8673aa96267 1259 * corresponds to the protection of the 1/8 of the total DFlash. The least significant bit corresponds to the lowest
manhpham 0:c8673aa96267 1260 * address area of the DFlash. The most significant bit corresponds to the highest address area of the DFlash. There
manhpham 0:c8673aa96267 1261 * are
manhpham 0:c8673aa96267 1262 * two possible cases as shown below:
manhpham 0:c8673aa96267 1263 * 0: this area is protected.
manhpham 0:c8673aa96267 1264 * 1: this area is unprotected.
manhpham 0:c8673aa96267 1265 *
manhpham 0:c8673aa96267 1266 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1267 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1268 * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported.
manhpham 0:c8673aa96267 1269 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
manhpham 0:c8673aa96267 1270 */
manhpham 0:c8673aa96267 1271 #if FLASH_SSD_IS_FLEXNVM_ENABLED
manhpham 0:c8673aa96267 1272 status_t FLASH_DflashSetProtection(flash_config_t *config, uint8_t protectStatus);
manhpham 0:c8673aa96267 1273 #endif
manhpham 0:c8673aa96267 1274
manhpham 0:c8673aa96267 1275 /*!
manhpham 0:c8673aa96267 1276 * @brief Gets the DFlash protection status.
manhpham 0:c8673aa96267 1277 *
manhpham 0:c8673aa96267 1278 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1279 * @param protectStatus DFlash Protect status returned by the PFlash IP. Each bit corresponds to the protection of the
manhpham 0:c8673aa96267 1280 * 1/8 of
manhpham 0:c8673aa96267 1281 * the total DFlash. The least significant bit corresponds to the lowest address area of the DFlash. The most
manhpham 0:c8673aa96267 1282 * significant bit corresponds to the highest address area of the DFlash, and so on. There are two possible cases as
manhpham 0:c8673aa96267 1283 * below:
manhpham 0:c8673aa96267 1284 * 0: this area is protected.
manhpham 0:c8673aa96267 1285 * 1: this area is unprotected.
manhpham 0:c8673aa96267 1286 *
manhpham 0:c8673aa96267 1287 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1288 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1289 * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported.
manhpham 0:c8673aa96267 1290 */
manhpham 0:c8673aa96267 1291 #if FLASH_SSD_IS_FLEXNVM_ENABLED
manhpham 0:c8673aa96267 1292 status_t FLASH_DflashGetProtection(flash_config_t *config, uint8_t *protectStatus);
manhpham 0:c8673aa96267 1293 #endif
manhpham 0:c8673aa96267 1294
manhpham 0:c8673aa96267 1295 /*!
manhpham 0:c8673aa96267 1296 * @brief Sets the EEPROM protection to the intended protection status.
manhpham 0:c8673aa96267 1297 *
manhpham 0:c8673aa96267 1298 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1299 * @param protectStatus The expected protect status to set to the EEPROM protection register. Each bit
manhpham 0:c8673aa96267 1300 * corresponds to the protection of the 1/8 of the total EEPROM. The least significant bit corresponds to the lowest
manhpham 0:c8673aa96267 1301 * address area of the EEPROM. The most significant bit corresponds to the highest address area of EEPROM, and so on.
manhpham 0:c8673aa96267 1302 * There are two possible cases as shown below:
manhpham 0:c8673aa96267 1303 * 0: this area is protected.
manhpham 0:c8673aa96267 1304 * 1: this area is unprotected.
manhpham 0:c8673aa96267 1305 *
manhpham 0:c8673aa96267 1306 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1307 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1308 * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported.
manhpham 0:c8673aa96267 1309 * @retval #kStatus_FLASH_CommandFailure Run-time error during command execution.
manhpham 0:c8673aa96267 1310 */
manhpham 0:c8673aa96267 1311 #if FLASH_SSD_IS_FLEXNVM_ENABLED
manhpham 0:c8673aa96267 1312 status_t FLASH_EepromSetProtection(flash_config_t *config, uint8_t protectStatus);
manhpham 0:c8673aa96267 1313 #endif
manhpham 0:c8673aa96267 1314
manhpham 0:c8673aa96267 1315 /*!
manhpham 0:c8673aa96267 1316 * @brief Gets the DFlash protection status.
manhpham 0:c8673aa96267 1317 *
manhpham 0:c8673aa96267 1318 * @param config A pointer to the storage for the driver runtime state.
manhpham 0:c8673aa96267 1319 * @param protectStatus DFlash Protect status returned by the PFlash IP. Each bit corresponds to the protection of the
manhpham 0:c8673aa96267 1320 * 1/8 of
manhpham 0:c8673aa96267 1321 * the total EEPROM. The least significant bit corresponds to the lowest address area of the EEPROM. The most
manhpham 0:c8673aa96267 1322 * significant bit corresponds to the highest address area of the EEPROM. There are two possible cases as below:
manhpham 0:c8673aa96267 1323 * 0: this area is protected.
manhpham 0:c8673aa96267 1324 * 1: this area is unprotected.
manhpham 0:c8673aa96267 1325 *
manhpham 0:c8673aa96267 1326 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1327 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided.
manhpham 0:c8673aa96267 1328 * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported.
manhpham 0:c8673aa96267 1329 */
manhpham 0:c8673aa96267 1330 #if FLASH_SSD_IS_FLEXNVM_ENABLED
manhpham 0:c8673aa96267 1331 status_t FLASH_EepromGetProtection(flash_config_t *config, uint8_t *protectStatus);
manhpham 0:c8673aa96267 1332 #endif
manhpham 0:c8673aa96267 1333
manhpham 0:c8673aa96267 1334 /*@}*/
manhpham 0:c8673aa96267 1335
manhpham 0:c8673aa96267 1336 /*@}*/
manhpham 0:c8673aa96267 1337
manhpham 0:c8673aa96267 1338 /*!
manhpham 0:c8673aa96267 1339 * @name Flash Speculation Utilities
manhpham 0:c8673aa96267 1340 * @{
manhpham 0:c8673aa96267 1341 */
manhpham 0:c8673aa96267 1342
manhpham 0:c8673aa96267 1343 /*!
manhpham 0:c8673aa96267 1344 * @brief Sets the PFlash prefetch speculation to the intended speculation status.
manhpham 0:c8673aa96267 1345 *
manhpham 0:c8673aa96267 1346 * @param speculationStatus The expected protect status to set to the PFlash protection register. Each bit is
manhpham 0:c8673aa96267 1347 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1348 * @retval #kStatus_FLASH_InvalidSpeculationOption An invalid speculation option argument is provided.
manhpham 0:c8673aa96267 1349 */
manhpham 0:c8673aa96267 1350 status_t FLASH_PflashSetPrefetchSpeculation(flash_prefetch_speculation_status_t *speculationStatus);
manhpham 0:c8673aa96267 1351
manhpham 0:c8673aa96267 1352 /*!
manhpham 0:c8673aa96267 1353 * @brief Gets the PFlash prefetch speculation status.
manhpham 0:c8673aa96267 1354 *
manhpham 0:c8673aa96267 1355 * @param speculationStatus Speculation status returned by the PFlash IP.
manhpham 0:c8673aa96267 1356 * @retval #kStatus_FLASH_Success API was executed successfully.
manhpham 0:c8673aa96267 1357 */
manhpham 0:c8673aa96267 1358 status_t FLASH_PflashGetPrefetchSpeculation(flash_prefetch_speculation_status_t *speculationStatus);
manhpham 0:c8673aa96267 1359
manhpham 0:c8673aa96267 1360 /*@}*/
manhpham 0:c8673aa96267 1361
manhpham 0:c8673aa96267 1362 #if defined(__cplusplus)
manhpham 0:c8673aa96267 1363 }
manhpham 0:c8673aa96267 1364 #endif
manhpham 0:c8673aa96267 1365
manhpham 0:c8673aa96267 1366 /*! @}*/
manhpham 0:c8673aa96267 1367
manhpham 0:c8673aa96267 1368 #endif /* _FSL_FLASH_H_ */