1 /* 2 ** ################################################################### 3 ** Processors: MCXA152VFM 4 ** MCXA152VFT 5 ** MCXA152VLF 6 ** MCXA152VLH 7 ** 8 ** Compilers: GNU C Compiler 9 ** IAR ANSI C/C++ Compiler for ARM 10 ** Keil ARM C/C++ Compiler 11 ** MCUXpresso Compiler 12 ** 13 ** Reference manual: MCXA1 User manual 14 ** Version: rev. 1.0, 2022-03-29 15 ** Build: b240403 16 ** 17 ** Abstract: 18 ** Provides a system configuration function and a global variable that 19 ** contains the system frequency. It configures the device and initializes 20 ** the oscillator (PLL) that is part of the microcontroller device. 21 ** 22 ** Copyright 2016 Freescale Semiconductor, Inc. 23 ** Copyright 2016-2024 NXP 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 (2022-03-29) 31 ** Initial version based on v0.1UM 32 ** 33 ** ################################################################### 34 */ 35 36 /*! 37 * @file MCXA152 38 * @version 1.0 39 * @date 2022-03-29 40 * @brief Device specific configuration file for MCXA152 (implementation file) 41 * 42 * Provides a system configuration function and a global variable that contains 43 * the system frequency. It configures the device and initializes the oscillator 44 * (PLL) that is part of the microcontroller device. 45 */ 46 47 #include <stdint.h> 48 #include "fsl_device_registers.h" 49 50 51 52 53 54 /* ---------------------------------------------------------------------------- 55 -- Core clock 56 ---------------------------------------------------------------------------- */ 57 58 uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK; 59 60 /* ---------------------------------------------------------------------------- 61 -- SystemInit() 62 ---------------------------------------------------------------------------- */ 63 SystemInit(void)64__attribute__ ((weak)) void SystemInit (void) { 65 66 SCB->CPACR |= ((3UL << 0*2) | (3UL << 1*2)); /* set CP0, CP1 Full Access in Secure mode (enable PowerQuad) */ 67 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) 68 SCB_NS->CPACR |= ((3UL << 0*2) | (3UL << 1*2)); /* set CP0, CP1 Full Access in Normal mode (enable PowerQuad) */ 69 #endif /* (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */ 70 71 SCB->NSACR |= ((3UL << 0) | (3UL << 10)); /* enable CP0, CP1, CP10, CP11 Non-secure Access */ 72 73 #if !defined(__ZEPHYR__) 74 #if defined(__MCUXPRESSO) 75 extern void(*const g_pfnVectors[]) (void); 76 SCB->VTOR = (uint32_t) &g_pfnVectors; 77 #else 78 extern void *__Vectors; 79 SCB->VTOR = (uint32_t) &__Vectors; 80 #endif 81 #endif 82 83 /* Enable the LPCAC */ 84 SYSCON->LPCAC_CTRL |= SYSCON_LPCAC_CTRL_LPCAC_MEM_REQ_MASK; 85 SYSCON->LPCAC_CTRL &= ~SYSCON_LPCAC_CTRL_DIS_LPCAC_MASK; 86 87 /* Enable flash RWX when FLASH_ACL in IFR0 is invalid */ 88 if ((*((volatile const uint32_t *)(0x1000000)) == 0xFFFFFFFFU) || 89 ((*((volatile const uint32_t *)(0x1000000)) == 0x59630000U) && 90 (*((volatile const uint32_t *)(0x1000040)) == 0xFFFFFFFFU) && 91 (*((volatile const uint32_t *)(0x1000044)) == 0xFFFFFFFFU))) 92 { 93 /* Enable MBC register written with GLIKEY index15 */ 94 GLIKEY0->CTRL_0 = 0x00060000U; 95 GLIKEY0->CTRL_0 = 0x0002000FU; 96 GLIKEY0->CTRL_0 = 0x0001000FU; 97 GLIKEY0->CTRL_1 = 0x00290000U; 98 GLIKEY0->CTRL_0 = 0x0002000FU; 99 GLIKEY0->CTRL_1 = 0x00280000U; 100 GLIKEY0->CTRL_0 = 0x0000000FU; 101 102 /* Enable RWX for GLBAC0 */ 103 MBC0->MBC_INDEX[0].MBC_MEMN_GLBAC[0] = 0x7700U; 104 105 /* Use GLBAC0 for all flash block */ 106 for (uint8_t i = 0; i < 2U; i++) 107 { 108 MBC0->MBC_INDEX[0].MBC_DOM0_MEM0_BLK_CFG_W[i] = 0x00000000U; 109 } 110 111 /* Disable MBC register written */ 112 GLIKEY0->CTRL_0 = 0x0002000FU; 113 } 114 SystemInitHook(); 115 } 116 117 /* ---------------------------------------------------------------------------- 118 -- SystemCoreClockUpdate() 119 ---------------------------------------------------------------------------- */ 120 SystemCoreClockUpdate(void)121void SystemCoreClockUpdate (void) { 122 123 } 124 125 /* ---------------------------------------------------------------------------- 126 -- SystemInitHook() 127 ---------------------------------------------------------------------------- */ 128 SystemInitHook(void)129__attribute__ ((weak)) void SystemInitHook (void) { 130 /* Void implementation of the weak function. */ 131 } 132