1 /* 2 * Copyright 2018-2021 NXP 3 * All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 * 7 */ 8 9 #ifndef FSL_IAP_H_ 10 #define FSL_IAP_H_ 11 12 #include "fsl_common.h" 13 /*! 14 * @addtogroup flash_driver 15 * @{ 16 */ 17 18 /*! @file */ 19 20 /******************************************************************************* 21 * Definitions 22 ******************************************************************************/ 23 /*! 24 * @name Flash version 25 * @{ 26 */ 27 /*! @brief Constructs the version number for drivers. */ 28 #if !defined(MAKE_VERSION) 29 #define MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix)) 30 #endif 31 32 /*! @brief Flash driver version for SDK*/ 33 #define FSL_FLASH_DRIVER_VERSION (MAKE_VERSION(2, 1, 5)) /*!< Version 2.1.5. */ 34 35 /*! @brief Flash driver version for ROM*/ 36 enum _flash_driver_version_constants 37 { 38 kFLASH_DriverVersionName = 'F', /*!< Flash driver version name.*/ 39 kFLASH_DriverVersionMajor = 2, /*!< Major flash driver version.*/ 40 kFLASH_DriverVersionMinor = 1, /*!< Minor flash driver version.*/ 41 kFLASH_DriverVersionBugfix = 3 /*!< Bugfix for flash driver version.*/ 42 }; 43 44 /*! @} */ 45 46 /*! 47 * @name Flash configuration 48 * @{ 49 */ 50 /*! @brief Flash IP Type. */ 51 #if !defined(FSL_FEATURE_FLASH_IP_IS_C040HD_ATFC) 52 #define FSL_FEATURE_FLASH_IP_IS_C040HD_ATFC (1) 53 #endif 54 #if !defined(FSL_FEATURE_FLASH_IP_IS_C040HD_FC) 55 #define FSL_FEATURE_FLASH_IP_IS_C040HD_FC (0) 56 #endif 57 58 /*! 59 * @name Flash status 60 * @{ 61 */ 62 /*! @brief Flash driver status group. */ 63 #if defined(kStatusGroup_FlashDriver) 64 #define kStatusGroupGeneric kStatusGroup_Generic 65 #define kStatusGroupFlashDriver kStatusGroup_FlashDriver 66 #elif defined(kStatusGroup_FLASHIAP) 67 #define kStatusGroupGeneric kStatusGroup_Generic 68 #define kStatusGroupFlashDriver kStatusGroup_FLASH 69 #else 70 #define kStatusGroupGeneric 0 71 #define kStatusGroupFlashDriver 1 72 #endif 73 74 /*! @brief Constructs a status code value from a group and a code number. */ 75 #if !defined(MAKE_STATUS) 76 #define MAKE_STATUS(group, code) ((((group)*100) + (code))) 77 #endif 78 79 /*! 80 * @brief Flash driver status codes. 81 */ 82 enum _flash_status 83 { 84 kStatus_FLASH_Success = MAKE_STATUS(kStatusGroupGeneric, 0), /*!< API is executed successfully*/ 85 kStatus_FLASH_InvalidArgument = MAKE_STATUS(kStatusGroupGeneric, 4), /*!< Invalid argument*/ 86 kStatus_FLASH_SizeError = MAKE_STATUS(kStatusGroupFlashDriver, 0), /*!< Error size*/ 87 kStatus_FLASH_AlignmentError = 88 MAKE_STATUS(kStatusGroupFlashDriver, 1), /*!< Parameter is not aligned with the specified baseline*/ 89 kStatus_FLASH_AddressError = MAKE_STATUS(kStatusGroupFlashDriver, 2), /*!< Address is out of range */ 90 kStatus_FLASH_AccessError = 91 MAKE_STATUS(kStatusGroupFlashDriver, 3), /*!< Invalid instruction codes and out-of bound addresses */ 92 kStatus_FLASH_ProtectionViolation = MAKE_STATUS( 93 kStatusGroupFlashDriver, 4), /*!< The program/erase operation is requested to execute on protected areas */ 94 kStatus_FLASH_CommandFailure = 95 MAKE_STATUS(kStatusGroupFlashDriver, 5), /*!< Run-time error during command execution. */ 96 kStatus_FLASH_UnknownProperty = MAKE_STATUS(kStatusGroupFlashDriver, 6), /*!< Unknown property.*/ 97 kStatus_FLASH_EraseKeyError = MAKE_STATUS(kStatusGroupFlashDriver, 7), /*!< API erase key is invalid.*/ 98 kStatus_FLASH_RegionExecuteOnly = 99 MAKE_STATUS(kStatusGroupFlashDriver, 8), /*!< The current region is execute-only.*/ 100 kStatus_FLASH_ExecuteInRamFunctionNotReady = 101 MAKE_STATUS(kStatusGroupFlashDriver, 9), /*!< Execute-in-RAM function is not available.*/ 102 103 kStatus_FLASH_CommandNotSupported = MAKE_STATUS(kStatusGroupFlashDriver, 11), /*!< Flash API is not supported.*/ 104 kStatus_FLASH_ReadOnlyProperty = MAKE_STATUS(kStatusGroupFlashDriver, 12), /*!< The flash property is read-only.*/ 105 kStatus_FLASH_InvalidPropertyValue = 106 MAKE_STATUS(kStatusGroupFlashDriver, 13), /*!< The flash property value is out of range.*/ 107 kStatus_FLASH_InvalidSpeculationOption = 108 MAKE_STATUS(kStatusGroupFlashDriver, 14), /*!< The option of flash prefetch speculation is invalid.*/ 109 kStatus_FLASH_EccError = MAKE_STATUS(kStatusGroupFlashDriver, 110 0x10), /*!< A correctable or uncorrectable error during command execution. */ 111 kStatus_FLASH_CompareError = 112 MAKE_STATUS(kStatusGroupFlashDriver, 0x11), /*!< Destination and source memory contents do not match. */ 113 kStatus_FLASH_RegulationLoss = MAKE_STATUS(kStatusGroupFlashDriver, 0x12), /*!< A loss of regulation during read. */ 114 kStatus_FLASH_InvalidWaitStateCycles = 115 MAKE_STATUS(kStatusGroupFlashDriver, 0x13), /*!< The wait state cycle set to r/w mode is invalid. */ 116 117 kStatus_FLASH_OutOfDateCfpaPage = 118 MAKE_STATUS(kStatusGroupFlashDriver, 0x20), /*!< CFPA page version is out of date. */ 119 kStatus_FLASH_BlankIfrPageData = MAKE_STATUS(kStatusGroupFlashDriver, 0x21), /*!< Blank page cannnot be read. */ 120 kStatus_FLASH_EncryptedRegionsEraseNotDoneAtOnce = 121 MAKE_STATUS(kStatusGroupFlashDriver, 0x22), /*!< Encrypted flash subregions are not erased at once. */ 122 kStatus_FLASH_ProgramVerificationNotAllowed = MAKE_STATUS( 123 kStatusGroupFlashDriver, 0x23), /*!< Program verification is not allowed when the encryption is enabled. */ 124 kStatus_FLASH_HashCheckError = 125 MAKE_STATUS(kStatusGroupFlashDriver, 0x24), /*!< Hash check of page data is failed. */ 126 kStatus_FLASH_SealedFfrRegion = MAKE_STATUS(kStatusGroupFlashDriver, 0x25), /*!< The FFR region is sealed. */ 127 kStatus_FLASH_FfrRegionWriteBroken = MAKE_STATUS( 128 kStatusGroupFlashDriver, 0x26), /*!< The FFR Spec region is not allowed to be written discontinuously. */ 129 kStatus_FLASH_NmpaAccessNotAllowed = 130 MAKE_STATUS(kStatusGroupFlashDriver, 0x27), /*!< The NMPA region is not allowed to be read/written/erased. */ 131 kStatus_FLASH_CmpaCfgDirectEraseNotAllowed = 132 MAKE_STATUS(kStatusGroupFlashDriver, 0x28), /*!< The CMPA Cfg region is not allowed to be erased directly. */ 133 kStatus_FLASH_FfrBankIsLocked = MAKE_STATUS(kStatusGroupFlashDriver, 0x29), /*!< The FFR bank region is locked. */ 134 kStatus_FLASH_EraseFrequencyError = 135 MAKE_STATUS(kStatusGroupFlashDriver, 0x2A), /*!< Core frequency is over 100MHZ. */ 136 kStatus_FLASH_ProgramFrequencyError = 137 MAKE_STATUS(kStatusGroupFlashDriver, 0x2B), /*!< Core frequency is over 100MHZ. */ 138 139 }; 140 /*! @} */ 141 142 /*! 143 * @name Flash API key 144 * @{ 145 */ 146 /*! @brief Constructs the four character code for the Flash driver API key. */ 147 #if !defined(FOUR_CHAR_CODE) 148 #define FOUR_CHAR_CODE(a, b, c, d) (((d) << 24) | ((c) << 16) | ((b) << 8) | ((a))) 149 #endif 150 151 /*! 152 * @brief Enumeration for Flash driver API keys. 153 * 154 * @note The resulting value is built with a byte order such that the string 155 * being readable in expected order when viewed in a hex editor, if the value 156 * is treated as a 32-bit little endian value. 157 */ 158 enum _flash_driver_api_keys 159 { 160 kFLASH_ApiEraseKey = FOUR_CHAR_CODE('l', 'f', 'e', 'k') /*!< Key value used to validate all flash erase APIs.*/ 161 }; 162 /*! @} */ 163 164 /*! 165 * @brief Enumeration for various flash properties. 166 */ 167 typedef enum _flash_property_tag 168 { 169 kFLASH_PropertyPflashSectorSize = 0x00U, /*!< Pflash sector size property.*/ 170 kFLASH_PropertyPflashTotalSize = 0x01U, /*!< Pflash total size property.*/ 171 kFLASH_PropertyPflashBlockSize = 0x02U, /*!< Pflash block size property.*/ 172 kFLASH_PropertyPflashBlockCount = 0x03U, /*!< Pflash block count property.*/ 173 kFLASH_PropertyPflashBlockBaseAddr = 0x04U, /*!< Pflash block base address property.*/ 174 175 kFLASH_PropertyPflashPageSize = 0x30U, /*!< Pflash page size property.*/ 176 kFLASH_PropertyPflashSystemFreq = 0x31U, /*!< System Frequency System Frequency.*/ 177 178 kFLASH_PropertyFfrSectorSize = 0x40U, /*!< FFR sector size property.*/ 179 kFLASH_PropertyFfrTotalSize = 0x41U, /*!< FFR total size property.*/ 180 kFLASH_PropertyFfrBlockBaseAddr = 0x42U, /*!< FFR block base address property.*/ 181 kFLASH_PropertyFfrPageSize = 0x43U, /*!< FFR page size property.*/ 182 } flash_property_tag_t; 183 184 /*! 185 * @brief Enumeration for flash max pages to erase. 186 */ 187 enum _flash_max_erase_page_value 188 { 189 kFLASH_MaxPagesToErase = 100U /*!< The max value in pages to erase. */ 190 }; 191 192 /*! 193 * @brief Enumeration for flash alignment property. 194 */ 195 enum _flash_alignment_property 196 { 197 kFLASH_AlignementUnitVerifyErase = 4, /*!< The alignment unit in bytes used for verify erase operation.*/ 198 kFLASH_AlignementUnitProgram = 512, /*!< The alignment unit in bytes used for program operation.*/ 199 /*kFLASH_AlignementUnitVerifyProgram = 4,*/ /*!< The alignment unit in bytes used for verify program operation.*/ 200 kFLASH_AlignementUnitSingleWordRead = 16 /*!< The alignment unit in bytes used for SingleWordRead command.*/ 201 }; 202 203 /*! 204 * @brief Enumeration for flash read ecc option 205 */ 206 enum _flash_read_ecc_option 207 { 208 kFLASH_ReadWithEccOn = 0, /*! ECC is on */ 209 kFLASH_ReadWithEccOff = 1, /*! ECC is off */ 210 }; 211 212 /* set flash Controller timing before flash init */ 213 enum _flash_freq_tag 214 { 215 kSysToFlashFreq_lowInMHz = 12u, 216 kSysToFlashFreq_defaultInMHz = 96u, 217 }; 218 219 /*! 220 * @brief Enumeration for flash read margin option 221 */ 222 enum _flash_read_margin_option 223 { 224 kFLASH_ReadMarginNormal = 0, /*!< Normal read */ 225 kFLASH_ReadMarginVsProgram = 1, /*!< Margin vs. program */ 226 kFLASH_ReadMarginVsErase = 2, /*!< Margin vs. erase */ 227 kFLASH_ReadMarginIllegalBitCombination = 3 /*!< Illegal bit combination */ 228 }; 229 230 /*! 231 * @brief Enumeration for flash read dmacc option 232 */ 233 enum _flash_read_dmacc_option 234 { 235 kFLASH_ReadDmaccDisabled = 0, /*!< Memory word */ 236 kFLASH_ReadDmaccEnabled = 1, /*!< DMACC word */ 237 }; 238 239 /*! 240 * @brief Enumeration for flash ramp control option 241 */ 242 enum _flash_ramp_control_option 243 { 244 kFLASH_RampControlDivisionFactorReserved = 0, /*!< Reserved */ 245 kFLASH_RampControlDivisionFactor256 = 1, /*!< clk48mhz / 256 = 187.5KHz */ 246 kFLASH_RampControlDivisionFactor128 = 2, /*!< clk48mhz / 128 = 375KHz */ 247 kFLASH_RampControlDivisionFactor64 = 3 /*!< clk48mhz / 64 = 750KHz */ 248 }; 249 250 /*! @brief Flash ECC log info. */ 251 typedef struct _flash_ecc_log 252 { 253 uint32_t firstEccEventAddress; 254 uint32_t eccErrorCount; 255 uint32_t eccCorrectionCount; 256 uint32_t reserved; 257 } flash_ecc_log_t; 258 259 /*! @brief Flash controller paramter config. */ 260 typedef struct _flash_mode_config 261 { 262 uint32_t sysFreqInMHz; 263 /* ReadSingleWord parameter. */ 264 struct 265 { 266 uint8_t readWithEccOff : 1; 267 uint8_t readMarginLevel : 2; 268 uint8_t readDmaccWord : 1; 269 uint8_t reserved0 : 4; 270 uint8_t reserved1[3]; 271 } readSingleWord; 272 /* SetWriteMode parameter. */ 273 struct 274 { 275 uint8_t programRampControl; 276 uint8_t eraseRampControl; 277 uint8_t reserved[2]; 278 } setWriteMode; 279 /* SetReadMode parameter. */ 280 struct 281 { 282 uint16_t readInterfaceTimingTrim; 283 uint16_t readControllerTimingTrim; 284 uint8_t readWaitStates; 285 uint8_t reserved[3]; 286 } setReadMode; 287 } flash_mode_config_t; 288 289 /*! @brief Flash controller paramter config. */ 290 typedef struct _flash_ffr_config 291 { 292 uint32_t ffrBlockBase; 293 uint32_t ffrTotalSize; 294 uint32_t ffrPageSize; 295 uint32_t cfpaPageVersion; 296 uint32_t cfpaPageOffset; 297 } flash_ffr_config_t; 298 299 /*! @brief Flash driver state information. 300 * 301 * An instance of this structure is allocated by the user of the flash driver and 302 * passed into each of the driver APIs. 303 */ 304 typedef struct _flash_config 305 { 306 uint32_t PFlashBlockBase; /*!< A base address of the first PFlash block */ 307 uint32_t PFlashTotalSize; /*!< The size of the combined PFlash block. */ 308 uint32_t PFlashBlockCount; /*!< A number of PFlash blocks. */ 309 uint32_t PFlashPageSize; /*!< The size in bytes of a page of PFlash. */ 310 uint32_t PFlashSectorSize; /*!< The size in bytes of a sector of PFlash. */ 311 flash_ffr_config_t ffrConfig; 312 flash_mode_config_t modeConfig; 313 } flash_config_t; 314 315 /* API prototype fields definition. 316 | 31 : 24 | 23 : 20 | 19 : 16 | 15 : 12 | 11 : 8 | 7 : 0 | 317 | Tag | Boot mode | bootloader periphal| Instance | Image Index| Reserved | 318 | | | | Used For Boot mode 0| | | 319 | | 0: Passive mode | 0 - Auto detection | | | | 320 | | 1: ISP mode | 1 - USB-HID | | | | 321 | | | 2 - UART | | | | 322 | | | 3 - SPI | | | | 323 | | | 4 - I2C | | | | 324 | | | 5 - CAN | | | | 325 */ 326 327 typedef struct 328 { 329 union 330 { 331 struct 332 { 333 uint32_t reserved : 8; 334 uint32_t boot_image_index : 4; 335 uint32_t instance : 4; 336 uint32_t boot_interface : 4; 337 uint32_t mode : 4; 338 uint32_t tag : 8; 339 } B; 340 uint32_t U; 341 } option; 342 } user_app_boot_invoke_option_t; 343 344 /******************************************************************************* 345 * API 346 ******************************************************************************/ 347 348 #if defined(__cplusplus) 349 extern "C" { 350 #endif 351 352 /*! 353 * @name Initialization 354 * @{ 355 */ 356 357 /*! 358 * @brief Initializes the global flash properties structure members. 359 * 360 * This function checks and initializes the Flash module for the other Flash APIs. 361 * 362 * @param config Pointer to the storage for the driver runtime state. 363 * 364 * @retval #kStatus_FLASH_Success API was executed successfully. 365 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 366 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 367 * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported. 368 * @retval #kStatus_FLASH_EccError A correctable or uncorrectable error during command execution. 369 */ 370 status_t FLASH_Init(flash_config_t *config); 371 372 /*! @} */ 373 374 /*! 375 * @name Erasing 376 * @{ 377 */ 378 379 /*! 380 * @brief Erases the flash sectors encompassed by parameters passed into function. 381 * 382 * This function erases the appropriate number of flash sectors based on the 383 * desired start address and length. 384 * 385 * @param config The pointer to the storage for the driver runtime state. 386 * @param start The start address of the desired flash memory to be erased. 387 * The start address need to be 512bytes-aligned. 388 * @param lengthInBytes The length, given in bytes (not words or long-words) 389 * to be erased. Must be 512bytes-aligned. 390 * @param key The value used to validate all flash erase APIs. 391 * 392 * @retval #kStatus_FLASH_Success API was executed successfully; 393 * the appropriate number of flash sectors based on the desired 394 * start address and length were erased successfully. 395 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 396 * @retval #kStatus_FLASH_AlignmentError The parameter is not aligned with the specified baseline. 397 * @retval #kStatus_FLASH_AddressError The address is out of range. 398 * @retval #kStatus_FLASH_EraseKeyError The API erase key is invalid. 399 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 400 * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported. 401 * @retval #kStatus_FLASH_EccError A correctable or uncorrectable error during command execution. 402 */ 403 status_t FLASH_Erase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes, uint32_t key); 404 405 /*! @} */ 406 407 /*! 408 * @name Programming 409 * @{ 410 */ 411 412 /*! 413 * @brief Programs flash with data at locations passed in through parameters. 414 * 415 * This function programs the flash memory with the desired data for a given 416 * flash area as determined by the start address and the length. 417 * 418 * @param config A pointer to the storage for the driver runtime state. 419 * @param start The start address of the desired flash memory to be programmed. Must be 420 * 512bytes-aligned. 421 * @param src A pointer to the source buffer of data that is to be programmed 422 * into the flash. 423 * @param lengthInBytes The length, given in bytes (not words or long-words), 424 * to be programmed. Must be 512bytes-aligned. 425 * 426 * @retval #kStatus_FLASH_Success API was executed successfully; the desired data were programed successfully 427 * into flash based on desired start address and length. 428 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 429 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with the specified baseline. 430 * @retval #kStatus_FLASH_AddressError Address is out of range. 431 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 432 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 433 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 434 * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported. 435 * @retval #kStatus_FLASH_EccError A correctable or uncorrectable error during command execution. 436 */ 437 status_t FLASH_Program(flash_config_t *config, uint32_t start, const uint8_t *src, uint32_t lengthInBytes); 438 439 /*! @} */ 440 441 /*! 442 * @brief Reads flash at locations passed in through parameters. 443 * 444 * This function read the flash memory from a given flash area as determined 445 * by the start address and the length. 446 * 447 * @param config A pointer to the storage for the driver runtime state. 448 * @param start The start address of the desired flash memory to be read. 449 * @param dest A pointer to the dest buffer of data that is to be read 450 * from the flash. 451 * @param lengthInBytes The length, given in bytes (not words or long-words), 452 * to be read. 453 * 454 * @retval #kStatus_FLASH_Success API was executed successfully. 455 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 456 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with the specified baseline. 457 * @retval #kStatus_FLASH_AddressError Address is out of range. 458 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 459 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 460 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 461 * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported. 462 * @retval #kStatus_FLASH_EccError A correctable or uncorrectable error during command execution. 463 */ 464 status_t FLASH_Read(flash_config_t *config, uint32_t start, uint8_t *dest, uint32_t lengthInBytes); 465 466 /*! 467 * @name Verification 468 * @{ 469 */ 470 471 /*! 472 * @brief Verifies an erasure of the desired flash area at a specified margin level. 473 * 474 * This function checks the appropriate number of flash sectors based on 475 * the desired start address and length to check whether the flash is erased 476 * to the specified read margin level. 477 * 478 * @param config A pointer to the storage for the driver runtime state. 479 * @param start The start address of the desired flash memory to be verified. 480 * The start address need to be 512bytes-aligned. 481 * @param lengthInBytes The length, given in bytes (not words or long-words), 482 * to be verified. Must be 512bytes-aligned. 483 * 484 * @retval #kStatus_FLASH_Success API was executed successfully; the specified FLASH region has been erased. 485 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 486 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 487 * @retval #kStatus_FLASH_AddressError Address is out of range. 488 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 489 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 490 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 491 * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported. 492 * @retval #kStatus_FLASH_EccError A correctable or uncorrectable error during command execution. 493 */ 494 status_t FLASH_VerifyErase(flash_config_t *config, uint32_t start, uint32_t lengthInBytes); 495 496 /*! 497 * @brief Verifies programming of the desired flash area at a specified margin level. 498 * 499 * This function verifies the data programed in the flash memory using the 500 * Flash Program Check Command and compares it to the expected data for a given 501 * flash area as determined by the start address and length. 502 * 503 * @param config A pointer to the storage for the driver runtime state. 504 * @param start The start address of the desired flash memory to be verified. need be 512bytes-aligned. 505 * @param lengthInBytes The length, given in bytes (not words or long-words), 506 * to be verified. need be 512bytes-aligned. 507 * @param expectedData A pointer to the expected data that is to be 508 * verified against. 509 * @param failedAddress A pointer to the returned failing address. 510 * @param failedData A pointer to the returned failing data. Some derivatives do 511 * not include failed data as part of the FCCOBx registers. In this 512 * case, zeros are returned upon failure. 513 * 514 * @retval #kStatus_FLASH_Success API was executed successfully; 515 * the desired data have been successfully programed into specified FLASH region. 516 * 517 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 518 * @retval #kStatus_FLASH_AlignmentError Parameter is not aligned with specified baseline. 519 * @retval #kStatus_FLASH_AddressError Address is out of range. 520 * @retval #kStatus_FLASH_AccessError Invalid instruction codes and out-of bounds addresses. 521 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 522 * @retval #kStatus_FLASH_CommandFailure Run-time error during the command execution. 523 * @retval #kStatus_FLASH_CommandNotSupported Flash API is not supported. 524 * @retval #kStatus_FLASH_EccError A correctable or uncorrectable error during command execution. 525 */ 526 status_t FLASH_VerifyProgram(flash_config_t *config, 527 uint32_t start, 528 uint32_t lengthInBytes, 529 const uint8_t *expectedData, 530 uint32_t *failedAddress, 531 uint32_t *failedData); 532 533 /*! @} */ 534 535 /*! 536 * @name Properties 537 * @{ 538 */ 539 540 /*! 541 * @brief Returns the desired flash property. 542 * 543 * @param config A pointer to the storage for the driver runtime state. 544 * @param whichProperty The desired property from the list of properties in 545 * enum flash_property_tag_t 546 * @param value A pointer to the value returned for the desired flash property. 547 * 548 * @retval #kStatus_FLASH_Success API was executed successfully; the flash property was stored to value. 549 * @retval #kStatus_FLASH_InvalidArgument An invalid argument is provided. 550 * @retval #kStatus_FLASH_UnknownProperty An unknown property tag. 551 */ 552 status_t FLASH_GetProperty(flash_config_t *config, flash_property_tag_t whichProperty, uint32_t *value); 553 554 /*! 555 * @brief Run the Bootloader API to force into the ISP mode base on the user arg 556 * 557 * @param arg Indicates API prototype fields definition. Refer to the above user_app_boot_invoke_option_t structure 558 */ 559 void BOOTLOADER_UserEntry(void *arg); 560 561 /*! @} */ 562 563 #ifdef __cplusplus 564 } 565 #endif 566 567 /*! @} */ 568 569 #endif /* __FLASH_FLASH_H_ */ 570