|
| 1 | +/* |
| 2 | + * This file is part of the MicroPython project, http://micropython.org/ |
| 3 | + * |
| 4 | + * The MIT License (MIT) |
| 5 | + * |
| 6 | + * Copyright (c) 2017 Glenn Ruben Bakke |
| 7 | + * |
| 8 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 | + * of this software and associated documentation files (the "Software"), to deal |
| 10 | + * in the Software without restriction, including without limitation the rights |
| 11 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 | + * copies of the Software, and to permit persons to whom the Software is |
| 13 | + * furnished to do so, subject to the following conditions: |
| 14 | + * |
| 15 | + * The above copyright notice and this permission notice shall be included in |
| 16 | + * all copies or substantial portions of the Software. |
| 17 | + * |
| 18 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 24 | + * THE SOFTWARE. |
| 25 | + */ |
| 26 | + |
| 27 | +#include <stdint.h> |
| 28 | + |
| 29 | +extern uint32_t _estack; |
| 30 | +extern uint32_t _sidata; |
| 31 | +extern uint32_t _sdata; |
| 32 | +extern uint32_t _edata; |
| 33 | +extern uint32_t _sbss; |
| 34 | +extern uint32_t _ebss; |
| 35 | + |
| 36 | +typedef void (*func)(void); |
| 37 | + |
| 38 | +#define _start main |
| 39 | + |
| 40 | +extern void _start(void) __attribute__((noreturn)); |
| 41 | +extern void SystemInit(void); |
| 42 | + |
| 43 | +void Default_Handler(void) { |
| 44 | + while (1); |
| 45 | +} |
| 46 | + |
| 47 | +void Reset_Handler(void) { |
| 48 | + uint32_t * p_src = &_sidata; |
| 49 | + uint32_t * p_dest = &_sdata; |
| 50 | + |
| 51 | + while (p_dest < &_edata) { |
| 52 | + *p_dest++ = *p_src++; |
| 53 | + } |
| 54 | + |
| 55 | + uint32_t * p_bss = &_sbss; |
| 56 | + uint32_t * p_bss_end = &_ebss; |
| 57 | + while (p_bss < p_bss_end) { |
| 58 | + *p_bss++ = 0ul; |
| 59 | + } |
| 60 | + |
| 61 | + SystemInit(); |
| 62 | + _start(); |
| 63 | +} |
| 64 | + |
| 65 | +void NMI_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 66 | +void HardFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 67 | +void MemoryManagement_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 68 | +void BusFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 69 | +void UsageFault_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 70 | +void SVC_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 71 | +void DebugMon_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 72 | +void PendSV_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 73 | +void SysTick_Handler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 74 | + |
| 75 | +void POWER_CLOCK_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 76 | +void RADIO_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 77 | +void UARTE0_UART0_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 78 | +void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 79 | +void SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 80 | +void NFCT_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 81 | +void GPIOTE_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 82 | +void SAADC_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 83 | +void TIMER0_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 84 | +void TIMER1_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 85 | +void TIMER2_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 86 | +void RTC0_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 87 | +void TEMP_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 88 | +void RNG_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 89 | +void ECB_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 90 | +void CCM_AAR_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 91 | +void WDT_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 92 | +void RTC1_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 93 | +void QDEC_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 94 | +void COMP_LPCOMP_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 95 | +void SWI0_EGU0_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 96 | +void SWI1_EGU1_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 97 | +void SWI2_EGU2_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 98 | +void SWI3_EGU3_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 99 | +void SWI4_EGU4_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 100 | +void SWI5_EGU5_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 101 | +void TIMER3_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 102 | +void TIMER4_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 103 | +void PWM0_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 104 | +void PDM_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 105 | +void MWU_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 106 | +void PWM1_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 107 | +void PWM2_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 108 | +void SPIM2_SPIS2_SPI2_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 109 | +void RTC2_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 110 | +void I2S_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 111 | +void FPU_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 112 | +void USBD_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 113 | +void UARTE1_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 114 | +void PWM3_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 115 | +void SPIM3_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler"))); |
| 116 | + |
| 117 | +const func __Vectors[] __attribute__ ((used, section(".isr_vector"))) = { |
| 118 | + (func)&_estack, |
| 119 | + Reset_Handler, |
| 120 | + NMI_Handler, |
| 121 | + HardFault_Handler, |
| 122 | + MemoryManagement_Handler, |
| 123 | + BusFault_Handler, |
| 124 | + UsageFault_Handler, |
| 125 | + 0, |
| 126 | + 0, |
| 127 | + 0, |
| 128 | + 0, |
| 129 | + SVC_Handler, |
| 130 | + DebugMon_Handler, |
| 131 | + 0, |
| 132 | + PendSV_Handler, |
| 133 | + SysTick_Handler, |
| 134 | + |
| 135 | + /* External Interrupts */ |
| 136 | + POWER_CLOCK_IRQHandler, |
| 137 | + RADIO_IRQHandler, |
| 138 | + UARTE0_UART0_IRQHandler, |
| 139 | + SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler, |
| 140 | + SPIM1_SPIS1_TWIM1_TWIS1_SPI1_TWI1_IRQHandler, |
| 141 | + NFCT_IRQHandler, |
| 142 | + GPIOTE_IRQHandler, |
| 143 | + SAADC_IRQHandler, |
| 144 | + TIMER0_IRQHandler, |
| 145 | + TIMER1_IRQHandler, |
| 146 | + TIMER2_IRQHandler, |
| 147 | + RTC0_IRQHandler, |
| 148 | + TEMP_IRQHandler, |
| 149 | + RNG_IRQHandler, |
| 150 | + ECB_IRQHandler, |
| 151 | + CCM_AAR_IRQHandler, |
| 152 | + WDT_IRQHandler, |
| 153 | + RTC1_IRQHandler, |
| 154 | + QDEC_IRQHandler, |
| 155 | + COMP_LPCOMP_IRQHandler, |
| 156 | + SWI0_EGU0_IRQHandler, |
| 157 | + SWI1_EGU1_IRQHandler, |
| 158 | + SWI2_EGU2_IRQHandler, |
| 159 | + SWI3_EGU3_IRQHandler, |
| 160 | + SWI4_EGU4_IRQHandler, |
| 161 | + SWI5_EGU5_IRQHandler, |
| 162 | + TIMER3_IRQHandler, |
| 163 | + TIMER4_IRQHandler, |
| 164 | + PWM0_IRQHandler, |
| 165 | + PDM_IRQHandler, |
| 166 | + 0, |
| 167 | + 0, |
| 168 | + MWU_IRQHandler, |
| 169 | + PWM1_IRQHandler, |
| 170 | + PWM2_IRQHandler, |
| 171 | + SPIM2_SPIS2_SPI2_IRQHandler, |
| 172 | + RTC2_IRQHandler, |
| 173 | + I2S_IRQHandler, |
| 174 | + FPU_IRQHandler, |
| 175 | + USBD_IRQHandler, |
| 176 | + UARTE1_IRQHandler, |
| 177 | + 0, |
| 178 | + 0, |
| 179 | + 0, |
| 180 | + 0, |
| 181 | + PWM3_IRQHandler, |
| 182 | + 0, |
| 183 | + SPIM3_IRQHandler, |
| 184 | +}; |
0 commit comments