startup_mspm0g350x_ticlang.c 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*****************************************************************************
  2. Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/
  3. Redistribution and use in source and binary forms, with or without
  4. modification, are permitted provided that the following conditions
  5. are met:
  6. Redistributions of source code must retain the above copyright
  7. notice, this list of conditions and the following disclaimer.
  8. Redistributions in binary form must reproduce the above copyright
  9. notice, this list of conditions and the following disclaimer in the
  10. documentation and/or other materials provided with the
  11. distribution.
  12. Neither the name of Texas Instruments Incorporated nor the names of
  13. its contributors may be used to endorse or promote products derived
  14. from this software without specific prior written permission.
  15. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  16. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  17. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  18. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  19. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  20. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  21. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  22. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  23. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  25. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. *****************************************************************************/
  27. #include <stdint.h>
  28. #include <ti/devices/msp/msp.h>
  29. /* Linker variable that marks the top of the stack. */
  30. extern unsigned long __STACK_END;
  31. /* External declaration for the reset handler that is to be called when the */
  32. /* processor is started */
  33. extern __NO_RETURN void __PROGRAM_START(void);
  34. /* Forward declaration of the default fault handlers. */
  35. void Default_Handler(void) __attribute__((weak));
  36. extern void Reset_Handler(void) __attribute__((weak));
  37. /* Processor Exceptions */
  38. extern void NMI_Handler(void) __attribute__((weak, alias("Default_Handler")));
  39. extern void HardFault_Handler(void)
  40. __attribute__((weak, alias("Default_Handler")));
  41. extern void SVC_Handler(void) __attribute__((weak, alias("Default_Handler")));
  42. extern void PendSV_Handler(void)
  43. __attribute__((weak, alias("Default_Handler")));
  44. extern void SysTick_Handler(void)
  45. __attribute__((weak, alias("Default_Handler")));
  46. /* Device Specific Interrupt Handlers */
  47. extern void GROUP0_IRQHandler(void)
  48. __attribute__((weak, alias("Default_Handler")));
  49. extern void GROUP1_IRQHandler(void)
  50. __attribute__((weak, alias("Default_Handler")));
  51. extern void TIMG8_IRQHandler(void)
  52. __attribute__((weak, alias("Default_Handler")));
  53. extern void UART3_IRQHandler(void)
  54. __attribute__((weak, alias("Default_Handler")));
  55. extern void ADC0_IRQHandler(void)
  56. __attribute__((weak, alias("Default_Handler")));
  57. extern void ADC1_IRQHandler(void)
  58. __attribute__((weak, alias("Default_Handler")));
  59. extern void CANFD0_IRQHandler(void)
  60. __attribute__((weak, alias("Default_Handler")));
  61. extern void DAC0_IRQHandler(void)
  62. __attribute__((weak, alias("Default_Handler")));
  63. extern void SPI0_IRQHandler(void)
  64. __attribute__((weak, alias("Default_Handler")));
  65. extern void SPI1_IRQHandler(void)
  66. __attribute__((weak, alias("Default_Handler")));
  67. extern void UART1_IRQHandler(void)
  68. __attribute__((weak, alias("Default_Handler")));
  69. extern void UART2_IRQHandler(void)
  70. __attribute__((weak, alias("Default_Handler")));
  71. extern void UART0_IRQHandler(void)
  72. __attribute__((weak, alias("Default_Handler")));
  73. extern void TIMG0_IRQHandler(void)
  74. __attribute__((weak, alias("Default_Handler")));
  75. extern void TIMG6_IRQHandler(void)
  76. __attribute__((weak, alias("Default_Handler")));
  77. extern void TIMA0_IRQHandler(void)
  78. __attribute__((weak, alias("Default_Handler")));
  79. extern void TIMA1_IRQHandler(void)
  80. __attribute__((weak, alias("Default_Handler")));
  81. extern void TIMG7_IRQHandler(void)
  82. __attribute__((weak, alias("Default_Handler")));
  83. extern void TIMG12_IRQHandler(void)
  84. __attribute__((weak, alias("Default_Handler")));
  85. extern void I2C0_IRQHandler(void)
  86. __attribute__((weak, alias("Default_Handler")));
  87. extern void I2C1_IRQHandler(void)
  88. __attribute__((weak, alias("Default_Handler")));
  89. extern void AES_IRQHandler(void)
  90. __attribute__((weak, alias("Default_Handler")));
  91. extern void RTC_IRQHandler(void)
  92. __attribute__((weak, alias("Default_Handler")));
  93. extern void DMA_IRQHandler(void)
  94. __attribute__((weak, alias("Default_Handler")));
  95. /* Interrupt vector table. Note that the proper constructs must be placed on this to */
  96. /* ensure that it ends up at physical address 0x0000.0000 or at the start of */
  97. /* the program if located at a start address other than 0. */
  98. #if defined(__ARM_ARCH) && (__ARM_ARCH != 0)
  99. void (*const interruptVectors[])(void) __attribute((used))
  100. __attribute__((section(".intvecs"))) =
  101. #elif defined(__TI_ARM__)
  102. #pragma RETAIN(interruptVectors)
  103. #pragma DATA_SECTION(interruptVectors, ".intvecs")
  104. void (*const interruptVectors[])(void) =
  105. #else
  106. #error "Compiler not supported"
  107. #endif
  108. {
  109. (void (*)(void))((uint32_t) &__STACK_END),
  110. /* The initial stack pointer */
  111. Reset_Handler, /* The reset handler */
  112. NMI_Handler, /* The NMI handler */
  113. HardFault_Handler, /* The hard fault handler */
  114. 0, /* Reserved */
  115. 0, /* Reserved */
  116. 0, /* Reserved */
  117. 0, /* Reserved */
  118. 0, /* Reserved */
  119. 0, /* Reserved */
  120. 0, /* Reserved */
  121. SVC_Handler, /* SVCall handler */
  122. 0, /* Reserved */
  123. 0, /* Reserved */
  124. PendSV_Handler, /* The PendSV handler */
  125. SysTick_Handler, /* SysTick handler */
  126. GROUP0_IRQHandler, /* GROUP0 interrupt handler */
  127. GROUP1_IRQHandler, /* GROUP1 interrupt handler */
  128. TIMG8_IRQHandler, /* TIMG8 interrupt handler */
  129. UART3_IRQHandler, /* UART3 interrupt handler */
  130. ADC0_IRQHandler, /* ADC0 interrupt handler */
  131. ADC1_IRQHandler, /* ADC1 interrupt handler */
  132. CANFD0_IRQHandler, /* CANFD0 interrupt handler */
  133. DAC0_IRQHandler, /* DAC0 interrupt handler */
  134. 0, /* Reserved */
  135. SPI0_IRQHandler, /* SPI0 interrupt handler */
  136. SPI1_IRQHandler, /* SPI1 interrupt handler */
  137. 0, /* Reserved */
  138. 0, /* Reserved */
  139. UART1_IRQHandler, /* UART1 interrupt handler */
  140. UART2_IRQHandler, /* UART2 interrupt handler */
  141. UART0_IRQHandler, /* UART0 interrupt handler */
  142. TIMG0_IRQHandler, /* TIMG0 interrupt handler */
  143. TIMG6_IRQHandler, /* TIMG6 interrupt handler */
  144. TIMA0_IRQHandler, /* TIMA0 interrupt handler */
  145. TIMA1_IRQHandler, /* TIMA1 interrupt handler */
  146. TIMG7_IRQHandler, /* TIMG7 interrupt handler */
  147. TIMG12_IRQHandler, /* TIMG12 interrupt handler */
  148. 0, /* Reserved */
  149. 0, /* Reserved */
  150. I2C0_IRQHandler, /* I2C0 interrupt handler */
  151. I2C1_IRQHandler, /* I2C1 interrupt handler */
  152. 0, /* Reserved */
  153. 0, /* Reserved */
  154. AES_IRQHandler, /* AES interrupt handler */
  155. 0, /* Reserved */
  156. RTC_IRQHandler, /* RTC interrupt handler */
  157. DMA_IRQHandler /* DMA interrupt handler */
  158. };
  159. /* Forward declaration of the default fault handlers. */
  160. /* This is the code that gets called when the processor first starts execution */
  161. /* following a reset event. Only the absolutely necessary set is performed, */
  162. /* after which the application supplied entry() routine is called. Any fancy */
  163. /* actions (such as making decisions based on the reset cause register, and */
  164. /* resetting the bits in that register) are left solely in the hands of the */
  165. /* application. */
  166. void Reset_Handler(void)
  167. {
  168. // SCB->VTOR =0x00006000;
  169. /* Jump to the ticlang C Initialization Routine. */
  170. __asm(
  171. " .global _c_int00\n"
  172. " b _c_int00");
  173. }
  174. /* This is the code that gets called when the processor receives an unexpected */
  175. /* interrupt. This simply enters an infinite loop, preserving the system state */
  176. /* for examination by a debugger. */
  177. void Default_Handler(void)
  178. {
  179. /* Enter an infinite loop. */
  180. while (1) {
  181. }
  182. }