rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Files | Data Structures | Enumerator | Variables
Clock

Files

file  fsl_clock.h
 

Data Structures

struct  _scg_sys_clk_config
 SCG system clock configuration. More...
 
struct  _scg_sosc_config
 SCG system OSC configuration. More...
 
struct  _scg_sirc_config
 SCG slow IRC clock configuration. More...
 
struct  _scg_firc_trim_config
 SCG fast IRC clock trim configuration. More...
 
struct  _scg_firc_config_t
 SCG fast IRC clock configuration. More...
 
struct  _scg_spll_config
 SCG system PLL configuration. More...
 

Variables

uint32_t _scg_sys_clk_config::divSlow: 4
 
uint32_t _scg_sys_clk_config::divBus: 4
 
uint32_t : 4
 
uint32_t : 4
 
uint32_t _scg_sys_clk_config::divCore: 4
 
uint32_t : 4
 
uint32_t _scg_sys_clk_config::src: 4
 
uint32_t : 4
 
uint32_t _scg_sosc_config::freq
 
scg_sosc_monitor_mode_t _scg_sosc_config::monitorMode
 
uint8_t _scg_sosc_config::enableMode
 
scg_async_clk_div_t _scg_sosc_config::div1
 
scg_async_clk_div_t _scg_sosc_config::div2
 
scg_sosc_mode_t _scg_sosc_config::workMode
 
uint32_t _scg_sirc_config::enableMode
 
scg_async_clk_div_t _scg_sirc_config::div1
 
scg_async_clk_div_t _scg_sirc_config::div2
 
scg_sirc_range_t _scg_sirc_config::range
 
scg_firc_trim_mode_t _scg_firc_trim_config::trimMode
 
scg_firc_trim_src_t _scg_firc_trim_config::trimSrc
 
scg_firc_trim_div_t _scg_firc_trim_config::trimDiv
 
uint8_t _scg_firc_trim_config::trimCoar
 
uint8_t _scg_firc_trim_config::trimFine
 
uint32_t _scg_firc_config_t::enableMode
 
scg_async_clk_div_t _scg_firc_config_t::div1
 
scg_async_clk_div_t _scg_firc_config_t::div2
 
scg_firc_range_t _scg_firc_config_t::range
 
const scg_firc_trim_config_t_scg_firc_config_t::trimConfig
 
uint8_t _scg_spll_config::enableMode
 
scg_spll_monitor_mode_t _scg_spll_config::monitorMode
 
scg_async_clk_div_t _scg_spll_config::div1
 
scg_async_clk_div_t _scg_spll_config::div2
 
scg_spll_src_t _scg_spll_config::src
 
uint8_t _scg_spll_config::prediv
 
uint8_t _scg_spll_config::mult
 

Driver version

enum  _clock_name {
  kCLOCK_CoreSysClk , kCLOCK_BusClk , kCLOCK_FlexBusClk , kCLOCK_FlashClk ,
  kCLOCK_ScgSysOscClk , kCLOCK_ScgSircClk , kCLOCK_ScgFircClk , kCLOCK_ScgSysPllClk ,
  kCLOCK_ScgSysOscAsyncDiv1Clk , kCLOCK_ScgSysOscAsyncDiv2Clk , kCLOCK_ScgSircAsyncDiv1Clk , kCLOCK_ScgSircAsyncDiv2Clk ,
  kCLOCK_ScgFircAsyncDiv1Clk , kCLOCK_ScgFircAsyncDiv2Clk , kCLOCK_ScgSysPllAsyncDiv1Clk , kCLOCK_ScgSysPllAsyncDiv2Clk ,
  kCLOCK_LpoClk , kCLOCK_Osc32kClk , kCLOCK_ErClk
}
 Clock name used to get clock frequency. More...
 
enum  _clock_ip_src {
  kCLOCK_IpSrcNoneOrExt = 0U , kCLOCK_IpSrcSysOscAsync = 1U , kCLOCK_IpSrcSircAsync = 2U , kCLOCK_IpSrcFircAsync = 3U ,
  kCLOCK_IpSrcSysPllAsync = 6U
}
 Clock source for peripherals that support various clock selections. More...
 
enum  _clock_ip_name {
  kCLOCK_IpInvalid = 0U , kCLOCK_Dma0 = 0x40065020U , kCLOCK_Sysmpu0 = 0x40065034U , kCLOCK_Flash0 = 0x40065080U ,
  kCLOCK_Dmamux0 = 0x40065084U , kCLOCK_Flexcan0 = 0x40065090U , kCLOCK_Flexcan1 = 0x40065094U , kCLOCK_Ftm3 = 0x40065098U ,
  kCLOCK_Adc1 = 0x4006509CU , kCLOCK_Lpspi0 = 0x400650B0U , kCLOCK_Lpspi1 = 0x400650B4U , kCLOCK_Pdb1 = 0x400650C4U ,
  kCLOCK_Crc0 = 0x400650C8U , kCLOCK_Pdb2 = 0x400650CCU , kCLOCK_Pdb0 = 0x400650D8U , kCLOCK_Lpit0 = 0x400650DCU ,
  kCLOCK_Ftm0 = 0x400650E0U , kCLOCK_Ftm1 = 0x400650E4U , kCLOCK_Ftm2 = 0x400650E8U , kCLOCK_Adc0 = 0x400650ECU ,
  kCLOCK_Adc2 = 0x400650F0U , kCLOCK_Rtc0 = 0x400650F4U , kCLOCK_Dac0 = 0x400650FCU , kCLOCK_Lptmr0 = 0x40065100U ,
  kCLOCK_PortA = 0x40065124U , kCLOCK_PortB = 0x40065128U , kCLOCK_PortC = 0x4006512CU , kCLOCK_PortD = 0x40065130U ,
  kCLOCK_PortE = 0x40065134U , kCLOCK_Pwt0 = 0x40065158U , kCLOCK_Flexio0 = 0x40065168U , kCLOCK_RtcOsc0 = 0x40065180U ,
  kCLOCK_Ewm0 = 0x40065184U , kCLOCK_Lpi2c0 = 0x40065198U , kCLOCK_Lpi2c1 = 0x4006519CU , kCLOCK_Lpuart0 = 0x400651A8U ,
  kCLOCK_Lpuart1 = 0x400651ACU , kCLOCK_Lpuart2 = 0x400651B0U , kCLOCK_Cmp0 = 0x400651CCU , kCLOCK_Cmp1 = 0x400651D0U ,
  kCLOCK_Cmp2 = 0x400651D4U
}
 Peripheral clock name difinition used for clock gate, clock source and clock divider setting. It is defined as the corresponding register address. More...
 
enum  _osc32_mode { kOSC32_Bypass = OSC32_CR_ROSCEN_MASK , kOSC32_Crystal = OSC32_CR_ROSCEN_MASK | OSC32_CR_ROSCEREFS_MASK , kOSC32_CrystalEnableInStop }
 OSC32 work mode. More...
 
enum  _scg_status { kStatus_SCG_Busy = MAKE_STATUS(kStatusGroup_SCG, 1) , kStatus_SCG_InvalidSrc = MAKE_STATUS(kStatusGroup_SCG, 2) }
 SCG status return codes. More...
 
enum  _scg_sys_clk { kSCG_SysClkSlow , kSCG_SysClkBus , kSCG_SysClkCore }
 SCG system clock type. More...
 
enum  _scg_sys_clk_src { kSCG_SysClkSrcSysOsc = 1U , kSCG_SysClkSrcSirc = 2U , kSCG_SysClkSrcFirc = 3U , kSCG_SysClkSrcSysPll = 6U }
 SCG system clock source. More...
 
enum  _scg_sys_clk_div {
  kSCG_SysClkDivBy1 = 0U , kSCG_SysClkDivBy2 = 1U , kSCG_SysClkDivBy3 = 2U , kSCG_SysClkDivBy4 = 3U ,
  kSCG_SysClkDivBy5 = 4U , kSCG_SysClkDivBy6 = 5U , kSCG_SysClkDivBy7 = 6U , kSCG_SysClkDivBy8 = 7U ,
  kSCG_SysClkDivBy9 = 8U , kSCG_SysClkDivBy10 = 9U , kSCG_SysClkDivBy11 = 10U , kSCG_SysClkDivBy12 = 11U ,
  kSCG_SysClkDivBy13 = 12U , kSCG_SysClkDivBy14 = 13U , kSCG_SysClkDivBy15 = 14U , kSCG_SysClkDivBy16 = 15U
}
 SCG system clock divider value. More...
 
enum  _clock_clkout_src {
  kClockClkoutSelScgSlow = 0U , kClockClkoutSelSysOsc = 1U , kClockClkoutSelSirc = 2U , kClockClkoutSelFirc = 3U ,
  kClockClkoutSelSysPll = 6U
}
 SCG clock out configuration (CLKOUTSEL). More...
 
enum  _scg_async_clk { kSCG_AsyncDiv1Clk , kSCG_AsyncDiv2Clk }
 SCG asynchronous clock type. More...
 
enum  scg_async_clk_div {
  kSCG_AsyncClkDisable = 0U , kSCG_AsyncClkDivBy1 = 1U , kSCG_AsyncClkDivBy2 = 2U , kSCG_AsyncClkDivBy4 = 3U ,
  kSCG_AsyncClkDivBy8 = 4U , kSCG_AsyncClkDivBy16 = 5U , kSCG_AsyncClkDivBy32 = 6U , kSCG_AsyncClkDivBy64 = 7U
}
 SCG asynchronous clock divider value. More...
 
enum  _scg_sosc_monitor_mode { kSCG_SysOscMonitorDisable = 0U , kSCG_SysOscMonitorInt = SCG_SOSCCSR_SOSCCM_MASK , kSCG_SysOscMonitorReset }
 SCG system OSC monitor mode. More...
 
enum  _scg_sosc_mode { kSCG_SysOscModeExt = 0U , kSCG_SysOscModeOscLowPower = SCG_SOSCCFG_EREFS_MASK , kSCG_SysOscModeOscHighGain = SCG_SOSCCFG_EREFS_MASK | SCG_SOSCCFG_HGO_MASK }
 OSC work mode. More...
 
enum  _scg_sosc_enable_mode { kSCG_SysOscEnable = SCG_SOSCCSR_SOSCEN_MASK , kSCG_SysOscEnableInStop = SCG_SOSCCSR_SOSCSTEN_MASK , kSCG_SysOscEnableInLowPower = SCG_SOSCCSR_SOSCLPEN_MASK , kSCG_SysOscEnableErClk = SCG_SOSCCSR_SOSCERCLKEN_MASK }
 OSC enable mode. More...
 
enum  _scg_sirc_range { kSCG_SircRangeLow , kSCG_SircRangeHigh }
 SCG slow IRC clock frequency range. More...
 
enum  _scg_sirc_enable_mode { kSCG_SircEnable = SCG_SIRCCSR_SIRCEN_MASK , kSCG_SircEnableInStop = SCG_SIRCCSR_SIRCSTEN_MASK , kSCG_SircEnableInLowPower = SCG_SIRCCSR_SIRCLPEN_MASK }
 SIRC enable mode. More...
 
enum  _scg_firc_trim_mode { kSCG_FircTrimNonUpdate = SCG_FIRCCSR_FIRCTREN_MASK , kSCG_FircTrimUpdate = SCG_FIRCCSR_FIRCTREN_MASK | SCG_FIRCCSR_FIRCTRUP_MASK }
 SCG fast IRC trim mode. More...
 
enum  _scg_firc_trim_div {
  kSCG_FircTrimDivBy1 , kSCG_FircTrimDivBy128 , kSCG_FircTrimDivBy256 , kSCG_FircTrimDivBy512 ,
  kSCG_FircTrimDivBy1024 , kSCG_FircTrimDivBy2048
}
 SCG fast IRC trim predivided value for system OSC. More...
 
enum  _scg_firc_trim_src { kSCG_FircTrimSrcSysOsc = 2U }
 SCG fast IRC trim source. More...
 
enum  _scg_firc_range { kSCG_FircRange48M , kSCG_FircRange52M , kSCG_FircRange56M , kSCG_FircRange60M }
 SCG fast IRC clock frequency range. More...
 
enum  _scg_firc_enable_mode { kSCG_FircEnable = SCG_FIRCCSR_FIRCEN_MASK , kSCG_FircEnableInStop = SCG_FIRCCSR_FIRCSTEN_MASK , kSCG_FircEnableInLowPower = SCG_FIRCCSR_FIRCLPEN_MASK , kSCG_FircDisableRegulator = SCG_FIRCCSR_FIRCREGOFF_MASK }
 FIRC enable mode. More...
 
enum  _scg_spll_src { kSCG_SysPllSrcSysOsc , kSCG_SysPllSrcFirc }
 SCG system PLL clock source. More...
 
enum  _scg_spll_monitor_mode { kSCG_SysPllMonitorDisable = 0U , kSCG_SysPllMonitorInt = SCG_SPLLCSR_SPLLCM_MASK , kSCG_SysPllMonitorReset }
 SCG system PLL monitor mode. More...
 
enum  _scg_spll_enable_mode { kSCG_SysPllEnable = SCG_SPLLCSR_SPLLEN_MASK , kSCG_SysPllEnableInStop = SCG_SPLLCSR_SPLLSTEN_MASK }
 SPLL enable mode. More...
 
typedef enum _clock_name clock_name_t
 Clock name used to get clock frequency.
 
typedef enum _clock_ip_src clock_ip_src_t
 Clock source for peripherals that support various clock selections.
 
typedef enum _clock_ip_name clock_ip_name_t
 Peripheral clock name difinition used for clock gate, clock source and clock divider setting. It is defined as the corresponding register address.
 
typedef enum _osc32_mode osc32_mode_t
 OSC32 work mode.
 
typedef enum _scg_sys_clk scg_sys_clk_t
 SCG system clock type.
 
typedef enum _scg_sys_clk_src scg_sys_clk_src_t
 SCG system clock source.
 
typedef enum _scg_sys_clk_div scg_sys_clk_div_t
 SCG system clock divider value.
 
typedef struct _scg_sys_clk_config scg_sys_clk_config_t
 SCG system clock configuration.
 
typedef enum _clock_clkout_src clock_clkout_src_t
 SCG clock out configuration (CLKOUTSEL).
 
typedef enum _scg_async_clk scg_async_clk_t
 SCG asynchronous clock type.
 
typedef enum scg_async_clk_div scg_async_clk_div_t
 SCG asynchronous clock divider value.
 
typedef enum _scg_sosc_monitor_mode scg_sosc_monitor_mode_t
 SCG system OSC monitor mode.
 
typedef enum _scg_sosc_mode scg_sosc_mode_t
 OSC work mode.
 
typedef struct _scg_sosc_config scg_sosc_config_t
 SCG system OSC configuration.
 
typedef enum _scg_sirc_range scg_sirc_range_t
 SCG slow IRC clock frequency range.
 
typedef struct _scg_sirc_config scg_sirc_config_t
 SCG slow IRC clock configuration.
 
typedef enum _scg_firc_trim_mode scg_firc_trim_mode_t
 SCG fast IRC trim mode.
 
typedef enum _scg_firc_trim_div scg_firc_trim_div_t
 SCG fast IRC trim predivided value for system OSC.
 
typedef enum _scg_firc_trim_src scg_firc_trim_src_t
 SCG fast IRC trim source.
 
typedef struct _scg_firc_trim_config scg_firc_trim_config_t
 SCG fast IRC clock trim configuration.
 
typedef enum _scg_firc_range scg_firc_range_t
 SCG fast IRC clock frequency range.
 
typedef struct _scg_firc_config_t scg_firc_config_t
 SCG fast IRC clock configuration.
 
typedef enum _scg_spll_src scg_spll_src_t
 SCG system PLL clock source.
 
typedef enum _scg_spll_monitor_mode scg_spll_monitor_mode_t
 SCG system PLL monitor mode.
 
typedef struct _scg_spll_config scg_spll_config_t
 SCG system PLL configuration.
 
volatile uint32_t g_xtal0Freq
 External XTAL0 (OSC0/SYSOSC) clock frequency.
 
volatile uint32_t g_xtal32Freq
 External XTAL32/EXTAL32 clock frequency.
 
static void CLOCK_EnableClock (clock_ip_name_t name)
 Enable the clock for specific IP.
 
static void CLOCK_DisableClock (clock_ip_name_t name)
 Disable the clock for specific IP.
 
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_SetIpSrc (clock_ip_name_t name, clock_ip_src_t src)
 Set the clock source for specific IP module.
 
uint32_t CLOCK_GetFreq (clock_name_t clockName)
 Gets the clock frequency for a specific clock name.
 
uint32_t CLOCK_GetCoreSysClkFreq (void)
 Get the core clock or system clock frequency.
 
uint32_t CLOCK_GetBusClkFreq (void)
 Get the bus clock frequency.
 
