1 /**************************************************************************//**
2  * @file     system_ARMCM33.c
3  * @brief    CMSIS Device System Source File for
4  *           ARMCM33 Device
5  * @version  V1.0.1
6  * @date     15. November 2019
7  ******************************************************************************/
8 /*
9  * Copyright (c) 2009-2019 Arm Limited. All rights reserved.
10  *
11  * SPDX-License-Identifier: Apache-2.0
12  *
13  * Licensed under the Apache License, Version 2.0 (the License); you may
14  * not use this file except in compliance with the License.
15  * You may obtain a copy of the License at
16  *
17  * www.apache.org/licenses/LICENSE-2.0
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
21  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  */
25 
26 #if defined (ARMCM33)
27   #include "ARMCM33.h"
28 #elif defined (ARMCM33_TZ)
29   #include "ARMCM33_TZ.h"
30 
31   #if defined (__ARM_FEATURE_CMSE) &&  (__ARM_FEATURE_CMSE == 3U)
32     #include "partition_ARMCM33.h"
33   #endif
34 #elif defined (ARMCM33_DSP_FP)
35   #include "ARMCM33_DSP_FP.h"
36 #elif defined (ARMCM33_DSP_FP_TZ)
37   #include "ARMCM33_DSP_FP_TZ.h"
38 
39   #if defined (__ARM_FEATURE_CMSE) &&  (__ARM_FEATURE_CMSE == 3U)
40     #include "partition_ARMCM33.h"
41   #endif
42 #else
43   #error device not specified!
44 #endif
45 
46 /*----------------------------------------------------------------------------
47   Define clocks
48  *----------------------------------------------------------------------------*/
49 #define  XTAL            (50000000UL)     /* Oscillator frequency */
50 
51 #define  SYSTEM_CLOCK    (XTAL / 2U)
52 
53 /*----------------------------------------------------------------------------
54   Exception / Interrupt Vector table
55  *----------------------------------------------------------------------------*/
56 extern const VECTOR_TABLE_Type __VECTOR_TABLE[496];
57 
58 
59 /*----------------------------------------------------------------------------
60   System Core Clock Variable
61  *----------------------------------------------------------------------------*/
62 uint32_t SystemCoreClock = SYSTEM_CLOCK;  /* System Core Clock Frequency */
63 
64 
65 /*----------------------------------------------------------------------------
66   System Core Clock update function
67  *----------------------------------------------------------------------------*/
SystemCoreClockUpdate(void)68 void SystemCoreClockUpdate (void)
69 {
70   SystemCoreClock = SYSTEM_CLOCK;
71 }
72 
73 /*----------------------------------------------------------------------------
74   System initialization function
75  *----------------------------------------------------------------------------*/
SystemInit(void)76 void SystemInit (void)
77 {
78 
79 #if defined (__VTOR_PRESENT) && (__VTOR_PRESENT == 1U)
80   SCB->VTOR = (uint32_t) &(__VECTOR_TABLE[0]);
81 #endif
82 
83 #if defined (__FPU_USED) && (__FPU_USED == 1U)
84   SCB->CPACR |= ((3U << 10U*2U) |           /* enable CP10 Full Access */
85                  (3U << 11U*2U)  );         /* enable CP11 Full Access */
86 #endif
87 
88 #ifdef UNALIGNED_SUPPORT_DISABLE
89   SCB->CCR |= SCB_CCR_UNALIGN_TRP_Msk;
90 #endif
91 
92 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
93   TZ_SAU_Setup();
94 #endif
95 
96   SystemCoreClock = SYSTEM_CLOCK;
97 }
98