Clock_Ip.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. /*==================================================================================================
  2. * Project : RTD AUTOSAR 4.4
  3. * Platform : CORTEXM
  4. * Peripheral :
  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. /**
  25. * @file Clock_Ip.h
  26. * @version 1.0.0
  27. *
  28. * @brief CLOCK IP driver header file.
  29. * @details CLOCK IP driver header file.
  30. *
  31. * @addtogroup CLOCK_DRIVER Clock Ip Driver
  32. * @{
  33. */
  34. #ifndef CLOCK_IP_H
  35. #define CLOCK_IP_H
  36. #include "Clock_Ip_Types.h"
  37. #include "Clock_Ip_Cfg.h"
  38. #if defined(__cplusplus)
  39. extern "C"{
  40. #endif
  41. /*==================================================================================================
  42. SOURCE FILE VERSION INFORMATION
  43. ==================================================================================================*/
  44. #define CLOCK_IP_VENDOR_ID 43
  45. #define CLOCK_IP_AR_RELEASE_MAJOR_VERSION 4
  46. #define CLOCK_IP_AR_RELEASE_MINOR_VERSION 4
  47. #define CLOCK_IP_AR_RELEASE_REVISION_VERSION 0
  48. #define CLOCK_IP_SW_MAJOR_VERSION 1
  49. #define CLOCK_IP_SW_MINOR_VERSION 0
  50. #define CLOCK_IP_SW_PATCH_VERSION 0
  51. /*==================================================================================================
  52. FILE VERSION CHECKS
  53. ==================================================================================================*/
  54. /* Check if Clock_Ip.h file and Clock_Ip_Types.h file have same versions */
  55. #if (CLOCK_IP_VENDOR_ID != CLOCK_IP_TYPES_VENDOR_ID)
  56. #error "Clock_Ip.h and Clock_Ip_Types.h have different vendor IDs"
  57. #endif
  58. /* Check if Clock_Ip.h file and Clock_Ip_Types.h file are of the same Autosar version */
  59. #if ((CLOCK_IP_AR_RELEASE_MAJOR_VERSION != CLOCK_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
  60. (CLOCK_IP_AR_RELEASE_MINOR_VERSION != CLOCK_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
  61. (CLOCK_IP_AR_RELEASE_REVISION_VERSION != CLOCK_IP_TYPES_AR_RELEASE_REVISION_VERSION))
  62. #error "AutoSar Version Numbers of Clock_Ip.h and Clock_Ip_Types.h are different"
  63. #endif
  64. /* Check if Clock_Ip.h file and Clock_Ip_Types.h file are of the same Software version */
  65. #if ((CLOCK_IP_SW_MAJOR_VERSION != CLOCK_IP_TYPES_SW_MAJOR_VERSION) || \
  66. (CLOCK_IP_SW_MINOR_VERSION != CLOCK_IP_TYPES_SW_MINOR_VERSION) || \
  67. (CLOCK_IP_SW_PATCH_VERSION != CLOCK_IP_TYPES_SW_PATCH_VERSION))
  68. #error "Software Version Numbers of Clock_Ip.h and Clock_Ip_Types.h are different"
  69. #endif
  70. /* Check if Clock_Ip.h file and Clock_Ip_Cfg.h file have same versions */
  71. #if (CLOCK_IP_VENDOR_ID != CLOCK_IP_CFG_VENDOR_ID)
  72. #error "Clock_Ip.h and Clock_Ip_Cfg.h have different vendor IDs"
  73. #endif
  74. /* Check if Clock_Ip.h file and Clock_Ip_Cfg.h file are of the same Autosar version */
  75. #if ((CLOCK_IP_AR_RELEASE_MAJOR_VERSION != CLOCK_IP_CFG_AR_RELEASE_MAJOR_VERSION) || \
  76. (CLOCK_IP_AR_RELEASE_MINOR_VERSION != CLOCK_IP_CFG_AR_RELEASE_MINOR_VERSION) || \
  77. (CLOCK_IP_AR_RELEASE_REVISION_VERSION != CLOCK_IP_CFG_AR_RELEASE_REVISION_VERSION))
  78. #error "AutoSar Version Numbers of Clock_Ip.h and Clock_Ip_Cfg.h are different"
  79. #endif
  80. /* Check if Clock_Ip.h file and Clock_Ip_Cfg.h file are of the same Software version */
  81. #if ((CLOCK_IP_SW_MAJOR_VERSION != CLOCK_IP_CFG_SW_MAJOR_VERSION) || \
  82. (CLOCK_IP_SW_MINOR_VERSION != CLOCK_IP_CFG_SW_MINOR_VERSION) || \
  83. (CLOCK_IP_SW_PATCH_VERSION != CLOCK_IP_CFG_SW_PATCH_VERSION))
  84. #error "Software Version Numbers of Clock_Ip.h and Clock_Ip_Cfg.h are different"
  85. #endif
  86. /*******************************************************************************
  87. * GLOBAL FUNCTION PROTOTYPES
  88. ******************************************************************************/
  89. /*******************************************************************************
  90. * API
  91. ******************************************************************************/
  92. /* Clock start section code */
  93. #define MCU_START_SEC_CODE
  94. #include "Mcu_MemMap.h"
  95. #if (defined(CLOCK_IP_GET_FREQUENCY_API) && (CLOCK_IP_GET_FREQUENCY_API == STD_ON))
  96. /*!
  97. * @brief Gets the clock frequency for a specific clock name.
  98. *
  99. * This function checks the current clock configurations and then calculates
  100. * the clock frequency for a specific clock name defined in Clock_Ip_NameType.
  101. * Clock modules must be properly configured before using this function.
  102. * See features.h for supported clock names for different chip families.
  103. * The returned value is in Hertz. If frequency is required for a peripheral and the
  104. * module is not clocked, then 0 Hz frequency is returned.
  105. *
  106. * @param[in] clockName Clock names defined in Clock_Ip_NameType
  107. * @return frequency Returned clock frequency value in Hertz
  108. */
  109. uint32 Clock_Ip_GetClockFrequency(Clock_Ip_NameType clockName);
  110. #endif
  111. /*!
  112. * @brief Set clock configuration according to pre-defined structure.
  113. *
  114. * This function sets system to target clock configuration; It sets the
  115. * clock modules registers for clock mode change.
  116. *
  117. * @param[in] config Pointer to configuration structure.
  118. *
  119. * @return void
  120. *
  121. * @note If external clock is used in the target mode, please make sure it is
  122. * enabled, for example, if the external oscillator is used, please setup correctly.
  123. */
  124. Clock_Ip_StatusType Clock_Ip_Init(Clock_Ip_ClockConfigType const * config);
  125. /*!
  126. * @brief Set the PLL and other MCU specific clock options.
  127. *
  128. * This function initializes the PLL and other MCU specific clock options.
  129. * The clock configuration parameters are provided via the configuration structure.
  130. *
  131. * This function shall start the PLL lock procedure (if PLL
  132. * shall be initialized) and shall return without waiting until the PLL is locked.
  133. *
  134. * @param[in] config Pointer to configuration structure.
  135. *
  136. * @return void
  137. */
  138. void Clock_Ip_InitClock(Clock_Ip_ClockConfigType const * config);
  139. /*!
  140. * @brief Returns the lock status of the PLL.
  141. *
  142. * This function returns status of the PLL: undefined, unlocked or locked.
  143. * This function returns undefined status if this function is called prior
  144. * to calling of the function Clock_Ip_InitClock
  145. *
  146. * @return Status. Pll lock status
  147. */
  148. Clock_Ip_PllStatusType Clock_Ip_GetPllStatus(void);
  149. #if (STD_OFF == CLOCK_IP_NO_PLL)
  150. /*!
  151. * @brief Activates the PLL in MCU clock distribution.
  152. *
  153. * This function activates the PLL clock to
  154. * the MCU clock distribution.
  155. *
  156. * This function removes the current clock source
  157. * (for example internal oscillator clock) from MCU clock distribution.
  158. *
  159. * Application layer calls this function after the status of the PLL has been detected as
  160. * locked by the function Clock_Ip_GetPllStatus.
  161. *
  162. * The function Clock_Ip_DistributePll shall return without affecting
  163. * the MCU hardware if the PLL clock has been automatically activated by the MCU
  164. * hardware.
  165. *
  166. * @return void
  167. */
  168. void Clock_Ip_DistributePll(void);
  169. #endif
  170. /*!
  171. * @brief Sends notifications regarding power mode transition
  172. *
  173. * This function sends notifications regarding power mode transition.
  174. * It is called by power driver each time power mode is changed.
  175. *
  176. *
  177. * @param[in] powerMode Power mode.
  178. * @param[in] powerMode Power mode notification.
  179. *
  180. * @return void
  181. */
  182. void Clock_Ip_PowerModeChangeNotification(power_modes_t powerMode,power_notification_t notification);
  183. /*!
  184. * @brief Install a clock notifications callback
  185. *
  186. * This function installs a callback for
  187. * reporting notifications from clock driver
  188. *
  189. *
  190. * @param[in] Clock_Ip_NotificationsCallbackType notifications callback
  191. *
  192. * @return void
  193. */
  194. void Clock_Ip_InstallNotificationsCallback(Clock_Ip_NotificationsCallbackType callback);
  195. /*!
  196. * @brief Clears status flags for a monitor clock.
  197. *
  198. * This function clears status flags for a monitor clock.
  199. *
  200. * @param[in] clockName Clock Name.
  201. *
  202. * @return void
  203. */
  204. void Clock_Ip_ClearClockMonitorStatus(Clock_Ip_NameType clockName);
  205. /*!
  206. * @brief Returns the clock monitor status.
  207. *
  208. * This function returns status of the clock monitor: undefined, lower, higher, in range.
  209. * This function returns undefined status if this function is called when corresponding
  210. * cmu is not enabled.
  211. *
  212. * @return Status. Cmu status
  213. */
  214. Clock_Ip_CmuStatusType Clock_Ip_GetClockMonitorStatus(Clock_Ip_NameType clockName);
  215. /*!
  216. * @brief Disables a clock monitor.
  217. *
  218. * This function disables a clock monitor.
  219. *
  220. * @param[in] clockName Clock Name.
  221. *
  222. * @return void
  223. */
  224. void Clock_Ip_DisableClockMonitor(Clock_Ip_NameType clockName);
  225. /*!
  226. * @brief Disables clock for a peripheral.
  227. *
  228. * This function disables clock for a peripheral.
  229. *
  230. * @param[in] clockName Clock Name.
  231. *
  232. * @return void
  233. */
  234. void Clock_Ip_DisableModuleClock(Clock_Ip_NameType clockName);
  235. /*!
  236. * @brief Enables clock for a peripheral.
  237. *
  238. * This function enables clock for a peripheral.
  239. *
  240. * @param[in] clockName Clock Name.
  241. *
  242. * @return void
  243. */
  244. void Clock_Ip_EnableModuleClock(Clock_Ip_NameType clockName);
  245. #if (defined(CLOCK_IP_ENABLE_USER_MODE_SUPPORT))
  246. #if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
  247. #if !(defined (CLOCK_IP_S32K1))
  248. void Clock_Ip_SetUserAccessAllowed(void);
  249. #endif
  250. #endif
  251. #endif
  252. /* Clock stop section code */
  253. #define MCU_STOP_SEC_CODE
  254. #include "Mcu_MemMap.h"
  255. #if defined(__cplusplus)
  256. }
  257. #endif /* __cplusplus*/
  258. /*! @}*/
  259. #endif /* CLOCK_IP_H */
  260. /*******************************************************************************
  261. * EOF
  262. ******************************************************************************/