Eep.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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 EEP_H
  25. #define EEP_H
  26. /**
  27. * @file
  28. *
  29. * @addtogroup EEP_DRIVER Eeprom Driver
  30. * @{
  31. */
  32. /* implements Eep.h_Artifact */
  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 "Eep_Cfg.h"
  43. #include "SchM_Eep.h"
  44. #include "StandardTypes.h"
  45. #if (STD_ON == EEP_MCORE_ENABLED)
  46. #include "CDD_Rm.h"
  47. #endif /* EEP_MCORE_ENABLED */
  48. /*==================================================================================================
  49. * SOURCE FILE VERSION INFORMATION
  50. ==================================================================================================*/
  51. #define EEP_VENDOR_ID 43
  52. #define EEP_MODULE_ID 90
  53. #define EEP_INSTANCE_ID 0U
  54. #define EEP_AR_RELEASE_MAJOR_VERSION 4
  55. #define EEP_AR_RELEASE_MINOR_VERSION 4
  56. #define EEP_AR_RELEASE_REVISION_VERSION 0
  57. #define EEP_SW_MAJOR_VERSION 1
  58. #define EEP_SW_MINOR_VERSION 0
  59. #define EEP_SW_PATCH_VERSION 0
  60. /*==================================================================================================
  61. * FILE VERSION CHECKS
  62. ==================================================================================================*/
  63. /* Check if header file and Eep_Cfg.h header file are of the same vendor */
  64. #if (EEP_VENDOR_ID != EEP_VENDOR_ID_CFG)
  65. #error "Eep.h and Eep_Cfg.h have different vendor ids"
  66. #endif
  67. /* Check if header file and Eep_Cfg.h header file are of the same Autosar version */
  68. #if ((EEP_AR_RELEASE_MAJOR_VERSION != EEP_AR_RELEASE_MAJOR_VERSION_CFG) || \
  69. (EEP_AR_RELEASE_MINOR_VERSION != EEP_AR_RELEASE_MINOR_VERSION_CFG) || \
  70. (EEP_AR_RELEASE_REVISION_VERSION != EEP_AR_RELEASE_REVISION_VERSION_CFG) \
  71. )
  72. #error "AutoSar Version Numbers of Eep.h and Eep_Cfg.h are different"
  73. #endif
  74. /* Check if header file and Eep_Cfg.h header file are of the same software version */
  75. #if ((EEP_SW_MAJOR_VERSION != EEP_SW_MAJOR_VERSION_CFG) || \
  76. (EEP_SW_MINOR_VERSION != EEP_SW_MINOR_VERSION_CFG) || \
  77. (EEP_SW_PATCH_VERSION != EEP_SW_PATCH_VERSION_CFG) \
  78. )
  79. #error "Software Version Numbers of Eep.h and Eep_Cfg.h are different"
  80. #endif
  81. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  82. /* Check if current file and StandardTypes.h file are of the same version */
  83. #if ((EEP_AR_RELEASE_MAJOR_VERSION != STD_AR_RELEASE_MAJOR_VERSION) || \
  84. (EEP_AR_RELEASE_MINOR_VERSION != STD_AR_RELEASE_MINOR_VERSION)\
  85. )
  86. #error "AutoSar Version Numbers of Eep.h and StandardTypes.h are different"
  87. #endif
  88. /* Check if current file and SchM_Eep.h file are of the same version */
  89. #if ((EEP_AR_RELEASE_MAJOR_VERSION != SCHM_EEP_AR_RELEASE_MAJOR_VERSION) || \
  90. (EEP_AR_RELEASE_MINOR_VERSION != SCHM_EEP_AR_RELEASE_MINOR_VERSION)\
  91. )
  92. #error "AutoSar Version Numbers of Eep.h and SchM_Eep.h are different"
  93. #endif
  94. #endif
  95. #if (STD_ON == EEP_MCORE_ENABLED)
  96. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  97. /* Check if current file and CDD_Rm header file are of the same Autosar version */
  98. #if ((EEP_AR_RELEASE_MAJOR_VERSION != RM_AR_RELEASE_MAJOR_VERSION) || \
  99. (EEP_AR_RELEASE_MINOR_VERSION != RM_AR_RELEASE_MINOR_VERSION) \
  100. )
  101. #error "AutoSar Version Numbers of Eep.c and CDD_Rm.h are different"
  102. #endif
  103. #endif
  104. #endif /* EEP_MCORE_ENABLED */
  105. /*==================================================================================================
  106. * CONSTANTS
  107. ==================================================================================================*/
  108. #define EEP_START_SEC_CONFIG_DATA_UNSPECIFIED
  109. #include "Eep_MemMap.h"
  110. EEP_CONFIG_EXT
  111. #define EEP_STOP_SEC_CONFIG_DATA_UNSPECIFIED
  112. #include "Eep_MemMap.h"
  113. /**
  114. * @brief Development error codes (passed to DET).
  115. *
  116. */
  117. /**
  118. * @brief service ID of function: Eep_Init. (passed to DET)
  119. */
  120. #define EEP_E_INIT_FAILED 0x10U
  121. /**
  122. * @brief service ID of error: TargetAddress is not in range and aligned to first byte of eeprom sector. (passed to DET)
  123. */
  124. #define EEP_E_PARAM_ADDRESS 0x11U
  125. /**
  126. * @brief service ID of error: NULL_PTR == SourceAddressPtr. (passed to DET)
  127. */
  128. #define EEP_E_PARAM_DATA 0x12U
  129. /**
  130. * @brief service ID of error: TargetAddress is not in range and aligned to last byte of eeprom sector. (passed to DET)
  131. */
  132. #define EEP_E_PARAM_LENGTH 0x13U
  133. /**
  134. * @brief service ID of error: API service called without module initialization. (passed to DET)
  135. */
  136. #define EEP_E_UNINIT 0x20U
  137. /**
  138. * @brief service ID of error: API service called while driver still busy. (passed to DET)
  139. */
  140. #define EEP_E_BUSY 0x21U
  141. /**
  142. * @brief service ID of error: The hardware operation did not finish before timeout expired. (passed to DET)
  143. */
  144. #define EEP_E_TIMEOUT 0x22U
  145. /**
  146. * @brief service ID of error: NULL_PTR passed. (passed to DET)
  147. */
  148. #define EEP_E_PARAM_POINTER 0x23U
  149. /**
  150. * @brief All service IDs (passed to DET).
  151. *
  152. */
  153. #define EEP_INIT_ID 0x00U
  154. #define EEP_SETMODE_ID 0x01U
  155. #define EEP_READ_ID 0x02U
  156. #define EEP_WRITE_ID 0x03U
  157. #define EEP_ERASE_ID 0x04U
  158. #define EEP_COMPARE_ID 0x05U
  159. #define EEP_CANCEL_ID 0x06U
  160. #define EEP_GETJOBRESULT_ID 0x08U
  161. #define EEP_MAINFUNCTION_ID 0x09U
  162. #define EEP_GETVERSIONINFO_ID 0x0AU
  163. #define EEP_QUICK_WRITE_ID 0x0BU
  164. /*==================================================================================================
  165. * FUNCTION PROTOTYPES
  166. ==================================================================================================*/
  167. /**
  168. * @brief Start of Eep section CODE
  169. */
  170. #define EEP_START_SEC_CODE
  171. #include "Eep_MemMap.h"
  172. /**
  173. * @brief The function initializes Eep module.
  174. * @details The function sets the internal module variables according to given
  175. * configuration set.
  176. *
  177. * @param[in] pConfigPtr Pointer to eeprom driver configuration set.
  178. *
  179. * @api
  180. *
  181. * @pre @p pConfigPtr must not be @p NULL_PTR and the module status must not
  182. * be @p MEMIF_BUSY.
  183. **
  184. */
  185. void Eep_Init (const Eep_ConfigType * pConfigPtr);
  186. /**
  187. * @brief Write one or more complete eeprom pages to the eeprom device.
  188. * @details Starts a write job asynchronously. The actual job is performed by
  189. * Eep_MainFunction.
  190. *
  191. * @param[in] TargetAddress Target address in eeprom memory.
  192. * @param[in] SourceAddressPtr Pointer to source data buffer.
  193. * @param[in] Length Number of bytes to write.
  194. *
  195. * @return Std_ReturnType
  196. * @retval E_OK Write command has been accepted.
  197. * @retval E_NOT_OK Write command has not been accepted.
  198. *
  199. * @api
  200. *
  201. * @pre The module has to be initialized and not busy.
  202. **
  203. */
  204. Std_ReturnType Eep_Write (Eep_AddressType u32TargetAddress,
  205. const uint8 * pSourceAddressPtr,
  206. Eep_LengthType u32Length
  207. );
  208. #if (EEP_QUICK_WRITES_API == STD_ON)
  209. /**
  210. * @brief Write one or more complete eeprom pages to the eeprom device in quick write mode.
  211. * @details Starts a write job asynchronously. The actual job is performed by
  212. * Eep_MainFunction.
  213. *
  214. * @param[in] TargetAddress Target address in eeprom memory.
  215. * @param[in] SourceAddressPtr Pointer to source data buffer.
  216. * @param[in] Length Number of bytes to write.
  217. * @param[in] u16QuickWritesLength Number of bytes to allocated for quick write
  218. *
  219. * @return Std_ReturnType
  220. * @retval E_OK Write command has been accepted.
  221. * @retval E_NOT_OK Write command has not been accepted.
  222. *
  223. * @api
  224. *
  225. * @pre The module has to be initialized and not busy.*/
  226. Std_ReturnType Eep_QuickWrite (Eep_AddressType u32TargetAddress,
  227. uint8 const * pSourceAddressPtr,
  228. Eep_LengthType u32Length,
  229. uint16 u16QuickWritesLength
  230. );
  231. #endif /* EEP_QUICK_WRITES_API */
  232. /**
  233. * @brief Erase memory by writing erase value.
  234. * @details Starts an erase job asynchronously. The actual job is performed
  235. * by the Eep_MainFunction.
  236. *
  237. * @param[in] TargetAddress Target address in eeprom memory.
  238. * @param[in] Length Number of bytes to erase by writing the erased value.
  239. *
  240. * @return Std_ReturnType
  241. * @retval E_OK Erase command has been accepted.
  242. * @retval E_NOT_OK Erase command has not been accepted.
  243. *
  244. * @api
  245. *
  246. * @pre The module has to be initialized and not busy.
  247. * @post
  248. **
  249. */
  250. Std_ReturnType Eep_Erase (Eep_AddressType u32TargetAddress,
  251. Eep_LengthType u32Length
  252. );
  253. #if (EEP_CANCEL_API == STD_ON)
  254. /**
  255. * @brief Cancel an ongoing eeprom read, write, erase or compare job.
  256. * @details Abort a running job synchronously so that directly after returning
  257. * from this function a new job can be started.
  258. *
  259. * @api
  260. *
  261. * @pre The module must be initialized.
  262. * @post @p Eep_Cancel changes module status and @p Eep_eJobResult
  263. * internal variable.
  264. **/
  265. void Eep_Cancel (void);
  266. #endif
  267. #if (EEP_GET_STATUS_API == STD_ON)
  268. /**
  269. * @brief Returns the EEP module status.
  270. * @details Returns the EEP module status synchronously.
  271. *
  272. * @return MemIf_StatusType
  273. * @retval MEMIF_UNINIT Module has not been initialized (yet).
  274. * @retval MEMIF_IDLE Module is currently idle.
  275. * @retval MEMIF_BUSY Module is currently busy.
  276. *
  277. * @api
  278. **/
  279. MemIf_StatusType Eep_GetStatus (void);
  280. #endif
  281. #if (EEP_GET_JOB_RESULT_API == STD_ON)
  282. /**
  283. * @brief Returns the result of the last job.
  284. * @details Returns synchronously the result of the last job.
  285. *
  286. * @return MemIf_JobResultType
  287. * @retval MEMIF_JOB_OK Successfully completed job.
  288. * @retval MEMIF_JOB_FAILED Not successfully completed job.
  289. * @retval MEMIF_JOB_PENDING Still pending job (not yet completed).
  290. * @retval MEMIF_JOB_CANCELED Job has been canceled.
  291. * @retval MEMIF_BLOCK_INCONSISTENT Inconsistent block requested, it may
  292. * contains corrupted data.
  293. * @retval MEMIF_BLOCK_INVALID Invalid block requested.
  294. *
  295. * @api
  296. **/
  297. MemIf_JobResultType Eep_GetJobResult (void);
  298. #endif
  299. /**
  300. * @brief Reads from eeprom memory.
  301. * @details Starts a read job asynchronously. The actual job is performed by
  302. * @p Eep_MainFunction.
  303. *
  304. * @param[in] SourceAddress Source address in eeprom memory.
  305. * @param[in] Length Number of bytes to read.
  306. * @param[out] TargetAddressPtr Pointer to target data buffer.
  307. *
  308. * @return MemIf_JobResultType
  309. * @retval MEMIF_JOB_OK Successfully completed job.
  310. * @retval MEMIF_JOB_FAILED Not successfully completed job.
  311. * @retval MEMIF_JOB_PENDING Still pending job (not yet completed).
  312. * @retval MEMIF_JOB_CANCELED Job has been canceled.
  313. * @retval MEMIF_BLOCK_INCONSISTENT Inconsistent block requested, it may
  314. * contains corrupted data.
  315. * @retval MEMIF_BLOCK_INVALID Invalid block requested.
  316. *
  317. * @api
  318. *
  319. * @pre The module has to be initialized and not busy.
  320. * @post
  321. **
  322. */
  323. Std_ReturnType Eep_Read (Eep_AddressType u32SourceAddress,
  324. uint8 * pTargetAddressPtr,
  325. Eep_LengthType u32Length
  326. );
  327. #if (EEP_COMPARE_API == STD_ON)
  328. /**
  329. * @brief Compares a eeprom memory area with an application data buffer.
  330. * @details Starts a compare job asynchronously. The actual job is performed by
  331. * Eep_MainFunction.
  332. *
  333. * @param[in] SourceAddress Source address in eeprom memory.
  334. * @param[in] TargetAddressPtr Pointer to source data buffer.
  335. * @param[in] Length Number of bytes to compare.
  336. *
  337. * @return Std_ReturnType
  338. * @retval E_OK Compare command has been accepted.
  339. * @retval E_NOT_OK Compare command has not been accepted.
  340. *
  341. * @api
  342. *
  343. * @pre The module has to be initialized and not busy.
  344. **/
  345. Std_ReturnType Eep_Compare (Eep_AddressType u32SourceAddress,
  346. const uint8 * pTargetAddressPtr,
  347. Eep_LengthType u32Length
  348. );
  349. #endif
  350. #if (EEP_SET_MODE_API == STD_ON)
  351. /**
  352. * @brief Sets the EEP module's operation mode to the given Mode.
  353. * @details Every given mode determinates maximum bytes for read-write
  354. * operations. Every mode has a set of pre-configured values.
  355. *
  356. * @param[in] Mode MEMIF_MODE_FAST or MEMIF_MODE_SLOW.
  357. *
  358. * @api
  359. *
  360. * @pre The module has to be initialized and not busy.
  361. * @post @p Eep_SetMode changes internal variables @p Eep_u32MaxRead and
  362. * @p Eep_u32MaxWrite.
  363. **/
  364. void Eep_SetMode (MemIf_ModeType eMode);
  365. #endif
  366. #if (EEP_VERSION_INFO_API == STD_ON)
  367. /**
  368. * @brief Returns version information about EEP module.
  369. * @details Version information includes:
  370. * - Module Id
  371. * - Vendor Id
  372. * - Vendor specific version numbers (BSW00407).
  373. *
  374. * @param[in,out] pVersionInfoPtr Pointer to where to store the version information of this module.
  375. *
  376. * @api
  377. **
  378. */
  379. void Eep_GetVersionInfo (Std_VersionInfoType * pVersionInfoPtr);
  380. #endif
  381. /**
  382. * @brief Stop of Eep section CODE
  383. */
  384. #define EEP_STOP_SEC_CODE
  385. #include "Eep_MemMap.h"
  386. #ifdef __cplusplus
  387. }
  388. #endif
  389. #endif /* EEP_H */
  390. /** @} */