1 /******************************************************************************
2 * Filename: startup_iar.c
3 * Revised: $Date: 2015-05-19 15:09:11 +0200 (ti, 19 mai 2015) $
4 * Revision: $Revision: 15736 $
5 *
6 * Description: Startup code for CC13xx PG2 device family for use with IAR.
7 *
8 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
9 *
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 *
15 * Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 *
18 * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 *
22 * Neither the name of Texas Instruments Incorporated nor the names of
23 * its contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 *
38 ******************************************************************************/
39
40
41 //*****************************************************************************
42 //
43 // Check if compiler is IAR
44 //
45 //*****************************************************************************
46 #if !(defined(__IAR_SYSTEMS_ICC__))
47 #error "startup_iar.c: Unsupported compiler!"
48 #endif
49
50
51 // We need intrinsic functions for IAR (if used in source code)
52 #include <intrinsics.h>
53 #include <inc/hw_types.h>
54
55
56 //*****************************************************************************
57 //
58 //! Forward declaration of the reset ISR and the default fault handlers.
59 //
60 //*****************************************************************************
61 void ResetISR( void );
62 static void NmiSRHandler( void );
63 static void FaultISRHandler( void );
64 static void IntDefaultHandler( void );
65 extern int main( void );
66
67 extern void NmiSR( void );
68 extern void FaultISR( void );
69 extern void MPUFaultIntHandler( void );
70 extern void BusFaultIntHandler( void );
71 extern void UsageFaultIntHandler( void );
72 extern void SVCallIntHandler( void );
73 extern void DebugMonIntHandler( void );
74 extern void PendSVIntHandler( void );
75 extern void SysTickIntHandler( void );
76 extern void GPIOIntHandler( void );
77 extern void I2CIntHandler( void );
78 extern void RFCCPE1IntHandler( void );
79 extern void AONIntHandler( void );
80 extern void AONRTCIntHandler( void );
81 extern void UART0IntHandler( void );
82 extern void AUXSWEvent0IntHandler( void );
83 extern void SSI0IntHandler( void );
84 extern void SSI1IntHandler( void );
85 extern void RFCCPE0IntHandler( void );
86 extern void RFCHardwareIntHandler( void );
87 extern void RFCCmdAckIntHandler( void );
88 extern void I2SIntHandler( void );
89 extern void AUXSWEvent1IntHandler( void );
90 extern void WatchdogIntHandler( void );
91 extern void Timer0AIntHandler( void );
92 extern void Timer0BIntHandler( void );
93 extern void Timer1AIntHandler( void );
94 extern void Timer1BIntHandler( void );
95 extern void Timer2AIntHandler( void );
96 extern void Timer2BIntHandler( void );
97 extern void Timer3AIntHandler( void );
98 extern void Timer3BIntHandler( void );
99 extern void CryptoIntHandler( void );
100 extern void uDMAIntHandler( void );
101 extern void uDMAErrIntHandler( void );
102 extern void FlashIntHandler( void );
103 extern void SWEvent0IntHandler( void );
104 extern void AUXCombEventIntHandler( void );
105 extern void AONProgIntHandler( void );
106 extern void DynProgIntHandler( void );
107 extern void AUXCompAIntHandler( void );
108 extern void AUXADCIntHandler( void );
109 extern void TRNGIntHandler( void );
110
111 // Default interrupt handlers
112 #pragma weak NmiSR = NmiSRHandler
113 #pragma weak FaultISR = FaultISRHandler
114 #pragma weak MPUFaultIntHandler = IntDefaultHandler
115 #pragma weak BusFaultIntHandler = IntDefaultHandler
116 #pragma weak UsageFaultIntHandler = IntDefaultHandler
117 #pragma weak SVCallIntHandler = IntDefaultHandler
118 #pragma weak DebugMonIntHandler = IntDefaultHandler
119 #pragma weak PendSVIntHandler = IntDefaultHandler
120 #pragma weak SysTickIntHandler = IntDefaultHandler
121 #pragma weak GPIOIntHandler = IntDefaultHandler
122 #pragma weak I2CIntHandler = IntDefaultHandler
123 #pragma weak RFCCPE1IntHandler = IntDefaultHandler
124 #pragma weak AONIntHandler = IntDefaultHandler
125 #pragma weak AONRTCIntHandler = IntDefaultHandler
126 #pragma weak UART0IntHandler = IntDefaultHandler
127 #pragma weak AUXSWEvent0IntHandler = IntDefaultHandler
128 #pragma weak SSI0IntHandler = IntDefaultHandler
129 #pragma weak SSI1IntHandler = IntDefaultHandler
130 #pragma weak RFCCPE0IntHandler = IntDefaultHandler
131 #pragma weak RFCHardwareIntHandler = IntDefaultHandler
132 #pragma weak RFCCmdAckIntHandler = IntDefaultHandler
133 #pragma weak I2SIntHandler = IntDefaultHandler
134 #pragma weak AUXSWEvent1IntHandler = IntDefaultHandler
135 #pragma weak WatchdogIntHandler = IntDefaultHandler
136 #pragma weak Timer0AIntHandler = IntDefaultHandler
137 #pragma weak Timer0BIntHandler = IntDefaultHandler
138 #pragma weak Timer1AIntHandler = IntDefaultHandler
139 #pragma weak Timer1BIntHandler = IntDefaultHandler
140 #pragma weak Timer2AIntHandler = IntDefaultHandler
141 #pragma weak Timer2BIntHandler = IntDefaultHandler
142 #pragma weak Timer3AIntHandler = IntDefaultHandler
143 #pragma weak Timer3BIntHandler = IntDefaultHandler
144 #pragma weak CryptoIntHandler = IntDefaultHandler
145 #pragma weak uDMAIntHandler = IntDefaultHandler
146 #pragma weak uDMAErrIntHandler = IntDefaultHandler
147 #pragma weak FlashIntHandler = IntDefaultHandler
148 #pragma weak SWEvent0IntHandler = IntDefaultHandler
149 #pragma weak AUXCombEventIntHandler = IntDefaultHandler
150 #pragma weak AONProgIntHandler = IntDefaultHandler
151 #pragma weak DynProgIntHandler = IntDefaultHandler
152 #pragma weak AUXCompAIntHandler = IntDefaultHandler
153 #pragma weak AUXADCIntHandler = IntDefaultHandler
154 #pragma weak TRNGIntHandler = IntDefaultHandler
155
156 //*****************************************************************************
157 //
158 //! The entry point for the application startup code and device trim fxn.
159 //
160 //*****************************************************************************
161 extern void __iar_program_start(void);
162 extern void trimDevice(void);
163
164 //*****************************************************************************
165 //
166 //! Get stack start (highest address) symbol from linker file.
167 //
168 //*****************************************************************************
169 extern const void* STACK_TOP;
170
171 // It is required to place something in the CSTACK segment to get the stack
172 // check feature in IAR to work as expected
173 __root static void* dummy_stack @ ".stack";
174
175
176 //*****************************************************************************
177 //
178 //! The vector table. Note that the proper constructs must be placed on this to
179 //! ensure that it ends up at physical address 0x0000.0000 or at the start of
180 //! the program if located at a start address other than 0.
181 //
182 //*****************************************************************************
183 __root void (* const __vector_table[])(void) @ ".intvec" =
184 {
185 (void (*)(void))&STACK_TOP, // The initial stack pointer
186 ResetISR, // The reset handler
187 NmiSR, // The NMI handler
188 FaultISR, // The hard fault handler
189 MPUFaultIntHandler, // The MPU fault handler
190 BusFaultIntHandler, // The bus fault handler
191 UsageFaultIntHandler, // The usage fault handler
192 0, // Reserved
193 0, // Reserved
194 0, // Reserved
195 0, // Reserved
196 SVCallIntHandler, // SVCall handler
197 DebugMonIntHandler, // Debug monitor handler
198 0, // Reserved
199 PendSVIntHandler, // The PendSV handler
200 SysTickIntHandler, // The SysTick handler
201 GPIOIntHandler, // AON edge detect
202 I2CIntHandler, // I2C
203 RFCCPE1IntHandler, // RF Core Command & Packet Engine 1
204 AONIntHandler, // AON SpiSplave Rx, Tx and CS
205 AONRTCIntHandler, // AON RTC
206 UART0IntHandler, // UART0 Rx and Tx
207 AUXSWEvent0IntHandler, // AUX software event 0
208 SSI0IntHandler, // SSI0 Rx and Tx
209 SSI1IntHandler, // SSI1 Rx and Tx
210 RFCCPE0IntHandler, // RF Core Command & Packet Engine 0
211 RFCHardwareIntHandler, // RF Core Hardware
212 RFCCmdAckIntHandler, // RF Core Command Acknowledge
213 I2SIntHandler, // I2S
214 AUXSWEvent1IntHandler, // AUX software event 1
215 WatchdogIntHandler, // Watchdog timer
216 Timer0AIntHandler, // Timer 0 subtimer A
217 Timer0BIntHandler, // Timer 0 subtimer B
218 Timer1AIntHandler, // Timer 1 subtimer A
219 Timer1BIntHandler, // Timer 1 subtimer B
220 Timer2AIntHandler, // Timer 2 subtimer A
221 Timer2BIntHandler, // Timer 2 subtimer B
222 Timer3AIntHandler, // Timer 3 subtimer A
223 Timer3BIntHandler, // Timer 3 subtimer B
224 CryptoIntHandler, // Crypto Core Result available
225 uDMAIntHandler, // uDMA Software
226 uDMAErrIntHandler, // uDMA Error
227 FlashIntHandler, // Flash controller
228 SWEvent0IntHandler, // Software Event 0
229 AUXCombEventIntHandler, // AUX combined event
230 AONProgIntHandler, // AON programmable 0
231 DynProgIntHandler, // Dynamic Programmable interrupt
232 // source (Default: PRCM)
233 AUXCompAIntHandler, // AUX Comparator A
234 AUXADCIntHandler, // AUX ADC new sample or ADC DMA
235 // done, ADC underflow, ADC overflow
236 TRNGIntHandler // TRNG event
237 };
238
239
240 //*****************************************************************************
241 //
242 //! This is the code that gets called when the processor first starts execution
243 //! following a reset event. Only the absolutely necessary set is performed,
244 //! after which the application supplied entry() routine is called. Any fancy
245 //! actions (such as making decisions based on the reset cause register, and
246 //! resetting the bits in that register) are left solely in the hands of the
247 //! application.
248 //
249 //*****************************************************************************
250 void
ResetISR(void)251 ResetISR(void)
252 {
253 //
254 // Final trim of device
255 //
256 trimDevice();
257
258 //
259 // Jump to IAR initialization routine
260 //
261 __iar_program_start();
262
263 //
264 // If we ever return signal Error
265 //
266 FaultISR();
267 }
268
269 //*****************************************************************************
270 //
271 //! This is the code that gets called when the processor receives a NMI. This
272 //! simply enters an infinite loop, preserving the system state for examination
273 //! by a debugger.
274 //
275 //*****************************************************************************
276 static void
NmiSRHandler(void)277 NmiSRHandler(void)
278 {
279 //
280 // Enter an infinite loop.
281 //
282 while(1)
283 {
284 }
285 }
286
287 //*****************************************************************************
288 //
289 //! This is the code that gets called when the processor receives a fault
290 //! interrupt. This simply enters an infinite loop, preserving the system state
291 //! for examination by a debugger.
292 //
293 //*****************************************************************************
294 static void
FaultISRHandler(void)295 FaultISRHandler(void)
296 {
297 //
298 // Enter an infinite loop.
299 //
300 while(1)
301 {
302 }
303 }
304
305 //*****************************************************************************
306 //
307 //! This is the code that gets called when the processor receives an unexpected
308 //! interrupt. This simply enters an infinite loop, preserving the system state
309 //! for examination by a debugger.
310 //
311 //*****************************************************************************
312 static void
IntDefaultHandler(void)313 IntDefaultHandler(void)
314 {
315 //
316 // Go into an infinite loop.
317 //
318 while(1)
319 {
320 }
321 }
322