1 /* 2 ** ################################################################### 3 ** Processors: MIMXRT555SFAWC 4 ** MIMXRT555SFFOC 5 ** 6 ** Compilers: GNU C Compiler 7 ** IAR ANSI C/C++ Compiler for ARM 8 ** Keil ARM C/C++ Compiler 9 ** MCUXpresso Compiler 10 ** 11 ** Reference manual: iMXRT500RM Rev.0, 01/2021 12 ** Version: rev. 5.0, 2020-08-27 13 ** Build: b220711 14 ** 15 ** Abstract: 16 ** Provides a system configuration function and a global variable that 17 ** contains the system frequency. It configures the device and initializes 18 ** the oscillator (PLL) that is part of the microcontroller device. 19 ** 20 ** Copyright 2016 Freescale Semiconductor, Inc. 21 ** Copyright 2016-2022 NXP 22 ** All rights reserved. 23 ** 24 ** SPDX-License-Identifier: BSD-3-Clause 25 ** 26 ** http: www.nxp.com 27 ** mail: support@nxp.com 28 ** 29 ** Revisions: 30 ** - rev. 1.0 (2019-04-19) 31 ** Initial version. 32 ** - rev. 2.0 (2019-07-22) 33 ** Base on rev 0.7 RM. 34 ** - rev. 3.0 (2020-03-16) 35 ** Base on Rev.A RM. 36 ** - rev. 4.0 (2020-05-18) 37 ** Base on Rev.B RM. 38 ** - rev. 5.0 (2020-08-27) 39 ** Base on Rev.C RM. 40 ** 41 ** ################################################################### 42 */ 43 44 /*! 45 * @file MIMXRT555S 46 * @version 5.0 47 * @date 2020-08-27 48 * @brief Device specific configuration file for MIMXRT555S (header file) 49 * 50 * Provides a system configuration function and a global variable that contains 51 * the system frequency. It configures the device and initializes the oscillator 52 * (PLL) that is part of the microcontroller device. 53 */ 54 55 #ifndef _SYSTEM_MIMXRT555S_H_ 56 #define _SYSTEM_MIMXRT555S_H_ /**< Symbol preventing repeated inclusion */ 57 58 #ifdef __cplusplus 59 extern "C" { 60 #endif 61 62 #include <stdint.h> 63 64 #define DEFAULT_SYSTEM_CLOCK 1000000u /* Default System clock value */ 65 #ifndef CLK_XTAL_OSC_CLK 66 #define CLK_XTAL_OSC_CLK 24000000u /* Default XTAL OSC clock */ 67 #endif 68 #define CLK_RTC_32K_CLK 32768u /* RTC oscillator 32 kHz (32k_clk) */ 69 #define CLK_LPOSC_1MHZ 1000000u /* Low power oscillator 1 MHz (1m_lposc) */ 70 #ifndef CLK_FRO_HIGH_FREQ 71 #define CLK_FRO_HIGH_FREQ 192000000u /* The high frequency of the FRO clock */ 72 #endif 73 #ifndef CLK_FRO_LOW_FREQ 74 #define CLK_FRO_LOW_FREQ 96000000u /* The low frequency of the FRO clock */ 75 #endif 76 #ifndef CLK_EXT_CLKIN 77 #define CLK_EXT_CLKIN 0u /* Default external CLKIN pin clock */ 78 #endif 79 #define CLK_OSC_CLK \ 80 ((CLKCTL0->SYSOSCBYPASS == 0u) ? CLK_XTAL_OSC_CLK : ((CLKCTL0->SYSOSCBYPASS == 1u) ? CLK_EXT_CLKIN : 0u)) 81 82 #define FRO_TUNER_USED ((CLKCTL0->FRO_CONTROL & CLKCTL0_FRO_CONTROL_EXP_COUNT_MASK) != 0u) 83 #define FRO_FREQ_GET_FROM_FUSE ((CLKCTL0->FRO_SCTRIM & 0x3fu) == 0x2fu ? CLK_FRO_LOW_FREQ : CLK_FRO_HIGH_FREQ) 84 /* freq = reference_clk * (2 * FRO_CAPVAL - 6) / 4095 */ 85 #define FRO_FREQ_GET_FROM_TUNER \ 86 (CLK_OSC_CLK / 4095u * (2u * (CLKCTL0->FRO_CAPVAL & CLKCTL0_FRO_CAPVAL_CAPVAL_MASK) - 6u) * 4u) 87 88 #define CLK_FRO_CLK (FRO_TUNER_USED ? FRO_FREQ_GET_FROM_TUNER : FRO_FREQ_GET_FROM_FUSE) 89 #define CLK_FRO_DIV2_CLK (CLK_FRO_CLK / 2u) /* FRO_DIV2 clock frequency */ 90 #define CLK_FRO_DIV4_CLK (CLK_FRO_CLK / 4u) /* FRO_DIV4 clock frequency */ 91 #define CLK_FRO_DIV8_CLK (CLK_FRO_CLK / 8u) /* FRO_DIV8 clock frequency */ 92 #define CLK_FRO_DIV16_CLK (CLK_FRO_CLK / 16u) /* FRO_DIV16 clock frequency */ 93 94 /** 95 * @brief System clock frequency (core clock) 96 * 97 * The system clock frequency supplied to the SysTick timer and the processor 98 * core clock. This variable can be used by the user application to setup the 99 * SysTick timer or configure other parameters. It may also be used by debugger to 100 * query the frequency of the debug timer or configure the trace clock speed 101 * SystemCoreClock is initialized with a correct predefined value. 102 */ 103 extern uint32_t SystemCoreClock; 104 105 /** 106 * @brief Setup the microcontroller system. 107 * 108 * Typically this function configures the oscillator (PLL) that is part of the 109 * microcontroller device. For systems with variable clock speed it also updates 110 * the variable SystemCoreClock. SystemInit is called from startup_device file. 111 */ 112 void SystemInit(void); 113 114 /** 115 * @brief Updates the SystemCoreClock variable. 116 * 117 * It must be called whenever the core clock is changed during program 118 * execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates 119 * the current core clock. 120 */ 121 void SystemCoreClockUpdate(void); 122 123 /** 124 * @brief SystemInit function hook. 125 * 126 * This weak function allows to call specific initialization code during the 127 * SystemInit() execution.This can be used when an application specific code needs 128 * to be called as close to the reset entry as possible (for example the Multicore 129 * Manager MCMGR_EarlyInit() function call). 130 * NOTE: No global r/w variables can be used in this hook function because the 131 * initialization of these variables happens after this function. 132 */ 133 void SystemInitHook(void); 134 135 #ifdef __cplusplus 136 } 137 #endif 138 139 #endif /* _SYSTEM_MIMXRT555S_H_ */ 140