PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
Clock Functions (CLK)

How to use the CLK module. More...

Data Structures

struct  stc_clk_intern_data
 Datatype for holding internal data needed for CLK. More...
 
struct  stc_clk_main_config
 Main/PLL Clock configuration. More...
 
struct  stc_clk_sub_config
 Sub Clock configuration. More...
 
struct  stc_clk_vbat_config
 Clock VBAT configuration. More...
 

Macros

#define CLK_SUBCLK_TRANSITION_TIMEOUT   100000000u
 
#define PLLK_MAX   4u
 
#define PLLN_MAX   40u
 
#define PLLM_MAX   4u
 
#define BSC_PSR_MAX   0x06u
 
#define APBC0_PSR_MAX   0x03u
 
#define APBC1_PSR_MAX   0x03u
 
#define APBC2_PSR_MAX   0x03u
 
#define CSW_TMR_SOWT_MAX   0x0Bu
 
#define CSW_TMR_MOWT_MAX   0x0Fu
 
#define PSW_TMR_POWT_MAX   0x07u
 
#define PLL_CTL1_PLLK_MAX   ((uint8_t)PLLK_MAX)
 
#define PLL_CTL1_PLLM_MAX   ((uint8_t)PLLM_MAX)
 
#define PLL_CTL2_PLLN_MAX   ((uint8_t)PLLN_MAX)
 
#define CLK_SCB_SCR   *(volatile uint32_t*) 0xE000ED10ul
 
#define CLK_SCB_SCR_SLEEPDEEP_Position   2u
 
#define CLK_SCB_SCR_SLEEPDEEP_Mask   (1ul << CLK_SCB_SCR_SLEEPDEEP_Position)
 
#define FM4_PMD_CTL   *(volatile uint8_t*) 0x40035800ul
 
#define FM4_STB_CTL_DSTM_BITPOS   0x00000004ul
 
#define FM4_PSW_TMR_PINC_BITPOS   0x10u
 
#define FM4_INT_ENR_PCSE_BITPOS   0x04u
 
#define FM4_INT_ENR_SCSE_BITPOS   0x02u
 
#define FM4_INT_ENR_MCSE_BITPOS   0x01u
 
#define FM4_INT_STR_PCSI_BITPOS   0x04u
 
#define FM4_INT_STR_SCSI_BITPOS   0x02u
 
#define FM4_INT_STR_MCSI_BITPOS   0x01u
 
#define FM4_INT_CLR_PCSC_BITPOS   0x04u
 
#define FM4_INT_CLR_SCSC_BITPOS   0x02u
 
#define FM4_INT_CLR_MCSC_BITPOS   0x01u
 

Typedefs

typedef enum en_clk_source en_clk_source_t
 Clock Source. More...
 
typedef enum en_clk_mode en_clk_mode_t
 Clock Mode. More...
 
typedef enum en_clk_baseclkdiv en_clk_baseclkdiv_t
 Base Clock Prescaler Settings. More...
 
typedef enum en_clk_apb0div en_clk_apb0div_t
 APB0 Prescaler Settings. More...
 
typedef enum en_clk_apb1div en_clk_apb1div_t
 APB1 Prescaler Settings. More...
 
typedef enum en_clk_apb2div en_clk_apb2div_t
 APB2 Prescaler Settings. More...
 
typedef enum en_clk_scowaittime en_clk_scowaittime_t
 Sub Clock oscillation stablilization wait time. More...
 
typedef enum en_clk_mcowaittime en_clk_mcowaittime_t
 Main Clock oscillation stablilization wait time. More...
 
typedef enum en_clk_pllowaittime en_clk_pllowaittime_t
 PLL Clock oscillation stablilization wait time. More...
 
typedef enum en_clk_pll_src en_clk_pll_src_t
 PLL SourceClock (PINC bit of PSW_TMR) More...
 
typedef struct stc_clk_intern_data stc_clk_intern_data_t
 Datatype for holding internal data needed for CLK. More...
 
typedef enum en_clk_current en_clk_current_t
 Sustain and Boost Current. More...
 
typedef enum en_clk_boost_time en_clk_boost_time_t
 Sustain and Boost Time. More...
 
typedef enum en_clk_vbat_pins en_clk_vbat_pins_t
 VBAT pin usage. More...
 
typedef enum en_clk_vbat_pins_ddr en_clk_vbat_pins_ddr_t
 VBAT pin direction and default values. More...
 
typedef enum en_clk_gate_peripheral en_clk_gate_peripheral_t
 Clock Gate peripheral enumerators. More...
 
typedef enum
en_clk_reset_peripheral 
en_clk_reset_peripheral_t
 Reset peripheral enumerators. More...
 
typedef struct stc_clk_main_config stc_clk_main_config_t
 Main/PLL Clock configuration. More...
 
typedef struct stc_clk_sub_config stc_clk_sub_config_t
 Sub Clock configuration. More...
 
typedef struct stc_clk_vbat_config stc_clk_vbat_config_t
 Clock VBAT configuration. More...
 

Enumerations

enum  en_clk_source {
  ClkMain = 0,
  ClkSub = 1,
  ClkHsCr = 2,
  ClkLsCr = 3,
  ClkPll = 4,
  ClkHsCrPll = 5
}
 Clock Source. More...
 
enum  en_clk_mode {
  ClkRun = 0,
  ClkSleep = 1,
  ClkTimer = 2,
  ClkStop = 3,
  ClkRtc = 4,
  ClkDeepRtc = 5,
  ClkDeepStop = 6
}
 Clock Mode. More...
 
enum  en_clk_baseclkdiv {
  BaseClkDiv1 = 0,
  BaseClkDiv2 = 1,
  BaseClkDiv3 = 2,
  BaseClkDiv4 = 3,
  BaseClkDiv6 = 4,
  BaseClkDiv8 = 5,
  BaseClkDiv16 = 6,
  BaseClkErr = 7
}
 Base Clock Prescaler Settings. More...
 
enum  en_clk_apb0div {
  Apb0Div1 = 0,
  Apb0Div2 = 1,
  Apb0Div4 = 2,
  Apb0Div8 = 3
}
 APB0 Prescaler Settings. More...
 
enum  en_clk_apb1div {
  Apb1Div1 = 0,
  Apb1Div2 = 1,
  Apb1Div4 = 2,
  Apb1Div8 = 3
}
 APB1 Prescaler Settings. More...
 
enum  en_clk_apb2div {
  Apb2Div1 = 0,
  Apb2Div2 = 1,
  Apb2Div4 = 2,
  Apb2Div8 = 3
}
 APB2 Prescaler Settings. More...
 
enum  en_clk_scowaittime {
  ScoWaitExp10 = 0,
  ScoWaitExp11 = 1,
  ScoWaitExp12 = 2,
  ScoWaitExp13 = 3,
  ScoWaitExp14 = 4,
  ScoWaitExp15 = 5,
  ScoWaitExp16 = 6,
  ScoWaitExp17 = 7,
  ScoWaitExp18 = 8,
  ScoWaitExp19 = 9,
  ScoWaitExp20 = 10,
  ScoWaitExp21 = 11,
  ScoWaitErr = 12
}
 Sub Clock oscillation stablilization wait time. More...
 
enum  en_clk_mcowaittime {
  McoWaitExp11 = 0,
  McoWaitExp15 = 1,
  McoWaitExp16 = 2,
  McoWaitExp17 = 3,
  McoWaitExp18 = 4,
  McoWaitExp19 = 5,
  McoWaitExp110 = 6,
  McoWaitExp111 = 7,
  McoWaitExp112 = 8,
  McoWaitExp113 = 9,
  McoWaitExp114 = 10,
  McoWaitExp115 = 11,
  McoWaitExp117 = 12,
  McoWaitExp119 = 13,
  McoWaitExp121 = 14,
  McoWaitExp123 = 15
}
 Main Clock oscillation stablilization wait time. More...
 
enum  en_clk_pllowaittime {
  PlloWaitExp19 = 0,
  PlloWaitExp110 = 1,
  PlloWaitExp111 = 2,
  PlloWaitExp112 = 3,
  PlloWaitExp113 = 4,
  PlloWaitExp114 = 5,
  PlloWaitExp115 = 6,
  PlloWaitExp116 = 7
}
 PLL Clock oscillation stablilization wait time. More...
 
enum  en_clk_pll_src {
  PllSrcClkMo = 0,
  PllSrcClkHc = 123
}
 PLL SourceClock (PINC bit of PSW_TMR) More...
 
enum  en_clk_current {
  Clk0nA = 0,
  Clk135nA = 1,
  Clk195nA = 2,
  Clk385nA = 3,
  Clk445nA = 4,
  Clk510nA = 5,
  ClkErrorCurrent = 6
}
 Sustain and Boost Current. More...
 
