![]() |
PDL for FM0+
Version1.0
Peripheral Driverl Library for FM0+
|
Provided CLK module functions:
Clk_Init() initializes the system clock according to the configuration of the structure type stc_clk_config_t. This function provides another method to configure system clock beside the CMSIS way.
Clk_EnableHscr() enables the high speed CR and Clk_DisableHscr() disables high speed CR.
Clk_EnableMainClock() enables main clock and Clk_DisableMainClock() disables main clock.
Clk_EnableSubClock() enables sub clock and Clk_DisableSubClock() disables sub clock.
Clk_EnablePllClock() enables PLL clock and Clk_DisablePllClock() disables PLL clock.
Clk_SetSource() set the source clock for system clock according to the the enumeration type en_clk_source_t. Before calling this function, the used clock should be enabled.
Clk_PeripheralClockEnable() enables the clock supply to the peripheral selected and Clk_PeripheralClockDisable() disables the clock supply to the peripheral selected. At default status, the clock is supplied. Clk_PeripheralGetClockState() reads the clock status of the peripheral selected.
Calling Clk_PeripheralSetReset() first and then Clk_PeripheralClearReset() can reset a peripheral.
#define FM0P_INT_CLR_MCSC_BITPOS 0x01u |
Definition at line 141 of file clk.h.
Referenced by Clk_IrqHandler().
#define FM0P_INT_CLR_PCSC_BITPOS 0x04u |
Definition at line 139 of file clk.h.
Referenced by Clk_IrqHandler().
#define FM0P_INT_CLR_SCSC_BITPOS 0x02u |
Definition at line 140 of file clk.h.
Referenced by Clk_IrqHandler().
#define FM0P_INT_ENR_MCSE_BITPOS 0x01u |
#define FM0P_INT_ENR_PCSE_BITPOS 0x04u |
#define FM0P_INT_ENR_SCSE_BITPOS 0x02u |
#define FM0P_INT_STR_MCSI_BITPOS 0x01u |
Definition at line 136 of file clk.h.
Referenced by Clk_IrqHandler().
#define FM0P_INT_STR_PCSI_BITPOS 0x04u |
Definition at line 134 of file clk.h.
Referenced by Clk_IrqHandler().
#define FM0P_INT_STR_SCSI_BITPOS 0x02u |
Definition at line 135 of file clk.h.
Referenced by Clk_IrqHandler().
#define FM0P_PSW_TMR_PINC_BITPOS 0x10u |
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_baseclkdiv en_clk_baseclkdiv_t |
Base Clock Prescaler Settings.
Enumeration of the dividers of the Base Clock (HCLK)
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 stabilization wait time.
Enumeration for the Main Clock oscillation stabilization wait time settings
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 stabilization 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 stabilization 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 struct stc_clk_config stc_clk_config_t |
Clock configuration.
The Clock configuration settings
typedef struct stc_clk_intern_data stc_clk_intern_data_t |
Datatype for holding internal data needed for CLK.
enum en_clk_apb0div |
enum en_clk_apb1div |
enum en_clk_baseclkdiv |
Base Clock Prescaler Settings.
Enumeration of the dividers of the Base Clock (HCLK)
Clock Gate peripheral enumerators.
enum en_clk_mcowaittime |
Main Clock oscillation stabilization wait time.
Enumeration for the Main Clock oscillation stabilization wait time settings
enum en_clk_pll_src |
PLL SourceClock (PINC bit of PSW_TMR)
Enumeration for the PLL Clock Source.
enum en_clk_pllowaittime |
PLL Clock oscillation stabilization wait time.
Enumeration for the PLL Clock oscillation stabilization wait time settings
Reset peripheral enumerators.
enum en_clk_scowaittime |
Sub Clock oscillation stabilization wait time.
Enumeration for the Sub Clock oscillation stabilization wait time settings
enum en_clk_source |
Clock Source.
Differentiator for the different clock sources
en_result_t Clk_DisableHscr | ( | void | ) |
en_result_t Clk_DisableMainClock | ( | void | ) |
en_result_t Clk_DisablePllClock | ( | void | ) |
en_result_t Clk_DisableSubClock | ( | void | ) |
en_result_t Clk_EnableHscr | ( | boolean_t | bBlock | ) |
Enable high speed CR.
This function easily enables the high speed CR. No configuration is needed.
bBlock | Wait until CR stability or not
|
Ok | high speed CR enabled |
en_result_t Clk_EnableMainClock | ( | boolean_t | bBlock | ) |
Enable Main Clock and wait until it is stable.
This function easily enables the Main Clock. No configuration is needed.
bBlock | Wait until Main Clock stability or not
|
Ok | Main Clock enabled |
en_result_t Clk_EnablePllClock | ( | boolean_t | bBlock | ) |
Enable PLL Clock.
This function easily enables the PLL Clock. No configuration is needed.
bBlock | Wait until PLL Clock stability or not
|
Ok | PLL Clock enabled |
en_result_t Clk_EnableSubClock | ( | boolean_t | bBlock | ) |
Enable Sub Clock.
This function easily enables the Sub Clock. No configuration is needed.
bBlock | Wait until Sub Clock stability or not
|
Ok | Sub Clock enabled |
en_result_t Clk_Init | ( | stc_clk_config_t * | pstcClk | ) |
Initialize system clock according to user configuration.
This function configues clock division, stability time, PLL setting.
[in] | pstcClk | Pointer to clock configuration structure |
Ok | Clock initialized normally |
ErrorInvalidParameter | The parameter is set to error range |
Definition at line 155 of file clk.c.
References Apb0Div1, Apb0Div2, Apb0Div4, Apb0Div8, Apb1Div1, Apb1Div2, Apb1Div4, Apb1Div8, stc_clk_config::bAPB1Disable, BaseClkDiv1, BaseClkDiv16, BaseClkDiv2, BaseClkDiv3, BaseClkDiv4, BaseClkDiv6, BaseClkDiv8, stc_clk_config::bMcoIrq, stc_clk_config::bPllIrq, stc_clk_config::bScoIrq, stc_clk_config::enAPB0Div, stc_clk_config::enAPB1Div, stc_clk_config::enBaseClkDiv, stc_clk_config::enMCOWaitTime, stc_clk_config::enPLLOWaitTime, stc_clk_config::enSCOWaitTime, ErrorInvalidParameter, Ok, stc_clk_intern_data::pfnMcoStabCb, stc_clk_config::pfnMcoStabCb, stc_clk_intern_data::pfnPllStabCb, stc_clk_config::pfnPllStabCb, stc_clk_intern_data::pfnScoStabCb, stc_clk_config::pfnScoStabCb, TRUE, stc_clk_config::u8PllK, stc_clk_config::u8PllM, and stc_clk_config::u8PllN.
void Clk_IrqHandler | ( | void | ) |
Clock Stabilization Interrupt Handler.
Definition at line 97 of file clk.c.
References FM0P_INT_CLR_MCSC_BITPOS, FM0P_INT_CLR_PCSC_BITPOS, FM0P_INT_CLR_SCSC_BITPOS, FM0P_INT_STR_MCSI_BITPOS, FM0P_INT_STR_PCSI_BITPOS, FM0P_INT_STR_SCSI_BITPOS, stc_clk_intern_data::pfnMcoStabCb, stc_clk_intern_data::pfnPllStabCb, and stc_clk_intern_data::pfnScoStabCb.
Referenced by TIM_IRQHandler().
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 1030 of file clk.c.
References ClkResetAdc0, ClkResetAdc1, ClkResetAdc2, ClkResetAdc3, ClkResetBt0, ClkResetBt12, ClkResetBt4, ClkResetBt8, ClkResetCan0, ClkResetCan1, ClkResetDma, ClkResetMfs0, ClkResetMfs1, ClkResetMfs10, ClkResetMfs11, ClkResetMfs12, ClkResetMfs13, ClkResetMfs14, ClkResetMfs15, ClkResetMfs2, ClkResetMfs3, ClkResetMfs4, ClkResetMfs5, ClkResetMfs6, ClkResetMfs7, ClkResetMfs8, ClkResetMfs9, ClkResetMft0, ClkResetMft1, ClkResetMft2, ClkResetMft3, ClkResetQprc0, ClkResetQprc1, ClkResetQprc2, ClkResetQprc3, 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 disable 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 769 of file clk.c.
References ClkGateAdc0, ClkGateAdc1, ClkGateAdc2, ClkGateAdc3, ClkGateBt0, ClkGateBt12, ClkGateBt4, ClkGateBt8, ClkGateCan0, ClkGateCan1, ClkGateDma, 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, 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 541 of file clk.c.
References ClkGateAdc0, ClkGateAdc1, ClkGateAdc2, ClkGateAdc3, ClkGateBt0, ClkGateBt12, ClkGateBt4, ClkGateBt8, ClkGateCan0, ClkGateCan1, ClkGateDma, 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, 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 673 of file clk.c.
References ClkGateAdc0, ClkGateAdc1, ClkGateAdc2, ClkGateAdc3, ClkGateBt0, ClkGateBt12, ClkGateBt4, ClkGateBt8, ClkGateCan0, ClkGateCan1, ClkGateDma, 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, 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 901 of file clk.c.
References ClkResetAdc0, ClkResetAdc1, ClkResetAdc2, ClkResetAdc3, ClkResetBt0, ClkResetBt12, ClkResetBt4, ClkResetBt8, ClkResetCan0, ClkResetCan1, ClkResetDma, ClkResetMfs0, ClkResetMfs1, ClkResetMfs10, ClkResetMfs11, ClkResetMfs12, ClkResetMfs13, ClkResetMfs14, ClkResetMfs15, ClkResetMfs2, ClkResetMfs3, ClkResetMfs4, ClkResetMfs5, ClkResetMfs6, ClkResetMfs7, ClkResetMfs8, ClkResetMfs9, ClkResetMft0, ClkResetMft1, ClkResetMft2, ClkResetMft3, ClkResetQprc0, ClkResetQprc1, ClkResetQprc2, ClkResetQprc3, ErrorInvalidParameter, and Ok.
en_result_t Clk_SetSource | ( | en_clk_source_t | enSource | ) |
Set Clock Source.
This function sets the clock source and performs transition, if wanted.
[in] | enSource | System source clock
|
Ok | Clock source set |
ErrorInvalidParameter | pstcConfig == NULL or Illegal mode |
ErrorInvalidMode | Clock setting not possible |
Definition at line 460 of file clk.c.
References ClkHsCr, ClkHsCrPll, ClkLsCr, ClkMain, ClkPll, ClkSub, ErrorInvalidMode, ErrorInvalidParameter, Ok, and TRUE.