1 /* 2 ** ################################################################### 3 ** Processors: LPC802M001JDH16 4 ** LPC802M001JDH20 5 ** LPC802M001JHI33 6 ** LPC802M011JDH20 7 ** LPC802UK 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: LPC802 User manual Rev.1.0 1 Dec 2017 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 LPC802 41 * @version 1.0 42 * @date 2018-01-09 43 * @brief Device specific configuration file for LPC802 (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 switch (SYSCON->MAINCLKSEL & SYSCON_MAINCLKSEL_SEL_MASK) { 87 case 0U: /* Free running oscillator (FRO / 2) */ 88 SystemCoreClock = (g_Fro_Osc_Freq >> 1U); 89 break; 90 case 1U: /* System oscillator */ 91 SystemCoreClock = CLK_OSC_IN; 92 break; 93 case 2U: /* low power oscillator */ 94 SystemCoreClock = CLK_OSC_LP; 95 break; 96 case 3U: /* Free running oscillator ((FRO / 2) / 2) */ 97 SystemCoreClock = (g_Fro_Osc_Freq >> 2U); 98 break; 99 default: 100 SystemCoreClock = 0U; 101 break; 102 } 103 104 SystemCoreClock /= SYSCON->SYSAHBCLKDIV; 105 } 106 107 /* ---------------------------------------------------------------------------- 108 -- SystemInitHook() 109 ---------------------------------------------------------------------------- */ 110 SystemInitHook(void)111__attribute__ ((weak)) void SystemInitHook (void) { 112 /* Void implementation of the weak function. */ 113 } 114