enum  en_clk_boost_time {
  ClkBoost50ms = 0,
  ClkBoost63ms = 1,
  ClkBoost125ms = 2,
  ClkBoost250ms = 3
}
 Sustain and Boost Time. More...
 
enum  en_clk_vbat_pins {
  ClkVbatGpio = 0,
  ClkVbatOsc = 1,
  ClkVbatGpioOsc = 2
}
 VBAT pin usage. More...
 
enum  en_clk_vbat_pins_ddr {
  ClkVbatInput = 0,
  ClkVbatOutputL = 1,
  ClkVbatOutputH = 2
}
 VBAT pin direction and default values. More...
 
enum  en_clk_gate_peripheral {
  ClkGateGpio = 0,
  ClkGateExtif = 1,
  ClkGateDma = 2,
  ClkGateAdc0 = 3,
  ClkGateAdc1 = 4,
  ClkGateAdc2 = 5,
  ClkGateAdc3 = 6,
  ClkGateMfs0 = 7,
  ClkGateMfs1 = 8,
  ClkGateMfs2 = 9,
  ClkGateMfs3 = 10,
  ClkGateMfs4 = 11,
  ClkGateMfs5 = 12,
  ClkGateMfs6 = 13,
  ClkGateMfs7 = 14,
  ClkGateMfs8 = 15,
  ClkGateMfs9 = 16,
  ClkGateMfs10 = 17,
  ClkGateMfs11 = 18,
  ClkGateMfs12 = 19,
  ClkGateMfs13 = 20,
  ClkGateMfs14 = 21,
  ClkGateMfs15 = 22,
  ClkGateQprc0 = 23,
  ClkGateQprc1 = 24,
  ClkGateQprc2 = 25,
  ClkGateQprc3 = 26,
  ClkGateMft0 = 27,
  ClkGateMft1 = 28,
  ClkGateMft2 = 29,
  ClkGateMft3 = 30,
  ClkGateBt0 = 31,
  ClkGateBt4 = 32,
  ClkGateBt8 = 33,
  ClkGateBt12 = 34,
  ClkGateSdIf = 35,
  ClkGateCan0 = 36,
  ClkGateCan1 = 37,
  ClkGateUsb0 = 38,
  ClkGateUsb1 = 39
}
 Clock Gate peripheral enumerators. More...
 
enum  en_clk_reset_peripheral {
  ClkResetExtif = 1,
  ClkResetDma = 2,
  ClkResetAdc0 = 3,
  ClkResetAdc1 = 4,
  ClkResetAdc2 = 5,
  ClkResetAdc3 = 6,
  ClkResetMfs0 = 7,
  ClkResetMfs1 = 8,
  ClkResetMfs2 = 9,
  ClkResetMfs3 = 10,
  ClkResetMfs4 = 11,
  ClkResetMfs5 = 12,
  ClkResetMfs6 = 13,
  ClkResetMfs7 = 14,
  ClkResetMfs8 = 15,
  ClkResetMfs9 = 16,
  ClkResetMfs10 = 17,
  ClkResetMfs11 = 18,
  ClkResetMfs12 = 19,
  ClkResetMfs13 = 20,
  ClkResetMfs14 = 21,
  ClkResetMfs15 = 22,
  ClkResetQprc0 = 23,
  ClkResetQprc1 = 24,
  ClkResetQprc2 = 25,
  ClkResetQprc3 = 26,
  ClkResetMft0 = 27,
  ClkResetMft1 = 28,
  ClkResetMft2 = 29,
  ClkResetMft3 = 30,
  ClkResetBt0 = 31,
  ClkResetBt4 = 32,
  ClkResetBt8 = 33,
  ClkResetBt12 = 34,
  ClkResetSdIf = 35,
  ClkResetCan0 = 36,
  ClkResetCan1 = 37,
  ClkResetUsb0 = 38,
  ClkResetUsb1 = 39
}
 Reset peripheral enumerators. More...
 

Functions

void ClkIrqHandler (void)
 Clock Stabilization Interrupt Handler. More...
 
en_result_t Clk_MainGetParameters (stc_clk_main_config_t *pstcConfig)
 Get current Main/PLL Clock parameters. More...
 
en_result_t Clk_SubGetParameters (stc_clk_sub_config_t *pstcConfig)
 Get current Sub Clock parameters. More...
 
en_result_t Clk_VbatGetParameters (stc_clk_vbat_config_t *pstcConfig)
 Get current VBAT parameters. More...
 
en_result_t Clk_SetDividers (stc_clk_main_config_t *pstcConfig)
 Set Clock Dividers. More...
 
en_result_t Clk_MainSetStabilizationWaitTime (stc_clk_main_config_t *pstcConfig)
 Set Main Oscillation Stabilization Wait Time. More...
 
en_result_t Clk_WaitForMainOscillator (uint32_t u32MaxTimeOut)
 Wait for Main Oscillation Stabilization. More...
 
en_result_t Clk_WaitForPllOscillator (uint32_t u32MaxTimeOut)
 Wait for PLL Oscillation Stabilization. More...
 
en_result_t Clk_WaitForClockSourceReady (en_clk_source_t enSource, uint32_t u32MaxTimeOut)
 Wait for Clock Mode ready (transition finished) More...
 
en_result_t Clk_MainOscillatorReady (void)
 Main Oscillation Ready? More...
 
en_result_t Clk_SubOscillatorReady (void)
 Sub Oscillation Ready? More...
 
en_result_t Clk_PllOscillatorReady (void)
 PLL Oscillation Ready? More...
 
en_result_t Clk_SetSource (stc_clk_main_config_t *pstcConfigMain, stc_clk_sub_config_t *pstcConfigSub)
 Set Clock Source. More...
 
en_result_t Clk_SetMode (stc_clk_main_config_t *pstcConfig)
 Set Clock Mode. More...
 
en_result_t Clk_DisableSubClock (void)
 Disable Sub Clock. More...
 
en_result_t Clk_EnableMainClock (void)
 Enable Main Clock. More...
 
en_result_t Clk_EnablePllClock (stc_clk_main_config_t *pstcConfigMain)
 Enable PLL Clock with parameter. More...
 
en_result_t Clk_DisableMainClock (void)
 Disable Main Clock. More...
 
en_result_t Clk_DisablePllClock (void)
 Disable PLL Clock. More...
 
en_result_t Clk_SetIrq (stc_clk_main_config_t *pstcConfigMain, stc_clk_sub_config_t *pstcConfigSub, boolean_t bTouchNvic)
 Set/Clear Clock interrupts. More...
 
en_result_t Clk_ClockVbatInit (stc_clk_vbat_config_t *pstcConfig)
 Init Sub Clock with VBAT settings. More...
 
en_result_t Clk_EnableSubClock (void)
 Enable Sub Clock. More...
 
en_result_t Clk_SubSetStabilizationWaitTime (stc_clk_sub_config_t *pstcConfig)
 Set Sub Oscillation Stabilization Wait Time. More...
 
en_result_t Clk_WaitForSubOscillator (uint32_t u32MaxTimeOut)
 Wait for Sub Oscillation Stabilization. More...
 
en_result_t Clk_RequestVccPowerDown (void)
 Request VCC Power-Down. More...
 
en_result_t Clk_PeripheralClockEnable (en_clk_gate_peripheral_t enPeripheral)
 Enables the clock gate of a peripheral. More...
 
boolean_t Clk_PeripheralGetClockState (en_clk_gate_peripheral_t enPeripheral)
 Read the clock gate state of a peripheral. More...
 
en_result_t Clk_PeripheralClockDisable (en_clk_gate_peripheral_t enPeripheral)
 Disables the clock gate of a peripheral. More...
 
en_result_t Clk_PeripheralSetReset (en_clk_reset_peripheral_t enPeripheral)
 Set reset bit a peripheral. More...
 
en_result_t Clk_PeripheralClearReset (en_clk_reset_peripheral_t enPeripheral)
 Clear reset bit a peripheral. More...
 
en_result_t Clk_SwitchToMainClock (void)
 Switch to Main Clock. More...
 
en_result_t Clk_SwitchToMainPllClock (void)
 Switch to Main PLL Clock. More...
 
en_result_t Clk_SwitchToSubClock (void)
 Switch to Sub Clock. More...
 
en_result_t Clk_SwitchToLsCrClock (void)
 Switch to Low Speed CR Clock. More...
 
en_result_t Clk_SwitchToHsCrClock (void)
 Switch to High Speed CR Clock. More...
 
en_result_t Clk_SetPllSource (stc_clk_main_config_t *pstcConfig)
 
