![]() |
PDL for FM4
Version1.2
Peripheral Driverl Library for FM4
|
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... | |
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... | |
Variables | |
| stc_clk_intern_data_t | stcClkInternData |
| stc_clk_intern_data_t | stcClkInternData |
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.
| #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_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 PSW_TMR_POWT_MAX 0x07u |
Definition at line 169 of file clk.h.
Referenced by Clk_MainSetStabilizationWaitTime().
| typedef enum en_clk_apb0div en_clk_apb0div_t |
APB0 Prescaler Settings.
Enumeration of the dividers of the APB0 (PCLK0)
| typedef enum en_clk_apb1div en_clk_apb1div_t |
APB1 Prescaler Settings.
Enumeration of the dividers of the APB0 (PCLK1)
| typedef enum en_clk_apb2div en_clk_apb2div_t |
APB2 Prescaler Settings.
Enumeration of the dividers of the APB0 (PCLK2)
| typedef enum en_clk_baseclkdiv en_clk_baseclkdiv_t |
Base Clock Prescaler Settings.
Enumeration of the dividers of the Base Clock (HCLK)
| typedef enum en_clk_boost_time en_clk_boost_time_t |
Sustain and Boost Time.
| typedef enum en_clk_current en_clk_current_t |
Sustain and Boost Current.
| typedef enum en_clk_gate_peripheral en_clk_gate_peripheral_t |
Clock Gate peripheral enumerators.
| typedef enum en_clk_mcowaittime en_clk_mcowaittime_t |
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
| typedef enum en_clk_pll_src en_clk_pll_src_t |
PLL SourceClock (PINC bit of PSW_TMR)
Enumeration for the PLL Clock Source.
| typedef enum en_clk_pllowaittime en_clk_pllowaittime_t |
PLL Clock oscillation stablilization wait time.
Enumeration for the PLL Clock oscillation stabilization wait time settings
| typedef enum en_clk_reset_peripheral en_clk_reset_peripheral_t |
Reset peripheral enumerators.
| typedef enum en_clk_scowaittime en_clk_scowaittime_t |
Sub Clock oscillation stablilization wait time.
Enumeration for the Sub Clock oscillation stabilization wait time settings
| typedef enum en_clk_source en_clk_source_t |
Clock Source.
Differentiator for the different clock sources
| typedef enum en_clk_vbat_pins_ddr en_clk_vbat_pins_ddr_t |
VBAT pin direction and default values.
| typedef enum en_clk_vbat_pins en_clk_vbat_pins_t |
VBAT pin usage.
| typedef struct stc_clk_intern_data stc_clk_intern_data_t |
Datatype for holding internal data needed for CLK.
| typedef struct stc_clk_main_config stc_clk_main_config_t |
Main/PLL Clock configuration.
The Main/PLL Clock configuration settings
| typedef struct stc_clk_sub_config stc_clk_sub_config_t |
Sub Clock configuration.
The Main/PLL Clock configuration settings
| typedef struct stc_clk_vbat_config stc_clk_vbat_config_t |
Clock VBAT configuration.
The Clock VBAT configuration settings
| enum en_clk_apb0div |
| enum en_clk_apb1div |
| enum en_clk_apb2div |
| enum en_clk_baseclkdiv |
Base Clock Prescaler Settings.
Enumeration of the dividers of the Base Clock (HCLK)
| enum en_clk_boost_time |
| enum en_clk_current |
Sustain and Boost Current.
Clock Gate peripheral enumerators.
| enum en_clk_mcowaittime |
Main Clock oscillation stablilization wait time.
Enumeration for the Main Clock oscillation stabilization wait time settings
| enum en_clk_mode |
Clock Mode.
Differentiator for the different clock modes
| 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. |
| enum en_clk_pll_src |
PLL SourceClock (PINC bit of PSW_TMR)
Enumeration for the PLL Clock Source.
| Enumerator | |
|---|---|
| PllSrcClkMo |
Use Main Clock as PLL source (always available, default) |
| PllSrcClkHc |
Use HS-RC Clock as PLL source (only if available!) |
| enum en_clk_pllowaittime |
PLL Clock oscillation stablilization wait time.
Enumeration for the PLL Clock oscillation stabilization wait time settings
Reset peripheral enumerators.
| enum en_clk_scowaittime |
Sub Clock oscillation stablilization wait time.
Enumeration for the Sub Clock oscillation stabilization wait time settings
| enum en_clk_source |
Clock Source.
Differentiator for the different clock sources
| enum en_clk_vbat_pins |
| enum en_clk_vbat_pins_ddr |
| en_result_t Clk_ClockVbatInit | ( | stc_clk_vbat_config_t * | pstcConfig | ) |
Init Sub Clock with VBAT settings.
THis function initializes the sub clock with VBAT setting. It does not start the clock.
| [in] | pstcConfig | Sub Clock/VBAT configuration parameters |
| Ok | Interrupts have been set |
| ErrorInvalidParameter | If pstcConfig == NULL |
Definition at line 1281 of file clk.c.
References 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, ClkBoost125ms, ClkBoost250ms, ClkBoost50ms, ClkBoost63ms, ClkVbatGpio, ClkVbatGpioOsc, ClkVbatInput, ClkVbatOsc, ClkVbatOutputH, ClkVbatOutputL, stc_clk_vbat_config::enClkBoostCurrent, stc_clk_vbat_config::enClkBoostTime, 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, ErrorInvalidParameter, FALSE, Ok, PDL_ZERO_STRUCT, TRUE, and stc_clk_vbat_config::u8VbClockDiv.
| en_result_t Clk_DisableMainClock | ( | void | ) |
Disable Main Clock.
This function easily disables the Main Clock. No configuration is needed.
| Ok | Main 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().

