PAN1080 Peripheral API
|
Clk Interface. More...
Modules | |
Clk frequence | |
Clk frequence definitions. | |
System clk source select | |
System clk source definitions. | |
Dpll clk reference source select | |
Dpll clk reference source select definitions. | |
Apb2 clk divisor | |
Apb2 clk divisor definitions. | |
Apb1 clk divisor | |
Apb1 clk divisor definitions. | |
Apb1 clk enable | |
Apb1 clk enable definitions. | |
Apb2 clk enable | |
Apb2 clk enable definitions. | |
Ahb peripheral clk enable | |
Ahb peripheral clk enable definitions. | |
Clk reference source | |
Clk reference source definitions. | |
Macros | |
#define | CLK_DPLL_OUTPUT_DIV (CLK_DPLL_OUT_96M) |
#define | CLK_APB1_WDTSEL_MILLI_PULSE (0x00000000UL) |
#define | CLK_APB1_WDTSEL_RCL32K (0x00010000UL) |
#define | CLK_APB1_WWDTSEL_MILLI_PULSE (0x00000000UL) |
#define | CLK_APB1_WWDTSEL_RCL32K (0x00020000UL) |
#define | CLK_APB1_TMR0SEL_APB1CLK (0x00000000UL) |
#define | CLK_APB1_TMR0SEL_RCL32K (0x00040000UL) |
#define | CLK_APB1_TMR0SEL_TM0 (0x00080000UL) |
#define | CLK_APB2_TMR1SEL_APB2CLK (0x00000000UL) |
#define | CLK_APB2_TMR1SEL_RCL32K (0x00000100UL) |
#define | CLK_APB2_TMR1SEL_TM1 (0x00000200UL) |
#define | CLK_APB2_TMR2SEL_APB2CLK (0x00000000UL) |
#define | CLK_APB2_TMR2SEL_RCL32K (0x00000400UL) |
#define | CLK_APB2_TMR2SEL_TM2 (0x00000800UL) |
#define | CLK_STABLE_STATUS_Pos (24) |
#define | CLK_STABLE_STATUS_Msk (0x1ul << CLK_STABLE_STATUS_Pos) |
#define | CLKTRIM_CALC_CLK_SEL_32K (0) |
#define | CLKTRIM_CALC_CLK_SEL_32M (1) |
#define | CLKTRIM_CALC_CLK_SEL_EXT (3) |
#define | CLKTRIM_QDEC_CLK_SEL_APB (0) |
#define | CLKTRIM_QDEC_CLK_SEL_32K (1) |
#define | CLKTRIM_KSCAN_CLK_SEL_APB (0) |
#define | CLKTRIM_KSCAN_CLK_SEL_32K (1) |
#define | DISABLE_3V_AUTOSYNC ANA->LP_REG_SYNC &= ~ANAC_LP_REG_AUTOSYNC_Msk |
This macro is used to disable Auto-sync function. More... | |
#define | ENABLE_3V_AUTOSYNC ANA->LP_REG_SYNC |= ~ANAC_LP_REG_AUTOSYNC_Msk |
This macro is used to enable Auto-sync function. More... | |
#define | START_3V_SYNC_NBLOCK ANA->LP_REG_SYNC |= ANAC_LP_REG_SYNC_3V_Msk |
This macro is used to start sync. More... | |
Enumerations | |
enum | { CLK_FLASH_CLKDIV_1 = 0x00 , CLK_FLASH_CLKDIV_2 = 0x01 , CLK_FLASH_CLKDIV_4 = 0x02 , CLK_FLASH_CLKDIV_8 = 0x04 , CLK_FLASH_CLKDIV_16 = 0x08 , CLK_FLASH_CLKDIV_32 = 0x10 } |
Functions | |
__STATIC_INLINE void | CLK_XthStartupConfig (void) |
Configures the xth clock. More... | |
__STATIC_INLINE void | CLK_HCLK1Config (uint32_t u32ClkDiv) |
Configures the Low Speed AHB clock (HCLK). More... | |
__STATIC_INLINE void | CLK_PCLK1Config (uint32_t u32ClkDiv) |
Configures the Low Speed APB clock (PCLK1). More... | |
__STATIC_INLINE void | CLK_PCLK2Config (uint32_t u32ClkDiv) |
Configures the High Speed APB clock (PCLK2). More... | |
__STATIC_INLINE void | CLK_SetQdecDiv (uint32_t div) |
This function used to set qdec divisor. More... | |
__STATIC_INLINE uint32_t | CLK_GetQdecDiv (void) |
This function used to get qdec divisor. More... | |
__STATIC_INLINE void | CLK_SetQdecClkSrc (uint32_t src) |
This function used to set qdec clk source. More... | |
__STATIC_INLINE void | CLK_SetKeyscanDiv (uint32_t div) |
This function used to set keyscan divisor. More... | |
__STATIC_INLINE uint32_t | CLK_GetKeyscanDiv (void) |
This function used to get keyscan divisor. More... | |
__STATIC_INLINE void | CLK_SetKeyscanClkSrc (uint32_t src) |
This function used to set keyscan clk source. More... | |
__STATIC_INLINE void | CLK_SetDpllOutputFreq (uint32_t freq) |
This function set DPLL frequence. More... | |
__STATIC_INLINE void | CLK_SetTemperatureGain (uint32_t gain) |
This function set temperature gain value. More... | |
__STATIC_INLINE void | CLK_EnableTempDetect (void) |
This function set temperature function enable. More... | |
__STATIC_INLINE void | CLK_EnableClkTrim (FunctionalState NewState) |
This function used to enable clktrim peripheral. More... | |
__STATIC_INLINE void | CLK_EnableClkTrimCalc (FunctionalState NewState) |
This function used to enable clktrim calculate function. More... | |
__STATIC_INLINE void | CLK_SelectClkTrimSrc (uint32_t src) |
This function used to select calculate clk source. More... | |
__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 CLKTRIM. More... | |
__STATIC_FORCEINLINE void | CLK_SetFlashClkDiv (uint8_t div) |
This function is used to set flash clk divisor. More... | |
uint32_t | CLK_GetHCLKFreq (void) |
This function get HCLK frequency. The frequency unit is Hz. More... | |
uint32_t | CLK_GetCPUFreq (void) |
This function get CPU frequency. The frequency unit is Hz. More... | |
uint32_t | CLK_GetPCLK1Freq (void) |
This function get APB1 frequency. The frequency unit is Hz. More... | |
uint32_t | CLK_GetPCLK2Freq (void) |
This function get APB2 frequency. The frequency unit is Hz. More... | |
void | CLK_RefClkSrcConfig (uint32_t u32ClkSrc) |
This function set 16M ref clock source. More... | |
void | CLK_SYSCLKConfig (uint32_t u32ClkSrc, uint32_t freq_out) |
This function set HCLK clock source. More... | |
void | CLK_HCLKConfig (uint32_t u32ClkDiv) |
This function set CPU frequency divider. The frequency unit is Hz. More... | |
void | CLK_AHBPeriphClockCmd (uint32_t CLK_AHBPeriph, FunctionalState NewState) |
Enables or disables the AHB peripheral clock. More... | |
void | CLK_APB1PeriphClockCmd (uint32_t CLK_APB1Periph, FunctionalState NewState) |
Enables or disables the Low Speed APB (APB1) peripheral clock. More... | |
void | CLK_APB2PeriphClockCmd (uint32_t CLK_APB2Periph, FunctionalState NewState) |
Enables or disables the High Speed APB (APB2) peripheral clock. More... | |
uint32_t | CLK_WaitClockReady (uint32_t u32ClkMask) |
This function check selected clock source status. More... | |
uint32_t | CLK_Wait3vSyncReady (void) |
This function wait sync 3v clock locale stable. More... | |
void | CLK_Set3vSyncAuto (void) |
This function wait sync 3v clock locale stable by hardware. More... | |
void | CLK_SetWdtClkSrc (uint32_t u32clksel) |
This API is used to select wdt clock source. More... | |
void | CLK_SetWwdtClkSrc (uint32_t u32clksel) |
This API is used to select wwdt clock source. More... | |
void | CLK_SetTmrClkSrc (TIMER_T *timer, uint32_t u32clksel) |
This API is used to SELECT timer clock source. More... | |
uint32_t | CLK_GetPeripheralFreq (void *Peripheral) |
This API is used to get peripheral clk frequence. More... | |
Clk Interface.
#define CLK_APB1_TMR0SEL_APB1CLK (0x00000000UL) |
Timer0 clk source select apb_clk / 2048
#define CLK_APB1_TMR0SEL_RCL32K (0x00040000UL) |
Timer0 clk source select rcl 32k
#define CLK_APB1_TMR0SEL_TM0 (0x00080000UL) |
Timer0 clk source select externel input
#define CLK_APB1_WDTSEL_MILLI_PULSE (0x00000000UL) |
Wdt clk source select apb_clk / 2048
#define CLK_APB1_WDTSEL_RCL32K (0x00010000UL) |
Wdt clk source select rcl 32k
#define CLK_APB1_WWDTSEL_MILLI_PULSE (0x00000000UL) |
Wwdt clk source select apb_clk / 2048
#define CLK_APB1_WWDTSEL_RCL32K (0x00020000UL) |
Wwdt clk source select rcl 32k
#define CLK_APB2_TMR1SEL_APB2CLK (0x00000000UL) |
Timer1 clk source select apb_clk / 2048
#define CLK_APB2_TMR1SEL_RCL32K (0x00000100UL) |
Timer1 clk source select rcl 32k
#define CLK_APB2_TMR1SEL_TM1 (0x00000200UL) |
Timer1 clk source select externel input
#define CLK_APB2_TMR2SEL_APB2CLK (0x00000000UL) |
Timer2 clk source select apb_clk / 2048
#define CLK_APB2_TMR2SEL_RCL32K (0x00000400UL) |
Timer2 clk source select rcl 32k
#define CLK_APB2_TMR2SEL_TM2 (0x00000800UL) |
Timer2 clk source select externel input
#define CLK_DPLL_OUTPUT_DIV (CLK_DPLL_OUT_96M) |
Clk dpll output
#define CLK_STABLE_STATUS_Msk (0x1ul << CLK_STABLE_STATUS_Pos) |
Clk stable register mask value
#define CLK_STABLE_STATUS_Pos (24) |
Clk stable register position
#define CLKTRIM_CALC_CLK_SEL_32K (0) |
Clktrim calibrate source selecet 32K
#define CLKTRIM_CALC_CLK_SEL_32M (1) |
Clktrim calibrate source selecet 32M
#define CLKTRIM_CALC_CLK_SEL_EXT (3) |
Clktrim calibrate source selecet external clk
#define CLKTRIM_KSCAN_CLK_SEL_32K (1) |
Kscan clk source selecet 32K
#define CLKTRIM_KSCAN_CLK_SEL_APB (0) |
Kscan clk source selecet apb clk
#define CLKTRIM_QDEC_CLK_SEL_32K (1) |
Qdec clk source selecet 32K
#define CLKTRIM_QDEC_CLK_SEL_APB (0) |
Qdec clk source selecet apb clk
#define DISABLE_3V_AUTOSYNC ANA->LP_REG_SYNC &= ~ANAC_LP_REG_AUTOSYNC_Msk |
This macro is used to disable Auto-sync function.
#define ENABLE_3V_AUTOSYNC ANA->LP_REG_SYNC |= ~ANAC_LP_REG_AUTOSYNC_Msk |
This macro is used to enable Auto-sync function.
#define START_3V_SYNC_NBLOCK ANA->LP_REG_SYNC |= ANAC_LP_REG_SYNC_3V_Msk |
This macro is used to start sync.
anonymous enum |
void CLK_AHBPeriphClockCmd | ( | uint32_t | CLK_AHBPeriph, |
FunctionalState | NewState | ||
) |
Enables or disables the AHB peripheral clock.
CLK_AHBPeriph | specifies the AHB2 peripheral to gates its clock. This parameter can be any combination of the following values: Ahb peripheral clk enable |
NewState | : new state of the specified peripheral clock. This parameter can be: ENABLE or DISABLE. |
None |
void CLK_APB1PeriphClockCmd | ( | uint32_t | CLK_APB1Periph, |
FunctionalState | NewState | ||
) |
Enables or disables the Low Speed APB (APB1) peripheral clock.
CLK_APB1Periph | specifies the APB1 peripheral to gates its clock. This parameter can be any combination of the following values: Apb1 clk enable |
NewState | : new state of the specified peripheral clock. This parameter can be: ENABLE or DISABLE. |
None |
void CLK_APB2PeriphClockCmd | ( | uint32_t | CLK_APB2Periph, |
FunctionalState | NewState | ||
) |
Enables or disables the High Speed APB (APB2) peripheral clock.
CLK_APB2Periph | specifies the APB2 peripheral to gates its clock. This parameter can be any combination of the following values: Apb2 clk enable |
NewState | new state of the specified peripheral clock. This parameter can be: ENABLE or DISABLE. |
None |
__STATIC_INLINE void CLK_EnableClkTrim | ( | FunctionalState | NewState | ) |
This function used to enable clktrim peripheral.
[in] | NewState | new state of the clk.This parameter can be: ENABLE or DISABLE. |
__STATIC_INLINE void CLK_EnableClkTrimCalc | ( | FunctionalState | NewState | ) |
This function used to enable clktrim calculate function.
[in] | NewState | new state of the clk.This parameter can be: ENABLE or DISABLE. |
__STATIC_INLINE void CLK_EnableTempDetect | ( | void | ) |
This function set temperature function enable.
uint32_t CLK_GetCPUFreq | ( | void | ) |
This function get CPU frequency. The frequency unit is Hz.
uint32_t CLK_GetHCLKFreq | ( | void | ) |
This function get HCLK frequency. The frequency unit is Hz.
__STATIC_INLINE uint32_t CLK_GetKeyscanDiv | ( | void | ) |
This function used to get keyscan divisor.
uint32_t CLK_GetPCLK1Freq | ( | void | ) |
This function get APB1 frequency. The frequency unit is Hz.
uint32_t CLK_GetPCLK2Freq | ( | void | ) |
This function get APB2 frequency. The frequency unit is Hz.
uint32_t CLK_GetPeripheralFreq | ( | void * | Peripheral | ) |
This API is used to get peripheral clk frequence.
[in] | Peripheral | The base address of peripheral module |
__STATIC_INLINE uint32_t CLK_GetQdecDiv | ( | void | ) |
This function used to get qdec divisor.
__STATIC_INLINE void CLK_HCLK1Config | ( | uint32_t | u32ClkDiv | ) |
Configures the Low Speed AHB clock (HCLK).
u32ClkDiv | defines the AHB clock divisor. This clock is derived from the AHB clock (HCLK). This parameter can be 0~15,hclk = hclk / (u32ClkDiv + 1): |
void CLK_HCLKConfig | ( | uint32_t | u32ClkDiv | ) |
This function set CPU frequency divider. The frequency unit is Hz.
[in] | u32ClkDiv | is ahb clock division |
void CLK_PCLK1Config | ( | uint32_t | u32ClkDiv | ) |
Configures the Low Speed APB clock (PCLK1).
This function set APB1 frequency divider. The frequency unit is Hz.
u32ClkDiv | defines the APB1 clock divisor. This clock is derived from the AHB clock (HCLK). This parameter can be 0~15,PCLK1 = hclk / (u32ClkDiv * 2): |
[in] | u32ClkDiv | is is APB1 clock division |
void CLK_PCLK2Config | ( | uint32_t | u32ClkDiv | ) |
Configures the High Speed APB clock (PCLK2).
This function set APB2 frequency divider. The frequency unit is Hz.
u32ClkDiv | defines the APB2 clock divisor. This clock is derived from the AHB clock (HCLK). This parameter can be 0~15,PCLK2 = hclk / (u32ClkDiv * 2): |
[in] | u32ClkDiv | is is APB2 clock division |
void CLK_RefClkSrcConfig | ( | uint32_t | u32ClkSrc | ) |
This function set 16M ref clock source.
[in] | u32ClkSrc | is HCLK clock source. Including : |
__STATIC_INLINE void CLK_SelectClkTrimSrc | ( | uint32_t | src | ) |
This function used to select calculate clk source.
[in] | src | clk source, including: CLKTRIM_CALC_CLK_SEL_32K CLKTRIM_CALC_CLK_SEL_32M CLKTRIM_CALC_CLK_SEL_EXT |
void CLK_Set3vSyncAuto | ( | void | ) |
This function wait sync 3v clock locale stable by hardware.
__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 CLKTRIM.
[in] | div | clock divisor (9 bits), 0: No division, cal_clk = HSCK others: Divided by 2*div, cal_clk = HSCK / (2*div) |
__STATIC_INLINE void CLK_SetDpllOutputFreq | ( | uint32_t | freq | ) |
This function set DPLL frequence.
[in] | freq | is target frequency,it could be: CLK_DPLL_OUT_48M CLK_DPLL_OUT_64M |
__STATIC_FORCEINLINE void CLK_SetFlashClkDiv | ( | uint8_t | div | ) |
This function is used to set flash clk divisor.
[in] | div | clock divisor |
__STATIC_INLINE void CLK_SetKeyscanClkSrc | ( | uint32_t | src | ) |
This function used to set keyscan clk source.
[in] | src | is keyscan sclk source,apb or 32k |
__STATIC_INLINE void CLK_SetKeyscanDiv | ( | uint32_t | div | ) |
This function used to set keyscan divisor.
[in] | div | is keyscan sclk dividor ratio,9 bit width |
__STATIC_INLINE void CLK_SetQdecClkSrc | ( | uint32_t | src | ) |
This function used to set qdec clk source.
[in] | src | is qdec sclk source,apb or 32k |
__STATIC_INLINE void CLK_SetQdecDiv | ( | uint32_t | div | ) |
This function used to set qdec divisor.
[in] | div | is qdec sclk dividor ratio,9 bit width |
__STATIC_INLINE void CLK_SetTemperatureGain | ( | uint32_t | gain | ) |
This function set temperature gain value.
[in] | gain | is target gain value |
void CLK_SetTmrClkSrc | ( | TIMER_T * | timer, |
uint32_t | u32clksel | ||
) |
This API is used to SELECT timer clock source.
[in] | timer | The base address of Timer module |
[in] | u32clksel | timer clock selection. Could be
|
void CLK_SetWdtClkSrc | ( | uint32_t | u32clksel | ) |
This API is used to select wdt clock source.
[in] | u32clksel | wdt clock selection. Could be |
void CLK_SetWwdtClkSrc | ( | uint32_t | u32clksel | ) |
This API is used to select wwdt clock source.
[in] | u32clksel | wwdt clock selection. Could be |
void CLK_SYSCLKConfig | ( | uint32_t | u32ClkSrc, |
uint32_t | freq_out | ||
) |
This function set HCLK clock source.
[in] | u32ClkSrc | is HCLK clock source. Including : |
[in] | freq_out | is output frequence clock |
uint32_t CLK_Wait3vSyncReady | ( | void | ) |
This function wait sync 3v clock locale stable.
[in] | none |
0 | clock sync is not stable |
1 | clock sync is stable |
To wait for clock ready by specified CLKSTATUS bit or timeout (~5ms)
uint32_t CLK_WaitClockReady | ( | uint32_t | u32ClkMask | ) |
This function check selected clock source status.
[in] | u32ClkMask | is selected clock source. Including |
0 | clock is not stable |
1 | clock is stable |
To wait for clock ready by specified CLKSTATUS bit or timeout (~5ms)
__STATIC_INLINE void CLK_XthStartupConfig | ( | void | ) |
Configures the xth clock.