37 #ifndef CHIP_SYSCLK_H_INCLUDED 38 #define CHIP_SYSCLK_H_INCLUDED 214 #ifndef CONFIG_SYSCLK_SOURCE 215 # define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_MAINCK_4M_RC 227 #ifndef CONFIG_SYSCLK_PRES 228 # define CONFIG_SYSCLK_PRES 0 235 #define SYSCLK_SRC_SLCK_RC 0 236 #define SYSCLK_SRC_SLCK_XTAL 1 237 #define SYSCLK_SRC_SLCK_BYPASS 2 238 #define SYSCLK_SRC_MAINCK_4M_RC 3 239 #define SYSCLK_SRC_MAINCK_8M_RC 4 240 #define SYSCLK_SRC_MAINCK_12M_RC 5 241 #define SYSCLK_SRC_MAINCK_XTAL 6 242 #define SYSCLK_SRC_MAINCK_BYPASS 7 243 #define SYSCLK_SRC_PLLACK 8 244 #define SYSCLK_SRC_UPLLCK 9 249 #define SYSCLK_PRES_1 PMC_MCKR_PRES_CLK_1 250 #define SYSCLK_PRES_2 PMC_MCKR_PRES_CLK_2 251 #define SYSCLK_PRES_4 PMC_MCKR_PRES_CLK_4 252 #define SYSCLK_PRES_8 PMC_MCKR_PRES_CLK_8 253 #define SYSCLK_PRES_16 PMC_MCKR_PRES_CLK_16 254 #define SYSCLK_PRES_32 PMC_MCKR_PRES_CLK_32 255 #define SYSCLK_PRES_64 PMC_MCKR_PRES_CLK_64 256 #define SYSCLK_PRES_3 PMC_MCKR_PRES_CLK_3 261 #define SYSCLK_DIV_1 PMC_MCKR_MDIV_EQ_PCK 262 #define SYSCLK_DIV_2 PMC_MCKR_MDIV_PCK_DIV2 263 #define SYSCLK_DIV_4 PMC_MCKR_MDIV_PCK_DIV4 264 #define SYSCLK_DIV_3 PMC_MCKR_MDIV_PCK_DIV3 269 #define USBCLK_SRC_PLL0 0 270 #define USBCLK_SRC_UPLL 1 284 # define CONFIG_USBCLK_SOURCE 296 # define CONFIG_USBCLK_DIV 321 #if (defined CONFIG_SYSCLK_DEFAULT_RETURNS_SLOW_OSC) 322 extern uint32_t sysclk_initialized;
326 #if (defined CONFIG_SYSCLK_DEFAULT_RETURNS_SLOW_OSC) 327 if (!sysclk_initialized ) {
350 #ifdef CONFIG_PLL0_SOURCE 356 #ifdef CONFIG_PLL1_SOURCE #define OSC_MAINCK_XTAL_HZ
External crystal oscillator.
#define UNUSED(v)
Marking v as a unused parameter or value.
#define pll_get_default_rate(pll_id)
Get the default rate in Hz of pll_id.
static uint32_t sysclk_get_cpu_hz(void)
Return the current rate in Hz of the CPU clock.
#define OSC_SLCK_32K_XTAL_HZ
External 32kHz crystal oscillator.
#define CONFIG_SYSCLK_SOURCE
Initial/static main system clock source.
#define SYSCLK_PRES_3
Set master clock prescaler to 3.
#define SYSCLK_SRC_MAINCK_12M_RC
Internal 12MHz RC oscillator as master source clock.
uint32_t pmc_disable_periph_clk(uint32_t ul_id)
Disable the specified peripheral clock.
uint32_t pmc_enable_periph_clk(uint32_t ul_id)
Enable the specified peripheral clock.
#define OSC_SLCK_32K_BYPASS_HZ
External 32kHz bypass oscillator.
#define OSC_MAINCK_12M_RC_HZ
Internal 12MHz RC oscillator.
#define SYSCLK_SRC_PLLACK
Use PLLACK as master source clock.
#define SYSCLK_SRC_MAINCK_8M_RC
Internal 8MHz RC oscillator as master source clock.
#define SYSCLK_SRC_SLCK_XTAL
External 32kHz crystal oscillator as master source clock.
Chip-specific PLL definitions.
#define SYSCLK_SRC_SLCK_RC
Internal 32kHz RC oscillator as master source clock.
static uint32_t sysclk_get_peripheral_hz(void)
Retrieves the current rate in Hz of the peripheral clocks.
#define OSC_MAINCK_8M_RC_HZ
Internal 8MHz RC oscillator.
void sysclk_set_prescalers(uint32_t ul_pres)
Set system clock prescaler configuration.
void sysclk_init(void)
Initialize the synchronous clock system.
static void sysclk_disable_peripheral_clock(uint32_t ul_id)
Disable a peripheral's clock.
void sysclk_enable_usb(void)
#define SYSCLK_SRC_SLCK_BYPASS
External 32kHz bypass oscillator as master source clock.
#define OSC_SLCK_32K_RC_HZ
Internal 32kHz RC oscillator.
void sysclk_disable_usb(void)
#define CONFIG_SYSCLK_PRES
Initial CPU clock divider (mck)
#define OSC_MAINCK_4M_RC_HZ
Internal 4MHz RC oscillator.
#define PMC_MCKR_PRES_Pos
#define CONFIG_SYSCLK_DIV
static void sysclk_enable_peripheral_clock(uint32_t ul_id)
Enable a peripheral's clock.
#define SYSCLK_SRC_UPLLCK
Use UPLLCK as master source clock.
#define SYSCLK_SRC_MAINCK_XTAL
External crystal oscillator as master source clock.
Chip-specific oscillator management functions.
#define OSC_MAINCK_BYPASS_HZ
External bypass oscillator.
#define SYSCLK_SRC_MAINCK_BYPASS
External bypass oscillator as master source clock.
static uint32_t sysclk_get_peripheral_bus_hz(const volatile void *module)
Retrieves the current rate in Hz of the Peripheral Bus clock attached to the specified peripheral...
#define SYSCLK_SRC_MAINCK_4M_RC
Internal 4MHz RC oscillator as master source clock.
void sysclk_set_source(uint32_t ul_src)
Change the source of the main system clock.
static uint32_t sysclk_get_main_hz(void)
Return the current rate in Hz of the main system clock.