| en_result_t Clk_DisablePllClock | ( | void | ) |
Disable PLL Clock.
This function easily disables the PLL Clock. No configuration is needed.
| Ok | PLL 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().

| en_result_t Clk_DisableSubClock | ( | void | ) |
Disable Sub Clock.
This function easily disables the Sub Clock. No configuration is needed.
| Ok | Sub 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().

| 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.
| Ok | Main 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.
| Ok | Main Clock enabled |
| ErrorInvalidParameter | PLL settings wrong, pstcConfigMain == NULL |
| ErrorOperationInProgress | PLL 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.
| Ok | Sub Clock enabled |
| ErrorTimeout | Data 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.
| [out] | pstcConfig | Clock configuration parameters |
| Ok | Main and PLL Clock configuration has been set |
| ErrorInvalidParameter | If pstcConfig == NULL |
| ErrorInvalidMode | Illegal 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().

| en_result_t Clk_MainOscillatorReady | ( | void | ) |
Main Oscillation Ready?
This function checks the availability of a stable Main Clock.
| Ok | Main Clock stabilized |
| ErrorNotReady | Main 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.
| [in] | pstcConfig | Clock configuration parameters |
| Ok | Time set |
| ErrorInvalidParameter | pstcConfig == 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.
| enPeripheral | Enumerator of a peripheral, see en_clk_reset_peripheral_t for details |
| Ok | Peripheral clock enabled |
| ErrorInvalidParameter | Peripheral 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.
| enPeripheral | Enumerator of a peripheral, see en_clk_gate_peripheral_t for details |
| Ok | Peripheral clock disabled |
| ErrorInvalidParameter | Peripheral 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.
| enPeripheral | Enumerator of a peripheral, see en_clk_gate_peripheral_t for details |
| Ok | Peripheral clock enabled |
| ErrorInvalidParameter | Peripheral 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.
| enPeripheral | Enumerator of a peripheral, see en_clk_gate_peripheral_t for details |
| TRUE | Peripheral clock enabled |
| FALSE | Peripheral 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.
| enPeripheral | Enumerator of a peripheral, see en_clk_reset_peripheral_t for details |
| Ok | Peripheral clock enabled |
| ErrorInvalidParameter | Peripheral 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.
| Ok | PLL Clock stabilized |
| ErrorNotReady | PLL Clock not stabilized yet |
Definition at line 841 of file clk.c.
References ErrorNotReady, and Ok.
| en_result_t Clk_RequestVccPowerDown | ( | void | ) |
| en_result_t Clk_SetDividers | ( | stc_clk_main_config_t * | pstcConfig | ) |
Set Clock Dividers.
This function sets the clock dividers.
| [in] | pstcConfig | Clock configuration parameters |
| Ok | Dividers set |
| ErrorInvalidParameter | pstcConfig == 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
| [in] | pstcConfigMain | Main/PLL Clock configuration parameters |
| [in] | pstcConfigSub | Sub Clock configuration parameters |
| [in] | bTouchNvic | TRUE = Touch NVIC registers, FALSE = Do not touch NVIC registers |
| Ok | Interrupts have been set |
| ErrorInvalidParameter | If 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.
| [in] | pstcConfig | Clock configuration parameters |
| Ok | Clock mode set |
| ErrorInvalidParameter | pstcConfig == 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().

| 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.
| [in] | pstcConfigMain | Main/PLL Clock configuration parameters |
| [in] | pstcConfigSub | Sub Clock configuration parameters |
| Ok | Clock source set |
| ErrorInvalidParameter | pstcConfig == NULL or Illegal mode |
| ErrorInvalidMode | Clock 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.

