Lptmr_Gpt_Ip.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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 LPTMR_GPT_IP_H
  25. #define LPTMR_GPT_IP_H
  26. /**
  27. * @file Lptmr_Gpt_Ip.h
  28. *
  29. * @addtogroup Lptmr_Gpt_Ip Lptmr IPL
  30. *
  31. * @{
  32. */
  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 "Lptmr_Gpt_Ip_Types.h"
  43. #include "Lptmr_Gpt_Ip_Cfg.h"
  44. #include "OsIf.h"
  45. #include "Mcal.h"
  46. #include "SchM_Gpt.h"
  47. #if LPTMR_GPT_IP_DEV_ERROR_DETECT == STD_ON
  48. #include "Devassert.h"
  49. #endif
  50. #if (LPTMR_GPT_IP_ENABLE_USER_MODE_SUPPORT == STD_ON)
  51. #include "Reg_eSys.h"
  52. #endif
  53. /*==================================================================================================
  54. * SOURCE FILE VERSION INFORMATION
  55. ==================================================================================================*/
  56. #define LPTMR_GPT_IP_VENDOR_ID 43
  57. #define LPTMR_GPT_IP_AR_RELEASE_MAJOR_VERSION 4
  58. #define LPTMR_GPT_IP_AR_RELEASE_MINOR_VERSION 4
  59. #define LPTMR_GPT_IP_AR_RELEASE_REVISION_VERSION 0
  60. #define LPTMR_GPT_IP_SW_MAJOR_VERSION 1
  61. #define LPTMR_GPT_IP_SW_MINOR_VERSION 0
  62. #define LPTMR_GPT_IP_SW_PATCH_VERSION 0
  63. /*==================================================================================================
  64. * FILE VERSION CHECKS
  65. ==================================================================================================*/
  66. #if (LPTMR_GPT_IP_VENDOR_ID != LPTMR_GPT_IP_TYPES_VENDOR_ID)
  67. #error "Lptmr_Gpt_Ip.h and Lptmr_Gpt_Ip_Types.h have different vendor ids"
  68. #endif
  69. /* Check if header file and Gpt header file are of the same Autosar version */
  70. #if ((LPTMR_GPT_IP_AR_RELEASE_MAJOR_VERSION != LPTMR_GPT_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
  71. (LPTMR_GPT_IP_AR_RELEASE_MINOR_VERSION != LPTMR_GPT_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
  72. (LPTMR_GPT_IP_AR_RELEASE_REVISION_VERSION != LPTMR_GPT_IP_TYPES_AR_RELEASE_REVISION_VERSION) \
  73. )
  74. #error "AutoSar Version Numbers of Lptmr_Gpt_Ip.h and Lptmr_Gpt_Ip_Types.h are different"
  75. #endif
  76. /* Check if source file and GPT header file are of the same Software version */
  77. #if ((LPTMR_GPT_IP_SW_MAJOR_VERSION != LPTMR_GPT_IP_TYPES_SW_MAJOR_VERSION) || \
  78. (LPTMR_GPT_IP_SW_MINOR_VERSION != LPTMR_GPT_IP_TYPES_SW_MINOR_VERSION) || \
  79. (LPTMR_GPT_IP_SW_PATCH_VERSION != LPTMR_GPT_IP_TYPES_SW_PATCH_VERSION) \
  80. )
  81. #error "Software Version Numbers of Lptmr_Gpt_Ip.h and Lptmr_Gpt_Ip_Types.h are different"
  82. #endif
  83. #if (LPTMR_GPT_IP_VENDOR_ID != LPTMR_GPT_IP_VENDOR_ID_CFG)
  84. #error "Lptmr_Gpt_Ip.h and Lptmr_Gpt_Ip_Cfg.h have different vendor ids"
  85. #endif
  86. /* Check if LPTMR_GPT_IP header file and LPTMR_GPT_IP_Cfg header file are of the same Autosar version */
  87. #if ((LPTMR_GPT_IP_AR_RELEASE_MAJOR_VERSION != LPTMR_GPT_IP_AR_RELEASE_MAJOR_VERSION_CFG) || \
  88. (LPTMR_GPT_IP_AR_RELEASE_MINOR_VERSION != LPTMR_GPT_IP_AR_RELEASE_MINOR_VERSION_CFG) || \
  89. (LPTMR_GPT_IP_AR_RELEASE_REVISION_VERSION != LPTMR_GPT_IP_AR_RELEASE_REVISION_VERSION_CFG) \
  90. )
  91. #error "AutoSar Version Numbers of Lptmr_Gpt_Ip.h and Lptmr_Gpt_Ip_Cfg.h are different"
  92. #endif
  93. /* Check if LPTMR_GPT_IP file and LPTMR_GPT_IP_Cfg header file are of the same Software version */
  94. #if ((LPTMR_GPT_IP_SW_MAJOR_VERSION != LPTMR_GPT_IP_SW_MAJOR_VERSION_CFG) || \
  95. (LPTMR_GPT_IP_SW_MINOR_VERSION != LPTMR_GPT_IP_SW_MINOR_VERSION_CFG) || \
  96. (LPTMR_GPT_IP_SW_PATCH_VERSION != LPTMR_GPT_IP_SW_PATCH_VERSION_CFG) \
  97. )
  98. #error "Software Version Numbers of Lptmr_Gpt_Ip.h and Lptmr_Gpt_Ip_Cfg.h are different"
  99. #endif
  100. #if (LPTMR_GPT_IP_ENABLE_USER_MODE_SUPPORT == STD_ON)
  101. /* Check if header file and StandardTypes.h file are of the same Autosar version */
  102. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  103. #if ((LPTMR_GPT_IP_AR_RELEASE_MAJOR_VERSION != REG_ESYS_AR_RELEASE_MAJOR_VERSION) || \
  104. (LPTMR_GPT_IP_AR_RELEASE_MINOR_VERSION != REG_ESYS_AR_RELEASE_MINOR_VERSION))
  105. #error "AutoSar Version Numbers of Lptmr_Gpt_Ip.h and Reg_eSys.h are different"
  106. #endif
  107. #endif
  108. #endif
  109. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  110. #if ((LPTMR_GPT_IP_AR_RELEASE_MAJOR_VERSION != SCHM_GPT_AR_RELEASE_MAJOR_VERSION) || \
  111. (LPTMR_GPT_IP_AR_RELEASE_MINOR_VERSION != SCHM_GPT_AR_RELEASE_MINOR_VERSION))
  112. #error "AutoSar Version Numbers of Lptmr_Gpt_Ip.h and SchM_Gpt.h are different"
  113. #endif
  114. /* Check if this header file and OsIf.h file are of the same Autosar version */
  115. #if ((LPTMR_GPT_IP_AR_RELEASE_MAJOR_VERSION != OSIF_AR_RELEASE_MAJOR_VERSION) || \
  116. (LPTMR_GPT_IP_AR_RELEASE_MINOR_VERSION != OSIF_AR_RELEASE_MINOR_VERSION))
  117. #error "AutoSar Version Numbers of Lptmr_Gpt_Ip.h and OsIf.h are different"
  118. #endif
  119. #endif
  120. #if LPTMR_GPT_IP_DEV_ERROR_DETECT == STD_ON
  121. #ifndef DISABLE_MCAL_INTERMODULE_ASR_CHECK
  122. #if ((LPTMR_GPT_IP_AR_RELEASE_MAJOR_VERSION != DEVASSERT_AR_RELEASE_MAJOR_VERSION) || \
  123. (LPTMR_GPT_IP_AR_RELEASE_MINOR_VERSION != DEVASSERT_AR_RELEASE_MINOR_VERSION))
  124. #error "AutoSar Version Numbers of Lptmr_Gpt_Ip.h and Devassert.h are different"
  125. #endif
  126. #endif
  127. #endif
  128. /*==================================================================================================
  129. * CONSTANTS
  130. ==================================================================================================*/
  131. /*==================================================================================================
  132. * DEFINES AND MACROS
  133. ==================================================================================================*/
  134. /*==================================================================================================
  135. * ENUMS
  136. ==================================================================================================*/
  137. /*==================================================================================================
  138. * STRUCTURES AND OTHER TYPEDEFS
  139. ==================================================================================================*/
  140. /*==================================================================================================
  141. * GLOBAL VARIABLE DECLARATIONS
  142. ==================================================================================================*/
  143. #if (LPTMR_GPT_IP_USED == STD_ON)
  144. /**
  145. * @brief Define Mode
  146. * @details Mode type (TMS)
  147. */
  148. #define LPTMR_GPT_IP_TM_MODE ((uint32)(0x00)) /**< @brief Time Counter mode */
  149. extern LPTMR_Type * const lptmrGptBase[LPTMR_INSTANCE_COUNT];
  150. uint32 Lptmr_Gpt_Ip_GetCompareValue(uint8 instance);
  151. boolean Lptmr_Gpt_Ip_GetCmpFlagState(uint8 instance);
  152. uint32 Lptmr_Gpt_Ip_GetCntValue(uint8 instance);
  153. void Lptmr_Gpt_Ip_WriteCounterValue(uint8 instance, uint16 value);
  154. /*==================================================================================================
  155. * FUNCTION PROTOTYPES
  156. ==================================================================================================*/
  157. #define GPT_START_SEC_CODE
  158. #include "Gpt_MemMap.h"
  159. /*================================================================================================*/
  160. /**
  161. * @brief LPTMR Driver initialization function
  162. * @details This function is called separately for each LPTMR hw channel corresponding to the configured
  163. *
  164. * - enables the LPTMR module
  165. * - configures the freeze mode (enabled or disabled)
  166. * - disables the IRQ corresponding to the LPTMR channel
  167. * - clears the (pending) interrupt flag corresponding to Lptmr channel
  168. * - disables the LPTMR timer channel
  169. * - clears the Load Value register corresponding to the Lptmr channel.
  170. *
  171. * @param[in] instance hw instance
  172. * @param[in] *config pointer to configuration
  173. * @return void
  174. * @pre The data structure including the configuration set required for initializing the GPT driver
  175. */
  176. void Lptmr_Gpt_Ip_Init(uint8 instance, const Lptmr_Gpt_Ip_ConfigType *config);
  177. /*================================================================================================*/
  178. /**
  179. * @brief de-initialization function for Lptmr module.
  180. * @details This function is called separately for each LPTMR hw channel corresponding to the configured
  181. * timer channels, and:
  182. * - disables the LPTMR channel
  183. * - disables the freeze mode
  184. * - disables IRQ corresponding to Lptmr channel
  185. * - clears the (pending) interrupt flag corresponding to Lptmr channel
  186. *
  187. *
  188. *
  189. * @param[in] instance LPTMR hw instance
  190. * @return void
  191. * @pre The data structure including the configuration set required for initializing the GPT driver
  192. *
  193. */
  194. void Lptmr_Gpt_Ip_DeInit(uint8 instance);
  195. /*================================================================================================*/
  196. /**
  197. * @brief Function for starting the Lptmr timer channel.
  198. * @details This function:
  199. * - clears the (pending) interrupt flag corresponding to Lptmr channel
  200. * - disables the LPTMR timer channel
  201. * - sets the timeout value into the LPTMR timer channel register
  202. * - enables the LPTMR timer channel
  203. * - enables the IRQ corresponding to the LPTMR timer channel,if channel configured in One Shot mode.
  204. *
  205. *
  206. *
  207. * @param[in] value channel timeout value
  208. * @return void
  209. * @pre The data structure including the configuration set required for initializing the GPT driver
  210. *
  211. */
  212. void Lptmr_Gpt_Ip_StartTimer(uint8 instance, uint16 value);
  213. /*================================================================================================*/
  214. /**
  215. * @brief Function for stopping the Lptmr timer channel.
  216. * @details This function disables the LPTMR channel
  217. *
  218. *
  219. * @param[in] instance LPTMR hw instance
  220. * @return void
  221. * @pre The driver needs to be initialized.
  222. */
  223. void Lptmr_Gpt_Ip_StopTimer(uint8 instance);
  224. /*================================================================================================*/
  225. /**
  226. * @brief Driver function for Enable Interrupt for LPTMR channel
  227. * @details This function:
  228. * - Enable Interrupt for LPTMR channel
  229. *
  230. * @param[in] instance LPTMR hw instance
  231. * @return void
  232. * @pre The driver needs to be initialized.
  233. *
  234. */
  235. void Lptmr_Gpt_Ip_EnableInterrupt(uint8 instance);
  236. /*================================================================================================*/
  237. /**
  238. * @brief Lptmr_Gpt_Ip_SetCompareValue
  239. * @details This function:
  240. * - Set the compare value in counter tick units, for a LPTMR instance.
  241. * Possible return values:
  242. * - STATUS_SUCCESS: completed successfully
  243. * - STATUS_ERROR: cannot reconfigure compare value (TCF not set)
  244. * - STATUS_TIMEOUT: compare value is smaller than current counter value
  245. *
  246. * @param[in] instance LPTMR hw instance
  247. * @param[in] compareValue Compare value in counter tick units
  248. * @return void
  249. * @pre The driver needs to be initialized.
  250. *
  251. *
  252. *
  253. */
  254. Lptmr_Gpt_Ip_StatusType Lptmr_Gpt_Ip_SetCompareValue(uint8 instance,
  255. uint16 compareValue);
  256. /*================================================================================================*/
  257. /**
  258. * @brief Gpt driver function for Disable Interrupt for LPTMR channel
  259. * @details This function:
  260. * - Disable Interrupt for LPTMR channel
  261. * @param[in] instance LPTMR hw instance
  262. * @return void
  263. * @pre The driver needs to be initialized.
  264. *
  265. */
  266. void Lptmr_Gpt_Ip_DisableInterrupt(uint8 instance);
  267. /*================================================================================================*/
  268. #if (LPTMR_GPT_IP_SET_CLOCK_MODE == STD_ON)
  269. /**
  270. * @brief The function changes the LPtimer prescaler value.
  271. * @details This function sets the LPtimer prescaler based on the input mode.
  272. *
  273. * @param[in] instance LPtimer hardware instance
  274. * @param[in] clockMode LPTMR_GPT_IP_CLOCKMODE_NORMAL or LPTMR_GPT_IP_CLOCKMODE_ALTERNATE
  275. *
  276. * @return void
  277. * @pre The driver needs to be initialized.On/Off by the configuration parameter: GPT_DUAL_CLOCK_MODE
  278. * @implements Lptmr_Gpt_Ip_SetClockMode_Activity
  279. */
  280. void Lptmr_Gpt_Ip_SetClockMode(uint8 instance, Lptmr_Gpt_Ip_ClockModeType clockMode);
  281. /*================================================================================================*/
  282. #endif
  283. #define GPT_STOP_SEC_CODE
  284. #include "Gpt_MemMap.h"
  285. #ifdef __cplusplus
  286. }
  287. #endif /* LPTMR_GPT_IP_USED == STD_ON */
  288. /** @} */
  289. #endif /* LPTMR_GPT_IP_H*/
  290. #endif /* LPTMR_GPT_IP_H*/