1 //*****************************************************************************
\r
3 // startup_ewarm.c - Boot code for Stellaris.
\r
5 // Copyright (c) 2005,2006 Luminary Micro, Inc. All rights reserved.
\r
7 // Software License Agreement
\r
9 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
\r
10 // exclusively on LMI's Stellaris Family of microcontroller products.
\r
12 // The software is owned by LMI and/or its suppliers, and is protected under
\r
13 // applicable copyright laws. All rights are reserved. Any use in violation
\r
14 // of the foregoing restrictions may subject the user to criminal sanctions
\r
15 // under applicable laws, as well as to civil liability for the breach of the
\r
16 // terms and conditions of this license.
\r
18 // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
\r
19 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
\r
20 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
\r
21 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
\r
22 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
\r
24 // This is part of revision 991 of the Stellaris Driver Library.
\r
26 //*****************************************************************************
\r
28 //*****************************************************************************
\r
30 // Enable the IAR extensions for this source file.
\r
32 //*****************************************************************************
\r
33 #pragma language=extended
\r
35 //*****************************************************************************
\r
37 // Forward declaration of the default fault handlers.
\r
39 //*****************************************************************************
\r
40 void ResetISR(void);
\r
41 static void NmiSR(void);
\r
42 static void FaultISR(void);
\r
43 static void IntDefaultHandler(void);
\r
45 //*****************************************************************************
\r
47 // The entry point for the application.
\r
49 //*****************************************************************************
\r
50 extern int main(void);
\r
52 //*****************************************************************************
\r
54 // External declaration for the interrupt handler used by the application.
\r
56 //*****************************************************************************
\r
57 extern void xPortPendSVHandler(void);
\r
58 extern void xPortSysTickHandler(void);
\r
59 extern void vGPIO_ISR(void);
\r
60 extern void vUART_ISR(void);
\r
62 //*****************************************************************************
\r
64 // Reserve space for the system stack.
\r
66 //*****************************************************************************
\r
68 #define STACK_SIZE 64
\r
70 static unsigned long pulStack[STACK_SIZE];
\r
72 //*****************************************************************************
\r
74 // A union that describes the entries of the vector table. The union is needed
\r
75 // since the first entry is the stack pointer and the remainder are function
\r
78 //*****************************************************************************
\r
81 void (*pfnHandler)(void);
\r
82 unsigned long ulPtr;
\r
86 //*****************************************************************************
\r
88 // The minimal vector table for a Cortex M3. Note that the proper constructs
\r
89 // must be placed on this to ensure that it ends up at physical address
\r
92 //*****************************************************************************
\r
93 __root const uVectorEntry g_pfnVectors[] @ "INTVEC" =
\r
95 { .ulPtr = (unsigned long)pulStack + sizeof(pulStack) },
\r
96 // The initial stack pointer
\r
97 ResetISR, // The reset handler
\r
98 NmiSR, // The NMI handler
\r
99 FaultISR, // The hard fault handler
\r
100 IntDefaultHandler, // The MPU fault handler
\r
101 IntDefaultHandler, // The bus fault handler
\r
102 IntDefaultHandler, // The usage fault handler
\r
107 IntDefaultHandler, // SVCall handler
\r
108 IntDefaultHandler, // Debug monitor handler
\r
110 xPortPendSVHandler, // The PendSV handler
\r
111 xPortSysTickHandler, // The SysTick handler
\r
112 IntDefaultHandler, // GPIO Port A
\r
113 IntDefaultHandler, // GPIO Port B
\r
114 vGPIO_ISR, // GPIO Port C
\r
115 IntDefaultHandler, // GPIO Port D
\r
116 IntDefaultHandler, // GPIO Port E
\r
117 vUART_ISR, // UART0 Rx and Tx
\r
118 IntDefaultHandler, // UART1 Rx and Tx
\r
119 IntDefaultHandler, // SSI Rx and Tx
\r
120 IntDefaultHandler, // I2C Master and Slave
\r
121 IntDefaultHandler, // PWM Fault
\r
122 IntDefaultHandler, // PWM Generator 0
\r
123 IntDefaultHandler, // PWM Generator 1
\r
124 IntDefaultHandler, // PWM Generator 2
\r
125 IntDefaultHandler, // Quadrature Encoder
\r
126 IntDefaultHandler, // ADC Sequence 0
\r
127 IntDefaultHandler, // ADC Sequence 1
\r
128 IntDefaultHandler, // ADC Sequence 2
\r
129 IntDefaultHandler, // ADC Sequence 3
\r
130 IntDefaultHandler, // Watchdog timer
\r
131 IntDefaultHandler, // Timer 0 subtimer A
\r
132 IntDefaultHandler, // Timer 0 subtimer B
\r
133 IntDefaultHandler, // Timer 1 subtimer A
\r
134 IntDefaultHandler, // Timer 1 subtimer B
\r
135 IntDefaultHandler, // Timer 2 subtimer A
\r
136 IntDefaultHandler, // Timer 2 subtimer B
\r
137 IntDefaultHandler, // Analog Comparator 0
\r
138 IntDefaultHandler, // Analog Comparator 1
\r
139 IntDefaultHandler, // Analog Comparator 2
\r
140 IntDefaultHandler, // System Control (PLL, OSC, BO)
\r
141 IntDefaultHandler // FLASH Control
\r
144 //*****************************************************************************
\r
146 // The following are constructs created by the linker, indicating where the
\r
147 // the "data" and "bss" segments reside in memory. The initializers for the
\r
148 // for the "data" segment resides immediately following the "text" segment.
\r
150 //*****************************************************************************
\r
151 #pragma segment="DATA_ID"
\r
152 #pragma segment="DATA_I"
\r
153 #pragma segment="DATA_Z"
\r
155 //*****************************************************************************
\r
157 // This is the code that gets called when the processor first starts execution
\r
158 // following a reset event. Only the absolutely necessary set is performed,
\r
159 // after which the application supplied entry() routine is called. Any fancy
\r
160 // actions (such as making decisions based on the reset cause register, and
\r
161 // resetting the bits in that register) are left solely in the hands of the
\r
164 //*****************************************************************************
\r
168 unsigned long *pulSrc, *pulDest, *pulEnd;
\r
171 // Copy the data segment initializers from flash to SRAM.
\r
173 pulSrc = __segment_begin("DATA_ID");
\r
174 pulDest = __segment_begin("DATA_I");
\r
175 pulEnd = __segment_end("DATA_I");
\r
176 while(pulDest < pulEnd)
\r
178 *pulDest++ = *pulSrc++;
\r
182 // Zero fill the bss segment.
\r
184 pulDest = __segment_begin("DATA_Z");
\r
185 pulEnd = __segment_end("DATA_Z");
\r
186 while(pulDest < pulEnd)
\r
192 // Call the application's entry point.
\r
197 //*****************************************************************************
\r
199 // This is the code that gets called when the processor receives a NMI. This
\r
200 // simply enters an infinite loop, preserving the system state for examination
\r
203 //*****************************************************************************
\r
208 // Enter an infinite loop.
\r
215 //*****************************************************************************
\r
217 // This is the code that gets called when the processor receives a fault
\r
218 // interrupt. This simply enters an infinite loop, preserving the system state
\r
219 // for examination by a debugger.
\r
221 //*****************************************************************************
\r
226 // Enter an infinite loop.
\r
233 //*****************************************************************************
\r
235 // This is the code that gets called when the processor receives an unexpected
\r
236 // interrupt. This simply enters an infinite loop, preserving the system state
\r
237 // for examination by a debugger.
\r
239 //*****************************************************************************
\r
241 IntDefaultHandler(void)
\r
244 // Go into an infinite loop.
\r