1 //*****************************************************************************
\r
3 // startup.c - Boot code for Stellaris.
\r
5 // Copyright (c) 2005-2007 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 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 1049 of the Stellaris Driver Library.
\r
26 //*****************************************************************************
\r
28 //*****************************************************************************
\r
30 // Forward declaration of the default fault handlers.
\r
32 //*****************************************************************************
\r
33 void ResetISR(void);
\r
34 static void NmiSR(void);
\r
35 static void FaultISR(void);
\r
36 static void IntDefaultHandler(void);
\r
37 extern void xPortPendSVHandler(void);
\r
38 extern void xPortSysTickHandler(void);
\r
39 extern void vUART_ISR( void );
\r
40 extern void vGPIO_ISR( void );
\r
41 extern void vPortSVCHandler( void );
\r
43 //*****************************************************************************
\r
45 // The entry point for the application.
\r
47 //*****************************************************************************
\r
48 extern int main(void);
\r
50 //*****************************************************************************
\r
52 // Reserve space for the system stack.
\r
54 //*****************************************************************************
\r
56 #define STACK_SIZE 64
\r
58 static unsigned long pulStack[STACK_SIZE];
\r
60 //*****************************************************************************
\r
62 // The minimal vector table for a Cortex M3. Note that the proper constructs
\r
63 // must be placed on this to ensure that it ends up at physical address
\r
66 //*****************************************************************************
\r
67 __attribute__ ((section(".isr_vector")))
\r
68 void (* const g_pfnVectors[])(void) =
\r
70 (void (*)(void))((unsigned long)pulStack + sizeof(pulStack)),
\r
71 // The initial stack pointer
\r
72 ResetISR, // The reset handler
\r
73 NmiSR, // The NMI handler
\r
74 FaultISR, // The hard fault handler
\r
75 IntDefaultHandler, // The MPU fault handler
\r
76 IntDefaultHandler, // The bus fault handler
\r
77 IntDefaultHandler, // The usage fault handler
\r
82 vPortSVCHandler, // SVCall handler
\r
83 IntDefaultHandler, // Debug monitor handler
\r
85 xPortPendSVHandler, // The PendSV handler
\r
86 xPortSysTickHandler, // The SysTick handler
\r
87 IntDefaultHandler, // GPIO Port A
\r
88 IntDefaultHandler, // GPIO Port B
\r
89 vGPIO_ISR, // GPIO Port C
\r
90 IntDefaultHandler, // GPIO Port D
\r
91 IntDefaultHandler, // GPIO Port E
\r
92 vUART_ISR, // UART0 Rx and Tx
\r
93 IntDefaultHandler, // UART1 Rx and Tx
\r
94 IntDefaultHandler, // SSI Rx and Tx
\r
95 IntDefaultHandler, // I2C Master and Slave
\r
96 IntDefaultHandler, // PWM Fault
\r
97 IntDefaultHandler, // PWM Generator 0
\r
98 IntDefaultHandler, // PWM Generator 1
\r
99 IntDefaultHandler, // PWM Generator 2
\r
100 IntDefaultHandler, // Quadrature Encoder
\r
101 IntDefaultHandler, // ADC Sequence 0
\r
102 IntDefaultHandler, // ADC Sequence 1
\r
103 IntDefaultHandler, // ADC Sequence 2
\r
104 IntDefaultHandler, // ADC Sequence 3
\r
105 IntDefaultHandler, // Watchdog timer
\r
106 IntDefaultHandler, // Timer 0 subtimer A
\r
107 IntDefaultHandler, // Timer 0 subtimer B
\r
108 IntDefaultHandler, // Timer 1 subtimer A
\r
109 IntDefaultHandler, // Timer 1 subtimer B
\r
110 IntDefaultHandler, // Timer 2 subtimer A
\r
111 IntDefaultHandler, // Timer 2 subtimer B
\r
112 IntDefaultHandler, // Analog Comparator 0
\r
113 IntDefaultHandler, // Analog Comparator 1
\r
114 IntDefaultHandler, // Analog Comparator 2
\r
115 IntDefaultHandler, // System Control (PLL, OSC, BO)
\r
116 IntDefaultHandler // FLASH Control
\r
119 //*****************************************************************************
\r
121 // The following are constructs created by the linker, indicating where the
\r
122 // the "data" and "bss" segments reside in memory. The initializers for the
\r
123 // for the "data" segment resides immediately following the "text" segment.
\r
125 //*****************************************************************************
\r
126 extern unsigned long _etext;
\r
127 extern unsigned long _data;
\r
128 extern unsigned long _edata;
\r
129 extern unsigned long _bss;
\r
130 extern unsigned long _ebss;
\r
132 //*****************************************************************************
\r
134 // This is the code that gets called when the processor first starts execution
\r
135 // following a reset event. Only the absolutely necessary set is performed,
\r
136 // after which the application supplied main() routine is called. Any fancy
\r
137 // actions (such as making decisions based on the reset cause register, and
\r
138 // resetting the bits in that register) are left solely in the hands of the
\r
141 //*****************************************************************************
\r
145 unsigned long *pulSrc, *pulDest;
\r
148 // Copy the data segment initializers from flash to SRAM.
\r
151 for(pulDest = &_data; pulDest < &_edata; )
\r
153 *pulDest++ = *pulSrc++;
\r
157 // Zero fill the bss segment.
\r
159 for(pulDest = &_bss; pulDest < &_ebss; )
\r
165 // Call the application's entry point.
\r
170 //*****************************************************************************
\r
172 // This is the code that gets called when the processor receives a NMI. This
\r
173 // simply enters an infinite loop, preserving the system state for examination
\r
176 //*****************************************************************************
\r
181 // Enter an infinite loop.
\r
188 //*****************************************************************************
\r
190 // This is the code that gets called when the processor receives a fault
\r
191 // interrupt. This simply enters an infinite loop, preserving the system state
\r
192 // for examination by a debugger.
\r
194 //*****************************************************************************
\r
199 // Enter an infinite loop.
\r
206 //*****************************************************************************
\r
208 // This is the code that gets called when the processor receives an unexpected
\r
209 // interrupt. This simply enters an infinite loop, preserving the system state
\r
210 // for examination by a debugger.
\r
212 //*****************************************************************************
\r
214 IntDefaultHandler(void)
\r
217 // Go into an infinite loop.
\r