/boards/ek-lm3s8962/qs_ek-lm3s8962/startup_gcc.c

https://github.com/hrshygoodness/Luminary-Micro-Library · C · 238 lines · 119 code · 13 blank · 106 comment · 4 complexity · 667ea9dd46b887605451574954b7eb5f MD5 · raw file

  1. //*****************************************************************************
  2. //
  3. // startup_gcc.c - Startup code for use with GNU tools.
  4. //
  5. // Copyright (c) 2007-2013 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of revision 10636 of the EK-LM3S8962 Firmware Package.
  22. //
  23. //*****************************************************************************
  24. //*****************************************************************************
  25. //
  26. // Forward declaration of the default fault handlers.
  27. //
  28. //*****************************************************************************
  29. void ResetISR(void);
  30. static void NmiSR(void);
  31. static void FaultISR(void);
  32. static void IntDefaultHandler(void);
  33. //*****************************************************************************
  34. //
  35. // External declarations for the interrupt handlers used by the application.
  36. //
  37. //*****************************************************************************
  38. extern void CANHandler(void);
  39. extern void lwIPEthernetIntHandler(void);
  40. extern void SysTickIntHandler(void);
  41. //*****************************************************************************
  42. //
  43. // The entry point for the application.
  44. //
  45. //*****************************************************************************
  46. extern int main(void);
  47. //*****************************************************************************
  48. //
  49. // Reserve space for the system stack.
  50. //
  51. //*****************************************************************************
  52. static unsigned long pulStack[256];
  53. //*****************************************************************************
  54. //
  55. // The vector table. Note that the proper constructs must be placed on this to
  56. // ensure that it ends up at physical address 0x0000.0000.
  57. //
  58. //*****************************************************************************
  59. __attribute__ ((section(".isr_vector")))
  60. void (* const g_pfnVectors[])(void) =
  61. {
  62. (void (*)(void))((unsigned long)pulStack + sizeof(pulStack)),
  63. // The initial stack pointer
  64. ResetISR, // The reset handler
  65. NmiSR, // The NMI handler
  66. FaultISR, // The hard fault handler
  67. IntDefaultHandler, // The MPU fault handler
  68. IntDefaultHandler, // The bus fault handler
  69. IntDefaultHandler, // The usage fault handler
  70. 0, // Reserved
  71. 0, // Reserved
  72. 0, // Reserved
  73. 0, // Reserved
  74. IntDefaultHandler, // SVCall handler
  75. IntDefaultHandler, // Debug monitor handler
  76. 0, // Reserved
  77. IntDefaultHandler, // The PendSV handler
  78. SysTickIntHandler, // The SysTick handler
  79. IntDefaultHandler, // GPIO Port A
  80. IntDefaultHandler, // GPIO Port B
  81. IntDefaultHandler, // GPIO Port C
  82. IntDefaultHandler, // GPIO Port D
  83. IntDefaultHandler, // GPIO Port E
  84. IntDefaultHandler, // UART0 Rx and Tx
  85. IntDefaultHandler, // UART1 Rx and Tx
  86. IntDefaultHandler, // SSI0 Rx and Tx
  87. IntDefaultHandler, // I2C0 Master and Slave
  88. IntDefaultHandler, // PWM Fault
  89. IntDefaultHandler, // PWM Generator 0
  90. IntDefaultHandler, // PWM Generator 1
  91. IntDefaultHandler, // PWM Generator 2
  92. IntDefaultHandler, // Quadrature Encoder 0
  93. IntDefaultHandler, // ADC Sequence 0
  94. IntDefaultHandler, // ADC Sequence 1
  95. IntDefaultHandler, // ADC Sequence 2
  96. IntDefaultHandler, // ADC Sequence 3
  97. IntDefaultHandler, // Watchdog timer
  98. IntDefaultHandler, // Timer 0 subtimer A
  99. IntDefaultHandler, // Timer 0 subtimer B
  100. IntDefaultHandler, // Timer 1 subtimer A
  101. IntDefaultHandler, // Timer 1 subtimer B
  102. IntDefaultHandler, // Timer 2 subtimer A
  103. IntDefaultHandler, // Timer 2 subtimer B
  104. IntDefaultHandler, // Analog Comparator 0
  105. IntDefaultHandler, // Analog Comparator 1
  106. IntDefaultHandler, // Analog Comparator 2
  107. IntDefaultHandler, // System Control (PLL, OSC, BO)
  108. IntDefaultHandler, // FLASH Control
  109. IntDefaultHandler, // GPIO Port F
  110. IntDefaultHandler, // GPIO Port G
  111. IntDefaultHandler, // GPIO Port H
  112. IntDefaultHandler, // UART2 Rx and Tx
  113. IntDefaultHandler, // SSI1 Rx and Tx
  114. IntDefaultHandler, // Timer 3 subtimer A
  115. IntDefaultHandler, // Timer 3 subtimer B
  116. IntDefaultHandler, // I2C1 Master and Slave
  117. IntDefaultHandler, // Quadrature Encoder 1
  118. CANHandler, // CAN0
  119. IntDefaultHandler, // CAN1
  120. IntDefaultHandler, // CAN2
  121. lwIPEthernetIntHandler, // Ethernet
  122. IntDefaultHandler // Hibernate
  123. };
  124. //*****************************************************************************
  125. //
  126. // The following are constructs created by the linker, indicating where the
  127. // the "data" and "bss" segments reside in memory. The initializers for the
  128. // for the "data" segment resides immediately following the "text" segment.
  129. //
  130. //*****************************************************************************
  131. extern unsigned long _etext;
  132. extern unsigned long _data;
  133. extern unsigned long _edata;
  134. extern unsigned long _bss;
  135. extern unsigned long _ebss;
  136. //*****************************************************************************
  137. //
  138. // This is the code that gets called when the processor first starts execution
  139. // following a reset event. Only the absolutely necessary set is performed,
  140. // after which the application supplied entry() routine is called. Any fancy
  141. // actions (such as making decisions based on the reset cause register, and
  142. // resetting the bits in that register) are left solely in the hands of the
  143. // application.
  144. //
  145. //*****************************************************************************
  146. void
  147. ResetISR(void)
  148. {
  149. unsigned long *pulSrc, *pulDest;
  150. //
  151. // Copy the data segment initializers from flash to SRAM.
  152. //
  153. pulSrc = &_etext;
  154. for(pulDest = &_data; pulDest < &_edata; )
  155. {
  156. *pulDest++ = *pulSrc++;
  157. }
  158. //
  159. // Zero fill the bss segment.
  160. //
  161. __asm(" ldr r0, =_bss\n"
  162. " ldr r1, =_ebss\n"
  163. " mov r2, #0\n"
  164. " .thumb_func\n"
  165. "zero_loop:\n"
  166. " cmp r0, r1\n"
  167. " it lt\n"
  168. " strlt r2, [r0], #4\n"
  169. " blt zero_loop");
  170. //
  171. // Call the application's entry point.
  172. //
  173. main();
  174. }
  175. //*****************************************************************************
  176. //
  177. // This is the code that gets called when the processor receives a NMI. This
  178. // simply enters an infinite loop, preserving the system state for examination
  179. // by a debugger.
  180. //
  181. //*****************************************************************************
  182. static void
  183. NmiSR(void)
  184. {
  185. //
  186. // Enter an infinite loop.
  187. //
  188. while(1)
  189. {
  190. }
  191. }
  192. //*****************************************************************************
  193. //
  194. // This is the code that gets called when the processor receives a fault
  195. // interrupt. This simply enters an infinite loop, preserving the system state
  196. // for examination by a debugger.
  197. //
  198. //*****************************************************************************
  199. static void
  200. FaultISR(void)
  201. {
  202. //
  203. // Enter an infinite loop.
  204. //
  205. while(1)
  206. {
  207. }
  208. }
  209. //*****************************************************************************
  210. //
  211. // This is the code that gets called when the processor receives an unexpected
  212. // interrupt. This simply enters an infinite loop, preserving the system state
  213. // for examination by a debugger.
  214. //
  215. //*****************************************************************************
  216. static void
  217. IntDefaultHandler(void)
  218. {
  219. //
  220. // Go into an infinite loop.
  221. //
  222. while(1)
  223. {
  224. }
  225. }