4 * \brief Startup file for SAM4E.
\r
6 * Copyright (c) 2012 - 2013 Atmel Corporation. All rights reserved.
\r
12 * Redistribution and use in source and binary forms, with or without
\r
13 * modification, are permitted provided that the following conditions are met:
\r
15 * 1. Redistributions of source code must retain the above copyright notice,
\r
16 * this list of conditions and the following disclaimer.
\r
18 * 2. Redistributions in binary form must reproduce the above copyright notice,
\r
19 * this list of conditions and the following disclaimer in the documentation
\r
20 * and/or other materials provided with the distribution.
\r
22 * 3. The name of Atmel may not be used to endorse or promote products derived
\r
23 * from this software without specific prior written permission.
\r
25 * 4. This software may only be redistributed and used in connection with an
\r
26 * Atmel microcontroller product.
\r
28 * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
\r
29 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
30 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
31 * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
\r
32 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
\r
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
\r
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
\r
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
\r
36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
\r
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
\r
38 * POSSIBILITY OF SUCH DAMAGE.
\r
45 #include "exceptions.h"
\r
46 #include "system_sam4e.h"
\r
47 #if __FPU_USED /* CMSIS defined value to indicate usage of FPU */
\r
51 /* Initialize segments */
\r
52 extern uint32_t _sfixed;
\r
53 extern uint32_t _efixed;
\r
54 extern uint32_t _etext;
\r
55 extern uint32_t _srelocate;
\r
56 extern uint32_t _erelocate;
\r
57 extern uint32_t _szero;
\r
58 extern uint32_t _ezero;
\r
59 extern uint32_t _sstack;
\r
60 extern uint32_t _estack;
\r
62 /** \cond DOXYGEN_SHOULD_SKIP_THIS */
\r
66 void __libc_init_array(void);
\r
68 /* Exception Table */
\r
69 __attribute__ ((section(".vectors")))
\r
70 const DeviceVectors exception_table = {
\r
72 /* Configure Initial Stack Pointer, using linker-generated symbols */
\r
75 (void*) Reset_Handler,
\r
76 (void*) NMI_Handler,
\r
77 (void*) HardFault_Handler,
\r
78 (void*) MemManage_Handler,
\r
79 (void*) BusFault_Handler,
\r
80 (void*) UsageFault_Handler,
\r
81 (void*) (0UL), /* Reserved */
\r
82 (void*) (0UL), /* Reserved */
\r
83 (void*) (0UL), /* Reserved */
\r
84 (void*) (0UL), /* Reserved */
\r
85 (void*) SVC_Handler,
\r
86 (void*) DebugMon_Handler,
\r
87 (void*) (0UL), /* Reserved */
\r
88 (void*) PendSV_Handler,
\r
89 (void*) SysTick_Handler,
\r
91 /* Configurable interrupts */
\r
92 (void*) SUPC_Handler, /* 0 Supply Controller */
\r
93 (void*) RSTC_Handler, /* 1 Reset Controller */
\r
94 (void*) RTC_Handler, /* 2 Real Time Clock */
\r
95 (void*) RTT_Handler, /* 3 Real Time Timer */
\r
96 (void*) WDT_Handler, /* 4 Watchdog/Dual Watchdog Timer */
\r
97 (void*) PMC_Handler, /* 5 Power Management Controller */
\r
98 (void*) EFC_Handler, /* 6 Enhanced Embedded Flash Controller */
\r
99 (void*) UART0_Handler, /* 7 UART 0 */
\r
100 (void*) Dummy_Handler,
\r
101 (void*) PIOA_Handler, /* 9 Parallel I/O Controller A */
\r
102 (void*) PIOB_Handler, /* 10 Parallel I/O Controller B */
\r
103 (void*) PIOC_Handler, /* 11 Parallel I/O Controller C */
\r
104 #ifdef _SAM4E_PIOD_INSTANCE_
\r
105 (void*) PIOD_Handler, /* 12 Parallel I/O Controller D */
\r
107 (void*) Dummy_Handler,
\r
109 #ifdef _SAM4E_PIOE_INSTANCE_
\r
110 (void*) PIOE_Handler, /* 13 Parallel I/O Controller E */
\r
112 (void*) Dummy_Handler,
\r
114 (void*) USART0_Handler, /* 14 USART 0 */
\r
115 (void*) USART1_Handler, /* 15 USART 1 */
\r
116 (void*) HSMCI_Handler, /* 16 Multimedia Card Interface */
\r
117 (void*) TWI0_Handler, /* 17 Two Wire Interface 0 */
\r
118 (void*) TWI1_Handler, /* 18 Two Wire Interface 1 */
\r
119 (void*) SPI_Handler, /* 19 Serial Peripheral Interface */
\r
120 (void*) DMAC_Handler, /* 20 DMAC */
\r
121 (void*) TC0_Handler, /* 21 Timer/Counter 0 */
\r
122 (void*) TC1_Handler, /* 22 Timer/Counter 1 */
\r
123 (void*) TC2_Handler, /* 23 Timer/Counter 2 */
\r
124 (void*) TC3_Handler, /* 24 Timer/Counter 3 */
\r
125 (void*) TC4_Handler, /* 25 Timer/Counter 4 */
\r
126 (void*) TC5_Handler, /* 26 Timer/Counter 5 */
\r
127 (void*) TC6_Handler, /* 27 Timer/Counter 6 */
\r
128 (void*) TC7_Handler, /* 28 Timer/Counter 7 */
\r
129 (void*) TC8_Handler, /* 29 Timer/Counter 8 */
\r
130 (void*) AFEC0_Handler, /* 30 Analog Front End 0 */
\r
131 (void*) AFEC1_Handler, /* 31 Analog Front End 1 */
\r
132 (void*) DACC_Handler, /* 32 Digital To Analog Converter */
\r
133 (void*) ACC_Handler, /* 33 Analog Comparator */
\r
134 (void*) ARM_Handler, /* 34 FPU signals : FPIXC, FPOFC, FPUFC, FPIOC, FPDZC, FPIDC, FPIXC */
\r
135 (void*) UDP_Handler, /* 35 USB DEVICE */
\r
136 (void*) PWM_Handler, /* 36 PWM */
\r
137 (void*) CAN0_Handler, /* 37 CAN0 */
\r
138 (void*) CAN1_Handler, /* 38 CAN1 */
\r
139 (void*) AES_Handler, /* 39 AES */
\r
140 (void*) Dummy_Handler,
\r
141 (void*) Dummy_Handler,
\r
142 (void*) Dummy_Handler,
\r
143 (void*) Dummy_Handler,
\r
144 #ifdef _SAM4E_GMAC_INSTANCE_
\r
145 (void*) GMAC_Handler, /* 44 EMAC */
\r
147 (void*) Dummy_Handler,
\r
149 (void*) UART1_Handler /* 45 UART */
\r
153 * \brief This is the code that gets called on processor reset.
\r
154 * To initialize the device, and call the main() routine.
\r
156 void Reset_Handler(void)
\r
158 uint32_t *pSrc, *pDest;
\r
160 /* Initialize the relocate segment */
\r
162 pDest = &_srelocate;
\r
164 if (pSrc != pDest) {
\r
165 for (; pDest < &_erelocate;) {
\r
166 *pDest++ = *pSrc++;
\r
170 /* Clear the zero segment */
\r
171 for (pDest = &_szero; pDest < &_ezero;) {
\r
175 /* Set the vector table base address */
\r
176 pSrc = (uint32_t *) & _sfixed;
\r
177 SCB->VTOR = ((uint32_t) pSrc & SCB_VTOR_TBLOFF_Msk);
\r
183 /* Initialize the C library */
\r
184 __libc_init_array();
\r
186 /* Branch to main function */
\r
189 /* Infinite loop */
\r