Fls_Api.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : FTFC_FLS_IP IPV_QSPI
  5. * Dependencies : none
  6. *
  7. * Autosar Version : 4.4.0
  8. * Autosar Revision : ASR_REL_4_4_REV_0000
  9. * Autosar Conf.Variant :
  10. * SW Version : 1.0.0
  11. * Build Version : S32K1_RTD_1_0_0_HF01_D2109_ASR_REL_4_4_REV_0000_20210907
  12. *
  13. * (c) Copyright 2020-2021 NXP Semiconductors
  14. * All Rights Reserved.
  15. *
  16. * NXP Confidential. This software is owned or controlled by NXP and may only be
  17. * used strictly in accordance with the applicable license terms. By expressly
  18. * accepting such terms or by downloading, installing, activating and/or otherwise
  19. * using the software, you are agreeing that you have read, and that you agree to
  20. * comply with and are bound by, such license terms. If you do not agree to be
  21. * bound by the applicable license terms, then you may not retain, install,
  22. * activate or otherwise use the software.
  23. ==================================================================================================*/
  24. /*==================================================================================================
  25. ==================================================================================================*/
  26. #ifndef FLS_API_H
  27. #define FLS_API_H
  28. /**
  29. * @file Fls_Api.h
  30. *
  31. * @addtogroup FLS FLS Driver
  32. * @{
  33. */
  34. /* implements Fls_Api.h_Artifact */
  35. #ifdef __cplusplus
  36. extern "C"{
  37. #endif
  38. /*==================================================================================================
  39. INCLUDE FILES
  40. 1) system and project includes
  41. 2) needed interfaces from external units
  42. 3) internal and external interfaces from this unit
  43. ==================================================================================================*/
  44. #include "Fls_Cfg.h"
  45. #include "MemIf_Types.h"
  46. /*==================================================================================================
  47. * SOURCE FILE VERSION INFORMATION
  48. ==================================================================================================*/
  49. /**
  50. * @brief Version Check parameters.
  51. */
  52. #define FLS_API_VENDOR_ID 43
  53. #define FLS_API_AR_RELEASE_MAJOR_VERSION 4
  54. #define FLS_API_AR_RELEASE_MINOR_VERSION 4
  55. #define FLS_API_AR_RELEASE_REVISION_VERSION 0
  56. #define FLS_API_SW_MAJOR_VERSION 1
  57. #define FLS_API_SW_MINOR_VERSION 0
  58. #define FLS_API_SW_PATCH_VERSION 0
  59. /*==================================================================================================
  60. * FILE VERSION CHECKS
  61. ==================================================================================================*/
  62. /* Check if current file and Fls_Cfg.h file are of the same vendor */
  63. #if (FLS_API_VENDOR_ID != FLS_VENDOR_ID_CFG)
  64. #error "Fls_Api.h and Fls_Cfg.h have different vendor ids"
  65. #endif
  66. /* Check if current file and Fls_Cfg.h file are of the same Autosar version */
  67. #if ((FLS_API_AR_RELEASE_MAJOR_VERSION != FLS_AR_RELEASE_MAJOR_VERSION_CFG) || \
  68. (FLS_API_AR_RELEASE_MINOR_VERSION != FLS_AR_RELEASE_MINOR_VERSION_CFG) || \
  69. (FLS_API_AR_RELEASE_REVISION_VERSION != FLS_AR_RELEASE_REVISION_VERSION_CFG) \
  70. )
  71. #error "AutoSar Version Numbers of Fls_Api.h and Fls_Cfg.h are different"
  72. #endif
  73. /* Check if current file and Fls_Cfg.h file are of the same software version */
  74. #if ((FLS_API_SW_MAJOR_VERSION != FLS_SW_MAJOR_VERSION_CFG) || \
  75. (FLS_API_SW_MINOR_VERSION != FLS_SW_MINOR_VERSION_CFG) || \
  76. (FLS_API_SW_PATCH_VERSION != FLS_SW_PATCH_VERSION_CFG) \
  77. )
  78. #error "Software Version Numbers of Fls_Api.h and Fls_Cfg.h are different"
  79. #endif
  80. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  81. /* Check if current file and MemIf_Types.h file are of the same Autosar version */
  82. #if ((FLS_API_AR_RELEASE_MAJOR_VERSION != MEMIF_AR_RELEASE_MAJOR_VERSION) || \
  83. (FLS_API_AR_RELEASE_MINOR_VERSION != MEMIF_AR_RELEASE_MINOR_VERSION) \
  84. )
  85. #error "AutoSar Version Numbers of Fls_Api.h and MemIf_Types.h are different"
  86. #endif
  87. #endif
  88. /*==================================================================================================
  89. * CONSTANTS
  90. ==================================================================================================*/
  91. /**
  92. * @brief AUTOSAR module identification
  93. */
  94. #define FLS_MODULE_ID 92
  95. /**
  96. * @brief AUTOSAR module instance identification
  97. */
  98. #define FLS_INSTANCE_ID 0U
  99. /**
  100. * @brief Development error codes (passed to DET).
  101. * @implements DETERRORCODE_enumeration
  102. */
  103. /**
  104. * @brief API service called with wrong config parameter
  105. */
  106. #define FLS_E_PARAM_CONFIG 0x01U
  107. /**
  108. * @brief API service called with wrong address parameter
  109. */
  110. #define FLS_E_PARAM_ADDRESS 0x02U
  111. /**
  112. * @brief API service called with wrong length parameter
  113. */
  114. #define FLS_E_PARAM_LENGTH 0x03U
  115. /**
  116. * @brief API service called with wrong data parameter
  117. */
  118. #define FLS_E_PARAM_DATA 0x04U
  119. /**
  120. * @brief API service called without module initialization
  121. */
  122. #define FLS_E_UNINIT 0x05U
  123. /**
  124. * @brief API service called while driver still busy
  125. */
  126. #define FLS_E_BUSY 0x06U
  127. /**
  128. * @brief API service called with NULL pointer
  129. */
  130. #define FLS_E_PARAM_POINTER 0x0AU
  131. /**
  132. * @brief Runtime error codes (passed to DET).
  133. */
  134. /**
  135. * @brief Erase verification (blank check) failed
  136. */
  137. #define FLS_E_VERIFY_ERASE_FAILED 0x07U
  138. /**
  139. * @brief Write verification (compare) failed
  140. */
  141. #define FLS_E_VERIFY_WRITE_FAILED 0x08U
  142. /**
  143. * @brief Timeout exceeded
  144. */
  145. #define FLS_E_TIMEOUT 0x09U
  146. /**
  147. * @brief Transient Faults codes (passed to DET).
  148. */
  149. /**
  150. * @brief Flash erase failed (HW)
  151. */
  152. #define FLS_E_ERASE_FAILED 0x01U
  153. /**
  154. * @brief Flash write failed (HW)
  155. */
  156. #define FLS_E_WRITE_FAILED 0x02U
  157. /**
  158. * @brief Flash read failed (HW)
  159. */
  160. #define FLS_E_READ_FAILED 0x03U
  161. /**
  162. * @brief Flash compare failed (HW)
  163. */
  164. #define FLS_E_COMPARE_FAILED 0x04U
  165. #if (FLS_QSPI_SECTORS_CONFIGURED == STD_ON)
  166. #define FLS_E_UNEXPECTED_FLASH_ID 0x05U /* Expected hardware ID not matched */
  167. #endif
  168. /**
  169. * @brief All service IDs (passed to DET).
  170. * @implements SERVICEIDs_enumeration
  171. */
  172. /**
  173. * @brief service ID of function: Fls_Init. (passed to DET)
  174. */
  175. #define FLS_INIT_ID 0x00U
  176. /**
  177. * @brief service ID of function: Fls_Erase. (passed to DET)
  178. */
  179. #define FLS_ERASE_ID 0x01U
  180. /**
  181. * @brief service ID of function: Fls_Write. (passed to DET)
  182. */
  183. #define FLS_WRITE_ID 0x02U
  184. /**
  185. * @brief service ID of function: Fls_Cancel. (passed to DET)
  186. */
  187. #define FLS_CANCEL_ID 0x03U
  188. /**
  189. * @brief service ID of function: Fls_GetJobResult. (passed to DET)
  190. */
  191. #define FLS_GETJOBRESULT_ID 0x05U
  192. /**
  193. * @brief service ID of function: Fls_MainFunction. (passed to DET)
  194. */
  195. #define FLS_MAINFUNCTION_ID 0x06U
  196. /**
  197. * @brief service ID of function: Fls_Read. (passed to DET)
  198. */
  199. #define FLS_READ_ID 0x07U
  200. /**
  201. * @brief service ID of function: Fls_Compare. (passed to DET)
  202. */
  203. #define FLS_COMPARE_ID 0x08U
  204. /**
  205. * @brief service ID of function: Fls_SetMode. (passed to DET)
  206. */
  207. #define FLS_SETMODE_ID 0x09U
  208. /**
  209. * @brief service ID of function: Fls_GetVersionInfo. (passed to DET)
  210. */
  211. #define FLS_GETVERSIONINFO_ID 0x10U
  212. /**
  213. * @brief service ID of function: Fls_BlankCheck. (passed to DET)
  214. */
  215. #define FLS_BLANK_CHECK_ID 0x11U
  216. /**
  217. * @brief All sector flags.
  218. */
  219. /**
  220. * @brief fls sector erase asynch
  221. */
  222. #define FLS_SECTOR_ERASE_ASYNCH 0x01U
  223. /**
  224. * @brief fls page write asynch
  225. */
  226. #define FLS_PAGE_WRITE_ASYNCH 0x02U
  227. /*==================================================================================================
  228. * DEFINES AND MACROS
  229. ==================================================================================================*/
  230. /*==================================================================================================
  231. * FUNCTION PROTOTYPES
  232. ==================================================================================================*/
  233. /**
  234. * @brief Start of Fls section CODE
  235. */
  236. #define FLS_START_SEC_CODE
  237. #include "Fls_MemMap.h"
  238. /**
  239. * @brief The function initializes Fls module.
  240. * @details The function sets the internal module variables according to given
  241. * configuration set.
  242. *
  243. * @param[in] pConfigPtr Pointer to flash driver configuration set.
  244. *
  245. * @api
  246. *
  247. * @pre @p pConfigPtr must not be @p NULL_PTR and the module status must not
  248. * be @p MEMIF_BUSY.
  249. *
  250. *
  251. */
  252. extern void Fls_Init(const Fls_ConfigType * pConfigPtr);
  253. /**
  254. * @brief Write one or more complete flash pages to the flash device.
  255. * @details Starts a write job asynchronously. The actual job is performed by
  256. * @p Fls_MainFunction.
  257. *
  258. * @param[in] u32TargetAddress Target address in flash memory.
  259. * @param[in] pSourceAddressPtr Pointer to source data buffer.
  260. * @param[in] u32Length Number of bytes to write.
  261. *
  262. * @return Std_ReturnType
  263. * @retval E_OK Write command has been accepted.
  264. * @retval E_NOT_OK Write command has not been accepted.
  265. *
  266. * @api
  267. *
  268. * @pre The module has to be initialized and not busy.
  269. * @post @p Fls_Write changes module status and some internal variables
  270. * (@p Fls_u32JobSectorIt, @p Fls_u32JobAddrIt, @p Fls_u32JobAddrEnd,
  271. * @p Fls_pJobDataSrcPtr, @p Fls_eJob, @p Fls_eJobResult).
  272. *
  273. */
  274. extern Std_ReturnType Fls_Write(Fls_AddressType u32TargetAddress,
  275. const uint8 * pSourceAddressPtr,
  276. Fls_LengthType u32Length
  277. );
  278. /**
  279. * @brief Erase one or more complete flash sectors.
  280. * @details Starts an erase job asynchronously. The actual job is performed
  281. * by the @p Fls_MainFunction.
  282. *
  283. * @param[in] u32TargetAddress Target address in flash memory.
  284. * @param[in] u32Length Number of bytes to erase.
  285. *
  286. * @return Std_ReturnType
  287. * @retval E_OK Erase command has been accepted.
  288. * @retval E_NOT_OK Erase command has not been accepted.
  289. *
  290. * @api
  291. *
  292. * @pre The module has to be initialized and not busy.
  293. * @post @p Fls_Erase changes module status and some internal variables
  294. * (@p Fls_u32JobSectorIt, @p Fls_u32JobSectorEnd, @p Fls_Job,
  295. * @p Fls_eJobResult).
  296. *
  297. *
  298. */
  299. extern Std_ReturnType Fls_Erase(Fls_AddressType u32TargetAddress,
  300. Fls_LengthType u32Length
  301. );
  302. #if ( FLS_CANCEL_API == STD_ON )
  303. /**
  304. * @brief Cancel an ongoing flash read, write, erase or compare job.
  305. * @details Abort a running job synchronously so that directly after returning
  306. * from this function a new job can be started.
  307. *
  308. * @api
  309. *
  310. * @pre The module must be initialized.
  311. * @post @p Fls_Cancel changes module status and @p Fls_eJobResult
  312. * internal variable.
  313. *
  314. *
  315. */
  316. extern void Fls_Cancel( void );
  317. #endif /* FLS_CANCEL_API == STD_ON */
  318. #if ( FLS_GET_STATUS_API == STD_ON )
  319. /**
  320. * @brief Returns the FLS module status.
  321. * @details Returns the FLS module status synchronously.
  322. *
  323. * @return MemIf_StatusType
  324. * @retval MEMIF_UNINIT Module has not been initialized (yet).
  325. * @retval MEMIF_IDLE Module is currently idle.
  326. * @retval MEMIF_BUSY Module is currently busy.
  327. *
  328. * @api
  329. *
  330. */
  331. extern MemIf_StatusType Fls_GetStatus( void );
  332. #endif /* FLS_GET_STATUS_API == STD_ON */
  333. #if ( FLS_GET_JOB_RESULT_API == STD_ON )
  334. /**
  335. * @brief Returns the result of the last job.
  336. * @details Returns synchronously the result of the last job.
  337. *
  338. * @return MemIf_JobResultType
  339. * @retval MEMIF_JOB_OK Successfully completed job.
  340. * @retval MEMIF_JOB_FAILED Not successfully completed job.
  341. * @retval MEMIF_JOB_PENDING Still pending job (not yet completed).
  342. * @retval MEMIF_JOB_CANCELED Job has been cancelled.
  343. * @retval MEMIF_BLOCK_INCONSISTENT Inconsistent block requested, it may
  344. * contains corrupted data.
  345. * @retval MEMIF_BLOCK_INVALID Invalid block requested.
  346. *
  347. * @api
  348. *
  349. * @implements Fls_GetJobResult_Activity
  350. *
  351. */
  352. extern MemIf_JobResultType Fls_GetJobResult( void );
  353. #endif /* FLS_GET_JOB_RESULT_API == STD_ON */
  354. /**
  355. * @brief Reads from flash memory.
  356. * @details Starts a read job asynchronously. The actual job is performed by
  357. * @p Fls_MainFunction.
  358. *
  359. * @param[in] u32SourceAddress Source address in flash memory.
  360. * @param[in] u32Length Number of bytes to read.
  361. * @param[out] pTargetAddressPtr Pointer to target data buffer.
  362. *
  363. * @return MemIf_JobResultType
  364. * @retval MEMIF_JOB_OK Successfully completed job.
  365. * @retval MEMIF_JOB_FAILED Not successfully completed job.
  366. * @retval MEMIF_JOB_PENDING Still pending job (not yet completed).
  367. * @retval MEMIF_JOB_CANCELED Job has been canceled.
  368. * @retval MEMIF_BLOCK_INCONSISTENT Inconsistent block requested, it may
  369. * contains corrupted data.
  370. * @retval MEMIF_BLOCK_INVALID Invalid block requested.
  371. *
  372. * @api
  373. *
  374. * @pre The module has to be initialized and not busy.
  375. * @post @p Fls_Read changes module status and some internal variables
  376. * (@p Fls_u32JobSectorIt, @p Fls_u32JobAddrIt, @p Fls_u32JobAddrEnd,
  377. * @p Fls_pJobDataDestPtr, @p Fls_eJob, @p Fls_eJobResult).
  378. *
  379. *
  380. */
  381. extern Std_ReturnType Fls_Read(Fls_AddressType u32SourceAddress,
  382. uint8 * pTargetAddressPtr,
  383. Fls_LengthType u32Length
  384. );
  385. #if ( FLS_COMPARE_API == STD_ON )
  386. /**
  387. * @brief Compares a flash memory area with an application data buffer.
  388. * @details Starts a compare job asynchronously. The actual job is performed by
  389. * @p Fls_MainFunction.
  390. *
  391. * @param[in] u32SourceAddress Source address in flash memory.
  392. * @param[in] pTargetAddressPtr Pointer to source data buffer.
  393. * @param[in] u32Length Number of bytes to compare.
  394. *
  395. * @return Std_ReturnType
  396. * @retval E_OK Compare command has been accepted.
  397. * @retval E_NOT_OK Compare command has not been accepted.
  398. *
  399. * @api
  400. *
  401. * @pre The module has to be initialized and not busy.
  402. * @post @p Fls_Read changes module status and some internal variables
  403. * (@p Fls_u32JobSectorIt, @p Fls_u32JobAddrIt, @p Fls_u32JobAddrEnd,
  404. * @p Fls_pJobDataSrcPtr, @p Fls_eJob, @p Fls_eJobResult).
  405. *
  406. */
  407. extern Std_ReturnType Fls_Compare(Fls_AddressType u32SourceAddress,
  408. const uint8 * pTargetAddressPtr,
  409. Fls_LengthType u32Length
  410. );
  411. #endif /* FLS_COMPARE_API == STD_ON */
  412. #if (FLS_BLANK_CHECK_API == STD_ON)
  413. /**
  414. * @brief Verify whether a given memory area has been erased but not (yet) programmed.
  415. * @details Starts a compare job asynchronously. The actual job is performed by
  416. * @p Fls_MainFunction.
  417. *
  418. * @param[in] u32TargetAddress Address in flash memory from which the blank check should be started.
  419. * @param[in] u32Length Number of bytes to be checked for erase pattern.
  420. *
  421. * @return Std_ReturnType
  422. * @retval E_OK Blank checking command has been accepted.
  423. * @retval E_NOT_OK Blank checking command has not been accepted.
  424. *
  425. * @api
  426. *
  427. * @pre The module has to be initialized and not busy.
  428. * @post @p Fls_Read changes module status and some internal variables
  429. * (@p Fls_u32JobSectorIt, @p Fls_u32JobAddrIt, @p Fls_u32JobAddrEnd,
  430. * @p Fls_pJobDataSrcPtr, @p Fls_eJob, @p Fls_eJobResult).
  431. *
  432. * @implements Fls_BlankCheck_Activity
  433. *
  434. */
  435. Std_ReturnType Fls_BlankCheck(Fls_AddressType u32TargetAddress,
  436. Fls_LengthType u32Length
  437. );
  438. #endif /* FLS_BLANK_CHECK_API == STD_ON */
  439. #if (FLS_SET_MODE_API == STD_ON) || defined(__DOXYGEN__)
  440. /**
  441. * @brief Sets the FLS module's operation mode to the given Mode.
  442. * @details Every given mode determinates maximum bytes for read-write
  443. * operations. Every mode has a set of pre-configured values.
  444. *
  445. * @param[in] eMode MEMIF_MODE_FAST or MEMIF_MODE_SLOW.
  446. *
  447. * @api
  448. *
  449. * @pre The module has to be initialized and not busy.
  450. * @post @p Fls_SetMode changes internal variables @p Fls_u32MaxRead and
  451. * @p Fls_u32MaxWrite.
  452. *
  453. */
  454. extern void Fls_SetMode(MemIf_ModeType eMode);
  455. #endif /* FLS_SET_MODE_API == STD_ON */
  456. #if ( FLS_VERSION_INFO_API == STD_ON )
  457. /**
  458. * @brief Returns version information about FLS module.
  459. * @details Version information includes:
  460. * - Module Id
  461. * - Vendor Id
  462. * - Vendor specific version numbers (BSW00407).
  463. *
  464. * @param[inout] pVersionInfoPtr Pointer to where to store the version information of this module.
  465. *
  466. * @api
  467. *
  468. */
  469. extern void Fls_GetVersionInfo(Std_VersionInfoType * pVersionInfoPtr);
  470. #endif /* FLS_VERSION_INFO_API == STD_ON */
  471. #if ( STD_ON == FLS_INTERNAL_SECTORS_CONFIGURED )
  472. #if ( (STD_ON == FLS_ECC_CHECK) || (STD_ON == FLS_ECC_CHECK_BY_AUTOSAR_OS) )
  473. /**
  474. * @brief Low level data storage exception handler.
  475. * @details Low level data storage exception handler.
  476. *
  477. * @param[in] pExceptionDetailsPtr Exception pointer
  478. *
  479. * @return Exc_CompHandlerReturnType
  480. * @retval EXC_HANDLED_SKIP The data storage exception was
  481. * caused by currently pending flash read or compare job
  482. * @retval EXC_UNHANDLED The data storage exception was
  483. * NOT caused by currently pending flash read or compare job
  484. *
  485. * @implements Fls_DsiHandler_Activity
  486. */
  487. extern Fls_CompHandlerReturnType Fls_DsiHandler(const Fls_ExceptionDetailsType * pExceptionDetailsPtr);
  488. #endif /* (STD_ON == FLS_ECC_CHECK) || (STD_ON == FLS_ECC_CHECK_BY_AUTOSAR_OS) */
  489. #if (STD_ON == FLS_ECC_CHECK_BY_AUTOSAR_OS)
  490. /**
  491. * @brief In the FlsReadFunctionCallout, user can start a task and call this function to performs the actual copy operation.
  492. *
  493. * @implements Fls_ReadEachBlock_Activity
  494. */
  495. extern void Fls_ReadEachBlock(void);
  496. #endif /* STD_ON == FLS_ECC_CHECK_BY_AUTOSAR_OS */
  497. #endif /* STD_ON == FLS_INTERNAL_SECTORS_CONFIGURED */
  498. /**
  499. * @brief Stop of Fls section CODE
  500. */
  501. #define FLS_STOP_SEC_CODE
  502. #include "Fls_MemMap.h"
  503. #ifdef __cplusplus
  504. }
  505. #endif
  506. /** @}*/
  507. #endif /* FLS_API_H */