Nut/OS  5.0.5
API Reference
lpc177x_8x_clk.c File Reference
#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>
Include dependency graph for lpc177x_8x_clk.c:

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 Documentation

#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)

Function Documentation

int SetSysClock ( void  )

Sets System clock frequency to the configured defaults.

Update SystemCoreClock according to Clock Register Values.

Note:
This function should be used only after reset.
Parameters:
None
Return values:
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.

Here is the call graph for this function:

uint32_t SysCtlClockGet ( void  )

requests System clock frequency

Note:
This function should be used only after reset.
Parameters:
None
Return values:
None

References SystemCoreClock, and SystemCoreClockUpdate().

Here is the call graph for this function:

uint32_t Lpc17xx_ClockGet ( int  idx)

requests frequency of the given clock

Parameters:
idxNUT_HWCLK Index
Return values:
clockor 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().

Here is the call graph for this function:


Variable Documentation

Peripheral Clock Frequency (Pclk)

Referenced by Lpc17xx_ClockGet(), and SystemCoreClockUpdate().

uint32_t EMCClock = __EMC_CLK

EMC Clock Frequency

Referenced by Lpc17xx_ClockGet(), and SystemCoreClockUpdate().

uint32_t USBClock = (48000000UL)

USB Clock Frequency - this value will be updated after call SystemCoreClockUpdate, should be 48MHz