mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_NXP/TARGET_LPC43XX/TOOLCHAIN_GCC_CR/startup_LPC43xx.cpp@67:78dfdb5b4d9e, 2013-12-24 (annotated)
- Committer:
- mbed_official
- Date:
- Tue Dec 24 21:15:05 2013 +0000
- Revision:
- 67:78dfdb5b4d9e
- Parent:
- 20:4263a77256ae
- Child:
- 256:76fd9a263045
Synchronized with git revision 82aa7b7f2b67dfdef90373b703bb8b2f33ea4e57
Full URL: https://github.com/mbedmicro/mbed/commit/82aa7b7f2b67dfdef90373b703bb8b2f33ea4e57/
1. Provide the required __end__ symbol
2. Call software_init_hook() if present, which in turn starts the RTOS
The fix was applied for all targets with a TOOLCHAIN_GCC_CR folder,
but it only works with LPC1768 and LPC4088 because of incomplete or
missing support for GCC_CR and/or the RTOS for the other targets.
Tested by running RTOS_1, RTOS_2 and RTOS_3 with LPC1768 and LPC4088.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 20:4263a77256ae | 1 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 2 | // +--+ |
bogdanm | 20:4263a77256ae | 3 | // | ++----+ |
bogdanm | 20:4263a77256ae | 4 | // +-++ | |
bogdanm | 20:4263a77256ae | 5 | // | | |
bogdanm | 20:4263a77256ae | 6 | // +-+--+ | |
bogdanm | 20:4263a77256ae | 7 | // | +--+--+ |
bogdanm | 20:4263a77256ae | 8 | // +----+ Copyright (c) 2011-12 Code Red Technologies Ltd. |
bogdanm | 20:4263a77256ae | 9 | // |
bogdanm | 20:4263a77256ae | 10 | // LPC43xx Microcontroller Startup code for use with Red Suite |
bogdanm | 20:4263a77256ae | 11 | // |
bogdanm | 20:4263a77256ae | 12 | // Version : 120430 |
bogdanm | 20:4263a77256ae | 13 | // |
bogdanm | 20:4263a77256ae | 14 | // Software License Agreement |
bogdanm | 20:4263a77256ae | 15 | // |
bogdanm | 20:4263a77256ae | 16 | // The software is owned by Code Red Technologies and/or its suppliers, and is |
bogdanm | 20:4263a77256ae | 17 | // protected under applicable copyright laws. All rights are reserved. Any |
bogdanm | 20:4263a77256ae | 18 | // use in violation of the foregoing restrictions may subject the user to criminal |
bogdanm | 20:4263a77256ae | 19 | // sanctions under applicable laws, as well as to civil liability for the breach |
bogdanm | 20:4263a77256ae | 20 | // of the terms and conditions of this license. |
bogdanm | 20:4263a77256ae | 21 | // |
bogdanm | 20:4263a77256ae | 22 | // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED |
bogdanm | 20:4263a77256ae | 23 | // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF |
bogdanm | 20:4263a77256ae | 24 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. |
bogdanm | 20:4263a77256ae | 25 | // USE OF THIS SOFTWARE FOR COMMERCIAL DEVELOPMENT AND/OR EDUCATION IS SUBJECT |
bogdanm | 20:4263a77256ae | 26 | // TO A CURRENT END USER LICENSE AGREEMENT (COMMERCIAL OR EDUCATIONAL) WITH |
bogdanm | 20:4263a77256ae | 27 | // CODE RED TECHNOLOGIES LTD. |
bogdanm | 20:4263a77256ae | 28 | // |
bogdanm | 20:4263a77256ae | 29 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 30 | #if defined(__cplusplus) |
bogdanm | 20:4263a77256ae | 31 | #ifdef __REDLIB__ |
bogdanm | 20:4263a77256ae | 32 | #error Redlib does not support C++ |
bogdanm | 20:4263a77256ae | 33 | #else |
bogdanm | 20:4263a77256ae | 34 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 35 | // |
bogdanm | 20:4263a77256ae | 36 | // The entry point for the C++ library startup |
bogdanm | 20:4263a77256ae | 37 | // |
bogdanm | 20:4263a77256ae | 38 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 39 | extern "C" { |
bogdanm | 20:4263a77256ae | 40 | extern void __libc_init_array(void); |
bogdanm | 20:4263a77256ae | 41 | |
bogdanm | 20:4263a77256ae | 42 | } |
bogdanm | 20:4263a77256ae | 43 | #endif |
bogdanm | 20:4263a77256ae | 44 | #endif |
bogdanm | 20:4263a77256ae | 45 | |
bogdanm | 20:4263a77256ae | 46 | #define WEAK __attribute__ ((weak)) |
bogdanm | 20:4263a77256ae | 47 | #define ALIAS(f) __attribute__ ((weak, alias(# f))) |
bogdanm | 20:4263a77256ae | 48 | |
bogdanm | 20:4263a77256ae | 49 | //#if defined (__USE_CMSIS) |
bogdanm | 20:4263a77256ae | 50 | #include "LPC43xx.h" |
bogdanm | 20:4263a77256ae | 51 | //#endif |
bogdanm | 20:4263a77256ae | 52 | |
bogdanm | 20:4263a77256ae | 53 | #if defined(OS_UCOS_III) |
bogdanm | 20:4263a77256ae | 54 | extern void OS_CPU_PendSVHandler(void); |
bogdanm | 20:4263a77256ae | 55 | extern void OS_CPU_SysTickHandler (void); |
bogdanm | 20:4263a77256ae | 56 | #endif |
bogdanm | 20:4263a77256ae | 57 | |
bogdanm | 20:4263a77256ae | 58 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 59 | #if defined(__cplusplus) |
bogdanm | 20:4263a77256ae | 60 | extern "C" { |
bogdanm | 20:4263a77256ae | 61 | #endif |
bogdanm | 20:4263a77256ae | 62 | |
bogdanm | 20:4263a77256ae | 63 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 64 | // |
bogdanm | 20:4263a77256ae | 65 | // Forward declaration of the default handlers. These are aliased. |
bogdanm | 20:4263a77256ae | 66 | // When the application defines a handler (with the same name), this will |
bogdanm | 20:4263a77256ae | 67 | // automatically take precedence over these weak definitions |
bogdanm | 20:4263a77256ae | 68 | // |
bogdanm | 20:4263a77256ae | 69 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 70 | void ResetISR(void); |
bogdanm | 20:4263a77256ae | 71 | WEAK void NMI_Handler(void); |
bogdanm | 20:4263a77256ae | 72 | WEAK void HardFault_Handler(void); |
bogdanm | 20:4263a77256ae | 73 | WEAK void MemManage_Handler(void); |
bogdanm | 20:4263a77256ae | 74 | WEAK void BusFault_Handler(void); |
bogdanm | 20:4263a77256ae | 75 | WEAK void UsageFault_Handler(void); |
bogdanm | 20:4263a77256ae | 76 | WEAK void SVC_Handler(void); |
bogdanm | 20:4263a77256ae | 77 | WEAK void DebugMon_Handler(void); |
bogdanm | 20:4263a77256ae | 78 | WEAK void PendSV_Handler(void); |
bogdanm | 20:4263a77256ae | 79 | WEAK void SysTick_Handler(void); |
bogdanm | 20:4263a77256ae | 80 | WEAK void IntDefaultHandler(void); |
bogdanm | 20:4263a77256ae | 81 | |
bogdanm | 20:4263a77256ae | 82 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 83 | // |
bogdanm | 20:4263a77256ae | 84 | // Forward declaration of the specific IRQ handlers. These are aliased |
bogdanm | 20:4263a77256ae | 85 | // to the IntDefaultHandler, which is a 'forever' loop. When the application |
bogdanm | 20:4263a77256ae | 86 | // defines a handler (with the same name), this will automatically take |
bogdanm | 20:4263a77256ae | 87 | // precedence over these weak definitions |
bogdanm | 20:4263a77256ae | 88 | // |
bogdanm | 20:4263a77256ae | 89 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 90 | void DAC_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 91 | void MX_CORE_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 92 | void DMA_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 93 | void FLASHEEPROM_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 94 | void ETH_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 95 | void SDIO_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 96 | void LCD_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 97 | void USB0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 98 | void USB1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 99 | void SCT_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 100 | void RIT_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 101 | void TIMER0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 102 | void TIMER1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 103 | void TIMER2_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 104 | void TIMER3_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 105 | void MCPWM_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 106 | void ADC0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 107 | void I2C0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 108 | void I2C1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 109 | void SPI_IRQHandler (void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 110 | void ADC1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 111 | void SSP0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 112 | void SSP1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 113 | void UART0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 114 | void UART1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 115 | void UART2_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 116 | void UART3_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 117 | void I2S0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 118 | void I2S1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 119 | void SPIFI_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 120 | void SGPIO_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 121 | void GPIO0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 122 | void GPIO1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 123 | void GPIO2_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 124 | void GPIO3_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 125 | void GPIO4_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 126 | void GPIO5_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 127 | void GPIO6_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 128 | void GPIO7_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 129 | void GINT0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 130 | void GINT1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 131 | void EVRT_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 132 | void CAN1_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 133 | void ATIMER_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 134 | void RTC_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 135 | void WDT_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 136 | void CAN0_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 137 | void QEI_IRQHandler(void) ALIAS(IntDefaultHandler); |
bogdanm | 20:4263a77256ae | 138 | |
bogdanm | 20:4263a77256ae | 139 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 140 | // |
bogdanm | 20:4263a77256ae | 141 | // The entry point for the application. |
bogdanm | 20:4263a77256ae | 142 | // __main() is the entry point for Redlib based applications |
bogdanm | 20:4263a77256ae | 143 | // main() is the entry point for Newlib based applications |
bogdanm | 20:4263a77256ae | 144 | // |
bogdanm | 20:4263a77256ae | 145 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 146 | #if defined(__REDLIB__) |
bogdanm | 20:4263a77256ae | 147 | extern void __main(void); |
bogdanm | 20:4263a77256ae | 148 | |
bogdanm | 20:4263a77256ae | 149 | #endif |
bogdanm | 20:4263a77256ae | 150 | extern int main(void); |
bogdanm | 20:4263a77256ae | 151 | |
bogdanm | 20:4263a77256ae | 152 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 153 | // |
bogdanm | 20:4263a77256ae | 154 | // External declaration for the pointer to the stack top from the Linker Script |
bogdanm | 20:4263a77256ae | 155 | // |
bogdanm | 20:4263a77256ae | 156 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 157 | extern void _vStackTop(void); |
bogdanm | 20:4263a77256ae | 158 | |
bogdanm | 20:4263a77256ae | 159 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 160 | // |
bogdanm | 20:4263a77256ae | 161 | // Application can define Stack size (If not defined, default stack size will |
bogdanm | 20:4263a77256ae | 162 | // used |
bogdanm | 20:4263a77256ae | 163 | // |
bogdanm | 20:4263a77256ae | 164 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 165 | #ifndef STACK_SIZE |
bogdanm | 20:4263a77256ae | 166 | #define STACK_SIZE (0x200) |
bogdanm | 20:4263a77256ae | 167 | #endif |
bogdanm | 20:4263a77256ae | 168 | |
bogdanm | 20:4263a77256ae | 169 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 170 | // |
bogdanm | 20:4263a77256ae | 171 | // Application can define Heap size (If not defined, default Heap size will |
bogdanm | 20:4263a77256ae | 172 | // used |
bogdanm | 20:4263a77256ae | 173 | // |
bogdanm | 20:4263a77256ae | 174 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 175 | #ifndef HEAP_SIZE |
bogdanm | 20:4263a77256ae | 176 | #define HEAP_SIZE (0x4000) |
bogdanm | 20:4263a77256ae | 177 | #endif |
bogdanm | 20:4263a77256ae | 178 | |
bogdanm | 20:4263a77256ae | 179 | unsigned int __vStack[STACK_SIZE / sizeof(unsigned int)] __attribute__((section("STACK,\"aw\",%nobits@"))); |
bogdanm | 20:4263a77256ae | 180 | unsigned int __vHeap[HEAP_SIZE / sizeof(unsigned int)] __attribute__((section("HEAP,\"aw\",%nobits@"))); |
bogdanm | 20:4263a77256ae | 181 | |
bogdanm | 20:4263a77256ae | 182 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 183 | #if defined(__cplusplus) |
bogdanm | 20:4263a77256ae | 184 | } // extern "C" |
bogdanm | 20:4263a77256ae | 185 | #endif |
bogdanm | 20:4263a77256ae | 186 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 187 | // |
bogdanm | 20:4263a77256ae | 188 | // The vector table. |
bogdanm | 20:4263a77256ae | 189 | // This relies on the linker script to place at correct location in memory. |
bogdanm | 20:4263a77256ae | 190 | // |
bogdanm | 20:4263a77256ae | 191 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 192 | extern void(*const g_pfnVectors[]) (void); |
bogdanm | 20:4263a77256ae | 193 | __attribute__ ((section(".isr_vector"))) |
bogdanm | 20:4263a77256ae | 194 | void(*const g_pfnVectors[]) (void) = { |
bogdanm | 20:4263a77256ae | 195 | // Core Level - CM4/CM3 |
bogdanm | 20:4263a77256ae | 196 | &_vStackTop, // The initial stack pointer |
bogdanm | 20:4263a77256ae | 197 | ResetISR, // The reset handler |
bogdanm | 20:4263a77256ae | 198 | NMI_Handler, // The NMI handler |
bogdanm | 20:4263a77256ae | 199 | HardFault_Handler, // The hard fault handler |
bogdanm | 20:4263a77256ae | 200 | MemManage_Handler, // The MPU fault handler |
bogdanm | 20:4263a77256ae | 201 | BusFault_Handler, // The bus fault handler |
bogdanm | 20:4263a77256ae | 202 | UsageFault_Handler, // The usage fault handler |
bogdanm | 20:4263a77256ae | 203 | 0, // Reserved |
bogdanm | 20:4263a77256ae | 204 | 0, // Reserved |
bogdanm | 20:4263a77256ae | 205 | 0, // Reserved |
bogdanm | 20:4263a77256ae | 206 | 0, // Reserved |
bogdanm | 20:4263a77256ae | 207 | SVC_Handler, // SVCall handler |
bogdanm | 20:4263a77256ae | 208 | DebugMon_Handler, // Debug monitor handler |
bogdanm | 20:4263a77256ae | 209 | 0, // Reserved |
bogdanm | 20:4263a77256ae | 210 | #if defined(OS_UCOS_III) |
bogdanm | 20:4263a77256ae | 211 | OS_CPU_PendSVHandler, // uCOS-III PendSV handler |
bogdanm | 20:4263a77256ae | 212 | OS_CPU_SysTickHandler, // uCOS-III SysTick handler |
bogdanm | 20:4263a77256ae | 213 | #else |
bogdanm | 20:4263a77256ae | 214 | PendSV_Handler, // The PendSV handler |
bogdanm | 20:4263a77256ae | 215 | SysTick_Handler, // The SysTick handler |
bogdanm | 20:4263a77256ae | 216 | #endif |
bogdanm | 20:4263a77256ae | 217 | |
bogdanm | 20:4263a77256ae | 218 | // Chip Level - LPC18xx/43xx |
bogdanm | 20:4263a77256ae | 219 | DAC_IRQHandler, // 16 D/A Converter |
bogdanm | 20:4263a77256ae | 220 | MX_CORE_IRQHandler, // 17 CortexM4/M0 (LPC43XX ONLY) |
bogdanm | 20:4263a77256ae | 221 | DMA_IRQHandler, // 18 General Purpose DMA |
bogdanm | 20:4263a77256ae | 222 | 0, // 19 Reserved |
bogdanm | 20:4263a77256ae | 223 | FLASHEEPROM_IRQHandler, // 20 ORed flash Bank A, flash Bank B, EEPROM interrupts |
bogdanm | 20:4263a77256ae | 224 | ETH_IRQHandler, // 21 Ethernet |
bogdanm | 20:4263a77256ae | 225 | SDIO_IRQHandler, // 22 SD/MMC |
bogdanm | 20:4263a77256ae | 226 | LCD_IRQHandler, // 23 LCD |
bogdanm | 20:4263a77256ae | 227 | USB0_IRQHandler, // 24 USB0 |
bogdanm | 20:4263a77256ae | 228 | USB1_IRQHandler, // 25 USB1 |
bogdanm | 20:4263a77256ae | 229 | SCT_IRQHandler, // 26 State Configurable Timer |
bogdanm | 20:4263a77256ae | 230 | RIT_IRQHandler, // 27 Repetitive Interrupt Timer |
bogdanm | 20:4263a77256ae | 231 | TIMER0_IRQHandler, // 28 Timer0 |
bogdanm | 20:4263a77256ae | 232 | TIMER1_IRQHandler, // 29 Timer 1 |
bogdanm | 20:4263a77256ae | 233 | TIMER2_IRQHandler, // 30 Timer 2 |
bogdanm | 20:4263a77256ae | 234 | TIMER3_IRQHandler, // 31 Timer 3 |
bogdanm | 20:4263a77256ae | 235 | MCPWM_IRQHandler, // 32 Motor Control PWM |
bogdanm | 20:4263a77256ae | 236 | ADC0_IRQHandler, // 33 A/D Converter 0 |
bogdanm | 20:4263a77256ae | 237 | I2C0_IRQHandler, // 34 I2C0 |
bogdanm | 20:4263a77256ae | 238 | I2C1_IRQHandler, // 35 I2C1 |
bogdanm | 20:4263a77256ae | 239 | SPI_IRQHandler, // 36 SPI (LPC43XX ONLY) |
bogdanm | 20:4263a77256ae | 240 | ADC1_IRQHandler, // 37 A/D Converter 1 |
bogdanm | 20:4263a77256ae | 241 | SSP0_IRQHandler, // 38 SSP0 |
bogdanm | 20:4263a77256ae | 242 | SSP1_IRQHandler, // 39 SSP1 |
bogdanm | 20:4263a77256ae | 243 | UART0_IRQHandler, // 40 UART0 |
bogdanm | 20:4263a77256ae | 244 | UART1_IRQHandler, // 41 UART1 |
bogdanm | 20:4263a77256ae | 245 | UART2_IRQHandler, // 42 UART2 |
bogdanm | 20:4263a77256ae | 246 | UART3_IRQHandler, // 43 USRT3 |
bogdanm | 20:4263a77256ae | 247 | I2S0_IRQHandler, // 44 I2S0 |
bogdanm | 20:4263a77256ae | 248 | I2S1_IRQHandler, // 45 I2S1 |
bogdanm | 20:4263a77256ae | 249 | SPIFI_IRQHandler, // 46 SPI Flash Interface |
bogdanm | 20:4263a77256ae | 250 | SGPIO_IRQHandler, // 47 SGPIO (LPC43XX ONLY) |
bogdanm | 20:4263a77256ae | 251 | GPIO0_IRQHandler, // 48 GPIO0 |
bogdanm | 20:4263a77256ae | 252 | GPIO1_IRQHandler, // 49 GPIO1 |
bogdanm | 20:4263a77256ae | 253 | GPIO2_IRQHandler, // 50 GPIO2 |
bogdanm | 20:4263a77256ae | 254 | GPIO3_IRQHandler, // 51 GPIO3 |
bogdanm | 20:4263a77256ae | 255 | GPIO4_IRQHandler, // 52 GPIO4 |
bogdanm | 20:4263a77256ae | 256 | GPIO5_IRQHandler, // 53 GPIO5 |
bogdanm | 20:4263a77256ae | 257 | GPIO6_IRQHandler, // 54 GPIO6 |
bogdanm | 20:4263a77256ae | 258 | GPIO7_IRQHandler, // 55 GPIO7 |
bogdanm | 20:4263a77256ae | 259 | GINT0_IRQHandler, // 56 GINT0 |
bogdanm | 20:4263a77256ae | 260 | GINT1_IRQHandler, // 57 GINT1 |
bogdanm | 20:4263a77256ae | 261 | EVRT_IRQHandler, // 58 Event Router |
bogdanm | 20:4263a77256ae | 262 | CAN1_IRQHandler, // 59 C_CAN1 |
bogdanm | 20:4263a77256ae | 263 | 0, // 60 Reserved |
bogdanm | 20:4263a77256ae | 264 | 0, // 61 Reserved |
bogdanm | 20:4263a77256ae | 265 | ATIMER_IRQHandler, // 62 ATIMER |
bogdanm | 20:4263a77256ae | 266 | RTC_IRQHandler, // 63 RTC |
bogdanm | 20:4263a77256ae | 267 | 0, // 64 Reserved |
bogdanm | 20:4263a77256ae | 268 | WDT_IRQHandler, // 65 WDT |
bogdanm | 20:4263a77256ae | 269 | 0, // 66 Reserved |
bogdanm | 20:4263a77256ae | 270 | CAN0_IRQHandler, // 67 C_CAN0 |
bogdanm | 20:4263a77256ae | 271 | QEI_IRQHandler, // 68 QEI |
bogdanm | 20:4263a77256ae | 272 | }; |
bogdanm | 20:4263a77256ae | 273 | |
bogdanm | 20:4263a77256ae | 274 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 275 | // Functions to carry out the initialization of RW and BSS data sections. These |
bogdanm | 20:4263a77256ae | 276 | // are written as separate functions rather than being inlined within the |
bogdanm | 20:4263a77256ae | 277 | // ResetISR() function in order to cope with MCUs with multiple banks of |
bogdanm | 20:4263a77256ae | 278 | // memory. |
bogdanm | 20:4263a77256ae | 279 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 280 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 281 | void data_init(unsigned int romstart, unsigned int start, unsigned int len) { |
bogdanm | 20:4263a77256ae | 282 | unsigned int *pulDest = (unsigned int *) start; |
bogdanm | 20:4263a77256ae | 283 | unsigned int *pulSrc = (unsigned int *) romstart; |
bogdanm | 20:4263a77256ae | 284 | unsigned int loop; |
bogdanm | 20:4263a77256ae | 285 | for (loop = 0; loop < len; loop = loop + 4) |
bogdanm | 20:4263a77256ae | 286 | *pulDest++ = *pulSrc++; |
bogdanm | 20:4263a77256ae | 287 | } |
bogdanm | 20:4263a77256ae | 288 | |
bogdanm | 20:4263a77256ae | 289 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 290 | void bss_init(unsigned int start, unsigned int len) { |
bogdanm | 20:4263a77256ae | 291 | unsigned int *pulDest = (unsigned int *) start; |
bogdanm | 20:4263a77256ae | 292 | unsigned int loop; |
bogdanm | 20:4263a77256ae | 293 | for (loop = 0; loop < len; loop = loop + 4) |
bogdanm | 20:4263a77256ae | 294 | *pulDest++ = 0; |
bogdanm | 20:4263a77256ae | 295 | } |
bogdanm | 20:4263a77256ae | 296 | |
bogdanm | 20:4263a77256ae | 297 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 298 | // The following symbols are constructs generated by the linker, indicating |
bogdanm | 20:4263a77256ae | 299 | // the location of various points in the "Global Section Table". This table is |
bogdanm | 20:4263a77256ae | 300 | // created by the linker via the Code Red managed linker script mechanism. It |
bogdanm | 20:4263a77256ae | 301 | // contains the load address, execution address and length of each RW data |
bogdanm | 20:4263a77256ae | 302 | // section and the execution and length of each BSS (zero initialized) section. |
bogdanm | 20:4263a77256ae | 303 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 304 | extern unsigned int __data_section_table; |
bogdanm | 20:4263a77256ae | 305 | extern unsigned int __data_section_table_end; |
bogdanm | 20:4263a77256ae | 306 | extern unsigned int __bss_section_table; |
bogdanm | 20:4263a77256ae | 307 | extern unsigned int __bss_section_table_end; |
bogdanm | 20:4263a77256ae | 308 | |
bogdanm | 20:4263a77256ae | 309 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 310 | // Reset entry point for your code. |
bogdanm | 20:4263a77256ae | 311 | // Sets up a simple runtime environment and initializes the C/C++ |
bogdanm | 20:4263a77256ae | 312 | // library. |
bogdanm | 20:4263a77256ae | 313 | // |
bogdanm | 20:4263a77256ae | 314 | // ***************************************************************************** |
mbed_official | 67:78dfdb5b4d9e | 315 | |
mbed_official | 67:78dfdb5b4d9e | 316 | extern "C" void software_init_hook(void) __attribute__((weak)); |
mbed_official | 67:78dfdb5b4d9e | 317 | |
bogdanm | 20:4263a77256ae | 318 | void |
bogdanm | 20:4263a77256ae | 319 | ResetISR(void) { |
bogdanm | 20:4263a77256ae | 320 | |
bogdanm | 20:4263a77256ae | 321 | // |
bogdanm | 20:4263a77256ae | 322 | // Copy the data sections from flash to SRAM. |
bogdanm | 20:4263a77256ae | 323 | // |
bogdanm | 20:4263a77256ae | 324 | unsigned int LoadAddr, ExeAddr, SectionLen; |
bogdanm | 20:4263a77256ae | 325 | unsigned int *SectionTableAddr; |
bogdanm | 20:4263a77256ae | 326 | |
bogdanm | 20:4263a77256ae | 327 | /* Call SystemInit() for clocking/memory setup prior to scatter load */ |
bogdanm | 20:4263a77256ae | 328 | SystemInit(); |
bogdanm | 20:4263a77256ae | 329 | |
bogdanm | 20:4263a77256ae | 330 | // Load base address of Global Section Table |
bogdanm | 20:4263a77256ae | 331 | SectionTableAddr = &__data_section_table; |
bogdanm | 20:4263a77256ae | 332 | |
bogdanm | 20:4263a77256ae | 333 | // Copy the data sections from flash to SRAM. |
bogdanm | 20:4263a77256ae | 334 | while (SectionTableAddr < &__data_section_table_end) { |
bogdanm | 20:4263a77256ae | 335 | LoadAddr = *SectionTableAddr++; |
bogdanm | 20:4263a77256ae | 336 | ExeAddr = *SectionTableAddr++; |
bogdanm | 20:4263a77256ae | 337 | SectionLen = *SectionTableAddr++; |
bogdanm | 20:4263a77256ae | 338 | data_init(LoadAddr, ExeAddr, SectionLen); |
bogdanm | 20:4263a77256ae | 339 | } |
bogdanm | 20:4263a77256ae | 340 | // At this point, SectionTableAddr = &__bss_section_table; |
bogdanm | 20:4263a77256ae | 341 | // Zero fill the bss segment |
bogdanm | 20:4263a77256ae | 342 | while (SectionTableAddr < &__bss_section_table_end) { |
bogdanm | 20:4263a77256ae | 343 | ExeAddr = *SectionTableAddr++; |
bogdanm | 20:4263a77256ae | 344 | SectionLen = *SectionTableAddr++; |
bogdanm | 20:4263a77256ae | 345 | bss_init(ExeAddr, SectionLen); |
bogdanm | 20:4263a77256ae | 346 | } |
bogdanm | 20:4263a77256ae | 347 | |
mbed_official | 67:78dfdb5b4d9e | 348 | if (software_init_hook) // give control to the RTOS |
mbed_official | 67:78dfdb5b4d9e | 349 | software_init_hook(); // this will also call __libc_init_array |
mbed_official | 67:78dfdb5b4d9e | 350 | else { |
mbed_official | 67:78dfdb5b4d9e | 351 | #if defined(__cplusplus) |
mbed_official | 67:78dfdb5b4d9e | 352 | // |
mbed_official | 67:78dfdb5b4d9e | 353 | // Call C++ library initialisation |
mbed_official | 67:78dfdb5b4d9e | 354 | // |
mbed_official | 67:78dfdb5b4d9e | 355 | __libc_init_array(); |
mbed_official | 67:78dfdb5b4d9e | 356 | #endif |
bogdanm | 20:4263a77256ae | 357 | |
mbed_official | 67:78dfdb5b4d9e | 358 | #if defined(__REDLIB__) |
mbed_official | 67:78dfdb5b4d9e | 359 | // Call the Redlib library, which in turn calls main() |
mbed_official | 67:78dfdb5b4d9e | 360 | __main(); |
mbed_official | 67:78dfdb5b4d9e | 361 | #else |
mbed_official | 67:78dfdb5b4d9e | 362 | main(); |
mbed_official | 67:78dfdb5b4d9e | 363 | #endif |
mbed_official | 67:78dfdb5b4d9e | 364 | } |
bogdanm | 20:4263a77256ae | 365 | // |
bogdanm | 20:4263a77256ae | 366 | // main() shouldn't return, but if it does, we'll just enter an infinite loop |
bogdanm | 20:4263a77256ae | 367 | // |
bogdanm | 20:4263a77256ae | 368 | while (1) {} |
bogdanm | 20:4263a77256ae | 369 | } |
bogdanm | 20:4263a77256ae | 370 | |
bogdanm | 20:4263a77256ae | 371 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 372 | // Default exception handlers. Override the ones here by defining your own |
bogdanm | 20:4263a77256ae | 373 | // handler routines in your application code. |
bogdanm | 20:4263a77256ae | 374 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 375 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 376 | void NMI_Handler(void) |
bogdanm | 20:4263a77256ae | 377 | { |
bogdanm | 20:4263a77256ae | 378 | while (1) {} |
bogdanm | 20:4263a77256ae | 379 | } |
bogdanm | 20:4263a77256ae | 380 | |
bogdanm | 20:4263a77256ae | 381 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 382 | void HardFault_Handler(void) |
bogdanm | 20:4263a77256ae | 383 | { |
bogdanm | 20:4263a77256ae | 384 | while (1) {} |
bogdanm | 20:4263a77256ae | 385 | } |
bogdanm | 20:4263a77256ae | 386 | |
bogdanm | 20:4263a77256ae | 387 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 388 | void MemManage_Handler(void) |
bogdanm | 20:4263a77256ae | 389 | { |
bogdanm | 20:4263a77256ae | 390 | while (1) {} |
bogdanm | 20:4263a77256ae | 391 | } |
bogdanm | 20:4263a77256ae | 392 | |
bogdanm | 20:4263a77256ae | 393 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 394 | void BusFault_Handler(void) |
bogdanm | 20:4263a77256ae | 395 | { |
bogdanm | 20:4263a77256ae | 396 | while (1) {} |
bogdanm | 20:4263a77256ae | 397 | } |
bogdanm | 20:4263a77256ae | 398 | |
bogdanm | 20:4263a77256ae | 399 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 400 | void UsageFault_Handler(void) |
bogdanm | 20:4263a77256ae | 401 | { |
bogdanm | 20:4263a77256ae | 402 | while (1) {} |
bogdanm | 20:4263a77256ae | 403 | } |
bogdanm | 20:4263a77256ae | 404 | |
bogdanm | 20:4263a77256ae | 405 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 406 | void SVC_Handler(void) |
bogdanm | 20:4263a77256ae | 407 | { |
bogdanm | 20:4263a77256ae | 408 | while (1) {} |
bogdanm | 20:4263a77256ae | 409 | } |
bogdanm | 20:4263a77256ae | 410 | |
bogdanm | 20:4263a77256ae | 411 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 412 | void DebugMon_Handler(void) |
bogdanm | 20:4263a77256ae | 413 | { |
bogdanm | 20:4263a77256ae | 414 | while (1) {} |
bogdanm | 20:4263a77256ae | 415 | } |
bogdanm | 20:4263a77256ae | 416 | |
bogdanm | 20:4263a77256ae | 417 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 418 | void PendSV_Handler(void) |
bogdanm | 20:4263a77256ae | 419 | { |
bogdanm | 20:4263a77256ae | 420 | while (1) {} |
bogdanm | 20:4263a77256ae | 421 | } |
bogdanm | 20:4263a77256ae | 422 | |
bogdanm | 20:4263a77256ae | 423 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 424 | void SysTick_Handler(void) |
bogdanm | 20:4263a77256ae | 425 | { |
bogdanm | 20:4263a77256ae | 426 | while (1) {} |
bogdanm | 20:4263a77256ae | 427 | } |
bogdanm | 20:4263a77256ae | 428 | |
bogdanm | 20:4263a77256ae | 429 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 430 | // |
bogdanm | 20:4263a77256ae | 431 | // Processor ends up here if an unexpected interrupt occurs or a specific |
bogdanm | 20:4263a77256ae | 432 | // handler is not present in the application code. |
bogdanm | 20:4263a77256ae | 433 | // |
bogdanm | 20:4263a77256ae | 434 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 435 | __attribute__ ((section(".after_vectors"))) |
bogdanm | 20:4263a77256ae | 436 | void IntDefaultHandler(void) |
bogdanm | 20:4263a77256ae | 437 | { |
bogdanm | 20:4263a77256ae | 438 | while (1) {} |
bogdanm | 20:4263a77256ae | 439 | } |
bogdanm | 20:4263a77256ae | 440 | |
bogdanm | 20:4263a77256ae | 441 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 442 | // |
bogdanm | 20:4263a77256ae | 443 | // Heap overflow check function required by REDLib_V2 library |
bogdanm | 20:4263a77256ae | 444 | // |
bogdanm | 20:4263a77256ae | 445 | // ***************************************************************************** |
bogdanm | 20:4263a77256ae | 446 | extern unsigned int *_pvHeapStart; |
bogdanm | 20:4263a77256ae | 447 | unsigned int __check_heap_overflow (void * new_end_of_heap) |
bogdanm | 20:4263a77256ae | 448 | { |
bogdanm | 20:4263a77256ae | 449 | return (new_end_of_heap >= (void *)&__vHeap[HEAP_SIZE/sizeof(unsigned int)]); |
bogdanm | 20:4263a77256ae | 450 | } |
bogdanm | 20:4263a77256ae | 451 |