uint32_t CLOCK_GetFlashClkFreq (void)
 Get the flash clock frequency.
 
uint32_t CLOCK_GetOsc32kClkFreq (void)
 Get the OSC 32K clock frequency (OSC32KCLK).
 
uint32_t CLOCK_GetErClkFreq (void)
 Get the external reference clock frequency (ERCLK).
 
uint32_t CLOCK_GetIpFreq (clock_ip_name_t name)
 Gets the clock frequency for a specific IP module.
 

MCU System Clock.

uint32_t CLOCK_GetSysClkFreq (scg_sys_clk_t type)
 Gets the SCG system clock frequency.
 
static void CLOCK_SetVlprModeSysClkConfig (const scg_sys_clk_config_t *config)
 Sets the system clock configuration for VLPR mode.
 
static void CLOCK_SetRunModeSysClkConfig (const scg_sys_clk_config_t *config)
 Sets the system clock configuration for RUN mode.
 
static void CLOCK_SetHsrunModeSysClkConfig (const scg_sys_clk_config_t *config)
 Sets the system clock configuration for HSRUN mode.
 
static void CLOCK_GetCurSysClkConfig (scg_sys_clk_config_t *config)
 Gets the system clock configuration in the current power mode.
 
static void CLOCK_SetClkOutSel (clock_clkout_src_t setting)
 Sets the clock out selection.
 

SCG System OSC Clock.

status_t CLOCK_InitSysOsc (const scg_sosc_config_t *config)
 Initializes the SCG system OSC.
 
status_t CLOCK_DeinitSysOsc (void)
 De-initializes the SCG system OSC.
 
static void CLOCK_SetSysOscAsyncClkDiv (scg_async_clk_t asyncClk, scg_async_clk_div_t divider)
 Set the asynchronous clock divider.
 
uint32_t CLOCK_GetSysOscFreq (void)
 Gets the SCG system OSC clock frequency (SYSOSC).
 
uint32_t CLOCK_GetSysOscAsyncFreq (scg_async_clk_t type)
 Gets the SCG asynchronous clock frequency from the system OSC.
 
static bool CLOCK_IsSysOscErr (void)
 Checks whether the system OSC clock error occurs.
 
static void CLOCK_ClearSysOscErr (void)
 Clears the system OSC clock error.
 
static void CLOCK_SetSysOscMonitorMode (scg_sosc_monitor_mode_t mode)
 Sets the system OSC monitor mode.
 
static bool CLOCK_IsSysOscValid (void)
 Checks whether the system OSC clock is valid.
 

SCG Slow IRC Clock.

status_t CLOCK_InitSirc (const scg_sirc_config_t *config)
 Initializes the SCG slow IRC clock.
 
status_t CLOCK_DeinitSirc (void)
 De-initializes the SCG slow IRC.
 
static void CLOCK_SetSircAsyncClkDiv (scg_async_clk_t asyncClk, scg_async_clk_div_t divider)
 Set the asynchronous clock divider.
 
uint32_t CLOCK_GetSircFreq (void)
 Gets the SCG SIRC clock frequency.
 
uint32_t CLOCK_GetSircAsyncFreq (scg_async_clk_t type)
 Gets the SCG asynchronous clock frequency from the SIRC.
 
static bool CLOCK_IsSircValid (void)
 Checks whether the SIRC clock is valid.
 

SCG Fast IRC Clock.

status_t CLOCK_InitFirc (const scg_firc_config_t *config)
 Initializes the SCG fast IRC clock.
 
status_t CLOCK_DeinitFirc (void)
 De-initializes the SCG fast IRC.
 
static void CLOCK_SetFircAsyncClkDiv (scg_async_clk_t asyncClk, scg_async_clk_div_t divider)
 Set the asynchronous clock divider.
 
uint32_t CLOCK_GetFircFreq (void)
 Gets the SCG FIRC clock frequency.
 
uint32_t CLOCK_GetFircAsyncFreq (scg_async_clk_t type)
 Gets the SCG asynchronous clock frequency from the FIRC.
 
static bool CLOCK_IsFircErr (void)
 Checks whether the FIRC clock error occurs.
 
static void CLOCK_ClearFircErr (void)
 Clears the FIRC clock error.
 
static bool CLOCK_IsFircValid (void)
 Checks whether the FIRC clock is valid.
 

SCG System PLL Clock.

uint32_t CLOCK_GetSysPllMultDiv (uint32_t refFreq, uint32_t desireFreq, uint8_t *mult, uint8_t *prediv)
 Calculates the MULT and PREDIV for the PLL.
 
status_t CLOCK_InitSysPll (const scg_spll_config_t *config)
 Initializes the SCG system PLL.
 
status_t CLOCK_DeinitSysPll (void)
 De-initializes the SCG system PLL.
 
static void CLOCK_SetSysPllAsyncClkDiv (scg_async_clk_t asyncClk, scg_async_clk_div_t divider)
 Set the asynchronous clock divider.
 
uint32_t CLOCK_GetSysPllFreq (void)
 Gets the SCG system PLL clock frequency.
 
uint32_t CLOCK_GetSysPllAsyncFreq (scg_async_clk_t type)
 Gets the SCG asynchronous clock frequency from the system PLL.
 
static bool CLOCK_IsSysPllErr (void)
 Checks whether the system PLL clock error occurs.
 
static void CLOCK_ClearSysPllErr (void)
 Clears the system PLL clock error.
 
static void CLOCK_SetSysPllMonitorMode (scg_spll_monitor_mode_t mode)
 Sets the system PLL monitor mode.
 
static bool CLOCK_IsSysPllValid (void)
 Checks whether the system PLL clock is valid.
 

OSC32 operations

void OSC32_Init (OSC32_Type *base, osc32_mode_t mode)
 Initializes OSC32.
 
void OSC32_Deinit (OSC32_Type *base)
 Deinitializes OSC32.
 

External clock frequency

static void CLOCK_SetXtal0Freq (uint32_t freq)
 Sets the XTAL0 frequency based on board settings.
 
static void CLOCK_SetXtal32Freq (uint32_t freq)
 Sets the XTAL32 frequency based on board settings.
 

Detailed Description

Typedef Documentation

◆ clock_clkout_src_t

SCG clock out configuration (CLKOUTSEL).

◆ clock_ip_name_t

Peripheral clock name difinition used for clock gate, clock source and clock divider setting. It is defined as the corresponding register address.

◆ clock_ip_src_t

Clock source for peripherals that support various clock selections.

◆ clock_name_t

typedef enum _clock_name clock_name_t

Clock name used to get clock frequency.

◆ osc32_mode_t

typedef enum _osc32_mode osc32_mode_t

OSC32 work mode.

◆ scg_async_clk_div_t

SCG asynchronous clock divider value.

◆ scg_async_clk_t

SCG asynchronous clock type.

◆ scg_firc_config_t

SCG fast IRC clock configuration.

◆ scg_firc_range_t

SCG fast IRC clock frequency range.

◆ scg_firc_trim_config_t

SCG fast IRC clock trim configuration.

◆ scg_firc_trim_div_t

SCG fast IRC trim predivided value for system OSC.

◆ scg_firc_trim_mode_t

SCG fast IRC trim mode.

◆ scg_firc_trim_src_t

SCG fast IRC trim source.

◆ scg_sirc_config_t

SCG slow IRC clock configuration.

◆ scg_sirc_range_t

SCG slow IRC clock frequency range.

◆ scg_sosc_config_t

SCG system OSC configuration.

◆ scg_sosc_mode_t

OSC work mode.

◆ scg_sosc_monitor_mode_t

SCG system OSC monitor mode.

◆ scg_spll_config_t

SCG system PLL configuration.

◆ scg_spll_monitor_mode_t

SCG system PLL monitor mode.

◆ scg_spll_src_t

SCG system PLL clock source.

◆ scg_sys_clk_config_t

SCG system clock configuration.

◆ scg_sys_clk_div_t

SCG system clock divider value.

◆ scg_sys_clk_src_t

SCG system clock source.

◆ scg_sys_clk_t

SCG system clock type.

Enumeration Type Documentation

◆ _clock_clkout_src

SCG clock out configuration (CLKOUTSEL).

Enumerator
kClockClkoutSelScgSlow 

SCG slow clock.

kClockClkoutSelSysOsc 

System OSC.

kClockClkoutSelSirc 

Slow IRC.

kClockClkoutSelFirc 

Fast IRC.

kClockClkoutSelSysPll 

System PLL.

Definition at line 395 of file fsl_clock.h.

