Subversion Repositories Projects

Rev

Rev 11 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11 dhylands 1
//*****************************************************************************
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 852 of the Stellaris Driver Library.
25
//
26
//*****************************************************************************
27
 
28
// modified by Martin Thomas - don't blame Luminary if it does
29
// not work for you.
30
 
31
//*****************************************************************************
32
//
33
// Forward declaration of the default fault handlers.
34
//
35
//*****************************************************************************
36
// mthomas: attribute for stack-aligment (see README_mthomas.txt)
37
#ifdef __GNUC__
38
void ResetISR(void) __attribute__((__interrupt__));
39
static void NmiSR(void) __attribute__((__interrupt__));
40
static void FaultISR(void) __attribute__((__interrupt__));
41
static void IntDefaultHandler(void) __attribute__((__interrupt__));
42
#else
43
void ResetISR(void);
44
static void NmiSR(void);
45
static void FaultISR(void);
46
static void IntDefaultHandler(void);
47
#endif
48
 
49
//*****************************************************************************
50
//
51
// The entry point for the application.
52
//
53
//*****************************************************************************
54
extern int main(void);
55
 
56
//*****************************************************************************
57
//
14 dhylands 58
// External declaration for the interrupt handlers used by the application.
11 dhylands 59
//
60
//*****************************************************************************
61
 
14 dhylands 62
void ADC_isr( void );
63
void Timer0A_isr( void );
64
 
11 dhylands 65
//*****************************************************************************
66
//
67
// Reserve space for the system stack.
68
//
69
//*****************************************************************************
70
#ifndef STACK_SIZE
71
#define STACK_SIZE                              64
72
#endif
73
 
74
// mthomas: added section -> alignment thru linker-script
75
__attribute__ ((section(".stackarea")))
76
static unsigned long pulStack[STACK_SIZE];
77
 
78
//*****************************************************************************
79
//
80
// The minimal vector table for a Cortex M3.  Note that the proper constructs
81
// must be placed on this to ensure that it ends up at physical address
82
// 0x0000.0000.
83
//
84
//*****************************************************************************
85
__attribute__ ((section(".isr_vector")))
86
void (* const g_pfnVectors[])(void) =
87
{
88
    (void (*)(void))((unsigned long)pulStack + sizeof(pulStack)),
89
                                            // The initial stack pointer
90
    ResetISR,                               // The reset handler
91
    NmiSR,                                  // The NMI handler
92
    FaultISR,                               // The hard fault handler
93
    IntDefaultHandler,                      // The MPU fault handler
94
    IntDefaultHandler,                      // The bus fault handler
95
    IntDefaultHandler,                      // The usage fault handler
96
    0,                                      // Reserved
97
    0,                                      // Reserved
98
    0,                                      // Reserved
99
    0,                                      // Reserved
100
    IntDefaultHandler,                      // SVCall handler
101
    IntDefaultHandler,                      // Debug monitor handler
102
    0,                                      // Reserved
103
    IntDefaultHandler,                      // The PendSV handler
104
    IntDefaultHandler,                      // The SysTick handler
105
    IntDefaultHandler,                      // GPIO Port A
106
    IntDefaultHandler,                      // GPIO Port B
107
    IntDefaultHandler,                      // GPIO Port C
108
    IntDefaultHandler,                      // GPIO Port D
109
    IntDefaultHandler,                      // GPIO Port E
110
    IntDefaultHandler,                      // UART0 Rx and Tx
111
    IntDefaultHandler,                      // UART1 Rx and Tx
112
    IntDefaultHandler,                      // SSI Rx and Tx
113
    IntDefaultHandler,                      // I2C Master and Slave
114
    IntDefaultHandler,                      // PWM Fault
115
    IntDefaultHandler,                      // PWM Generator 0
116
    IntDefaultHandler,                      // PWM Generator 1
117
    IntDefaultHandler,                      // PWM Generator 2
118
    IntDefaultHandler,                      // Quadrature Encoder
119
    ADC_isr,                                // ADC Sequence 0
120
    IntDefaultHandler,                      // ADC Sequence 1
121
    IntDefaultHandler,                      // ADC Sequence 2
122
    IntDefaultHandler,                      // ADC Sequence 3
123
    IntDefaultHandler,                      // Watchdog timer
14 dhylands 124
    Timer0A_isr,                            // Timer 0 subtimer A
11 dhylands 125
    IntDefaultHandler,                      // Timer 0 subtimer B
126
    IntDefaultHandler,                      // Timer 1 subtimer A
127
    IntDefaultHandler,                      // Timer 1 subtimer B
128
    IntDefaultHandler,                      // Timer 2 subtimer A
129
    IntDefaultHandler,                      // Timer 2 subtimer B
130
    IntDefaultHandler,                      // Analog Comparator 0
131
    IntDefaultHandler,                      // Analog Comparator 1
132
    IntDefaultHandler,                      // Analog Comparator 2
133
    IntDefaultHandler,                      // System Control (PLL, OSC, BO)
134
    IntDefaultHandler                       // FLASH Control
135
};
136
 
