您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

573 行
26 KiB

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