Ftfc_Eep_Ip.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : IPV_FTFC
  5. * Dependencies :
  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. #ifndef FTFC_EEP_IP_H
  25. #define FTFC_EEP_IP_H
  26. /**
  27. * @file Ftfc_Eep_Ip.h
  28. *
  29. * @addtogroup FTFC_EEP_IP
  30. * @{
  31. */
  32. #ifdef __cplusplus
  33. extern "C"{
  34. #endif
  35. /*==================================================================================================
  36. * INCLUDE FILES
  37. * 1) system and project includes
  38. * 2) needed interfaces from external units
  39. * 3) internal and external interfaces from this unit
  40. ==================================================================================================*/
  41. #include "Ftfc_Eep_Ip_Cfg.h"
  42. #include "Ftfc_Eep_Ip_Types.h"
  43. /*==================================================================================================
  44. * SOURCE FILE VERSION INFORMATION
  45. ==================================================================================================*/
  46. #define FTFC_EEP_IP_VENDOR_ID_H 43
  47. #define FTFC_EEP_IP_AR_RELEASE_MAJOR_VERSION_H 4
  48. #define FTFC_EEP_IP_AR_RELEASE_MINOR_VERSION_H 4
  49. #define FTFC_EEP_IP_AR_RELEASE_REVISION_VERSION_H 0
  50. #define FTFC_EEP_IP_SW_MAJOR_VERSION_H 1
  51. #define FTFC_EEP_IP_SW_MINOR_VERSION_H 0
  52. #define FTFC_EEP_IP_SW_PATCH_VERSION_H 0
  53. /*==================================================================================================
  54. * FILE VERSION CHECKS
  55. ==================================================================================================*/
  56. /* Version checks for Ftfc_Eep_Ip_Cfg.h */
  57. #if (FTFC_EEP_IP_VENDOR_ID_H != FTFC_EEP_IP_CFG_VENDOR_ID_H)
  58. #error "Ftfc_Eep_Ip.h and Ftfc_Eep_Ip_Cfg.h have different vendor IDs!"
  59. #endif
  60. #if ((FTFC_EEP_IP_AR_RELEASE_MAJOR_VERSION_H != FTFC_EEP_IP_CFG_AR_RELEASE_MAJOR_VERSION_H) || \
  61. (FTFC_EEP_IP_AR_RELEASE_MINOR_VERSION_H != FTFC_EEP_IP_CFG_AR_RELEASE_MINOR_VERSION_H) || \
  62. (FTFC_EEP_IP_AR_RELEASE_REVISION_VERSION_H != FTFC_EEP_IP_CFG_AR_RELEASE_REVISION_VERSION_H) \
  63. )
  64. #error "Ftfc_Eep_Ip.h and Ftfc_Eep_Ip_Cfg.h are for different AUTOSAR versions!"
  65. #endif
  66. #if ((FTFC_EEP_IP_SW_MAJOR_VERSION_H != FTFC_EEP_IP_CFG_SW_MAJOR_VERSION_H) || \
  67. (FTFC_EEP_IP_SW_MINOR_VERSION_H != FTFC_EEP_IP_CFG_SW_MINOR_VERSION_H) || \
  68. (FTFC_EEP_IP_SW_PATCH_VERSION_H != FTFC_EEP_IP_CFG_SW_PATCH_VERSION_H) \
  69. )
  70. #error "Ftfc_Eep_Ip.h and Ftfc_Eep_Ip_Cfg.h have different SW versions!"
  71. #endif
  72. /* Version checks for Ftfc_Eep_Ip_Types.h */
  73. #if (FTFC_EEP_IP_VENDOR_ID_H != FTFC_EEP_IP_TYPES_VENDOR_ID_H)
  74. #error "Ftfc_Eep_Ip.h and Ftfc_Eep_Ip_Types.h have different vendor IDs!"
  75. #endif
  76. #if ((FTFC_EEP_IP_AR_RELEASE_MAJOR_VERSION_H != FTFC_EEP_IP_TYPES_AR_RELEASE_MAJOR_VERSION_H) || \
  77. (FTFC_EEP_IP_AR_RELEASE_MINOR_VERSION_H != FTFC_EEP_IP_TYPES_AR_RELEASE_MINOR_VERSION_H) || \
  78. (FTFC_EEP_IP_AR_RELEASE_REVISION_VERSION_H != FTFC_EEP_IP_TYPES_AR_RELEASE_REVISION_VERSION_H) \
  79. )
  80. #error "Ftfc_Eep_Ip.h and Ftfc_Eep_Ip_Types.h are for different AUTOSAR versions!"
  81. #endif
  82. #if ((FTFC_EEP_IP_SW_MAJOR_VERSION_H != FTFC_EEP_IP_TYPES_SW_MAJOR_VERSION_H) || \
  83. (FTFC_EEP_IP_SW_MINOR_VERSION_H != FTFC_EEP_IP_TYPES_SW_MINOR_VERSION_H) || \
  84. (FTFC_EEP_IP_SW_PATCH_VERSION_H != FTFC_EEP_IP_TYPES_SW_PATCH_VERSION_H) \
  85. )
  86. #error "Ftfc_Eep_Ip.h and Ftfc_Eep_Ip_Types.h have different SW versions!"
  87. #endif
  88. /*==================================================================================================
  89. * CONSTANTS
  90. ==================================================================================================*/
  91. /*==================================================================================================
  92. * DEFINES AND MACROS
  93. ==================================================================================================*/
  94. /*==================================================================================================
  95. * ENUMS
  96. ==================================================================================================*/
  97. /*==================================================================================================
  98. * STRUCTURES AND OTHER TYPEDEFS
  99. ==================================================================================================*/
  100. /*==================================================================================================
  101. * GLOBAL VARIABLE DECLARATIONS
  102. ==================================================================================================*/
  103. /*==================================================================================================
  104. * FUNCTION PROTOTYPES
  105. ==================================================================================================*/
  106. #define EEP_START_SEC_CODE
  107. #include "Eep_MemMap.h"
  108. /**
  109. * @brief Initialize the module.
  110. * @details Set FlexRAM to work as EEERAM.
  111. * Query EEPROM quick write status and complete the maintenance, if needed.
  112. *
  113. * Out of reset with the FSTAT[CCIF] bit clear, the partition settings (EEESIZE, DEPART)
  114. * are read from the data flash IFR and the emulated EEPROM file system is initialized
  115. * accordingly. The emulated EEPROM file system locates all valid EEPROM data records
  116. * in EEPROM backup and copies the newest data to FlexRAM.
  117. *
  118. * CCIF is cleared throughout the reset sequence. Completion of the reset sequence is marked by
  119. * setting CCIF which enables flash user commands.
  120. *
  121. * @param[in] pConfig pointer stored in Ftfc_Eep_Ip_pxConfiguration
  122. *
  123. * @return the initialization result
  124. * @retval FTFC_EEP_IP_STATUS_OK initialization successful
  125. * @retval FTFC_EEP_IP_STATUS_TIMEOUT a flash cmd timeout has occurred
  126. * @retval FTFC_EEP_IP_STATUS_FAILED a flash command failed to execute
  127. * @retval FTFC_EEP_IP_STATUS_FAILED_MGSTAT one or more MGSTAT 1/2/3 bits were set
  128. *
  129. **/
  130. Ftfc_Eep_Ip_StatusType Ftfc_Eep_Ip_Init (Ftfc_Eep_Ip_ConfigType const * pConfig);
  131. /**
  132. * @brief Read @p Length bytes from EEPROM @p SrcAddress to @p pu8DestAddress.
  133. *
  134. * @param[in] SrcAddress EEPROM address to read from
  135. * @param[out] pu8DestAddress buffer to store the read data
  136. * @param[in] Length how many bytes to read
  137. *
  138. * @return the read operation status
  139. * @retval FTFC_EEP_IP_STATUS_OK the requested bytes were copied into the destination buffer
  140. * @retval FTFC_EEP_IP_STATUS_FAILED FTFC not ready
  141. * @retval FTFC_EEP_IP_STATUS_FAILED a read was attempted on an invalid page size
  142. *
  143. **/
  144. Ftfc_Eep_Ip_StatusType Ftfc_Eep_Ip_Read (Ftfc_Eep_Ip_AddressType SrcAddress,
  145. uint8 * pu8DestAddress,
  146. Ftfc_Eep_Ip_LengthType Length
  147. );
  148. #if (FTFC_EEP_IP_COMPARE_API == STD_ON)
  149. /**
  150. * @brief Compare the first @p Length bytes of @p pu8DestAddress to the contents found at @p SrcAddress.
  151. *
  152. * @param[in] pu8DestAddress pointer to the data buffer
  153. * @param[in] SrcAddress where the contents in EEPROM are stored
  154. * @param[in] Length how many bytes to compare
  155. *
  156. * @return the comparison result
  157. * @retval FTFC_EEP_IP_STATUS_OK the contents match
  158. * @retval FTFC_EEP_IP_STATUS_BLOCK_INCONSISTENT the contents do not match
  159. * @retval FTFC_EEP_IP_STATUS_FAILED FTFC not ready
  160. * @retval FTFC_EEP_IP_STATUS_FAILED a read was attempted on an invalid page size
  161. *
  162. **/
  163. Ftfc_Eep_Ip_StatusType Ftfc_Eep_Ip_Compare (Ftfc_Eep_Ip_AddressType SrcAddress,
  164. uint8 const * pu8DestAddress,
  165. Ftfc_Eep_Ip_LengthType Length
  166. );
  167. #endif
  168. /**
  169. * @brief Write @p PageSize bytes from @p pu8SrcAddress buffer to EEPROM at @p offset DestAddress.
  170. *
  171. * @param[out] DestAddress EEPROM offset
  172. * @param[in] pu8SrcAddress buffer containing the data to be written
  173. * @param[in] PageSize must be a valid PageSize: 1, 2 or 4 bytes for FTFC and only 4 bytes for FTFM
  174. * @param[in] Async choose between a synchronous and an asynchronous job
  175. *
  176. * @return the write operation result
  177. * @retval FTFC_EEP_IP_STATUS_FAILED FTFC not ready
  178. * @retval FTFC_EEP_IP_STATUS_FAILED an invalid page alignment was given
  179. * @retval FTFC_EEP_IP_STATUS_FAILED sync: some of the FSTAT error bits were set
  180. * @retval FTFC_EEP_IP_STATUS_TIMEOUT sync: timeout occurred while waiting for CCIF
  181. * @retval FTFC_EEP_IP_STATUS_OK sync: page successfully written to EFLASH
  182. * @retval FTFC_EEP_IP_STATUS_PENDING async: the page was written to FlexRAM, but the status of
  183. * the EFLASH record shall be interrogated with GetJobResult
  184. *
  185. **/
  186. Ftfc_Eep_Ip_StatusType Ftfc_Eep_Ip_Write (Ftfc_Eep_Ip_AddressType DestAddress,
  187. uint8 const * pu8SrcAddress,
  188. Ftfc_Eep_Ip_PageSizeType PageSize,
  189. boolean Async
  190. );
  191. #if (FTFC_EEP_IP_QUICK_WRITES_API == STD_ON)
  192. /**
  193. * @brief QuickWrite API
  194. * @details
  195. *
  196. * For configurations with interleaved flash blocks for EEPROM backup, quick writes
  197. * should be restricted to either within the first half of EEERAM or within the second half
  198. * of EEERAM. Otherwise, FSTAT[ACCERR] will be returned.
  199. *
  200. * Once a quick write is started, user must finish the entire quick write activity prior to
  201. * starting another FTFC or CSE command.
  202. *
  203. * @param[out] DestAddress EEPROM offset needs to be 4-bytes aligned
  204. * @param[in] pu8SrcAddress
  205. * @param[in] Length
  206. *
  207. * @return quick write status
  208. * @retval FTFC_EEP_IP_STATUS_FAILED FTFC not ready
  209. * @retval FTFC_EEP_IP_STATUS_OK everything ok
  210. * @retval FTFC_EEP_IP_STATUS_FAILED invalid page size/alignment
  211. * @retval FTFC_EEP_IP_STATUS_FAILED some of the FSTAT error bits were set
  212. * @retval FTFC_EEP_IP_STATUS_FAILED_MGSTAT one or more MGSTAT 1/2/3 bits were set
  213. * @retval FTFC_EEP_IP_STATUS_TIMEOUT timeout occurred while waiting for CCIF
  214. *
  215. **/
  216. Ftfc_Eep_Ip_StatusType Ftfc_Eep_Ip_QuickWrite (Ftfc_Eep_Ip_AddressType DestAddress,
  217. uint8 const * pu8SrcAddress,
  218. Ftfc_Eep_Ip_LengthType Length
  219. );
  220. #endif
  221. /**
  222. * @brief Erase API
  223. * @details Invokes a write with ERASED_CELL_VALUE.
  224. *
  225. * @return the erase operation result
  226. * @retval FTFC_EEP_IP_STATUS_FAILED FTFC not ready
  227. * @retval FTFC_EEP_IP_STATUS_FAILED an invalid page size/alignment was given
  228. * @retval FTFC_EEP_IP_STATUS_FAILED sync: some of the FSTAT error bits were set
  229. * @retval FTFC_EEP_IP_STATUS_TIMEOUT sync: timeout occurred while waiting for CCIF
  230. * @retval FTFC_EEP_IP_STATUS_OK sync: page successfully written to EFLASH
  231. * @retval FTFC_EEP_IP_STATUS_PENDING async: the page was written to FlexRAM, but the status of
  232. * the EFLASH record shall be interrogated with GetJobResult
  233. *
  234. **/
  235. Ftfc_Eep_Ip_StatusType Ftfc_Eep_Ip_Erase (Ftfc_Eep_Ip_AddressType Address,
  236. Ftfc_Eep_Ip_PageSizeType PageSize,
  237. boolean Async
  238. );
  239. /**
  240. * @brief Interrogate the result of the last async job, considering the timeout and FSTAT errors.
  241. *
  242. * @return the result of the last async job
  243. * @retval FTFC_EEP_IP_STATUS_OK the job finished successfully
  244. * @retval FTFC_EEP_IP_STATUS_FAILED FSTAT error bits were set
  245. * @retval FTFC_EEP_IP_STATUS_PENDING the job is still waiting for CCIF
  246. * @retval FTFC_EEP_IP_STATUS_TIMEOUT a timeout has occurred while waiting for CCIF
  247. *
  248. **/
  249. Ftfc_Eep_Ip_StatusType Ftfc_Eep_Ip_GetJobResult (void);
  250. /**
  251. * @brief Getter for Ftfc_Eep_Ip_eBrownOutCode.
  252. *
  253. * @return the brownout code read after reset
  254. * @retval 0x04 normal write was interrupted
  255. * @retval 0x02 quick write was interrupted before writing all bytes to flash
  256. * @retval 0x01 quick write was interrupted before maintenance completed
  257. *
  258. **/
  259. Ftfc_Eep_Ip_BrownOutCodeType Ftfc_Eep_Ip_GetBrownOutCode (void);
  260. #define EEP_STOP_SEC_CODE
  261. #include "Eep_MemMap.h"
  262. #ifdef __cplusplus
  263. }
  264. #endif
  265. /** @} */
  266. #endif /* FTFC_EEP_IP_H */