#include <stdint.h>
#include <cfg/arch.h>
#include <arch/cm3.h>
#include <arch/cm3/timer.h>
#include <arch/cm3/nxp/lpc177x_8x_clk.h>
#include <cfg/clock.h>
#include <arch/cm3/nxp/lpc177x_8x.h>
Defines | |
#define | CLOCK_SETUP 1 |
#define | SCS_Val 0x00000021 |
#define | CLKSRCSEL_Val 0x00000001 |
#define | PLL0_SETUP 1 |
#define | PLL0CFG_Val 0x00000009 |
#define | PLL1_SETUP 1 |
#define | PLL1CFG_Val 0x00000023 |
#define | CCLKSEL_Val (0x00000001|(1<<8)) |
#define | USBCLK_SETUP 1 |
#define | USBCLKSEL_Val (0x00000001|(0x02<<8)) |
#define | EMCCLKSEL_Val 0x00000001 |
#define | PCLKSEL_Val 0x00000002 |
#define | PCONP_Val 0x042887DE |
#define | CLKOUTCFG_Val 0x00000100 |
#define | FLASH_SETUP 1 |
#define | FLASHCFG_Val 0x00005000 |
#define | CHECK_RANGE(val, min, max) ((val < min) || (val > max)) |
#define | CHECK_RSVD(val, mask) (val & mask) |
#define | __M ((PLL0CFG_Val & 0x1F) + 1) |
#define | __PLL0_CLK(__F_IN) (__F_IN * __M) |
#define | __CCLK_DIV (CCLKSEL_Val & 0x1F) |
#define | __PCLK_DIV (PCLKSEL_Val & 0x1F) |
#define | __ECLK_DIV ((EMCCLKSEL_Val & 0x01) + 1) |
#define | __CORE_CLK (__PLL0_CLK(OSC_CLK) / __CCLK_DIV) |
#define | __PER_CLK (__PLL0_CLK(OSC_CLK) / __PCLK_DIV) |
#define | __EMC_CLK (__PLL0_CLK(OSC_CLK) / __ECLK_DIV) |
Functions | |
void | SystemCoreClockUpdate (void) |
int | SetSysClock (void) |
Sets System clock frequency to the configured defaults. | |
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 | PeripheralClock = __PER_CLK |
uint32_t | EMCClock = __EMC_CLK |
uint32_t | USBClock = (48000000UL) |
#define CLOCK_SETUP 1 |
#define SCS_Val 0x00000021 |
Referenced by SetSysClock().
#define CLKSRCSEL_Val 0x00000001 |
Referenced by SetSysClock().
#define PLL0_SETUP 1 |
#define PLL0CFG_Val 0x00000009 |
Referenced by SetSysClock().
#define PLL1_SETUP 1 |
#define PLL1CFG_Val 0x00000023 |
Referenced by SetSysClock().
#define CCLKSEL_Val (0x00000001|(1<<8)) |
Referenced by SetSysClock().
#define USBCLK_SETUP 1 |
#define USBCLKSEL_Val (0x00000001|(0x02<<8)) |
Referenced by SetSysClock().
#define EMCCLKSEL_Val 0x00000001 |
Referenced by SetSysClock().
#define PCLKSEL_Val 0x00000002 |
Referenced by SetSysClock().
#define PCONP_Val 0x042887DE |
Referenced by SetSysClock().
#define CLKOUTCFG_Val 0x00000100 |
Referenced by SetSysClock().
#define FLASH_SETUP 1 |
#define FLASHCFG_Val 0x00005000 |
Referenced by SetSysClock().
#define CHECK_RANGE | ( | val, | |
min, | |||
max | |||
) | ((val < min) || (val > max)) |
#define CHECK_RSVD | ( | val, | |
mask | |||
) | (val & mask) |
#define __M ((PLL0CFG_Val & 0x1F) + 1) |
#define __PLL0_CLK | ( | __F_IN | ) | (__F_IN * __M) |
#define __CCLK_DIV (CCLKSEL_Val & 0x1F) |
#define __PCLK_DIV (PCLKSEL_Val & 0x1F) |
#define __ECLK_DIV ((EMCCLKSEL_Val & 0x01) + 1) |
#define __CORE_CLK (__PLL0_CLK(OSC_CLK) / __CCLK_DIV) |
#define __PER_CLK (__PLL0_CLK(OSC_CLK) / __PCLK_DIV) |
#define __EMC_CLK (__PLL0_CLK(OSC_CLK) / __ECLK_DIV) |
int SetSysClock | ( | void | ) |
Sets System clock frequency to the configured defaults.
Update SystemCoreClock according to Clock Register Values.
None |
None |
References CCLKSEL_Val, CLKOUTCFG_Val, CLKSRCSEL_Val, EMCCLKSEL_Val, FLASHCFG_Val, LPC_SC, PCLKSEL_Val, PCONP_Val, PLL0CFG_Val, PLL1CFG_Val, rc, SCS_Val, SystemCoreClockUpdate(), and USBCLKSEL_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 EMCClock, NUT_HWCLK_CPU, PeripheralClock, SystemCoreClock, SystemCoreClockUpdate(), and USBClock.
Referenced by Lpc177x_8x_MciSet_MCIClock(), and NutArchClockGet().
uint32_t PeripheralClock = __PER_CLK |
Peripheral Clock Frequency (Pclk)
Referenced by Lpc17xx_ClockGet(), and SystemCoreClockUpdate().
EMC Clock Frequency
Referenced by Lpc17xx_ClockGet(), and SystemCoreClockUpdate().