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