![]() |
MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The MCUXpresso SDK provides APIs for MCUXpresso SDK devices' clock operation.
Modules | |
Multipurpose Clock Generator Lite (MCGLITE) | |
Files | |
file | fsl_clock.h |
Data Structures | |
struct | sim_clock_config_t |
SIM configuration structure for clock setting. More... | |
struct | oscer_config_t |
The OSC configuration for OSCERCLK. More... | |
struct | osc_config_t |
OSC Initialization Configuration Structure. More... | |
struct | mcglite_config_t |
MCG_Lite configure structure for mode change. More... | |
Macros | |
#define | FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL 0 |
Configure whether driver controls clock. More... | |
#define | DMAMUX_CLOCKS |
Clock ip name array for DMAMUX. More... | |
#define | RTC_CLOCKS |
Clock ip name array for RTC. More... | |
#define | SAI_CLOCKS |
Clock ip name array for SAI. More... | |
#define | SPI_CLOCKS |
Clock ip name array for SPI. More... | |
#define | SLCD_CLOCKS |
Clock ip name array for SLCD. More... | |
#define | PIT_CLOCKS |
Clock ip name array for PIT. More... | |
#define | PORT_CLOCKS |
Clock ip name array for PORT. More... | |
#define | LPUART_CLOCKS |
Clock ip name array for LPUART. More... | |
#define | DAC_CLOCKS |
Clock ip name array for DAC. More... | |
#define | LPTMR_CLOCKS |
Clock ip name array for LPTMR. More... | |
#define | ADC16_CLOCKS |
Clock ip name array for ADC16. More... | |
#define | FLEXIO_CLOCKS |
Clock ip name array for FLEXIO. More... | |
#define | VREF_CLOCKS |
Clock ip name array for VREF. More... | |
#define | DMA_CLOCKS |
Clock ip name array for DMA. More... | |
#define | UART_CLOCKS |
Clock ip name array for UART. More... | |
#define | TPM_CLOCKS |
Clock ip name array for TPM. More... | |
#define | I2C_CLOCKS |
Clock ip name array for I2C. More... | |
#define | FTF_CLOCKS |
Clock ip name array for FTF. More... | |
#define | CMP_CLOCKS |
Clock ip name array for CMP. More... | |
#define | LPO_CLK_FREQ 1000U |
LPO clock frequency. | |
#define | SYS_CLK kCLOCK_CoreSysClk |
Peripherals clock source definition. More... | |
Functions | |
static void | CLOCK_EnableClock (clock_ip_name_t name) |
Enable the clock for specific IP. More... | |
static void | CLOCK_DisableClock (clock_ip_name_t name) |
Disable the clock for specific IP. More... | |
static void | CLOCK_SetEr32kClock (uint32_t src) |
Set ERCLK32K source. More... | |
static void | CLOCK_SetLpuart0Clock (uint32_t src) |
Set LPUART0 clock source. More... | |
static void | CLOCK_SetLpuart1Clock (uint32_t src) |
Set LPUART1 clock source. More... | |
static void | CLOCK_SetTpmClock (uint32_t src) |
Set TPM clock source. More... | |
static void | CLOCK_SetFlexio0Clock (uint32_t src) |
Set FLEXIO clock source. More... | |
bool | CLOCK_EnableUsbfs0Clock (clock_usb_src_t src, uint32_t freq) |
Enable USB FS clock. More... | |
static void | CLOCK_DisableUsbfs0Clock (void) |
Disable USB FS clock. More... | |
static void | CLOCK_SetClkOutClock (uint32_t src) |
Set CLKOUT source. More... | |
static void | CLOCK_SetRtcClkOutClock (uint32_t src) |
Set RTC_CLKOUT source. More... | |
static void | CLOCK_SetOutDiv (uint32_t outdiv1, uint32_t outdiv4) |
System clock divider. More... | |
uint32_t | CLOCK_GetFreq (clock_name_t clockName) |
Gets the clock frequency for a specific clock name. More... | |
uint32_t | CLOCK_GetCoreSysClkFreq (void) |
Get the core clock or system clock frequency. More... | |
uint32_t | CLOCK_GetPlatClkFreq (void) |
Get the platform clock frequency. More... | |
uint32_t | CLOCK_GetBusClkFreq (void) |
Get the bus clock frequency. More... | |
uint32_t | CLOCK_GetFlashClkFreq (void) |
Get the flash clock frequency. More... | |
uint32_t | CLOCK_GetEr32kClkFreq (void) |
Get the external reference 32K clock frequency (ERCLK32K). More... | |
uint32_t | CLOCK_GetOsc0ErClkFreq (void) |
Get the OSC0 external reference clock frequency (OSC0ERCLK). More... | |
void | CLOCK_SetSimConfig (sim_clock_config_t const *config) |
Set the clock configure in SIM module. More... | |
static void | CLOCK_SetSimSafeDivs (void) |
Set the system clock dividers in SIM to safe value. More... | |
Variables | |
volatile uint32_t | g_xtal0Freq |
External XTAL0 (OSC0) clock frequency. More... | |
volatile uint32_t | g_xtal32Freq |
The external XTAL32/EXTAL32/RTC_CLKIN clock frequency. More... | |
Driver version | |
#define | FSL_CLOCK_DRIVER_VERSION (MAKE_VERSION(2, 3, 1)) |
CLOCK driver version 2.3.1. More... | |
MCG_Lite clock frequency | |
uint32_t | CLOCK_GetOutClkFreq (void) |
Gets the MCG_Lite output clock (MCGOUTCLK) frequency. More... | |
uint32_t | CLOCK_GetInternalRefClkFreq (void) |
Gets the MCG internal reference clock (MCGIRCLK) frequency. More... | |
uint32_t | CLOCK_GetPeriphClkFreq (void) |
Gets the current MCGPCLK frequency. More... | |
MCG_Lite mode. | |
mcglite_mode_t | CLOCK_GetMode (void) |
Gets the current MCG_Lite mode. More... | |
status_t | CLOCK_SetMcgliteConfig (mcglite_config_t const *targetConfig) |
Sets the MCG_Lite configuration. More... | |
OSC configuration | |
static void | OSC_SetExtRefClkConfig (OSC_Type *base, oscer_config_t const *config) |
Configures the OSC external reference clock (OSCERCLK). More... | |
static void | OSC_SetCapLoad (OSC_Type *base, uint8_t capLoad) |
Sets the capacitor load configuration for the oscillator. More... | |
void | CLOCK_InitOsc0 (osc_config_t const *config) |
Initializes the OSC0. More... | |
void | CLOCK_DeinitOsc0 (void) |
Deinitializes the OSC0. More... | |
External clock frequency | |
static void | CLOCK_SetXtal0Freq (uint32_t freq) |
Sets the XTAL0 frequency based on board settings. More... | |
static void | CLOCK_SetXtal32Freq (uint32_t freq) |
Sets the XTAL32/RTC_CLKIN frequency based on board settings. More... | |
struct sim_clock_config_t |
struct oscer_config_t |
Data Fields | |
uint8_t | enableMode |
OSCERCLK enable mode. More... | |
uint8_t oscer_config_t::enableMode |
OR'ed value of _oscer_enable_mode.
struct osc_config_t |
Defines the configuration data structure to initialize the OSC. When porting to a new board, set the following members according to the board settings:
Data Fields | |
uint32_t | freq |
External clock frequency. More... | |
uint8_t | capLoad |
Capacitor load setting. More... | |
osc_mode_t | workMode |
OSC work mode setting. More... | |
oscer_config_t | oscerConfig |
Configuration for OSCERCLK. More... | |
uint32_t osc_config_t::freq |
uint8_t osc_config_t::capLoad |
osc_mode_t osc_config_t::workMode |
oscer_config_t osc_config_t::oscerConfig |
struct mcglite_config_t |
Data Fields | |
mcglite_clkout_src_t | outSrc |
MCGOUT clock select. More... | |
uint8_t | irclkEnableMode |
MCGIRCLK enable mode, OR'ed value of _mcglite_irclk_enable_mode. More... | |
mcglite_lirc_mode_t | ircs |
MCG_C2[IRCS]. More... | |
mcglite_lirc_div_t | fcrdiv |
MCG_SC[FCRDIV]. More... | |
mcglite_lirc_div_t | lircDiv2 |
MCG_MC[LIRC_DIV2]. More... | |
bool | hircEnableInNotHircMode |
HIRC enable when not in HIRC mode. More... | |
mcglite_clkout_src_t mcglite_config_t::outSrc |
uint8_t mcglite_config_t::irclkEnableMode |
mcglite_lirc_mode_t mcglite_config_t::ircs |
mcglite_lirc_div_t mcglite_config_t::fcrdiv |
mcglite_lirc_div_t mcglite_config_t::lircDiv2 |
bool mcglite_config_t::hircEnableInNotHircMode |
#define FSL_SDK_DISABLE_DRIVER_CLOCK_CONTROL 0 |
When set to 0, peripheral drivers will enable clock in initialize function and disable clock in de-initialize function. When set to 1, peripheral driver will not control the clock, application could control the clock out of the driver.
#define FSL_CLOCK_DRIVER_VERSION (MAKE_VERSION(2, 3, 1)) |
#define DMAMUX_CLOCKS |
#define RTC_CLOCKS |
#define SAI_CLOCKS |
#define SPI_CLOCKS |
#define SLCD_CLOCKS |
#define PIT_CLOCKS |
#define PORT_CLOCKS |
#define LPUART_CLOCKS |
#define DAC_CLOCKS |
#define LPTMR_CLOCKS |
#define ADC16_CLOCKS |
#define FLEXIO_CLOCKS |
#define VREF_CLOCKS |
#define DMA_CLOCKS |
#define UART_CLOCKS |
#define TPM_CLOCKS |
#define I2C_CLOCKS |
#define FTF_CLOCKS |
#define CMP_CLOCKS |
#define SYS_CLK kCLOCK_CoreSysClk |
enum clock_name_t |
enum clock_usb_src_t |
enum clock_ip_name_t |
enum _osc_cap_load |
enum _oscer_enable_mode |
enum osc_mode_t |
enum mcglite_clkout_src_t |
enum mcglite_lirc_mode_t |
enum mcglite_lirc_div_t |
enum mcglite_mode_t |
|
inlinestatic |
name | Which clock to enable, see clock_ip_name_t. |
|
inlinestatic |
name | Which clock to disable, see clock_ip_name_t. |
|
inlinestatic |
src | The value to set ERCLK32K clock source. |
|
inlinestatic |
src | The value to set LPUART0 clock source. |
|
inlinestatic |
src | The value to set LPUART1 clock source. |
|
inlinestatic |
src | The value to set TPM clock source. |
|
inlinestatic |
src | The value to set FLEXIO clock source. |
bool CLOCK_EnableUsbfs0Clock | ( | clock_usb_src_t | src, |
uint32_t | freq | ||
) |
src | USB FS clock source. |
freq | The frequency specified by src. |
true | The clock is set successfully. |
false | The clock source is invalid to get proper USB FS clock. |
|
inlinestatic |
Disable USB FS clock.
|
inlinestatic |
src | The value to set CLKOUT source. |
|
inlinestatic |
src | The value to set RTC_CLKOUT source. |
|
inlinestatic |
Set the SIM_CLKDIV1[OUTDIV1], SIM_CLKDIV1[OUTDIV4].
outdiv1 | Clock 1 output divider value. |
outdiv4 | Clock 4 output divider value. |
uint32_t CLOCK_GetFreq | ( | clock_name_t | clockName | ) |
This function checks the current clock configurations and then calculates the clock frequency for a specific clock name defined in clock_name_t. The MCG must be properly configured before using this function.
clockName | Clock names defined in clock_name_t |
uint32_t CLOCK_GetCoreSysClkFreq | ( | void | ) |
uint32_t CLOCK_GetPlatClkFreq | ( | void | ) |
uint32_t CLOCK_GetBusClkFreq | ( | void | ) |
uint32_t CLOCK_GetFlashClkFreq | ( | void | ) |
uint32_t CLOCK_GetEr32kClkFreq | ( | void | ) |
uint32_t CLOCK_GetOsc0ErClkFreq | ( | void | ) |
void CLOCK_SetSimConfig | ( | sim_clock_config_t const * | config | ) |
This function sets system layer clock settings in SIM module.
config | Pointer to the configure structure. |
|
inlinestatic |
The system level clocks (core clock, bus clock, flexbus clock and flash clock) must be in allowed ranges. During MCG clock mode switch, the MCG output clock changes then the system level clocks may be out of range. This function could be used before MCG mode change, to make sure system level clocks are in allowed range.
config | Pointer to the configure structure. |
uint32_t CLOCK_GetOutClkFreq | ( | void | ) |
This function gets the MCG_Lite output clock frequency in Hz based on the current MCG_Lite register value.
uint32_t CLOCK_GetInternalRefClkFreq | ( | void | ) |
This function gets the MCG_Lite internal reference clock frequency in Hz based on the current MCG register value.
uint32_t CLOCK_GetPeriphClkFreq | ( | void | ) |
This function gets the MCGPCLK frequency in Hz based on the current MCG_Lite register settings.
mcglite_mode_t CLOCK_GetMode | ( | void | ) |
This function checks the MCG_Lite registers and determines the current MCG_Lite mode.
status_t CLOCK_SetMcgliteConfig | ( | mcglite_config_t const * | targetConfig | ) |
This function configures the MCG_Lite, includes the output clock source, MCGIRCLK settings, HIRC settings, and so on. See mcglite_config_t for details.
targetConfig | Pointer to the target MCG_Lite mode configuration structure. |
|
inlinestatic |
This function configures the OSC external reference clock (OSCERCLK). This is an example to enable the OSCERCLK in normal mode and stop mode, and set the output divider to 1.
base | OSC peripheral address. |
config | Pointer to the configuration structure. |
|
inlinestatic |
This function sets the specified capacitor configuration for the oscillator. This should be done in the early system level initialization function call based on the system configuration.
base | OSC peripheral address. |
capLoad | OR'ed value for the capacitor load option.See _osc_cap_load. |
Example:
void CLOCK_InitOsc0 | ( | osc_config_t const * | config | ) |
This function initializes the OSC0 according to the board configuration.
config | Pointer to the OSC0 configuration structure. |
void CLOCK_DeinitOsc0 | ( | void | ) |
This function deinitializes the OSC0.
|
inlinestatic |
freq | The XTAL0/EXTAL0 input clock frequency in Hz. |
|
inlinestatic |
freq | The XTAL32/EXTAL32/RTC_CLKIN input clock frequency in Hz. |
volatile uint32_t g_xtal0Freq |
The XTAL0/EXTAL0 (OSC0) 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:
This is important for the multicore platforms where one core needs to set up the OSC0 using the CLOCK_InitOsc0. All other cores need to call the CLOCK_SetXtal0Freq to get a valid clock frequency.
volatile uint32_t g_xtal32Freq |
The XTAL32/EXTAL32/RTC_CLKIN 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 one core needs to set up the clock. All other cores need to call the CLOCK_SetXtal32Freq to get a valid clock frequency.