Icu_Ipw.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : Ftm Lpit Lptmr Port_Ci LpCmp
  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. #ifndef ICU_IPW_H
  25. #define ICU_IPW_H
  26. /**
  27. * @file
  28. * @internal
  29. * @addtogroup icu_ipw Icu_Ipw Driver
  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 "Icu_Cfg.h"
  42. #include "Icu_Types.h"
  43. #include "Icu_Ipw_Types.h"
  44. #include "Icu_Ipw_Cfg.h"
  45. /*==================================================================================================
  46. * SOURCE FILE VERSION INFORMATION
  47. ==================================================================================================*/
  48. #define ICU_IPW_VENDOR_ID 43
  49. #define ICU_IPW_AR_RELEASE_MAJOR_VERSION 4
  50. #define ICU_IPW_AR_RELEASE_MINOR_VERSION 4
  51. #define ICU_IPW_AR_RELEASE_REVISION_VERSION 0
  52. #define ICU_IPW_SW_MAJOR_VERSION 1
  53. #define ICU_IPW_SW_MINOR_VERSION 0
  54. #define ICU_IPW_SW_PATCH_VERSION 0
  55. /*==================================================================================================
  56. * FILE VERSION CHECKS
  57. ==================================================================================================*/
  58. /* Check if current file and ICU header file are of the same vendor */
  59. #if (ICU_IPW_VENDOR_ID != ICU_CFG_VENDOR_ID)
  60. #error "Icu_Ipw.h and Icu_Cfg.h have different vendor IDs"
  61. #endif
  62. /* Check if current file and ICU header file are of the same AutoSar version */
  63. #if ((ICU_IPW_AR_RELEASE_MAJOR_VERSION != ICU_CFG_AR_RELEASE_MAJOR_VERSION) || \
  64. (ICU_IPW_AR_RELEASE_MINOR_VERSION != ICU_CFG_AR_RELEASE_MINOR_VERSION) || \
  65. (ICU_IPW_AR_RELEASE_REVISION_VERSION != ICU_CFG_AR_RELEASE_REVISION_VERSION))
  66. #error "AutoSar Version Numbers of Icu_Ipw.h and Icu_Cfg.h are different"
  67. #endif
  68. /* Check if current file and ICU header file are of the same Software version */
  69. #if ((ICU_IPW_SW_MAJOR_VERSION != ICU_CFG_SW_MAJOR_VERSION) || \
  70. (ICU_IPW_SW_MINOR_VERSION != ICU_CFG_SW_MINOR_VERSION) || \
  71. (ICU_IPW_SW_PATCH_VERSION != ICU_CFG_SW_PATCH_VERSION))
  72. #error "Software Version Numbers of Icu_Ipw.h and Icu_Cfg.h are different"
  73. #endif
  74. /* Check if current file and ICU header file are of the same vendor */
  75. #if (ICU_IPW_VENDOR_ID != ICU_TYPES_VENDOR_ID)
  76. #error "Icu_Ipw.h and Icu_Types.h have different vendor IDs"
  77. #endif
  78. /* Check if current file and ICU header file are of the same AutoSar version */
  79. #if ((ICU_IPW_AR_RELEASE_MAJOR_VERSION != ICU_TYPES_AR_RELEASE_MAJOR_VERSION) || \
  80. (ICU_IPW_AR_RELEASE_MINOR_VERSION != ICU_TYPES_AR_RELEASE_MINOR_VERSION) || \
  81. (ICU_IPW_AR_RELEASE_REVISION_VERSION != ICU_TYPES_AR_RELEASE_REVISION_VERSION))
  82. #error "AutoSar Version Numbers of Icu_Ipw.h and Icu_Types.h are different"
  83. #endif
  84. /* Check if current file and ICU header file are of the same Software version */
  85. #if ((ICU_IPW_SW_MAJOR_VERSION != ICU_TYPES_SW_MAJOR_VERSION) || \
  86. (ICU_IPW_SW_MINOR_VERSION != ICU_TYPES_SW_MINOR_VERSION) || \
  87. (ICU_IPW_SW_PATCH_VERSION != ICU_TYPES_SW_PATCH_VERSION))
  88. #error "Software Version Numbers of Icu_Ipw.h and Icu_Types.h are different"
  89. #endif
  90. /* Check if current file and ICU header file are of the same vendor */
  91. #if (ICU_IPW_VENDOR_ID != ICU_IPW_TYPES_VENDOR_ID)
  92. #error "Icu_Ipw.h and Icu_Ipw_Types.h have different vendor IDs"
  93. #endif
  94. /* Check if current file and ICU header file are of the same AutoSar version */
  95. #if ((ICU_IPW_AR_RELEASE_MAJOR_VERSION != ICU_IPW_TYPES_AR_RELEASE_MAJOR_VERSION) || \
  96. (ICU_IPW_AR_RELEASE_MINOR_VERSION != ICU_IPW_TYPES_AR_RELEASE_MINOR_VERSION) || \
  97. (ICU_IPW_AR_RELEASE_REVISION_VERSION != ICU_IPW_TYPES_AR_RELEASE_REVISION_VERSION))
  98. #error "AutoSar Version Numbers of Icu_Ipw.h and Icu_Ipw_Types.h are different"
  99. #endif
  100. /* Check if current file and ICU header file are of the same Software version */
  101. #if ((ICU_IPW_SW_MAJOR_VERSION != ICU_IPW_TYPES_SW_MAJOR_VERSION) || \
  102. (ICU_IPW_SW_MINOR_VERSION != ICU_IPW_TYPES_SW_MINOR_VERSION) || \
  103. (ICU_IPW_SW_PATCH_VERSION != ICU_IPW_TYPES_SW_PATCH_VERSION))
  104. #error "Software Version Numbers of Icu_Ipw.h and Icu_Ipw_Types.h are different"
  105. #endif
  106. /* Check if current file and ICU IPW header file are of the same vendor */
  107. #if (ICU_IPW_VENDOR_ID != ICU_IPW_CFG_VENDOR_ID)
  108. #error "Icu_Ipw.h and Icu_Ipw_Cfg.h have different vendor IDs"
  109. #endif
  110. /* Check if current file and ICU IPW header file are of the same AutoSar version */
  111. #if ((ICU_IPW_AR_RELEASE_MAJOR_VERSION != ICU_IPW_CFG_AR_RELEASE_MAJOR_VERSION) || \
  112. (ICU_IPW_AR_RELEASE_MINOR_VERSION != ICU_IPW_CFG_AR_RELEASE_MINOR_VERSION) || \
  113. (ICU_IPW_AR_RELEASE_REVISION_VERSION != ICU_IPW_CFG_AR_RELEASE_REVISION_VERSION))
  114. #error "AutoSar Version Numbers of Icu_Ipw.h and Icu_Ipw_Cfg.h are different"
  115. #endif
  116. /* Check if current file and ICU IPW header file are of the same Software version */
  117. #if ((ICU_IPW_SW_MAJOR_VERSION != ICU_IPW_CFG_SW_MAJOR_VERSION) || \
  118. (ICU_IPW_SW_MINOR_VERSION != ICU_IPW_CFG_SW_MINOR_VERSION) || \
  119. (ICU_IPW_SW_PATCH_VERSION != ICU_IPW_CFG_SW_PATCH_VERSION))
  120. #error "Software Version Numbers of Icu_Ipw.h and Icu_Ipw_Cfg.h are different"
  121. #endif
  122. /*==================================================================================================
  123. * CONSTANTS
  124. ==================================================================================================*/
  125. /*==================================================================================================
  126. * DEFINES AND MACROS
  127. ==================================================================================================*/
  128. /*==================================================================================================
  129. * ENUMS
  130. ==================================================================================================*/
  131. /*==================================================================================================
  132. * STRUCTURES AND OTHER TYPEDEFS
  133. ==================================================================================================*/
  134. /*==================================================================================================
  135. * GLOBAL VARIABLE DECLARATIONS
  136. ==================================================================================================*/
  137. /*==================================================================================================
  138. * FUNCTION PROTOTYPES
  139. ==================================================================================================*/
  140. #define ICU_START_SEC_CODE
  141. #include "Icu_MemMap.h"
  142. /**
  143. * @internal
  144. * @brief Icu_Ipw_Init
  145. * @details Initialize a hardware Icu IP Instance
  146. *
  147. * @param[in] count - Number of IPs instances to be configured.
  148. * @param[in] pIpConfig - Pointer to an array of Icu_Ipw_IpConfigType structures that contains
  149. * IP specific configuration data for the entire ICU driver.
  150. * @return void
  151. *
  152. * @pre Icu_DeInit must be called before.
  153. */
  154. void Icu_Ipw_Init(uint8 count, const Icu_Ipw_IpConfigType (*pIpConfig)[]);
  155. #if (ICU_DE_INIT_API == STD_ON)
  156. /**
  157. * @brief Icu_Ipw_DeInit
  158. * @details De-initialize ICU hardware channel
  159. *
  160. * @param[in] pIpConfig - Pointer to ICU top configuration structure
  161. *
  162. * @internal
  163. * @return void
  164. *
  165. * @pre Icu_Init must be called before.
  166. *
  167. */
  168. void Icu_Ipw_DeInit(uint8 count, const Icu_Ipw_IpConfigType (*pIpConfig)[]);
  169. #endif
  170. #if (ICU_SET_MODE_API == STD_ON)
  171. /**
  172. * @brief Put the channel in a reduce power state.
  173. *
  174. * @internal
  175. * @param channelConfig - configuration of the channel
  176. */
  177. void Icu_Ipw_SetSleepMode(const Icu_Ipw_ChannelConfigType * ChannelConfig);
  178. /**
  179. * @brief Set the channel to run again.
  180. *
  181. * @internal
  182. * @param channelConfig - configuration of the channel
  183. */
  184. void Icu_Ipw_SetNormalMode(const Icu_Ipw_ChannelConfigType * ChannelConfig);
  185. #endif /* ICU_SET_MODE_API == STD_ON */
  186. /**
  187. * @brief Icu_Ipw_SetActivationCondition
  188. * @details
  189. *
  190. * @param[in] activation - the type of activation for the ICU channel.
  191. * @param[in] ChannelConfig - the measurement mode of the channel
  192. *
  193. * @internal
  194. * @return void
  195. *
  196. */
  197. void Icu_Ipw_SetActivationCondition(Icu_ActivationType activation,
  198. const Icu_Ipw_ChannelConfigType* ChannelConfig);
  199. #if (ICU_GET_INPUT_STATE_API == STD_ON)
  200. /**
  201. * @brief Icu_Ipw_GetInputState
  202. * @details Service that returns the state of the ICU driver
  203. *
  204. * @param[in] ChannelConfig - The current channel configuration structure
  205. *
  206. * @internal
  207. * @return Icu_InputStateType
  208. * @retval ICU_ACTIVE An active edge has been detected
  209. * @retval ICU_IDLE No active edge has been detected since the cast call to
  210. * Icu_Ipw_Init or Icu_Ipw_GetInputState
  211. */
  212. boolean Icu_Ipw_GetInputState (const Icu_Ipw_ChannelConfigType *ChannelConfig);
  213. #endif /* ICU_GET_INPUT_STATE_API == STD_ON */
  214. #if (STD_ON == ICU_TIMESTAMP_API)
  215. /**
  216. * @brief
  217. * @internal
  218. * @param channelConfig
  219. * @param bDmaSupport
  220. */
  221. void Icu_Ipw_StartTimestamp(const Icu_Ipw_ChannelConfigType* channelConfig,
  222. uint16* bufferPtr,
  223. uint16 bufferSize,
  224. uint16 notifyInterval);
  225. /**
  226. * @brief
  227. * @internal
  228. * @param channelConfig
  229. */
  230. void Icu_Ipw_StopTimestamp(const Icu_Ipw_ChannelConfigType *channelConfig);
  231. /**
  232. * @brief
  233. *
  234. * @param channelConfig
  235. * @return uint16
  236. */
  237. uint16 Icu_Ipw_GetTimestampIndex(const Icu_Ipw_ChannelConfigType* channelConfig);
  238. #if (ICU_TIMESTAMP_USES_DMA == STD_ON)
  239. uint32 Icu_Ipw_GetStartAddress(const Icu_Ipw_ChannelConfigType *ChannelConfig);
  240. #endif /* ICU_TIMESTAMP_USES_DMA == STD_ON */
  241. #endif /* ICU_TIMESTAMP_API == STD_ON */
  242. #if (STD_ON == ICU_EDGE_COUNT_API)
  243. /**
  244. * @brief
  245. * @internal
  246. * @param ChannelConfig
  247. */
  248. void Icu_Ipw_ResetEdgeCount(const Icu_Ipw_ChannelConfigType *ChannelConfig);
  249. /**
  250. * @brief
  251. * @internal
  252. * @param ChannelConfig
  253. */
  254. void Icu_Ipw_EnableEdgeCount(const Icu_Ipw_ChannelConfigType *ChannelConfig);
  255. /**
  256. * @brief
  257. * @internal
  258. * @param ChannelConfig
  259. */
  260. void Icu_Ipw_DisableEdgeCount(const Icu_Ipw_ChannelConfigType *ChannelConfig);
  261. /**
  262. * @brief
  263. * @internal
  264. * @param ChannelConfig
  265. * @return uint16
  266. */
  267. uint16 Icu_Ipw_GetEdgeNumbers(const Icu_Ipw_ChannelConfigType *ChannelConfig);
  268. #endif /* STD_ON == ICU_EDGE_COUNT_API */
  269. #if (STD_ON == ICU_EDGE_DETECT_API)
  270. void Icu_Ipw_EnableEdgeDetection(const Icu_Ipw_ChannelConfigType * ChannelConfig);
  271. void Icu_Ipw_DisableEdgeDetection(const Icu_Ipw_ChannelConfigType* ChannelConfig);
  272. #endif
  273. #if ((ICU_OVERFLOW_NOTIFICATION_API == STD_OFF) && (ICU_VALIDATE_PARAMS == STD_ON))
  274. #if ((ICU_EDGE_COUNT_API == STD_ON) || (ICU_TIMESTAMP_API == STD_ON) || \
  275. (ICU_GET_TIME_ELAPSED_API == STD_ON) || (ICU_GET_DUTY_CYCLE_VALUES_API == STD_ON))
  276. /**
  277. * @brief The function get the state of the overflow flag
  278. * @internal
  279. * @param ChannelConfig Channel configuration pointer
  280. * @return boolean the state of the overflow flag
  281. * @retval TRUE the overflow flag is set
  282. * @retval FALSE the overflow flag is not set
  283. */
  284. boolean Icu_Ipw_Get_Overflow(const Icu_Ipw_ChannelConfigType* ChannelConfig);
  285. #endif
  286. #endif /* (ICU_OVERFLOW_NOTIFICATION_API == STD_OFF) && (ICU_VALIDATE_PARAMS == STD_ON) */
  287. #if ((ICU_CAPTURERGISTER_API == STD_ON) && ((ICU_SIGNAL_MEASUREMENT_API == STD_ON) || (ICU_TIMESTAMP_API == STD_ON)))/**
  288. * @brief Capture the value of counter register for a specified channel.
  289. *
  290. * @details The API shall return the value stored in capture register.
  291. * The API is the equivalent of AUTOSAR API GetCaptureRegisterValue.
  292. *
  293. * @param ChannelConfig Channel configuration pointer
  294. * @return uint32 Value of the register captured.
  295. */
  296. Icu_ValueType Icu_Ipw_GetCaptureRegisterValue(const Icu_Ipw_ChannelConfigType* ChannelConfig);
  297. #endif
  298. #if (STD_ON == ICU_SIGNAL_MEASUREMENT_API)
  299. /**
  300. * @brief
  301. * @internal
  302. * @param channelConfig
  303. */
  304. void Icu_Ipw_StartSignalMeasurement(const Icu_Ipw_ChannelConfigType *ChannelConfig);
  305. /**
  306. * @brief
  307. * @internal
  308. * @param channelConfig
  309. */
  310. void Icu_Ipw_StopSignalMeasurement(const Icu_Ipw_ChannelConfigType * ChannelConfig);
  311. void Icu_Ipw_GetPWandPeriod(const Icu_Ipw_ChannelConfigType* channelConfig, \
  312. Icu_ValueType* Icu_aActivePulseWidth, \
  313. Icu_ValueType* Icu_aPeriod);
  314. #endif /* STD_ON == ICU_SIGNAL_MEASUREMENT_API */
  315. #if (STD_ON == ICU_DUAL_CLOCK_MODE_API)
  316. /**
  317. * @brief
  318. * @internal
  319. * @param moduleConfig
  320. * @param selectPrescaler
  321. * @param modulesNumber
  322. */
  323. void Icu_Ipw_SetClockMode(const Icu_Ipw_IpConfigType (*moduleConfig)[], Icu_SelectPrescalerType selectPrescaler,
  324. uint8 modulesNumber);
  325. #endif /* STD_ON == ICU_DUAL_CLOCK_MODE_API */
  326. #if (STD_ON == ICU_GET_INPUT_LEVEL_API)
  327. /**
  328. * @brief Mapping macro between IP input level functionality and HL function.
  329. * @internal
  330. * @param channelConfig
  331. * @return Icu_LevelType
  332. */
  333. Icu_LevelType Icu_Ipw_GetInputLevel(const Icu_Ipw_ChannelConfigType * ChannelConfig);
  334. #endif /* STD_ON == ICU_GET_INPUT_LEVEL_API */
  335. #if ((ICU_VALIDATE_PARAMS == STD_ON) && (ICU_GET_INPUT_LEVEL_API == STD_ON))
  336. /**
  337. * @brief
  338. * @internal
  339. * @param channelConfig
  340. * @return Icu_Ipw_StatusType
  341. */
  342. Icu_Ipw_StatusType Icu_Ipw_ValidateGetInputLevel(const Icu_Ipw_ChannelConfigType * ChannelConfig);
  343. #endif
  344. #if (STD_ON == ICU_GET_DUTY_CYCLE_VALUES_API)
  345. /**
  346. * @brief
  347. *
  348. * @param channelConfig
  349. * @param DutyCycleValues
  350. * @internal
  351. */
  352. void Icu_Ipw_GetDutyCycleValues(const Icu_Ipw_ChannelConfigType* channelConfig,
  353. Icu_DutyCycleType* DutyCycleValues);
  354. #endif /* STD_ON == ICU_GET_DUTY_CYCLE_VALUES_API */
  355. #if (STD_ON == ICU_GET_TIME_ELAPSED_API)
  356. /**
  357. * @brief
  358. *
  359. * @param channelConfig
  360. * @return Icu_ValueType
  361. * @internal
  362. */
  363. Icu_ValueType Icu_Ipw_GetTimeElapsed(const Icu_Ipw_ChannelConfigType* channelConfig);
  364. #endif /* STD_ON == ICU_GET_TIME_ELAPSED_API */
  365. /**
  366. * @brief Icu_Ipw_EnableNotification
  367. * @details Enable Notification for timestamp
  368. *
  369. * @param[in] ChannelConfig - The index of ICU channel for current configuration structure
  370. *
  371. * @return void
  372. * @internal
  373. */
  374. void Icu_Ipw_EnableNotification(const Icu_Ipw_ChannelConfigType* ChannelConfig);
  375. /**
  376. * @brief Icu_Ipw_DisableNotification
  377. * @details Disable Notification for timestamp
  378. *
  379. * @param[in] ChannelConfig - The index of ICU channel for current configuration structure
  380. *
  381. * @return void
  382. * @internal
  383. */
  384. void Icu_Ipw_DisableNotification(const Icu_Ipw_ChannelConfigType* ChannelConfig);
  385. #define ICU_STOP_SEC_CODE
  386. #include "Icu_MemMap.h"
  387. #ifdef __cplusplus
  388. }
  389. #endif
  390. /** @} */
  391. #endif /* ICU_IPW_H */