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