en_result_t Clk_SwitchToHsCrPllClock (void)
 Switch to High Speed CR PLL Clock. More...
 

Variables

stc_clk_intern_data_t stcClkInternData
 
stc_clk_intern_data_t stcClkInternData
 

Detailed Description

How to use the CLK module.

Provided functions of CLK module:

This driver manages the FM4 clock settings for:

Also polling routines for the oscillation stabilization wait are provided, e.g. Clk_WaitForMainOscillator(). If this waiting/polling is not wanted in the user application, there are also function, which return the current state of the stability of a clock, e.g. Clk_MainOscillatorReady().

For Clock Mode transition a hook function is called (if specified) for making individual power saving settings between setting SLEEPDEEP and the final WFI instruction (Timer-, Sleep-, Stop modes).

Each wait function has at lest a parameter for time out counting. The value of this parameter depends on the user's wait time settings. Additionally these functions call the library's PDL_WAIT_LOOP_HOOK() function.

Note
  • After each Clock Source change Clk_WaitForClockSourceReady() with the clock source enumerator en_clk_source_t and a time out count value as parameters has to be called, if a previous waiting for stabilization was not performed.
  • If the used device supports RTC and the RTC low power modes should be used, switch PDL_RTC_AVAILABLE to PDL_ON in pdl_user.h.
  • Because the Clock interrupts are shared with other interrupts (e.g. Watch Counter), Clk_SetIrq() has an argument, whether to touch the NVIC registers or not to prevent interference with other driver parts.
  • Deep Standby Modes are only available in DSM driver module
  • The CLK driver functions may replace the System_Init() clock settings in system_mb9[ab]xyz.c. Set the definition for CLOCK_SETUP to CLOCK_SETTING_NONE in system_mb9[ab]xyz.h in this case.
  • The 'Clk_SwitchTo*' functions expect that the destination clock is enabled and stable.

Macro Definition Documentation

#define APBC0_PSR_MAX   0x03u

Definition at line 164 of file clk.h.

Referenced by Clk_SetDividers().

#define APBC1_PSR_MAX   0x03u

Definition at line 165 of file clk.h.

Referenced by Clk_SetDividers().

#define APBC2_PSR_MAX   0x03u

Definition at line 166 of file clk.h.

Referenced by Clk_SetDividers().

#define BSC_PSR_MAX   0x06u

Definition at line 163 of file clk.h.

Referenced by Clk_SetDividers().

#define CLK_SCB_SCR   *(volatile uint32_t*) 0xE000ED10ul

Definition at line 175 of file clk.h.

Referenced by Clk_SetMode().

#define CLK_SCB_SCR_SLEEPDEEP_Mask   (1ul << CLK_SCB_SCR_SLEEPDEEP_Position)

Definition at line 177 of file clk.h.

Referenced by Clk_SetMode().

#define CLK_SCB_SCR_SLEEPDEEP_Position   2u

Definition at line 176 of file clk.h.

#define CLK_SUBCLK_TRANSITION_TIMEOUT   100000000u

Definition at line 157 of file clk.h.

Referenced by Clk_EnableSubClock().

#define CSW_TMR_MOWT_MAX   0x0Fu

Definition at line 168 of file clk.h.

Referenced by Clk_MainSetStabilizationWaitTime().

#define CSW_TMR_SOWT_MAX   0x0Bu

Definition at line 167 of file clk.h.

Referenced by Clk_SubSetStabilizationWaitTime().

#define FM4_INT_CLR_MCSC_BITPOS   0x01u

Definition at line 201 of file clk.h.

Referenced by ClkIrqHandler().

#define FM4_INT_CLR_PCSC_BITPOS   0x04u

Definition at line 199 of file clk.h.

Referenced by ClkIrqHandler().

#define FM4_INT_CLR_SCSC_BITPOS   0x02u

Definition at line 200 of file clk.h.

Referenced by ClkIrqHandler().

#define FM4_INT_ENR_MCSE_BITPOS   0x01u

Definition at line 191 of file clk.h.

Referenced by Clk_SetIrq().

#define FM4_INT_ENR_PCSE_BITPOS   0x04u

Definition at line 189 of file clk.h.

Referenced by Clk_SetIrq().

#define FM4_INT_ENR_SCSE_BITPOS   0x02u

Definition at line 190 of file clk.h.

Referenced by Clk_SetIrq().

#define FM4_INT_STR_MCSI_BITPOS   0x01u

Definition at line 196 of file clk.h.

Referenced by ClkIrqHandler().

#define FM4_INT_STR_PCSI_BITPOS   0x04u

Definition at line 194 of file clk.h.

Referenced by ClkIrqHandler().

#define FM4_INT_STR_SCSI_BITPOS   0x02u

Definition at line 195 of file clk.h.

Referenced by ClkIrqHandler().

#define FM4_PMD_CTL   *(volatile uint8_t*) 0x40035800ul

Definition at line 180 of file clk.h.

Referenced by Clk_SetMode().

#define FM4_PSW_TMR_PINC_BITPOS   0x10u

Definition at line 186 of file clk.h.

Referenced by Clk_MainSetStabilizationWaitTime().

#define FM4_STB_CTL_DSTM_BITPOS   0x00000004ul

Definition at line 183 of file clk.h.

Referenced by Clk_SetMode().

#define PLL_CTL1_PLLK_MAX   ((uint8_t)PLLK_MAX)

Definition at line 170 of file clk.h.

Referenced by Clk_EnablePllClock().

#define PLL_CTL1_PLLM_MAX   ((uint8_t)PLLM_MAX)

Definition at line 171 of file clk.h.

Referenced by Clk_EnablePllClock().

#define PLL_CTL2_PLLN_MAX   ((uint8_t)PLLN_MAX)

Definition at line 172 of file clk.h.

Referenced by Clk_EnablePllClock().

#define PLLK_MAX   4u

Definition at line 159 of file clk.h.

#define PLLM_MAX   4u

Definition at line 161 of file clk.h.

#define PLLN_MAX   40u

Definition at line 160 of file clk.h.

#define PSW_TMR_POWT_MAX   0x07u

Definition at line 169 of file clk.h.

Referenced by Clk_MainSetStabilizationWaitTime().

Typedef Documentation

APB0 Prescaler Settings.

Enumeration of the dividers of the APB0 (PCLK0)

APB1 Prescaler Settings.

Enumeration of the dividers of the APB0 (PCLK1)

APB2 Prescaler Settings.

Enumeration of the dividers of the APB0 (PCLK2)

Base Clock Prescaler Settings.

Enumeration of the dividers of the Base Clock (HCLK)

Sustain and Boost Time.

Sustain and Boost Current.

Clock Gate peripheral enumerators.

Main Clock oscillation stablilization wait time.

Enumeration for the Main Clock oscillation stabilization wait time settings

typedef enum en_clk_mode en_clk_mode_t

Clock Mode.

Differentiator for the different clock modes

Note
This configuration uses together the STB_CTL register settings like in the DSM module.

PLL SourceClock (PINC bit of PSW_TMR)

Enumeration for the PLL Clock Source.

Attention
HS-RC source only available, if used device supports PLL-CLKHC setting! PINC bit availability is not checked in this driver!

PLL Clock oscillation stablilization wait time.

Enumeration for the PLL Clock oscillation stabilization wait time settings

Reset peripheral enumerators.

Sub Clock oscillation stablilization wait time.

Enumeration for the Sub Clock oscillation stabilization wait time settings

Clock Source.

Differentiator for the different clock sources

Note
The enumerated values do not correspond to the RCS/RCM bits of the clock control and status registers due to having upward compatibility, if this bit coding may change in future devices. The correct bit patterns are set by switch(en_clk_source)/case statements individually in the corresponding function(s).

VBAT pin direction and default values.

VBAT pin usage.

Datatype for holding internal data needed for CLK.

Main/PLL Clock configuration.

The Main/PLL Clock configuration settings

Sub Clock configuration.

The Main/PLL Clock configuration settings

Clock VBAT configuration.

The Clock VBAT configuration settings

Enumeration Type Documentation

APB0 Prescaler Settings.

Enumeration of the dividers of the APB0 (PCLK0)

Enumerator
Apb0Div1 

PCLK0 Division 1/1.

Apb0Div2 

PCLK0 Division 1/2.

Apb0Div4 

PCLK0 Division 1/4.

Apb0Div8 

PCLK0 Division 1/8.

Definition at line 274 of file clk.h.

APB1 Prescaler Settings.

Enumeration of the dividers of the APB0 (PCLK1)

Enumerator
Apb1Div1 

PCLK1 Division 1/1.

Apb1Div2 

