1 /* 2 * Copyright 2013-2016 Freescale Semiconductor, Inc. 3 * Copyright 2016-2020 NXP 4 * All rights reserved. 5 * 6 * SPDX-License-Identifier: BSD-3-Clause 7 * 8 */ 9 10 #ifndef FSL_FTFX_FLEXNVM_H 11 #define FSL_FTFX_FLEXNVM_H 12 13 #include "fsl_ftfx_controller.h" 14 15 /*! 16 * @addtogroup ftfx_flexnvm_driver 17 * @{ 18 */ 19 /******************************************************************************* 20 * Definitions 21 ******************************************************************************/ 22 23 /*! 24 * @brief Enumeration for various flexnvm properties. 25 */ 26 typedef enum _flexnvm_property_tag 27 { 28 kFLEXNVM_PropertyDflashSectorSize = 0x00U, /*!< Dflash sector size property.*/ 29 kFLEXNVM_PropertyDflashTotalSize = 0x01U, /*!< Dflash total size property.*/ 30 kFLEXNVM_PropertyDflashBlockSize = 0x02U, /*!< Dflash block size property.*/ 31 kFLEXNVM_PropertyDflashBlockCount = 0x03U, /*!< Dflash block count property.*/ 32 kFLEXNVM_PropertyDflashBlockBaseAddr = 0x04U, /*!< Dflash block base address property.*/ 33 kFLEXNVM_PropertyAliasDflashBlockBaseAddr = 0x05U, /*!< Dflash block base address Alias property.*/ 34 kFLEXNVM_PropertyFlexRamBlockBaseAddr = 0x06U, /*!< FlexRam block base address property.*/ 35 kFLEXNVM_PropertyFlexRamTotalSize = 0x07U, /*!< FlexRam total size property.*/ 36 kFLEXNVM_PropertyEepromTotalSize = 0x08U, /*!< EEPROM total size property.*/ 37 } flexnvm_property_tag_t; 38 39 /*! @brief Flexnvm driver state information. 40 * 41 * An instance of this structure is allocated by the user of the Flexnvm driver and 42 * passed into each of the driver APIs. 43 */ 44 typedef struct _flexnvm_config 45 { 46 ftfx_config_t ftfxConfig; 47 } flexnvm_config_t; 48 49 /******************************************************************************* 50 * API 51 ******************************************************************************/ 52 53 #if defined(__cplusplus) 54 extern "C" { 55 #endif 56 57 /*! 58 * @name Initialization 59 * @{ 60 */ 61 62 /*! 63 * @brief Initializes the global flash properties structure members. 64 * 65 * This function checks and initializes the Flash module for the other Flash APIs. 66 * 67 * @param config Pointer to the storage for the driver runtime state. 68 * 69 * @retval #kStatus_FTFx_Success API was executed successfully. 70 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 71 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 72 * @retval #kStatus_FTFx_PartitionStatusUpdateFailure Failed to update the partition status. 73 */ 74 status_t FLEXNVM_Init(flexnvm_config_t *config); 75 76 /*@}*/ 77 78 /*! 79 * @name Erasing 80 * @{ 81 */ 82 83 /*! 84 * @brief Erases the Dflash sectors encompassed by parameters passed into function. 85 * 86 * This function erases the appropriate number of flash sectors based on the 87 * desired start address and length. 88 * 89 * @param config The pointer to the storage for the driver runtime state. 90 * @param start The start address of the desired flash memory to be erased. 91 * The start address does not need to be sector-aligned but must be word-aligned. 92 * @param lengthInBytes The length, given in bytes (not words or long-words) 93 * to be erased. Must be word-aligned. 94 * @param key The value used to validate all flash erase APIs. 95 * 96 * @retval #kStatus_FTFx_Success API was executed successfully; the appropriate number of date flash sectors based on 97 * the desired start address and length were erased successfully. 98 * 99 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 100 * @retval #kStatus_FTFx_AlignmentError The parameter is not aligned with the specified baseline. 101 * @retval #kStatus_FTFx_AddressError The address is out of range. 102 * @retval #kStatus_FTFx_EraseKeyError The API erase key is invalid. 103 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 104 * @retval #kStatus_FTFx_AccessError Invalid instruction codes and out-of bounds addresses. 105 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 106 * @retval #kStatus_FTFx_CommandFailure Run-time error during the command execution. 107 */ 108 status_t FLEXNVM_DflashErase(flexnvm_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key); 109 110 /*! 111 * @brief Erases entire flexnvm 112 * 113 * @param config Pointer to the storage for the driver runtime state. 114 * @param key A value used to validate all flash erase APIs. 115 * 116 * @retval #kStatus_FTFx_Success API was executed successfully; the entire flexnvm has been erased successfully. 117 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 118 * @retval #kStatus_FTFx_EraseKeyError API erase key is invalid. 119 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 120 * @retval #kStatus_FTFx_AccessError Invalid instruction codes and out-of bounds addresses. 121 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 122 * @retval #kStatus_FTFx_CommandFailure Run-time error during command execution. 123 * @retval #kStatus_FTFx_PartitionStatusUpdateFailure Failed to update the partition status. 124 */ 125 status_t FLEXNVM_EraseAll(flexnvm_config_t *config, uint32_t key); 126 127 #if defined(FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD) && FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD 128 /*! 129 * @brief Erases the entire flexnvm, including protected sectors. 130 * 131 * @param config Pointer to the storage for the driver runtime state. 132 * @param key A value used to validate all flash erase APIs. 133 * 134 * @retval #kStatus_FTFx_Success API was executed successfully; the flexnvm is not in securityi state. 135 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 136 * @retval #kStatus_FTFx_EraseKeyError API erase key is invalid. 137 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 138 * @retval #kStatus_FTFx_AccessError Invalid instruction codes and out-of bounds addresses. 139 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 140 * @retval #kStatus_FTFx_CommandFailure Run-time error during command execution. 141 * @retval #kStatus_FTFx_PartitionStatusUpdateFailure Failed to update the partition status. 142 */ 143 status_t FLEXNVM_EraseAllUnsecure(flexnvm_config_t *config, uint32_t key); 144 #endif /* FSL_FEATURE_FLASH_HAS_ERASE_ALL_BLOCKS_UNSECURE_CMD */ 145 146 /*@}*/ 147 148 /*! 149 * @name Programming 150 * @{ 151 */ 152 153 /*! 154 * @brief Programs flash with data at locations passed in through parameters. 155 * 156 * This function programs the flash memory with the desired data for a given 157 * flash area as determined by the start address and the length. 158 * 159 * @param config A pointer to the storage for the driver runtime state. 160 * @param start The start address of the desired flash memory to be programmed. Must be 161 * word-aligned. 162 * @param src A pointer to the source buffer of data that is to be programmed 163 * into the flash. 164 * @param lengthInBytes The length, given in bytes (not words or long-words), 165 * to be programmed. Must be word-aligned. 166 * 167 * @retval #kStatus_FTFx_Success API was executed successfully; the desired date have been successfully 168 * programed into specified date flash region. 169 * 170 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 171 * @retval #kStatus_FTFx_AlignmentError Parameter is not aligned with the specified baseline. 172 * @retval #kStatus_FTFx_AddressError Address is out of range. 173 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 174 * @retval #kStatus_FTFx_AccessError Invalid instruction codes and out-of bounds addresses. 175 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 176 * @retval #kStatus_FTFx_CommandFailure Run-time error during the command execution. 177 */ 178 status_t FLEXNVM_DflashProgram(flexnvm_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes); 179 180 #if defined(FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD) && FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD 181 /*! 182 * @brief Programs flash with data at locations passed in through parameters via the Program Section command. 183 * 184 * This function programs the flash memory with the desired data for a given 185 * flash area as determined by the start address and length. 186 * 187 * @param config A pointer to the storage for the driver runtime state. 188 * @param start The start address of the desired flash memory to be programmed. Must be 189 * word-aligned. 190 * @param src A pointer to the source buffer of data that is to be programmed 191 * into the flash. 192 * @param lengthInBytes The length, given in bytes (not words or long-words), 193 * to be programmed. Must be word-aligned. 194 * 195 * @retval #kStatus_FTFx_Success API was executed successfully; the desired date have been successfully 196 * programed into specified date flash area. 197 * 198 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 199 * @retval #kStatus_FTFx_AlignmentError Parameter is not aligned with specified baseline. 200 * @retval #kStatus_FTFx_AddressError Address is out of range. 201 * @retval #kStatus_FTFx_SetFlexramAsRamError Failed to set flexram as RAM. 202 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 203 * @retval #kStatus_FTFx_AccessError Invalid instruction codes and out-of bounds addresses. 204 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 205 * @retval #kStatus_FTFx_CommandFailure Run-time error during command execution. 206 * @retval #kStatus_FTFx_RecoverFlexramAsEepromError Failed to recover FlexRAM as EEPROM. 207 */ 208 status_t FLEXNVM_DflashProgramSection(flexnvm_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes); 209 #endif /* FSL_FEATURE_FLASH_HAS_PROGRAM_SECTION_CMD */ 210 211 /*! 212 * @brief Prepares the FlexNVM block for use as data flash, EEPROM backup, or a combination of both and initializes the 213 * FlexRAM. 214 * 215 * @param config Pointer to storage for the driver runtime state. 216 * @param option The option used to set FlexRAM load behavior during reset. 217 * @param eepromDataSizeCode Determines the amount of FlexRAM used in each of the available EEPROM subsystems. 218 * @param flexnvmPartitionCode Specifies how to split the FlexNVM block between data flash memory and EEPROM backup 219 * memory supporting EEPROM functions. 220 * 221 * @retval #kStatus_FTFx_Success API was executed successfully; the FlexNVM block for use as data flash, EEPROM backup, 222 * or a combination of both have been Prepared. 223 * 224 * @retval #kStatus_FTFx_InvalidArgument Invalid argument is provided. 225 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 226 * @retval #kStatus_FTFx_AccessError Invalid instruction codes and out-of bounds addresses. 227 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 228 * @retval #kStatus_FTFx_CommandFailure Run-time error during command execution. 229 */ 230 status_t FLEXNVM_ProgramPartition(flexnvm_config_t *config, 231 ftfx_partition_flexram_load_opt_t option, 232 uint32_t eepromDataSizeCode, 233 uint32_t flexnvmPartitionCode); 234 235 /*@}*/ 236 237 /*! 238 * @name Reading 239 * @{ 240 */ 241 242 #if defined(FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD) && FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD 243 /*! 244 * @brief Reads the resource with data at locations passed in through parameters. 245 * 246 * This function reads the flash memory with the desired location for a given 247 * flash area as determined by the start address and length. 248 * 249 * @param config A pointer to the storage for the driver runtime state. 250 * @param start The start address of the desired flash memory to be programmed. Must be 251 * word-aligned. 252 * @param dst A pointer to the destination buffer of data that is used to store 253 * data to be read. 254 * @param lengthInBytes The length, given in bytes (not words or long-words), 255 * to be read. Must be word-aligned. 256 * @param option The resource option which indicates which area should be read back. 257 * 258 * @retval #kStatus_FTFx_Success API was executed successfully; the data have been read successfully from 259 * program flash IFR, data flash IFR space, and the Version ID field 260 * 261 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 262 * @retval #kStatus_FTFx_AlignmentError Parameter is not aligned with the specified baseline. 263 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 264 * @retval #kStatus_FTFx_AccessError Invalid instruction codes and out-of bounds addresses. 265 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 266 * @retval #kStatus_FTFx_CommandFailure Run-time error during the command execution. 267 */ 268 status_t FLEXNVM_ReadResource( 269 flexnvm_config_t *config, uint32_t start, uint8_t *dst, uint32_t lengthInBytes, ftfx_read_resource_opt_t option); 270 #endif /* FSL_FEATURE_FLASH_HAS_READ_RESOURCE_CMD */ 271 272 /*@}*/ 273 274 /*! 275 * @name Verification 276 * @{ 277 */ 278 279 /*! 280 * @brief Verifies an erasure of the desired flash area at a specified margin level. 281 * 282 * This function checks the appropriate number of flash sectors based on 283 * the desired start address and length to check whether the flash is erased 284 * to the specified read margin level. 285 * 286 * @param config A pointer to the storage for the driver runtime state. 287 * @param start The start address of the desired flash memory to be verified. 288 * The start address does not need to be sector-aligned but must be word-aligned. 289 * @param lengthInBytes The length, given in bytes (not words or long-words), 290 * to be verified. Must be word-aligned. 291 * @param margin Read margin choice. 292 * 293 * @retval #kStatus_FTFx_Success API was executed successfully; the specified data flash region is in erased state. 294 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 295 * @retval #kStatus_FTFx_AlignmentError Parameter is not aligned with specified baseline. 296 * @retval #kStatus_FTFx_AddressError Address is out of range. 297 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 298 * @retval #kStatus_FTFx_AccessError Invalid instruction codes and out-of bounds addresses. 299 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 300 * @retval #kStatus_FTFx_CommandFailure Run-time error during the command execution. 301 */ 302 status_t FLEXNVM_DflashVerifyErase(flexnvm_config_t *config, 303 uint32_t start, 304 uint32_t lengthInBytes, 305 ftfx_margin_value_t margin); 306 307 /*! 308 * @brief Verifies erasure of the entire flash at a specified margin level. 309 * 310 * This function checks whether the flash is erased to the 311 * specified read margin level. 312 * 313 * @param config A pointer to the storage for the driver runtime state. 314 * @param margin Read margin choice. 315 * 316 * @retval #kStatus_FTFx_Success API was executed successfully; the entire flexnvm region is in erased state. 317 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 318 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 319 * @retval #kStatus_FTFx_AccessError Invalid instruction codes and out-of bounds addresses. 320 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 321 * @retval #kStatus_FTFx_CommandFailure Run-time error during the command execution. 322 */ 323 status_t FLEXNVM_VerifyEraseAll(flexnvm_config_t *config, ftfx_margin_value_t margin); 324 325 /*! 326 * @brief Verifies programming of the desired flash area at a specified margin level. 327 * 328 * This function verifies the data programmed in the flash memory using the 329 * Flash Program Check Command and compares it to the expected data for a given 330 * flash area as determined by the start address and length. 331 * 332 * @param config A pointer to the storage for the driver runtime state. 333 * @param start The start address of the desired flash memory to be verified. Must be word-aligned. 334 * @param lengthInBytes The length, given in bytes (not words or long-words), 335 * to be verified. Must be word-aligned. 336 * @param expectedData A pointer to the expected data that is to be 337 * verified against. 338 * @param margin Read margin choice. 339 * @param failedAddress A pointer to the returned failing address. 340 * @param failedData A pointer to the returned failing data. Some derivatives do 341 * not include failed data as part of the FCCOBx registers. In this 342 * case, zeros are returned upon failure. 343 * 344 * @retval #kStatus_FTFx_Success API was executed successfully; the desired data hve been programed successfully into 345 * specified data flash region. 346 * 347 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 348 * @retval #kStatus_FTFx_AlignmentError Parameter is not aligned with specified baseline. 349 * @retval #kStatus_FTFx_AddressError Address is out of range. 350 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 351 * @retval #kStatus_FTFx_AccessError Invalid instruction codes and out-of bounds addresses. 352 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 353 * @retval #kStatus_FTFx_CommandFailure Run-time error during the command execution. 354 */ 355 status_t FLEXNVM_DflashVerifyProgram(flexnvm_config_t *config, 356 uint32_t start, 357 uint32_t lengthInBytes, 358 const uint8_t *expectedData, 359 ftfx_margin_value_t margin, 360 uint32_t *failedAddress, 361 uint32_t *failedData); 362 363 /*@}*/ 364 365 /*! 366 * @name Security 367 * @{ 368 */ 369 370 /*! 371 * @brief Returns the security state via the pointer passed into the function. 372 * 373 * This function retrieves the current flash security status, including the 374 * security enabling state and the backdoor key enabling state. 375 * 376 * @param config A pointer to storage for the driver runtime state. 377 * @param state A pointer to the value returned for the current security status code: 378 * 379 * @retval #kStatus_FTFx_Success API was executed successfully; 380 * the security state of flexnvm was stored to state. 381 * 382 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 383 */ 384 status_t FLEXNVM_GetSecurityState(flexnvm_config_t *config, ftfx_security_state_t *state); 385 386 /*! 387 * @brief Allows users to bypass security with a backdoor key. 388 * 389 * If the MCU is in secured state, this function unsecures the MCU by 390 * comparing the provided backdoor key with ones in the flash configuration 391 * field. 392 * 393 * @param config A pointer to the storage for the driver runtime state. 394 * @param backdoorKey A pointer to the user buffer containing the backdoor key. 395 * 396 * @retval #kStatus_FTFx_Success API was executed successfully. 397 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 398 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 399 * @retval #kStatus_FTFx_AccessError Invalid instruction codes and out-of bounds addresses. 400 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 401 * @retval #kStatus_FTFx_CommandFailure Run-time error during the command execution. 402 */ 403 status_t FLEXNVM_SecurityBypass(flexnvm_config_t *config, const uint8_t *backdoorKey); 404 405 /*@}*/ 406 407 /*! 408 * @name FlexRAM 409 * @{ 410 */ 411 412 #if defined(FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD) && FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD 413 /*! 414 * @brief Sets the FlexRAM function command. 415 * 416 * @param config A pointer to the storage for the driver runtime state. 417 * @param option The option used to set the work mode of FlexRAM. 418 * 419 * @retval #kStatus_FTFx_Success API was executed successfully; 420 * the FlexRAM has been successfully configured as RAM or EEPROM 421 * 422 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 423 * @retval #kStatus_FTFx_ExecuteInRamFunctionNotReady Execute-in-RAM function is not available. 424 * @retval #kStatus_FTFx_AccessError Invalid instruction codes and out-of bounds addresses. 425 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 426 * @retval #kStatus_FTFx_CommandFailure Run-time error during the command execution. 427 */ 428 status_t FLEXNVM_SetFlexramFunction(flexnvm_config_t *config, ftfx_flexram_func_opt_t option); 429 #endif /* FSL_FEATURE_FLASH_HAS_SET_FLEXRAM_FUNCTION_CMD */ 430 431 /*@}*/ 432 433 /*! 434 * @brief Programs the EEPROM with data at locations passed in through parameters. 435 * 436 * This function programs the emulated EEPROM with the desired data for a given 437 * flash area as determined by the start address and length. 438 * 439 * @param config A pointer to the storage for the driver runtime state. 440 * @param start The start address of the desired flash memory to be programmed. Must be 441 * word-aligned. 442 * @param src A pointer to the source buffer of data that is to be programmed 443 * into the flash. 444 * @param lengthInBytes The length, given in bytes (not words or long-words), 445 * to be programmed. Must be word-aligned. 446 * 447 * @retval #kStatus_FTFx_Success API was executed successfully; the desires data have been successfully programed 448 * into specified eeprom region. 449 * 450 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 451 * @retval #kStatus_FTFx_AddressError Address is out of range. 452 * @retval #kStatus_FTFx_SetFlexramAsEepromError Failed to set flexram as eeprom. 453 * @retval #kStatus_FTFx_ProtectionViolation The program/erase operation is requested to execute on protected areas. 454 * @retval #kStatus_FTFx_RecoverFlexramAsRamError Failed to recover the FlexRAM as RAM. 455 */ 456 status_t FLEXNVM_EepromWrite(flexnvm_config_t *config, uint32_t start, uint8_t *src, uint32_t lengthInBytes); 457 458 /*! 459 * @name Flash Protection Utilities 460 * @{ 461 */ 462 463 /*! 464 * @brief Sets the DFlash protection to the intended protection status. 465 * 466 * @param config A pointer to the storage for the driver runtime state. 467 * @param protectStatus The expected protect status to set to the DFlash protection register. Each bit 468 * corresponds to the protection of the 1/8 of the total DFlash. The least significant bit corresponds to the lowest 469 * address area of the DFlash. The most significant bit corresponds to the highest address area of the DFlash. There 470 * are 471 * two possible cases as shown below: 472 * 0: this area is protected. 473 * 1: this area is unprotected. 474 * 475 * @retval #kStatus_FTFx_Success API was executed successfully; the specified DFlash region is protected. 476 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 477 * @retval #kStatus_FTFx_CommandNotSupported Flash API is not supported. 478 * @retval #kStatus_FTFx_CommandFailure Run-time error during command execution. 479 */ 480 status_t FLEXNVM_DflashSetProtection(flexnvm_config_t *config, uint8_t protectStatus); 481 482 /*! 483 * @brief Gets the DFlash protection status. 484 * 485 * @param config A pointer to the storage for the driver runtime state. 486 * @param protectStatus DFlash Protect status returned by the PFlash IP. Each bit corresponds to the protection of the 487 * 1/8 of 488 * the total DFlash. The least significant bit corresponds to the lowest address area of the DFlash. The most 489 * significant bit corresponds to the highest address area of the DFlash, and so on. There are two possible cases as 490 * below: 491 * 0: this area is protected. 492 * 1: this area is unprotected. 493 * 494 * @retval #kStatus_FTFx_Success API was executed successfully. 495 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 496 * @retval #kStatus_FTFx_CommandNotSupported Flash API is not supported. 497 */ 498 status_t FLEXNVM_DflashGetProtection(flexnvm_config_t *config, uint8_t *protectStatus); 499 500 /*! 501 * @brief Sets the EEPROM protection to the intended protection status. 502 * 503 * @param config A pointer to the storage for the driver runtime state. 504 * @param protectStatus The expected protect status to set to the EEPROM protection register. Each bit 505 * corresponds to the protection of the 1/8 of the total EEPROM. The least significant bit corresponds to the lowest 506 * address area of the EEPROM. The most significant bit corresponds to the highest address area of EEPROM, and so on. 507 * There are two possible cases as shown below: 508 * 0: this area is protected. 509 * 1: this area is unprotected. 510 * 511 * @retval #kStatus_FTFx_Success API was executed successfully. 512 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 513 * @retval #kStatus_FTFx_CommandNotSupported Flash API is not supported. 514 * @retval #kStatus_FTFx_CommandFailure Run-time error during command execution. 515 */ 516 status_t FLEXNVM_EepromSetProtection(flexnvm_config_t *config, uint8_t protectStatus); 517 518 /*! 519 * @brief Gets the EEPROM protection status. 520 * 521 * @param config A pointer to the storage for the driver runtime state. 522 * @param protectStatus DFlash Protect status returned by the PFlash IP. Each bit corresponds to the protection of the 523 * 1/8 of 524 * the total EEPROM. The least significant bit corresponds to the lowest address area of the EEPROM. The most 525 * significant bit corresponds to the highest address area of the EEPROM. There are two possible cases as below: 526 * 0: this area is protected. 527 * 1: this area is unprotected. 528 * 529 * @retval #kStatus_FTFx_Success API was executed successfully. 530 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 531 * @retval #kStatus_FTFx_CommandNotSupported Flash API is not supported. 532 */ 533 status_t FLEXNVM_EepromGetProtection(flexnvm_config_t *config, uint8_t *protectStatus); 534 535 /*@}*/ 536 537 /*! 538 * @name Properties 539 * @{ 540 */ 541 542 /*! 543 * @brief Returns the desired flexnvm property. 544 * 545 * @param config A pointer to the storage for the driver runtime state. 546 * @param whichProperty The desired property from the list of properties in 547 * enum flexnvm_property_tag_t 548 * @param value A pointer to the value returned for the desired flexnvm property. 549 * 550 * @retval #kStatus_FTFx_Success API was executed successfully. 551 * @retval #kStatus_FTFx_InvalidArgument An invalid argument is provided. 552 * @retval #kStatus_FTFx_UnknownProperty An unknown property tag. 553 */ 554 status_t FLEXNVM_GetProperty(flexnvm_config_t *config, flexnvm_property_tag_t whichProperty, uint32_t *value); 555 556 /*@}*/ 557 558 #if defined(__cplusplus) 559 } 560 #endif 561 562 /*! @}*/ 563 564 #endif /* FSL_FTFX_FLEXNVM_H */ 565