]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil/system/IAR/msp432_startup_ewarm.c
721a2d5f42489ad4ffe53f59367fc1ee336556c7
[freertos] / FreeRTOS / Demo / CORTEX_M4F_MSP432_LaunchPad_IAR_CCS_Keil / system / IAR / msp432_startup_ewarm.c
1 /*\r
2  * -------------------------------------------\r
3  *    MSP432 DriverLib - v3_10_00_09\r
4  * -------------------------------------------\r
5  *\r
6  * --COPYRIGHT--,BSD,BSD\r
7  * Copyright (c) 2014, Texas Instruments Incorporated\r
8  * All rights reserved.\r
9  *\r
10  * Redistribution and use in source and binary forms, with or without\r
11  * modification, are permitted provided that the following conditions\r
12  * are met:\r
13  *\r
14  * *  Redistributions of source code must retain the above copyright\r
15  *    notice, this list of conditions and the following disclaimer.\r
16  *\r
17  * *  Redistributions in binary form must reproduce the above copyright\r
18  *    notice, this list of conditions and the following disclaimer in the\r
19  *    documentation and/or other materials provided with the distribution.\r
20  *\r
21  * *  Neither the name of Texas Instruments Incorporated nor the names of\r
22  *    its contributors may be used to endorse or promote products derived\r
23  *    from this software without specific prior written permission.\r
24  *\r
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
26  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
27  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
28  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
29  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
30  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
31  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
32  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
33  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
34  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
35  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
36  * --/COPYRIGHT--*/\r
37 //*****************************************************************************\r
38 //\r
39 // Copyright (C) 2012 - 2015 Texas Instruments Incorporated - http://www.ti.com/\r
40 //\r
41 // Redistribution and use in source and binary forms, with or without\r
42 // modification, are permitted provided that the following conditions\r
43 // are met:\r
44 //\r
45 //  Redistributions of source code must retain the above copyright\r
46 //  notice, this list of conditions and the following disclaimer.\r
47 //\r
48 //  Redistributions in binary form must reproduce the above copyright\r
49 //  notice, this list of conditions and the following disclaimer in the\r
50 //  documentation and/or other materials provided with the\r
51 //  distribution.\r
52 //\r
53 //  Neither the name of Texas Instruments Incorporated nor the names of\r
54 //  its contributors may be used to endorse or promote products derived\r
55 //  from this software without specific prior written permission.\r
56 //\r
57 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r
58 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\r
59 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\r
60 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\r
61 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
62 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\r
63 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
64 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
65 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
66 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\r
67 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
68 //\r
69 // MSP432 Startup Code for IAR Embedded Workbench for ARM\r
70 //\r
71 //****************************************************************************\r
72 \r
73 #include <stdint.h>\r
74 \r
75 //*****************************************************************************\r
76 //\r
77 // Enable the IAR extensions for this source file.\r
78 //\r
79 //*****************************************************************************\r
80 #pragma language=extended\r
81 \r
82 //*****************************************************************************\r
83 //\r
84 // Forward declaration of the default fault handlers.\r
85 //\r
86 //*****************************************************************************\r
87 void ResetISR(void);\r
88 static void NmiSR(void);\r
89 static void FaultISR(void);\r
90 static void IntDefaultHandler(void);\r
91 \r
92 //*****************************************************************************\r
93 //\r
94 // External declaration for the interrupt handler used by the application.\r
95 //\r
96 //*****************************************************************************\r
97 extern void SysTick_Handler( void );\r
98 extern void PendSV_Handler( void );\r
99 extern void SVC_Handler( void );\r
100 extern void vUART_Handler( void );\r
101 extern void vT32_0_Handler( void );\r
102 extern void vT32_1_Handler( void );\r
103 //*****************************************************************************\r
104 //\r
105 // The entry point for the application startup code.\r
106 //\r
107 //*****************************************************************************\r
108 extern void __iar_program_start(void);\r
109 \r
110 //*****************************************************************************\r
111 //\r
112 // Reserve space for the system stack.\r
113 //\r
114 //*****************************************************************************\r
115 static uint32_t systemStack[128] @ ".noinit";\r
116 \r
117 //*****************************************************************************\r
118 //\r
119 // A union that describes the entries of the vector table.  The union is needed\r
120 // since the first entry is the stack pointer and the remainder are function\r
121 // pointers.\r
122 //\r
123 //*****************************************************************************\r
124 typedef union\r
125 {\r
126     void (*handler)(void);\r
127     uint32_t ptr;\r
128 }\r
129 uVectorEntry;\r
130 \r
131 //*****************************************************************************\r
132 //\r
133 // The vector table.  Note that the proper constructs must be placed on this to\r
134 // ensure that it ends up at physical address 0x0000.0000.\r
135 //\r
136 //*****************************************************************************\r
137 __root const uVectorEntry __vector_table[] @ ".intvec" =\r
138 {\r
139     { .ptr = (uint32_t)systemStack + sizeof(systemStack) },\r
140                                             // The initial stack pointer\r
141     ResetISR,                               // The reset handler\r
142     NmiSR,                                  // The NMI handler\r
143     FaultISR,                               // The hard fault handler\r
144     IntDefaultHandler,                      // The MPU fault handler\r
145     IntDefaultHandler,                      // The bus fault handler\r
146     IntDefaultHandler,                      // The usage fault handler\r
147     0,                                      // Reserved\r
148     0,                                      // Reserved\r
149     0,                                      // Reserved\r
150     0,                                      // Reserved\r
151     SVC_Handler,                             // SVCall handler\r
152     IntDefaultHandler,                      // Debug monitor handler\r
153     0,                                      // Reserved\r
154     PendSV_Handler,                             // The PendSV handler\r
155     SysTick_Handler,                            // The SysTick handler\r
156     IntDefaultHandler,                      // PSS ISR\r
157     IntDefaultHandler,                      // CS ISR\r
158     IntDefaultHandler,                      // PCM ISR\r
159     IntDefaultHandler,                      // WDT ISR\r
160     IntDefaultHandler,                      // FPU ISR\r
161     IntDefaultHandler,                      // FLCTL ISR\r
162     IntDefaultHandler,                      // COMP_E0_MODULE ISR\r
163     IntDefaultHandler,                      // COMP_E1_MODULE ISR\r
164     IntDefaultHandler,                      // TA0_0 ISR\r
165     IntDefaultHandler,                      // TA0_N ISR\r
166     IntDefaultHandler,                      // TA1_0 ISR\r
167     IntDefaultHandler,                      // TA1_N ISR\r
168     IntDefaultHandler,                      // TA2_0 ISR\r
169     IntDefaultHandler,                      // TA2_N ISR\r
170     IntDefaultHandler,                      // TA3_0 ISR\r
171     IntDefaultHandler,                      // TA3_N ISR\r
172     vUART_Handler,                            // EUSCIA0 ISR\r
173     IntDefaultHandler,                      // EUSCIA1 ISR\r
174     IntDefaultHandler,                      // EUSCIA2 ISR\r
175     IntDefaultHandler,                      // EUSCIA3 ISR\r
176     IntDefaultHandler,                      // EUSCIB0 ISR\r
177     IntDefaultHandler,                      // EUSCIB1 ISR\r
178     IntDefaultHandler,                      // EUSCIB2 ISR\r
179     IntDefaultHandler,                      // EUSCIB3 ISR\r
180     IntDefaultHandler,                      // ADC12 ISR\r
181     vT32_0_Handler,                                // T32_INT1 ISR\r
182     vT32_1_Handler,                                // T32_INT2 ISR\r
183     IntDefaultHandler,                      // T32_INTC ISR\r
184     IntDefaultHandler,                      // AES ISR\r
185     IntDefaultHandler,                      // RTC ISR\r
186     IntDefaultHandler,                      // DMA_ERR ISR\r
187     IntDefaultHandler,                      // DMA_INT3 ISR\r
188     IntDefaultHandler,                      // DMA_INT2 ISR\r
189     IntDefaultHandler,                       // DMA_INT1 ISR\r
190     IntDefaultHandler,                      // DMA_INT0 ISR\r
191     IntDefaultHandler,                      // PORT1 ISR\r
192     IntDefaultHandler,                      // PORT2 ISR\r
193     IntDefaultHandler,                      // PORT3 ISR\r
194     IntDefaultHandler,                      // PORT4 ISR\r
195     IntDefaultHandler,                      // PORT5 ISR\r
196     IntDefaultHandler,                      // PORT6 ISR\r
197     IntDefaultHandler,                      // Reserved 41\r
198     IntDefaultHandler,                      // Reserved 42\r
199     IntDefaultHandler,                      // Reserved 43\r
200     IntDefaultHandler,                      // Reserved 44\r
201     IntDefaultHandler,                      // Reserved 45\r
202     IntDefaultHandler,                      // Reserved 46\r
203     IntDefaultHandler,                      // Reserved 47\r
204     IntDefaultHandler,                      // Reserved 48\r
205     IntDefaultHandler,                      // Reserved 49\r
206     IntDefaultHandler,                      // Reserved 50\r
207     IntDefaultHandler,                      // Reserved 51\r
208     IntDefaultHandler,                      // Reserved 52\r
209     IntDefaultHandler,                      // Reserved 53\r
210     IntDefaultHandler,                      // Reserved 54\r
211     IntDefaultHandler,                      // Reserved 55\r
212     IntDefaultHandler,                      // Reserved 56\r
213     IntDefaultHandler,                      // Reserved 57\r
214     IntDefaultHandler,                      // Reserved 58\r
215     IntDefaultHandler,                      // Reserved 59\r
216     IntDefaultHandler,                      // Reserved 60\r
217     IntDefaultHandler,                      // Reserved 61\r
218     IntDefaultHandler,                      // Reserved 62\r
219     IntDefaultHandler,                      // Reserved 63\r
220     IntDefaultHandler                       // Reserved 64\r
221 };\r
222 \r
223 //*****************************************************************************\r
224 //\r
225 // This is the code that gets called when the processor first starts execution\r
226 // following a reset event.  Only the absolutely necessary set is performed,\r
227 // after which the application supplied entry() routine is called.  Any fancy\r
228 // actions (such as making decisions based on the reset cause register, and\r
229 // resetting the bits in that register) are left solely in the hands of the\r
230 // application.\r
231 //\r
232 //*****************************************************************************\r
233 void\r
234 ResetISR(void)\r
235 {\r
236 void SystemInit(void);\r
237 \r
238         // Initialize the device\r
239         SystemInit();\r
240 \r
241     //\r
242     // Call the application's entry point.\r
243     //\r
244     __iar_program_start();\r
245 }\r
246 \r
247 //*****************************************************************************\r
248 //\r
249 // This is the code that gets called when the processor receives a NMI.  This\r
250 // simply enters an infinite loop, preserving the system state for examination\r
251 // by a debugger.\r
252 //\r
253 //*****************************************************************************\r
254 static void\r
255 NmiSR(void)\r
256 {\r
257     //\r
258     // Enter an infinite loop.\r
259     //\r
260     while(1)\r
261     {\r
262     }\r
263 }\r
264 \r
265 //*****************************************************************************\r
266 //\r
267 // This is the code that gets called when the processor receives a fault\r
268 // interrupt.  This simply enters an infinite loop, preserving the system state\r
269 // for examination by a debugger.\r
270 //\r
271 //*****************************************************************************\r
272 static void\r
273 FaultISR(void)\r
274 {\r
275     //\r
276     // Enter an infinite loop.\r
277     //\r
278     while(1)\r
279     {\r
280     }\r
281 }\r
282 \r
283 //*****************************************************************************\r
284 //\r
285 // This is the code that gets called when the processor receives an unexpected\r
286 // interrupt.  This simply enters an infinite loop, preserving the system state\r
287 // for examination by a debugger.\r
288 //\r
289 //*****************************************************************************\r
290 static void\r
291 IntDefaultHandler(void)\r
292 {\r
293     //\r
294     // Go into an infinite loop.\r
295     //\r
296     while(1)\r
297     {\r
298     }\r
299 }\r