1 //*****************************************************************************
\r
3 // startup.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 //*****************************************************************************
\r
26 //*****************************************************************************
\r
28 // Forward declaration of the default fault handlers.
\r
30 //*****************************************************************************
\r
31 void ResetISR(void);
\r
32 static void NmiSR(void);
\r
33 void FaultISR(void);
\r
34 extern void xPortPendSVHandler(void);
\r
35 extern void xPortSysTickHandler(void);
\r
36 extern void vUART_ISR( void );
\r
38 //*****************************************************************************
\r
40 // The entry point for the application.
\r
42 //*****************************************************************************
\r
43 extern void entry(void);
\r
45 //*****************************************************************************
\r
47 // Reserve space for the system stack.
\r
49 //*****************************************************************************
\r
51 #define STACK_SIZE 51
\r
53 static unsigned long pulMainStack[STACK_SIZE];
\r
55 //*****************************************************************************
\r
57 // The minimal vector table for a Cortex M3. Note that the proper constructs
\r
58 // must be placed on this to ensure that it ends up at physical address
\r
61 //*****************************************************************************
\r
62 __attribute__ ((section("vectors")))
\r
63 void (* const g_pfnVectors[])(void) =
\r
65 (void (*)(void))((unsigned long)pulMainStack + sizeof(pulMainStack)),
\r
69 0, // The MPU fault handler
\r
70 0, // The bus fault handler
\r
71 0, // The usage fault handler
\r
76 0, // SVCall handler
\r
77 0, // Debug monitor handler
\r
79 xPortPendSVHandler, // The PendSV handler
\r
80 xPortSysTickHandler, // The SysTick handler
\r
86 vUART_ISR // UART0 Rx and Tx
\r
89 //*****************************************************************************
\r
91 // The following are constructs created by the linker, indicating where the
\r
92 // the "data" and "bss" segments reside in memory. The initializers for the
\r
93 // for the "data" segment resides immediately following the "text" segment.
\r
95 //*****************************************************************************
\r
96 extern unsigned long _etext;
\r
97 extern unsigned long _data;
\r
98 extern unsigned long _edata;
\r
99 extern unsigned long _bss;
\r
100 extern unsigned long _ebss;
\r
102 //*****************************************************************************
\r
104 // This is the code that gets called when the processor first starts execution
\r
105 // following a reset event. Only the absolutely necessary set is performed,
\r
106 // after which the application supplied entry() routine is called. Any fancy
\r
107 // actions (such as making decisions based on the reset cause register, and
\r
108 // resetting the bits in that register) are left solely in the hands of the
\r
111 //*****************************************************************************
\r
115 unsigned long *pulSrc, *pulDest;
\r
118 // Copy the data segment initializers from flash to SRAM.
\r
121 for(pulDest = &_data; pulDest < &_edata; )
\r
123 *pulDest++ = *pulSrc++;
\r
127 // Zero fill the bss segment.
\r
129 for(pulDest = &_bss; pulDest < &_ebss; )
\r
135 // Call the application's entry point.
\r
140 //*****************************************************************************
\r
142 // This is the code that gets called when the processor receives a NMI. This
\r
143 // simply enters an infinite loop, preserving the system state for examination
\r
146 //*****************************************************************************
\r
151 // Enter an infinite loop.
\r
158 //*****************************************************************************
\r
160 // This is the code that gets called when the processor receives a fault
\r
161 // interrupt. This simply enters an infinite loop, preserving the system state
\r
162 // for examination by a debugger.
\r
164 //*****************************************************************************
\r
169 // Enter an infinite loop.
\r