startup_saml11e16a.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. /**
  2. * \file
  3. *
  4. * \brief GCC startup file for ATSAML11E16A
  5. *
  6. * Copyright (c) 2018 Microchip Technology Inc.
  7. *
  8. * \license_start
  9. *
  10. * \page License
  11. *
  12. * SPDX-License-Identifier: Apache-2.0
  13. *
  14. * Licensed under the Apache License, Version 2.0 (the "License");
  15. * you may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at
  17. *
  18. * http://www.apache.org/licenses/LICENSE-2.0
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. *
  26. * \license_stop
  27. *
  28. */
  29. #include "saml11e16a.h"
  30. /* Initialize segments */
  31. extern uint32_t _sfixed;
  32. extern uint32_t _efixed;
  33. extern uint32_t _etext;
  34. extern uint32_t _srelocate;
  35. extern uint32_t _erelocate;
  36. extern uint32_t _szero;
  37. extern uint32_t _ezero;
  38. extern uint32_t _sstack;
  39. extern uint32_t _estack;
  40. /** \cond DOXYGEN_SHOULD_SKIP_THIS */
  41. int main(void);
  42. /** \endcond */
  43. void __libc_init_array(void);
  44. /* Reset handler */
  45. void Reset_Handler(void);
  46. /* Default empty handler */
  47. void Dummy_Handler(void);
  48. /* Cortex-M23 core handlers */
  49. void NonMaskableInt_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  50. void HardFault_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  51. void SVCall_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  52. void PendSV_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  53. void SysTick_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  54. /* Peripherals handlers */
  55. void SYSTEM_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  56. void WDT_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  57. void RTC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  58. void EIC_0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  59. void EIC_1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  60. void EIC_2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  61. void EIC_3_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  62. void EIC_OTHER_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  63. void FREQM_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  64. void NVMCTRL_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  65. void PORT_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  66. void DMAC_0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  67. void DMAC_1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  68. void DMAC_2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  69. void DMAC_3_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  70. void DMAC_OTHER_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  71. void EVSYS_0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  72. void EVSYS_1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  73. void EVSYS_2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  74. void EVSYS_3_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  75. void EVSYS_NSCHK_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  76. void PAC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  77. void SERCOM0_0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  78. void SERCOM0_1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  79. void SERCOM0_2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  80. void SERCOM0_OTHER_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  81. void SERCOM1_0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  82. void SERCOM1_1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  83. void SERCOM1_2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  84. void SERCOM1_OTHER_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  85. void SERCOM2_0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  86. void SERCOM2_1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  87. void SERCOM2_2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  88. void SERCOM2_OTHER_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  89. void TC0_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  90. void TC1_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  91. void TC2_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  92. void ADC_OTHER_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  93. void ADC_RESRDY_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  94. void AC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  95. void DAC_UNDERRUN_A_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  96. void DAC_EMPTY_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  97. void PTC_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  98. void TRNG_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  99. void TRAM_Handler ( void ) __attribute__ ((weak, alias("Dummy_Handler")));
  100. /* Exception Table */
  101. __attribute__ ((section(".vectors")))
  102. const DeviceVectors exception_table = {
  103. /* Configure Initial Stack Pointer, using linker-generated symbols */
  104. .pvStack = (void*) (&_estack),
  105. .pfnReset_Handler = (void*) Reset_Handler,
  106. .pfnNonMaskableInt_Handler = (void*) NonMaskableInt_Handler,
  107. .pfnHardFault_Handler = (void*) HardFault_Handler,
  108. .pvReservedC12 = (void*) (0UL), /* Reserved */
  109. .pvReservedC11 = (void*) (0UL), /* Reserved */
  110. .pvReservedC10 = (void*) (0UL), /* Reserved */
  111. .pvReservedC9 = (void*) (0UL), /* Reserved */
  112. .pvReservedC8 = (void*) (0UL), /* Reserved */
  113. .pvReservedC7 = (void*) (0UL), /* Reserved */
  114. .pvReservedC6 = (void*) (0UL), /* Reserved */
  115. .pfnSVCall_Handler = (void*) SVCall_Handler,
  116. .pvReservedC4 = (void*) (0UL), /* Reserved */
  117. .pvReservedC3 = (void*) (0UL), /* Reserved */
  118. .pfnPendSV_Handler = (void*) PendSV_Handler,
  119. .pfnSysTick_Handler = (void*) SysTick_Handler,
  120. /* Configurable interrupts */
  121. .pfnSYSTEM_Handler = (void*) SYSTEM_Handler, /* 0 Main Clock */
  122. .pfnWDT_Handler = (void*) WDT_Handler, /* 1 Watchdog Timer */
  123. .pfnRTC_Handler = (void*) RTC_Handler, /* 2 Real-Time Counter */
  124. .pfnEIC_0_Handler = (void*) EIC_0_Handler, /* 3 External Interrupt Controller */
  125. .pfnEIC_1_Handler = (void*) EIC_1_Handler, /* 4 External Interrupt Controller */
  126. .pfnEIC_2_Handler = (void*) EIC_2_Handler, /* 5 External Interrupt Controller */
  127. .pfnEIC_3_Handler = (void*) EIC_3_Handler, /* 6 External Interrupt Controller */
  128. .pfnEIC_OTHER_Handler = (void*) EIC_OTHER_Handler, /* 7 External Interrupt Controller */
  129. .pfnFREQM_Handler = (void*) FREQM_Handler, /* 8 Frequency Meter */
  130. .pfnNVMCTRL_Handler = (void*) NVMCTRL_Handler, /* 9 Non-Volatile Memory Controller */
  131. .pfnPORT_Handler = (void*) PORT_Handler, /* 10 Port Module */
  132. .pfnDMAC_0_Handler = (void*) DMAC_0_Handler, /* 11 Direct Memory Access Controller */
  133. .pfnDMAC_1_Handler = (void*) DMAC_1_Handler, /* 12 Direct Memory Access Controller */
  134. .pfnDMAC_2_Handler = (void*) DMAC_2_Handler, /* 13 Direct Memory Access Controller */
  135. .pfnDMAC_3_Handler = (void*) DMAC_3_Handler, /* 14 Direct Memory Access Controller */
  136. .pfnDMAC_OTHER_Handler = (void*) DMAC_OTHER_Handler, /* 15 Direct Memory Access Controller */
  137. .pfnEVSYS_0_Handler = (void*) EVSYS_0_Handler, /* 16 Event System Interface */
  138. .pfnEVSYS_1_Handler = (void*) EVSYS_1_Handler, /* 17 Event System Interface */
  139. .pfnEVSYS_2_Handler = (void*) EVSYS_2_Handler, /* 18 Event System Interface */
  140. .pfnEVSYS_3_Handler = (void*) EVSYS_3_Handler, /* 19 Event System Interface */
  141. .pfnEVSYS_NSCHK_Handler = (void*) EVSYS_NSCHK_Handler, /* 20 Event System Interface */
  142. .pfnPAC_Handler = (void*) PAC_Handler, /* 21 Peripheral Access Controller */
  143. .pfnSERCOM0_0_Handler = (void*) SERCOM0_0_Handler, /* 22 Serial Communication Interface */
  144. .pfnSERCOM0_1_Handler = (void*) SERCOM0_1_Handler, /* 23 Serial Communication Interface */
  145. .pfnSERCOM0_2_Handler = (void*) SERCOM0_2_Handler, /* 24 Serial Communication Interface */
  146. .pfnSERCOM0_OTHER_Handler = (void*) SERCOM0_OTHER_Handler, /* 25 Serial Communication Interface */
  147. .pfnSERCOM1_0_Handler = (void*) SERCOM1_0_Handler, /* 26 Serial Communication Interface */
  148. .pfnSERCOM1_1_Handler = (void*) SERCOM1_1_Handler, /* 27 Serial Communication Interface */
  149. .pfnSERCOM1_2_Handler = (void*) SERCOM1_2_Handler, /* 28 Serial Communication Interface */
  150. .pfnSERCOM1_OTHER_Handler = (void*) SERCOM1_OTHER_Handler, /* 29 Serial Communication Interface */
  151. .pfnSERCOM2_0_Handler = (void*) SERCOM2_0_Handler, /* 30 Serial Communication Interface */
  152. .pfnSERCOM2_1_Handler = (void*) SERCOM2_1_Handler, /* 31 Serial Communication Interface */
  153. .pfnSERCOM2_2_Handler = (void*) SERCOM2_2_Handler, /* 32 Serial Communication Interface */
  154. .pfnSERCOM2_OTHER_Handler = (void*) SERCOM2_OTHER_Handler, /* 33 Serial Communication Interface */
  155. .pfnTC0_Handler = (void*) TC0_Handler, /* 34 Basic Timer Counter */
  156. .pfnTC1_Handler = (void*) TC1_Handler, /* 35 Basic Timer Counter */
  157. .pfnTC2_Handler = (void*) TC2_Handler, /* 36 Basic Timer Counter */
  158. .pfnADC_OTHER_Handler = (void*) ADC_OTHER_Handler, /* 37 Analog Digital Converter */
  159. .pfnADC_RESRDY_Handler = (void*) ADC_RESRDY_Handler, /* 38 Analog Digital Converter */
  160. .pfnAC_Handler = (void*) AC_Handler, /* 39 Analog Comparators */
  161. .pfnDAC_UNDERRUN_A_Handler = (void*) DAC_UNDERRUN_A_Handler, /* 40 Digital Analog Converter */
  162. .pfnDAC_EMPTY_Handler = (void*) DAC_EMPTY_Handler, /* 41 Digital Analog Converter */
  163. .pfnPTC_Handler = (void*) PTC_Handler, /* 42 Peripheral Touch Controller */
  164. .pfnTRNG_Handler = (void*) TRNG_Handler, /* 43 True Random Generator */
  165. .pfnTRAM_Handler = (void*) TRAM_Handler /* 44 TrustRAM */
  166. };
  167. /**
  168. * \brief This is the code that gets called on processor reset.
  169. * To initialize the device, and call the main() routine.
  170. */
  171. void Reset_Handler(void)
  172. {
  173. uint32_t *pSrc, *pDest;
  174. /* Initialize the relocate segment */
  175. pSrc = &_etext;
  176. pDest = &_srelocate;
  177. if (pSrc != pDest) {
  178. for (; pDest < &_erelocate;) {
  179. *pDest++ = *pSrc++;
  180. }
  181. }
  182. /* Clear the zero segment */
  183. for (pDest = &_szero; pDest < &_ezero;) {
  184. *pDest++ = 0;
  185. }
  186. /* Set the vector table base address */
  187. pSrc = (uint32_t *) & _sfixed;
  188. SCB->VTOR = ((uint32_t) pSrc & SCB_VTOR_TBLOFF_Msk);
  189. /* Initialize the C library */
  190. __libc_init_array();
  191. /* Branch to main function */
  192. main();
  193. /* Infinite loop */
  194. while (1);
  195. }
  196. /**
  197. * \brief Default interrupt handler for unused IRQs.
  198. */
  199. void Dummy_Handler(void)
  200. {
  201. while (1) {
  202. }
  203. }