Chip-specific system clock management functions.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include <compiler.h>
#include <stdbool.h>
#include <sysclk.h>
#include <flashcalw.h>
#include <bpm.h>
#include <osc.h>
Macros | |
#define | PBADIV_CLKSRC_MASK |
Initial module clock masks | |
These are the mask values written to the xxxMASK registers during initialization if the user has overridden the default behavior of all clocks left enabled. These values assume that:
| |
#define | SYSCLK_INIT_MINIMAL_CPUMASK 0 |
Initial value of CPUMASK. More... | |
#define | SYSCLK_INIT_MINIMAL_HSBMASK |
Initial value of HSBMASK. More... | |
#define | SYSCLK_INIT_MINIMAL_PBAMASK 0 |
Initial value of PBAMASK. More... | |
#define | SYSCLK_INIT_MINIMAL_PBBMASK (1 << SYSCLK_HFLASHC_REGS) |
Initial value of PBBMASK. More... | |
#define | SYSCLK_INIT_MINIMAL_PBCMASK |
Initial value of PBCMASK. More... | |
#define | SYSCLK_INIT_MINIMAL_PBDMASK |
Initial value of PBDMASK. More... | |
Functions | |
void | sysclk_disable_usb (void) |
Disable the USB generic clock. More... | |
void | sysclk_enable_usb (void) |
Enable the USB generic clock. More... | |
void | sysclk_priv_disable_module (uint32_t bus_id, uint32_t module_index) |
Disable a maskable module clock. More... | |
void | sysclk_priv_enable_module (uint32_t bus_id, uint32_t module_index) |
Enable a maskable module clock. More... | |
Enabling and disabling synchronous clocks | |
void | sysclk_enable_pba_module (uint32_t module_index) |
Enable a module clock derived from the PBA clock. More... | |
void | sysclk_disable_pba_module (uint32_t module_index) |
Disable a module clock derived from the PBA clock. More... | |
void | sysclk_enable_pbb_module (uint32_t module_index) |
Enable a module clock derived from the PBB clock. More... | |
void | sysclk_disable_pbb_module (uint32_t module_index) |
Disable a module clock derived from the PBB clock. More... | |
void | sysclk_enable_peripheral_clock (const volatile void *module) |
Enable a peripheral's clock from its base address. More... | |
void | sysclk_disable_peripheral_clock (const volatile void *module) |
Disable a peripheral's clock from its base address. More... | |
Querying the system clock and its derived clocks | |
The following functions may be used to query the current frequency of the system clock and the CPU and bus clocks derived from it. sysclk_get_main_hz() and sysclk_get_cpu_hz() can be assumed to be available on all platforms, although some platforms may define additional accessors for various chip-internal bus clocks. These are usually not intended to be queried directly by generic code. | |
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. More... | |
System Clock Source and Prescaler configuration | |
void | sysclk_set_prescalers (uint32_t cpu_shift, uint32_t pba_shift, uint32_t pbb_shift, uint32_t pbc_shift, uint32_t pbd_shift) |
Set system clock prescaler configuration. More... | |
void | sysclk_set_source (uint32_t src) |
Change the source of the main system clock. More... | |
System Clock Initialization | |
void | sysclk_init (void) |
Initialize the synchronous clock system. More... | |
#define PBADIV_CLKSRC_MASK |
Referenced by sysclk_disable_peripheral_clock().