PCLK1 Division 1/2.

Apb1Div4 

PCLK1 Division 1/4.

Apb1Div8 

PCLK1 Division 1/8.

Definition at line 288 of file clk.h.

APB2 Prescaler Settings.

Enumeration of the dividers of the APB0 (PCLK2)

Enumerator
Apb2Div1 

PCLK2 Division 1/1.

Apb2Div2 

PCLK2 Division 1/2.

Apb2Div4 

PCLK2 Division 1/4.

Apb2Div8 

PCLK2 Division 1/8.

Definition at line 302 of file clk.h.

Base Clock Prescaler Settings.

Enumeration of the dividers of the Base Clock (HCLK)

Enumerator
BaseClkDiv1 

HCLK Division 1/1.

BaseClkDiv2 

HCLK Division 1/2.

BaseClkDiv3 

HCLK Division 1/3.

BaseClkDiv4 

HCLK Division 1/4.

BaseClkDiv6 

HCLK Division 1/6.

BaseClkDiv8 

HCLK Division 1/8.

BaseClkDiv16 

HCLK Division 1/16.

BaseClkErr 

HCLK prohibited setting.

Definition at line 256 of file clk.h.

Sustain and Boost Time.

Enumerator
ClkBoost50ms 

Boost time 50 ms (initial value)

ClkBoost63ms 

Boost time 62.5 ms.

ClkBoost125ms 

Boost time 125 ms.

ClkBoost250ms 

Boost time 250 ms.

Definition at line 425 of file clk.h.

Sustain and Boost Current.

Enumerator
Clk0nA 

0 nA sustain/boost, not allowed, if subclock is enabled

Clk135nA 

135 nA

Clk195nA 

195 nA

Clk385nA 

385 nA

Clk445nA 

445 nA, initial value for current sustain

Clk510nA 

510 nA, initial value for current boost

ClkErrorCurrent 

Errornous setting (for read-out function)

Definition at line 410 of file clk.h.

Clock Gate peripheral enumerators.

Enumerator
ClkGateGpio 

GPIO clock gate.

ClkGateExtif 

External bus interface clock gate.

ClkGateDma 

DMA clock gate.

ClkGateAdc0 

ADC0 clock gate.

ClkGateAdc1 

ADC1 clock gate.

ClkGateAdc2 

ADC2 clock gate.

ClkGateAdc3 

ADC3 clock gate.

ClkGateMfs0 

MFS0 clock gate.

ClkGateMfs1 

MFS1 clock gate.

ClkGateMfs2 

MFS2 clock gate.

ClkGateMfs3 

MFS3 clock gate.

ClkGateMfs4 

MFS4 clock gate.

ClkGateMfs5 

MFS5 clock gate.

ClkGateMfs6 

MFS6 clock gate.

ClkGateMfs7 

MFS7 clock gate.

ClkGateMfs8 

MFS8 clock gate.

ClkGateMfs9 

MFS9 clock gate.

ClkGateMfs10 

MFS10 clock gate.

ClkGateMfs11 

MFS11 clock gate.

ClkGateMfs12 

MFS12 clock gate.

ClkGateMfs13 

MFS13 clock gate.

ClkGateMfs14 

MFS14 clock gate.

ClkGateMfs15 

MFS15 clock gate.

ClkGateQprc0 

QPRC0 clock gate.

ClkGateQprc1 

QPRC1 clock gate.

ClkGateQprc2 

QPRC2 clock gate.

ClkGateQprc3 

QPRC3 clock gate.

ClkGateMft0 

MFT0, PPG0/2/4/6 clock gate.

ClkGateMft1 

MFT1, PPG8/10/12/14 clock gate.

ClkGateMft2 

MFT2, PPG16/18/20/22 clock gate.

ClkGateMft3 

MFT3, PPG24/26/28/30 clock gate.

ClkGateBt0 

BT0/1/2/3 clock gate.

ClkGateBt4 

BT4/5/6/7 clock gate.

ClkGateBt8 

BT8/9/10/11 clock gate.

ClkGateBt12 

BT12/13/14/15 clock gate.

ClkGateSdIf 

SD Card I/F clock gate.

ClkGateCan0 

CAN0 clock gate.

ClkGateCan1 

CAN1 clock gate.

ClkGateUsb0 

USB0 clock gate.

ClkGateUsb1 

USB1 clock gate.

Definition at line 459 of file clk.h.

Main Clock oscillation stablilization wait time.

Enumeration for the Main Clock oscillation stabilization wait time settings

Enumerator
McoWaitExp11 

2^1 / F(CH) => ~500 ns (F(CH) = 4 MHz)

McoWaitExp15 

2^5 / F(CH) => ~8 us (F(CH) = 4 MHz)

McoWaitExp16 

2^6 / F(CH) => ~16 us (F(CH) = 4 MHz)

McoWaitExp17 

2^7 / F(CH) => ~32 us (F(CH) = 4 MHz)

McoWaitExp18 

2^8 / F(CH) => ~64 us (F(CH) = 4 MHz)

McoWaitExp19 

2^9 / F(CH) => ~128 us (F(CH) = 4 MHz)

McoWaitExp110 

2^10 / F(CH) => ~256 us (F(CH) = 4 MHz)

McoWaitExp111 

2^11 / F(CH) => ~512 us (F(CH) = 4 MHz)

McoWaitExp112 

2^12 / F(CH) => ~1.0 ms (F(CH) = 4 MHz)

McoWaitExp113 

2^13 / F(CH) => ~2.0 ms (F(CH) = 4 MHz)

McoWaitExp114 

2^14 / F(CH) => ~4.0 ms (F(CH) = 4 MHz)

McoWaitExp115 

2^15 / F(CH) => ~8.0 ms (F(CH) = 4 MHz)

McoWaitExp117 

2^17 / F(CH) => ~33.0 ms (F(CH) = 4 MHz)

McoWaitExp119 

2^18 / F(CH) => ~131 ms (F(CH) = 4 MHz)

McoWaitExp121 

2^21 / F(CH) => ~524 ms (F(CH) = 4 MHz)

McoWaitExp123 

2^23 / F(CH) => ~2.0 s (F(CH) = 4 MHz)

Definition at line 339 of file clk.h.

Clock Mode.

Differentiator for the different clock modes

Note
This configuration uses together the STB_CTL register settings like in the DSM module.
Enumerator
ClkRun 

Run modes.

ClkSleep 

Sleep modes.

ClkTimer 

Timer modes.

ClkStop 

Stop mode.

ClkRtc 

RTC mode.

ClkDeepRtc 

Deep Standby RTC mode.

ClkDeepStop 

Deep Standby Stop mode.

Definition at line 239 of file clk.h.

PLL SourceClock (PINC bit of PSW_TMR)

Enumeration for the PLL Clock Source.

Attention
HS-RC source only available, if used device supports PLL-CLKHC setting! PINC bit availability is not checked in this driver!
Enumerator
PllSrcClkMo 

Use Main Clock as PLL source (always available, default)

PllSrcClkHc 

Use HS-RC Clock as PLL source (only if available!)

Definition at line 387 of file clk.h.

PLL Clock oscillation stablilization wait time.

Enumeration for the PLL Clock oscillation stabilization wait time settings

Enumerator
PlloWaitExp19 

2^9 / F(CH) => ~128 us (F(CH) = 4 MHz)

PlloWaitExp110 

2^10 / F(CH) => ~256 us (F(CH) = 4 MHz)

PlloWaitExp111 

2^11 / F(CH) => ~512 us (F(CH) = 4 MHz)

PlloWaitExp112 

2^12 / F(CH) => ~1.02 ms (F(CH) = 4 MHz)

PlloWaitExp113 

2^13 / F(CH) => ~2.05 ms (F(CH) = 4 MHz)

PlloWaitExp114 

2^14 / F(CH) => ~4.10 ms (F(CH) = 4 MHz)

PlloWaitExp115 

2^15 / F(CH) => ~8.20 ms (F(CH) = 4 MHz)

PlloWaitExp116 

2^16 / F(CH) => ~16.4 ms (F(CH) = 4 MHz)

Definition at line 365 of file clk.h.

Reset peripheral enumerators.

Enumerator
ClkResetExtif 

External bus interface Reset.

ClkResetDma 

DMA Reset.

ClkResetAdc0 

ADC0 Reset.

ClkResetAdc1 

ADC1 Reset.

ClkResetAdc2 

ADC2 Reset.

ClkResetAdc3 

ADC3 Reset.

ClkResetMfs0 

MFS0 Reset.

ClkResetMfs1 

MFS1 Reset.

ClkResetMfs2 

MFS2 Reset.

ClkResetMfs3 

MFS3 Reset.

