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