clock_config.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("AutoChips Software") are
  4. * protected under relevant copyright laws. The information contained herein is
  5. * confidential and proprietary to AutoChips Inc. and/or its licensors. Without
  6. * the prior written permission of AutoChips inc. and/or its licensors, any
  7. * reproduction, modification, use or disclosure of AutoChips Software, and
  8. * information contained herein, in whole or in part, shall be strictly
  9. * prohibited.
  10. *
  11. * AutoChips Inc. (C) 2022. All rights reserved.
  12. *
  13. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  14. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("AUTOCHIPS SOFTWARE")
  15. * RECEIVED FROM AUTOCHIPS AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
  16. * ON AN "AS-IS" BASIS ONLY. AUTOCHIPS EXPRESSLY DISCLAIMS ANY AND ALL
  17. * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
  19. * NONINFRINGEMENT. NEITHER DOES AUTOCHIPS PROVIDE ANY WARRANTY WHATSOEVER WITH
  20. * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
  21. * INCORPORATED IN, OR SUPPLIED WITH THE AUTOCHIPS SOFTWARE, AND RECEIVER AGREES
  22. * TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
  23. * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
  24. * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN AUTOCHIPS
  25. * SOFTWARE. AUTOCHIPS SHALL ALSO NOT BE RESPONSIBLE FOR ANY AUTOCHIPS SOFTWARE
  26. * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  27. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND AUTOCHIPS'S
  28. * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE AUTOCHIPS SOFTWARE
  29. * RELEASED HEREUNDER WILL BE, AT AUTOCHIPS'S OPTION, TO REVISE OR REPLACE THE
  30. * AUTOCHIPS SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
  31. * CHARGE PAID BY RECEIVER TO AUTOCHIPS FOR SUCH AUTOCHIPS SOFTWARE AT ISSUE.
  32. */
  33. /******************************************************************************
  34. * @version: V2.0.1 AC7840x Demo
  35. ******************************************************************************/
  36. /*!
  37. * @file clock_config.c
  38. *
  39. * @brief This file provides clock config integration functions.
  40. *
  41. */
  42. /* =========================================== Includes =========================================== */
  43. #include "clock_config.h"
  44. /* ============================================ Define ============================================ */
  45. /* =========================================== Typedef ============================================ */
  46. /* ========================================== Variables =========================================== */
  47. /*! @brief peripheral clock configuration 0 */
  48. peripheral_clock_config_t peripheralClockConfig0[NUM_OF_PERIPHERAL_CLOCKS_0] = {
  49. {
  50. .clockName = I2C0_CLK,
  51. .clkSrc = SPLLDIV2_CLK,
  52. },
  53. {
  54. .clockName = TIMER_CLK,
  55. .clkSrc = SPLLDIV2_CLK,
  56. },
  57. {
  58. .clockName = SPI0_CLK,
  59. .clkSrc = SPLLDIV2_CLK,
  60. },
  61. {
  62. .clockName = SPI1_CLK,
  63. .clkSrc = SPLLDIV2_CLK,
  64. },
  65. {
  66. .clockName = SPI2_CLK,
  67. .clkSrc = SPLLDIV2_CLK,
  68. },
  69. {
  70. .clockName = ADC0_CLK,
  71. .clkSrc = SPLLDIV2_CLK,
  72. },
  73. {
  74. .clockName = ADC1_CLK,
  75. .clkSrc = SPLLDIV2_CLK,
  76. },
  77. {
  78. .clockName = CAN0_CLK,
  79. .clkSrc = CORE_CLK,
  80. .divider = DIVIDE_BY_TWO,
  81. },
  82. {
  83. .clockName = CAN1_CLK,
  84. .clkSrc = CORE_CLK,
  85. .divider = DIVIDE_BY_TWO,
  86. },
  87. {
  88. .clockName = CAN2_CLK,
  89. .clkSrc = CORE_CLK,
  90. .divider = DIVIDE_BY_TWO,
  91. },
  92. {
  93. .clockName = CAN3_CLK,
  94. .clkSrc = CORE_CLK,
  95. .divider = DIVIDE_BY_TWO,
  96. },
  97. {
  98. .clockName = PCT_CLK,
  99. .clkSrc = SPLLDIV2_CLK,
  100. },
  101. {
  102. .clockName = EIO_CLK,
  103. .clkSrc = SPLLDIV2_CLK,
  104. },
  105. {
  106. .clockName = UART0_CLK,
  107. .clkSrc = SPLLDIV2_CLK,
  108. },
  109. {
  110. .clockName = UART1_CLK,
  111. .clkSrc = SPLLDIV2_CLK,
  112. },
  113. {
  114. .clockName = UART2_CLK,
  115. .clkSrc = SPLLDIV2_CLK,
  116. },
  117. {
  118. .clockName = UART3_CLK,
  119. .clkSrc = SPLLDIV2_CLK,
  120. },
  121. {
  122. .clockName = PWM0_CLK,
  123. .clkSrc = SPLLDIV1_CLK,
  124. },
  125. {
  126. .clockName = PWM1_CLK,
  127. .clkSrc = SPLLDIV1_CLK,
  128. },
  129. {
  130. .clockName = PWM2_CLK,
  131. .clkSrc = SPLLDIV1_CLK,
  132. },
  133. {
  134. .clockName = PWM3_CLK,
  135. .clkSrc = SPLLDIV1_CLK,
  136. },
  137. {
  138. .clockName = PWM4_CLK,
  139. .clkSrc = SPLLDIV1_CLK,
  140. },
  141. {
  142. .clockName = PWM5_CLK,
  143. .clkSrc = SPLLDIV1_CLK,
  144. },
  145. };
  146. /*! @brief User Configuration structure clockMan1_InitConfig0 */
  147. clock_manager_user_config_t clockMan1_InitConfig0 = {
  148. /* CKGEN Clock Configuration. */
  149. .ckgenConfig =
  150. {
  151. /* Slow Internal Reference Clock Configuration. */
  152. .hsiConfig =
  153. {
  154. /* HSIDIV */
  155. .div1 = CKGEN_ASYNC_CLOCK_DIV_BY_1, /*!< HSIDIV1 */
  156. .div2 = CKGEN_ASYNC_CLOCK_DIV_BY_1, /*!< HSIDIV2 */
  157. .initialize = true, /*!< Initialize */
  158. .enableInLowPower = true, /*!< Enable in VLPS mode */
  159. },
  160. /* Fast Internal Reference Clock Configuration. */
  161. .vhsiConfig =
  162. {
  163. /* VHSIDIV */
  164. .div1 = CKGEN_ASYNC_CLOCK_DIV_BY_1, /*!< VHSIDIV1 */
  165. .div2 = CKGEN_ASYNC_CLOCK_DIV_BY_1, /*!< VHSIDIV2 */
  166. .initialize = true, /*!< Initialize */
  167. },
  168. /* System Oscillator Configuration. */
  169. .hseConfig =
  170. {
  171. .freq = 25000000U, /*!< Frequency */
  172. .monitor = CKGEN_XOSC_MONITOR_RESET,
  173. /* HSEREF */
  174. .extRef = CKGEN_HSE_REF_OSC, /*!< HSEREF */
  175. /* HSEDIV */
  176. .div1 = CKGEN_ASYNC_CLOCK_DIV_BY_1, /*!< HSEDIV1 */
  177. .div2 = CKGEN_ASYNC_CLOCK_DIV_BY_1, /*!< HSEDIV2 */
  178. .initialize = true, /*!< Initialize */
  179. },
  180. /* System Phase Locked Loop Configuration. */
  181. .spllConfig =
  182. {
  183. /* SPLLCFG */
  184. .prediv = (uint8_t)CKGEN_SPLL_CLOCK_PREDIV_BY_4, /*!< PREDIV */
  185. .fbkdiv = 100U, /*!< FBKDIV */
  186. .posdiv = 6U, /*!< POSDIV */
  187. .src = (uint8_t)CKGEN_SPLL_REF_HSE, /*!< SOURCE */
  188. .lockDetect = CKGEN_SPLL_LOCK_DETECT_RESET,
  189. /* SPLLDIV */
  190. .div1 = CKGEN_ASYNC_CLOCK_DIV_BY_2, /*!< SPLLDIV1 */
  191. .div2 = CKGEN_ASYNC_CLOCK_DIV_BY_2, /*!< SPLLDIV2 */
  192. .initialize = true, /*!< Initialize */
  193. },
  194. /* RTC Configuration.*/
  195. .rtcConfig =
  196. {
  197. .rtcClkInFreq = 0U, /*!< RTC_CLKIN */
  198. .initialize = true, /*!< Initialize */
  199. },
  200. /* Clock Mode Configuration.*/
  201. .clockModeConfig =
  202. {
  203. /* RCCR - Run Clock Control Register. */
  204. .rccrConfig =
  205. {
  206. .src = CKGEN_SYSTEM_CLOCK_SRC_SPLL, /*!< SCS */
  207. .divCore = CKGEN_SYSTEM_CLOCK_DIV_BY_1, /*!< DIVCORE */
  208. .divBus = CKGEN_SYSTEM_CLOCK_DIV_BY_2, /*!< DIVBUS */
  209. },
  210. /* VCCR - VLPR Clock Control Register */
  211. .vccrConfig =
  212. {
  213. .src = CKGEN_SYSTEM_CLOCK_SRC_HSI, /*!< SCS */
  214. .divCore = CKGEN_SYSTEM_CLOCK_DIV_BY_1, /*!< DIVCORE */
  215. .divBus = CKGEN_SYSTEM_CLOCK_DIV_BY_2, /*!< DIVBUS */
  216. },
  217. .initialize = true, /*!< Initialize */
  218. },
  219. },
  220. .simConfig =
  221. {
  222. /* Clock Out Configuration. */
  223. .clockOutConfig =
  224. {
  225. .initialize = true, /*!< Initialize */
  226. .enable = false,
  227. .source = CKGEN_CLKOUT_SEL_HSI_CLK, /*!< CLKOUTSEL */
  228. .divider = CKGEN_CLKOUT_DIV_BY_2, /*!< CLKOUTDIV */
  229. },
  230. /* Low Power Clock Configuration. */
  231. .lpClockConfig =
  232. {
  233. .initialize = true, /*!< Initialize */
  234. .sourceLsiClk = LSI_CLK_SEL_128K, /*!< LSICLKSEL */
  235. .sourceRtcClk = RTC_CLK_SEL_VHSIDIV1, /*!< RTCCLKSEL */
  236. },
  237. /* Tclk Clock Configuration. */
  238. .tclkConfig =
  239. {
  240. .initialize = true, /*!< Initialize */
  241. .tclkFreq[0U] = 0UL, /*!< TCLK0 */
  242. .tclkFreq[1U] = 0UL, /*!< TCLK1 */
  243. .tclkFreq[2U] = 0UL, /*!< TCLK2 */
  244. },
  245. /* Debug Trace Clock Configuration. */
  246. .traceClockConfig =
  247. {
  248. .initialize = true, /*!< Initialize */
  249. .divider = 0U, /*!< TRACEDIV */
  250. },
  251. },
  252. /* PCC - Peripheral Clock Configuration. */
  253. .pccConfig =
  254. {
  255. .peripheralClocks = peripheralClockConfig0, /*!< Peripheral clock control configurations */
  256. .count = NUM_OF_PERIPHERAL_CLOCKS_0, /*!< Number of the peripheral clock control configurations */
  257. },
  258. };
  259. /*! @brief Array of pointers to User configuration structures */
  260. clock_manager_user_config_t const * g_clockManConfigsArr[] = {
  261. &clockMan1_InitConfig0
  262. };
  263. /*! @brief Array of pointers to User defined Callbacks configuration structures */
  264. clock_manager_callback_user_config_t * g_clockManCallbacksArr[] = {(void*)0};
  265. /* ==================================== Functions declaration ===================================== */
  266. /* ====================================== Functions define ======================================== */
  267. /* ============================================= EOF ============================================== */