ClkResetMfs4 

MFS4 Reset.

ClkResetMfs5 

MFS5 Reset.

ClkResetMfs6 

MFS6 Reset.

ClkResetMfs7 

MFS7 Reset.

ClkResetMfs8 

MFS8 Reset.

ClkResetMfs9 

MFS9 Reset.

ClkResetMfs10 

MFS10 Reset.

ClkResetMfs11 

MFS11 Reset.

ClkResetMfs12 

MFS12 Reset.

ClkResetMfs13 

MFS13 Reset.

ClkResetMfs14 

MFS14 Reset.

ClkResetMfs15 

MFS15 Reset.

ClkResetQprc0 

QPRC0 Reset.

ClkResetQprc1 

QPRC1 Reset.

ClkResetQprc2 

QPRC2 Reset.

ClkResetQprc3 

QPRC3 Reset.

ClkResetMft0 

MFT0, PPG0/2/4/6 Reset.

ClkResetMft1 

MFT1, PPG8/10/12/14 Reset.

ClkResetMft2 

MFT2, PPG16/18/20/22 Reset.

ClkResetMft3 

MFT3, PPG24/26/28/30 Reset.

ClkResetBt0 

BT0/1/2/3 Reset.

ClkResetBt4 

BT4/5/6/7 Reset.

ClkResetBt8 

BT8/9/19/11 Reset.

ClkResetBt12 

BT12/13/14/15 Reset.

ClkResetSdIf 

SD Card I/F Reset.

ClkResetCan0 

CAN0 Reset.

ClkResetCan1 

CAN1 Reset.

ClkResetUsb0 

USB0 Reset.

ClkResetUsb1 

USB1 Reset.

Definition at line 507 of file clk.h.

Sub Clock oscillation stablilization wait time.

Enumeration for the Sub Clock oscillation stabilization wait time settings

Enumerator
ScoWaitExp10 

2^10 / F(CL) => ~10.3 ms

ScoWaitExp11 

2^11 / F(CL) => ~20.5 ms

ScoWaitExp12 

2^12 / F(CL) => ~41 ms

ScoWaitExp13 

2^13 / F(CL) => ~82 ms

ScoWaitExp14 

2^14 / F(CL) => ~164 ms

ScoWaitExp15 

2^15 / F(CL) => ~327 ms

ScoWaitExp16 

2^16 / F(CL) => ~655 ms

ScoWaitExp17 

2^17 / F(CL) => ~1.31 s

ScoWaitExp18 

2^17 / F(CL) => ~2.62 s

ScoWaitExp19 

2^17 / F(CL) => ~5.24 s

ScoWaitExp20 

2^17 / F(CL) => ~10.48 s

ScoWaitExp21 

2^17 / F(CL) => ~20.96 s

ScoWaitErr 

Prohibited Setting.

Definition at line 316 of file clk.h.

Clock Source.

Differentiator for the different clock sources

Note
The enumerated values do not correspond to the RCS/RCM bits of the clock control and status registers due to having upward compatibility, if this bit coding may change in future devices. The correct bit patterns are set by switch(en_clk_source)/case statements individually in the corresponding function(s).
Enumerator
ClkMain 

Main Clock Oscillator.

ClkSub 

Sub Clock Oscillator.

ClkHsCr 

High-Speed CR Clock Oscillator.

ClkLsCr 

Low-Speed CR Clock Oscillator.

ClkPll 

PLL Clock.

ClkHsCrPll 

High-Speed CR PLL Clock.

Definition at line 219 of file clk.h.

VBAT pin usage.

Enumerator
ClkVbatGpio 

P46 and P47 used as GPIOs.

ClkVbatOsc 

P46 and P47 as 32 KHz oscillation pins (initial value)

ClkVbatGpioOsc 

P46 is uaed as GPIO, P47 is used as clock input pin.

Definition at line 437 of file clk.h.

VBAT pin direction and default values.

Enumerator
ClkVbatInput 

VBAT pin input function.

ClkVbatOutputL 

VBAT pin output "low" function.

ClkVbatOutputH 

VBAT pin output "high" function.

Definition at line 448 of file clk.h.

Function Documentation

en_result_t Clk_DisableMainClock ( void  )

Disable Main Clock.

This function easily disables the Main Clock. No configuration is needed.

Return values
OkMain Clock disabled

Definition at line 1146 of file clk.c.

References Ok.

Referenced by Lpm_SetHsCrSleep(), Lpm_SetHsCrTimer(), Lpm_SetLsCrSleep(), Lpm_SetLsCrTimer(), Lpm_SetSubSleep(), and Lpm_SetSubTimer().

Here is the caller graph for this function:

en_result_t Clk_DisablePllClock ( void  )

Disable PLL Clock.

This function easily disables the PLL Clock. No configuration is needed.

Return values
OkPLL Clock disabled

Definition at line 1161 of file clk.c.

References Ok.

Referenced by Lpm_SetHsCrSleep(), Lpm_SetHsCrTimer(), Lpm_SetLsCrSleep(), Lpm_SetLsCrTimer(), Lpm_SetMainSleep(), Lpm_SetMainTimer(), Lpm_SetSubSleep(), and Lpm_SetSubTimer().

Here is the caller graph for this function:

en_result_t Clk_DisableSubClock ( void  )

Disable Sub Clock.

This function easily disables the Sub Clock. No configuration is needed.

Return values
OkSub Clock disabled

Definition at line 1044 of file clk.c.

References Ok.

Referenced by Lpm_SetHsCrSleep(), Lpm_SetHsCrTimer(), Lpm_SetLsCrSleep(), Lpm_SetLsCrTimer(), Lpm_SetMainSleep(), Lpm_SetMainTimer(), Lpm_SetPllSleep(), and Lpm_SetPllTimer().

Here is the caller graph for this function:

en_result_t Clk_EnableMainClock ( void  )

Enable Main Clock.

This function easily enables the Main Clock. No configuration is needed. For stabilization wait time Clk_WaitForMainOscillator() has to be called afterwards.

Return values
OkMain Clock enabled

Definition at line 1061 of file clk.c.

References Ok.

en_result_t Clk_EnablePllClock ( stc_clk_main_config_t *  pstcConfigMain)

Enable PLL Clock with parameter.

This function easily enables the PLL Clock. It uses the Pll configuration from stc_clk_main_config_t. For stabilization wait time Clk_WaitForPllOscillator() has to be called afterwards.

Return values
OkMain Clock enabled
ErrorInvalidParameterPLL settings wrong, pstcConfigMain == NULL
ErrorOperationInProgressPLL already running

Definition at line 1081 of file clk.c.

References ErrorInvalidParameter, ErrorOperationInProgress, Ok, PLL_CTL1_PLLK_MAX, PLL_CTL1_PLLM_MAX, PLL_CTL2_PLLN_MAX, stc_clk_main_config::u8PllK, stc_clk_main_config::u8PllM, and stc_clk_main_config::u8PllN.

en_result_t Clk_EnableSubClock ( void  )

Enable Sub Clock.

This function easily enables the Sub Clock. No configuration is needed. For stabilization wait time Clk_WaitForSubOscillator() has to be called afterwards.

Return values
OkSub Clock enabled
ErrorTimeoutData transition to VBAT domain failed

Definition at line 1522 of file clk.c.

References CLK_SUBCLK_TRANSITION_TIMEOUT, ErrorTimeout, and Ok.

en_result_t Clk_MainGetParameters ( stc_clk_main_config_t *  pstcConfig)

Get current Main/PLL Clock parameters.

This function sets the 'current' elements of the configuration according the main and PLL clock registers.

Note
This function overwrites any configuration. To avoid this, a second configuration structure like 'ConfigRecent' may be used.
This function does not set any hook function pointer! If this function is used to get the current main and PLL clock settings as a base for new settings, a possible hook function pointer must be set explicitly after copying the configuration!
Parameters
[out]pstcConfigClock configuration parameters
Return values
OkMain and PLL Clock configuration has been set
ErrorInvalidParameterIf pstcConfig == NULL
ErrorInvalidModeIllegal clock mode has been detected

Definition at line 168 of file clk.c.

