1 /* 2 ** ################################################################### 3 ** Processors: LPC804M101JDH20 4 ** LPC804M101JDH24 5 ** LPC804M101JHI33 6 ** LPC804M111JDH24 7 ** LPC804UK 8 ** 9 ** Compilers: GNU C Compiler 10 ** IAR ANSI C/C++ Compiler for ARM 11 ** Keil ARM C/C++ Compiler 12 ** MCUXpresso Compiler 13 ** 14 ** Reference manual: LPC804 User manual Rev.1.0 24 Jan 2018 15 ** Version: rev. 1.0, 2018-01-09 16 ** Build: b201015 17 ** 18 ** Abstract: 19 ** Provides a system configuration function and a global variable that 20 ** contains the system frequency. It configures the device and initializes 21 ** the oscillator (PLL) that is part of the microcontroller device. 22 ** 23 ** Copyright 2016 Freescale Semiconductor, Inc. 24 ** Copyright 2016-2020 NXP 25 ** All rights reserved. 26 ** 27 ** SPDX-License-Identifier: BSD-3-Clause 28 ** 29 ** http: www.nxp.com 30 ** mail: support@nxp.com 31 ** 32 ** Revisions: 33 ** - rev. 1.0 (2018-01-09) 34 ** Initial version. 35 ** 36 ** ################################################################### 37 */ 38 39 /*! 40 * @file LPC804 41 * @version 1.0 42 * @date 2018-01-09 43 * @brief Device specific configuration file for LPC804 (implementation file) 44 * 45 * Provides a system configuration function and a global variable that contains 46 * the system frequency. It configures the device and initializes the oscillator 47 * (PLL) that is part of the microcontroller device. 48 */ 49 50 #include <stdint.h> 51 #include "fsl_device_registers.h" 52 53 54 55 56 57 /* ---------------------------------------------------------------------------- 58 -- Core clock 59 ---------------------------------------------------------------------------- */ 60 61 uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK; 62 63 /* ---------------------------------------------------------------------------- 64 -- SystemInit() 65 ---------------------------------------------------------------------------- */ 66 SystemInit(void)67void SystemInit (void) { 68 69 #if defined(__MCUXPRESSO) 70 extern void(*const g_pfnVectors[]) (void); 71 SCB->VTOR = (uint32_t) &g_pfnVectors; 72 #else 73 extern void *__Vectors; 74 SCB->VTOR = (uint32_t) &__Vectors; 75 #endif 76 SystemCoreClock = DEFAULT_SYSTEM_CLOCK; 77 SystemInitHook(); 78 } 79 80 /* ---------------------------------------------------------------------------- 81 -- SystemCoreClockUpdate() 82 ---------------------------------------------------------------------------- */ 83 SystemCoreClockUpdate(void)84void SystemCoreClockUpdate (void) { 85 86 87 switch (SYSCON->MAINCLKSEL & SYSCON_MAINCLKSEL_SEL_MASK) 88 { 89 case 0U: /* Free running oscillator (FRO / 2) */ 90 SystemCoreClock = (g_Fro_Osc_Freq >> 1U); 91 break; 92 case 1U: /* System oscillator */ 93 SystemCoreClock = CLK_OSC_IN; 94 break; 95 case 2U: /* lower power oscillator */ 96 SystemCoreClock = CLK_OSC_LP; 97 break; 98 case 3U: /* Free running oscillator ((FRO / 2) / 2) */ 99 SystemCoreClock = (g_Fro_Osc_Freq >> 2U); 100 break; 101 default: 102 SystemCoreClock = 0U; 103 break; 104 } 105 106 SystemCoreClock /= SYSCON->SYSAHBCLKDIV; 107 } 108 109 /* ---------------------------------------------------------------------------- 110 -- SystemInitHook() 111 ---------------------------------------------------------------------------- */ 112 SystemInitHook(void)113__attribute__ ((weak)) void SystemInitHook (void) { 114 /* Void implementation of the weak function. */ 115 } 116