mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_Freescale/TARGET_KLXX/TARGET_KL25Z/TOOLCHAIN_GCC_CW_EWL/startup_MKL25Z4.c@323:9e901b0a5aa1, 2014-09-13 (annotated)
- Committer:
- shaoziyang
- Date:
- Sat Sep 13 14:25:46 2014 +0000
- Revision:
- 323:9e901b0a5aa1
- Parent:
- 82:0b31dbcd4769
test with CLOCK_SETUP = 0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 82:0b31dbcd4769 | 1 | #include <string.h> |
mbed_official | 82:0b31dbcd4769 | 2 | #include <stdlib.h> |
mbed_official | 82:0b31dbcd4769 | 3 | |
mbed_official | 82:0b31dbcd4769 | 4 | #include "cmsis.h" |
mbed_official | 82:0b31dbcd4769 | 5 | |
mbed_official | 82:0b31dbcd4769 | 6 | // Linker Script |
mbed_official | 82:0b31dbcd4769 | 7 | extern unsigned long _estack; |
mbed_official | 82:0b31dbcd4769 | 8 | extern char __S_romp[]; |
mbed_official | 82:0b31dbcd4769 | 9 | |
mbed_official | 82:0b31dbcd4769 | 10 | extern char __START_BSS[]; |
mbed_official | 82:0b31dbcd4769 | 11 | extern char __END_BSS[]; |
mbed_official | 82:0b31dbcd4769 | 12 | |
mbed_official | 82:0b31dbcd4769 | 13 | // CRT0 |
mbed_official | 82:0b31dbcd4769 | 14 | extern void __init_registers(); |
mbed_official | 82:0b31dbcd4769 | 15 | extern void __copy_rom_sections_to_ram(void); |
mbed_official | 82:0b31dbcd4769 | 16 | extern void __call_static_initializers(void); |
mbed_official | 82:0b31dbcd4769 | 17 | extern void __init_user(); |
mbed_official | 82:0b31dbcd4769 | 18 | |
mbed_official | 82:0b31dbcd4769 | 19 | // User/mbed Defined |
mbed_official | 82:0b31dbcd4769 | 20 | extern int main(); |
mbed_official | 82:0b31dbcd4769 | 21 | extern void mbed_exit(int return_code); |
mbed_official | 82:0b31dbcd4769 | 22 | |
mbed_official | 82:0b31dbcd4769 | 23 | void _ExitProcess(int return_code) { |
mbed_official | 82:0b31dbcd4769 | 24 | mbed_exit(return_code); |
mbed_official | 82:0b31dbcd4769 | 25 | } |
mbed_official | 82:0b31dbcd4769 | 26 | |
mbed_official | 82:0b31dbcd4769 | 27 | void __thumb_startup(void) { |
mbed_official | 82:0b31dbcd4769 | 28 | // Setup registers |
mbed_official | 82:0b31dbcd4769 | 29 | __init_registers(); |
mbed_official | 82:0b31dbcd4769 | 30 | |
mbed_official | 82:0b31dbcd4769 | 31 | // Disable the Watchdog because it may reset the core before entering main(). |
mbed_official | 82:0b31dbcd4769 | 32 | SIM->COPC = 0x0; |
mbed_official | 82:0b31dbcd4769 | 33 | |
mbed_official | 82:0b31dbcd4769 | 34 | // zero-fill the .bss section |
mbed_official | 82:0b31dbcd4769 | 35 | memset(__START_BSS, 0, (__END_BSS - __START_BSS)); |
mbed_official | 82:0b31dbcd4769 | 36 | |
mbed_official | 82:0b31dbcd4769 | 37 | if (__S_romp != 0L) |
mbed_official | 82:0b31dbcd4769 | 38 | __copy_rom_sections_to_ram(); |
mbed_official | 82:0b31dbcd4769 | 39 | |
mbed_official | 82:0b31dbcd4769 | 40 | // call C++ static initializers |
mbed_official | 82:0b31dbcd4769 | 41 | __call_static_initializers(); |
mbed_official | 82:0b31dbcd4769 | 42 | |
mbed_official | 82:0b31dbcd4769 | 43 | // initializations before main, user specific |
mbed_official | 82:0b31dbcd4769 | 44 | __init_user(); |
mbed_official | 82:0b31dbcd4769 | 45 | |
mbed_official | 82:0b31dbcd4769 | 46 | exit(main()); |
mbed_official | 82:0b31dbcd4769 | 47 | |
mbed_official | 82:0b31dbcd4769 | 48 | // should never get here |
mbed_official | 82:0b31dbcd4769 | 49 | while (1); |
mbed_official | 82:0b31dbcd4769 | 50 | } |
mbed_official | 82:0b31dbcd4769 | 51 | |
mbed_official | 82:0b31dbcd4769 | 52 | void Default_Handler() { |
mbed_official | 82:0b31dbcd4769 | 53 | __asm("bkpt"); |
mbed_official | 82:0b31dbcd4769 | 54 | } |
mbed_official | 82:0b31dbcd4769 | 55 | |
mbed_official | 82:0b31dbcd4769 | 56 | /* Weak definitions of handlers point to Default_Handler if not implemented */ |
mbed_official | 82:0b31dbcd4769 | 57 | void NMI_Handler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 58 | void HardFault_Handler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 59 | void SVC_Handler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 60 | void PendSV_Handler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 61 | void SysTick_Handler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 62 | |
mbed_official | 82:0b31dbcd4769 | 63 | void DMA0_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 64 | void DMA1_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 65 | void DMA2_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 66 | void DMA3_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 67 | void MCM_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 68 | void FTFL_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 69 | void PMC_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 70 | void LLW_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 71 | void I2C0_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 72 | void I2C1_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 73 | void SPI0_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 74 | void SPI1_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 75 | void UART0_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 76 | void UART1_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 77 | void UART2_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 78 | void ADC0_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 79 | void CMP0_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 80 | void FTM0_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 81 | void FTM1_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 82 | void FTM2_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 83 | void RTC_Alarm_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 84 | void RTC_Seconds_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 85 | void PIT_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 86 | void USBOTG_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 87 | void DAC0_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 88 | void TSI0_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 89 | void MCG_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 90 | void LPTimer_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 91 | void PORTA_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 92 | void PORTD_IRQHandler() __attribute__ ((weak, alias("Default_Handler"))); |
mbed_official | 82:0b31dbcd4769 | 93 | |
mbed_official | 82:0b31dbcd4769 | 94 | /* The Interrupt Vector Table */ |
mbed_official | 82:0b31dbcd4769 | 95 | void (* const InterruptVector[])() __attribute__ ((section(".vectortable"))) = { |
mbed_official | 82:0b31dbcd4769 | 96 | /* Processor exceptions */ |
mbed_official | 82:0b31dbcd4769 | 97 | (void(*)(void)) &_estack, |
mbed_official | 82:0b31dbcd4769 | 98 | __thumb_startup, |
mbed_official | 82:0b31dbcd4769 | 99 | NMI_Handler, |
mbed_official | 82:0b31dbcd4769 | 100 | HardFault_Handler, |
mbed_official | 82:0b31dbcd4769 | 101 | 0, |
mbed_official | 82:0b31dbcd4769 | 102 | 0, |
mbed_official | 82:0b31dbcd4769 | 103 | 0, |
mbed_official | 82:0b31dbcd4769 | 104 | 0, |
mbed_official | 82:0b31dbcd4769 | 105 | 0, |
mbed_official | 82:0b31dbcd4769 | 106 | 0, |
mbed_official | 82:0b31dbcd4769 | 107 | 0, |
mbed_official | 82:0b31dbcd4769 | 108 | SVC_Handler, |
mbed_official | 82:0b31dbcd4769 | 109 | 0, |
mbed_official | 82:0b31dbcd4769 | 110 | 0, |
mbed_official | 82:0b31dbcd4769 | 111 | PendSV_Handler, |
mbed_official | 82:0b31dbcd4769 | 112 | SysTick_Handler, |
mbed_official | 82:0b31dbcd4769 | 113 | |
mbed_official | 82:0b31dbcd4769 | 114 | /* Interrupts */ |
mbed_official | 82:0b31dbcd4769 | 115 | DMA0_IRQHandler, /* DMA Channel 0 Transfer Complete and Error */ |
mbed_official | 82:0b31dbcd4769 | 116 | DMA1_IRQHandler, /* DMA Channel 1 Transfer Complete and Error */ |
mbed_official | 82:0b31dbcd4769 | 117 | DMA2_IRQHandler, /* DMA Channel 2 Transfer Complete and Error */ |
mbed_official | 82:0b31dbcd4769 | 118 | DMA3_IRQHandler, /* DMA Channel 3 Transfer Complete and Error */ |
mbed_official | 82:0b31dbcd4769 | 119 | MCM_IRQHandler, /* Normal Interrupt */ |
mbed_official | 82:0b31dbcd4769 | 120 | FTFL_IRQHandler, /* FTFL Interrupt */ |
mbed_official | 82:0b31dbcd4769 | 121 | PMC_IRQHandler, /* PMC Interrupt */ |
mbed_official | 82:0b31dbcd4769 | 122 | LLW_IRQHandler, /* Low Leakage Wake-up */ |
mbed_official | 82:0b31dbcd4769 | 123 | I2C0_IRQHandler, /* I2C0 interrupt */ |
mbed_official | 82:0b31dbcd4769 | 124 | I2C1_IRQHandler, /* I2C1 interrupt */ |
mbed_official | 82:0b31dbcd4769 | 125 | SPI0_IRQHandler, /* SPI0 Interrupt */ |
mbed_official | 82:0b31dbcd4769 | 126 | SPI1_IRQHandler, /* SPI1 Interrupt */ |
mbed_official | 82:0b31dbcd4769 | 127 | UART0_IRQHandler, /* UART0 Status and Error interrupt */ |
mbed_official | 82:0b31dbcd4769 | 128 | UART1_IRQHandler, /* UART1 Status and Error interrupt */ |
mbed_official | 82:0b31dbcd4769 | 129 | UART2_IRQHandler, /* UART2 Status and Error interrupt */ |
mbed_official | 82:0b31dbcd4769 | 130 | ADC0_IRQHandler, /* ADC0 interrupt */ |
mbed_official | 82:0b31dbcd4769 | 131 | CMP0_IRQHandler, /* CMP0 interrupt */ |
mbed_official | 82:0b31dbcd4769 | 132 | FTM0_IRQHandler, /* FTM0 fault, overflow and channels interrupt */ |
mbed_official | 82:0b31dbcd4769 | 133 | FTM1_IRQHandler, /* FTM1 fault, overflow and channels interrupt */ |
mbed_official | 82:0b31dbcd4769 | 134 | FTM2_IRQHandler, /* FTM2 fault, overflow and channels interrupt */ |
mbed_official | 82:0b31dbcd4769 | 135 | RTC_Alarm_IRQHandler, /* RTC Alarm interrupt */ |
mbed_official | 82:0b31dbcd4769 | 136 | RTC_Seconds_IRQHandler, /* RTC Seconds interrupt */ |
mbed_official | 82:0b31dbcd4769 | 137 | PIT_IRQHandler, /* PIT timer all channels interrupt */ |
mbed_official | 82:0b31dbcd4769 | 138 | Default_Handler, /* Reserved interrupt 39/23 */ |
mbed_official | 82:0b31dbcd4769 | 139 | USBOTG_IRQHandler, /* USB interrupt */ |
mbed_official | 82:0b31dbcd4769 | 140 | DAC0_IRQHandler, /* DAC0 interrupt */ |
mbed_official | 82:0b31dbcd4769 | 141 | TSI0_IRQHandler, /* TSI0 Interrupt */ |
mbed_official | 82:0b31dbcd4769 | 142 | MCG_IRQHandler, /* MCG Interrupt */ |
mbed_official | 82:0b31dbcd4769 | 143 | LPTimer_IRQHandler, /* LPTimer interrupt */ |
mbed_official | 82:0b31dbcd4769 | 144 | Default_Handler, /* Reserved interrupt 45/29 */ |
mbed_official | 82:0b31dbcd4769 | 145 | PORTA_IRQHandler, /* Port A interrupt */ |
mbed_official | 82:0b31dbcd4769 | 146 | PORTD_IRQHandler /* Port D interrupt */ |
mbed_official | 82:0b31dbcd4769 | 147 | }; |