1 /**
2 * \file
3 *
4 * Copyright (c) 2015 Atmel Corporation. All rights reserved.
5 *
6 * \asf_license_start
7 *
8 * \page License
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright notice,
17 * this list of conditions and the following disclaimer in the documentation
18 * and/or other materials provided with the distribution.
19 *
20 * 3. The name of Atmel may not be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * 4. This software may only be redistributed and used in connection with an
24 * Atmel microcontroller product.
25 *
26 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
27 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
29 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
30 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
34 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 *
38 * \asf_license_stop
39 *
40 */
41 /*
42 * Support and FAQ: visit <a href="http://www.atmel.com/design-support/">Atmel Support</a>
43 */
44
45 #include "samv71.h"
46
47 /* Initialize segments */
48 extern uint32_t _sfixed;
49 extern uint32_t _efixed;
50 extern uint32_t _etext;
51 extern uint32_t _srelocate;
52 extern uint32_t _erelocate;
53 extern uint32_t _szero;
54 extern uint32_t _ezero;
55 extern uint32_t _sstack;
56 extern uint32_t _estack;
57
58 /** \cond DOXYGEN_SHOULD_SKIP_THIS */
59 int main(void);
60 /** \endcond */
61
62 void __libc_init_array(void);
63
64 /* Default empty handler */
65 void Dummy_Handler(void);
66
67 /* Cortex-M7 core handlers */
68 void NMI_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
69 void HardFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
70 void MemManage_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
71 void BusFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
72 void UsageFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
73 void SVC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
74 void DebugMon_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
75 void PendSV_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
76 void SysTick_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
77
78 /* Peripherals handlers */
79 void SUPC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
80 void RSTC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
81 void RTC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
82 void RTT_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
83 void WDT_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
84 void PMC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
85 void EFC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
86 void UART0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
87 void UART1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
88 void PIOA_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
89 void PIOB_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
90 #ifdef _SAMV71_PIOC_INSTANCE_
91 void PIOC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
92 #endif /* _SAMV71_PIOC_INSTANCE_ */
93 void USART0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
94 void USART1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
95 void USART2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
96 void PIOD_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
97 #ifdef _SAMV71_PIOE_INSTANCE_
98 void PIOE_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
99 #endif /* _SAMV71_PIOE_INSTANCE_ */
100 void HSMCI_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
101 void TWIHS0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
102 void TWIHS1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
103 void SPI0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
104 void SSC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
105 void TC0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
106 void TC1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
107 void TC2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
108 #ifdef _SAMV71_TC1_INSTANCE_
109 void TC3_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
110 #endif /* _SAMV71_TC1_INSTANCE_ */
111 #ifdef _SAMV71_TC1_INSTANCE_
112 void TC4_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
113 #endif /* _SAMV71_TC1_INSTANCE_ */
114 #ifdef _SAMV71_TC1_INSTANCE_
115 void TC5_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
116 #endif /* _SAMV71_TC1_INSTANCE_ */
117 void AFEC0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
118 #ifdef _SAMV71_DACC_INSTANCE_
119 void DACC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
120 #endif /* _SAMV71_DACC_INSTANCE_ */
121 void PWM0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
122 void ICM_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
123 void ACC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
124 void USBHS_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
125 void MCAN0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
126 void MCAN1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
127 void GMAC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
128 void AFEC1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
129 #ifdef _SAMV71_TWIHS2_INSTANCE_
130 void TWIHS2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
131 #endif /* _SAMV71_TWIHS2_INSTANCE_ */
132 void SPI1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
133 void QSPI_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
134 void UART2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
135 void UART3_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
136 void UART4_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
137 #ifdef _SAMV71_TC2_INSTANCE_
138 void TC6_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
139 #endif /* _SAMV71_TC2_INSTANCE_ */
140 #ifdef _SAMV71_TC2_INSTANCE_
141 void TC7_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
142 #endif /* _SAMV71_TC2_INSTANCE_ */
143 #ifdef _SAMV71_TC2_INSTANCE_
144 void TC8_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
145 #endif /* _SAMV71_TC2_INSTANCE_ */
146 void TC9_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
147 void TC10_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
148 void TC11_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
149 void MLB_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
150 void AES_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
151 void TRNG_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
152 void XDMAC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
153 void ISI_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
154 void PWM1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
155 #ifdef _SAMV71_SDRAMC_INSTANCE_
156 void SDRAMC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
157 #endif /* _SAMV71_SDRAMC_INSTANCE_ */
158 void RSWDT_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
159
160 /* Exception Table */
161 __attribute__ ((section(".vectors")))
162 const DeviceVectors exception_table = {
163
164 /* Configure Initial Stack Pointer, using linker-generated symbols */
165 .pvStack = (void*) (&_estack),
166
167 .pfnReset_Handler = (void*) Reset_Handler,
168 .pfnNMI_Handler = (void*) NMI_Handler,
169 .pfnHardFault_Handler = (void*) HardFault_Handler,
170 .pfnMemManage_Handler = (void*) MemManage_Handler,
171 .pfnBusFault_Handler = (void*) BusFault_Handler,
172 .pfnUsageFault_Handler = (void*) UsageFault_Handler,
173 .pfnReserved1_Handler = (void*) (0UL), /* Reserved */
174 .pfnReserved2_Handler = (void*) (0UL), /* Reserved */
175 .pfnReserved3_Handler = (void*) (0UL), /* Reserved */
176 .pfnReserved4_Handler = (void*) (0UL), /* Reserved */
177 .pfnSVC_Handler = (void*) SVC_Handler,
178 .pfnDebugMon_Handler = (void*) DebugMon_Handler,
179 .pfnReserved5_Handler = (void*) (0UL), /* Reserved */
180 .pfnPendSV_Handler = (void*) PendSV_Handler,
181 .pfnSysTick_Handler = (void*) SysTick_Handler,
182
183 /* Configurable interrupts */
184 .pfnSUPC_Handler = (void*) SUPC_Handler, /* 0 Supply Controller */
185 .pfnRSTC_Handler = (void*) RSTC_Handler, /* 1 Reset Controller */
186 .pfnRTC_Handler = (void*) RTC_Handler, /* 2 Real Time Clock */
187 .pfnRTT_Handler = (void*) RTT_Handler, /* 3 Real Time Timer */
188 .pfnWDT_Handler = (void*) WDT_Handler, /* 4 Watchdog Timer */
189 .pfnPMC_Handler = (void*) PMC_Handler, /* 5 Power Management Controller */
190 .pfnEFC_Handler = (void*) EFC_Handler, /* 6 Enhanced Embedded Flash Controller */
191 .pfnUART0_Handler = (void*) UART0_Handler, /* 7 UART 0 */
192 .pfnUART1_Handler = (void*) UART1_Handler, /* 8 UART 1 */
193 .pvReserved9 = (void*) (0UL), /* 9 Reserved */
194 .pfnPIOA_Handler = (void*) PIOA_Handler, /* 10 Parallel I/O Controller A */
195 .pfnPIOB_Handler = (void*) PIOB_Handler, /* 11 Parallel I/O Controller B */
196 #ifdef _SAMV71_PIOC_INSTANCE_
197 .pfnPIOC_Handler = (void*) PIOC_Handler, /* 12 Parallel I/O Controller C */
198 #else
199 .pvReserved12 = (void*) (0UL), /* 12 Reserved */
200 #endif /* _SAMV71_PIOC_INSTANCE_ */
201 .pfnUSART0_Handler = (void*) USART0_Handler, /* 13 USART 0 */
202 .pfnUSART1_Handler = (void*) USART1_Handler, /* 14 USART 1 */
203 .pfnUSART2_Handler = (void*) USART2_Handler, /* 15 USART 2 */
204 .pfnPIOD_Handler = (void*) PIOD_Handler, /* 16 Parallel I/O Controller D */
205 #ifdef _SAMV71_PIOE_INSTANCE_
206 .pfnPIOE_Handler = (void*) PIOE_Handler, /* 17 Parallel I/O Controller E */
207 #else
208 .pvReserved17 = (void*) (0UL), /* 17 Reserved */
209 #endif /* _SAMV71_PIOE_INSTANCE_ */
210 .pfnHSMCI_Handler = (void*) HSMCI_Handler, /* 18 Multimedia Card Interface */
211 .pfnTWIHS0_Handler = (void*) TWIHS0_Handler, /* 19 Two Wire Interface 0 HS */
212 .pfnTWIHS1_Handler = (void*) TWIHS1_Handler, /* 20 Two Wire Interface 1 HS */
213 .pfnSPI0_Handler = (void*) SPI0_Handler, /* 21 Serial Peripheral Interface 0 */
214 .pfnSSC_Handler = (void*) SSC_Handler, /* 22 Synchronous Serial Controller */
215 .pfnTC0_Handler = (void*) TC0_Handler, /* 23 Timer/Counter 0 */
216 .pfnTC1_Handler = (void*) TC1_Handler, /* 24 Timer/Counter 1 */
217 .pfnTC2_Handler = (void*) TC2_Handler, /* 25 Timer/Counter 2 */
218 #ifdef _SAMV71_TC1_INSTANCE_
219 .pfnTC3_Handler = (void*) TC3_Handler, /* 26 Timer/Counter 3 */
220 #else
221 .pvReserved26 = (void*) (0UL), /* 26 Reserved */
222 #endif /* _SAMV71_TC1_INSTANCE_ */
223 #ifdef _SAMV71_TC1_INSTANCE_
224 .pfnTC4_Handler = (void*) TC4_Handler, /* 27 Timer/Counter 4 */
225 #else
226 .pvReserved27 = (void*) (0UL), /* 27 Reserved */
227 #endif /* _SAMV71_TC1_INSTANCE_ */
228 #ifdef _SAMV71_TC1_INSTANCE_
229 .pfnTC5_Handler = (void*) TC5_Handler, /* 28 Timer/Counter 5 */
230 #else
231 .pvReserved28 = (void*) (0UL), /* 28 Reserved */
232 #endif /* _SAMV71_TC1_INSTANCE_ */
233 .pfnAFEC0_Handler = (void*) AFEC0_Handler, /* 29 Analog Front End 0 */
234 #ifdef _SAMV71_DACC_INSTANCE_
235 .pfnDACC_Handler = (void*) DACC_Handler, /* 30 Digital To Analog Converter */
236 #else
237 .pvReserved30 = (void*) (0UL), /* 30 Reserved */
238 #endif /* _SAMV71_DACC_INSTANCE_ */
239 .pfnPWM0_Handler = (void*) PWM0_Handler, /* 31 Pulse Width Modulation 0 */
240 .pfnICM_Handler = (void*) ICM_Handler, /* 32 Integrity Check Monitor */
241 .pfnACC_Handler = (void*) ACC_Handler, /* 33 Analog Comparator */
242 .pfnUSBHS_Handler = (void*) USBHS_Handler, /* 34 USB Host / Device Controller */
243 .pfnMCAN0_Handler = (void*) MCAN0_Handler, /* 35 MCAN Controller 0 */
244 .pvReserved36 = (void*) (0UL), /* 36 Reserved */
245 .pfnMCAN1_Handler = (void*) MCAN1_Handler, /* 37 MCAN Controller 1 */
246 .pvReserved38 = (void*) (0UL), /* 38 Reserved */
247 .pfnGMAC_Handler = (void*) GMAC_Handler, /* 39 Ethernet MAC */
248 .pfnAFEC1_Handler = (void*) AFEC1_Handler, /* 40 Analog Front End 1 */
249 #ifdef _SAMV71_TWIHS2_INSTANCE_
250 .pfnTWIHS2_Handler = (void*) TWIHS2_Handler, /* 41 Two Wire Interface 2 HS */
251 #else
252 .pvReserved41 = (void*) (0UL), /* 41 Reserved */
253 #endif /* _SAMV71_TWIHS2_INSTANCE_ */
254 .pfnSPI1_Handler = (void*) SPI1_Handler, /* 42 Serial Peripheral Interface 1 */
255 .pfnQSPI_Handler = (void*) QSPI_Handler, /* 43 Quad I/O Serial Peripheral Interface */
256 .pfnUART2_Handler = (void*) UART2_Handler, /* 44 UART 2 */
257 .pfnUART3_Handler = (void*) UART3_Handler, /* 45 UART 3 */
258 .pfnUART4_Handler = (void*) UART4_Handler, /* 46 UART 4 */
259 #ifdef _SAMV71_TC2_INSTANCE_
260 .pfnTC6_Handler = (void*) TC6_Handler, /* 47 Timer/Counter 6 */
261 #else
262 .pvReserved47 = (void*) (0UL), /* 47 Reserved */
263 #endif /* _SAMV71_TC2_INSTANCE_ */
264 #ifdef _SAMV71_TC2_INSTANCE_
265 .pfnTC7_Handler = (void*) TC7_Handler, /* 48 Timer/Counter 7 */
266 #else
267 .pvReserved48 = (void*) (0UL), /* 48 Reserved */
268 #endif /* _SAMV71_TC2_INSTANCE_ */
269 #ifdef _SAMV71_TC2_INSTANCE_
270 .pfnTC8_Handler = (void*) TC8_Handler, /* 49 Timer/Counter 8 */
271 #else
272 .pvReserved49 = (void*) (0UL), /* 49 Reserved */
273 #endif /* _SAMV71_TC2_INSTANCE_ */
274 .pfnTC9_Handler = (void*) TC9_Handler, /* 50 Timer/Counter 9 */
275 .pfnTC10_Handler = (void*) TC10_Handler, /* 51 Timer/Counter 10 */
276 .pfnTC11_Handler = (void*) TC11_Handler, /* 52 Timer/Counter 11 */
277 .pfnMLB_Handler = (void*) MLB_Handler, /* 53 MediaLB */
278 .pvReserved54 = (void*) (0UL), /* 54 Reserved */
279 .pvReserved55 = (void*) (0UL), /* 55 Reserved */
280 .pfnAES_Handler = (void*) AES_Handler, /* 56 AES */
281 .pfnTRNG_Handler = (void*) TRNG_Handler, /* 57 True Random Generator */
282 .pfnXDMAC_Handler = (void*) XDMAC_Handler, /* 58 DMA */
283 .pfnISI_Handler = (void*) ISI_Handler, /* 59 Camera Interface */
284 .pfnPWM1_Handler = (void*) PWM1_Handler, /* 60 Pulse Width Modulation 1 */
285 .pvReserved61 = (void*) (0UL), /* 61 Reserved */
286 #ifdef _SAMV71_SDRAMC_INSTANCE_
287 .pfnSDRAMC_Handler = (void*) SDRAMC_Handler, /* 62 SDRAM Controller */
288 #else
289 .pvReserved62 = (void*) (0UL), /* 62 Reserved */
290 #endif /* _SAMV71_SDRAMC_INSTANCE_ */
291 .pfnRSWDT_Handler = (void*) RSWDT_Handler /* 63 Reinforced Secure Watchdog Timer */
292 };
293
294 /**
295 * \brief This is the code that gets called on processor reset.
296 * To initialize the device, and call the main() routine.
297 */
Reset_Handler(void)298 void Reset_Handler(void)
299 {
300 uint32_t *pSrc, *pDest;
301
302 /* Initialize the relocate segment */
303 pSrc = &_etext;
304 pDest = &_srelocate;
305
306 if (pSrc != pDest) {
307 for (; pDest < &_erelocate;) {
308 *pDest++ = *pSrc++;
309 }
310 }
311
312 /* Clear the zero segment */
313 for (pDest = &_szero; pDest < &_ezero;) {
314 *pDest++ = 0;
315 }
316
317 /* Set the vector table base address */
318 pSrc = (uint32_t *) & _sfixed;
319 SCB->VTOR = ((uint32_t) pSrc & SCB_VTOR_TBLOFF_Msk);
320
321 /* Initialize the C library */
322 __libc_init_array();
323
324 /* Branch to main function */
325 main();
326
327 /* Infinite loop */
328 while (1);
329 }
330
331 /**
332 * \brief Default interrupt handler for unused IRQs.
333 */
Dummy_Handler(void)334 void Dummy_Handler(void)
335 {
336 while (1) {
337 }
338 }