1 |
581 |
jeremybenn |
//*****************************************************************************
|
2 |
|
|
//
|
3 |
|
|
// startup.c - Boot code for Stellaris.
|
4 |
|
|
//
|
5 |
|
|
// Copyright (c) 2005,2006 Luminary Micro, Inc. All rights reserved.
|
6 |
|
|
//
|
7 |
|
|
// Software License Agreement
|
8 |
|
|
//
|
9 |
|
|
// Luminary Micro, Inc. (LMI) is supplying this software for use solely and
|
10 |
|
|
// exclusively on LMI's Stellaris Family of microcontroller products.
|
11 |
|
|
//
|
12 |
|
|
// The software is owned by LMI and/or its suppliers, and is protected under
|
13 |
|
|
// applicable copyright laws. All rights are reserved. Any use in violation
|
14 |
|
|
// of the foregoing restrictions may subject the user to criminal sanctions
|
15 |
|
|
// under applicable laws, as well as to civil liability for the breach of the
|
16 |
|
|
// terms and conditions of this license.
|
17 |
|
|
//
|
18 |
|
|
// THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
19 |
|
|
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
20 |
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
21 |
|
|
// LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
|
22 |
|
|
// CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
23 |
|
|
//
|
24 |
|
|
// This is part of revision 635 of the Stellaris Driver Library.
|
25 |
|
|
//
|
26 |
|
|
//*****************************************************************************
|
27 |
|
|
|
28 |
|
|
//*****************************************************************************
|
29 |
|
|
//
|
30 |
|
|
// Enable the IAR extensions for this source file.
|
31 |
|
|
//
|
32 |
|
|
//*****************************************************************************
|
33 |
|
|
#pragma language=extended
|
34 |
|
|
|
35 |
|
|
//*****************************************************************************
|
36 |
|
|
//
|
37 |
|
|
// Forward declaration of the default fault handlers.
|
38 |
|
|
//
|
39 |
|
|
//*****************************************************************************
|
40 |
|
|
static void NmiSR(void);
|
41 |
|
|
static void FaultISR(void);
|
42 |
|
|
static void IntDefaultHandler(void);
|
43 |
|
|
|
44 |
|
|
//*****************************************************************************
|
45 |
|
|
//
|
46 |
|
|
// External declaration for the interrupt handler used by the application.
|
47 |
|
|
//
|
48 |
|
|
//*****************************************************************************
|
49 |
|
|
extern void xPortPendSVHandler(void);
|
50 |
|
|
extern void xPortSysTickHandler(void);
|
51 |
|
|
extern void vUART_ISR( void );
|
52 |
|
|
extern void vPortSVCHandler( void );
|
53 |
|
|
|
54 |
|
|
//*****************************************************************************
|
55 |
|
|
//
|
56 |
|
|
// The entry point for the application.
|
57 |
|
|
//
|
58 |
|
|
//*****************************************************************************
|
59 |
|
|
extern void __iar_program_start(void);
|
60 |
|
|
|
61 |
|
|
//*****************************************************************************
|
62 |
|
|
//
|
63 |
|
|
// Reserve space for the system stack.
|
64 |
|
|
//
|
65 |
|
|
//*****************************************************************************
|
66 |
|
|
#ifndef STACK_SIZE
|
67 |
|
|
#define STACK_SIZE 50
|
68 |
|
|
#endif
|
69 |
|
|
static unsigned long pulStack[STACK_SIZE] @ ".noinit";
|
70 |
|
|
//*****************************************************************************
|
71 |
|
|
//
|
72 |
|
|
// A union that describes the entries of the vector table. The union is needed
|
73 |
|
|
// since the first entry is the stack pointer and the remainder are function
|
74 |
|
|
// pointers.
|
75 |
|
|
//
|
76 |
|
|
//*****************************************************************************
|
77 |
|
|
typedef union
|
78 |
|
|
{
|
79 |
|
|
void (*pfnHandler)(void);
|
80 |
|
|
unsigned long ulPtr;
|
81 |
|
|
}
|
82 |
|
|
uVectorEntry;
|
83 |
|
|
|
84 |
|
|
//*****************************************************************************
|
85 |
|
|
//
|
86 |
|
|
// The minimal vector table for a Cortex M3. Note that the proper constructs
|
87 |
|
|
// must be placed on this to ensure that it ends up at physical address
|
88 |
|
|
// 0x0000.0000.
|
89 |
|
|
//
|
90 |
|
|
//*****************************************************************************
|
91 |
|
|
__root const uVectorEntry __vector_table[] @ ".intvec" =
|
92 |
|
|
{
|
93 |
|
|
{ .ulPtr = (unsigned long)pulStack + sizeof(pulStack) },
|
94 |
|
|
// The initial stack pointer
|
95 |
|
|
__iar_program_start, // The reset handler
|
96 |
|
|
NmiSR, // The NMI handler
|
97 |
|
|
FaultISR, // The hard fault handler
|
98 |
|
|
IntDefaultHandler, // The MPU fault handler
|
99 |
|
|
IntDefaultHandler, // The bus fault handler
|
100 |
|
|
IntDefaultHandler, // The usage fault handler
|
101 |
|
|
0, // Reserved
|
102 |
|
|
0, // Reserved
|
103 |
|
|
0, // Reserved
|
104 |
|
|
0, // Reserved
|
105 |
|
|
vPortSVCHandler, // SVCall handler
|
106 |
|
|
IntDefaultHandler, // Debug monitor handler
|
107 |
|
|
0, // Reserved
|
108 |
|
|
xPortPendSVHandler, // The PendSV handler
|
109 |
|
|
xPortSysTickHandler, // The SysTick handler
|
110 |
|
|
IntDefaultHandler, // GPIO Port A
|
111 |
|
|
IntDefaultHandler, // GPIO Port B
|
112 |
|
|
IntDefaultHandler, // GPIO Port C
|
113 |
|
|
IntDefaultHandler, // GPIO Port D
|
114 |
|
|
IntDefaultHandler, // GPIO Port E
|
115 |
|
|
vUART_ISR, // UART0 Rx and Tx
|
116 |
|
|
IntDefaultHandler, // UART1 Rx and Tx
|
117 |
|
|
IntDefaultHandler, // SSI Rx and Tx
|
118 |
|
|
IntDefaultHandler, // I2C Master and Slave
|
119 |
|
|
IntDefaultHandler, // PWM Fault
|
120 |
|
|
IntDefaultHandler, // PWM Generator 0
|
121 |
|
|
IntDefaultHandler, // PWM Generator 1
|
122 |
|
|
IntDefaultHandler, // PWM Generator 2
|
123 |
|
|
0, // Reserved
|
124 |
|
|
IntDefaultHandler, // ADC Sequence 0
|
125 |
|
|
IntDefaultHandler, // ADC Sequence 1
|
126 |
|
|
IntDefaultHandler, // ADC Sequence 2
|
127 |
|
|
IntDefaultHandler, // ADC Sequence 3
|
128 |
|
|
IntDefaultHandler, // Watchdog timer
|
129 |
|
|
IntDefaultHandler, // Timer 0 subtimer A
|
130 |
|
|
IntDefaultHandler, // Timer 0 subtimer B
|
131 |
|
|
IntDefaultHandler, // Timer 1 subtimer A
|
132 |
|
|
IntDefaultHandler, // Timer 1 subtimer B
|
133 |
|
|
IntDefaultHandler, // Timer 2 subtimer A
|
134 |
|
|
IntDefaultHandler, // Timer 2 subtimer B
|
135 |
|
|
IntDefaultHandler, // Analog Comparator 0
|
136 |
|
|
IntDefaultHandler, // Analog Comparator 1
|
137 |
|
|
IntDefaultHandler, // Analog Comparator 2
|
138 |
|
|
IntDefaultHandler, // System Control (PLL, OSC, BO)
|
139 |
|
|
IntDefaultHandler // FLASH Control
|
140 |
|
|
};
|
141 |
|
|
|
142 |
|
|
|
143 |
|
|
//*****************************************************************************
|
144 |
|
|
//
|
145 |
|
|
// This is the code that gets called when the processor receives a NMI. This
|
146 |
|
|
// simply enters an infinite loop, preserving the system state for examination
|
147 |
|
|
// by a debugger.
|
148 |
|
|
//
|
149 |
|
|
//*****************************************************************************
|
150 |
|
|
static void
|
151 |
|
|
NmiSR(void)
|
152 |
|
|
{
|
153 |
|
|
//
|
154 |
|
|
// Enter an infinite loop.
|
155 |
|
|
//
|
156 |
|
|
while(1)
|
157 |
|
|
{
|
158 |
|
|
}
|
159 |
|
|
}
|
160 |
|
|
|
161 |
|
|
//*****************************************************************************
|
162 |
|
|
//
|
163 |
|
|
// This is the code that gets called when the processor receives a fault
|
164 |
|
|
// interrupt. This simply enters an infinite loop, preserving the system state
|
165 |
|
|
// for examination by a debugger.
|
166 |
|
|
//
|
167 |
|
|
//*****************************************************************************
|
168 |
|
|
static void
|
169 |
|
|
FaultISR(void)
|
170 |
|
|
{
|
171 |
|
|
//
|
172 |
|
|
// Enter an infinite loop.
|
173 |
|
|
//
|
174 |
|
|
while(1)
|
175 |
|
|
{
|
176 |
|
|
}
|
177 |
|
|
}
|
178 |
|
|
|
179 |
|
|
//*****************************************************************************
|
180 |
|
|
//
|
181 |
|
|
// This is the code that gets called when the processor receives an unexpected
|
182 |
|
|
// interrupt. This simply enters an infinite loop, preserving the system state
|
183 |
|
|
// for examination by a debugger.
|
184 |
|
|
//
|
185 |
|
|
//*****************************************************************************
|
186 |
|
|
static void
|
187 |
|
|
IntDefaultHandler(void)
|
188 |
|
|
{
|
189 |
|
|
//
|
190 |
|
|
// Go into an infinite loop.
|
191 |
|
|
//
|
192 |
|
|
while(1)
|
193 |
|
|
{
|
194 |
|
|
}
|
195 |
|
|
}
|