Gpt_Ipw.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral : Ftm_Srtc_Lptmr_LPit
  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 GPT_IPW_H
  25. #define GPT_IPW_H
  26. /**
  27. * @file Gpt_Ipw.h
  28. *
  29. * @internal
  30. * @addtogroup gpt gpt_ipw
  31. *
  32. * @{
  33. */
  34. #ifdef __cplusplus
  35. extern "C"{
  36. #endif
  37. /*==================================================================================================
  38. * INCLUDE FILES
  39. * 1) system and project includes
  40. * 2) needed interfaces from external units
  41. * 3) internal and external interfaces from this unit
  42. ==================================================================================================*/
  43. #include "Gpt.h"
  44. #include "Gpt_Ipw_Types.h"
  45. /*==================================================================================================
  46. * SOURCE FILE VERSION INFORMATION
  47. ==================================================================================================*/
  48. #define GPT_IPW_VENDOR_ID 43
  49. #define GPT_IPW_AR_RELEASE_MAJOR_VERSION 4
  50. #define GPT_IPW_AR_RELEASE_MINOR_VERSION 4
  51. #define GPT_IPW_AR_RELEASE_REVISION_VERSION 0
  52. #define GPT_IPW_SW_MAJOR_VERSION 1
  53. #define GPT_IPW_SW_MINOR_VERSION 0
  54. #define GPT_IPW_SW_PATCH_VERSION 0
  55. /*==================================================================================================
  56. * FILE VERSION CHECKS
  57. ==================================================================================================*/
  58. #if ( GPT_VENDOR_ID != GPT_IPW_VENDOR_ID)
  59. #error "Gpt.h and Gpt_Ipw.h have different vendor ids"
  60. #endif
  61. /* Check if the header files are of the same Autosar version */
  62. #if ((GPT_AR_RELEASE_MAJOR_VERSION != GPT_IPW_AR_RELEASE_MAJOR_VERSION) || \
  63. (GPT_AR_RELEASE_MINOR_VERSION != GPT_IPW_AR_RELEASE_MINOR_VERSION) || \
  64. (GPT_AR_RELEASE_REVISION_VERSION != GPT_IPW_AR_RELEASE_REVISION_VERSION) \
  65. )
  66. #error "AutoSar Version Numbers of Gpt.h and Gpt_Ipw.h are different"
  67. #endif
  68. /* Check if the header files are of the same Software version */
  69. #if ((GPT_SW_MAJOR_VERSION != GPT_IPW_SW_MAJOR_VERSION) || \
  70. (GPT_SW_MINOR_VERSION != GPT_IPW_SW_MINOR_VERSION) || \
  71. (GPT_SW_PATCH_VERSION != GPT_IPW_SW_PATCH_VERSION) \
  72. )
  73. #error "Software Version Numbers of Gpt.h and Gpt_Ipw.h are different"
  74. #endif
  75. #if (GPT_IPW_TYPES_VENDOR_ID != GPT_IPW_VENDOR_ID)
  76. #error "Gpt_Ipw_Types.h and Gpt_Ipw.h have different vendor ids"
  77. #endif
  78. /* Check if the header files are of the same Autosar version */
  79. #if ((GPT_IPW_TYPES_AR_RELEASE_MAJOR_VERSION != GPT_IPW_AR_RELEASE_MAJOR_VERSION) || \
  80. (GPT_IPW_TYPES_AR_RELEASE_MINOR_VERSION != GPT_IPW_AR_RELEASE_MINOR_VERSION) || \
  81. (GPT_IPW_TYPES_AR_RELEASE_REVISION_VERSION != GPT_IPW_AR_RELEASE_REVISION_VERSION) \
  82. )
  83. #error "AutoSar Version Numbers of Gpt_Ipw_Types.h and Gpt_Ipw.h are different"
  84. #endif
  85. /* Check if the header files are of the same Software version */
  86. #if ((GPT_IPW_TYPES_SW_MAJOR_VERSION != GPT_IPW_SW_MAJOR_VERSION) || \
  87. (GPT_IPW_TYPES_SW_MINOR_VERSION != GPT_IPW_SW_MINOR_VERSION) || \
  88. (GPT_IPW_TYPES_SW_PATCH_VERSION != GPT_IPW_SW_PATCH_VERSION) \
  89. )
  90. #error "Software Version Numbers of Gpt_Ipw_Types.h and Gpt_Ipw.h are different"
  91. #endif
  92. /*==================================================================================================
  93. * CONSTANTS
  94. ==================================================================================================*/
  95. /*==================================================================================================
  96. * DEFINES AND MACROS
  97. ==================================================================================================*/
  98. /*==================================================================================================
  99. ENUMS
  100. ==================================================================================================*/
  101. /*==================================================================================================
  102. STRUCTURES AND OTHER TYPEDEFS
  103. ==================================================================================================*/
  104. #define GPT_START_SEC_CONFIG_DATA_UNSPECIFIED
  105. #include "Gpt_MemMap.h"
  106. /**
  107. * @internal
  108. * @brief Gpt channel hardware runtime information.
  109. * @details This is the type of the data structure used by the Autosar layer to
  110. * receive runtime information specific to hardware IP
  111. */
  112. typedef struct
  113. {
  114. boolean bChannelRollover; /**< @brief GPT channel rollover information*/
  115. Gpt_ValueType uTargetTime; /**< @brief GPT channel target value*/
  116. } Gpt_HwChannelInfoType;
  117. #define GPT_STOP_SEC_CONFIG_DATA_UNSPECIFIED
  118. #include "Gpt_MemMap.h"
  119. /*==================================================================================================
  120. GLOBAL VARIABLE DECLARATIONS
  121. ==================================================================================================*/
  122. /*==================================================================================================
  123. FUNCTION PROTOTYPES
  124. ==================================================================================================*/
  125. #define GPT_START_SEC_CODE
  126. #include "Gpt_MemMap.h"
  127. /*================================================================================================*/
  128. /**
  129. * @internal
  130. * @brief Gpt driver Autosar independent and IP dependent initialization function.
  131. * @details This function Gpt_Ipw_Init is called once for each channel in the used configuration.
  132. * It determines the type of the HW channel and calls the
  133. * appropriate IP function in order to initializes the hardware timer.
  134. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  135. * @return void
  136. * @pre The driver needs to be initialized.
  137. */
  138. void Gpt_Ipw_Init(const Gpt_Ipw_HwChannelConfigType *pHwChannelConfig);
  139. /*================================================================================================*/
  140. /**
  141. * @internal
  142. * @brief Gpt driver Autosar independent and IP dependent initialization function.
  143. * @details This Gpt_Ipw_InitInstances is called once for each channel in the used configuration.
  144. * It determines the type of the HW channel and calls the
  145. * appropriate IP function in order to initializes the hardware timer.
  146. * @param[in] configPtr Pointer to the channel configuration structure dependent by platform
  147. *
  148. * @return void
  149. * @pre The driver needs to be initialized.
  150. */
  151. void Gpt_Ipw_InitInstances(const Gpt_ConfigType * configPtr);
  152. /*================================================================================================*/
  153. /**
  154. * @internal
  155. * @brief Gpt driver Autosar independent and IP dependent function for fetching the elapsed timer value.
  156. * @details It determines the type of the HW channel and calls the
  157. * appropriate IP function for reading the elapsed timer value from the HW.
  158. *
  159. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  160. * @param[in] uTargetTime Target time value
  161. * @param[out] pReturnHwChannelInfo Rollover status flag value of the hardware timer channel
  162. * @return returnValue The elapsed time
  163. * @pre The driver needs to be initialized.Call GetTimeElapsed before.
  164. *
  165. */
  166. Gpt_ValueType Gpt_Ipw_GetTimeElapsed
  167. (
  168. const Gpt_Ipw_HwChannelConfigType * pHwChannelConfig,
  169. Gpt_HwChannelInfoType * pReturnHwChannelInfo
  170. );
  171. /*================================================================================================*/
  172. /**
  173. * @internal
  174. * @brief Gpt driver Autosar independent and platform dependent function for starting the timer channel.
  175. * @details It checks the type of the HW module and calls the appropriate
  176. * IP function for starting the timer channel.
  177. *
  178. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  179. * @param[in] uValue Timeout period (in ticks) after which a notification shall occur (if enabled).
  180. * @return void
  181. * @pre The driver needs to be initialized.Call Gpt_StartTimer before.
  182. */
  183. Std_ReturnType Gpt_Ipw_StartTimer(const Gpt_Ipw_HwChannelConfigType * pHwChannelConfig, Gpt_ValueType uValue);
  184. /*================================================================================================*/
  185. /**
  186. * @internal
  187. * @brief Gpt driver Autosar independent and platform dependent function for stopping the timer channel.
  188. * @details It checks the type of the HW module, and calls the appropriate
  189. * IP function for stopping the timer channel.
  190. *
  191. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  192. * @return void
  193. * @pre The driver needs to be initialized.Call StopTimer before.
  194. */
  195. void Gpt_Ipw_StopTimer(const Gpt_Ipw_HwChannelConfigType * pHwChannelConfig);
  196. /*================================================================================================*/
  197. /**
  198. * @internal
  199. * @brief Gpt driver Autosar independent and platform dependent function for enabling hardware timer interrupts.
  200. * @details It checks the type of the HW module and calls the appropriate
  201. * IP function for enabling hardware timer interrupts.
  202. *
  203. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  204. * @return void
  205. * @pre The driver needs to be initialized.
  206. */
  207. void Gpt_Ipw_EnableInterrupt(const Gpt_Ipw_HwChannelConfigType * pHwChannelConfig);
  208. /*================================================================================================*/
  209. #if (GPT_DEINIT_API == STD_ON)
  210. /**
  211. * @internal
  212. * @brief Gpt driver Autosar independent and IP dependent de-initialization function.
  213. * @details This function is called for each channel from the current configuration.
  214. * It determines the type of the HW channel and calls the
  215. * appropriate IP function in order to de-initializes the hardware timer.
  216. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  217. * @return void
  218. * @pre The driver needs to be initialized. On/Off by the configuration parameter: GPT_DEINIT_API
  219. */
  220. void Gpt_Ipw_DeInit(const Gpt_Ipw_HwChannelConfigType * pHwChannelConfig);
  221. #endif
  222. /*================================================================================================*/
  223. #if (GPT_ENABLE_DISABLE_NOTIFICATION_API == STD_ON)|| (GPT_WAKEUP_FUNCTIONALITY_API == STD_ON)
  224. /**
  225. * @internal
  226. * @brief Gpt driver Autosar independent and platform dependent function for disabling hardware timer interrupts.
  227. * @details It checks the type of the HW module and calls the appropriate
  228. * IP function for disabling hardware timer interrupts.
  229. *
  230. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  231. * @return void
  232. * @pre The driver needs to be initialized.On/Off by the configuration parameter: GPT_ENABLE_DISABLE_NOTIFICATION_API
  233. */
  234. void Gpt_Ipw_DisableInterrupt(const Gpt_Ipw_HwChannelConfigType * pHwChannelConfig);
  235. #endif
  236. /*================================================================================================*/
  237. #if (GPT_CHANGE_NEXT_TIMEOUT_VALUE == STD_ON)
  238. /**
  239. * @internal
  240. * @brief Gpt driver Autosar independent and IP dependent function to change compare register value.
  241. * @details This function:
  242. * - Write next timeout to local variable
  243. *
  244. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent
  245. * by platform
  246. * @param[in] value New Timeout period (in ticks) after which a notification
  247. * shall occur (if enabled).
  248. * @return void
  249. * @pre The driver needs to be initialized.On/Off by the configuration parameter: GPT_CHANGE_NEXT_TIMEOUT_VALUE
  250. *
  251. */
  252. Std_ReturnType Gpt_Ipw_ChangeNextTimeoutValue
  253. (
  254. const Gpt_Ipw_HwChannelConfigType * pHwChannelConfig,
  255. Gpt_ValueType value
  256. );
  257. #endif
  258. /*================================================================================================*/
  259. #if (GPT_SET_CLOCK_MODE == STD_ON)
  260. /**
  261. * @internal
  262. * @brief Gpt driver Autosar independent and IP dependent function to change FTM prescaler value.
  263. * @details Calls the FTM function to change the FTM prescaler.
  264. *
  265. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  266. * @param[in] clkMode Clock mode for configuration channel
  267. *
  268. * @return void
  269. * @pre The driver needs to be initialized.On/Off by the configuration parameter: GPT_SET_CLOCK_MODE
  270. */
  271. void Gpt_Ipw_SetClockModeInStance(const Gpt_Ipw_HwInstanceConfigType * pHwInstanceConfig,
  272. Gpt_ClockModeType clkMode);
  273. #endif
  274. /*================================================================================================*/
  275. #if(GPT_PREDEFTIMER_FUNCTIONALITY_API == STD_ON)
  276. /**
  277. * @internal
  278. * @brief Gpt driver Autosar start predeftimer hw.
  279. * @details This function to start channel, which using predeftimer feature in the used configuration.
  280. * It determines the type of the HW channel and calls the
  281. * appropriate IP function in order to initializes the hardware timer.
  282. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  283. * @return void
  284. * @pre The driver needs to be initialized. On/Off GPT_PREDEFTIMER_FUNCTIONALITY_API == STD_ON
  285. *
  286. */
  287. void Gpt_Ipw_StartPredefTimer
  288. (
  289. const Gpt_ConfigType * configPtr
  290. );
  291. /**
  292. * @internal
  293. * @brief Gpt driver Autosar get value of predeftimer hw.
  294. * @details This function to start channel, which using predeftimer feature in the used configuration.
  295. * It determines the type of the HW channel and calls the
  296. * appropriate IP function in order to initializes the hardware timer.
  297. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  298. * @param[in] TimeValuePtr The pointer using for save current value of hardware channel
  299. * @param[in] PredefTimer Gpt_PredefTimerType
  300. * @return void
  301. * @pre The driver needs to be initialized. On/Off GPT_PREDEFTIMER_FUNCTIONALITY_API == STD_ON
  302. *
  303. */
  304. void Gpt_Ipw_GetPredefTimerValue
  305. (
  306. const Gpt_HwPredefChannelConfigType * pHwChannelConfig,
  307. Gpt_PredefTimerType PredefTimer,
  308. uint32 * TimeValuePtr
  309. );
  310. /**
  311. * @internal
  312. * @brief Gpt driver Autosar stop predeftimer hw.
  313. * @details This function to start channel, which using predeftimer feature in the used configuration.
  314. * It determines the type of the HW channel and calls the
  315. * appropriate IP function in order to initializes the hardware timer.
  316. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  317. * @return void
  318. * @pre The driver needs to be initialized. GPT_PREDEFTIMER_FUNCTIONALITY_API == STD_ON
  319. */
  320. void Gpt_Ipw_StopPredefTimer
  321. (
  322. const Gpt_ConfigType * configPtr
  323. );
  324. #endif
  325. /*================================================================================================*/
  326. #if (GPT_CHAIN_MODE == STD_ON)
  327. /**
  328. * @internal
  329. * @brief The function Gpt_Ipw_EnableChainMode.
  330. * @details This function:
  331. * - Chain the timer.
  332. *
  333. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  334. * @return returnValue
  335. * @pre The driver needs to be initialized. CHAIN_MODE == STD_ON
  336. */
  337. Std_ReturnType Gpt_Ipw_EnableChainMode(const Gpt_Ipw_HwChannelConfigType * pHwChannelConfig);
  338. /**
  339. * @internal
  340. * @brief The function Gpt_Ipw_DisableChainMode.
  341. * @details This function:
  342. * - Chain the timer.
  343. *
  344. * @param[in] pHwChannelConfig Pointer to the channel configuration structure dependent by platform
  345. * @return returnValue
  346. * @pre The driver needs to be initialized. CHAIN_MODE == STD_ON
  347. */
  348. Std_ReturnType Gpt_Ipw_DisableChainMode(const Gpt_Ipw_HwChannelConfigType * pHwChannelConfig);
  349. #endif
  350. /*================================================================================================*/
  351. #define GPT_STOP_SEC_CODE
  352. #include "Gpt_MemMap.h"
  353. #ifdef __cplusplus
  354. }
  355. #endif
  356. /** @} */
  357. #endif /*GPT_IPW_H*/