startup_ARMCM0plus.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /******************************************************************************
  2. * @file startup_ARMCM0plus.c
  3. * @brief CMSIS-Core(M) Device Startup File for a Cortex-M0+ Device
  4. * @version V2.0.3
  5. * @date 31. March 2020
  6. ******************************************************************************/
  7. /*
  8. * Copyright (c) 2009-2020 Arm Limited. All rights reserved.
  9. *
  10. * SPDX-License-Identifier: Apache-2.0
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the License); you may
  13. * not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an AS IS BASIS, WITHOUT
  20. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. #if defined (ARMCM0P)
  25. #include "ARMCM0plus.h"
  26. #elif defined (ARMCM0P_MPU)
  27. #include "ARMCM0plus_MPU.h"
  28. #else
  29. #error device not specified!
  30. #endif
  31. /*----------------------------------------------------------------------------
  32. External References
  33. *----------------------------------------------------------------------------*/
  34. extern uint32_t __INITIAL_SP;
  35. extern __NO_RETURN void __PROGRAM_START(void);
  36. /*----------------------------------------------------------------------------
  37. Internal References
  38. *----------------------------------------------------------------------------*/
  39. __NO_RETURN void Reset_Handler (void);
  40. void Default_Handler(void);
  41. /*----------------------------------------------------------------------------
  42. Exception / Interrupt Handler
  43. *----------------------------------------------------------------------------*/
  44. /* Exceptions */
  45. void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  46. void HardFault_Handler (void) __attribute__ ((weak));
  47. void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  48. void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  49. void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  50. void Interrupt0_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  51. void Interrupt1_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  52. void Interrupt2_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  53. void Interrupt3_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  54. void Interrupt4_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  55. void Interrupt5_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  56. void Interrupt6_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  57. void Interrupt7_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  58. void Interrupt8_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  59. void Interrupt9_Handler (void) __attribute__ ((weak, alias("Default_Handler")));
  60. /*----------------------------------------------------------------------------
  61. Exception / Interrupt Vector table
  62. *----------------------------------------------------------------------------*/
  63. #if defined ( __GNUC__ )
  64. #pragma GCC diagnostic push
  65. #pragma GCC diagnostic ignored "-Wpedantic"
  66. #endif
  67. extern const VECTOR_TABLE_Type __VECTOR_TABLE[48];
  68. const VECTOR_TABLE_Type __VECTOR_TABLE[48] __VECTOR_TABLE_ATTRIBUTE = {
  69. (VECTOR_TABLE_Type)(&__INITIAL_SP), /* Initial Stack Pointer */
  70. Reset_Handler, /* Reset Handler */
  71. NMI_Handler, /* -14 NMI Handler */
  72. HardFault_Handler, /* -13 Hard Fault Handler */
  73. 0, /* Reserved */
  74. 0, /* Reserved */
  75. 0, /* Reserved */
  76. 0, /* Reserved */
  77. 0, /* Reserved */
  78. 0, /* Reserved */
  79. 0, /* Reserved */
  80. SVC_Handler, /* -5 SVCall Handler */
  81. 0, /* Reserved */
  82. 0, /* Reserved */
  83. PendSV_Handler, /* -2 PendSV Handler */
  84. SysTick_Handler, /* -1 SysTick Handler */
  85. /* Interrupts */
  86. Interrupt0_Handler, /* 0 Interrupt 0 */
  87. Interrupt1_Handler, /* 1 Interrupt 1 */
  88. Interrupt2_Handler, /* 2 Interrupt 2 */
  89. Interrupt3_Handler, /* 3 Interrupt 3 */
  90. Interrupt4_Handler, /* 4 Interrupt 4 */
  91. Interrupt5_Handler, /* 5 Interrupt 5 */
  92. Interrupt6_Handler, /* 6 Interrupt 6 */
  93. Interrupt7_Handler, /* 7 Interrupt 7 */
  94. Interrupt8_Handler, /* 8 Interrupt 8 */
  95. Interrupt9_Handler /* 9 Interrupt 9 */
  96. /* Interrupts 10..31 are left out */
  97. };
  98. #if defined ( __GNUC__ )
  99. #pragma GCC diagnostic pop
  100. #endif
  101. /*----------------------------------------------------------------------------
  102. Reset Handler called on controller reset
  103. *----------------------------------------------------------------------------*/
  104. __NO_RETURN void Reset_Handler(void)
  105. {
  106. SystemInit(); /* CMSIS System Initialization */
  107. __PROGRAM_START(); /* Enter PreMain (C library entry point) */
  108. }
  109. #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  110. #pragma clang diagnostic push
  111. #pragma clang diagnostic ignored "-Wmissing-noreturn"
  112. #endif
  113. /*----------------------------------------------------------------------------
  114. Hard Fault Handler
  115. *----------------------------------------------------------------------------*/
  116. void HardFault_Handler(void)
  117. {
  118. while(1);
  119. }
  120. /*----------------------------------------------------------------------------
  121. Default Handler for Exceptions / Interrupts
  122. *----------------------------------------------------------------------------*/
  123. void Default_Handler(void)
  124. {
  125. while(1);
  126. }
  127. #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
  128. #pragma clang diagnostic pop
  129. #endif