References Apb0Div1, Apb0Div2, Apb0Div4, Apb0Div8, Apb1Div1, Apb1Div2, Apb1Div4, Apb1Div8, Apb2Div1, Apb2Div2, Apb2Div4, Apb2Div8, BaseClkDiv1, BaseClkDiv16, BaseClkDiv2, BaseClkDiv3, BaseClkDiv4, BaseClkDiv6, BaseClkDiv8, BaseClkErr, stc_clk_main_config::bEnableMainClock, stc_clk_main_config::bEnablePll, stc_clk_main_config::bMcoIrq, stc_clk_main_config::bPllIrq, ClkHsCr, ClkLsCr, ClkMain, ClkPll, ClkRun, ClkSub, stc_clk_main_config::enAPB0Div, stc_clk_main_config::enAPB1Div, stc_clk_main_config::enAPB2Div, stc_clk_main_config::enBaseClkDiv, stc_clk_main_config::enMCOWaitTime, stc_clk_main_config::enMode, stc_clk_main_config::enSource, ErrorInvalidMode, ErrorInvalidParameter, McoWaitExp11, McoWaitExp110, McoWaitExp111, McoWaitExp112, McoWaitExp113, McoWaitExp114, McoWaitExp115, McoWaitExp117, McoWaitExp119, McoWaitExp121, McoWaitExp123, McoWaitExp15, McoWaitExp16, McoWaitExp17, McoWaitExp18, McoWaitExp19, Ok, stc_clk_main_config::u8PllK, stc_clk_main_config::u8PllM, and stc_clk_main_config::u8PllN.

Referenced by Clk_SetSource(), Lpm_SetHsCrSleep(), Lpm_SetHsCrTimer(), Lpm_SetLsCrSleep(), Lpm_SetLsCrTimer(), Lpm_SetMainSleep(), Lpm_SetMainTimer(), Lpm_SetPllSleep(), Lpm_SetPllTimer(), Lpm_SetSubSleep(), and Lpm_SetSubTimer().

Here is the caller graph for this function:

en_result_t Clk_MainOscillatorReady ( void  )

Main Oscillation Ready?

This function checks the availability of a stable Main Clock.

Return values
OkMain Clock stabilized
ErrorNotReadyMain Clock not stabilized yet

Definition at line 803 of file clk.c.

References ErrorNotReady, and Ok.

en_result_t Clk_MainSetStabilizationWaitTime ( stc_clk_main_config_t *  pstcConfig)

Set Main Oscillation Stabilization Wait Time.

This function sets the stabilization wait time.

Parameters
[in]pstcConfigClock configuration parameters
Return values
OkTime set
ErrorInvalidParameterpstcConfig == NULL or Illegal timing setting

Definition at line 634 of file clk.c.

References CSW_TMR_MOWT_MAX, stc_clk_main_config::enMCOWaitTime, stc_clk_main_config::enPLLOWaitTime, stc_clk_main_config::enPllSource, ErrorInvalidParameter, FM4_PSW_TMR_PINC_BITPOS, Ok, PllSrcClkHc, and PSW_TMR_POWT_MAX.

en_result_t Clk_PeripheralClearReset ( en_clk_reset_peripheral_t  enPeripheral)

Clear reset bit a peripheral.

This function clears the corresponding bit in the MRSTn register to release a peripheral from reset state.

Parameters
enPeripheralEnumerator of a peripheral, see en_clk_reset_peripheral_t for details
Return values
OkPeripheral clock enabled
ErrorInvalidParameterPeripheral enumerator does not exist

Definition at line 2211 of file clk.c.

References ClkResetAdc0, ClkResetAdc1, ClkResetAdc2, ClkResetAdc3, ClkResetBt0, ClkResetBt12, ClkResetBt4, ClkResetBt8, ClkResetCan0, ClkResetCan1, ClkResetDma, ClkResetExtif, ClkResetMfs0, ClkResetMfs1, ClkResetMfs10, ClkResetMfs11, ClkResetMfs12, ClkResetMfs13, ClkResetMfs14, ClkResetMfs15, ClkResetMfs2, ClkResetMfs3, ClkResetMfs4, ClkResetMfs5, ClkResetMfs6, ClkResetMfs7, ClkResetMfs8, ClkResetMfs9, ClkResetMft0, ClkResetMft1, ClkResetMft2, ClkResetMft3, ClkResetQprc0, ClkResetQprc1, ClkResetQprc2, ClkResetQprc3, ClkResetSdIf, ClkResetUsb0, ClkResetUsb1, ErrorInvalidParameter, and Ok.

en_result_t Clk_PeripheralClockDisable ( en_clk_gate_peripheral_t  enPeripheral)

Disables the clock gate of a peripheral.

This function clears the corresponding bit in the CKENn register to enable the clock of a peripheral.

Parameters
enPeripheralEnumerator of a peripheral, see en_clk_gate_peripheral_t for details
Return values
OkPeripheral clock disabled
ErrorInvalidParameterPeripheral enumerator does not exist

Definition at line 1926 of file clk.c.

References ClkGateAdc0, ClkGateAdc1, ClkGateAdc2, ClkGateAdc3, ClkGateBt0, ClkGateBt12, ClkGateBt4, ClkGateBt8, ClkGateCan0, ClkGateCan1, ClkGateDma, ClkGateExtif, ClkGateGpio, ClkGateMfs0, ClkGateMfs1, ClkGateMfs10, ClkGateMfs11, ClkGateMfs12, ClkGateMfs13, ClkGateMfs14, ClkGateMfs15, ClkGateMfs2, ClkGateMfs3, ClkGateMfs4, ClkGateMfs5, ClkGateMfs6, ClkGateMfs7, ClkGateMfs8, ClkGateMfs9, ClkGateMft0, ClkGateMft1, ClkGateMft2, ClkGateMft3, ClkGateQprc0, ClkGateQprc1, ClkGateQprc2, ClkGateQprc3, ClkGateSdIf, ClkGateUsb0, ClkGateUsb1, ErrorInvalidParameter, and Ok.

en_result_t Clk_PeripheralClockEnable ( en_clk_gate_peripheral_t  enPeripheral)

Enables the clock gate of a peripheral.

This function sets the corresponding bit in the CKENn register to enable the clock of a peripheral.

Parameters
enPeripheralEnumerator of a peripheral, see en_clk_gate_peripheral_t for details
Return values
OkPeripheral clock enabled
ErrorInvalidParameterPeripheral enumerator does not exist

Definition at line 1678 of file clk.c.

References ClkGateAdc0, ClkGateAdc1, ClkGateAdc2, ClkGateAdc3, ClkGateBt0, ClkGateBt12, ClkGateBt4, ClkGateBt8, ClkGateCan0, ClkGateCan1, ClkGateDma, ClkGateExtif, ClkGateGpio, ClkGateMfs0, ClkGateMfs1, ClkGateMfs10, ClkGateMfs11, ClkGateMfs12, ClkGateMfs13, ClkGateMfs14, ClkGateMfs15, ClkGateMfs2, ClkGateMfs3, ClkGateMfs4, ClkGateMfs5, ClkGateMfs6, ClkGateMfs7, ClkGateMfs8, ClkGateMfs9, ClkGateMft0, ClkGateMft1, ClkGateMft2, ClkGateMft3, ClkGateQprc0, ClkGateQprc1, ClkGateQprc2, ClkGateQprc3, ClkGateSdIf, ClkGateUsb0, ClkGateUsb1, ErrorInvalidParameter, and Ok.

boolean_t Clk_PeripheralGetClockState ( en_clk_gate_peripheral_t  enPeripheral)

Read the clock gate state of a peripheral.

This function reads out the corresponding bit in the CKENn register.

Parameters
enPeripheralEnumerator of a peripheral, see en_clk_gate_peripheral_t for details
Return values
TRUEPeripheral clock enabled
FALSEPeripheral clock not enabled, peripheral not existing

Definition at line 1822 of file clk.c.

References ClkGateAdc0, ClkGateAdc1, ClkGateAdc2, ClkGateAdc3, ClkGateBt0, ClkGateBt12, ClkGateBt4, ClkGateBt8, ClkGateCan0, ClkGateCan1, ClkGateDma, ClkGateExtif, ClkGateGpio, ClkGateMfs0, ClkGateMfs1, ClkGateMfs10, ClkGateMfs11, ClkGateMfs12, ClkGateMfs13, ClkGateMfs14, ClkGateMfs15, ClkGateMfs2, ClkGateMfs3, ClkGateMfs4, ClkGateMfs5, ClkGateMfs6, ClkGateMfs7, ClkGateMfs8, ClkGateMfs9, ClkGateMft0, ClkGateMft1, ClkGateMft2, ClkGateMft3, ClkGateQprc0, ClkGateQprc1, ClkGateQprc2, ClkGateQprc3, ClkGateSdIf, ClkGateUsb0, ClkGateUsb1, FALSE, and TRUE.

en_result_t Clk_PeripheralSetReset ( en_clk_reset_peripheral_t  enPeripheral)

Set reset bit a peripheral.

This function sets the corresponding bit in the MRSTn register to set a peripheral in reset state.

