1 /******************************************************************************
2  * @file     startup_ARMCM7.c
3  * @brief    CMSIS-Core(M) Device Startup File for a Cortex-M7 Device
4  * @version  V2.0.2
5  * @date     15. November 2019
6  ******************************************************************************/
7 /*
8  * Copyright (c) 2009-2019 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 (ARMCM7)
26   #include "ARMCM7.h"
27 #elif defined (ARMCM7_SP)
28   #include "ARMCM7_SP.h"
29 #elif defined (ARMCM7_DP)
30   #include "ARMCM7_DP.h"
31 #else
32   #error device not specified!
33 #endif
34 
35 /*----------------------------------------------------------------------------
36   External References
37  *----------------------------------------------------------------------------*/
38 extern uint32_t __INITIAL_SP;
39 
40 extern __NO_RETURN void __PROGRAM_START(void);
41 
42 /*----------------------------------------------------------------------------
43   Internal References
44  *----------------------------------------------------------------------------*/
45 void __NO_RETURN Default_Handler(void);
46 void __NO_RETURN Reset_Handler  (void);
47 
48 /*----------------------------------------------------------------------------
49   Exception / Interrupt Handler
50  *----------------------------------------------------------------------------*/
51 /* Exceptions */
52 void NMI_Handler            (void) __attribute__ ((weak, alias("Default_Handler")));
53 void HardFault_Handler      (void) __attribute__ ((weak));
54 void MemManage_Handler      (void) __attribute__ ((weak, alias("Default_Handler")));
55 void BusFault_Handler       (void) __attribute__ ((weak, alias("Default_Handler")));
56 void UsageFault_Handler     (void) __attribute__ ((weak, alias("Default_Handler")));
57 void SVC_Handler            (void) __attribute__ ((weak, alias("Default_Handler")));
58 void DebugMon_Handler       (void) __attribute__ ((weak, alias("Default_Handler")));
59 void PendSV_Handler         (void) __attribute__ ((weak, alias("Default_Handler")));
60 void SysTick_Handler        (void) __attribute__ ((weak, alias("Default_Handler")));
61 
62 void Interrupt0_Handler     (void) __attribute__ ((weak, alias("Default_Handler")));
63 void Interrupt1_Handler     (void) __attribute__ ((weak, alias("Default_Handler")));
64 void Interrupt2_Handler     (void) __attribute__ ((weak, alias("Default_Handler")));
65 void Interrupt3_Handler     (void) __attribute__ ((weak, alias("Default_Handler")));
66 void Interrupt4_Handler     (void) __attribute__ ((weak, alias("Default_Handler")));
67 void Interrupt5_Handler     (void) __attribute__ ((weak, alias("Default_Handler")));
68 void Interrupt6_Handler     (void) __attribute__ ((weak, alias("Default_Handler")));
69 void Interrupt7_Handler     (void) __attribute__ ((weak, alias("Default_Handler")));
70 void Interrupt8_Handler     (void) __attribute__ ((weak, alias("Default_Handler")));
71 void Interrupt9_Handler     (void) __attribute__ ((weak, alias("Default_Handler")));
72 
73 
74 /*----------------------------------------------------------------------------
75   Exception / Interrupt Vector table
76  *----------------------------------------------------------------------------*/
77 
78 #if defined ( __GNUC__ )
79 #pragma GCC diagnostic push
80 #pragma GCC diagnostic ignored "-Wpedantic"
81 #endif
82 
83 extern const VECTOR_TABLE_Type __VECTOR_TABLE[240];
84        const VECTOR_TABLE_Type __VECTOR_TABLE[240] __VECTOR_TABLE_ATTRIBUTE = {
85   (VECTOR_TABLE_Type)(&__INITIAL_SP),       /*     Initial Stack Pointer */
86   Reset_Handler,                            /*     Reset Handler */
87   NMI_Handler,                              /* -14 NMI Handler */
88   HardFault_Handler,                        /* -13 Hard Fault Handler */
89   MemManage_Handler,                        /* -12 MPU Fault Handler */
90   BusFault_Handler,                         /* -11 Bus Fault Handler */
91   UsageFault_Handler,                       /* -10 Usage Fault Handler */
92   0,                                        /*     Reserved */
93   0,                                        /*     Reserved */
94   0,                                        /*     Reserved */
95   0,                                        /*     Reserved */
96   SVC_Handler,                              /*  -5 SVCall Handler */
97   DebugMon_Handler,                         /*  -4 Debug Monitor Handler */
98   0,                                        /*     Reserved */
99   PendSV_Handler,                           /*  -2 PendSV Handler */
100   SysTick_Handler,                          /*  -1 SysTick Handler */
101 
102   /* Interrupts */
103   Interrupt0_Handler,                       /*   0 Interrupt 0 */
104   Interrupt1_Handler,                       /*   1 Interrupt 1 */
105   Interrupt2_Handler,                       /*   2 Interrupt 2 */
106   Interrupt3_Handler,                       /*   3 Interrupt 3 */
107   Interrupt4_Handler,                       /*   4 Interrupt 4 */
108   Interrupt5_Handler,                       /*   5 Interrupt 5 */
109   Interrupt6_Handler,                       /*   6 Interrupt 6 */
110   Interrupt7_Handler,                       /*   7 Interrupt 7 */
111   Interrupt8_Handler,                       /*   8 Interrupt 8 */
112   Interrupt9_Handler                        /*   9 Interrupt 9 */
113                                             /* Interrupts 10 .. 223 are left out */
114 };
115 
116 #if defined ( __GNUC__ )
117 #pragma GCC diagnostic pop
118 #endif
119 
120 /*----------------------------------------------------------------------------
121   Reset Handler called on controller reset
122  *----------------------------------------------------------------------------*/
Reset_Handler(void)123 void Reset_Handler(void)
124 {
125   SystemInit();                             /* CMSIS System Initialization */
126   __PROGRAM_START();                        /* Enter PreMain (C library entry point) */
127 }
128 
129 /*----------------------------------------------------------------------------
130   Hard Fault Handler
131  *----------------------------------------------------------------------------*/
HardFault_Handler(void)132 __NO_RETURN void HardFault_Handler(void)
133 {
134   while(1);
135 }
136 
137 /*----------------------------------------------------------------------------
138   Default Handler for Exceptions / Interrupts
139  *----------------------------------------------------------------------------*/
Default_Handler(void)140 void Default_Handler(void)
141 {
142   while(1);
143 }
144