| en_result_t Clk_SubGetParameters | ( | stc_clk_sub_config_t * | pstcConfig | ) |
Get current Sub Clock parameters.
| [out] | pstcConfig | Clock configuration parameters |
| Ok | Sub Clock configuration has been set |
| ErrorInvalidParameter | If pstcConfig == NULL |
| ErrorInvalidMode | Illegal 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().

| en_result_t Clk_SubOscillatorReady | ( | void | ) |
Sub Oscillation Ready?
This function checks the availability of a stable Sub Clock.
| Ok | Sub Clock stabilized |
| ErrorNotReady | Sub 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.
| [in] | pstcConfig | Clock configuration parameters |
| Ok | Time set |
| ErrorInvalidParameter | pstcConfig == 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.
| Ok | HCLK is High Speed CR Clock oscillation |
Definition at line 2461 of file clk.c.
References Ok.
Referenced by Lpm_SetHsCrSleep(), and Lpm_SetHsCrTimer().

| en_result_t Clk_SwitchToHsCrPllClock | ( | void | ) |
Switch to High Speed CR PLL Clock.
This function sets HCLK to High Speed CR Pll Clock oscillation.
| Ok | HCLK is High Speed CR Pll Clock oscillation |
| ErrorInvalidMode | High Speed CR Pll Clock not available or not enabled |
| en_result_t Clk_SwitchToLsCrClock | ( | void | ) |
Switch to Low Speed CR Clock.
This function sets HCLK to Low Speed CR Clock oscillation.
| Ok | HCLK is Low Speed CR Clock oscillation |
Definition at line 2446 of file clk.c.
References Ok.
Referenced by Lpm_SetLsCrSleep(), and Lpm_SetLsCrTimer().

| en_result_t Clk_SwitchToMainClock | ( | void | ) |
Switch to Main Clock.
This function sets HCLK to Main Clock oscillation.
| Ok | HCLK is Main Clock oscillation |
| ErrorInvalidMode | Main clock not available or not enabled |
| ErrorNotReady | Main 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().

| 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.
| Ok | HCLK is Main Clock PLL oscillation |
| ErrorInvalidMode | Main/PLL clock not available or not enabled |
| ErrorNotReady | Main/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.
| Ok | HCLK is Sub Clock oscillation |
| ErrorInvalidMode | Sub 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().

| en_result_t Clk_VbatGetParameters | ( | stc_clk_vbat_config_t * | pstcConfig | ) |
Get current VBAT parameters.
| [out] | pstcConfig | Clock configuration parameters |
| Ok | VBAT configuration has been set |
| ErrorInvalidParameter | If pstcConfig == NULL |
| ErrorInvalidMode | Illegal 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.
| [in] | enSource | Clock Source to be checked |
| [in] | u32MaxTimeOut | Time out counter start value |
| Ok | Clock Source ready |
| ErrorTimeout | Clock Source not ready within time out count |
| ErrorInvalidParameter | Not 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().

| 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.).
| [in] | u32MaxTimeOut | Time out counter start value |
| Ok | Clock stabilized |
| ErrorTimeout | Clock not stabilized after timeout count |
Definition at line 687 of file clk.c.
References ErrorTimeout, Ok, and PDL_WAIT_LOOP_HOOK().

| 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).
| [in] | u32MaxTimeOut | Time out counter start value |
| Ok | Clock stabilized |
| ErrorTimeout | Clock not stabilized after timeout count |
Definition at line 717 of file clk.c.
References ErrorTimeout, Ok, and PDL_WAIT_LOOP_HOOK().

| 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).
| [in] | u32MaxTimeOut | Time out counter start value |
| Ok | Clock stabilized |
| ErrorTimeout | Clock not stabilized after timeout count |
Definition at line 1633 of file clk.c.
References ErrorTimeout, Ok, and PDL_WAIT_LOOP_HOOK().

| void ClkIrqHandler | ( | void | ) |
Clock Stabilization Interrupt Handler.
Definition at line 102 of file clk.c.
References FM4_INT_CLR_MCSC_BITPOS, FM4_INT_CLR_PCSC_BITPOS, FM4_INT_CLR_SCSC_BITPOS, FM4_INT_STR_MCSI_BITPOS, FM4_INT_STR_PCSI_BITPOS, FM4_INT_STR_SCSI_BITPOS, stc_clk_intern_data::pfnMcoStabCb, stc_clk_intern_data::pfnPllStabCb, and stc_clk_intern_data::pfnScoStabCb.
| stc_clk_intern_data_t stcClkInternData |
| stc_clk_intern_data_t stcClkInternData |