31#define CLK_DPLL_OUTPUT_DIV (CLK_DPLL_OUT_96M)
34#define CLK_APB1_WDTSEL_MILLI_PULSE (0x00000000UL)
35#define CLK_APB1_WDTSEL_RCL32K (0x00010000UL)
37#define CLK_APB1_WWDTSEL_MILLI_PULSE (0x00000000UL)
38#define CLK_APB1_WWDTSEL_RCL32K (0x00020000UL)
40#define CLK_APB1_TMR0SEL_APB1CLK (0x00000000UL)
41#define CLK_APB1_TMR0SEL_RCL32K (0x00040000UL)
42#define CLK_APB1_TMR0SEL_TM0 (0x00080000UL)
44#define CLK_APB2_TMR1SEL_APB2CLK (0x00000000UL)
45#define CLK_APB2_TMR1SEL_RCL32K (0x00000100UL)
46#define CLK_APB2_TMR1SEL_TM1 (0x00000200UL)
48#define CLK_APB2_TMR2SEL_APB2CLK (0x00000000UL)
49#define CLK_APB2_TMR2SEL_RCL32K (0x00000400UL)
50#define CLK_APB2_TMR2SEL_TM2 (0x00000800UL)
55 #define FREQ_1MHZ (1000000)
56 #define FREQ_8MHZ (8000000)
57 #define FREQ_16MHZ (16000000)
58 #define FREQ_25MHZ (25000000)
59 #define FREQ_32MHZ (32000000)
60 #define FREQ_48MHZ (48000000)
61 #define FREQ_64MHZ (64000000)
62 #define FREQ_96MHZ (96000000)
63 #define FREQ_50MHZ (50000000)
64 #define FREQ_72MHZ (72000000)
65 #define FREQ_100MHZ (100000000)
66 #define FREQ_200MHZ (200000000)
67 #define FREQ_250MHZ (250000000)
68 #define FREQ_500MHZ (500000000)
74#define CLK_SYS_SRCSEL_RCH ((uint32_t)0x00000000)
75#define CLK_SYS_SRCSEL_XTH ((uint32_t)0x00000100)
76#define CLK_SYS_SRCSEL_DPLL ((uint32_t)0x00000200)
82#define CLK_DPLL_REF_CLKSEL_RCH ((uint32_t)0x00000000)
83#define CLK_DPLL_REF_CLKSEL_XTH ((uint32_t)0x00000002)
84#define CLK_DPLL_OUT_48M ((uint32_t)0x00000000)
85#define CLK_DPLL_OUT_64M ((uint32_t)0x00000001)
92#define CLK_HCLK_APB2_Div1 ((uint32_t)0x00000000)
93#define CLK_HCLK_APB2_Div2 ((uint32_t)0x00100000)
94#define CLK_HCLK_APB2_Div4 ((uint32_t)0x00200000)
95#define CLK_HCLK_APB2_Div8 ((uint32_t)0x00400000)
96#define CLK_HCLK_APB2_Div16 ((uint32_t)0x00800000)
102#define CLK_HCLK_APB1_Div1 ((uint32_t)0x00000000)
103#define CLK_HCLK_APB1_Div2 ((uint32_t)0x00010000)
104#define CLK_HCLK_APB1_Div4 ((uint32_t)0x00020000)
105#define CLK_HCLK_APB1_Div8 ((uint32_t)0x00040000)
106#define CLK_HCLK_APB1_Div16 ((uint32_t)0x00080000)
112#define CLK_APB1Periph_I2C0 ((uint32_t)0x00000001)
113#define CLK_APB1Periph_SPI0 ((uint32_t)0x00000002)
114#define CLK_APB1Periph_UART0 ((uint32_t)0x00000008)
115#define CLK_APB1Periph_PWM0_CH01 ((uint32_t)0x00000010)
116#define CLK_APB1Periph_PWM0_CH23 ((uint32_t)0x00000020)
117#define CLK_APB1Periph_PWM0_CH45 ((uint32_t)0x00000040)
118#define CLK_APB1Periph_PWM0_CH67 ((uint32_t)0x00000080)
119#define CLK_APB1Periph_PWM0_EN ((uint32_t)0x00000100)
120#define CLK_APB1Periph_ADC ((uint32_t)0x00000200)
121#define CLK_APB1Periph_WDT ((uint32_t)0x00000400)
122#define CLK_APB1Periph_WWDT ((uint32_t)0x00000800)
123#define CLK_APB1Periph_TMR0 ((uint32_t)0x00001000)
124#define CLK_APB1Periph_I2SS ((uint32_t)0x00100000)
125#define CLK_APB1Periph_I2SM ((uint32_t)0x00200000)
126#define CLK_APB1Periph_PWM1_CH01 ((uint32_t)0x00400000)
127#define CLK_APB1Periph_PWM1_CH23 ((uint32_t)0x00800000)
128#define CLK_APB1Periph_PWM1_CH45 ((uint32_t)0x01000000)
129#define CLK_APB1Periph_PWM1_CH67 ((uint32_t)0x02000000)
130#define CLK_APB1Periph_PWM1_EN ((uint32_t)0x04000000)
131#define CLK_APB1Periph_PWM2_CH01 ((uint32_t)0x08000000)
132#define CLK_APB1Periph_PWM2_CH23 ((uint32_t)0x10000000)
133#define CLK_APB1Periph_PWM2_CH45 ((uint32_t)0x20000000)
134#define CLK_APB1Periph_PWM2_CH67 ((uint32_t)0x40000000)
135#define CLK_APB1Periph_PWM2_EN ((uint32_t)0x80000000)
136#define CLK_APB1Periph_All ((uint32_t)0xfff01ffb)
142#define CLK_APB2Periph_SPI1 ((uint32_t)0x00000002)
143#define CLK_APB2Periph_UART1 ((uint32_t)0x00000008)
144#define CLK_APB2Periph_TMR1 ((uint32_t)0x00000010)
145#define CLK_APB2Periph_TMR2 ((uint32_t)0x00000020)
146#define CLK_APB2Periph_KEYSCAN ((uint32_t)0x00001000)
147#define CLK_APB2Periph_QDEC ((uint32_t)0x00400000)
148#define CLK_APB2Periph_All ((uint32_t)0x0040103a)
154#define CLK_AHBPeriph_DMAC ((uint32_t)0x00000001)
155#define CLK_AHBPeriph_GPIO ((uint32_t)0x00000002)
156#define CLK_AHBPeriph_SYSTICK ((uint32_t)0x00000004)
157#define CLK_AHBPeriph_APB1 ((uint32_t)0x00000008)
158#define CLK_AHBPeriph_APB2 ((uint32_t)0x00000010)
159#define CLK_AHBPeriph_AHB ((uint32_t)0x00000020)
160#define CLK_AHBPeriph_BLE_32M ((uint32_t)0x00000040)
161#define CLK_AHBPeriph_BLE_32K ((uint32_t)0x00000080)
162#define CLK_AHBPeriph_ROM ((uint32_t)0x00000400)
163#define CLK_AHBPeriph_EFUSE ((uint32_t)0x00000800)
164#define CLK_AHBPeriph_ECC ((uint32_t)0x00001000)
165#define CLK_AHBPeriph_USB_AHB ((uint32_t)0x00002000)
166#define CLK_AHBPeriph_USB_48M ((uint32_t)0x00004000)
167#define CLK_AHBPeriph_All ((uint32_t)0x00007CFF)
173#define CLK_RCL_SELECT (0)
174#define CLK_RCH_SELECT (1)
175#define CLK_XTL_SELECT (2)
176#define CLK_XTH_SELECT (3)
177#define CLK_DPLL_SELECT (4)
180#define CLK_STABLE_STATUS_Pos (24)
181#define CLK_STABLE_STATUS_Msk (0x1ul << CLK_STABLE_STATUS_Pos)
183#define CLKTRIM_CALC_CLK_SEL_32K (0)
184#define CLKTRIM_CALC_CLK_SEL_32M (1)
185#define CLKTRIM_CALC_CLK_SEL_EXT (3)
187#define CLKTRIM_QDEC_CLK_SEL_APB (0)
188#define CLKTRIM_QDEC_CLK_SEL_32K (1)
190#define CLKTRIM_KSCAN_CLK_SEL_APB (0)
191#define CLKTRIM_KSCAN_CLK_SEL_32K (1)
200 CLK->XTH_CTRL |= (CLK_XTHCTL_FSYN_EN_Msk | CLK_XTHCTL_START_FAST_Msk);
212 CLK->CLK_TOP_CTRL = (CLK->CLK_TOP_CTRL & (~CLK_TOPCTL_AHB_DIV_Msk)) | (u32ClkDiv << CLK_TOPCTL_AHB_DIV_Pos);
224 CLK->CLK_TOP_CTRL = (CLK->CLK_TOP_CTRL & (~CLK_TOPCTL_APB1_DIV_Msk))| (u32ClkDiv << CLK_TOPCTL_APB1_DIV_Pos);
236 CLK->CLK_TOP_CTRL = (CLK->CLK_TOP_CTRL & (~CLK_TOPCTL_APB2_DIV_Msk))| (u32ClkDiv << CLK_TOPCTL_APB2_DIV_Pos);
247 CLK->APB2_CLK_CTRL = (CLK->APB2_CLK_CTRL & ~CLK_APB2CLK_QDEC_DIV_Msk) | (div << CLK_APB2CLK_QDEC_DIV_Pos);
256 return ((CLK->APB2_CLK_CTRL & CLK_APB2CLK_QDEC_DIV_Msk) >> CLK_APB2CLK_QDEC_DIV_Pos);
265 CLK->APB2_CLK_CTRL1 = (CLK->APB2_CLK_CTRL1 & ~CLK_APB2CLK_QDEC_CLK_SEL_Msk) | (src << CLK_APB2CLK_QDEC_CLK_SEL_Pos);
274 CLK->APB2_CLK_CTRL = (CLK->APB2_CLK_CTRL & ~CLK_APB2CLK_KEYSCAN_DIV_Msk) | (div << CLK_APB2CLK_KEYSCAN_DIV_Pos);
282 return ((CLK->APB2_CLK_CTRL & CLK_APB2CLK_KEYSCAN_DIV_Msk) >> CLK_APB2CLK_KEYSCAN_DIV_Pos);
292 CLK->APB2_CLK_CTRL1 = (CLK->APB2_CLK_CTRL1 & ~CLK_APB2CLK_KSCAN_CLK_DIV_Msk) | (src << CLK_APB2CLK_KSCAN_CLK_DIV_Pos);
306 CLK->DPLL_CTRL &= ~CLK_DPLLCTL_FREQ_OUT_Msk;
307 CLK->DPLL_CTRL |= freq;
318 ANA->ANA_TEMP = (ANA->ANA_TEMP & ~ANAC_TEMP_GAIN_CTL_Msk) | (gain<<ANAC_TEMP_GAIN_CTL_Pos);
327 ANA->ANA_TEMP |= ANAC_TEMP_ENABLE_Msk;
339 (NewState != ENABLE)?(CLK->APB2_CLK_CTRL1 &= ~CLK_APB2CLK_TRIM_EN_Msk):(CLK->APB2_CLK_CTRL1 |= CLK_APB2CLK_TRIM_EN_Msk);
350 (NewState != ENABLE)?(CLK->APB2_CLK_CTRL1 &= ~CLK_APB2CLK_TRIM_CALC_EN_Msk):(CLK->APB2_CLK_CTRL1 |= CLK_APB2CLK_TRIM_CALC_EN_Msk);
364 CLK->APB2_CLK_CTRL1 = (CLK->APB2_CLK_CTRL1 & ~CLK_APB2CLK_CALC_CLK_SEL_Msk)| (src << CLK_APB2CLK_CALC_CLK_SEL_Pos);
376 uint32_t reg = CLK->APB2_CLK_CTRL1 & ~CLK_APB2CLK_CALC_CLK_DIV_Msk;
377 CLK->APB2_CLK_CTRL1 = reg | ((div << CLK_APB2CLK_CALC_CLK_DIV_Pos) & CLK_APB2CLK_CALC_CLK_DIV_Msk);
398 uint32_t reg = CLK->AHB_CLK_CTRL & (~CLK_AHBCLK_SPI_FLASH_DIV_Msk);
399 CLK->AHB_CLK_CTRL = reg | ((div << CLK_AHBCLK_SPI_FLASH_DIV_Pos) & CLK_AHBCLK_SPI_FLASH_DIV_Msk);
575#define DISABLE_3V_AUTOSYNC ANA->LP_REG_SYNC &= ~ANAC_LP_REG_AUTOSYNC_Msk
580#define ENABLE_3V_AUTOSYNC ANA->LP_REG_SYNC |= ~ANAC_LP_REG_AUTOSYNC_Msk
585#define START_3V_SYNC_NBLOCK ANA->LP_REG_SYNC |= ANAC_LP_REG_SYNC_3V_Msk
__STATIC_INLINE void CLK_SetKeyscanDiv(uint32_t div)
This function used to set keyscan divisor.
Definition: pan_clk.h:272
__STATIC_INLINE void CLK_PCLK2Config(uint32_t u32ClkDiv)
Configures the High Speed APB clock (PCLK2).
Definition: pan_clk.h:234
void CLK_SYSCLKConfig(uint32_t u32ClkSrc, uint32_t freq_out)
This function set HCLK clock source.
uint32_t CLK_GetHCLKFreq(void)
This function get HCLK frequency. The frequency unit is Hz.
void CLK_SetWdtClkSrc(uint32_t u32clksel)
This API is used to select wdt clock source.
void CLK_SetWwdtClkSrc(uint32_t u32clksel)
This API is used to select wwdt clock source.
__STATIC_INLINE void CLK_HCLK1Config(uint32_t u32ClkDiv)
Configures the Low Speed AHB clock (HCLK).
Definition: pan_clk.h:210
void CLK_APB1PeriphClockCmd(uint32_t CLK_APB1Periph, FunctionalState NewState)
Enables or disables the Low Speed APB (APB1) peripheral clock.
uint32_t CLK_GetPCLK2Freq(void)
This function get APB2 frequency. The frequency unit is Hz.
uint32_t CLK_WaitClockReady(uint32_t u32ClkMask)
This function check selected clock source status.
void CLK_HCLKConfig(uint32_t u32ClkDiv)
This function set CPU frequency divider. The frequency unit is Hz.
void CLK_SetTmrClkSrc(TIMER_T *timer, uint32_t u32clksel)
This API is used to SELECT timer clock source.
uint32_t CLK_GetPCLK1Freq(void)
This function get APB1 frequency. The frequency unit is Hz.
uint32_t CLK_Wait3vSyncReady(void)
This function wait sync 3v clock locale stable.
uint32_t CLK_GetPeripheralFreq(void *Peripheral)
This API is used to get peripheral clk frequence.
__STATIC_INLINE uint32_t CLK_GetKeyscanDiv(void)
This function used to get keyscan divisor.
Definition: pan_clk.h:280
__STATIC_INLINE uint32_t CLK_GetQdecDiv(void)
This function used to get qdec divisor.
Definition: pan_clk.h:254
__STATIC_INLINE void CLK_SetTemperatureGain(uint32_t gain)
This function set temperature gain value.
Definition: pan_clk.h:316
uint32_t CLK_GetCPUFreq(void)
This function get CPU frequency. The frequency unit is Hz.
__STATIC_INLINE void CLK_SetClkTrimCalClkDiv(uint16_t div)
This function is used to set calculated high speed clock source (HSCK = RCH/EXT_CLK) divisor of CLKTR...
Definition: pan_clk.h:374
__STATIC_FORCEINLINE void CLK_SetFlashClkDiv(uint8_t div)
This function is used to set flash clk divisor.
Definition: pan_clk.h:396
__STATIC_INLINE void CLK_EnableTempDetect(void)
This function set temperature function enable.
Definition: pan_clk.h:325
__STATIC_INLINE void CLK_SetQdecClkSrc(uint32_t src)
This function used to set qdec clk source.
Definition: pan_clk.h:263
__STATIC_INLINE void CLK_XthStartupConfig(void)
Configures the xth clock.
Definition: pan_clk.h:198
__STATIC_INLINE void CLK_SetDpllOutputFreq(uint32_t freq)
This function set DPLL frequence.
Definition: pan_clk.h:304
void CLK_Set3vSyncAuto(void)
This function wait sync 3v clock locale stable by hardware.
void CLK_AHBPeriphClockCmd(uint32_t CLK_AHBPeriph, FunctionalState NewState)
Enables or disables the AHB peripheral clock.
__STATIC_INLINE void CLK_SetQdecDiv(uint32_t div)
This function used to set qdec divisor.
Definition: pan_clk.h:245
__STATIC_INLINE void CLK_EnableClkTrimCalc(FunctionalState NewState)
This function used to enable clktrim calculate function.
Definition: pan_clk.h:348
__STATIC_INLINE void CLK_SetKeyscanClkSrc(uint32_t src)
This function used to set keyscan clk source.
Definition: pan_clk.h:290
void CLK_RefClkSrcConfig(uint32_t u32ClkSrc)
This function set 16M ref clock source.
__STATIC_INLINE void CLK_EnableClkTrim(FunctionalState NewState)
This function used to enable clktrim peripheral.
Definition: pan_clk.h:337
__STATIC_INLINE void CLK_PCLK1Config(uint32_t u32ClkDiv)
Configures the Low Speed APB clock (PCLK1).
Definition: pan_clk.h:222
void CLK_APB2PeriphClockCmd(uint32_t CLK_APB2Periph, FunctionalState NewState)
Enables or disables the High Speed APB (APB2) peripheral clock.
__STATIC_INLINE void CLK_SelectClkTrimSrc(uint32_t src)
This function used to select calculate clk source.
Definition: pan_clk.h:362
@ CLK_FLASH_CLKDIV_8
Definition: pan_clk.h:386
@ CLK_FLASH_CLKDIV_1
Definition: pan_clk.h:383
@ CLK_FLASH_CLKDIV_16
Definition: pan_clk.h:387
@ CLK_FLASH_CLKDIV_2
Definition: pan_clk.h:384
@ CLK_FLASH_CLKDIV_4
Definition: pan_clk.h:385
@ CLK_FLASH_CLKDIV_32
Definition: pan_clk.h:388