source: rtos_arduino/trunk/arduino_lib/hardware/tools/CMSIS/Device/ATMEL/samd21/source/as_gcc/startup_samd21.c@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 8.7 KB
Line 
1/**
2 * \file
3 *
4 * \brief gcc starttup file for SAMD21
5 *
6 * Copyright (c) 2014 Atmel Corporation. All rights reserved.
7 *
8 * \asf_license_start
9 *
10 * \page License
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions are met:
14 *
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 *
18 * 2. Redistributions in binary form must reproduce the above copyright notice,
19 * this list of conditions and the following disclaimer in the documentation
20 * and/or other materials provided with the distribution.
21 *
22 * 3. The name of Atmel may not be used to endorse or promote products derived
23 * from this software without specific prior written permission.
24 *
25 * 4. This software may only be redistributed and used in connection with an
26 * Atmel microcontroller product.
27 *
28 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
31 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 *
40 * \asf_license_stop
41 *
42 */
43
44#include "samd21.h"
45
46/* Initialize segments */
47extern uint32_t _sfixed;
48extern uint32_t _efixed;
49extern uint32_t _etext;
50extern uint32_t _srelocate;
51extern uint32_t _erelocate;
52extern uint32_t _szero;
53extern uint32_t _ezero;
54extern uint32_t _sstack;
55extern uint32_t _estack;
56
57/** \cond DOXYGEN_SHOULD_SKIP_THIS */
58int main(void);
59/** \endcond */
60
61void __libc_init_array(void);
62
63/* Default empty handler */
64void Dummy_Handler(void);
65
66/* Cortex-M0+ core handlers */
67void NMI_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
68void HardFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
69void SVC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
70void PendSV_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
71void SysTick_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
72
73/* Peripherals handlers */
74void PM_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
75void SYSCTRL_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
76void WDT_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
77void RTC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
78void EIC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
79void NVMCTRL_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
80void DMAC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
81void USB_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
82void EVSYS_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
83void SERCOM0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
84void SERCOM1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
85void SERCOM2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
86void SERCOM3_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
87void SERCOM4_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
88void SERCOM5_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
89void TCC0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
90void TCC1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
91void TCC2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
92void TC3_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
93void TC4_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
94void TC5_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
95void TC6_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
96void TC7_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
97void ADC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
98void AC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
99void DAC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
100void PTC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
101void I2S_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
102
103/* Exception Table */
104__attribute__ ((section(".vectors")))
105const DeviceVectors exception_table = {
106
107 /* Configure Initial Stack Pointer, using linker-generated symbols */
108 (void*) (&_estack),
109
110 (void*) Reset_Handler,
111 (void*) NMI_Handler,
112 (void*) HardFault_Handler,
113 (void*) (0UL), /* Reserved */
114 (void*) (0UL), /* Reserved */
115 (void*) (0UL), /* Reserved */
116 (void*) (0UL), /* Reserved */
117 (void*) (0UL), /* Reserved */
118 (void*) (0UL), /* Reserved */
119 (void*) (0UL), /* Reserved */
120 (void*) SVC_Handler,
121 (void*) (0UL), /* Reserved */
122 (void*) (0UL), /* Reserved */
123 (void*) PendSV_Handler,
124 (void*) SysTick_Handler,
125
126 /* Configurable interrupts */
127 (void*) PM_Handler, /* 0 Power Manager */
128 (void*) SYSCTRL_Handler, /* 1 System Control */
129 (void*) WDT_Handler, /* 2 Watchdog Timer */
130 (void*) RTC_Handler, /* 3 Real-Time Counter */
131 (void*) EIC_Handler, /* 4 External Interrupt Controller */
132 (void*) NVMCTRL_Handler, /* 5 Non-Volatile Memory Controller */
133 (void*) DMAC_Handler, /* 6 Direct Memory Access Controller */
134 (void*) USB_Handler, /* 7 Universal Serial Bus */
135 (void*) EVSYS_Handler, /* 8 Event System Interface */
136 (void*) SERCOM0_Handler, /* 9 Serial Communication Interface 0 */
137 (void*) SERCOM1_Handler, /* 10 Serial Communication Interface 1 */
138 (void*) SERCOM2_Handler, /* 11 Serial Communication Interface 2 */
139 (void*) SERCOM3_Handler, /* 12 Serial Communication Interface 3 */
140 (void*) SERCOM4_Handler, /* 13 Serial Communication Interface 4 */
141 (void*) SERCOM5_Handler, /* 14 Serial Communication Interface 5 */
142 (void*) TCC0_Handler, /* 15 Timer Counter Control 0 */
143 (void*) TCC1_Handler, /* 16 Timer Counter Control 1 */
144 (void*) TCC2_Handler, /* 17 Timer Counter Control 2 */
145 (void*) TC3_Handler, /* 18 Basic Timer Counter 0 */
146 (void*) TC4_Handler, /* 19 Basic Timer Counter 1 */
147 (void*) TC5_Handler, /* 20 Basic Timer Counter 2 */
148 (void*) TC6_Handler, /* 21 Basic Timer Counter 3 */
149 (void*) TC7_Handler, /* 22 Basic Timer Counter 4 */
150 (void*) ADC_Handler, /* 23 Analog Digital Converter */
151 (void*) AC_Handler, /* 24 Analog Comparators */
152 (void*) DAC_Handler, /* 25 Digital Analog Converter */
153 (void*) PTC_Handler, /* 26 Peripheral Touch Controller */
154 (void*) I2S_Handler /* 27 Inter-IC Sound Interface */
155};
156
157/**
158 * \brief This is the code that gets called on processor reset.
159 * To initialize the device, and call the main() routine.
160 */
161void Reset_Handler(void)
162{
163 uint32_t *pSrc, *pDest;
164
165 /* Initialize the relocate segment */
166 pSrc = &_etext;
167 pDest = &_srelocate;
168
169 if (pSrc != pDest) {
170 for (; pDest < &_erelocate;) {
171 *pDest++ = *pSrc++;
172 }
173 }
174
175 /* Clear the zero segment */
176 for (pDest = &_szero; pDest < &_ezero;) {
177 *pDest++ = 0;
178 }
179
180 /* Set the vector table base address */
181 pSrc = (uint32_t *) & _sfixed;
182 SCB->VTOR = ((uint32_t) pSrc & SCB_VTOR_TBLOFF_Msk);
183
184 /* Initialize the C library */
185 __libc_init_array();
186
187 /* Branch to main function */
188 main();
189
190 /* Infinite loop */
191 while (1);
192}
193
194/**
195 * \brief Default interrupt handler for unused IRQs.
196 */
197void Dummy_Handler(void)
198{
199 while (1) {
200 }
201}
Note: See TracBrowser for help on using the repository browser.