Parameters
enPeripheralEnumerator of a peripheral, see en_clk_reset_peripheral_t for details
Return values
OkPeripheral clock enabled
ErrorInvalidParameterPeripheral enumerator does not exist

Definition at line 2070 of file clk.c.

References ClkResetAdc0, ClkResetAdc1, ClkResetAdc2, ClkResetAdc3, ClkResetBt0, ClkResetBt12, ClkResetBt4, ClkResetBt8, ClkResetCan0, ClkResetCan1, ClkResetDma, ClkResetExtif, ClkResetMfs0, ClkResetMfs1, ClkResetMfs10, ClkResetMfs11, ClkResetMfs12, ClkResetMfs13, ClkResetMfs14, ClkResetMfs15, ClkResetMfs2, ClkResetMfs3, ClkResetMfs4, ClkResetMfs5, ClkResetMfs6, ClkResetMfs7, ClkResetMfs8, ClkResetMfs9, ClkResetMft0, ClkResetMft1, ClkResetMft2, ClkResetMft3, ClkResetQprc0, ClkResetQprc1, ClkResetQprc2, ClkResetQprc3, ClkResetSdIf, ClkResetUsb0, ClkResetUsb1, ErrorInvalidParameter, and Ok.

en_result_t Clk_PllOscillatorReady ( void  )

PLL Oscillation Ready?

This function checks the availability of a stable PLL Clock.

Return values
OkPLL Clock stabilized
ErrorNotReadyPLL Clock not stabilized yet

Definition at line 841 of file clk.c.

References ErrorNotReady, and Ok.

en_result_t Clk_RequestVccPowerDown ( void  )

Request VCC Power-Down.

This function sets the 32 kHz oscillation control disable of the RTC.

Return values
OkDisable set

Definition at line 1658 of file clk.c.

References Ok.

en_result_t Clk_SetDividers ( stc_clk_main_config_t *  pstcConfig)

Set Clock Dividers.

This function sets the clock dividers.

Note
It is strongly recommended to disable any resource of its corresponding bus, if the bus division setting is changed! Malfunction of the resources may result (i.e. wrong baud rates, lost data, etc.).
Do not access any of the resource registers, if the corresponding resource's bus is disabled! An immediate bus fault exception will occur in this case!
Parameters
[in]pstcConfigClock configuration parameters
Return values
OkDividers set
ErrorInvalidParameterpstcConfig == NULL or Illegal divider setting

Definition at line 569 of file clk.c.

References APBC0_PSR_MAX, APBC1_PSR_MAX, APBC2_PSR_MAX, stc_clk_main_config::bAPB1Disable, stc_clk_main_config::bAPB2Disable, BSC_PSR_MAX, stc_clk_main_config::enAPB0Div, stc_clk_main_config::enAPB1Div, stc_clk_main_config::enAPB2Div, stc_clk_main_config::enBaseClkDiv, ErrorInvalidParameter, and Ok.

en_result_t Clk_SetIrq ( stc_clk_main_config_t *  pstcConfigMain,
stc_clk_sub_config_t *  pstcConfigSub,
boolean_t  bTouchNvic 
)

Set/Clear Clock interrupts.

This function enables or disables the clock stabilization interrupts according configuration

Parameters
[in]pstcConfigMainMain/PLL Clock configuration parameters
[in]pstcConfigSubSub Clock configuration parameters
[in]bTouchNvicTRUE = Touch NVIC registers, FALSE = Do not touch NVIC registers
Return values
OkInterrupts have been set
ErrorInvalidParameterIf pstcConfig == NULL

Definition at line 1184 of file clk.c.

References stc_clk_main_config::bMcoIrq, stc_clk_main_config::bPllIrq, stc_clk_sub_config::bScoIrq, ErrorInvalidParameter, FM4_INT_ENR_MCSE_BITPOS, FM4_INT_ENR_PCSE_BITPOS, FM4_INT_ENR_SCSE_BITPOS, Ok, PDL_DEFAULT_INTERRUPT_LEVEL, PDL_IRQ_LEVEL_CAN0, stc_clk_intern_data::pfnMcoStabCb, stc_clk_main_config::pfnMcoStabCb, stc_clk_intern_data::pfnPllStabCb, stc_clk_main_config::pfnPllStabCb, stc_clk_intern_data::pfnScoStabCb, stc_clk_sub_config::pfnScoStabCb, and TRUE.

en_result_t Clk_SetMode ( stc_clk_main_config_t *  pstcConfig)

Set Clock Mode.

This function sets the clock mode and performs the transition. For individual settings (such as USB and CAN low power configuration) a hook function is called after setting SLEEPDEEP to 1 and final WFI instruction. This function is only called, if the function pointer is unequal to NULL. Additionally the ports will go into Hi-Z state, if stc_clk_config_t::bPortHiZState is TRUE.

Parameters
[in]pstcConfigClock configuration parameters
Return values
OkClock mode set
ErrorInvalidParameterpstcConfig == NULL or Illegal mode

Definition at line 945 of file clk.c.

References stc_clk_main_config::bLpmPortHiZState, CLK_SCB_SCR, CLK_SCB_SCR_SLEEPDEEP_Mask, ClkDeepRtc, ClkDeepStop, ClkRtc, ClkRun, ClkSleep, ClkStop, ClkTimer, stc_clk_main_config::enMode, ErrorInvalidParameter, FM4_PMD_CTL, FM4_STB_CTL_DSTM_BITPOS, Ok, stc_clk_main_config::pfnHook, and TRUE.

Referenced by Lpm_SetDeepRtcMode(), Lpm_SetDeepStopMode(), Lpm_SetHsCrSleep(), Lpm_SetHsCrTimer(), Lpm_SetLsCrSleep(), Lpm_SetLsCrTimer(), Lpm_SetMainSleep(), Lpm_SetMainTimer(), Lpm_SetPllSleep(), Lpm_SetPllTimer(), Lpm_SetRtcMode(), Lpm_SetStopMode(), Lpm_SetSubSleep(), and Lpm_SetSubTimer().

Here is the caller graph for this function:

en_result_t Clk_SetPllSource ( stc_clk_main_config_t *  pstcConfig)
en_result_t Clk_SetSource ( stc_clk_main_config_t *  pstcConfigMain,
stc_clk_sub_config_t *  pstcConfigSub 
)

Set Clock Source.

This function sets the clock source and performs transition, if wanted.

Parameters
[in]pstcConfigMainMain/PLL Clock configuration parameters
[in]pstcConfigSubSub Clock configuration parameters
Return values
OkClock source set
ErrorInvalidParameterpstcConfig == NULL or Illegal mode
ErrorInvalidModeClock setting not possible

Definition at line 864 of file clk.c.

References Clk_MainGetParameters(), Clk_SubGetParameters(), ClkHsCr, ClkLsCr, ClkMain, ClkPll, ClkSub, stc_clk_main_config::enSource, ErrorInvalidParameter, Ok, and TRUE.

Here is the call graph for this function:

en_result_t Clk_SubGetParameters ( stc_clk_sub_config_t *  pstcConfig)

Get current Sub Clock parameters.

Note
This function overwrites any configuration. To avoid this, a second configuration structure like 'ConfigRecent' may be used.
This function does not set any hook function pointer! If this function is used to get the current sub clock settings as a base for new settings, a possible hook function pointer must be set explicitly after copying the configuration!
Parameters
[out]pstcConfigClock configuration parameters
Return values
OkSub Clock configuration has been set
ErrorInvalidParameterIf pstcConfig == NULL
ErrorInvalidModeIllegal clock mode has been detected

Definition at line 327 of file clk.c.

References stc_clk_sub_config::bScoIrq, stc_clk_sub_config::enSCOWaitTime, Ok, ScoWaitErr, ScoWaitExp10, ScoWaitExp11, ScoWaitExp12, ScoWaitExp13, ScoWaitExp14, ScoWaitExp15, ScoWaitExp16, ScoWaitExp18, ScoWaitExp19, ScoWaitExp20, and ScoWaitExp21.

Referenced by Clk_SetSource().

Here is the caller graph for this function:

en_result_t Clk_SubOscillatorReady ( void  )

Sub Oscillation Ready?

This function checks the availability of a stable Sub Clock.

Return values
OkSub Clock stabilized
ErrorNotReadySub Clock not stabilized yet

Definition at line 822 of file clk.c.

References ErrorNotReady, and Ok.

en_result_t Clk_SubSetStabilizationWaitTime ( stc_clk_sub_config_t *  pstcConfig)

Set Sub Oscillation Stabilization Wait Time.

This function sets the stabilization wait time.

Parameters
[in]pstcConfigClock configuration parameters
Return values
OkTime set
ErrorInvalidParameterpstcConfig == NULL or Illegal timing setting