137
//*****************************************************************************
138
//
139
// The following are constructs created by the linker, indicating where the
140
// the "data" and "bss" segments reside in memory.  The initializers for the
141
// for the "data" segment resides immediately following the "text" segment.
142
//
143
//*****************************************************************************
144
extern unsigned long _etext;
145
extern unsigned long _data;
146
extern unsigned long _edata;
147
extern unsigned long _bss;
148
extern unsigned long _ebss;
149
 
150
//*****************************************************************************
151
//
152
// This is the code that gets called when the processor first starts execution
153
// following a reset event.  Only the absolutely necessary set is performed,
154
// after which the application supplied main() routine is called.  Any fancy
155
// actions (such as making decisions based on the reset cause register, and
156
// resetting the bits in that register) are left solely in the hands of the
157
// application.
158
//
159
//*****************************************************************************
160
void
161
ResetISR(void)
162
{
163
    unsigned long *pulSrc, *pulDest;
164
 
165
    //
166
    // Copy the data segment initializers from flash to SRAM.
167
    //
168
    pulSrc = &_etext;
169
    for(pulDest = &_data; pulDest < &_edata; )
170
    {
171
        *pulDest++ = *pulSrc++;
172
    }
173
 
174
    //
175
    // Zero fill the bss segment.
176
    //
177
    for(pulDest = &_bss; pulDest < &_ebss; )
178
    {
179
        *pulDest++ = 0;
180
    }
181
 
182
    //
183
    // Call the application's entry point.
184
    //
185
    main();
186
}
187
 
188
//*****************************************************************************
189
//
190
// This is the code that gets called when the processor receives a NMI.  This
191
// simply enters an infinite loop, preserving the system state for examination
192
// by a debugger.
193
//
194
//*****************************************************************************
195
static void
196
NmiSR(void)
197
{
198
    //
199
    // Enter an infinite loop.
200
    //
201
    while(1)
202
    {
203
    }
204
}
205
 
206
//*****************************************************************************
207
//
208
// This is the code that gets called when the processor receives a fault
209
// interrupt.  This simply enters an infinite loop, preserving the system state
210
// for examination by a debugger.
211
//
212
//*****************************************************************************
213
static void
214
FaultISR(void)
215
{
216
    //
217
    // Enter an infinite loop.
218
    //
219
    while(1)
220
    {
221
    }
222
}
223
 
224
//*****************************************************************************
225
//
226
// This is the code that gets called when the processor receives an unexpected
227
// interrupt.  This simply enters an infinite loop, preserving the system state
228
// for examination by a debugger.
229
//
230
//*****************************************************************************
231
static void
232
IntDefaultHandler(void)
233
{
234
    //
235
    // Go into an infinite loop.
236
    //
237
    while(1)
238
    {
239
    }
240
}