aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/devices/LPC822/drivers/fsl_clock.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/LPC822/drivers/fsl_clock.h')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/devices/LPC822/drivers/fsl_clock.h572
1 files changed, 572 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/LPC822/drivers/fsl_clock.h b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC822/drivers/fsl_clock.h
new file mode 100644
index 000000000..c92d6ba12
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC822/drivers/fsl_clock.h
@@ -0,0 +1,572 @@
1/*
2 * Copyright 2017-2019 NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#ifndef _FSL_CLOCK_H_
9#define _FSL_CLOCK_H_
10
11#include "fsl_common.h"
12
13/*! @addtogroup clock */
14/*! @{ */
15
16/*! @file */
17
18/*******************************************************************************
19 * Definitions
20 *****************************************************************************/
21
22/*! @name Driver version */
23/*@{*/
24/*! @brief CLOCK driver version 2.4.2. */
25#define FSL_CLOCK_DRIVER_VERSION (MAKE_VERSION(2, 4, 2))
26/*@}*/
27
28/* Definition for delay API in clock driver, users can redefine it to the real application. */
29#ifndef SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY
30#define SDK_DEVICE_MAXIMUM_CPU_CLOCK_FREQUENCY (30000000UL)
31#endif
32
33/*! @brief watchdog oscilltor clock frequency.
34 *
35 * This variable is used to store the watchdog oscillator frequency which is
36 * set by CLOCK_InitWdtOsc, and it is returned by CLOCK_GetWdtOscFreq.
37 */
38extern volatile uint32_t g_Wdt_Osc_Freq;
39
40/*! @brief external clock frequency.
41 *
42 * This variable is used to store the external clock frequency which is include
43 * external oscillator clock and external clk in clock frequency value, it is
44 * set by CLOCK_InitExtClkin when CLK IN is used as external clock or by CLOCK_InitSysOsc
45 * when external oscillator is used as external clock ,and it is returned by
46 * CLOCK_GetExtClkFreq.
47 */
48extern volatile uint32_t g_Ext_Clk_Freq;
49
50/*! @brief Clock ip name array for ADC. */
51#define ADC_CLOCKS \
52 { \
53 kCLOCK_Adc, \
54 }
55/*! @brief Clock ip name array for ACMP. */
56#define ACMP_CLOCKS \
57 { \
58 kCLOCK_Acmp, \
59 }
60/*! @brief Clock ip name array for SWM. */
61#define SWM_CLOCKS \
62 { \
63 kCLOCK_Swm, \
64 }
65/*! @brief Clock ip name array for ROM. */
66#define ROM_CLOCKS \
67 { \
68 kCLOCK_Rom, \
69 }
70/*! @brief Clock ip name array for SRAM. */
71#define SRAM_CLOCKS \
72 { \
73 kCLOCK_Ram0_1, \
74 }
75/*! @brief Clock ip name array for IOCON. */
76#define IOCON_CLOCKS \
77 { \
78 kCLOCK_Iocon, \
79 }
80/*! @brief Clock ip name array for GPIO. */
81#define GPIO_CLOCKS \
82 { \
83 kCLOCK_Gpio0, \
84 }
85/*! @brief Clock ip name array for GPIO_INT. */
86#define GPIO_INT_CLOCKS \
87 { \
88 kCLOCK_GpioInt, \
89 }
90/*! @brief Clock ip name array for DMA. */
91#define DMA_CLOCKS \
92 { \
93 kCLOCK_Dma, \
94 }
95/*! @brief Clock ip name array for CRC. */
96#define CRC_CLOCKS \
97 { \
98 kCLOCK_Crc, \
99 }
100/*! @brief Clock ip name array for WWDT. */
101#define WWDT_CLOCKS \
102 { \
103 kCLOCK_Wwdt, \
104 }
105/*! @brief Clock ip name array for SCT0. */
106#define SCT_CLOCKS \
107 { \
108 kCLOCK_Sct, \
109 }
110/*! @brief Clock ip name array for I2C. */
111#define I2C_CLOCKS \
112 { \
113 kCLOCK_I2c0, kCLOCK_I2c1, kCLOCK_I2c2, kCLOCK_I2c3, \
114 }
115/*! @brief Clock ip name array for I2C. */
116#define USART_CLOCKS \
117 { \
118 kCLOCK_Uart0, kCLOCK_Uart1, kCLOCK_Uart2, \
119 }
120/*! @brief Clock ip name array for SPI. */
121#define SPI_CLOCKS \
122 { \
123 kCLOCK_Spi0, kCLOCK_Spi1, \
124 }
125/*! @brief Clock ip name array for MTB. */
126#define MTB_CLOCKS \
127 { \
128 kCLOCK_Mtb, \
129 }
130/*! @brief Clock ip name array for MRT. */
131#define MRT_CLOCKS \
132 { \
133 kCLOCK_Mrt, \
134 }
135/*! @brief Clock ip name array for WKT. */
136#define WKT_CLOCKS \
137 { \
138 kCLOCK_Wkt, \
139 }
140
141/*! @brief Internal used Clock definition only. */
142#define CLK_GATE_DEFINE(reg, bit) ((((reg)&0xFFU) << 8U) | ((bit)&0xFFU))
143#define CLK_GATE_GET_REG(x) (((x) >> 8U) & 0xFFU)
144#define CLK_GATE_GET_BITS_SHIFT(x) ((uint32_t)(x)&0xFFU)
145/* clock mux register definition */
146#define CLK_MUX_DEFINE(reg, mux) (((offsetof(SYSCON_Type, reg) & 0xFFU) << 8U) | ((mux)&0xFFU))
147#define CLK_MUX_GET_REG(x) ((volatile uint32_t *)(((uint32_t)(SYSCON)) + (((uint32_t)(x) >> 8U) & 0xFFU)))
148#define CLK_MUX_GET_MUX(x) ((uint32_t)(x)&0xFFU)
149#define CLK_MAIN_CLK_MUX_DEFINE(preMux, mux) ((preMux) << 8U | (mux))
150#define CLK_MAIN_CLK_MUX_GET_PRE_MUX(x) ((((uint32_t)(x)) >> 8U) & 0xFFU)
151#define CLK_MAIN_CLK_MUX_GET_MUX(x) (((uint32_t)(x)) & 0xFFU)
152/* clock divider register definition */
153#define CLK_DIV_DEFINE(reg) (((uint32_t)offsetof(SYSCON_Type, reg)) & 0xFFFU)
154#define CLK_DIV_GET_REG(x) *((volatile uint32_t *)(((uint32_t)(SYSCON)) + ((uint32_t)(x)&0xFFFU)))
155/* watch dog oscillator definition */
156#define CLK_WDT_OSC_DEFINE(freq, regValue) (((freq)&0xFFFFFFU) | (((regValue)&0xFFU) << 24U))
157#define CLK_WDT_OSC_GET_FREQ(x) (((uint32_t)(x)) & 0xFFFFFFU)
158#define CLK_WDT_OSC_GET_REG(x) (((uint32_t)(x) >> 24U) & 0xFFU)
159/* register offset */
160#define SYS_AHB_CLK_CTRL (0U)
161/*! @brief Clock gate name used for CLOCK_EnableClock/CLOCK_DisableClock. */
162typedef enum _clock_ip_name
163{
164 kCLOCK_Sys = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 0U),
165 kCLOCK_Rom = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 1U),
166 kCLOCK_Ram0_1 = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 2U),
167 kCLOCK_Flashreg = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 3U),
168 kCLOCK_Flash = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 4U),
169 kCLOCK_I2c0 = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 5U),
170 kCLOCK_Gpio0 = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 6U),
171 kCLOCK_Swm = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 7U),
172 kCLOCK_Sct = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 8U),
173 kCLOCK_Wkt = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 9U),
174 kCLOCK_Mrt = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 10U),
175 kCLOCK_Spi0 = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 11U),
176 kCLOCK_Spi1 = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 12U),
177 kCLOCK_Crc = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 13U),
178 kCLOCK_Uart0 = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 14U),
179 kCLOCK_Uart1 = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 15U),
180 kCLOCK_Uart2 = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 16U),
181 kCLOCK_Wwdt = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 17U),
182 kCLOCK_Iocon = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 18U),
183 kCLOCK_Acmp = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 19U),
184 kCLOCK_I2c1 = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 21U),
185 kCLOCK_I2c2 = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 22U),
186 kCLOCK_I2c3 = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 23U),
187 kCLOCK_Adc = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 24U),
188 kCLOCK_Mtb = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 26U),
189 kCLOCK_Dma = CLK_GATE_DEFINE(SYS_AHB_CLK_CTRL, 29U),
190} clock_ip_name_t;
191
192/*! @brief Clock name used to get clock frequency. */
193typedef enum _clock_name
194{
195 kCLOCK_CoreSysClk, /*!< Cpu/AHB/AHB matrix/Memories,etc */
196 kCLOCK_MainClk, /*!< Main clock */
197 kCLOCK_SysOsc, /*!< Crystal Oscillator */
198 kCLOCK_Irc, /*!< IRC12M */
199 kCLOCK_ExtClk, /*!< External Clock */
200 kCLOCK_PllOut, /*!< PLL Output */
201 kCLOCK_Pllin, /*!< PLL Input */
202 kCLOCK_WdtOsc, /*!< Watchdog Oscillator */
203} clock_name_t;
204
205/*! @brief Clock Mux Switches
206 *CLK_MUX_DEFINE(reg, mux)
207 *reg is used to define the mux register
208 *mux is used to define the mux value
209 *
210 */
211typedef enum _clock_select
212{
213
214 kSYSPLL_From_Irc = CLK_MUX_DEFINE(SYSPLLCLKSEL, 0U),
215 kSYSPLL_From_SysOsc = CLK_MUX_DEFINE(SYSPLLCLKSEL, 1U),
216 kSYSPLL_From_ExtClk = CLK_MUX_DEFINE(SYSPLLCLKSEL, 3U),
217
218 kMAINCLK_From_Irc = CLK_MUX_DEFINE(MAINCLKSEL, 0U),
219 kMAINCLK_From_SysPllIn = CLK_MUX_DEFINE(MAINCLKSEL, 1U),
220 kMAINCLK_From_WdtOsc = CLK_MUX_DEFINE(MAINCLKSEL, 2U),
221 kMAINCLK_From_SysPll = CLK_MUX_DEFINE(MAINCLKSEL, 3U),
222
223 kCLKOUT_From_Irc = CLK_MUX_DEFINE(CLKOUTSEL, 0U),
224 kCLKOUT_From_SysOsc = CLK_MUX_DEFINE(CLKOUTSEL, 1U),
225 kCLKOUT_From_WdtOsc = CLK_MUX_DEFINE(CLKOUTSEL, 2U),
226 kCLKOUT_From_MainClk = CLK_MUX_DEFINE(CLKOUTSEL, 3U)
227} clock_select_t;
228
229/*! @brief Clock divider
230 */
231typedef enum _clock_divider
232{
233
234 kCLOCK_DivUsartClk = CLK_DIV_DEFINE(UARTCLKDIV),
235 kCLOCK_DivClkOut = CLK_DIV_DEFINE(CLKOUTDIV),
236 kCLOCK_DivUartFrg = CLK_DIV_DEFINE(UARTFRGDIV),
237
238 kCLOCK_IOCONCLKDiv6 = CLK_DIV_DEFINE(IOCONCLKDIV6),
239 kCLOCK_IOCONCLKDiv5 = CLK_DIV_DEFINE(IOCONCLKDIV5),
240 kCLOCK_IOCONCLKDiv4 = CLK_DIV_DEFINE(IOCONCLKDIV4),
241 kCLOCK_IOCONCLKDiv3 = CLK_DIV_DEFINE(IOCONCLKDIV3),
242 kCLOCK_IOCONCLKDiv2 = CLK_DIV_DEFINE(IOCONCLKDIV2),
243 kCLOCK_IOCONCLKDiv1 = CLK_DIV_DEFINE(IOCONCLKDIV1),
244 kCLOCK_IOCONCLKDiv0 = CLK_DIV_DEFINE(IOCONCLKDIV0),
245
246} clock_divider_t;
247
248/*! @brief watch dog analog output frequency */
249typedef enum _clock_wdt_analog_freq
250{
251 kCLOCK_WdtAnaFreq0HZ = CLK_WDT_OSC_DEFINE(0U, 0U),
252 kCLOCK_WdtAnaFreq600KHZ = CLK_WDT_OSC_DEFINE(600000U, 1U),
253 kCLOCK_WdtAnaFreq1050KHZ = CLK_WDT_OSC_DEFINE(1050000U, 2u),
254 kCLOCK_WdtAnaFreq1400KHZ = CLK_WDT_OSC_DEFINE(1400000U, 3U),
255 kCLOCK_WdtAnaFreq1750KHZ = CLK_WDT_OSC_DEFINE(1750000U, 4U),
256 kCLOCK_WdtAnaFreq2100KHZ = CLK_WDT_OSC_DEFINE(2100000U, 5U),
257 kCLOCK_WdtAnaFreq2400KHZ = CLK_WDT_OSC_DEFINE(2400000U, 6U),
258 kCLOCK_WdtAnaFreq2700KHZ = CLK_WDT_OSC_DEFINE(2700000U, 7U),
259 kCLOCK_WdtAnaFreq3000KHZ = CLK_WDT_OSC_DEFINE(3000000U, 8U),
260 kCLOCK_WdtAnaFreq3250KHZ = CLK_WDT_OSC_DEFINE(3250000U, 9U),
261 kCLOCK_WdtAnaFreq3500KHZ = CLK_WDT_OSC_DEFINE(3500000U, 10U),
262 kCLOCK_WdtAnaFreq3750KHZ = CLK_WDT_OSC_DEFINE(3750000U, 11U),
263 kCLOCK_WdtAnaFreq4000KHZ = CLK_WDT_OSC_DEFINE(4000000U, 12U),
264 kCLOCK_WdtAnaFreq4200KHZ = CLK_WDT_OSC_DEFINE(4200000U, 13U),
265 kCLOCK_WdtAnaFreq4400KHZ = CLK_WDT_OSC_DEFINE(4400000U, 14U),
266 kCLOCK_WdtAnaFreq4600KHZ = CLK_WDT_OSC_DEFINE(4600000U, 15U),
267} clock_wdt_analog_freq_t;
268
269/*! @brief PLL clock definition.*/
270typedef enum _clock_sys_pll_src
271{
272 kCLOCK_SysPllSrcIrc = 0U, /*!< system pll source from FRO */
273 kCLOCK_SysPllSrcSysosc = 1U, /*!< system pll source from system osc */
274 kCLOCK_SysPllSrcExtClk = 3U, /*!< system pll source from ext clkin */
275} clock_sys_pll_src;
276
277/*!< Main clock source definition */
278typedef enum _clock_main_clk_src
279{
280 kCLOCK_MainClkSrcIrc = CLK_MAIN_CLK_MUX_DEFINE(0U, 0U), /*!< main clock source from FRO */
281 kCLOCK_MainClkSrcSysPllin = CLK_MAIN_CLK_MUX_DEFINE(1U, 0U), /*!< main clock source from pll input */
282 kCLOCK_MainClkSrcWdtOsc = CLK_MAIN_CLK_MUX_DEFINE(2U, 0U), /*!< main clock source from watchdog oscillator */
283 kCLOCK_MainClkSrcSysPll = CLK_MAIN_CLK_MUX_DEFINE(3U, 0U), /*!< main clock source from system pll */
284} clock_main_clk_src_t;
285
286/*! @brief PLL configuration structure */
287typedef struct _clock_sys_pll
288{
289 uint32_t targetFreq; /*!< System pll fclk output frequency, the output frequency should be lower than 100MHZ*/
290 clock_sys_pll_src src; /*!< System pll clock source */
291} clock_sys_pll_t;
292
293/*******************************************************************************
294 * API
295 ******************************************************************************/
296
297#if defined(__cplusplus)
298extern "C" {
299#endif /* __cplusplus */
300
301/*!
302 * @name Clock gate, mux, and divider.
303 * @{
304 */
305
306/*
307 *! @brief enable ip clock.
308 *
309 * @param clk clock ip definition.
310 */
311static inline void CLOCK_EnableClock(clock_ip_name_t clk)
312{
313 SYSCON->SYSAHBCLKCTRL |= 1UL << CLK_GATE_GET_BITS_SHIFT(clk);
314}
315
316/*
317 *!@brief disable ip clock.
318 *
319 * @param clk clock ip definition.
320 */
321static inline void CLOCK_DisableClock(clock_ip_name_t clk)
322{
323 SYSCON->SYSAHBCLKCTRL &= ~(1UL << CLK_GATE_GET_BITS_SHIFT(clk));
324}
325
326/*
327 *! @brief Configure the clock selection muxes.
328 * @param mux : Clock to be configured.
329 * @return Nothing
330 */
331static inline void CLOCK_Select(clock_select_t sel)
332{
333 *(CLK_MUX_GET_REG(sel)) = CLK_MUX_GET_MUX(sel);
334}
335
336/*
337 *! @brief Setup peripheral clock dividers.
338 * @param name : Clock divider name
339 * @param value: Value to be divided
340 * @return Nothing
341 */
342static inline void CLOCK_SetClkDivider(clock_divider_t name, uint32_t value)
343{
344 CLK_DIV_GET_REG(name) = value & 0xFFU;
345}
346
347/*
348 *! @brief Get peripheral clock dividers.
349 * @param name : Clock divider name
350 * @return clock divider value
351 */
352static inline uint32_t CLOCK_GetClkDivider(clock_divider_t name)
353{
354 return CLK_DIV_GET_REG(name) & 0xFFU;
355}
356
357/*
358 *! @brief Setup Core clock dividers.
359 * Be careful about the core divider value, due to core/system frequency should be lower than 30MHZ.
360 * @param value: Value to be divided
361 * @return Nothing
362 */
363static inline void CLOCK_SetCoreSysClkDiv(uint32_t value)
364{
365 assert(value != 0U);
366
367 SYSCON->SYSAHBCLKDIV = (SYSCON->SYSAHBCLKDIV & (~SYSCON_SYSAHBCLKDIV_DIV_MASK)) | SYSCON_SYSAHBCLKDIV_DIV(value);
368}
369
370/*! @brief Set main clock reference source.
371 * @param src, reference clock_main_clk_src_t to set the main clock source.
372 */
373void CLOCK_SetMainClkSrc(clock_main_clk_src_t src);
374
375/*
376 *! @brief Set Fractional generator 0 multiplier value.
377 * @param mul : FRG0 multiplier value.
378 * @return Nothing
379 */
380static inline void CLOCK_SetFRGClkMul(uint32_t mul)
381{
382 SYSCON->UARTFRGDIV = SYSCON_UARTFRGDIV_DIV_MASK;
383 SYSCON->UARTFRGMULT = SYSCON_UARTFRGMULT_MULT(mul);
384}
385/* @} */
386
387/*!
388 * @name Get frequency
389 * @{
390 */
391
392/*! @brief Return Frequency of Main Clock.
393 * @return Frequency of Main Clock.
394 */
395uint32_t CLOCK_GetMainClkFreq(void);
396
397/*! @brief Return Frequency of core.
398 * @return Frequency of core.
399 */
400static inline uint32_t CLOCK_GetCoreSysClkFreq(void)
401{
402 return CLOCK_GetMainClkFreq() / (SYSCON->SYSAHBCLKDIV & 0xffU);
403}
404
405/*! @brief Return Frequency of ClockOut
406 * @return Frequency of ClockOut
407 */
408uint32_t CLOCK_GetClockOutClkFreq(void);
409
410/*! @brief Return Frequency of IRC
411 * @return Frequency of IRC
412 */
413uint32_t CLOCK_GetIrcFreq(void);
414
415/*! @brief Return Frequency of SYSOSC
416 * @return Frequency of SYSOSC
417 */
418uint32_t CLOCK_GetSysOscFreq(void);
419
420/*! @brief Get UART0 frequency
421 * @retval UART0 frequency value.
422 */
423uint32_t CLOCK_GetUartClkFreq(void);
424
425/*! @brief Get UART0 frequency
426 * @retval UART0 frequency value.
427 */
428uint32_t CLOCK_GetUart0ClkFreq(void);
429
430/*! @brief Get UART1 frequency
431 * @retval UART1 frequency value.
432 */
433uint32_t CLOCK_GetUart1ClkFreq(void);
434
435/*! @brief Get UART2 frequency
436 * @retval UART2 frequency value.
437 */
438uint32_t CLOCK_GetUart2ClkFreq(void);
439
440/*! @brief Return Frequency of selected clock
441 * @return Frequency of selected clock
442 */
443uint32_t CLOCK_GetFreq(clock_name_t clockName);
444
445/*! @brief Return System PLL input clock rate
446 * @return System PLL input clock rate
447 */
448uint32_t CLOCK_GetSystemPLLInClockRate(void);
449
450/*! @brief Return Frequency of System PLL
451 * @return Frequency of PLL
452 */
453static inline uint32_t CLOCK_GetSystemPLLFreq(void)
454{
455 return CLOCK_GetSystemPLLInClockRate() * ((SYSCON->SYSPLLCTRL & SYSCON_SYSPLLCTRL_MSEL_MASK) + 1U);
456}
457
458/*! @brief Get watch dog OSC frequency
459 * @retval watch dog OSC frequency value.
460 */
461static inline uint32_t CLOCK_GetWdtOscFreq(void)
462{
463 return g_Wdt_Osc_Freq;
464}
465
466/*! @brief Get external clock frequency
467 * @retval external clock frequency value.
468 */
469static inline uint32_t CLOCK_GetExtClkFreq(void)
470{
471 return g_Ext_Clk_Freq;
472}
473/* @} */
474
475/*!
476 * @name PLL operations
477 * @{
478 */
479
480/*! @brief System PLL initialize.
481 * @param config System PLL configurations.
482 */
483void CLOCK_InitSystemPll(const clock_sys_pll_t *config);
484
485/*! @brief System PLL Deinitialize.*/
486static inline void CLOCK_DenitSystemPll(void)
487{
488 /* Power off PLL */
489 SYSCON->PDRUNCFG |= SYSCON_PDRUNCFG_SYSPLL_PD_MASK;
490}
491
492/* @} */
493
494/*!
495 * @name External/internal oscillator clock operations
496 * @{
497 */
498
499/*! @brief Init external CLK IN, select the CLKIN as the external clock source.
500 * @param clkInFreq external clock in frequency.
501 */
502void CLOCK_InitExtClkin(uint32_t clkInFreq);
503
504/*! @brief Init SYS OSC
505 * @param oscFreq oscillator frequency value.
506 */
507void CLOCK_InitSysOsc(uint32_t oscFreq);
508
509/*! @brief XTALIN init function
510 * system oscillator is bypassed, sys_osc_clk is fed driectly from the XTALIN.
511 * @param xtalInFreq XTALIN frequency value
512 * @return Frequency of PLL
513 */
514void CLOCK_InitXtalin(uint32_t xtalInFreq);
515
516/*! @brief Deinit SYS OSC
517 * @param config oscillator configuration.
518 */
519static inline void CLOCK_DeinitSysOsc(void)
520{
521 /* Deinit system osc power */
522 SYSCON->PDRUNCFG |= SYSCON_PDRUNCFG_SYSOSC_PD_MASK;
523}
524
525/*! @brief Init watch dog OSC
526 * Any setting of the FREQSEL bits will yield a Fclkana value within 40% of the
527 * listed frequency value. The watchdog oscillator is the clock source with the lowest power
528 * consumption. If accurate timing is required, use the FRO or system oscillator.
529 * The frequency of the watchdog oscillator is undefined after reset. The watchdog
530 * oscillator frequency must be programmed by writing to the WDTOSCCTRL register before
531 * using the watchdog oscillator.
532 * Watchdog osc output frequency = wdtOscFreq / wdtOscDiv, should in range 9.3KHZ to 2.3MHZ.
533 * @param wdtOscFreq watch dog analog part output frequency, reference _wdt_analog_output_freq.
534 * @param wdtOscDiv watch dog analog part output frequency divider, shoule be a value >= 2U and multiple of 2
535 */
536void CLOCK_InitWdtOsc(clock_wdt_analog_freq_t wdtOscFreq, uint32_t wdtOscDiv);
537
538/*! @brief Deinit watch dog OSC
539 * @param config oscillator configuration.
540 */
541static inline void CLOCK_DeinitWdtOsc(void)
542{
543 SYSCON->PDRUNCFG |= SYSCON_PDRUNCFG_WDTOSC_PD_MASK;
544}
545
546/*! @brief Set UARTFRG
547 * @param target UART clock src.
548 */
549bool CLOCK_SetUARTFRGClkFreq(uint32_t freq);
550
551/*! @brief updates the clock source of the CLKOUT
552 */
553void CLOCK_UpdateClkOUTsrc(void);
554
555/*! @brief Set UARTFRGMULT
556 * @deprecated Do not use this function. Refer to CLOCK_SetFRGClkMul().
557 * @param UARTFRGMULT.
558 */
559static inline void CLOCK_SetUARTFRGMULT(uint32_t mul)
560{
561 SYSCON->UARTFRGMULT = SYSCON_UARTFRGMULT_MULT(mul);
562}
563
564/* @} */
565
566#if defined(__cplusplus)
567}
568#endif /* __cplusplus */
569
570/*! @} */
571
572#endif /* _FSL_CLOCK_H_ */