Ftfc_Fls_Ip.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. * @file Ftfc_Fls_Ip.h
  26. *
  27. * @addtogroup FTFC_FLS_IP FTFC IP Driver
  28. * @{
  29. */
  30. /*================================================================================================*/
  31. #ifndef FLS_FLASH_H
  32. #define FLS_FLASH_H
  33. #ifdef __cplusplus
  34. extern "C"{
  35. #endif
  36. /*==================================================================================================
  37. * INCLUDE FILES
  38. * 1) system and project includes
  39. * 2) needed interfaces from external units
  40. * 3) internal and external interfaces from this unit
  41. ==================================================================================================*/
  42. #include "Ftfc_Fls_Ip_Types.h"
  43. #include "Ftfc_Fls_Ip_Cfg.h"
  44. /*==================================================================================================
  45. * SOURCE FILE VERSION INFORMATION
  46. ==================================================================================================*/
  47. #define FTFC_FLS_IP_VENDOR_ID_H 43
  48. #define FTFC_FLS_IP_AR_RELEASE_MAJOR_VERSION_H 4
  49. #define FTFC_FLS_IP_AR_RELEASE_MINOR_VERSION_H 4
  50. #define FTFC_FLS_IP_AR_RELEASE_REVISION_VERSION_H 0
  51. #define FTFC_FLS_IP_SW_MAJOR_VERSION_H 1
  52. #define FTFC_FLS_IP_SW_MINOR_VERSION_H 0
  53. #define FTFC_FLS_IP_SW_PATCH_VERSION_H 0
  54. /*==================================================================================================
  55. FILE VERSION CHECKS
  56. ==================================================================================================*/
  57. /* Check if current file and Ftfc_Fls_Ip_Types header file are of the same vendor */
  58. #if (FTFC_FLS_IP_TYPES_VENDOR_ID != FTFC_FLS_IP_VENDOR_ID_H)
  59. #error "Ftfc_Fls_Ip.h and Ftfc_Fls_Ip_Types.h have different vendor ids"
  60. #endif
  61. /* Check if current file and Ftfc_Fls_Ip_Types header file are of the same Autosar version */
  62. #if ((FTFC_FLS_IP_TYPES_AR_RELEASE_MAJOR_VERSION != FTFC_FLS_IP_AR_RELEASE_MAJOR_VERSION_H) || \
  63. (FTFC_FLS_IP_TYPES_AR_RELEASE_MINOR_VERSION != FTFC_FLS_IP_AR_RELEASE_MINOR_VERSION_H) || \
  64. (FTFC_FLS_IP_TYPES_AR_RELEASE_REVISION_VERSION != FTFC_FLS_IP_AR_RELEASE_REVISION_VERSION_H) \
  65. )
  66. #error "AutoSar Version Numbers of Ftfc_Fls_Ip.h and Ftfc_Fls_Ip_Types.h are different"
  67. #endif
  68. /* Check if current file and Ftfc_Fls_Ip_Types header file are of the same Software version */
  69. #if ((FTFC_FLS_IP_TYPES_SW_MAJOR_VERSION != FTFC_FLS_IP_SW_MAJOR_VERSION_H) || \
  70. (FTFC_FLS_IP_TYPES_SW_MINOR_VERSION != FTFC_FLS_IP_SW_MINOR_VERSION_H) || \
  71. (FTFC_FLS_IP_TYPES_SW_PATCH_VERSION != FTFC_FLS_IP_SW_PATCH_VERSION_H) \
  72. )
  73. #error "Software Version Numbers of Ftfc_Fls_Ip.h and Ftfc_Fls_Ip_Types.h are different"
  74. #endif
  75. /* Check if current file and Ftfc_Fls_Ip_Cfg header file are of the same vendor */
  76. #if (FTFC_FLS_IP_VENDOR_ID_CFG != FTFC_FLS_IP_VENDOR_ID_H)
  77. #error "Ftfc_Fls_Ip.h and Ftfc_Fls_Ip_Cfg.h have different vendor ids"
  78. #endif
  79. /* Check if current file and Ftfc_Fls_Ip_Cfg header file are of the same Autosar version */
  80. #if ((FTFC_FLS_IP_AR_RELEASE_MAJOR_VERSION_CFG != FTFC_FLS_IP_AR_RELEASE_MAJOR_VERSION_H) || \
  81. (FTFC_FLS_IP_AR_RELEASE_MINOR_VERSION_CFG != FTFC_FLS_IP_AR_RELEASE_MINOR_VERSION_H) || \
  82. (FTFC_FLS_IP_AR_RELEASE_REVISION_VERSION_CFG != FTFC_FLS_IP_AR_RELEASE_REVISION_VERSION_H) \
  83. )
  84. #error "AutoSar Version Numbers of Ftfc_Fls_Ip.h and Ftfc_Fls_Ip_Cfg.h are different"
  85. #endif
  86. /* Check if current file and Ftfc_Fls_Ip_Cfg header file are of the same Software version */
  87. #if ((FTFC_FLS_IP_SW_MAJOR_VERSION_CFG != FTFC_FLS_IP_SW_MAJOR_VERSION_H) || \
  88. (FTFC_FLS_IP_SW_MINOR_VERSION_CFG != FTFC_FLS_IP_SW_MINOR_VERSION_H) || \
  89. (FTFC_FLS_IP_SW_PATCH_VERSION_CFG != FTFC_FLS_IP_SW_PATCH_VERSION_H) \
  90. )
  91. #error "Software Version Numbers of Ftfc_Fls_Ip.h and Ftfc_Fls_Ip_Cfg.h are different"
  92. #endif
  93. /*==================================================================================================
  94. * DEFINES AND MACROS
  95. ==================================================================================================*/
  96. /*==================================================================================================
  97. GLOBAL VARIABLES
  98. ==================================================================================================*/
  99. #define FLS_START_SEC_VAR_CLEARED_32
  100. #include "Fls_MemMap.h"
  101. #if (STD_ON == FTFC_TIMEOUT_SUPERVISION_ENABLED)
  102. extern uint32 Ftfc_Fls_Ip_u32ElapsedTicks;
  103. extern uint32 Ftfc_Fls_Ip_u32TimeoutTicks;
  104. extern uint32 Ftfc_Fls_Ip_u32CurrentTicks;
  105. #endif
  106. #define FLS_STOP_SEC_VAR_CLEARED_32
  107. #include "Fls_MemMap.h"
  108. #define FLS_START_SEC_CONST_UNSPECIFIED
  109. #include "Fls_MemMap.h"
  110. /* Base address for Flash Memory Module */
  111. extern FTFx_HARDWARE_TYPE * const FTFx_BaseAddress;
  112. #define FLS_STOP_SEC_CONST_UNSPECIFIED
  113. #include "Fls_MemMap.h"
  114. /*==================================================================================================
  115. * FUNCTION PROTOTYPES
  116. ==================================================================================================*/
  117. #define FLS_START_SEC_CODE
  118. #include "Fls_MemMap.h"
  119. /**
  120. * @brief Initializes the FTCF module
  121. *
  122. * @details This function will initialize ftfc module and clear all error flags.
  123. *
  124. * @param[in] Ftfc_Fls_Ip_pInitConfig Pointer to the driver configuration structure.
  125. * @return Ftfc_Fls_Ip_StatusType
  126. * @retval STATUS_FTFC_FLS_IP_SUCCESS Initialization is success
  127. * @retval STATUS_FTFC_FLS_IP_ERROR_TIMEOUT Errors Timeout because wait for the Done bit long time
  128. *
  129. */
  130. Ftfc_Fls_Ip_StatusType Ftfc_Fls_Ip_Init(const Ftfc_ConfigType * Ftfc_Fls_Ip_pInitConfig);
  131. /*!
  132. * @brief Abort a program or erase operation
  133. *
  134. * @details This function will abort a program or erase operation in user
  135. * mode and clear all PGM, APGM, ERS, AERS, EHV, AEHV bits in MCR,AMCRS registers
  136. *
  137. * @return Ftfc_Fls_Ip_StatusType
  138. * @retval STATUS_FTFC_FLS_IP_SUCCESS : The operation is successful.
  139. * @retval STATUS_FTFC_FLS_IP_ERROR_TIMEOUT: the operation error because wait for the Done bit long time
  140. *
  141. */
  142. Ftfc_Fls_Ip_StatusType Ftfc_Fls_Ip_Abort(void);
  143. /**
  144. * @brief This function fills data to pDestAddressPtr
  145. *
  146. * @details This function fills data to pDestAddressPtr with data from the specified address
  147. *
  148. * @param[in] u32SrcAddress The start address of the area to be read.
  149. * @param[in] pDestAddressPtr Pointer to the destination of the read.
  150. * @param[in] u32Length Read size
  151. *
  152. * @return Ftfc_Fls_Ip_StatusType
  153. * @retval STATUS_FTFC_FLS_IP_SUCCESS Read performed successfully.
  154. * @retval STATUS_FTFC_FLS_IP_ERROR_INPUT_PARAM Input parameters are invalid.
  155. * @retval STATUS_FTFC_FLS_IP_ERROR There was an error while reading.
  156. *
  157. * @pre The module has to be initialized and not busy.
  158. *
  159. */
  160. Ftfc_Fls_Ip_StatusType Ftfc_Fls_Ip_Read(Ftfc_Fls_Ip_AddressType u32SrcAddress,
  161. uint8 *pDestAddressPtr,
  162. Ftfc_Fls_Ip_LengthType u32Length
  163. );
  164. /**
  165. * @brief Checks that there is the desired data at the specified address
  166. *
  167. * @details Checks that there is the desired data at the specified address.
  168. * If the compare is intented to be a blank check, the pSourceAddressPtr should be NULL.
  169. *
  170. * @param[in] u32SrcAddress The start address of the area to be checked.
  171. * @param[in] pCompareAddressPtr Pointer to the data expected to be read.
  172. * @param[in] u32Length Check size
  173. *
  174. * @return Ftfc_Fls_Ip_StatusType
  175. * @retval STATUS_FTFC_FLS_IP_SUCCESS Read performed successfully.
  176. * @retval STATUS_FTFC_FLS_IP_ERROR_INPUT_PARAM Input parameters are invalid.
  177. * @retval STATUS_FTFC_FLS_IP_ERROR There was an error while reading.
  178. * @retval STATUS_FTFC_FLS_IP_ERROR_PROGRAM_VERIFY The expected data was not found completely at the specified address
  179. *
  180. * @pre The module has to be initialized and not busy.
  181. *
  182. */
  183. Ftfc_Fls_Ip_StatusType Ftfc_Fls_Ip_Compare(Ftfc_Fls_Ip_AddressType u32SrcAddress,
  184. const uint8 * pCompareAddressPtr,
  185. Ftfc_Fls_Ip_LengthType u32Length
  186. );
  187. /**
  188. * @brief Get block number from target address
  189. *
  190. * @details Get block number from target address
  191. *
  192. * @param[in] u32TargetAddress target address
  193. *
  194. * @return Ftfc_Fls_Ip_GetBlockNumberFromAddress
  195. * @retval The block number which contains the target address.
  196. *
  197. */
  198. Ftfc_Fls_Ip_FlashBlocksNumberType Ftfc_Fls_Ip_GetBlockNumberFromAddress(uint32 u32TargetAddress);
  199. /**
  200. * @brief Accepts and erases a selected program flash or data flash sector if possible
  201. *
  202. * @details Accepts an erase job over one of the sectors if possible.
  203. * Starts the high voltage erase and then exits. The status of the hardware erase must
  204. * be verified by calling asynchronously the Ftfc_Fls_Ip_SectorEraseStatus function.
  205. * The Ftfc_Fls_Ip_SectorErase function shall cover all the available sectors.
  206. *
  207. * @param[in] u32SectorStartAddress The start address of the sector to be erased.
  208. *
  209. * @return Ftfc_Fls_Ip_StatusType
  210. * @retval STATUS_FTFC_FLS_IP_SUCCESS Hardware erase started successfully
  211. * @retval STATUS_FTFC_FLS_IP_ERROR_INPUT_PARAM The selected sector is out of bound
  212. * @retval STATUS_FTFC_FLS_IP_ERROR There is another job configured or in progress or
  213. * @p The sector is locked by another core or couldn't be unlocked.
  214. * @retval STATUS_FTFC_FLS_IP_ERROR_TIMEOUT The erase operation exceeded the timeout - Status value available only if the timeout feature is enabled
  215. *
  216. * @pre The module has to be initialized.
  217. *
  218. */
  219. Ftfc_Fls_Ip_StatusType Ftfc_Fls_Ip_SectorErase(uint32 u32SectorStartAddress);
  220. /**
  221. * @brief Checks the status of the hardware erase started by the Ftfc_Fls_Ip_SectorErase function.
  222. *
  223. * @details Checks the status of the hardware erase started by the Ftfc_Fls_Ip_SectorErase function.
  224. *
  225. * @return Ftfc_Fls_Ip_StatusType
  226. * @retval STATUS_FTFC_FLS_IP_SUCCESS Erase performed successfully
  227. * @retval STATUS_Ftfc_Fls_Ip_BUSY Hardware erase is still in progress
  228. * @retval STATUS_FTFC_FLS_IP_ERROR There was an error during the hardware erase.
  229. * @retval STATUS_FTFC_FLS_IP_ERROR_TIMEOUT The erase operation exceeded the timeout - Status value available only if the timeout feature is enabled.
  230. * @retval STATUS_FTFC_FLS_IP_ERROR_BLANK_CHECK The sector was not erased correctly - Status value available only if the blank check feature is enabled
  231. *
  232. * @pre The module has to be initialized.
  233. *
  234. */
  235. Ftfc_Fls_Ip_StatusType Ftfc_Fls_Ip_SectorEraseStatus(void);
  236. /**
  237. * @brief Writes data into the memory array using the main interface. Initiates the hardware write and then exits.
  238. *
  239. * @details Writes data into the memory array using the main interface. Initiates the hardware write and then exits.
  240. * the status of the hardware erase must be verified by calling asynchronously the Ftfc_Fls_Ip_WriteStatus function.
  241. *
  242. * @param[in] u32DestAddress The start address of the write, must be aligned with 8 bytes.
  243. * @param[in] pSourceAddressPtr Source program buffer address.
  244. * @param[in] u32Length Size in bytes of the flash region to be programed, must be aligned with 8 bytes and the maximum value is 128 bytes.
  245. *
  246. * @return Ftfc_Fls_Ip_StatusType
  247. * @retval STATUS_FTFC_FLS_IP_SUCCESS Program performed successfully
  248. * @retval STATUS_FTFC_FLS_IP_ERROR_INPUT_PARAM The input parameters are invaid.
  249. * @retval STATUS_FTFC_FLS_IP_ERROR There is another job configured or in progress or
  250. * @p The sector is locked by another core or couldn't be unlocked.
  251. * @retval STATUS_FTFC_FLS_IP_ERROR_TIMEOUT The erase operation exceeded the timeout - Status value available only if the timeout feature is enabled
  252. *
  253. * @pre The module has to be initialized.
  254. *
  255. */
  256. Ftfc_Fls_Ip_StatusType Ftfc_Fls_Ip_Write(uint32 u32DestAddress,
  257. const uint8 *pSourceAddressPtr,
  258. uint32 u32Length
  259. );
  260. /**
  261. * @brief Checks the status of the hardware program started by the FTFC_Ip_Write function.
  262. *
  263. * @details Checks the status of the hardware program started by the FTFC_Ip_Write function.
  264. *
  265. * @return Ftfc_Fls_Ip_StatusType
  266. * @retval STATUS_FTFC_FLS_IP_SUCCESS Program performed successfully
  267. * @retval STATUS_Ftfc_Fls_Ip_BUSY Hardware program is still in progress
  268. * @retval STATUS_FTFC_FLS_IP_ERROR There was an error during the hardware program.
  269. * @retval STATUS_FTFC_FLS_IP_ERROR_TIMEOUT The program operation exceeded the timeout - Status value available only if the timeout feature is enabled.
  270. * @retval STATUS_FTFC_FLS_IP_ERROR_PROGRAM_VERIFY The data was not written corectly into the memory - Status available only of program verify feature is enabled
  271. *
  272. * @pre The module has to be initialized.
  273. *
  274. */
  275. Ftfc_Fls_Ip_StatusType Ftfc_Fls_Ip_WriteStatus(void);
  276. #if ( (FTFC_ECC_CHECK == STD_ON) || (FTFC_ECC_CHECK_BY_AUTOSAR_OS == STD_ON) )
  277. #if ( FTFC_ECC_SYNDROME_AND_DATA_ADDRESS_CHECK == STD_ON )
  278. Fls_CompHandlerReturnType Ftfc_Fls_Ip_DsiHandler(const Fls_ExceptionDetailsType *pExceptionDetailsPtr);
  279. #else
  280. Fls_CompHandlerReturnType Ftfc_Fls_Ip_DsiHandler(void);
  281. #endif
  282. #endif /* ( (FTFC_ECC_CHECK == STD_ON) || (FTFC_ECC_CHECK_BY_AUTOSAR_OS == STD_ON) ) */
  283. void Ftfc_Fls_Ip_SetAsyncMode(const boolean Async);
  284. #define FLS_STOP_SEC_CODE
  285. #include "Fls_MemMap.h"
  286. #ifdef __cplusplus
  287. }
  288. #endif
  289. /** @} */
  290. #endif /* FTFC_FLS_IP_H */