#include <stdint.h>
#include <cfg/arch.h>
#include <arch/cm3.h>
#include <arch/cm3/timer.h>
#include <arch/cm3/nxp/lpc176x_clk.h>
#include <cfg/clock.h>
#include <arch/cm3/nxp/lpc176x.h>
Defines | |
#define | CLOCK_SETUP 1 |
#define | SCS_Val 0x00000020 |
#define | CLKSRCSEL_Val 0x00000001 |
#define | PLL0_SETUP 1 |
#define | PLL0CFG_Val 0x00050063 |
#define | PLL1_SETUP 1 |
#define | PLL1CFG_Val 0x00000023 |
#define | CCLKCFG_Val 0x00000003 |
#define | USBCLKCFG_Val 0x00000000 |
#define | PCLKSEL0_Val 0x00000000 |
#define | PCLKSEL1_Val 0x00000000 |
#define | PCONP_Val 0x042887DE |
#define | CLKOUTCFG_Val 0x00000000 |
#define | FLASH_SETUP 1 |
#define | FLASHCFG_Val 0x00004000 |
#define | CHECK_RANGE(val, min, max) ((val < min) || (val > max)) |
#define | CHECK_RSVD(val, mask) (val & mask) |
#define | __M (((PLL0CFG_Val ) & 0x7FFF) + 1) |
#define | __N (((PLL0CFG_Val >> 16) & 0x00FF) + 1) |
#define | __FCCO(__F_IN) ((2 * __M * __F_IN) / __N) |
#define | __CCLK_DIV (((CCLKCFG_Val ) & 0x00FF) + 1) |
#define | __CORE_CLK (__FCCO(OSC_CLK) / __CCLK_DIV) |
Functions | |
void | SystemCoreClockUpdate (void) |
int | SetSysClock (void) |
Update SystemCoreClock according to Clock Register Values. | |
uint32_t | SysCtlClockGet (void) |
requests System clock frequency | |
uint32_t | Lpc17xx_ClockGet (int idx) |
requests frequency of the given clock | |
Variables | |
uint32_t | SystemCoreClock = __CORE_CLK |
uint32_t | USBClock = (48000000UL) |
#define CLOCK_SETUP 1 |
#define SCS_Val 0x00000020 |
Referenced by SetSysClock().
#define CLKSRCSEL_Val 0x00000001 |
Referenced by SetSysClock().
#define PLL0_SETUP 1 |
#define PLL0CFG_Val 0x00050063 |
Referenced by SetSysClock().
#define PLL1_SETUP 1 |
#define PLL1CFG_Val 0x00000023 |
Referenced by SetSysClock().
#define CCLKCFG_Val 0x00000003 |
Referenced by SetSysClock().
#define USBCLKCFG_Val 0x00000000 |
Referenced by SetSysClock().
#define PCLKSEL0_Val 0x00000000 |
Referenced by SetSysClock().
#define PCLKSEL1_Val 0x00000000 |
Referenced by SetSysClock().
#define PCONP_Val 0x042887DE |
Referenced by SetSysClock().
#define CLKOUTCFG_Val 0x00000000 |
Referenced by SetSysClock().
#define FLASH_SETUP 1 |
#define FLASHCFG_Val 0x00004000 |
Referenced by SetSysClock().
#define CHECK_RANGE | ( | val, | |
min, | |||
max | |||
) | ((val < min) || (val > max)) |
#define CHECK_RSVD | ( | val, | |
mask | |||
) | (val & mask) |
#define __M (((PLL0CFG_Val ) & 0x7FFF) + 1) |
#define __N (((PLL0CFG_Val >> 16) & 0x00FF) + 1) |
#define __FCCO | ( | __F_IN | ) | ((2 * __M * __F_IN) / __N) |
#define __CCLK_DIV (((CCLKCFG_Val ) & 0x00FF) + 1) |
#define __CORE_CLK (__FCCO(OSC_CLK) / __CCLK_DIV) |
int SetSysClock | ( | void | ) |
Update SystemCoreClock according to Clock Register Values.
This function reads out the CPUs clock and PLL registers and assembles the actual clock speed values into the SystemCoreClock global variable. Sets System clock frequency to the configured defaults.
None |
None |
References CCLKCFG_Val, CLKOUTCFG_Val, CLKSRCSEL_Val, FLASHCFG_Val, LPC_SC, PCLKSEL0_Val, PCLKSEL1_Val, PCONP_Val, PLL0CFG_Val, PLL1CFG_Val, rc, SCS_Val, SystemCoreClockUpdate(), and USBCLKCFG_Val.
uint32_t SysCtlClockGet | ( | void | ) |
requests System clock frequency
None |
None |
References SystemCoreClock, and SystemCoreClockUpdate().
uint32_t Lpc17xx_ClockGet | ( | int | idx | ) |
requests frequency of the given clock
idx | NUT_HWCLK Index |
clock | or 0 if idx points to an invalid clock |
References NUT_HWCLK_CPU, SystemCoreClock, SystemCoreClockUpdate(), and USBClock.
USB Clock Frequency - this value will be updated after call SystemCoreClockUpdate, should be 48MHz
Referenced by Lpc17xx_ClockGet(), and SystemCoreClockUpdate().