Definition at line 1558 of file clk.c.

References CSW_TMR_SOWT_MAX, stc_clk_sub_config::enSCOWaitTime, ErrorInvalidParameter, Ok, ScoWaitExp10, ScoWaitExp11, ScoWaitExp12, ScoWaitExp13, ScoWaitExp14, ScoWaitExp15, ScoWaitExp16, ScoWaitExp17, ScoWaitExp18, ScoWaitExp19, ScoWaitExp20, and ScoWaitExp21.

en_result_t Clk_SwitchToHsCrClock ( void  )

Switch to High Speed CR Clock.

This function sets HCLK to High Speed CR Clock oscillation.

Return values
OkHCLK is High Speed CR Clock oscillation

Definition at line 2461 of file clk.c.

References Ok.

Referenced by Lpm_SetHsCrSleep(), and Lpm_SetHsCrTimer().

Here is the caller graph for this function:

en_result_t Clk_SwitchToHsCrPllClock ( void  )

Switch to High Speed CR PLL Clock.

This function sets HCLK to High Speed CR Pll Clock oscillation.

Note
If PLL is enabled by this function no wait for stabilization is performed.
Return values
OkHCLK is High Speed CR Pll Clock oscillation
ErrorInvalidModeHigh Speed CR Pll Clock not available or not enabled

Definition at line 2483 of file clk.c.

References FALSE, and Ok.

en_result_t Clk_SwitchToLsCrClock ( void  )

Switch to Low Speed CR Clock.

This function sets HCLK to Low Speed CR Clock oscillation.

Return values
OkHCLK is Low Speed CR Clock oscillation

Definition at line 2446 of file clk.c.

References Ok.

Referenced by Lpm_SetLsCrSleep(), and Lpm_SetLsCrTimer().

Here is the caller graph for this function:

en_result_t Clk_SwitchToMainClock ( void  )

Switch to Main Clock.

This function sets HCLK to Main Clock oscillation.

Return values
OkHCLK is Main Clock oscillation
ErrorInvalidModeMain clock not available or not enabled
ErrorNotReadyMain clock enabled but oscillation not stable yet

Definition at line 2350 of file clk.c.

References ErrorInvalidMode, ErrorNotReady, FALSE, and Ok.

Referenced by Lpm_SetMainSleep(), and Lpm_SetMainTimer().

Here is the caller graph for this function:

en_result_t Clk_SwitchToMainPllClock ( void  )

Switch to Main PLL Clock.

This function sets HCLK to Main PLL Clock oscillation. The function expects enabled Main and PLL clock oscillation.

Note
By transition from HS-CR PLL clock mode, no waiting stabilization time is done for Main Clock PLL mode.
Return values
OkHCLK is Main Clock PLL oscillation
ErrorInvalidModeMain/PLL clock not available or not enabled
ErrorNotReadyMain/PLL clock enabled but oscillation not stable yet

Definition at line 2382 of file clk.c.

References ErrorInvalidMode, ErrorNotReady, FALSE, and Ok.

en_result_t Clk_SwitchToSubClock ( void  )

Switch to Sub Clock.

This function sets HCLK to Sub Clock oscillation.

Return values
OkHCLK is Sub Clock oscillation
ErrorInvalidModeSub clock not available or not enabled

Definition at line 2421 of file clk.c.

References ErrorInvalidMode, ErrorNotReady, FALSE, and Ok.

Referenced by Lpm_SetSubSleep(), and Lpm_SetSubTimer().

Here is the caller graph for this function:

en_result_t Clk_VbatGetParameters ( stc_clk_vbat_config_t *  pstcConfig)

Get current VBAT parameters.

Note
This function overwrites any configuration. To avoid this, a second configuration structure like 'ConfigRecent' may be used.
This function does not set any hook function pointer! If this function is used to get the current VBAT settings as a base for new settings, a possible hook function pointer must be set explicitly after copying the configuration!
Parameters
[out]pstcConfigClock configuration parameters
Return values
OkVBAT configuration has been set
ErrorInvalidParameterIf pstcConfig == NULL
ErrorInvalidModeIllegal VBAT mode has been detected

Definition at line 394 of file clk.c.

References stc_clk_vbat_config::bLinkClock, stc_clk_vbat_config::bVbP46Peripheral, stc_clk_vbat_config::bVbP46PullUp, stc_clk_vbat_config::bVbP47Peripheral, stc_clk_vbat_config::bVbP47PullUp, stc_clk_vbat_config::bVbP48OpenDrain, stc_clk_vbat_config::bVbP48Peripheral, stc_clk_vbat_config::bVbP48PullUp, stc_clk_vbat_config::bVbP49OpenDrain, stc_clk_vbat_config::bVbP49Peripheral, stc_clk_vbat_config::bVbP49PullUp, Clk0nA, Clk135nA, Clk195nA, Clk385nA, Clk445nA, Clk510nA, ClkErrorCurrent, ClkVbatGpio, ClkVbatGpioOsc, ClkVbatInput, ClkVbatOsc, ClkVbatOutputH, ClkVbatOutputL, stc_clk_vbat_config::enClkBoostCurrent, stc_clk_vbat_config::enClkSustainCurrent, stc_clk_vbat_config::enVbatPins, stc_clk_vbat_config::enVbP46InOut, stc_clk_vbat_config::enVbP47InOut, stc_clk_vbat_config::enVbP48InOut, stc_clk_vbat_config::enVbP49InOut, Ok, TRUE, and stc_clk_vbat_config::u8VbClockDiv.

en_result_t Clk_WaitForClockSourceReady ( en_clk_source_t  enSource,
uint32_t  u32MaxTimeOut 
)

Wait for Clock Mode ready (transition finished)

This function waits for a clock source, meaning a clock source already available or a clock source transition to be expected to be ready soon or already available. PDL_WAIT_LOOP_HOOK() is called during polling.

Note
This function is not needed to be called, if the user has performed the stabilization wait time for the desired source clock before. For safety reasons, this function can be called anyhow with a small timeout count (<<10).
Parameters
[in]enSourceClock Source to be checked
[in]u32MaxTimeOutTime out counter start value
Return values
OkClock Source ready
ErrorTimeoutClock Source not ready within time out count
ErrorInvalidParameterNot a valid Clock Mode to be checked

Definition at line 754 of file clk.c.

References ClkHsCr, ClkLsCr, ClkMain, ClkPll, ClkSub, ErrorInvalidParameter, ErrorTimeout, Ok, and PDL_WAIT_LOOP_HOOK().

Here is the call graph for this function:

en_result_t Clk_WaitForMainOscillator ( uint32_t  u32MaxTimeOut)

Wait for Main Oscillation Stabilization.

This function waits for the Main Oscillator stabilization via polling. PDL_WAIT_LOOP_HOOK() is called during polling. It should be called, if the system needs a stable main clock (i.e. for communication or switching to PLL clock, etc.).

Parameters
[in]u32MaxTimeOutTime out counter start value
Return values
OkClock stabilized
ErrorTimeoutClock not stabilized after timeout count

Definition at line 687 of file clk.c.

References ErrorTimeout, Ok, and PDL_WAIT_LOOP_HOOK().

Here is the call graph for this function:

en_result_t Clk_WaitForPllOscillator ( uint32_t  u32MaxTimeOut)

Wait for PLL Oscillation Stabilization.

This function waits for the PLL Oscillator stabilization via polling. PDL_WAIT_LOOP_HOOK() is called during polling. It should be called, if the system needs a stable PLL clock (i.e. for communication).

Parameters
[in]u32MaxTimeOutTime out counter start value
Return values
OkClock stabilized
ErrorTimeoutClock not stabilized after timeout count

Definition at line 717 of file clk.c.

References ErrorTimeout, Ok, and PDL_WAIT_LOOP_HOOK().

Here is the call graph for this function:

en_result_t Clk_WaitForSubOscillator ( uint32_t  u32MaxTimeOut)

Wait for Sub Oscillation Stabilization.

This function waits for the Sub Oscillator stabilization via polling. PDL_WAIT_LOOP_HOOK() is called during polling. It should be called, if the system needs a stable sub clock (i.e. for communication).

Parameters
[in]u32MaxTimeOutTime out counter start value
Return values
OkClock stabilized
ErrorTimeoutClock not stabilized after timeout count

Definition at line 1633 of file clk.c.

References ErrorTimeout, Ok, and PDL_WAIT_LOOP_HOOK().

Here is the call graph for this function:

Variable Documentation

stc_clk_intern_data_t stcClkInternData

Definition at line 78 of file clk.c.

stc_clk_intern_data_t stcClkInternData

Definition at line 78 of file clk.c.