1
0

startup_ewarm.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. //*****************************************************************************
  2. //
  3. // startup_ewarm.c - Startup code for use with IAR's Embedded Workbench,
  4. // version 5.
  5. //
  6. // Copyright (c) 2013-2014 Texas Instruments Incorporated. All rights reserved.
  7. // Software License Agreement
  8. //
  9. // Texas Instruments (TI) is supplying this software for use solely and
  10. // exclusively on TI's microcontroller products. The software is owned by
  11. // TI and/or its suppliers, and is protected under applicable copyright
  12. // laws. You may not combine this software with "viral" open-source
  13. // software in order to form a larger program.
  14. //
  15. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  16. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  17. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  19. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  20. // DAMAGES, FOR ANY REASON WHATSOEVER.
  21. //
  22. // This is part of revision 2.1.0.12573 of the DK-TM4C129X Firmware Package.
  23. //
  24. //*****************************************************************************
  25. #include <stdint.h>
  26. #include "inc/hw_nvic.h"
  27. #include "inc/hw_types.h"
  28. //*****************************************************************************
  29. //
  30. // Enable the IAR extensions for this source file.
  31. //
  32. //*****************************************************************************
  33. #pragma language=extended
  34. //*****************************************************************************
  35. //
  36. // Forward declaration of the default fault handlers.
  37. //
  38. //*****************************************************************************
  39. void ResetISR(void);
  40. static void NmiSR(void);
  41. static void FaultISR(void);
  42. static void IntDefaultHandler(void);
  43. //*****************************************************************************
  44. //
  45. // The entry point for the application startup code.
  46. //
  47. //*****************************************************************************
  48. extern void __iar_program_start(void);
  49. extern void PendSV_Handler(void);
  50. extern void SysTick_Handler(void);
  51. extern void UART0_IRQHandler(void);
  52. extern void HardFault_Handler(void);
  53. //*****************************************************************************
  54. //
  55. // Reserve space for the system stack.
  56. //
  57. //*****************************************************************************
  58. static uint32_t pui32Stack[64] @ ".noinit";
  59. //*****************************************************************************
  60. //
  61. // A union that describes the entries of the vector table. The union is needed
  62. // since the first entry is the stack pointer and the remainder are function
  63. // pointers.
  64. //
  65. //*****************************************************************************
  66. typedef union
  67. {
  68. void (*pfnHandler)(void);
  69. uint32_t ui32Ptr;
  70. }
  71. uVectorEntry;
  72. //*****************************************************************************
  73. //
  74. // The vector table. Note that the proper constructs must be placed on this to
  75. // ensure that it ends up at physical address 0x0000.0000.
  76. //
  77. //*****************************************************************************
  78. __root const uVectorEntry __vector_table[] @ ".intvec" =
  79. {
  80. { .ui32Ptr = (uint32_t)pui32Stack + sizeof(pui32Stack) },
  81. // The initial stack pointer
  82. ResetISR, // The reset handler
  83. NmiSR, // The NMI handler
  84. HardFault_Handler, // The hard fault handler
  85. IntDefaultHandler, // The MPU fault handler
  86. IntDefaultHandler, // The bus fault handler
  87. IntDefaultHandler, // The usage fault handler
  88. 0, // Reserved
  89. 0, // Reserved
  90. 0, // Reserved
  91. 0, // Reserved
  92. IntDefaultHandler, // SVCall handler
  93. IntDefaultHandler, // Debug monitor handler
  94. 0, // Reserved
  95. PendSV_Handler, //IntDefaultHandler, // The PendSV handler
  96. SysTick_Handler,//IntDefaultHandler, // The SysTick handler
  97. IntDefaultHandler, // GPIO Port A
  98. IntDefaultHandler, // GPIO Port B
  99. IntDefaultHandler, // GPIO Port C
  100. IntDefaultHandler, // GPIO Port D
  101. IntDefaultHandler, // GPIO Port E
  102. UART0_IRQHandler, //IntDefaultHandler, // UART0 Rx and Tx
  103. IntDefaultHandler, // UART1 Rx and Tx
  104. IntDefaultHandler, // SSI0 Rx and Tx
  105. IntDefaultHandler, // I2C0 Master and Slave
  106. IntDefaultHandler, // PWM Fault
  107. IntDefaultHandler, // PWM Generator 0
  108. IntDefaultHandler, // PWM Generator 1
  109. IntDefaultHandler, // PWM Generator 2
  110. IntDefaultHandler, // Quadrature Encoder 0
  111. IntDefaultHandler, // ADC Sequence 0
  112. IntDefaultHandler, // ADC Sequence 1
  113. IntDefaultHandler, // ADC Sequence 2
  114. IntDefaultHandler, // ADC Sequence 3
  115. IntDefaultHandler, // Watchdog timer
  116. IntDefaultHandler, // Timer 0 subtimer A
  117. IntDefaultHandler, // Timer 0 subtimer B
  118. IntDefaultHandler, // Timer 1 subtimer A
  119. IntDefaultHandler, // Timer 1 subtimer B
  120. IntDefaultHandler, // Timer 2 subtimer A
  121. IntDefaultHandler, // Timer 2 subtimer B
  122. IntDefaultHandler, // Analog Comparator 0
  123. IntDefaultHandler, // Analog Comparator 1
  124. IntDefaultHandler, // Analog Comparator 2
  125. IntDefaultHandler, // System Control (PLL, OSC, BO)
  126. IntDefaultHandler, // FLASH Control
  127. IntDefaultHandler, // GPIO Port F
  128. IntDefaultHandler, // GPIO Port G
  129. IntDefaultHandler, // GPIO Port H
  130. IntDefaultHandler, // UART2 Rx and Tx
  131. IntDefaultHandler, // SSI1 Rx and Tx
  132. IntDefaultHandler, // Timer 3 subtimer A
  133. IntDefaultHandler, // Timer 3 subtimer B
  134. IntDefaultHandler, // I2C1 Master and Slave
  135. IntDefaultHandler, // CAN0
  136. IntDefaultHandler, // CAN1
  137. IntDefaultHandler, // Ethernet
  138. IntDefaultHandler, // Hibernate
  139. IntDefaultHandler, // USB0
  140. IntDefaultHandler, // PWM Generator 3
  141. IntDefaultHandler, // uDMA Software Transfer
  142. IntDefaultHandler, // uDMA Error
  143. IntDefaultHandler, // ADC1 Sequence 0
  144. IntDefaultHandler, // ADC1 Sequence 1
  145. IntDefaultHandler, // ADC1 Sequence 2
  146. IntDefaultHandler, // ADC1 Sequence 3
  147. IntDefaultHandler, // External Bus Interface 0
  148. IntDefaultHandler, // GPIO Port J
  149. IntDefaultHandler, // GPIO Port K
  150. IntDefaultHandler, // GPIO Port L
  151. IntDefaultHandler, // SSI2 Rx and Tx
  152. IntDefaultHandler, // SSI3 Rx and Tx
  153. IntDefaultHandler, // UART3 Rx and Tx
  154. IntDefaultHandler, // UART4 Rx and Tx
  155. IntDefaultHandler, // UART5 Rx and Tx
  156. IntDefaultHandler, // UART6 Rx and Tx
  157. IntDefaultHandler, // UART7 Rx and Tx
  158. IntDefaultHandler, // I2C2 Master and Slave
  159. IntDefaultHandler, // I2C3 Master and Slave
  160. IntDefaultHandler, // Timer 4 subtimer A
  161. IntDefaultHandler, // Timer 4 subtimer B
  162. IntDefaultHandler, // Timer 5 subtimer A
  163. IntDefaultHandler, // Timer 5 subtimer B
  164. IntDefaultHandler, // FPU
  165. 0, // Reserved
  166. 0, // Reserved
  167. IntDefaultHandler, // I2C4 Master and Slave
  168. IntDefaultHandler, // I2C5 Master and Slave
  169. IntDefaultHandler, // GPIO Port M
  170. IntDefaultHandler, // GPIO Port N
  171. 0, // Reserved
  172. IntDefaultHandler, // Tamper
  173. IntDefaultHandler, // GPIO Port P (Summary or P0)
  174. IntDefaultHandler, // GPIO Port P1
  175. IntDefaultHandler, // GPIO Port P2
  176. IntDefaultHandler, // GPIO Port P3
  177. IntDefaultHandler, // GPIO Port P4
  178. IntDefaultHandler, // GPIO Port P5
  179. IntDefaultHandler, // GPIO Port P6
  180. IntDefaultHandler, // GPIO Port P7
  181. IntDefaultHandler, // GPIO Port Q (Summary or Q0)
  182. IntDefaultHandler, // GPIO Port Q1
  183. IntDefaultHandler, // GPIO Port Q2
  184. IntDefaultHandler, // GPIO Port Q3
  185. IntDefaultHandler, // GPIO Port Q4
  186. IntDefaultHandler, // GPIO Port Q5
  187. IntDefaultHandler, // GPIO Port Q6
  188. IntDefaultHandler, // GPIO Port Q7
  189. IntDefaultHandler, // GPIO Port R
  190. IntDefaultHandler, // GPIO Port S
  191. IntDefaultHandler, // SHA/MD5 0
  192. IntDefaultHandler, // AES 0
  193. IntDefaultHandler, // DES3DES 0
  194. IntDefaultHandler, // LCD Controller 0
  195. IntDefaultHandler, // Timer 6 subtimer A
  196. IntDefaultHandler, // Timer 6 subtimer B
  197. IntDefaultHandler, // Timer 7 subtimer A
  198. IntDefaultHandler, // Timer 7 subtimer B
  199. IntDefaultHandler, // I2C6 Master and Slave
  200. IntDefaultHandler, // I2C7 Master and Slave
  201. IntDefaultHandler, // HIM Scan Matrix Keyboard 0
  202. IntDefaultHandler, // One Wire 0
  203. IntDefaultHandler, // HIM PS/2 0
  204. IntDefaultHandler, // HIM LED Sequencer 0
  205. IntDefaultHandler, // HIM Consumer IR 0
  206. IntDefaultHandler, // I2C8 Master and Slave
  207. IntDefaultHandler, // I2C9 Master and Slave
  208. IntDefaultHandler // GPIO Port T
  209. };
  210. //*****************************************************************************
  211. //
  212. // This is the code that gets called when the processor first starts execution
  213. // following a reset event. Only the absolutely necessary set is performed,
  214. // after which the application supplied entry() routine is called. Any fancy
  215. // actions (such as making decisions based on the reset cause register, and
  216. // resetting the bits in that register) are left solely in the hands of the
  217. // application.
  218. //
  219. //*****************************************************************************
  220. void
  221. ResetISR(void)
  222. {
  223. //
  224. // Enable the floating-point unit. This must be done here to handle the
  225. // case where main() uses floating-point and the function prologue saves
  226. // floating-point registers (which will fault if floating-point is not
  227. // enabled). Any configuration of the floating-point unit using DriverLib
  228. // APIs must be done here prior to the floating-point unit being enabled.
  229. //
  230. // Note that this does not use DriverLib since it might not be included in
  231. // this project.
  232. //
  233. HWREG(NVIC_CPAC) = ((HWREG(NVIC_CPAC) &
  234. ~(NVIC_CPAC_CP10_M | NVIC_CPAC_CP11_M)) |
  235. NVIC_CPAC_CP10_FULL | NVIC_CPAC_CP11_FULL);
  236. //
  237. // Call the application's entry point.
  238. //
  239. __iar_program_start();
  240. }
  241. //*****************************************************************************
  242. //
  243. // This is the code that gets called when the processor receives a NMI. This
  244. // simply enters an infinite loop, preserving the system state for examination
  245. // by a debugger.
  246. //
  247. //*****************************************************************************
  248. static void
  249. NmiSR(void)
  250. {
  251. //
  252. // Enter an infinite loop.
  253. //
  254. while(1)
  255. {
  256. }
  257. }
  258. //*****************************************************************************
  259. //
  260. // This is the code that gets called when the processor receives a fault
  261. // interrupt. This simply enters an infinite loop, preserving the system state
  262. // for examination by a debugger.
  263. //
  264. //*****************************************************************************
  265. static void
  266. FaultISR(void)
  267. {
  268. //
  269. // Enter an infinite loop.
  270. //
  271. while(1)
  272. {
  273. }
  274. }
  275. //*****************************************************************************
  276. //
  277. // This is the code that gets called when the processor receives an unexpected
  278. // interrupt. This simply enters an infinite loop, preserving the system state
  279. // for examination by a debugger.
  280. //
  281. //*****************************************************************************
  282. static void
  283. IntDefaultHandler(void)
  284. {
  285. //
  286. // Go into an infinite loop.
  287. //
  288. while(1)
  289. {
  290. }
  291. }