396{
397 kClockClkoutSelScgSlow = 0U, /*!< SCG slow clock. */
398 kClockClkoutSelSysOsc = 1U, /*!< System OSC. */
399 kClockClkoutSelSirc = 2U, /*!< Slow IRC. */
400 kClockClkoutSelFirc = 3U, /*!< Fast IRC. */
401 kClockClkoutSelSysPll = 6U /*!< System PLL. */
enum _clock_clkout_src clock_clkout_src_t
SCG clock out configuration (CLKOUTSEL).
@ kClockClkoutSelScgSlow
Definition fsl_clock.h:397
@ kClockClkoutSelFirc
Definition fsl_clock.h:400
@ kClockClkoutSelSysOsc
Definition fsl_clock.h:398
@ kClockClkoutSelSirc
Definition fsl_clock.h:399
@ kClockClkoutSelSysPll
Definition fsl_clock.h:401

◆ _clock_ip_name

Peripheral clock name difinition used for clock gate, clock source and clock divider setting. It is defined as the corresponding register address.

Enumerator
kCLOCK_IpInvalid 
kCLOCK_Dma0 
kCLOCK_Sysmpu0 
kCLOCK_Flash0 
kCLOCK_Dmamux0 
kCLOCK_Flexcan0 
kCLOCK_Flexcan1 
kCLOCK_Ftm3 
kCLOCK_Adc1 
kCLOCK_Lpspi0 
kCLOCK_Lpspi1 
kCLOCK_Pdb1 
kCLOCK_Crc0 
kCLOCK_Pdb2 
kCLOCK_Pdb0 
kCLOCK_Lpit0 
kCLOCK_Ftm0 
kCLOCK_Ftm1 
kCLOCK_Ftm2 
kCLOCK_Adc0 
kCLOCK_Adc2 
kCLOCK_Rtc0 
kCLOCK_Dac0 
kCLOCK_Lptmr0 
kCLOCK_PortA 
kCLOCK_PortB 
kCLOCK_PortC 
kCLOCK_PortD 
kCLOCK_PortE 
kCLOCK_Pwt0 
kCLOCK_Flexio0 
kCLOCK_RtcOsc0 
kCLOCK_Ewm0 
kCLOCK_Lpi2c0 
kCLOCK_Lpi2c1 
kCLOCK_Lpuart0 
kCLOCK_Lpuart1 
kCLOCK_Lpuart2 
kCLOCK_Cmp0 
kCLOCK_Cmp1 
kCLOCK_Cmp2 

Definition at line 266 of file fsl_clock.h.

267{
268 kCLOCK_IpInvalid = 0U,
269
270 /* PCC 0 */
271 kCLOCK_Dma0 = 0x40065020U,
272 kCLOCK_Sysmpu0 = 0x40065034U,
273 kCLOCK_Flash0 = 0x40065080U,
274 kCLOCK_Dmamux0 = 0x40065084U,
275 kCLOCK_Flexcan0 = 0x40065090U,
276 kCLOCK_Flexcan1 = 0x40065094U,
277 kCLOCK_Ftm3 = 0x40065098U,
278 kCLOCK_Adc1 = 0x4006509CU,
279 kCLOCK_Lpspi0 = 0x400650B0U,
280 kCLOCK_Lpspi1 = 0x400650B4U,
281 kCLOCK_Pdb1 = 0x400650C4U,
282 kCLOCK_Crc0 = 0x400650C8U,
283 kCLOCK_Pdb2 = 0x400650CCU,
284 kCLOCK_Pdb0 = 0x400650D8U,
285 kCLOCK_Lpit0 = 0x400650DCU,
286 kCLOCK_Ftm0 = 0x400650E0U,
287 kCLOCK_Ftm1 = 0x400650E4U,
288 kCLOCK_Ftm2 = 0x400650E8U,
289 kCLOCK_Adc0 = 0x400650ECU,
290 kCLOCK_Adc2 = 0x400650F0U,
291 kCLOCK_Rtc0 = 0x400650F4U,
292 kCLOCK_Dac0 = 0x400650FCU,
293 kCLOCK_Lptmr0 = 0x40065100U,
294 kCLOCK_PortA = 0x40065124U,
295 kCLOCK_PortB = 0x40065128U,
296 kCLOCK_PortC = 0x4006512CU,
297 kCLOCK_PortD = 0x40065130U,
298 kCLOCK_PortE = 0x40065134U,
299 kCLOCK_Pwt0 = 0x40065158U,
300 kCLOCK_Flexio0 = 0x40065168U,
301 kCLOCK_RtcOsc0 = 0x40065180U,
302 kCLOCK_Ewm0 = 0x40065184U,
303 kCLOCK_Lpi2c0 = 0x40065198U,
304 kCLOCK_Lpi2c1 = 0x4006519CU,
305 kCLOCK_Lpuart0 = 0x400651A8U,
306 kCLOCK_Lpuart1 = 0x400651ACU,
307 kCLOCK_Lpuart2 = 0x400651B0U,
308 kCLOCK_Cmp0 = 0x400651CCU,
309 kCLOCK_Cmp1 = 0x400651D0U,
310 kCLOCK_Cmp2 = 0x400651D4U,
enum _clock_ip_name clock_ip_name_t
Peripheral clock name difinition used for clock gate, clock source and clock divider setting....
@ kCLOCK_Cmp2
Definition fsl_clock.h:310
@ kCLOCK_Sysmpu0
Definition fsl_clock.h:272
@ kCLOCK_IpInvalid
Definition fsl_clock.h:268
@ kCLOCK_PortC
Definition fsl_clock.h:296
@ kCLOCK_Dma0
Definition fsl_clock.h:271
@ kCLOCK_PortE
Definition fsl_clock.h:298
@ kCLOCK_Lptmr0
Definition fsl_clock.h:293
@ kCLOCK_Pdb0
Definition fsl_clock.h:284
@ kCLOCK_Pdb1
Definition fsl_clock.h:281
@ kCLOCK_Lpi2c1
Definition fsl_clock.h:304
@ kCLOCK_Rtc0
Definition fsl_clock.h:291
@ kCLOCK_Ewm0
Definition fsl_clock.h:302
@ kCLOCK_Lpuart2
Definition fsl_clock.h:307
@ kCLOCK_Flexio0
Definition fsl_clock.h:300
@ kCLOCK_Flash0
Definition fsl_clock.h:273
@ kCLOCK_Pwt0
Definition fsl_clock.h:299
@ kCLOCK_Adc1
Definition fsl_clock.h:278
@ kCLOCK_Ftm3
Definition fsl_clock.h:277
@ kCLOCK_Cmp0
Definition fsl_clock.h:308
@ kCLOCK_Dmamux0
Definition fsl_clock.h:274
@ kCLOCK_Adc2
Definition fsl_clock.h:290
@ kCLOCK_PortA
Definition fsl_clock.h:294
@ kCLOCK_Pdb2
Definition fsl_clock.h:283
@ kCLOCK_PortB
Definition fsl_clock.h:295
@ kCLOCK_Lpuart1
Definition fsl_clock.h:306
@ kCLOCK_Lpi2c0
Definition fsl_clock.h:303
@ kCLOCK_Flexcan1
Definition fsl_clock.h:276
@ kCLOCK_Cmp1
Definition fsl_clock.h:309
@ kCLOCK_Crc0
Definition fsl_clock.h:282
@ kCLOCK_Adc0
Definition fsl_clock.h:289
@ kCLOCK_Flexcan0
Definition fsl_clock.h:275
@ kCLOCK_Lpspi1
Definition fsl_clock.h:280
@ kCLOCK_RtcOsc0
Definition fsl_clock.h:301
@ kCLOCK_Lpuart0
Definition fsl_clock.h:305
@ kCLOCK_Lpit0
Definition fsl_clock.h:285
@ kCLOCK_Ftm1
Definition fsl_clock.h:287
@ kCLOCK_Lpspi0
Definition fsl_clock.h:279
@ kCLOCK_PortD
Definition fsl_clock.h:297
@ kCLOCK_Ftm2
Definition fsl_clock.h:288
@ kCLOCK_Dac0
Definition fsl_clock.h:292
@ kCLOCK_Ftm0
Definition fsl_clock.h:286

◆ _clock_ip_src

Clock source for peripherals that support various clock selections.

Enumerator
kCLOCK_IpSrcNoneOrExt 

Clock is off or external clock is used.

kCLOCK_IpSrcSysOscAsync 

System Oscillator async clock.

kCLOCK_IpSrcSircAsync 

Slow IRC async clock.

kCLOCK_IpSrcFircAsync 

Fast IRC async clock.

kCLOCK_IpSrcSysPllAsync 

System PLL async clock.

Definition at line 253 of file fsl_clock.h.

254{
255 kCLOCK_IpSrcNoneOrExt = 0U, /*!< Clock is off or external clock is used. */
256 kCLOCK_IpSrcSysOscAsync = 1U, /*!< System Oscillator async clock. */
257 kCLOCK_IpSrcSircAsync = 2U, /*!< Slow IRC async clock. */
258 kCLOCK_IpSrcFircAsync = 3U, /*!< Fast IRC async clock. */
259 kCLOCK_IpSrcSysPllAsync = 6U /*!< System PLL async clock. */
enum _clock_ip_src clock_ip_src_t
Clock source for peripherals that support various clock selections.
@ kCLOCK_IpSrcSysPllAsync
Definition fsl_clock.h:259
@ kCLOCK_IpSrcSysOscAsync
Definition fsl_clock.h:256
@ kCLOCK_IpSrcSircAsync
Definition fsl_clock.h:257
@ kCLOCK_IpSrcFircAsync
Definition fsl_clock.h:258
@ kCLOCK_IpSrcNoneOrExt
Definition fsl_clock.h:255

◆ _clock_name

Clock name used to get clock frequency.

Enumerator
kCLOCK_CoreSysClk 

Core/system clock

kCLOCK_BusClk 

Bus clock

kCLOCK_FlexBusClk 

FlexBus clock

kCLOCK_FlashClk 

Flash clock

kCLOCK_ScgSysOscClk 

SCG system OSC clock. (SYSOSC)

kCLOCK_ScgSircClk 

SCG SIRC clock.

kCLOCK_ScgFircClk 

SCG FIRC clock.

kCLOCK_ScgSysPllClk 

SCG system PLL clock. (SYSPLL)

kCLOCK_ScgSysOscAsyncDiv1Clk 

SOSCDIV1_CLK.

kCLOCK_ScgSysOscAsyncDiv2Clk 

SOSCDIV2_CLK.

kCLOCK_ScgSircAsyncDiv1Clk 

SIRCDIV1_CLK.

kCLOCK_ScgSircAsyncDiv2Clk 

SIRCDIV2_CLK.

kCLOCK_ScgFircAsyncDiv1Clk 

FIRCDIV1_CLK.

kCLOCK_ScgFircAsyncDiv2Clk 

FIRCDIV2_CLK.

kCLOCK_ScgSysPllAsyncDiv1Clk 

SPLLDIV1_CLK.

kCLOCK_ScgSysPllAsyncDiv2Clk 

SPLLDIV2_CLK.

kCLOCK_LpoClk 

LPO clock

kCLOCK_Osc32kClk 

External OSC 32K clock (OSC32KCLK)

kCLOCK_ErClk 

ERCLK. The external reference clock from SCG.

Definition at line 213 of file fsl_clock.h.

214{
215 /* ----------------------------- System layer clock -------------------------------*/
216 kCLOCK_CoreSysClk, /*!< Core/system clock */
217 kCLOCK_BusClk, /*!< Bus clock */
218 kCLOCK_FlexBusClk, /*!< FlexBus clock */
219 kCLOCK_FlashClk, /*!< Flash clock */
220
221 /* ------------------------------------ SCG clock ---------------------------------*/
222 kCLOCK_ScgSysOscClk, /*!< SCG system OSC clock. (SYSOSC) */
223 kCLOCK_ScgSircClk, /*!< SCG SIRC clock. */
224 kCLOCK_ScgFircClk, /*!< SCG FIRC clock. */
225 kCLOCK_ScgSysPllClk, /*!< SCG system PLL clock. (SYSPLL) */
226
227 kCLOCK_ScgSysOscAsyncDiv1Clk, /*!< SOSCDIV1_CLK. */
228 kCLOCK_ScgSysOscAsyncDiv2Clk, /*!< SOSCDIV2_CLK. */
229
230 kCLOCK_ScgSircAsyncDiv1Clk, /*!< SIRCDIV1_CLK. */
231 kCLOCK_ScgSircAsyncDiv2Clk, /*!< SIRCDIV2_CLK. */
232
233 kCLOCK_ScgFircAsyncDiv1Clk, /*!< FIRCDIV1_CLK. */
234 kCLOCK_ScgFircAsyncDiv2Clk, /*!< FIRCDIV2_CLK. */
235
236 kCLOCK_ScgSysPllAsyncDiv1Clk, /*!< SPLLDIV1_CLK. */
237 kCLOCK_ScgSysPllAsyncDiv2Clk, /*!< SPLLDIV2_CLK. */
238
239 /* --------------------------------- Other clock ----------------------------------*/
240 kCLOCK_LpoClk, /*!< LPO clock */
241 kCLOCK_Osc32kClk, /*!< External OSC 32K clock (OSC32KCLK) */
242 kCLOCK_ErClk, /*!< ERCLK. The external reference clock from SCG. */
enum _clock_name clock_name_t
Clock name used to get clock frequency.
@ kCLOCK_ScgSysOscAsyncDiv1Clk
Definition fsl_clock.h:227
@ kCLOCK_CoreSysClk
Definition fsl_clock.h:216
@ kCLOCK_ScgSysOscClk
Definition fsl_clock.h:222
@ kCLOCK_ScgSysPllAsyncDiv2Clk
Definition fsl_clock.h:237
@ kCLOCK_BusClk
Definition fsl_clock.h:217
@ kCLOCK_ScgSysOscAsyncDiv2Clk
Definition fsl_clock.h:228
@ kCLOCK_ScgFircAsyncDiv2Clk
Definition fsl_clock.h:234
@ kCLOCK_LpoClk
Definition fsl_clock.h:240
@ kCLOCK_ErClk
Definition fsl_clock.h:242
@ kCLOCK_FlexBusClk
Definition fsl_clock.h:218
@ kCLOCK_ScgFircClk
Definition fsl_clock.h:224
@ kCLOCK_ScgSircAsyncDiv1Clk
Definition fsl_clock.h:230
@ kCLOCK_ScgSircClk
Definition fsl_clock.h:223
@ kCLOCK_Osc32kClk
Definition fsl_clock.h:241
@ kCLOCK_FlashClk
Definition fsl_clock.h:219
@ kCLOCK_ScgSircAsyncDiv2Clk
Definition fsl_clock.h:231
@ kCLOCK_ScgFircAsyncDiv1Clk
Definition fsl_clock.h:233
@ kCLOCK_ScgSysPllClk
Definition fsl_clock.h:225
@ kCLOCK_ScgSysPllAsyncDiv1Clk
Definition fsl_clock.h:236

◆ _osc32_mode

OSC32 work mode.

Enumerator
kOSC32_Bypass 

Bypass mode, use external input clock directly.

kOSC32_Crystal 

Crystal mode, does not work in stop mode.

kOSC32_CrystalEnableInStop 

Crystal mode, still work in stop mode.

Definition at line 316 of file fsl_clock.h.

317{
318 kOSC32_Bypass = OSC32_CR_ROSCEN_MASK, /*!< Bypass mode, use external input clock directly. */
319 kOSC32_Crystal = OSC32_CR_ROSCEN_MASK | OSC32_CR_ROSCEREFS_MASK, /*!< Crystal mode, does not work in stop mode. */
320 kOSC32_CrystalEnableInStop = OSC32_CR_ROSCEN_MASK | OSC32_CR_ROSCSTPEN_MASK |
321 OSC32_CR_ROSCEREFS_MASK, /*!< Crystal mode, still work in stop mode. */
enum _osc32_mode osc32_mode_t
OSC32 work mode.
@ kOSC32_CrystalEnableInStop
Definition fsl_clock.h:320
@ kOSC32_Crystal
Definition fsl_clock.h:319
@ kOSC32_Bypass
Definition fsl_clock.h:318

◆ _scg_async_clk

SCG asynchronous clock type.

Enumerator
kSCG_AsyncDiv1Clk 

The async clock by DIV1, e.g. SOSCDIV1_CLK, SIRCDIV1_CLK.

kSCG_AsyncDiv2Clk 

The async clock by DIV2, e.g. SOSCDIV2_CLK, SIRCDIV2_CLK.

Definition at line 407 of file fsl_clock.h.

408{
409 kSCG_AsyncDiv1Clk, /*!< The async clock by DIV1, e.g. SOSCDIV1_CLK, SIRCDIV1_CLK. */
410 kSCG_AsyncDiv2Clk, /*!< The async clock by DIV2, e.g. SOSCDIV2_CLK, SIRCDIV2_CLK. */
enum _scg_async_clk scg_async_clk_t
SCG asynchronous clock type.
@ kSCG_AsyncDiv1Clk
Definition fsl_clock.h:409
@ kSCG_AsyncDiv2Clk
Definition fsl_clock.h:410

◆ _scg_firc_enable_mode

FIRC enable mode.

Enumerator
kSCG_FircEnable 

Enable FIRC clock.

kSCG_FircEnableInStop 

Enable FIRC in stop mode.

kSCG_FircEnableInLowPower 

Enable FIRC in low power mode.

kSCG_FircDisableRegulator 

Disable regulator.

Definition at line 562 of file fsl_clock.h.

563{
564 kSCG_FircEnable = SCG_FIRCCSR_FIRCEN_MASK, /*!< Enable FIRC clock. */
565 kSCG_FircEnableInStop = SCG_FIRCCSR_FIRCSTEN_MASK, /*!< Enable FIRC in stop mode. */
566 kSCG_FircEnableInLowPower = SCG_FIRCCSR_FIRCLPEN_MASK, /*!< Enable FIRC in low power mode. */
567 kSCG_FircDisableRegulator = SCG_FIRCCSR_FIRCREGOFF_MASK /*!< Disable regulator. */
568};
@ kSCG_FircEnable
Definition fsl_clock.h:564
@ kSCG_FircDisableRegulator
Definition fsl_clock.h:567
@ kSCG_FircEnableInLowPower
Definition fsl_clock.h:566
@ kSCG_FircEnableInStop
Definition fsl_clock.h:565

◆ _scg_firc_range

SCG fast IRC clock frequency range.

Enumerator
kSCG_FircRange48M 

Fast IRC is trimmed to 48 MHz.

kSCG_FircRange52M 

Fast IRC is trimmed to 52 MHz.

kSCG_FircRange56M 

Fast IRC is trimmed to 56 MHz.

kSCG_FircRange60M 

Fast IRC is trimmed to 60 MHz.

Definition at line 553 of file fsl_clock.h.

554{
555 kSCG_FircRange48M, /*!< Fast IRC is trimmed to 48 MHz. */
556 kSCG_FircRange52M, /*!< Fast IRC is trimmed to 52 MHz. */
557 kSCG_FircRange56M, /*!< Fast IRC is trimmed to 56 MHz. */
558 kSCG_FircRange60M /*!< Fast IRC is trimmed to 60 MHz. */
enum _scg_firc_range scg_firc_range_t
SCG fast IRC clock frequency range.
@ kSCG_FircRange56M
Definition fsl_clock.h:557
@ kSCG_FircRange60M
Definition fsl_clock.h:558
@ kSCG_FircRange52M
Definition fsl_clock.h:556
@ kSCG_FircRange48M
Definition fsl_clock.h:555

◆ _scg_firc_trim_div

SCG fast IRC trim predivided value for system OSC.

Enumerator
kSCG_FircTrimDivBy1 

Divided by 1.

kSCG_FircTrimDivBy128 

Divided by 128.

kSCG_FircTrimDivBy256 

Divided by 256.

kSCG_FircTrimDivBy512 

Divided by 512.

kSCG_FircTrimDivBy1024 

Divided by 1024.

kSCG_FircTrimDivBy2048 

Divided by 2048.

Definition at line 519 of file fsl_clock.h.

520{
521 kSCG_FircTrimDivBy1, /*!< Divided by 1. */
522 kSCG_FircTrimDivBy128, /*!< Divided by 128. */
523 kSCG_FircTrimDivBy256, /*!< Divided by 256. */
524 kSCG_FircTrimDivBy512, /*!< Divided by 512. */
525 kSCG_FircTrimDivBy1024, /*!< Divided by 1024. */
526 kSCG_FircTrimDivBy2048 /*!< Divided by 2048. */
enum _scg_firc_trim_div scg_firc_trim_div_t
SCG fast IRC trim predivided value for system OSC.
@ kSCG_FircTrimDivBy512
Definition fsl_clock.h:524
@ kSCG_FircTrimDivBy1024
Definition fsl_clock.h:525
@ kSCG_FircTrimDivBy2048
Definition fsl_clock.h:526
@ kSCG_FircTrimDivBy1
Definition fsl_clock.h:521
@ kSCG_FircTrimDivBy128
Definition fsl_clock.h:522
@ kSCG_FircTrimDivBy256
Definition fsl_clock.h:523

◆ _scg_firc_trim_mode

SCG fast IRC trim mode.

Enumerator
kSCG_FircTrimNonUpdate 

FIRC trim enable but not enable trim value update. In this mode, the trim value is fixed to the initialized value which is defined by trimCoar and trimFine in configure structure scg_firc_trim_config_t.

kSCG_FircTrimUpdate 

FIRC trim enable and trim value update enable. In this mode, the trim value is auto update.

Definition at line 503 of file fsl_clock.h.

504{
505 kSCG_FircTrimNonUpdate = SCG_FIRCCSR_FIRCTREN_MASK,
506 /*!< FIRC trim enable but not enable trim value update. In this mode, the
507 trim value is fixed to the initialized value which is defined by
508 trimCoar and trimFine in configure structure \ref scg_firc_trim_config_t.*/
509
510 kSCG_FircTrimUpdate = SCG_FIRCCSR_FIRCTREN_MASK | SCG_FIRCCSR_FIRCTRUP_MASK
511 /*!< FIRC trim enable and trim value update enable. In this mode, the trim
512 value is auto update. */
513
enum _scg_firc_trim_mode scg_firc_trim_mode_t
SCG fast IRC trim mode.
@ kSCG_FircTrimNonUpdate
Definition fsl_clock.h:505
@ kSCG_FircTrimUpdate
Definition fsl_clock.h:510

◆ _scg_firc_trim_src

SCG fast IRC trim source.

Enumerator
kSCG_FircTrimSrcSysOsc 

System OSC.

Definition at line 532 of file fsl_clock.h.

533{
534 kSCG_FircTrimSrcSysOsc = 2U, /*!< System OSC. */
enum _scg_firc_trim_src scg_firc_trim_src_t
SCG fast IRC trim source.
@ kSCG_FircTrimSrcSysOsc
Definition fsl_clock.h:534

◆ _scg_sirc_enable_mode

SIRC enable mode.

Enumerator
kSCG_SircEnable 

Enable SIRC clock.

kSCG_SircEnableInStop 

Enable SIRC in stop mode.

kSCG_SircEnableInLowPower 

Enable SIRC in low power mode.

Definition at line 481 of file fsl_clock.h.

482{
483 kSCG_SircEnable = SCG_SIRCCSR_SIRCEN_MASK, /*!< Enable SIRC clock. */
484 kSCG_SircEnableInStop = SCG_SIRCCSR_SIRCSTEN_MASK, /*!< Enable SIRC in stop mode. */
485 kSCG_SircEnableInLowPower = SCG_SIRCCSR_SIRCLPEN_MASK /*!< Enable SIRC in low power mode. */
486};
@ kSCG_SircEnable
Definition fsl_clock.h:483
@ kSCG_SircEnableInStop
Definition fsl_clock.h:484
@ kSCG_SircEnableInLowPower
Definition fsl_clock.h:485

◆ _scg_sirc_range

SCG slow IRC clock frequency range.

Enumerator
kSCG_SircRangeLow 

Slow IRC low range clock (2 MHz, 4 MHz for i.MX 7 ULP).

kSCG_SircRangeHigh 

Slow IRC high range clock (8 MHz, 16 MHz for i.MX 7 ULP).

Definition at line 474 of file fsl_clock.h.

475{
476 kSCG_SircRangeLow, /*!< Slow IRC low range clock (2 MHz, 4 MHz for i.MX 7 ULP). */
477 kSCG_SircRangeHigh /*!< Slow IRC high range clock (8 MHz, 16 MHz for i.MX 7 ULP). */
enum _scg_sirc_range scg_sirc_range_t
SCG slow IRC clock frequency range.
@ kSCG_SircRangeLow
Definition fsl_clock.h:476
@ kSCG_SircRangeHigh
Definition fsl_clock.h:477

◆ _scg_sosc_enable_mode

OSC enable mode.

Enumerator
kSCG_SysOscEnable 

Enable OSC clock.

kSCG_SysOscEnableInStop 

Enable OSC in stop mode.

kSCG_SysOscEnableInLowPower 

Enable OSC in low power mode.

kSCG_SysOscEnableErClk 

Enable OSCERCLK.

Definition at line 448 of file fsl_clock.h.

449{
450 kSCG_SysOscEnable = SCG_SOSCCSR_SOSCEN_MASK, /*!< Enable OSC clock. */
451 kSCG_SysOscEnableInStop = SCG_SOSCCSR_SOSCSTEN_MASK, /*!< Enable OSC in stop mode. */
452 kSCG_SysOscEnableInLowPower = SCG_SOSCCSR_SOSCLPEN_MASK, /*!< Enable OSC in low power mode. */
453 kSCG_SysOscEnableErClk = SCG_SOSCCSR_SOSCERCLKEN_MASK /*!< Enable OSCERCLK. */
454};
@ kSCG_SysOscEnableErClk
Definition fsl_clock.h:453
@ kSCG_SysOscEnable
Definition fsl_clock.h:450
@ kSCG_SysOscEnableInLowPower
Definition fsl_clock.h:452
@ kSCG_SysOscEnableInStop
Definition fsl_clock.h:451

◆ _scg_sosc_mode

OSC work mode.

Enumerator
kSCG_SysOscModeExt 

Use external clock.

kSCG_SysOscModeOscLowPower 

Oscillator low power.

kSCG_SysOscModeOscHighGain 

Oscillator high gain.

Definition at line 440 of file fsl_clock.h.

441{
442 kSCG_SysOscModeExt = 0U, /*!< Use external clock. */
443 kSCG_SysOscModeOscLowPower = SCG_SOSCCFG_EREFS_MASK, /*!< Oscillator low power. */
444 kSCG_SysOscModeOscHighGain = SCG_SOSCCFG_EREFS_MASK | SCG_SOSCCFG_HGO_MASK /*!< Oscillator high gain. */
enum _scg_sosc_mode scg_sosc_mode_t
OSC work mode.
@ kSCG_SysOscModeOscHighGain
Definition fsl_clock.h:444
@ kSCG_SysOscModeOscLowPower
Definition fsl_clock.h:443
@ kSCG_SysOscModeExt
Definition fsl_clock.h:442

◆ _scg_sosc_monitor_mode

SCG system OSC monitor mode.

Enumerator
kSCG_SysOscMonitorDisable 

Monitor disabled.

kSCG_SysOscMonitorInt 

Interrupt when the system OSC error is detected.

kSCG_SysOscMonitorReset 

Reset when the system OSC error is detected.

Definition at line 431 of file fsl_clock.h.

432{
433 kSCG_SysOscMonitorDisable = 0U, /*!< Monitor disabled. */
434 kSCG_SysOscMonitorInt = SCG_SOSCCSR_SOSCCM_MASK, /*!< Interrupt when the system OSC error is detected. */
436 SCG_SOSCCSR_SOSCCM_MASK | SCG_SOSCCSR_SOSCCMRE_MASK /*!< Reset when the system OSC error is detected. */
enum _scg_sosc_monitor_mode scg_sosc_monitor_mode_t
SCG system OSC monitor mode.
@ kSCG_SysOscMonitorInt
Definition fsl_clock.h:434
@ kSCG_SysOscMonitorReset
Definition fsl_clock.h:435
@ kSCG_SysOscMonitorDisable
Definition fsl_clock.h:433

◆ _scg_spll_enable_mode

SPLL enable mode.

Enumerator
kSCG_SysPllEnable 

Enable SPLL clock.

kSCG_SysPllEnableInStop 

Enable SPLL in stop mode.

Definition at line 606 of file fsl_clock.h.

607{
608 kSCG_SysPllEnable = SCG_SPLLCSR_SPLLEN_MASK, /*!< Enable SPLL clock. */
609 kSCG_SysPllEnableInStop = SCG_SPLLCSR_SPLLSTEN_MASK /*!< Enable SPLL in stop mode. */
610};
@ kSCG_SysPllEnableInStop
Definition fsl_clock.h:609
@ kSCG_SysPllEnable
Definition fsl_clock.h:608

◆ _scg_spll_monitor_mode

SCG system PLL monitor mode.

Enumerator
kSCG_SysPllMonitorDisable 

Monitor disabled.

kSCG_SysPllMonitorInt 

Interrupt when the system PLL error is detected.

kSCG_SysPllMonitorReset 

Reset when the system PLL error is detected.

Definition at line 597 of file fsl_clock.h.

598{
599 kSCG_SysPllMonitorDisable = 0U, /*!< Monitor disabled. */
600 kSCG_SysPllMonitorInt = SCG_SPLLCSR_SPLLCM_MASK, /*!< Interrupt when the system PLL error is detected. */
602 SCG_SPLLCSR_SPLLCM_MASK | SCG_SPLLCSR_SPLLCMRE_MASK /*!< Reset when the system PLL error is detected. */
enum _scg_spll_monitor_mode scg_spll_monitor_mode_t
SCG system PLL monitor mode.
@ kSCG_SysPllMonitorDisable
Definition fsl_clock.h:599
@ kSCG_SysPllMonitorInt
Definition fsl_clock.h:600
@ kSCG_SysPllMonitorReset
Definition fsl_clock.h:601

◆ _scg_spll_src

SCG system PLL clock source.

Enumerator
kSCG_SysPllSrcSysOsc 

System PLL clock source is system OSC.

kSCG_SysPllSrcFirc 

System PLL clock source is fast IRC.

Definition at line 588 of file fsl_clock.h.

589{
590 kSCG_SysPllSrcSysOsc, /*!< System PLL clock source is system OSC. */
591 kSCG_SysPllSrcFirc /*!< System PLL clock source is fast IRC. */
enum _scg_spll_src scg_spll_src_t
SCG system PLL clock source.
@ kSCG_SysPllSrcSysOsc
Definition fsl_clock.h:590
@ kSCG_SysPllSrcFirc
Definition fsl_clock.h:591

◆ _scg_status

SCG status return codes.

Enumerator
kStatus_SCG_Busy 

Clock is busy.

kStatus_SCG_InvalidSrc 

Invalid source.

Definition at line 327 of file fsl_clock.h.

328{
329 kStatus_SCG_Busy = MAKE_STATUS(kStatusGroup_SCG, 1), /*!< Clock is busy. */
330 kStatus_SCG_InvalidSrc = MAKE_STATUS(kStatusGroup_SCG, 2) /*!< Invalid source. */
331};
@ kStatus_SCG_InvalidSrc
Definition fsl_clock.h:330
@ kStatus_SCG_Busy
Definition fsl_clock.h:329
@ kStatusGroup_SCG
Definition fsl_common.h:81

◆ _scg_sys_clk

SCG system clock type.

Enumerator
kSCG_SysClkSlow 

System slow clock.

kSCG_SysClkBus 

Bus clock.

kSCG_SysClkCore 

Core clock.

Definition at line 336 of file fsl_clock.h.

337{
338 kSCG_SysClkSlow, /*!< System slow clock. */
339 kSCG_SysClkBus, /*!< Bus clock. */
340 kSCG_SysClkCore, /*!< Core clock. */
enum _scg_sys_clk scg_sys_clk_t
SCG system clock type.
@ kSCG_SysClkCore
Definition fsl_clock.h:340
@ kSCG_SysClkBus
Definition fsl_clock.h:339
@ kSCG_SysClkSlow
Definition fsl_clock.h:338

◆ _scg_sys_clk_div

SCG system clock divider value.

Enumerator
kSCG_SysClkDivBy1 

Divided by 1.

kSCG_SysClkDivBy2 

Divided by 2.

kSCG_SysClkDivBy3 

Divided by 3.

kSCG_SysClkDivBy4 

Divided by 4.

kSCG_SysClkDivBy5 

Divided by 5.

kSCG_SysClkDivBy6 

Divided by 6.

kSCG_SysClkDivBy7 

Divided by 7.

kSCG_SysClkDivBy8 

Divided by 8.

kSCG_SysClkDivBy9 

Divided by 9.

kSCG_SysClkDivBy10 

Divided by 10.

kSCG_SysClkDivBy11 

Divided by 11.

kSCG_SysClkDivBy12 

Divided by 12.

kSCG_SysClkDivBy13 

Divided by 13.

kSCG_SysClkDivBy14 

Divided by 14.

kSCG_SysClkDivBy15 

Divided by 15.

kSCG_SysClkDivBy16 

Divided by 16.

Definition at line 357 of file fsl_clock.h.

358{
359 kSCG_SysClkDivBy1 = 0U, /*!< Divided by 1. */
360 kSCG_SysClkDivBy2 = 1U, /*!< Divided by 2. */
361 kSCG_SysClkDivBy3 = 2U, /*!< Divided by 3. */
362 kSCG_SysClkDivBy4 = 3U, /*!< Divided by 4. */
363 kSCG_SysClkDivBy5 = 4U, /*!< Divided by 5. */
364 kSCG_SysClkDivBy6 = 5U, /*!< Divided by 6. */
365 kSCG_SysClkDivBy7 = 6U, /*!< Divided by 7. */
366 kSCG_SysClkDivBy8 = 7U, /*!< Divided by 8. */
367 kSCG_SysClkDivBy9 = 8U, /*!< Divided by 9. */
368 kSCG_SysClkDivBy10 = 9U, /*!< Divided by 10. */
369 kSCG_SysClkDivBy11 = 10U, /*!< Divided by 11. */
370 kSCG_SysClkDivBy12 = 11U, /*!< Divided by 12. */
371 kSCG_SysClkDivBy13 = 12U, /*!< Divided by 13. */
372 kSCG_SysClkDivBy14 = 13U, /*!< Divided by 14. */
373 kSCG_SysClkDivBy15 = 14U, /*!< Divided by 15. */
374 kSCG_SysClkDivBy16 = 15U /*!< Divided by 16. */
enum _scg_sys_clk_div scg_sys_clk_div_t
SCG system clock divider value.
@ kSCG_SysClkDivBy16
Definition fsl_clock.h:374
@ kSCG_SysClkDivBy4
Definition fsl_clock.h:362
@ kSCG_SysClkDivBy13
Definition fsl_clock.h:371
@ kSCG_SysClkDivBy10
Definition fsl_clock.h:368
@ kSCG_SysClkDivBy3
Definition fsl_clock.h:361
@ kSCG_SysClkDivBy14
Definition fsl_clock.h:372
@ kSCG_SysClkDivBy11
Definition fsl_clock.h:369
@ kSCG_SysClkDivBy12
Definition fsl_clock.h:370
@ kSCG_SysClkDivBy9
Definition fsl_clock.h:367
@ kSCG_SysClkDivBy5
Definition fsl_clock.h:363
@ kSCG_SysClkDivBy15
Definition fsl_clock.h:373
@ kSCG_SysClkDivBy6
Definition fsl_clock.h:364
@ kSCG_SysClkDivBy1
Definition fsl_clock.h:359
@ kSCG_SysClkDivBy2
Definition fsl_clock.h:360
@ kSCG_SysClkDivBy8
Definition fsl_clock.h:366
@ kSCG_SysClkDivBy7
Definition fsl_clock.h:365

◆ _scg_sys_clk_src

SCG system clock source.

Enumerator
kSCG_SysClkSrcSysOsc 

System OSC.

kSCG_SysClkSrcSirc 

Slow IRC.

kSCG_SysClkSrcFirc 

Fast IRC.

kSCG_SysClkSrcSysPll 

System PLL.

Definition at line 346 of file fsl_clock.h.

347{
348 kSCG_SysClkSrcSysOsc = 1U, /*!< System OSC. */
349 kSCG_SysClkSrcSirc = 2U, /*!< Slow IRC. */
350 kSCG_SysClkSrcFirc = 3U, /*!< Fast IRC. */
351 kSCG_SysClkSrcSysPll = 6U /*!< System PLL. */
enum _scg_sys_clk_src scg_sys_clk_src_t
SCG system clock source.
@ kSCG_SysClkSrcSysPll
Definition fsl_clock.h:351
@ kSCG_SysClkSrcSysOsc
Definition fsl_clock.h:348
@ kSCG_SysClkSrcFirc
Definition fsl_clock.h:350
@ kSCG_SysClkSrcSirc
Definition fsl_clock.h:349

◆ scg_async_clk_div

SCG asynchronous clock divider value.

Enumerator
kSCG_AsyncClkDisable 

Clock output is disabled.

kSCG_AsyncClkDivBy1 

Divided by 1.

kSCG_AsyncClkDivBy2 

Divided by 2.

kSCG_AsyncClkDivBy4 

Divided by 4.

kSCG_AsyncClkDivBy8 

Divided by 8.

kSCG_AsyncClkDivBy16 

Divided by 16.

kSCG_AsyncClkDivBy32 

Divided by 32.

kSCG_AsyncClkDivBy64 

Divided by 64.

Definition at line 416 of file fsl_clock.h.

417{
418 kSCG_AsyncClkDisable = 0U, /*!< Clock output is disabled. */
419 kSCG_AsyncClkDivBy1 = 1U, /*!< Divided by 1. */
420 kSCG_AsyncClkDivBy2 = 2U, /*!< Divided by 2. */
421 kSCG_AsyncClkDivBy4 = 3U, /*!< Divided by 4. */
422 kSCG_AsyncClkDivBy8 = 4U, /*!< Divided by 8. */
423 kSCG_AsyncClkDivBy16 = 5U, /*!< Divided by 16. */
424 kSCG_AsyncClkDivBy32 = 6U, /*!< Divided by 32. */
425 kSCG_AsyncClkDivBy64 = 7U /*!< Divided by 64. */
enum scg_async_clk_div scg_async_clk_div_t
SCG asynchronous clock divider value.
@ kSCG_AsyncClkDivBy2
Definition fsl_clock.h:420
@ kSCG_AsyncClkDivBy8
Definition fsl_clock.h:422
@ kSCG_AsyncClkDivBy1
Definition fsl_clock.h:419
@ kSCG_AsyncClkDivBy64
Definition fsl_clock.h:425
@ kSCG_AsyncClkDisable
Definition fsl_clock.h:418
@ kSCG_AsyncClkDivBy16
Definition fsl_clock.h:423
@ kSCG_AsyncClkDivBy32
Definition fsl_clock.h:424
@ kSCG_AsyncClkDivBy4
Definition fsl_clock.h:421

Function Documentation

◆ CLOCK_ClearFircErr()

static void CLOCK_ClearFircErr ( void  )
inlinestatic

Clears the FIRC clock error.

Definition at line 1140 of file fsl_clock.h.

1141{
1142 SCG->FIRCCSR |= SCG_FIRCCSR_FIRCERR_MASK;
1143}

◆ CLOCK_ClearSysOscErr()

static void CLOCK_ClearSysOscErr ( void  )
inlinestatic

Clears the system OSC clock error.

Definition at line 932 of file fsl_clock.h.

933{
934 SCG->SOSCCSR |= SCG_SOSCCSR_SOSCERR_MASK;
935}

◆ CLOCK_ClearSysPllErr()

static void CLOCK_ClearSysPllErr ( void  )
inlinestatic

Clears the system PLL clock error.

Definition at line 1282 of file fsl_clock.h.

1283{
1284 SCG->SPLLCSR |= SCG_SPLLCSR_SPLLERR_MASK;
1285}

◆ CLOCK_DeinitFirc()

status_t CLOCK_DeinitFirc ( void  )

De-initializes the SCG fast IRC.

This function disables the SCG fast IRC.

Return values
kStatus_SuccessFIRC is deinitialized.
kStatus_SCG_BusyFIRC is used by the system clock.
kStatus_ReadOnlyFIRC control register is locked.
Note
This function can't detect whether the FIRC is used by an IP.

brief De-initializes the SCG fast IRC.

This function disables the SCG fast IRC.

retval kStatus_Success FIRC is deinitialized. retval kStatus_SCG_Busy FIRC is used by the system clock. retval kStatus_ReadOnly FIRC control register is locked.

note This function can't detect whether the FIRC is used by an IP.

Definition at line 755 of file fsl_clock.c.

756{
757 uint32_t reg = SCG->FIRCCSR;
758
759 /* If clock is used by system, return error. */
760 if (reg & SCG_FIRCCSR_FIRCSEL_MASK)
761 {
762 return kStatus_SCG_Busy;
763 }
764
765 /* If configure register is locked, return error. */
766 if (reg & SCG_FIRCCSR_LK_MASK)
767 {
768 return kStatus_ReadOnly;
769 }
770
771 SCG->FIRCCSR = SCG_FIRCCSR_FIRCERR_MASK;
772
773 return kStatus_Success;
774}
@ kStatus_ReadOnly
Definition fsl_common.h:161
@ kStatus_Success
Definition fsl_common.h:159

Referenced by CLOCK_InitFirc().

Here is the caller graph for this function:

◆ CLOCK_DeinitSirc()

status_t CLOCK_DeinitSirc ( void  )

De-initializes the SCG slow IRC.

This function disables the SCG slow IRC.

Return values
kStatus_SuccessSIRC is deinitialized.
kStatus_SCG_BusySIRC is used by system clock.
kStatus_ReadOnlySIRC control register is locked.
Note
This function can't detect whether the SIRC is used by an IP.

brief De-initializes the SCG slow IRC.

This function disables the SCG slow IRC.

retval kStatus_Success SIRC is deinitialized. retval kStatus_SCG_Busy SIRC is used by system clock. retval kStatus_ReadOnly SIRC control register is locked.

note This function can't detect whether the SIRC is used by an IP.

Definition at line 601 of file fsl_clock.c.

602{
603 uint32_t reg = SCG->SIRCCSR;
604
605 /* If clock is used by system, return error. */
606 if (reg & SCG_SIRCCSR_SIRCSEL_MASK)
607 {
608 return kStatus_SCG_Busy;
609 }
610
611 /* If configure register is locked, return error. */
612 if (reg & SCG_SIRCCSR_LK_MASK)
613 {
614 return kStatus_ReadOnly;
615 }
616
617 SCG->SIRCCSR = 0U;
618
619 return kStatus_Success;
620}

Referenced by CLOCK_InitSirc().

Here is the caller graph for this function:

◆ CLOCK_DeinitSysOsc()

status_t CLOCK_DeinitSysOsc ( void  )

De-initializes the SCG system OSC.

This function disables the SCG system OSC clock.

Return values
kStatus_SuccessSystem OSC is deinitialized.
kStatus_SCG_BusySystem OSC is used by the system clock.
kStatus_ReadOnlySystem OSC control register is locked.
Note
This function can't detect whether the system OSC is used by an IP.

brief De-initializes the SCG system OSC.

This function disables the SCG system OSC clock.

retval kStatus_Success System OSC is deinitialized. retval kStatus_SCG_Busy System OSC is used by the system clock. retval kStatus_ReadOnly System OSC control register is locked.

note This function can't detect whether the system OSC is used by an IP.

Definition at line 468 of file fsl_clock.c.

469{
470 uint32_t reg = SCG->SOSCCSR;
471
472 /* If clock is used by system, return error. */
473 if (reg & SCG_SOSCCSR_SOSCSEL_MASK)
474 {
475 return kStatus_SCG_Busy;
476 }
477
478 /* If configure register is locked, return error. */
479 if (reg & SCG_SOSCCSR_LK_MASK)
480 {
481 return kStatus_ReadOnly;
482 }
483
484 SCG->SOSCCSR = SCG_SOSCCSR_SOSCERR_MASK;
485
486 return kStatus_Success;
487}

Referenced by CLOCK_InitSysOsc().

Here is the caller graph for this function:

◆ CLOCK_DeinitSysPll()

status_t CLOCK_DeinitSysPll ( void  )

De-initializes the SCG system PLL.

This function disables the SCG system PLL.

Return values
kStatus_Successsystem PLL is deinitialized.
kStatus_SCG_Busysystem PLL is used by the system clock.
kStatus_ReadOnlySystem PLL control register is locked.
Note
This function can't detect whether the system PLL is used by an IP.

brief De-initializes the SCG system PLL.

This function disables the SCG system PLL.

retval kStatus_Success system PLL is deinitialized. retval kStatus_SCG_Busy system PLL is used by the system clock. retval kStatus_ReadOnly System PLL control register is locked.

note This function can't detect whether the system PLL is used by an IP.

Definition at line 1031 of file fsl_clock.c.

1032{
1033 uint32_t reg = SCG->SPLLCSR;
1034
1035 /* If clock is used by system, return error. */
1036 if (reg & SCG_SPLLCSR_SPLLSEL_MASK)
1037 {
1038 return kStatus_SCG_Busy;
1039 }
1040
1041 /* If configure register is locked, return error. */
1042 if (reg & SCG_SPLLCSR_LK_MASK)
1043 {
1044 return kStatus_ReadOnly;
1045 }
1046
1047 /* Deinit and clear the error. */
1048 SCG->SPLLCSR = SCG_SPLLCSR_SPLLERR_MASK;
1049
1050 return kStatus_Success;
1051}

Referenced by CLOCK_InitSysPll().

Here is the caller graph for this function:

◆ CLOCK_DisableClock()

static void CLOCK_DisableClock ( clock_ip_name_t  name)
inlinestatic

Disable the clock for specific IP.

Parameters
nameWhich clock to disable, see clock_ip_name_t.

Definition at line 653 of file fsl_clock.h.

654{
655 assert((*(volatile uint32_t *)name) & PCC_CLKCFG_PR_MASK);
656
657 (*(volatile uint32_t *)name) &= ~PCC_CLKCFG_CGC_MASK;
658}

Referenced by ACMP_Deinit(), ADC12_Deinit(), DMAMUX_Deinit(), EDMA_Deinit(), LPSPI_Deinit(), LPUART_Deinit(), and OSC32_Deinit().

Here is the caller graph for this function:

◆ CLOCK_EnableClock()

static void CLOCK_EnableClock ( clock_ip_name_t  name)
inlinestatic

Enable the clock for specific IP.

Parameters
nameWhich clock to enable, see clock_ip_name_t.

Definition at line 641 of file fsl_clock.h.

642{
643 assert((*(volatile uint32_t *)name) & PCC_CLKCFG_PR_MASK);
644
645 (*(volatile uint32_t *)name) |= PCC_CLKCFG_CGC_MASK;
646}

Referenced by ACMP_Init(), ADC12_Init(), DMAMUX_Init(), EDMA_Init(), LPSPI_MasterInit(), LPSPI_SlaveInit(), LPUART_Init(), OSC32_Init(), and pwm_lld_start().

Here is the caller graph for this function:

◆ CLOCK_GetBusClkFreq()

uint32_t CLOCK_GetBusClkFreq ( void  )

Get the bus clock frequency.

Returns
Clock frequency in Hz.

brief Get the bus clock frequency.

return Clock frequency in Hz.

Definition at line 144 of file fsl_clock.c.

145{
147}
uint32_t CLOCK_GetSysClkFreq(scg_sys_clk_t type)
Gets the SCG system clock frequency.
Definition fsl_clock.c:339
Here is the call graph for this function:

◆ CLOCK_GetCoreSysClkFreq()

uint32_t CLOCK_GetCoreSysClkFreq ( void  )

Get the core clock or system clock frequency.

Returns
Clock frequency in Hz.

brief Get the core clock or system clock frequency.

return Clock frequency in Hz.

Definition at line 154 of file fsl_clock.c.

155{
157}
Here is the call graph for this function:

◆ CLOCK_GetCurSysClkConfig()

static void CLOCK_GetCurSysClkConfig ( scg_sys_clk_config_t config)
inlinestatic

Gets the system clock configuration in the current power mode.

This function gets the system configuration in the current power mode.

Parameters
configPointer to the configuration.

Definition at line 823 of file fsl_clock.h.

824{
825 assert(config);
826
827 *(uint32_t *)config = SCG->CSR;
828}
static constexpr persistent_config_s * config

Referenced by CLOCK_CONFIG_FircSafeConfig(), CLOCK_GetSysClkFreq(), and setClockConfig().

Here is the caller graph for this function:

◆ CLOCK_GetErClkFreq()

uint32_t CLOCK_GetErClkFreq ( void  )

Get the external reference clock frequency (ERCLK).

Returns
Clock frequency in Hz.

brief Get the external reference clock frequency (ERCLK).

return Clock frequency in Hz.

Definition at line 104 of file fsl_clock.c.

105{
106 if (SCG->SOSCCSR & SCG_SOSCCSR_SOSCEN_MASK)
107 {
108 /* Please call CLOCK_SetXtal0Freq base on board setting before using OSC0 clock. */
109 assert(g_xtal0Freq);
110 return g_xtal0Freq;
111 }
112 else
113 {
114 return 0U;
115 }
116}
volatile uint32_t g_xtal0Freq
External XTAL0 (OSC0/SYSOSC) clock frequency.
Definition fsl_clock.c:75

Referenced by CLOCK_GetFreq().

Here is the caller graph for this function:

◆ CLOCK_GetFircAsyncFreq()

uint32_t CLOCK_GetFircAsyncFreq ( scg_async_clk_t  type)

Gets the SCG asynchronous clock frequency from the FIRC.

Parameters
typeThe asynchronous clock type.
Returns
Clock frequency; If the clock is invalid, returns 0.

brief Gets the SCG asynchronous clock frequency from the FIRC.

param type The asynchronous clock type. return Clock frequency; If the clock is invalid, returns 0.

Definition at line 803 of file fsl_clock.c.

804{
805 uint32_t fircFreq = CLOCK_GetFircFreq();
806 uint32_t divider = 0U;
807
808 /* Get divider. */
809 if (fircFreq)
810 {
811 switch (type)
812 {
813 case kSCG_AsyncDiv2Clk: /* FIRCDIV2_CLK. */
814 divider = SCG_FIRCDIV_FIRCDIV2_VAL;
815 break;
816 case kSCG_AsyncDiv1Clk: /* FIRCDIV1_CLK. */
817 divider = SCG_FIRCDIV_FIRCDIV1_VAL;
818 break;
819 default:
820 break;
821 }
822 }
823 if (divider)
824 {
825 return fircFreq >> (divider - 1U);
826 }
827 else /* Output disabled. */
828 {
829 return 0U;
830 }
831}
uint32_t CLOCK_GetFircFreq(void)
Gets the SCG FIRC clock frequency.
Definition fsl_clock.c:781

Referenced by CLOCK_GetFreq(), and CLOCK_GetIpFreq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CLOCK_GetFircFreq()

uint32_t CLOCK_GetFircFreq ( void  )

Gets the SCG FIRC clock frequency.

Returns
Clock frequency; If the clock is invalid, returns 0.

brief Gets the SCG FIRC clock frequency.

return Clock frequency; If the clock is invalid, returns 0.

Definition at line 781 of file fsl_clock.c.

782{
783 static const uint32_t fircFreq[] = {
784 SCG_FIRC_FREQ0, SCG_FIRC_FREQ1, SCG_FIRC_FREQ2, SCG_FIRC_FREQ3,
785 };
786
787 if (SCG->FIRCCSR & SCG_FIRCCSR_FIRCVLD_MASK) /* FIRC is valid. */
788 {
789 return fircFreq[SCG_FIRCCFG_RANGE_VAL];
790 }
791 else
792 {
793 return 0U;
794 }
795}

Referenced by CLOCK_GetFircAsyncFreq(), CLOCK_GetFreq(), CLOCK_GetSysClkFreq(), and CLOCK_GetSysPllCommonFreq().

Here is the caller graph for this function:

◆ CLOCK_GetFlashClkFreq()

uint32_t CLOCK_GetFlashClkFreq ( void  )

Get the flash clock frequency.

Returns
Clock frequency in Hz.

brief Get the flash clock frequency.

return Clock frequency in Hz.

Definition at line 134 of file fsl_clock.c.

135{
137}
Here is the call graph for this function:

◆ CLOCK_GetFreq()

uint32_t CLOCK_GetFreq ( clock_name_t  clockName)

Gets the clock frequency for a specific clock name.

This function checks the current clock configurations and then calculates the clock frequency for a specific clock name defined in clock_name_t.

Parameters
clockNameClock names defined in clock_name_t
Returns
Clock frequency value in hertz

brief Gets the clock frequency for a specific clock name.

This function checks the current clock configurations and then calculates the clock frequency for a specific clock name defined in clock_name_t.

param clockName Clock names defined in clock_name_t return Clock frequency value in hertz

Definition at line 168 of file fsl_clock.c.

169{
170 uint32_t freq;
171
172 switch (clockName)
173 {
176 break;
177 case kCLOCK_BusClk:
179 break;
180 case kCLOCK_FlashClk:
182 break;
183
185 freq = CLOCK_GetSysOscFreq();
186 break;
188 freq = CLOCK_GetSircFreq();
189 break;
191 freq = CLOCK_GetFircFreq();
192 break;
194 freq = CLOCK_GetSysPllFreq();
195 break;
196
199 break;
202 break;
203
206 break;
209 break;
210
213 break;
216 break;
217
220 break;
223 break;
224
225 case kCLOCK_LpoClk:
226 freq = LPO_CLK_FREQ;
227 break;
228 case kCLOCK_Osc32kClk:
229 freq = CLOCK_GetOsc32kClkFreq();
230 break;
231 case kCLOCK_ErClk:
232 freq = CLOCK_GetErClkFreq();
233 break;
234 default:
235 freq = 0U;
236 break;
237 }
238 return freq;
239}
uint32_t CLOCK_GetSysPllFreq(void)
Gets the SCG system PLL clock frequency.
Definition fsl_clock.c:1080
uint32_t CLOCK_GetSysPllAsyncFreq(scg_async_clk_t type)
Gets the SCG asynchronous clock frequency from the system PLL.
Definition fsl_clock.c:1102
uint32_t CLOCK_GetSircFreq(void)
Gets the SCG SIRC clock frequency.
Definition fsl_clock.c:627
uint32_t CLOCK_GetErClkFreq(void)
Get the external reference clock frequency (ERCLK).
Definition fsl_clock.c:104
uint32_t CLOCK_GetSircAsyncFreq(scg_async_clk_t type)
Gets the SCG asynchronous clock frequency from the SIRC.
Definition fsl_clock.c:647
uint32_t CLOCK_GetSysOscFreq(void)
Gets the SCG system OSC clock frequency (SYSOSC).
Definition fsl_clock.c:494
uint32_t CLOCK_GetOsc32kClkFreq(void)
Get the OSC 32K clock frequency (OSC32KCLK).
Definition fsl_clock.c:123
uint32_t CLOCK_GetFircAsyncFreq(scg_async_clk_t type)
Gets the SCG asynchronous clock frequency from the FIRC.
Definition fsl_clock.c:803
uint32_t CLOCK_GetSysOscAsyncFreq(scg_async_clk_t type)
Gets the SCG asynchronous clock frequency from the system OSC.
Definition fsl_clock.c:514
Here is the call graph for this function:

◆ CLOCK_GetIpFreq()

uint32_t CLOCK_GetIpFreq ( clock_ip_name_t  name)

Gets the clock frequency for a specific IP module.

This function gets the IP module clock frequency based on PCC registers. It is only used for the IP modules which could select clock source by PCC[PCS].

Parameters
nameWhich peripheral to get, see clock_ip_name_t.
Returns
Clock frequency value in hertz

brief Gets the clock frequency for a specific IP module.

This function gets the IP module clock frequency based on PCC registers. It is only used for the IP modules which could select clock source by PCC[PCS].

param name Which peripheral to get, see clock_ip_name_t. return Clock frequency value in hertz

Definition at line 250 of file fsl_clock.c.

251{
252 uint32_t reg = (*(volatile uint32_t *)name);
253
254 scg_async_clk_t asycClk;
255 uint32_t freq;
256
257 assert(reg & PCC_CLKCFG_PR_MASK);
258
259 /* FTM uses SCG DIV1 clock, others use SCG DIV2 clock. */
260 if ((kCLOCK_Ftm0 == name) || (kCLOCK_Ftm1 == name) || (kCLOCK_Ftm2 == name) || (kCLOCK_Ftm3 == name))
261 {
262 asycClk = kSCG_AsyncDiv1Clk;
263 }
264 else
265 {
266 asycClk = kSCG_AsyncDiv2Clk;
267 }
268
269 switch (PCC_PCS_VAL(reg))
270 {
272 freq = CLOCK_GetSysOscAsyncFreq(asycClk);
273 break;
275 freq = CLOCK_GetSircAsyncFreq(asycClk);
276 break;
278 freq = CLOCK_GetFircAsyncFreq(asycClk);
279 break;
281 freq = CLOCK_GetSysPllAsyncFreq(asycClk);
282 break;
283 default:
284 freq = 0U;
285 break;
286 }
287
288 return freq;
289}

Referenced by spi_lld_start().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CLOCK_GetOsc32kClkFreq()

uint32_t CLOCK_GetOsc32kClkFreq ( void  )

Get the OSC 32K clock frequency (OSC32KCLK).

Returns
Clock frequency in Hz.

brief Get the OSC 32K clock frequency (OSC32KCLK).

return Clock frequency in Hz.

Definition at line 123 of file fsl_clock.c.

124{
125 assert(g_xtal32Freq);
126 return g_xtal32Freq;
127}
volatile uint32_t g_xtal32Freq
External XTAL32/EXTAL32 clock frequency.
Definition fsl_clock.c:77

Referenced by CLOCK_GetFreq().

Here is the caller graph for this function:

◆ CLOCK_GetSircAsyncFreq()

uint32_t CLOCK_GetSircAsyncFreq ( scg_async_clk_t  type)

Gets the SCG asynchronous clock frequency from the SIRC.

Parameters
typeThe asynchronous clock type.
Returns
Clock frequency; If the clock is invalid, returns 0.

brief Gets the SCG asynchronous clock frequency from the SIRC.

param type The asynchronous clock type. return Clock frequency; If the clock is invalid, returns 0.

Definition at line 647 of file fsl_clock.c.

648{
649 uint32_t sircFreq = CLOCK_GetSircFreq();
650 uint32_t divider = 0U;
651
652 /* Get divider. */
653 if (sircFreq)
654 {
655 switch (type)
656 {
657 case kSCG_AsyncDiv2Clk: /* SIRCDIV2_CLK. */
658 divider = SCG_SIRCDIV_SIRCDIV2_VAL;
659 break;
660 case kSCG_AsyncDiv1Clk: /* SIRCDIV2_CLK. */
661 divider = SCG_SIRCDIV_SIRCDIV1_VAL;
662 break;
663 default:
664 break;
665 }
666 }
667 if (divider)
668 {
669 return sircFreq >> (divider - 1U);
670 }
671 else /* Output disabled. */
672 {
673 return 0U;
674 }
675}

Referenced by CLOCK_GetFreq(), and CLOCK_GetIpFreq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CLOCK_GetSircFreq()

uint32_t CLOCK_GetSircFreq ( void  )

Gets the SCG SIRC clock frequency.

Returns
Clock frequency; If the clock is invalid, returns 0.

brief Gets the SCG SIRC clock frequency.

return Clock frequency; If the clock is invalid, returns 0.

Definition at line 627 of file fsl_clock.c.

628{
629 static const uint32_t sircFreq[] = {SCG_SIRC_LOW_RANGE_FREQ, SCG_SIRC_HIGH_RANGE_FREQ};
630
631 if (SCG->SIRCCSR & SCG_SIRCCSR_SIRCVLD_MASK) /* SIRC is valid. */
632 {
633 return sircFreq[SCG_SIRCCFG_RANGE_VAL];
634 }
635 else
636 {
637 return 0U;
638 }
639}

Referenced by CLOCK_GetFreq(), CLOCK_GetSircAsyncFreq(), and CLOCK_GetSysClkFreq().

Here is the caller graph for this function:

◆ CLOCK_GetSysClkFreq()

uint32_t CLOCK_GetSysClkFreq ( scg_sys_clk_t  type)

Gets the SCG system clock frequency.

This function gets the SCG system clock frequency. These clocks are used for core, platform, external, and bus clock domains.

Parameters
typeWhich type of clock to get, core clock or slow clock.
Returns
Clock frequency.

brief Gets the SCG system clock frequency.

This function gets the SCG system clock frequency. These clocks are used for core, platform, external, and bus clock domains.

param type Which type of clock to get, core clock or slow clock. return Clock frequency.

Definition at line 339 of file fsl_clock.c.

340{
341 uint32_t freq;
342
343 scg_sys_clk_config_t sysClkConfig;
344
345 CLOCK_GetCurSysClkConfig(&sysClkConfig);
346
347 switch (sysClkConfig.src)
348 {
350 freq = CLOCK_GetSysOscFreq();
351 break;
353 freq = CLOCK_GetSircFreq();
354 break;
356 freq = CLOCK_GetFircFreq();
357 break;
359 freq = CLOCK_GetSysPllFreq();
360 break;
361 default:
362 freq = 0U;
363 break;
364 }
365
366 freq /= (sysClkConfig.divCore + 1U);
367
368 if (kSCG_SysClkSlow == type)
369 {
370 freq /= (sysClkConfig.divSlow + 1U);
371 }
372 else if (kSCG_SysClkBus == type)
373 {
374 freq /= (sysClkConfig.divBus + 1U);
375 }
376 else
377 {
378 }
379
380 return freq;
381}
static void CLOCK_GetCurSysClkConfig(scg_sys_clk_config_t *config)
Gets the system clock configuration in the current power mode.
Definition fsl_clock.h:823
SCG system clock configuration.
Definition fsl_clock.h:381

Referenced by CLOCK_GetBusClkFreq(), CLOCK_GetCoreSysClkFreq(), CLOCK_GetFlashClkFreq(), and CLOCK_GetFreq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CLOCK_GetSysOscAsyncFreq()

uint32_t CLOCK_GetSysOscAsyncFreq ( scg_async_clk_t  type)

Gets the SCG asynchronous clock frequency from the system OSC.

Parameters
typeThe asynchronous clock type.
Returns
Clock frequency; If the clock is invalid, returns 0.

brief Gets the SCG asynchronous clock frequency from the system OSC.

param type The asynchronous clock type. return Clock frequency; If the clock is invalid, returns 0.

Definition at line 514 of file fsl_clock.c.

515{
516 uint32_t oscFreq = CLOCK_GetSysOscFreq();
517 uint32_t divider = 0U;
518
519 /* Get divider. */
520 if (oscFreq)
521 {
522 switch (type)
523 {
524 case kSCG_AsyncDiv2Clk: /* SOSCDIV2_CLK. */
525 divider = SCG_SOSCDIV_SOSCDIV2_VAL;
526 break;
527 case kSCG_AsyncDiv1Clk: /* SOSCDIV1_CLK. */
528 divider = SCG_SOSCDIV_SOSCDIV1_VAL;
529 break;
530 default:
531 break;
532 }
533 }
534 if (divider)
535 {
536 return oscFreq >> (divider - 1U);
537 }
538 else /* Output disabled. */
539 {
540 return 0U;
541 }
542}

Referenced by CLOCK_GetFreq(), and CLOCK_GetIpFreq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CLOCK_GetSysOscFreq()

uint32_t CLOCK_GetSysOscFreq ( void  )

Gets the SCG system OSC clock frequency (SYSOSC).

Returns
Clock frequency; If the clock is invalid, returns 0.

brief Gets the SCG system OSC clock frequency (SYSOSC).

return Clock frequency; If the clock is invalid, returns 0.

Definition at line 494 of file fsl_clock.c.

495{
496 if (SCG->SOSCCSR & SCG_SOSCCSR_SOSCVLD_MASK) /* System OSC clock is valid. */
497 {
498 /* Please call CLOCK_SetXtal0Freq base on board setting before using OSC0 clock. */
499 assert(g_xtal0Freq);
500 return g_xtal0Freq;
501 }
502 else
503 {
504 return 0U;
505 }
506}

Referenced by CLOCK_GetFreq(), CLOCK_GetSysClkFreq(), CLOCK_GetSysOscAsyncFreq(), and CLOCK_GetSysPllCommonFreq().

Here is the caller graph for this function:

◆ CLOCK_GetSysPllAsyncFreq()

uint32_t CLOCK_GetSysPllAsyncFreq ( scg_async_clk_t  type)

Gets the SCG asynchronous clock frequency from the system PLL.

Parameters
typeThe asynchronous clock type.
Returns
Clock frequency; If the clock is invalid, returns 0.

brief Gets the SCG asynchronous clock frequency from the system PLL.

param type The asynchronous clock type. return Clock frequency; If the clock is invalid, returns 0.

Definition at line 1102 of file fsl_clock.c.

1103{
1104 uint32_t pllFreq = CLOCK_GetSysPllFreq();
1105 uint32_t divider = 0U;
1106
1107 /* Get divider. */
1108 if (pllFreq)
1109 {
1110 switch (type)
1111 {
1112 case kSCG_AsyncDiv2Clk: /* SPLLDIV2_CLK. */
1113 divider = SCG_SPLLDIV_SPLLDIV2_VAL;
1114 break;
1115 case kSCG_AsyncDiv1Clk: /* SPLLDIV1_CLK. */
1116 divider = SCG_SPLLDIV_SPLLDIV1_VAL;
1117 break;
1118 default:
1119 break;
1120 }
1121 }
1122 if (divider)
1123 {
1124 return pllFreq >> (divider - 1U);
1125 }
1126 else /* Output disabled. */
1127 {
1128 return 0U;
1129 }
1130}

Referenced by CLOCK_GetFreq(), and CLOCK_GetIpFreq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CLOCK_GetSysPllFreq()

uint32_t CLOCK_GetSysPllFreq ( void  )

Gets the SCG system PLL clock frequency.

Returns
Clock frequency; If the clock is invalid, returns 0.

brief Gets the SCG system PLL clock frequency.

return Clock frequency; If the clock is invalid, returns 0.

Definition at line 1080 of file fsl_clock.c.

1081{
1082 uint32_t freq;
1083
1084 if (SCG->SPLLCSR & SCG_SPLLCSR_SPLLVLD_MASK) /* System PLL is valid. */
1085 {
1087
1088 return freq >> 1U;
1089 }
1090 else
1091 {
1092 return 0U;
1093 }
1094}
static uint32_t CLOCK_GetSysPllCommonFreq(void)
Get the common System PLL frequency for both RAW SPLL output and SPLL PFD output.
Definition fsl_clock.c:1053

Referenced by CLOCK_GetFreq(), CLOCK_GetSysClkFreq(), and CLOCK_GetSysPllAsyncFreq().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CLOCK_GetSysPllMultDiv()

uint32_t CLOCK_GetSysPllMultDiv ( uint32_t  refFreq,
uint32_t  desireFreq,
uint8_t *  mult,
uint8_t *  prediv 
)

Calculates the MULT and PREDIV for the PLL.

This function calculates the proper MULT and PREDIV to generate the desired PLL output frequency with the input reference clock frequency. It returns the closest frequency match that the PLL can generate. The corresponding MULT/PREDIV are returned with parameters. If the desired frequency is not valid, this function returns 0.

Parameters
refFreqThe input reference clock frequency.
desireFreqThe desired output clock frequency.
multThe value of MULT.
predivThe value of PREDIV.
Returns
The PLL output frequency with the MULT and PREDIV; If the desired frequency can't be generated, this function returns 0U.

brief Calculates the MULT and PREDIV for the PLL.

This function calculates the proper MULT and PREDIV to generate the desired PLL output frequency with the input reference clock frequency. It returns the closest frequency match that the PLL can generate. The corresponding MULT/PREDIV are returned with parameters. If the desired frequency is not valid, this function returns 0.

param refFreq The input reference clock frequency. param desireFreq The desired output clock frequency. param mult The value of MULT. param prediv The value of PREDIV. return The PLL output frequency with the MULT and PREDIV; If the desired frequency can't be generated, this function returns 0U.

Definition at line 848 of file fsl_clock.c.

849{
850 uint8_t ret_prediv; /* PREDIV to return */
851 uint8_t ret_mult; /* MULT to return */
852 uint8_t prediv_min; /* Minimal PREDIV value to make reference clock in allowed range. */
853 uint8_t prediv_max; /* Max PREDIV value to make reference clock in allowed range. */
854 uint8_t prediv_cur; /* PREDIV value for iteration. */
855 uint8_t mult_cur; /* MULT value for iteration. */
856 uint32_t ret_freq = 0U; /* Output frequency to return .*/
857 uint32_t diff = 0xFFFFFFFFU; /* Difference between desireFreq and return frequency. */
858 uint32_t ref_div; /* Reference frequency after PREDIV. */
859
860 /*
861 * Steps:
862 * 1. Get allowed prediv with such rules:
863 * 1). refFreq / prediv >= SCG_PLL_REF_MIN.
864 * 2). refFreq / prediv <= SCG_PLL_REF_MAX.
865 * 2. For each allowed prediv, there are two candidate mult values:
866 * 1). (desireFreq / (refFreq / prediv)).
867 * 2). (desireFreq / (refFreq / prediv)) + 1.
868 * If could get the precise desired frequency, return current prediv and
869 * mult directly. Otherwise choose the one which is closer to desired
870 * frequency.
871 */
872
873 /* Reference frequency is out of range. */
874 if ((refFreq < SCG_SPLL_REF_MIN) ||
875 (refFreq > (SCG_SPLL_REF_MAX * (SCG_SPLL_PREDIV_MAX_VALUE + SCG_SPLL_PREDIV_BASE_VALUE))))
876 {
877 return 0U;
878 }
879
880 /* refFreq/PREDIV must in a range. First get the allowed PREDIV range. */
881 prediv_max = refFreq / SCG_SPLL_REF_MIN;
882 prediv_min = (refFreq + SCG_SPLL_REF_MAX - 1U) / SCG_SPLL_REF_MAX;
883
884 desireFreq *= 2U;
885
886 /* PREDIV traversal. */
887 for (prediv_cur = prediv_max; prediv_cur >= prediv_min; prediv_cur--)
888 {
889 /*
890 * For each PREDIV, the available MULT is (desireFreq*PREDIV/refFreq)
891 * or (desireFreq*PREDIV/refFreq + 1U). This function chooses the closer
892 * one.
893 */
894 /* Reference frequency after PREDIV. */
895 ref_div = refFreq / prediv_cur;
896
897 mult_cur = desireFreq / ref_div;
898
899 if ((mult_cur < SCG_SPLL_MULT_BASE_VALUE - 1U) ||
900 (mult_cur > SCG_SPLL_MULT_BASE_VALUE + SCG_SPLL_MULT_MAX_VALUE))
901 {
902 /* No MULT is available with this PREDIV. */
903 continue;
904 }
905
906 ret_freq = mult_cur * ref_div;
907
908 if (mult_cur >= SCG_SPLL_MULT_BASE_VALUE)
909 {
910 if (ret_freq == desireFreq) /* If desire frequency is got. */
911 {
912 *prediv = prediv_cur - SCG_SPLL_PREDIV_BASE_VALUE;
913 *mult = mult_cur - SCG_SPLL_MULT_BASE_VALUE;
914 return ret_freq / 2U;
915 }
916 if (diff > desireFreq - ret_freq) /* New PRDIV/VDIV is closer. */
917 {
918 diff = desireFreq - ret_freq;
919 ret_prediv = prediv_cur;
920 ret_mult = mult_cur;
921 }
922 }
923 mult_cur++;
924 if (mult_cur <= (SCG_SPLL_MULT_BASE_VALUE + SCG_SPLL_MULT_MAX_VALUE))
925 {
926 ret_freq += ref_div;
927 if (diff > ret_freq - desireFreq) /* New PRDIV/VDIV is closer. */
928 {
929 diff = ret_freq - desireFreq;
930 ret_prediv = prediv_cur;
931 ret_mult = mult_cur;
932 }
933 }
934 }
935
936 if (0xFFFFFFFFU != diff)
937 {
938 /* PREDIV/MULT found. */
939 *prediv = ret_prediv - SCG_SPLL_PREDIV_BASE_VALUE;
940 *mult = ret_mult - SCG_SPLL_MULT_BASE_VALUE;
941 return ((refFreq / ret_prediv) * ret_mult) / 2;
942 }
943 else
944 {
945 return 0U; /* No proper PREDIV/MULT found. */
946 }
947}

◆ CLOCK_InitFirc()

status_t CLOCK_InitFirc ( const scg_firc_config_t config)

Initializes the SCG fast IRC clock.

This function enables the SCG fast IRC clock according to the configuration.

Parameters
configPointer to the configuration structure.
Return values
kStatus_SuccessFIRC is initialized.
kStatus_SCG_BusyFIRC has been enabled and is used by the system clock.
kStatus_ReadOnlyFIRC control register is locked.
Note
This function can't detect whether the FIRC has been enabled and used by an IP.

brief Initializes the SCG fast IRC clock.

This function enables the SCG fast IRC clock according to the configuration.

param config Pointer to the configuration structure. retval kStatus_Success FIRC is initialized. retval kStatus_SCG_Busy FIRC has been enabled and is used by the system clock. retval kStatus_ReadOnly FIRC control register is locked.

note This function can't detect whether the FIRC has been enabled and used by an IP.

Definition at line 690 of file fsl_clock.c.

691{
692 assert(config);
693
694 status_t status;
695
696 /* De-init the FIRC first. */
697 status = CLOCK_DeinitFirc();
698
699 if (kStatus_Success != status)
700 {
701 return status;
702 }
703
704 /* Now start to set up FIRC clock. */
705 /* Step 1. Setup dividers. */
706 SCG->FIRCDIV = SCG_FIRCDIV_FIRCDIV1(config->div1) | SCG_FIRCDIV_FIRCDIV2(config->div2);
707
708 /* Step 2. Set FIRC configuration. */
709 SCG->FIRCCFG = SCG_FIRCCFG_RANGE(config->range);
710
711 /* Step 3. Set trimming configuration. */
712 if (config->trimConfig)
713 {
714 SCG->FIRCTCFG =
715 SCG_FIRCTCFG_TRIMDIV(config->trimConfig->trimDiv) | SCG_FIRCTCFG_TRIMSRC(config->trimConfig->trimSrc);
716
717 /* TODO: Write FIRCSTAT cause bus error: TKT266932. */
718 if (kSCG_FircTrimNonUpdate == config->trimConfig->trimMode)
719 {
720 SCG->FIRCSTAT = SCG_FIRCSTAT_TRIMCOAR(config->trimConfig->trimCoar) |
721 SCG_FIRCSTAT_TRIMFINE(config->trimConfig->trimFine);
722 }
723
724 /* trim mode. */
725 SCG->FIRCCSR = config->trimConfig->trimMode;
726
727 if (SCG->FIRCCSR & SCG_FIRCCSR_FIRCERR_MASK)
728 {
729 return kStatus_Fail;
730 }
731 }
732
733 /* Step 4. Enable clock. */
734 SCG->FIRCCSR |= (SCG_FIRCCSR_FIRCEN_MASK | config->enableMode);
735
736 /* Step 5. Wait for FIRC clock to be valid. */
737 while (!(SCG->FIRCCSR & SCG_FIRCCSR_FIRCVLD_MASK))
738 {
739 }
740
741 return kStatus_Success;
742}
status_t CLOCK_DeinitFirc(void)
De-initializes the SCG fast IRC.
Definition fsl_clock.c:755
int32_t status_t
Type used for all status and error return values.
Definition fsl_common.h:169
@ kStatus_Fail
Definition fsl_common.h:160

Referenced by CLOCK_CONFIG_FircSafeConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CLOCK_InitSirc()

status_t CLOCK_InitSirc ( const scg_sirc_config_t config)

Initializes the SCG slow IRC clock.

This function enables the SCG slow IRC clock according to the configuration.

Parameters
configPointer to the configuration structure.
Return values
kStatus_SuccessSIRC is initialized.
kStatus_SCG_BusySIRC has been enabled and is used by system clock.
kStatus_ReadOnlySIRC control register is locked.
Note
This function can't detect whether the system OSC has been enabled and used by an IP.

brief Initializes the SCG slow IRC clock.

This function enables the SCG slow IRC clock according to the configuration.

param config Pointer to the configuration structure. retval kStatus_Success SIRC is initialized. retval kStatus_SCG_Busy SIRC has been enabled and is used by system clock. retval kStatus_ReadOnly SIRC control register is locked.

note This function can't detect whether the system OSC has been enabled and used by an IP.

Definition at line 558 of file fsl_clock.c.

559{
560 assert(config);
561
562 status_t status;
563
564 /* De-init the SIRC first. */
565 status = CLOCK_DeinitSirc();
566
567 if (kStatus_Success != status)
568 {
569 return status;
570 }
571
572 /* Now start to set up SIRC clock. */
573 /* Step 1. Setup dividers. */
574 SCG->SIRCDIV = SCG_SIRCDIV_SIRCDIV1(config->div1) | SCG_SIRCDIV_SIRCDIV2(config->div2);
575
576 /* Step 2. Set SIRC configuration. */
577 SCG->SIRCCFG = SCG_SIRCCFG_RANGE(config->range);
578
579 /* Step 3. Enable clock. */
580 SCG->SIRCCSR = SCG_SIRCCSR_SIRCEN_MASK | config->enableMode;
581
582 /* Step 4. Wait for SIRC clock to be valid. */
583 while (!(SCG->SIRCCSR & SCG_SIRCCSR_SIRCVLD_MASK))
584 {
585 }
586
587 return kStatus_Success;
588}
status_t CLOCK_DeinitSirc(void)
De-initializes the SCG slow IRC.
Definition fsl_clock.c:601

Referenced by CLOCK_CONFIG_FircSafeConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CLOCK_InitSysOsc()

status_t CLOCK_InitSysOsc ( const scg_sosc_config_t config)

Initializes the SCG system OSC.

This function enables the SCG system OSC clock according to the configuration.

Parameters
configPointer to the configuration structure.
Return values
kStatus_SuccessSystem OSC is initialized.
kStatus_SCG_BusySystem OSC has been enabled and is used by the system clock.
kStatus_ReadOnlySystem OSC control register is locked.
Note
This function can't detect whether the system OSC has been enabled and used by an IP.

brief Initializes the SCG system OSC.

This function enables the SCG system OSC clock according to the configuration.

param config Pointer to the configuration structure. retval kStatus_Success System OSC is initialized. retval kStatus_SCG_Busy System OSC has been enabled and is used by the system clock. retval kStatus_ReadOnly System OSC control register is locked.

note This function can't detect whether the system OSC has been enabled and used by an IP.

Definition at line 397 of file fsl_clock.c.

398{
399 assert(config);
400 uint8_t range = 0U; /* SCG_SOSCCFG[RANGE] */
401 status_t status;
402 uint8_t tmp8;
403
404 /* If crystal oscillator used, need to get RANGE value base on frequency. */
405 if (kSCG_SysOscModeExt != config->workMode)
406 {
407 if ((config->freq >= 32768U) && (config->freq <= 40000U))
408 {
409 range = 1U;
410 }
411 else if ((config->freq >= 1000000U) && (config->freq <= 8000000U))
412 {
413 range = 2U;
414 }
415 else if ((config->freq >= 8000000U) && (config->freq <= 32000000U))
416 {
417 range = 3U;
418 }
419 else
420 {
422 }
423 }
424
425 /* De-init the SOSC first. */
426 status = CLOCK_DeinitSysOsc();
427
428 if (kStatus_Success != status)
429 {
430 return status;
431 }
432
433 /* Now start to set up OSC clock. */
434 /* Step 1. Setup dividers. */
435 SCG->SOSCDIV = SCG_SOSCDIV_SOSCDIV1(config->div1) | SCG_SOSCDIV_SOSCDIV2(config->div2);
436
437 /* Step 2. Set OSC configuration. */
438 SCG->SOSCCFG = config->workMode | SCG_SOSCCFG_RANGE(range);
439
440 /* Step 3. Enable clock. */
441 /* SCG->SOSCCSR = SCG_SOSCCSR_SOSCEN_MASK | (config->enableMode); */
442 tmp8 = config->enableMode;
443 tmp8 |= SCG_SOSCCSR_SOSCEN_MASK;
444 SCG->SOSCCSR = tmp8;
445
446 /* Step 4. Wait for OSC clock to be valid. */
447 while (!(SCG->SOSCCSR & SCG_SOSCCSR_SOSCVLD_MASK))
448 {
449 }
450
451 /* Step 5. Enabe monitor. */
452 SCG->SOSCCSR |= (uint32_t)config->monitorMode;
453
454 return kStatus_Success;
455}
status_t CLOCK_DeinitSysOsc(void)
De-initializes the SCG system OSC.
Definition fsl_clock.c:468
@ kStatus_InvalidArgument
Definition fsl_common.h:163

Referenced by ke1xf_clock_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CLOCK_InitSysPll()

status_t CLOCK_InitSysPll ( const scg_spll_config_t config)

Initializes the SCG system PLL.

This function enables the SCG system PLL clock according to the configuration. The system PLL can use the system OSC or FIRC as the clock source. Ensure that the source clock is valid before calling this function.

Example code for initializing SPLL clock output:

const scg_spll_config_t g_scgSysPllConfig = {.enableMode = kSCG_SysPllEnable,
.monitorMode = kSCG_SysPllMonitorDisable,
.isBypassSelected = false,
.isPfdSelected = false, // Configure SPLL PFD as diabled
.prediv = 5U,
.pfdClkout = kSCG_AuxPllPfd0Clk, // No need to configure pfdClkout; only
needed for initialization
.mult = 20U,
.pllPostdiv1 = kSCG_SysClkDivBy3,
.pllPostdiv2 = kSCG_SysClkDivBy4};
CLOCK_InitSysPll(&g_scgSysPllConfig);
uint8_t enableMode
Definition fsl_clock.h:617
status_t CLOCK_InitSysPll(const scg_spll_config_t *config)
Initializes the SCG system PLL.
Definition fsl_clock.c:984
SCG system PLL configuration.
Definition fsl_clock.h:616
Parameters
configPointer to the configuration structure.
Return values
kStatus_SuccessSystem PLL is initialized.
kStatus_SCG_BusySystem PLL has been enabled and is used by the system clock.
kStatus_ReadOnlySystem PLL control register is locked.
Note
This function can't detect whether the system PLL has been enabled and used by an IP.

brief Initializes the SCG system PLL.

This function enables the SCG system PLL clock according to the configuration. The system PLL can use the system OSC or FIRC as the clock source. Ensure that the source clock is valid before calling this function.

Example code for initializing SPLL clock output: code const scg_spll_config_t g_scgSysPllConfig = {.enableMode = kSCG_SysPllEnable, .monitorMode = kSCG_SysPllMonitorDisable, .div1 = kSCG_AsyncClkDivBy1, .div2 = kSCG_AsyncClkDisable, .div3 = kSCG_AsyncClkDivBy2, .src = kSCG_SysPllSrcFirc, .isBypassSelected = false, .isPfdSelected = false, // Configure SPLL PFD as diabled .prediv = 5U, .pfdClkout = kSCG_AuxPllPfd0Clk, // No need to configure pfdClkout; only needed for initialization .mult = 20U, .pllPostdiv1 = kSCG_SysClkDivBy3, .pllPostdiv2 = kSCG_SysClkDivBy4}; CLOCK_InitSysPll(&g_scgSysPllConfig); endcode

param config Pointer to the configuration structure. retval kStatus_Success System PLL is initialized. retval kStatus_SCG_Busy System PLL has been enabled and is used by the system clock. retval kStatus_ReadOnly System PLL control register is locked.

note This function can't detect whether the system PLL has been enabled and used by an IP.

Definition at line 984 of file fsl_clock.c.

985{
986 assert(config);
987
988 status_t status;
989
990 /* De-init the SPLL first. */
991 status = CLOCK_DeinitSysPll();
992
993 if (kStatus_Success != status)
994 {
995 return status;
996 }
997
998 /* Now start to set up PLL clock. */
999 /* Step 1. Setup dividers. */
1000 SCG->SPLLDIV = SCG_SPLLDIV_SPLLDIV1(config->div1) | SCG_SPLLDIV_SPLLDIV2(config->div2);
1001
1002 /* Step 2. Set PLL configuration. */
1003 SCG->SPLLCFG =
1004 SCG_SPLLCFG_SOURCE(config->src) | SCG_SPLLCFG_PREDIV(config->prediv) | SCG_SPLLCFG_MULT(config->mult);
1005
1006 /* Step 3. Enable clock. */
1007 SCG->SPLLCSR = SCG_SPLLCSR_SPLLEN_MASK | config->enableMode;
1008
1009 /* Step 4. Wait for PLL clock to be valid. */
1010 while (!(SCG->SPLLCSR & SCG_SPLLCSR_SPLLVLD_MASK))
1011 {
1012 }
1013
1014 /* Step 5. Enabe monitor. */
1015 SCG->SPLLCSR |= (uint32_t)config->monitorMode;
1016
1017 return kStatus_Success;
1018}
status_t CLOCK_DeinitSysPll(void)
De-initializes the SCG system PLL.
Definition fsl_clock.c:1031

Referenced by ke1xf_clock_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CLOCK_IsEnabledByOtherCore()

static bool CLOCK_IsEnabledByOtherCore ( clock_ip_name_t  name)
inlinestatic

Check whether the clock is already enabled and configured by any other core.

Parameters
nameWhich peripheral to check, see clock_ip_name_t.
Returns
True if clock is already enabled, otherwise false.

Definition at line 667 of file fsl_clock.h.

668{
669 assert((*(volatile uint32_t *)name) & PCC_CLKCFG_PR_MASK);
670
671 return ((*(volatile uint32_t *)name) & PCC_CLKCFG_INUSE_MASK) ? true : false;
672}

◆ CLOCK_IsFircErr()

static bool CLOCK_IsFircErr ( void  )
inlinestatic

Checks whether the FIRC clock error occurs.

Returns
True if the error occurs, false if not.

Definition at line 1132 of file fsl_clock.h.

1133{
1134 return (bool)(SCG->FIRCCSR & SCG_FIRCCSR_FIRCERR_MASK);
1135}

◆ CLOCK_IsFircValid()

static bool CLOCK_IsFircValid ( void  )
inlinestatic

Checks whether the FIRC clock is valid.

Returns
True if clock is valid, false if not.

Definition at line 1150 of file fsl_clock.h.

1151{
1152 return (bool)(SCG->FIRCCSR & SCG_FIRCCSR_FIRCVLD_MASK);
1153}

◆ CLOCK_IsSircValid()

static bool CLOCK_IsSircValid ( void  )
inlinestatic

Checks whether the SIRC clock is valid.

Returns
True if clock is valid, false if not.

Definition at line 1047 of file fsl_clock.h.

1048{
1049 return (bool)(SCG->SIRCCSR & SCG_SIRCCSR_SIRCVLD_MASK);
1050}

◆ CLOCK_IsSysOscErr()

static bool CLOCK_IsSysOscErr ( void  )
inlinestatic

Checks whether the system OSC clock error occurs.

Returns
True if the error occurs, false if not.

Definition at line 924 of file fsl_clock.h.

925{
926 return (bool)(SCG->SOSCCSR & SCG_SOSCCSR_SOSCERR_MASK);
927}

◆ CLOCK_IsSysOscValid()

static bool CLOCK_IsSysOscValid ( void  )
inlinestatic

Checks whether the system OSC clock is valid.

Returns
True if clock is valid, false if not.

Definition at line 961 of file fsl_clock.h.

962{
963 return (bool)(SCG->SOSCCSR & SCG_SOSCCSR_SOSCVLD_MASK);
964}

◆ CLOCK_IsSysPllErr()

static bool CLOCK_IsSysPllErr ( void  )
inlinestatic

Checks whether the system PLL clock error occurs.

Returns
True if an error occurs, false if not.

Definition at line 1274 of file fsl_clock.h.

1275{
1276 return (bool)(SCG->SPLLCSR & SCG_SPLLCSR_SPLLERR_MASK);
1277}

◆ CLOCK_IsSysPllValid()

static bool CLOCK_IsSysPllValid ( void  )
inlinestatic

Checks whether the system PLL clock is valid.

Returns
True if the clock is valid, false if not.

Definition at line 1311 of file fsl_clock.h.

1312{
1313 return (bool)(SCG->SPLLCSR & SCG_SPLLCSR_SPLLVLD_MASK);
1314}

◆ CLOCK_SetClkOutSel()

static void CLOCK_SetClkOutSel ( clock_clkout_src_t  setting)
inlinestatic

Sets the clock out selection.

This function sets the clock out selection (CLKOUTSEL).

Parameters
settingThe selection to set.
Returns
The current clock out selection.

Definition at line 838 of file fsl_clock.h.

839{
840 SCG->CLKOUTCNFG = SCG_CLKOUTCNFG_CLKOUTSEL(setting);
841}

◆ CLOCK_SetFircAsyncClkDiv()

static void CLOCK_SetFircAsyncClkDiv ( scg_async_clk_t  asyncClk,
scg_async_clk_div_t  divider 
)
inlinestatic

Set the asynchronous clock divider.

Parameters
asyncClkWhich asynchronous clock to configure.
dividerThe divider value to set.
Note
There might be glitch when changing the asynchronous divider, so make sure the asynchronous clock is not used while changing divider.

Definition at line 1095 of file fsl_clock.h.

1096{
1097 uint32_t reg = SCG->FIRCDIV;
1098
1099 switch (asyncClk)
1100 {
1101 case kSCG_AsyncDiv2Clk:
1102 reg = (reg & ~SCG_FIRCDIV_FIRCDIV2_MASK) | SCG_FIRCDIV_FIRCDIV2(divider);
1103 break;
1104 default:
1105 reg = (reg & ~SCG_FIRCDIV_FIRCDIV1_MASK) | SCG_FIRCDIV_FIRCDIV1(divider);
1106 break;
1107 }
1108
1109 SCG->FIRCDIV = reg;
1110}

◆ CLOCK_SetHsrunModeSysClkConfig()

static void CLOCK_SetHsrunModeSysClkConfig ( const scg_sys_clk_config_t config)
inlinestatic

Sets the system clock configuration for HSRUN mode.

This function sets the system clock configuration for HSRUN mode.

Parameters
configPointer to the configuration.

Definition at line 809 of file fsl_clock.h.

810{
811 assert(config);
812
813 SCG->HCCR = *(const uint32_t *)config;
814}

Referenced by setClockConfig().

Here is the caller graph for this function:

◆ CLOCK_SetIpSrc()

static void CLOCK_SetIpSrc ( clock_ip_name_t  name,
clock_ip_src_t  src 
)
inlinestatic

Set the clock source for specific IP module.

Set the clock source for specific IP, not all modules need to set the clock source, should only use this function for the modules need source setting.

Parameters
nameWhich peripheral to check, see clock_ip_name_t.
srcClock source to set.

Definition at line 684 of file fsl_clock.h.

685{
686 uint32_t reg = (*(volatile uint32_t *)name);
687
688 assert(reg & PCC_CLKCFG_PR_MASK);
689 assert(!(reg & PCC_CLKCFG_INUSE_MASK)); /* Should not change if clock has been enabled by other core. */
690
691 reg = (reg & ~PCC_CLKCFG_PCS_MASK) | PCC_CLKCFG_PCS(src);
692
693 /*
694 * If clock is already enabled, first disable it, then set the clock
695 * source and re-enable it.
696 */
697 (*(volatile uint32_t *)name) = reg & ~PCC_CLKCFG_CGC_MASK;
698 (*(volatile uint32_t *)name) = reg;
699}

Referenced by ke1xf_clock_init().

Here is the caller graph for this function:

◆ CLOCK_SetRunModeSysClkConfig()

static void CLOCK_SetRunModeSysClkConfig ( const scg_sys_clk_config_t config)
inlinestatic

Sets the system clock configuration for RUN mode.

This function sets the system clock configuration for RUN mode.

Parameters
configPointer to the configuration.

Definition at line 795 of file fsl_clock.h.

796{
797 assert(config);
798
799 SCG->RCCR = *(const uint32_t *)config;
800}

Referenced by CLOCK_CONFIG_FircSafeConfig(), and setClockConfig().

Here is the caller graph for this function:

◆ CLOCK_SetSircAsyncClkDiv()

static void CLOCK_SetSircAsyncClkDiv ( scg_async_clk_t  asyncClk,
scg_async_clk_div_t  divider 
)
inlinestatic

Set the asynchronous clock divider.

Parameters
asyncClkWhich asynchronous clock to configure.
dividerThe divider value to set.
Note
There might be glitch when changing the asynchronous divider, so make sure the asynchronous clock is not used while changing divider.

Definition at line 1010 of file fsl_clock.h.

1011{
1012 uint32_t reg = SCG->SIRCDIV;
1013
1014 switch (asyncClk)
1015 {
1016 case kSCG_AsyncDiv2Clk:
1017 reg = (reg & ~SCG_SIRCDIV_SIRCDIV2_MASK) | SCG_SIRCDIV_SIRCDIV2(divider);
1018 break;
1019 default:
1020 reg = (reg & ~SCG_SIRCDIV_SIRCDIV1_MASK) | SCG_SIRCDIV_SIRCDIV1(divider);
1021 break;
1022 }
1023
1024 SCG->SIRCDIV = reg;
1025}

◆ CLOCK_SetSysOscAsyncClkDiv()

static void CLOCK_SetSysOscAsyncClkDiv ( scg_async_clk_t  asyncClk,
scg_async_clk_div_t  divider 
)
inlinestatic

Set the asynchronous clock divider.

Parameters
asyncClkWhich asynchronous clock to configure.
dividerThe divider value to set.
Note
There might be glitch when changing the asynchronous divider, so make sure the asynchronous clock is not used while changing divider.

Definition at line 887 of file fsl_clock.h.

888{
889 uint32_t reg = SCG->SOSCDIV;
890
891 switch (asyncClk)
892 {
894 reg = (reg & ~SCG_SOSCDIV_SOSCDIV2_MASK) | SCG_SOSCDIV_SOSCDIV2(divider);
895 break;
896 default:
897 reg = (reg & ~SCG_SOSCDIV_SOSCDIV1_MASK) | SCG_SOSCDIV_SOSCDIV1(divider);
898 break;
899 }
900
901 SCG->SOSCDIV = reg;
902}

◆ CLOCK_SetSysOscMonitorMode()

static void CLOCK_SetSysOscMonitorMode ( scg_sosc_monitor_mode_t  mode)
inlinestatic

Sets the system OSC monitor mode.

This function sets the system OSC monitor mode. The mode can be disabled, it can generate an interrupt when the error is disabled, or reset when the error is detected.

Parameters
modeMonitor mode to set.

Definition at line 945 of file fsl_clock.h.

946{
947 uint32_t reg = SCG->SOSCCSR;
948
949 reg &= ~(SCG_SOSCCSR_SOSCCM_MASK | SCG_SOSCCSR_SOSCCMRE_MASK);
950
951 reg |= (uint32_t)mode;
952
953 SCG->SOSCCSR = reg;
954}

◆ CLOCK_SetSysPllAsyncClkDiv()

static void CLOCK_SetSysPllAsyncClkDiv ( scg_async_clk_t  asyncClk,
scg_async_clk_div_t  divider 
)
inlinestatic

Set the asynchronous clock divider.

Parameters
asyncClkWhich asynchronous clock to configure.
dividerThe divider value to set.
Note
There might be glitch when changing the asynchronous divider, so make sure the asynchronous clock is not used while changing divider.

Definition at line 1237 of file fsl_clock.h.

1238{
1239 uint32_t reg = SCG->SPLLDIV;
1240
1241 switch (asyncClk)
1242 {
1243 case kSCG_AsyncDiv2Clk:
1244 reg = (reg & ~SCG_SPLLDIV_SPLLDIV2_MASK) | SCG_SPLLDIV_SPLLDIV2(divider);
1245 break;
1246 default:
1247 reg = (reg & ~SCG_SPLLDIV_SPLLDIV1_MASK) | SCG_SPLLDIV_SPLLDIV1(divider);
1248 break;
1249 }
1250
1251 SCG->SPLLDIV = reg;
1252}

◆ CLOCK_SetSysPllMonitorMode()

static void CLOCK_SetSysPllMonitorMode ( scg_spll_monitor_mode_t  mode)
inlinestatic

Sets the system PLL monitor mode.

This function sets the system PLL monitor mode. The mode can be disabled. It can generate an interrupt when the error is disabled, or reset when the error is detected.

Parameters
modeMonitor mode to set.

Definition at line 1295 of file fsl_clock.h.

1296{
1297 uint32_t reg = SCG->SPLLCSR;
1298
1299 reg &= ~(SCG_SPLLCSR_SPLLCM_MASK | SCG_SPLLCSR_SPLLCMRE_MASK);
1300
1301 reg |= (uint32_t)mode;
1302
1303 SCG->SPLLCSR = reg;
1304}

◆ CLOCK_SetVlprModeSysClkConfig()

static void CLOCK_SetVlprModeSysClkConfig ( const scg_sys_clk_config_t config)
inlinestatic

Sets the system clock configuration for VLPR mode.

This function sets the system clock configuration for VLPR mode.

Parameters
configPointer to the configuration.

Definition at line 781 of file fsl_clock.h.

782{
783 assert(config);
784
785 SCG->VCCR = *(const uint32_t *)config;
786}

◆ CLOCK_SetXtal0Freq()

static void CLOCK_SetXtal0Freq ( uint32_t  freq)
inlinestatic

Sets the XTAL0 frequency based on board settings.

Parameters
freqThe XTAL0/EXTAL0 input clock frequency in Hz.

Definition at line 1347 of file fsl_clock.h.

1348{
1349 g_xtal0Freq = freq;
1350}

Referenced by ke1xf_clock_init().

Here is the caller graph for this function:

◆ CLOCK_SetXtal32Freq()

static void CLOCK_SetXtal32Freq ( uint32_t  freq)
inlinestatic

Sets the XTAL32 frequency based on board settings.

Parameters
freqThe XTAL32/EXTAL32 input clock frequency in Hz.

Definition at line 1357 of file fsl_clock.h.

1358{
1359 g_xtal32Freq = freq;
1360}

◆ OSC32_Deinit()

void OSC32_Deinit ( OSC32_Type *  base)

Deinitializes OSC32.

Parameters
baseOSC32 peripheral base address.

brief Deinitializes OSC32.

param base OSC32 peripheral base address.

Definition at line 321 of file fsl_clock.c.

322{
323 /* Only support one instance now. */
324 assert(OSC32 == base);
325
326 base->CR = 0U;
328}
static void CLOCK_DisableClock(clock_ip_name_t name)
Disable the clock for specific IP.
Definition fsl_clock.h:653
Here is the call graph for this function:

◆ OSC32_Init()

void OSC32_Init ( OSC32_Type *  base,
osc32_mode_t  mode 
)

Initializes OSC32.

Parameters
baseOSC32 peripheral base address.
modeOSC32 work mode, see osc32_mode_t

brief Initializes OSC32.

param base OSC32 peripheral base address. param mode OSC32 work mode, see ref osc32_mode_t

Definition at line 297 of file fsl_clock.c.

298{
299 /* Only support one instance now. */
300 assert(OSC32 == base);
301
303
304 /* Set work mode. */
305 base->CR = (uint8_t)mode;
306
307 if (mode & OSC32_CR_ROSCEREFS_MASK)
308 {
309 /* If use crystal mode, wait for stable. */
310 while (!(base->CR & OSC32_CR_ROSCSTB_MASK))
311 {
312 }
313 }
314}
static void CLOCK_EnableClock(clock_ip_name_t name)
Enable the clock for specific IP.
Definition fsl_clock.h:641
Here is the call graph for this function:

Variable Documentation

◆ __pad0__

uint32_t _scg_sys_clk_config::__pad0__

Reserved.

Definition at line 384 of file fsl_clock.h.

◆ __pad1__

uint32_t _scg_sys_clk_config::__pad1__

Reserved.

Definition at line 385 of file fsl_clock.h.

◆ __pad2__

uint32_t _scg_sys_clk_config::__pad2__

Reserved.

Definition at line 387 of file fsl_clock.h.

◆ __pad3__

uint32_t _scg_sys_clk_config::__pad3__

reserved.

Definition at line 389 of file fsl_clock.h.

◆ div1 [1/4]

scg_async_clk_div_t _scg_sosc_config::div1

SOSCDIV1 value.

Definition at line 465 of file fsl_clock.h.

◆ div1 [2/4]

scg_async_clk_div_t _scg_sirc_config::div1

SIRCDIV1 value.

Definition at line 494 of file fsl_clock.h.

◆ div1 [3/4]

scg_async_clk_div_t _scg_firc_config_t::div1

FIRCDIV1 value.

Definition at line 577 of file fsl_clock.h.

◆ div1 [4/4]

scg_async_clk_div_t _scg_spll_config::div1

SPLLDIV1 value.

Definition at line 620 of file fsl_clock.h.

◆ div2 [1/4]

scg_async_clk_div_t _scg_sosc_config::div2

SOSCDIV2 value.

Definition at line 466 of file fsl_clock.h.

◆ div2 [2/4]

scg_async_clk_div_t _scg_sirc_config::div2

SIRCDIV2 value.

Definition at line 495 of file fsl_clock.h.

◆ div2 [3/4]

scg_async_clk_div_t _scg_firc_config_t::div2

FIRCDIV2 value.

Definition at line 578 of file fsl_clock.h.

◆ div2 [4/4]

scg_async_clk_div_t _scg_spll_config::div2

SPLLDIV2 value.

Definition at line 621 of file fsl_clock.h.

◆ divBus

uint32_t _scg_sys_clk_config::divBus

Bus clock divider, see scg_sys_clk_div_t.

Definition at line 383 of file fsl_clock.h.

Referenced by CLOCK_GetSysClkFreq().

◆ divCore

uint32_t _scg_sys_clk_config::divCore

Core clock divider, see scg_sys_clk_div_t.

Definition at line 386 of file fsl_clock.h.

Referenced by CLOCK_GetSysClkFreq().

◆ divSlow

uint32_t _scg_sys_clk_config::divSlow

Slow clock divider, see scg_sys_clk_div_t.

Definition at line 382 of file fsl_clock.h.

Referenced by CLOCK_CONFIG_FircSafeConfig(), and CLOCK_GetSysClkFreq().

◆ enableMode [1/4]

uint8_t _scg_sosc_config::enableMode

Enable mode, OR'ed value of _scg_sosc_enable_mode.

Definition at line 463 of file fsl_clock.h.

◆ enableMode [2/4]

uint32_t _scg_sirc_config::enableMode

Enable mode, OR'ed value of _scg_sirc_enable_mode.

Definition at line 493 of file fsl_clock.h.

Referenced by CLOCK_CONFIG_FircSafeConfig().

◆ enableMode [3/4]

uint32_t _scg_firc_config_t::enableMode

Enable mode, OR'ed value of _scg_firc_enable_mode.

Definition at line 575 of file fsl_clock.h.

◆ enableMode [4/4]

uint8_t _scg_spll_config::enableMode

Enable mode, OR'ed value of _scg_spll_enable_mode

Definition at line 617 of file fsl_clock.h.

◆ freq

uint32_t _scg_sosc_config::freq

System OSC frequency.

Definition at line 461 of file fsl_clock.h.

Referenced by ke1xf_clock_init().

◆ g_xtal0Freq

volatile uint32_t g_xtal0Freq
extern

External XTAL0 (OSC0/SYSOSC) clock frequency.

The XTAL0/EXTAL0 (OSC0/SYSOSC) clock frequency in Hz. When the clock is set up, use the function CLOCK_SetXtal0Freq to set the value in the clock driver. For example, if XTAL0 is 8 MHz:

CLOCK_InitSysOsc(...); // Set up the OSC0/SYSOSC
CLOCK_SetXtal0Freq(80000000); // Set the XTAL0 value in the clock driver.
static void CLOCK_SetXtal0Freq(uint32_t freq)
Sets the XTAL0 frequency based on board settings.
Definition fsl_clock.h:1347
status_t CLOCK_InitSysOsc(const scg_sosc_config_t *config)
Initializes the SCG system OSC.
Definition fsl_clock.c:397

This is important for the multicore platforms where only one core needs to set up the OSC0/SYSOSC using CLOCK_InitSysOsc. All other cores need to call the CLOCK_SetXtal0Freq to get a valid clock frequency.

Definition at line 75 of file fsl_clock.c.

Referenced by CLOCK_GetErClkFreq(), CLOCK_GetSysOscFreq(), and CLOCK_SetXtal0Freq().

◆ g_xtal32Freq

volatile uint32_t g_xtal32Freq
extern

External XTAL32/EXTAL32 clock frequency.

The XTAL32/EXTAL32 clock frequency in Hz. When the clock is set up, use the function CLOCK_SetXtal32Freq to set the value in the clock driver.

This is important for the multicore platforms where only one core needs to set up the clock. All other cores need to call the CLOCK_SetXtal32Freq to get a valid clock frequency.

Definition at line 77 of file fsl_clock.c.

Referenced by CLOCK_GetOsc32kClkFreq(), and CLOCK_SetXtal32Freq().

◆ monitorMode [1/2]

scg_sosc_monitor_mode_t _scg_sosc_config::monitorMode

Clock monitor mode selected.

Definition at line 462 of file fsl_clock.h.

◆ monitorMode [2/2]

scg_spll_monitor_mode_t _scg_spll_config::monitorMode

Clock monitor mode selected.

Definition at line 618 of file fsl_clock.h.

◆ mult

uint8_t _scg_spll_config::mult

System PLL multiplier.

Definition at line 625 of file fsl_clock.h.

◆ prediv

uint8_t _scg_spll_config::prediv

PLL reference clock divider.

Definition at line 624 of file fsl_clock.h.

◆ range [1/2]

scg_sirc_range_t _scg_sirc_config::range

Slow IRC frequency range.

Definition at line 497 of file fsl_clock.h.

◆ range [2/2]

scg_firc_range_t _scg_firc_config_t::range

Fast IRC frequency range.

Definition at line 580 of file fsl_clock.h.

◆ src [1/2]

uint32_t _scg_sys_clk_config::src

System clock source, see scg_sys_clk_src_t.

Definition at line 388 of file fsl_clock.h.

Referenced by CLOCK_CONFIG_FircSafeConfig(), CLOCK_GetSysClkFreq(), and setClockConfig().

◆ src [2/2]

scg_spll_src_t _scg_spll_config::src

Clock source.

Definition at line 623 of file fsl_clock.h.

◆ trimCoar

uint8_t _scg_firc_trim_config::trimCoar

Trim coarse value; Irrelevant if trimMode is kSCG_FircTrimUpdate.

Definition at line 546 of file fsl_clock.h.

◆ trimConfig

const scg_firc_trim_config_t* _scg_firc_config_t::trimConfig

Pointer to the FIRC trim configuration; set NULL to disable trim.

Definition at line 582 of file fsl_clock.h.

◆ trimDiv

scg_firc_trim_div_t _scg_firc_trim_config::trimDiv

Trim predivided value for the system OSC.

Definition at line 544 of file fsl_clock.h.

◆ trimFine

uint8_t _scg_firc_trim_config::trimFine

Trim fine value; Irrelevant if trimMode is kSCG_FircTrimUpdate.

Definition at line 547 of file fsl_clock.h.

◆ trimMode

scg_firc_trim_mode_t _scg_firc_trim_config::trimMode

FIRC trim mode.

Definition at line 542 of file fsl_clock.h.

◆ trimSrc

scg_firc_trim_src_t _scg_firc_trim_config::trimSrc

Trim source.

Definition at line 543 of file fsl_clock.h.

◆ workMode

scg_sosc_mode_t _scg_sosc_config::workMode

OSC work mode.

Definition at line 468 of file fsl_clock.h.