34#if !(defined(FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL))
35#define FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL 0
45#define FSL_CLOCK_DRIVER_VERSION (MAKE_VERSION(2, 1, 2))
76#define DMAMUX_CLOCKS \
88#define RTCOSC_CLOCKS \
96 kCLOCK_PortA, kCLOCK_PortB, kCLOCK_PortC, kCLOCK_PortD, kCLOCK_PortE \
100#define LPI2C_CLOCKS \
102 kCLOCK_Lpi2c0, kCLOCK_Lpi2c1 \
106#define FLEXIO_CLOCKS \
118#define LPUART_CLOCKS \
120 kCLOCK_Lpuart0, kCLOCK_Lpuart1, kCLOCK_Lpuart2 \
130#define LPTMR_CLOCKS \
136#define ADC12_CLOCKS \
138 kCLOCK_Adc0, kCLOCK_Adc1, kCLOCK_Adc2 \
142#define LPSPI_CLOCKS \
144 kCLOCK_Lpspi0, kCLOCK_Lpspi1 \
162 kCLOCK_Cmp0, kCLOCK_Cmp1, kCLOCK_Cmp2 \
166#define FLASH_CLOCKS \
172#define SYSMPU_CLOCKS \
184#define FLEXCAN_CLOCKS \
186 kCLOCK_Flexcan0, kCLOCK_Flexcan1 \
192 kCLOCK_Ftm0, kCLOCK_Ftm1, kCLOCK_Ftm2, kCLOCK_Ftm3 \
198 kCLOCK_Pdb0, kCLOCK_Pdb1, kCLOCK_Pdb2 \
210#define LPO_CLK_FREQ 128000U
245#define kCLOCK_Osc0ErClk kCLOCK_ErClk
246#define kCLOCK_Er32kClk kCLOCK_Osc32kClk
247#define CLOCK_GetOsc0ErClkFreq CLOCK_GetErClkFreq
248#define CLOCK_GetEr32kClkFreq CLOCK_GetOsc32kClkFreq
321 OSC32_CR_ROSCEREFS_MASK,
436 SCG_SOSCCSR_SOSCCM_MASK | SCG_SOSCCSR_SOSCCMRE_MASK
602 SCG_SPLLCSR_SPLLCM_MASK | SCG_SPLLCSR_SPLLCMRE_MASK
632#if defined(__cplusplus)
643 assert((*(
volatile uint32_t *)name) & PCC_CLKCFG_PR_MASK);
645 (*(
volatile uint32_t *)name) |= PCC_CLKCFG_CGC_MASK;
655 assert((*(
volatile uint32_t *)name) & PCC_CLKCFG_PR_MASK);
657 (*(
volatile uint32_t *)name) &= ~PCC_CLKCFG_CGC_MASK;
669 assert((*(
volatile uint32_t *)name) & PCC_CLKCFG_PR_MASK);
671 return ((*(
volatile uint32_t *)name) & PCC_CLKCFG_INUSE_MASK) ? true :
false;
686 uint32_t reg = (*(
volatile uint32_t *)name);
688 assert(reg & PCC_CLKCFG_PR_MASK);
689 assert(!(reg & PCC_CLKCFG_INUSE_MASK));
691 reg = (reg & ~PCC_CLKCFG_PCS_MASK) | PCC_CLKCFG_PCS(src);
697 (*(
volatile uint32_t *)name) = reg & ~PCC_CLKCFG_CGC_MASK;
698 (*(
volatile uint32_t *)name) = reg;
785 SCG->VCCR = *(
const uint32_t *)
config;
799 SCG->RCCR = *(
const uint32_t *)
config;
813 SCG->HCCR = *(
const uint32_t *)
config;
827 *(uint32_t *)
config = SCG->CSR;
840 SCG->CLKOUTCNFG = SCG_CLKOUTCNFG_CLKOUTSEL(setting);
889 uint32_t reg = SCG->SOSCDIV;
894 reg = (reg & ~SCG_SOSCDIV_SOSCDIV2_MASK) | SCG_SOSCDIV_SOSCDIV2(divider);
897 reg = (reg & ~SCG_SOSCDIV_SOSCDIV1_MASK) | SCG_SOSCDIV_SOSCDIV1(divider);
926 return (
bool)(SCG->SOSCCSR & SCG_SOSCCSR_SOSCERR_MASK);
934 SCG->SOSCCSR |= SCG_SOSCCSR_SOSCERR_MASK;
947 uint32_t reg = SCG->SOSCCSR;
949 reg &= ~(SCG_SOSCCSR_SOSCCM_MASK | SCG_SOSCCSR_SOSCCMRE_MASK);
951 reg |= (uint32_t)mode;
963 return (
bool)(SCG->SOSCCSR & SCG_SOSCCSR_SOSCVLD_MASK);
1012 uint32_t reg = SCG->SIRCDIV;
1017 reg = (reg & ~SCG_SIRCDIV_SIRCDIV2_MASK) | SCG_SIRCDIV_SIRCDIV2(divider);
1020 reg = (reg & ~SCG_SIRCDIV_SIRCDIV1_MASK) | SCG_SIRCDIV_SIRCDIV1(divider);
1049 return (
bool)(SCG->SIRCCSR & SCG_SIRCCSR_SIRCVLD_MASK);
1097 uint32_t reg = SCG->FIRCDIV;
1102 reg = (reg & ~SCG_FIRCDIV_FIRCDIV2_MASK) | SCG_FIRCDIV_FIRCDIV2(divider);
1105 reg = (reg & ~SCG_FIRCDIV_FIRCDIV1_MASK) | SCG_FIRCDIV_FIRCDIV1(divider);
1134 return (
bool)(SCG->FIRCCSR & SCG_FIRCCSR_FIRCERR_MASK);
1142 SCG->FIRCCSR |= SCG_FIRCCSR_FIRCERR_MASK;
1152 return (
bool)(SCG->FIRCCSR & SCG_FIRCCSR_FIRCVLD_MASK);
1239 uint32_t reg = SCG->SPLLDIV;
1244 reg = (reg & ~SCG_SPLLDIV_SPLLDIV2_MASK) | SCG_SPLLDIV_SPLLDIV2(divider);
1247 reg = (reg & ~SCG_SPLLDIV_SPLLDIV1_MASK) | SCG_SPLLDIV_SPLLDIV1(divider);
1276 return (
bool)(SCG->SPLLCSR & SCG_SPLLCSR_SPLLERR_MASK);
1284 SCG->SPLLCSR |= SCG_SPLLCSR_SPLLERR_MASK;
1297 uint32_t reg = SCG->SPLLCSR;
1299 reg &= ~(SCG_SPLLCSR_SPLLCM_MASK | SCG_SPLLCSR_SPLLCMRE_MASK);
1301 reg |= (uint32_t)mode;
1313 return (
bool)(SCG->SPLLCSR & SCG_SPLLCSR_SPLLVLD_MASK);
1364#if defined(__cplusplus)
static constexpr persistent_config_s * config
_scg_firc_range
SCG fast IRC clock frequency range.
enum _clock_ip_name clock_ip_name_t
Peripheral clock name difinition used for clock gate, clock source and clock divider setting....
uint32_t CLOCK_GetSysPllMultDiv(uint32_t refFreq, uint32_t desireFreq, uint8_t *mult, uint8_t *prediv)
Calculates the MULT and PREDIV for the PLL.
_scg_async_clk
SCG asynchronous clock type.
_clock_ip_name
Peripheral clock name difinition used for clock gate, clock source and clock divider setting....
scg_async_clk_div
SCG asynchronous clock divider value.
enum _scg_sys_clk_div scg_sys_clk_div_t
SCG system clock divider value.
_scg_sirc_range
SCG slow IRC clock frequency range.
_clock_name
Clock name used to get clock frequency.
static void CLOCK_SetSysOscAsyncClkDiv(scg_async_clk_t asyncClk, scg_async_clk_div_t divider)
Set the asynchronous clock divider.
static bool CLOCK_IsSysPllValid(void)
Checks whether the system PLL clock is valid.
volatile uint32_t g_xtal32Freq
External XTAL32/EXTAL32 clock frequency.
scg_firc_trim_src_t trimSrc
static bool CLOCK_IsSysOscErr(void)
Checks whether the system OSC clock error occurs.
enum _scg_sys_clk_src scg_sys_clk_src_t
SCG system clock source.
uint32_t CLOCK_GetSysPllFreq(void)
Gets the SCG system PLL clock frequency.
uint32_t CLOCK_GetIpFreq(clock_ip_name_t name)
Gets the clock frequency for a specific IP module.
_scg_spll_src
SCG system PLL clock source.
enum _clock_name clock_name_t
Clock name used to get clock frequency.
struct _scg_firc_trim_config scg_firc_trim_config_t
SCG fast IRC clock trim configuration.
static bool CLOCK_IsSircValid(void)
Checks whether the SIRC clock is valid.
_scg_sirc_enable_mode
SIRC enable mode.
static void CLOCK_DisableClock(clock_ip_name_t name)
Disable the clock for specific IP.
void OSC32_Deinit(OSC32_Type *base)
Deinitializes OSC32.
enum _scg_spll_src scg_spll_src_t
SCG system PLL clock source.
uint32_t CLOCK_GetCoreSysClkFreq(void)
Get the core clock or system clock frequency.
_scg_status
SCG status return codes.
static void CLOCK_SetRunModeSysClkConfig(const scg_sys_clk_config_t *config)
Sets the system clock configuration for RUN mode.
uint32_t CLOCK_GetSysPllAsyncFreq(scg_async_clk_t type)
Gets the SCG asynchronous clock frequency from the system PLL.
enum _scg_firc_trim_div scg_firc_trim_div_t
SCG fast IRC trim predivided value for system OSC.
enum _scg_sys_clk scg_sys_clk_t
SCG system clock type.
enum _scg_sosc_monitor_mode scg_sosc_monitor_mode_t
SCG system OSC monitor mode.
status_t CLOCK_DeinitFirc(void)
De-initializes the SCG fast IRC.
scg_firc_trim_mode_t trimMode
static void CLOCK_SetXtal0Freq(uint32_t freq)
Sets the XTAL0 frequency based on board settings.
enum scg_async_clk_div scg_async_clk_div_t
SCG asynchronous clock divider value.
uint32_t CLOCK_GetSircFreq(void)
Gets the SCG SIRC clock frequency.
enum _clock_clkout_src clock_clkout_src_t
SCG clock out configuration (CLKOUTSEL).
uint32_t CLOCK_GetFreq(clock_name_t clockName)
Gets the clock frequency for a specific clock name.
struct _scg_sys_clk_config scg_sys_clk_config_t
SCG system clock configuration.
enum _scg_firc_trim_mode scg_firc_trim_mode_t
SCG fast IRC trim mode.
uint32_t CLOCK_GetFircFreq(void)
Gets the SCG FIRC clock frequency.
_osc32_mode
OSC32 work mode.
static void CLOCK_SetVlprModeSysClkConfig(const scg_sys_clk_config_t *config)
Sets the system clock configuration for VLPR mode.
static void CLOCK_SetIpSrc(clock_ip_name_t name, clock_ip_src_t src)
Set the clock source for specific IP module.
static void CLOCK_ClearFircErr(void)
Clears the FIRC clock error.
_scg_firc_trim_mode
SCG fast IRC trim mode.
volatile uint32_t g_xtal0Freq
External XTAL0 (OSC0/SYSOSC) clock frequency.
_scg_firc_trim_div
SCG fast IRC trim predivided value for system OSC.
enum _scg_spll_monitor_mode scg_spll_monitor_mode_t
SCG system PLL monitor mode.
enum _scg_firc_range scg_firc_range_t
SCG fast IRC clock frequency range.
static void CLOCK_SetSysOscMonitorMode(scg_sosc_monitor_mode_t mode)
Sets the system OSC monitor mode.
static bool CLOCK_IsFircValid(void)
Checks whether the FIRC clock is valid.
_scg_spll_enable_mode
SPLL enable mode.
_scg_sosc_enable_mode
OSC enable mode.
_scg_sosc_monitor_mode
SCG system OSC monitor mode.
enum _clock_ip_src clock_ip_src_t
Clock source for peripherals that support various clock selections.
enum _scg_async_clk scg_async_clk_t
SCG asynchronous clock type.
_scg_firc_enable_mode
FIRC enable mode.
uint32_t CLOCK_GetErClkFreq(void)
Get the external reference clock frequency (ERCLK).
_scg_sys_clk_div
SCG system clock divider value.
uint32_t CLOCK_GetSysClkFreq(scg_sys_clk_t type)
Gets the SCG system clock frequency.
status_t CLOCK_DeinitSysPll(void)
De-initializes the SCG system PLL.
static bool CLOCK_IsEnabledByOtherCore(clock_ip_name_t name)
Check whether the clock is already enabled and configured by any other core.
static void CLOCK_SetClkOutSel(clock_clkout_src_t setting)
Sets the clock out selection.
static void CLOCK_GetCurSysClkConfig(scg_sys_clk_config_t *config)
Gets the system clock configuration in the current power mode.
uint32_t CLOCK_GetBusClkFreq(void)
Get the bus clock frequency.
_scg_spll_monitor_mode
SCG system PLL monitor mode.
uint32_t CLOCK_GetSircAsyncFreq(scg_async_clk_t type)
Gets the SCG asynchronous clock frequency from the SIRC.
_scg_sys_clk
SCG system clock type.
enum _scg_sirc_range scg_sirc_range_t
SCG slow IRC clock frequency range.
static void CLOCK_SetXtal32Freq(uint32_t freq)
Sets the XTAL32 frequency based on board settings.
uint32_t CLOCK_GetFlashClkFreq(void)
Get the flash clock frequency.
void OSC32_Init(OSC32_Type *base, osc32_mode_t mode)
Initializes OSC32.
uint32_t CLOCK_GetSysOscFreq(void)
Gets the SCG system OSC clock frequency (SYSOSC).
_clock_ip_src
Clock source for peripherals that support various clock selections.
enum _scg_sosc_mode scg_sosc_mode_t
OSC work mode.
static void CLOCK_SetHsrunModeSysClkConfig(const scg_sys_clk_config_t *config)
Sets the system clock configuration for HSRUN mode.
static void CLOCK_ClearSysPllErr(void)
Clears the system PLL clock error.
status_t CLOCK_DeinitSirc(void)
De-initializes the SCG slow IRC.
_scg_sosc_mode
OSC work mode.
scg_firc_trim_div_t trimDiv
struct _scg_spll_config scg_spll_config_t
SCG system PLL configuration.
struct _scg_sirc_config scg_sirc_config_t
SCG slow IRC clock configuration.
uint32_t CLOCK_GetOsc32kClkFreq(void)
Get the OSC 32K clock frequency (OSC32KCLK).
const scg_firc_trim_config_t * trimConfig
static bool CLOCK_IsFircErr(void)
Checks whether the FIRC clock error occurs.
_scg_sys_clk_src
SCG system clock source.
struct _scg_sosc_config scg_sosc_config_t
SCG system OSC configuration.
_scg_firc_trim_src
SCG fast IRC trim source.
enum _scg_firc_trim_src scg_firc_trim_src_t
SCG fast IRC trim source.
status_t CLOCK_InitSirc(const scg_sirc_config_t *config)
Initializes the SCG slow IRC clock.
status_t CLOCK_InitFirc(const scg_firc_config_t *config)
Initializes the SCG fast IRC clock.
static void CLOCK_SetFircAsyncClkDiv(scg_async_clk_t asyncClk, scg_async_clk_div_t divider)
Set the asynchronous clock divider.
static bool CLOCK_IsSysOscValid(void)
Checks whether the system OSC clock is valid.
_clock_clkout_src
SCG clock out configuration (CLKOUTSEL).
static void CLOCK_ClearSysOscErr(void)
Clears the system OSC clock error.
static void CLOCK_SetSysPllMonitorMode(scg_spll_monitor_mode_t mode)
Sets the system PLL monitor mode.
status_t CLOCK_InitSysPll(const scg_spll_config_t *config)
Initializes the SCG system PLL.
uint32_t CLOCK_GetFircAsyncFreq(scg_async_clk_t type)
Gets the SCG asynchronous clock frequency from the FIRC.
status_t CLOCK_DeinitSysOsc(void)
De-initializes the SCG system OSC.
status_t CLOCK_InitSysOsc(const scg_sosc_config_t *config)
Initializes the SCG system OSC.
scg_spll_monitor_mode_t monitorMode
struct _scg_firc_config_t scg_firc_config_t
SCG fast IRC clock configuration.
static void CLOCK_EnableClock(clock_ip_name_t name)
Enable the clock for specific IP.
uint32_t CLOCK_GetSysOscAsyncFreq(scg_async_clk_t type)
Gets the SCG asynchronous clock frequency from the system OSC.
static bool CLOCK_IsSysPllErr(void)
Checks whether the system PLL clock error occurs.
static void CLOCK_SetSircAsyncClkDiv(scg_async_clk_t asyncClk, scg_async_clk_div_t divider)
Set the asynchronous clock divider.
static void CLOCK_SetSysPllAsyncClkDiv(scg_async_clk_t asyncClk, scg_async_clk_div_t divider)
Set the asynchronous clock divider.
scg_sosc_monitor_mode_t monitorMode
enum _osc32_mode osc32_mode_t
OSC32 work mode.
@ kCLOCK_ScgSysOscAsyncDiv1Clk
@ kCLOCK_ScgSysPllAsyncDiv2Clk
@ kCLOCK_ScgSysOscAsyncDiv2Clk
@ kCLOCK_ScgFircAsyncDiv2Clk
@ kCLOCK_ScgSircAsyncDiv1Clk
@ kCLOCK_ScgSircAsyncDiv2Clk
@ kCLOCK_ScgFircAsyncDiv1Clk
@ kCLOCK_ScgSysPllAsyncDiv1Clk
@ kSCG_SircEnableInLowPower
@ kOSC32_CrystalEnableInStop
@ kSCG_SysPllEnableInStop
@ kSCG_SysOscEnableInLowPower
@ kSCG_SysOscEnableInStop
@ kSCG_SysOscMonitorReset
@ kSCG_SysOscMonitorDisable
@ kSCG_FircDisableRegulator
@ kSCG_FircEnableInLowPower
@ kSCG_SysPllMonitorDisable
@ kSCG_SysPllMonitorReset
@ kCLOCK_IpSrcSysPllAsync
@ kCLOCK_IpSrcSysOscAsync
@ kSCG_SysOscModeOscHighGain
@ kSCG_SysOscModeOscLowPower
int32_t status_t
Type used for all status and error return values.
SCG fast IRC clock configuration.
SCG fast IRC clock trim configuration.
SCG slow IRC clock configuration.
SCG system OSC configuration.
SCG system PLL configuration.
SCG system clock configuration.