1 /******************************************************************************
2 * @file startup_ARMCM55.c
3 * @brief CMSIS Core Device Startup File for ARMCM55 Device
4 * @version V1.0.0
5 * @date 31. March 2020
6 ******************************************************************************/
7 /*
8 * Copyright (c) 2020 Arm Limited. All rights reserved.
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 *
12 * Licensed under the Apache License, Version 2.0 (the License); you may
13 * not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 */
24
25 #if defined (ARMCM55)
26 #include "ARMCM55.h"
27 #else
28 #error device not specified!
29 #endif
30
31 /*----------------------------------------------------------------------------
32 External References
33 *----------------------------------------------------------------------------*/
34 extern uint32_t __INITIAL_SP;
35 extern uint32_t __STACK_LIMIT;
36
37 extern __NO_RETURN void __PROGRAM_START(void);
38
39 /*----------------------------------------------------------------------------
40 Internal References
41 *----------------------------------------------------------------------------*/
42 __NO_RETURN void Reset_Handler (void);
43 void Default_Handler(void);
44
45 /*----------------------------------------------------------------------------
46 Exception / Interrupt Handler
47 *----------------------------------------------------------------------------*/
48 /* Exceptions */
49 void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
50 void HardFault_Handler (void) __attribute__ ((weak));
51 void MemManage_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
52 void BusFault_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
53 void UsageFault_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
54 void SecureFault_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
55 void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
56 void DebugMon_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
57 void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
58 void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
59
60 void Interrupt0_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
61 void Interrupt1_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
62 void Interrupt2_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
63 void Interrupt3_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
64 void Interrupt4_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
65 void Interrupt5_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
66 void Interrupt6_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
67 void Interrupt7_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
68 void Interrupt8_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
69 void Interrupt9_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
70
71
72 /*----------------------------------------------------------------------------
73 Exception / Interrupt Vector table
74 *----------------------------------------------------------------------------*/
75
76 #if defined ( __GNUC__ )
77 #pragma GCC diagnostic push
78 #pragma GCC diagnostic ignored "-Wpedantic"
79 #endif
80
81 extern const VECTOR_TABLE_Type __VECTOR_TABLE[496];
82 const VECTOR_TABLE_Type __VECTOR_TABLE[496] __VECTOR_TABLE_ATTRIBUTE = {
83 (VECTOR_TABLE_Type)(&__INITIAL_SP), /* Initial Stack Pointer */
84 Reset_Handler, /* Reset Handler */
85 NMI_Handler, /* -14 NMI Handler */
86 HardFault_Handler, /* -13 Hard Fault Handler */
87 MemManage_Handler, /* -12 MPU Fault Handler */
88 BusFault_Handler, /* -11 Bus Fault Handler */
89 UsageFault_Handler, /* -10 Usage Fault Handler */
90 SecureFault_Handler, /* -9 Secure Fault Handler */
91 0, /* Reserved */
92 0, /* Reserved */
93 0, /* Reserved */
94 SVC_Handler, /* -5 SVCall Handler */
95 DebugMon_Handler, /* -4 Debug Monitor Handler */
96 0, /* Reserved */
97 PendSV_Handler, /* -2 PendSV Handler */
98 SysTick_Handler, /* -1 SysTick Handler */
99
100 /* Interrupts */
101 Interrupt0_Handler, /* 0 Interrupt 0 */
102 Interrupt1_Handler, /* 1 Interrupt 1 */
103 Interrupt2_Handler, /* 2 Interrupt 2 */
104 Interrupt3_Handler, /* 3 Interrupt 3 */
105 Interrupt4_Handler, /* 4 Interrupt 4 */
106 Interrupt5_Handler, /* 5 Interrupt 5 */
107 Interrupt6_Handler, /* 6 Interrupt 6 */
108 Interrupt7_Handler, /* 7 Interrupt 7 */
109 Interrupt8_Handler, /* 8 Interrupt 8 */
110 Interrupt9_Handler /* 9 Interrupt 9 */
111 /* Interrupts 10 .. 480 are left out */
112 };
113
114 #if defined ( __GNUC__ )
115 #pragma GCC diagnostic pop
116 #endif
117
118 /*----------------------------------------------------------------------------
119 Reset Handler called on controller reset
120 *----------------------------------------------------------------------------*/
Reset_Handler(void)121 __NO_RETURN void Reset_Handler(void)
122 {
123 __set_MSPLIM((uint32_t)(&__STACK_LIMIT));
124
125 SystemInit(); /* CMSIS System Initialization */
126 __PROGRAM_START(); /* Enter PreMain (C library entry point) */
127 }
128
129
130 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
131 #pragma clang diagnostic push
132 #pragma clang diagnostic ignored "-Wmissing-noreturn"
133 #endif
134
135 /*----------------------------------------------------------------------------
136 Hard Fault Handler
137 *----------------------------------------------------------------------------*/
HardFault_Handler(void)138 void HardFault_Handler(void)
139 {
140 while(1);
141 }
142
143 /*----------------------------------------------------------------------------
144 Default Handler for Exceptions / Interrupts
145 *----------------------------------------------------------------------------*/
Default_Handler(void)146 void Default_Handler(void)
147 {
148 while(1);
149 }
150
151 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
152 #pragma clang diagnostic pop
153 #endif
154
155