mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
bogdanm
Date:
Wed Aug 07 16:43:59 2013 +0300
Revision:
15:4892fe388435
Child:
67:78dfdb5b4d9e
Added LPC4088 target and interrupt chaining code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 15:4892fe388435 1 //*****************************************************************************
bogdanm 15:4892fe388435 2 // +--+
bogdanm 15:4892fe388435 3 // | ++----+
bogdanm 15:4892fe388435 4 // +-++ |
bogdanm 15:4892fe388435 5 // | |
bogdanm 15:4892fe388435 6 // +-+--+ |
bogdanm 15:4892fe388435 7 // | +--+--+
bogdanm 15:4892fe388435 8 // +----+ Copyright (c) 2012 Code Red Technologies Ltd.
bogdanm 15:4892fe388435 9 //
bogdanm 15:4892fe388435 10 // LPC407x_8x Microcontroller Startup code for use with Red Suite
bogdanm 15:4892fe388435 11 //
bogdanm 15:4892fe388435 12 // Version : 120624
bogdanm 15:4892fe388435 13 //
bogdanm 15:4892fe388435 14 // Software License Agreement
bogdanm 15:4892fe388435 15 //
bogdanm 15:4892fe388435 16 // The software is owned by Code Red Technologies and/or its suppliers, and is
bogdanm 15:4892fe388435 17 // protected under applicable copyright laws. All rights are reserved. Any
bogdanm 15:4892fe388435 18 // use in violation of the foregoing restrictions may subject the user to criminal
bogdanm 15:4892fe388435 19 // sanctions under applicable laws, as well as to civil liability for the breach
bogdanm 15:4892fe388435 20 // of the terms and conditions of this license.
bogdanm 15:4892fe388435 21 //
bogdanm 15:4892fe388435 22 // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
bogdanm 15:4892fe388435 23 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
bogdanm 15:4892fe388435 24 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
bogdanm 15:4892fe388435 25 // USE OF THIS SOFTWARE FOR COMMERCIAL DEVELOPMENT AND/OR EDUCATION IS SUBJECT
bogdanm 15:4892fe388435 26 // TO A CURRENT END USER LICENSE AGREEMENT (COMMERCIAL OR EDUCATIONAL) WITH
bogdanm 15:4892fe388435 27 // CODE RED TECHNOLOGIES LTD.
bogdanm 15:4892fe388435 28 //
bogdanm 15:4892fe388435 29 //*****************************************************************************
bogdanm 15:4892fe388435 30 #if defined (__cplusplus)
bogdanm 15:4892fe388435 31 #ifdef __REDLIB__
bogdanm 15:4892fe388435 32 #error Redlib does not support C++
bogdanm 15:4892fe388435 33 #else
bogdanm 15:4892fe388435 34 //*****************************************************************************
bogdanm 15:4892fe388435 35 //
bogdanm 15:4892fe388435 36 // The entry point for the C++ library startup
bogdanm 15:4892fe388435 37 //
bogdanm 15:4892fe388435 38 //*****************************************************************************
bogdanm 15:4892fe388435 39 extern "C" {
bogdanm 15:4892fe388435 40 extern void __libc_init_array(void);
bogdanm 15:4892fe388435 41 }
bogdanm 15:4892fe388435 42 #endif
bogdanm 15:4892fe388435 43 #endif
bogdanm 15:4892fe388435 44
bogdanm 15:4892fe388435 45 #define WEAK __attribute__ ((weak))
bogdanm 15:4892fe388435 46 #define ALIAS(f) __attribute__ ((weak, alias (#f)))
bogdanm 15:4892fe388435 47
bogdanm 15:4892fe388435 48 //#if defined (__USE_CMSIS)
bogdanm 15:4892fe388435 49 #include "LPC407x_8x_177x_8x.h"
bogdanm 15:4892fe388435 50 //#endif
bogdanm 15:4892fe388435 51
bogdanm 15:4892fe388435 52 //*****************************************************************************
bogdanm 15:4892fe388435 53 #if defined (__cplusplus)
bogdanm 15:4892fe388435 54 extern "C" {
bogdanm 15:4892fe388435 55 #endif
bogdanm 15:4892fe388435 56
bogdanm 15:4892fe388435 57 //*****************************************************************************
bogdanm 15:4892fe388435 58 //
bogdanm 15:4892fe388435 59 // Forward declaration of the default handlers. These are aliased.
bogdanm 15:4892fe388435 60 // When the application defines a handler (with the same name), this will
bogdanm 15:4892fe388435 61 // automatically take precedence over these weak definitions
bogdanm 15:4892fe388435 62 //
bogdanm 15:4892fe388435 63 //*****************************************************************************
bogdanm 15:4892fe388435 64 void ResetISR(void);
bogdanm 15:4892fe388435 65 WEAK void NMI_Handler(void);
bogdanm 15:4892fe388435 66 WEAK void HardFault_Handler(void);
bogdanm 15:4892fe388435 67 WEAK void MemManage_Handler(void);
bogdanm 15:4892fe388435 68 WEAK void BusFault_Handler(void);
bogdanm 15:4892fe388435 69 WEAK void UsageFault_Handler(void);
bogdanm 15:4892fe388435 70 WEAK void SVC_Handler(void);
bogdanm 15:4892fe388435 71 WEAK void DebugMon_Handler(void);
bogdanm 15:4892fe388435 72 WEAK void PendSV_Handler(void);
bogdanm 15:4892fe388435 73 WEAK void SysTick_Handler(void);
bogdanm 15:4892fe388435 74 WEAK void IntDefaultHandler(void);
bogdanm 15:4892fe388435 75
bogdanm 15:4892fe388435 76 //*****************************************************************************
bogdanm 15:4892fe388435 77 //
bogdanm 15:4892fe388435 78 // Forward declaration of the specific IRQ handlers. These are aliased
bogdanm 15:4892fe388435 79 // to the IntDefaultHandler, which is a 'forever' loop. When the application
bogdanm 15:4892fe388435 80 // defines a handler (with the same name), this will automatically take
bogdanm 15:4892fe388435 81 // precedence over these weak definitions
bogdanm 15:4892fe388435 82 //
bogdanm 15:4892fe388435 83 //*****************************************************************************
bogdanm 15:4892fe388435 84 void WDT_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 85 void TIMER0_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 86 void TIMER1_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 87 void TIMER2_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 88 void TIMER3_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 89 void UART0_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 90 void UART1_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 91 void UART2_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 92 void UART3_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 93 void PWM1_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 94 void I2C0_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 95 void I2C1_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 96 void I2C2_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 97 void SPI_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 98 void SSP0_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 99 void SSP1_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 100 void PLL0_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 101 void RTC_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 102 void EINT0_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 103 void EINT1_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 104 void EINT2_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 105 void EINT3_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 106 void ADC_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 107 void BOD_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 108 void USB_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 109 void CAN_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 110 void DMA_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 111 void I2S_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 112 void ENET_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 113 void RIT_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 114 void MCPWM_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 115 void QEI_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 116 void PLL1_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 117 void USBActivity_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 118 void CANActivity_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 119 void MCI_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 120 void UART4_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 121 void SSP2_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 122 void LCD_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 123 void GPIO_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 124 void PWM0_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 125 void EEPROM_IRQHandler(void) ALIAS(IntDefaultHandler);
bogdanm 15:4892fe388435 126
bogdanm 15:4892fe388435 127 //*****************************************************************************
bogdanm 15:4892fe388435 128 //
bogdanm 15:4892fe388435 129 // The entry point for the application.
bogdanm 15:4892fe388435 130 // __main() is the entry point for Redlib based applications
bogdanm 15:4892fe388435 131 // main() is the entry point for Newlib based applications
bogdanm 15:4892fe388435 132 //
bogdanm 15:4892fe388435 133 //*****************************************************************************
bogdanm 15:4892fe388435 134 #if defined (__REDLIB__)
bogdanm 15:4892fe388435 135 extern void __main(void);
bogdanm 15:4892fe388435 136 #endif
bogdanm 15:4892fe388435 137 extern int main(void);
bogdanm 15:4892fe388435 138 //*****************************************************************************
bogdanm 15:4892fe388435 139 //
bogdanm 15:4892fe388435 140 // External declaration for the pointer to the stack top from the Linker Script
bogdanm 15:4892fe388435 141 //
bogdanm 15:4892fe388435 142 //*****************************************************************************
bogdanm 15:4892fe388435 143 extern void _vStackTop(void);
bogdanm 15:4892fe388435 144
bogdanm 15:4892fe388435 145 //*****************************************************************************
bogdanm 15:4892fe388435 146 #if defined (__cplusplus)
bogdanm 15:4892fe388435 147 } // extern "C"
bogdanm 15:4892fe388435 148 #endif
bogdanm 15:4892fe388435 149 //*****************************************************************************
bogdanm 15:4892fe388435 150 //
bogdanm 15:4892fe388435 151 // The vector table.
bogdanm 15:4892fe388435 152 // This relies on the linker script to place at correct location in memory.
bogdanm 15:4892fe388435 153 //
bogdanm 15:4892fe388435 154 //*****************************************************************************
bogdanm 15:4892fe388435 155 extern void (* const g_pfnVectors[])(void);
bogdanm 15:4892fe388435 156 __attribute__ ((section(".isr_vector")))
bogdanm 15:4892fe388435 157 void (* const g_pfnVectors[])(void) = {
bogdanm 15:4892fe388435 158 // Core Level - CM3
bogdanm 15:4892fe388435 159 &_vStackTop, // The initial stack pointer
bogdanm 15:4892fe388435 160 ResetISR, // The reset handler
bogdanm 15:4892fe388435 161 NMI_Handler, // The NMI handler
bogdanm 15:4892fe388435 162 HardFault_Handler, // The hard fault handler
bogdanm 15:4892fe388435 163 MemManage_Handler, // The MPU fault handler
bogdanm 15:4892fe388435 164 BusFault_Handler, // The bus fault handler
bogdanm 15:4892fe388435 165 UsageFault_Handler, // The usage fault handler
bogdanm 15:4892fe388435 166 0, // Reserved
bogdanm 15:4892fe388435 167 0, // Reserved
bogdanm 15:4892fe388435 168 0, // Reserved
bogdanm 15:4892fe388435 169 0, // Reserved
bogdanm 15:4892fe388435 170 SVC_Handler, // SVCall handler
bogdanm 15:4892fe388435 171 DebugMon_Handler, // Debug monitor handler
bogdanm 15:4892fe388435 172 0, // Reserved
bogdanm 15:4892fe388435 173 PendSV_Handler, // The PendSV handler
bogdanm 15:4892fe388435 174 SysTick_Handler, // The SysTick handler
bogdanm 15:4892fe388435 175
bogdanm 15:4892fe388435 176 // Chip Level - LPC17
bogdanm 15:4892fe388435 177 WDT_IRQHandler, // 16, 0x40 - WDT
bogdanm 15:4892fe388435 178 TIMER0_IRQHandler, // 17, 0x44 - TIMER0
bogdanm 15:4892fe388435 179 TIMER1_IRQHandler, // 18, 0x48 - TIMER1
bogdanm 15:4892fe388435 180 TIMER2_IRQHandler, // 19, 0x4c - TIMER2
bogdanm 15:4892fe388435 181 TIMER3_IRQHandler, // 20, 0x50 - TIMER3
bogdanm 15:4892fe388435 182 UART0_IRQHandler, // 21, 0x54 - UART0
bogdanm 15:4892fe388435 183 UART1_IRQHandler, // 22, 0x58 - UART1
bogdanm 15:4892fe388435 184 UART2_IRQHandler, // 23, 0x5c - UART2
bogdanm 15:4892fe388435 185 UART3_IRQHandler, // 24, 0x60 - UART3
bogdanm 15:4892fe388435 186 PWM1_IRQHandler, // 25, 0x64 - PWM1
bogdanm 15:4892fe388435 187 I2C0_IRQHandler, // 26, 0x68 - I2C0
bogdanm 15:4892fe388435 188 I2C1_IRQHandler, // 27, 0x6c - I2C1
bogdanm 15:4892fe388435 189 I2C2_IRQHandler, // 28, 0x70 - I2C2
bogdanm 15:4892fe388435 190 IntDefaultHandler, // 29, Not used
bogdanm 15:4892fe388435 191 SSP0_IRQHandler, // 30, 0x78 - SSP0
bogdanm 15:4892fe388435 192 SSP1_IRQHandler, // 31, 0x7c - SSP1
bogdanm 15:4892fe388435 193 PLL0_IRQHandler, // 32, 0x80 - PLL0 (Main PLL)
bogdanm 15:4892fe388435 194 RTC_IRQHandler, // 33, 0x84 - RTC
bogdanm 15:4892fe388435 195 EINT0_IRQHandler, // 34, 0x88 - EINT0
bogdanm 15:4892fe388435 196 EINT1_IRQHandler, // 35, 0x8c - EINT1
bogdanm 15:4892fe388435 197 EINT2_IRQHandler, // 36, 0x90 - EINT2
bogdanm 15:4892fe388435 198 EINT3_IRQHandler, // 37, 0x94 - EINT3
bogdanm 15:4892fe388435 199 ADC_IRQHandler, // 38, 0x98 - ADC
bogdanm 15:4892fe388435 200 BOD_IRQHandler, // 39, 0x9c - BOD
bogdanm 15:4892fe388435 201 USB_IRQHandler, // 40, 0xA0 - USB
bogdanm 15:4892fe388435 202 CAN_IRQHandler, // 41, 0xa4 - CAN
bogdanm 15:4892fe388435 203 DMA_IRQHandler, // 42, 0xa8 - GP DMA
bogdanm 15:4892fe388435 204 I2S_IRQHandler, // 43, 0xac - I2S
bogdanm 15:4892fe388435 205 ENET_IRQHandler, // 44, 0xb0 - Ethernet
bogdanm 15:4892fe388435 206 MCI_IRQHandler, // 45, 0xb4 - SD/MMC card I/F
bogdanm 15:4892fe388435 207 MCPWM_IRQHandler, // 46, 0xb8 - Motor Control PWM
bogdanm 15:4892fe388435 208 QEI_IRQHandler, // 47, 0xbc - Quadrature Encoder
bogdanm 15:4892fe388435 209 PLL1_IRQHandler, // 48, 0xc0 - PLL1 (USB PLL)
bogdanm 15:4892fe388435 210 USBActivity_IRQHandler, // 49, 0xc4 - USB Activity interrupt to wakeup
bogdanm 15:4892fe388435 211 CANActivity_IRQHandler, // 50, 0xc8 - CAN Activity interrupt to wakeup
bogdanm 15:4892fe388435 212 UART4_IRQHandler, // 51, 0xcc - UART4
bogdanm 15:4892fe388435 213
bogdanm 15:4892fe388435 214 SSP2_IRQHandler, // 52, 0xd0 - SSP2
bogdanm 15:4892fe388435 215 LCD_IRQHandler, // 53, 0xd4 - LCD
bogdanm 15:4892fe388435 216 GPIO_IRQHandler, // 54, 0xd8 - GPIO
bogdanm 15:4892fe388435 217 PWM0_IRQHandler, // 55, 0xdc - PWM0
bogdanm 15:4892fe388435 218 EEPROM_IRQHandler, // 56, 0xe0 - EEPROM
bogdanm 15:4892fe388435 219
bogdanm 15:4892fe388435 220 };
bogdanm 15:4892fe388435 221
bogdanm 15:4892fe388435 222 //*****************************************************************************
bogdanm 15:4892fe388435 223 // Functions to carry out the initialization of RW and BSS data sections. These
bogdanm 15:4892fe388435 224 // are written as separate functions rather than being inlined within the
bogdanm 15:4892fe388435 225 // ResetISR() function in order to cope with MCUs with multiple banks of
bogdanm 15:4892fe388435 226 // memory.
bogdanm 15:4892fe388435 227 //*****************************************************************************
bogdanm 15:4892fe388435 228 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 229 void data_init(unsigned int romstart, unsigned int start, unsigned int len) {
bogdanm 15:4892fe388435 230 unsigned int *pulDest = (unsigned int*) start;
bogdanm 15:4892fe388435 231 unsigned int *pulSrc = (unsigned int*) romstart;
bogdanm 15:4892fe388435 232 unsigned int loop;
bogdanm 15:4892fe388435 233 for (loop = 0; loop < len; loop = loop + 4)
bogdanm 15:4892fe388435 234 *pulDest++ = *pulSrc++;
bogdanm 15:4892fe388435 235 }
bogdanm 15:4892fe388435 236
bogdanm 15:4892fe388435 237 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 238 void bss_init(unsigned int start, unsigned int len) {
bogdanm 15:4892fe388435 239 unsigned int *pulDest = (unsigned int*) start;
bogdanm 15:4892fe388435 240 unsigned int loop;
bogdanm 15:4892fe388435 241 for (loop = 0; loop < len; loop = loop + 4)
bogdanm 15:4892fe388435 242 *pulDest++ = 0;
bogdanm 15:4892fe388435 243 }
bogdanm 15:4892fe388435 244
bogdanm 15:4892fe388435 245 //*****************************************************************************
bogdanm 15:4892fe388435 246 // The following symbols are constructs generated by the linker, indicating
bogdanm 15:4892fe388435 247 // the location of various points in the "Global Section Table". This table is
bogdanm 15:4892fe388435 248 // created by the linker via the Code Red managed linker script mechanism. It
bogdanm 15:4892fe388435 249 // contains the load address, execution address and length of each RW data
bogdanm 15:4892fe388435 250 // section and the execution and length of each BSS (zero initialized) section.
bogdanm 15:4892fe388435 251 //*****************************************************************************
bogdanm 15:4892fe388435 252 extern unsigned int __data_section_table;
bogdanm 15:4892fe388435 253 extern unsigned int __data_section_table_end;
bogdanm 15:4892fe388435 254 extern unsigned int __bss_section_table;
bogdanm 15:4892fe388435 255 extern unsigned int __bss_section_table_end;
bogdanm 15:4892fe388435 256
bogdanm 15:4892fe388435 257 //*****************************************************************************
bogdanm 15:4892fe388435 258 // Reset entry point for your code.
bogdanm 15:4892fe388435 259 // Sets up a simple runtime environment and initializes the C/C++
bogdanm 15:4892fe388435 260 // library.
bogdanm 15:4892fe388435 261 //*****************************************************************************
bogdanm 15:4892fe388435 262 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 263 void
bogdanm 15:4892fe388435 264 ResetISR(void) {
bogdanm 15:4892fe388435 265
bogdanm 15:4892fe388435 266 //
bogdanm 15:4892fe388435 267 // Copy the data sections from flash to SRAM.
bogdanm 15:4892fe388435 268 //
bogdanm 15:4892fe388435 269 unsigned int LoadAddr, ExeAddr, SectionLen;
bogdanm 15:4892fe388435 270 unsigned int *SectionTableAddr;
bogdanm 15:4892fe388435 271
bogdanm 15:4892fe388435 272 // Load base address of Global Section Table
bogdanm 15:4892fe388435 273 SectionTableAddr = &__data_section_table;
bogdanm 15:4892fe388435 274
bogdanm 15:4892fe388435 275 // Copy the data sections from flash to SRAM.
bogdanm 15:4892fe388435 276 while (SectionTableAddr < &__data_section_table_end) {
bogdanm 15:4892fe388435 277 LoadAddr = *SectionTableAddr++;
bogdanm 15:4892fe388435 278 ExeAddr = *SectionTableAddr++;
bogdanm 15:4892fe388435 279 SectionLen = *SectionTableAddr++;
bogdanm 15:4892fe388435 280 data_init(LoadAddr, ExeAddr, SectionLen);
bogdanm 15:4892fe388435 281 }
bogdanm 15:4892fe388435 282 // At this point, SectionTableAddr = &__bss_section_table;
bogdanm 15:4892fe388435 283 // Zero fill the bss segment
bogdanm 15:4892fe388435 284 while (SectionTableAddr < &__bss_section_table_end) {
bogdanm 15:4892fe388435 285 ExeAddr = *SectionTableAddr++;
bogdanm 15:4892fe388435 286 SectionLen = *SectionTableAddr++;
bogdanm 15:4892fe388435 287 bss_init(ExeAddr, SectionLen);
bogdanm 15:4892fe388435 288 }
bogdanm 15:4892fe388435 289
bogdanm 15:4892fe388435 290 #if defined (__VFP_FP__) && !defined (__SOFTFP__)
bogdanm 15:4892fe388435 291 /*
bogdanm 15:4892fe388435 292 * Code to enable the Cortex-M4 FPU only included
bogdanm 15:4892fe388435 293 * if appropriate build options have been selected.
bogdanm 15:4892fe388435 294 * Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C)
bogdanm 15:4892fe388435 295 */
bogdanm 15:4892fe388435 296 // Read CPACR (located at address 0xE000ED88)
bogdanm 15:4892fe388435 297 // Set bits 20-23 to enable CP10 and CP11 coprocessors
bogdanm 15:4892fe388435 298 // Write back the modified value to the CPACR
bogdanm 15:4892fe388435 299 asm volatile ("LDR.W R0, =0xE000ED88\n\t"
bogdanm 15:4892fe388435 300 "LDR R1, [R0]\n\t"
bogdanm 15:4892fe388435 301 "ORR R1, R1, #(0xF << 20)\n\t"
bogdanm 15:4892fe388435 302 "STR R1, [R0]");
bogdanm 15:4892fe388435 303 #endif // (__VFP_FP__) && !(__SOFTFP__)
bogdanm 15:4892fe388435 304
bogdanm 15:4892fe388435 305 // Check to see if we are running the code from a non-zero
bogdanm 15:4892fe388435 306 // address (eg RAM, external flash), in which case we need
bogdanm 15:4892fe388435 307 // to modify the VTOR register to tell the CPU that the
bogdanm 15:4892fe388435 308 // vector table is located at a non-0x0 address.
bogdanm 15:4892fe388435 309
bogdanm 15:4892fe388435 310 // Note that we do not use the CMSIS register access mechanism,
bogdanm 15:4892fe388435 311 // as there is no guarantee that the project has been configured
bogdanm 15:4892fe388435 312 // to use CMSIS.
bogdanm 15:4892fe388435 313 unsigned int * pSCB_VTOR = (unsigned int *) 0xE000ED08;
bogdanm 15:4892fe388435 314 if ((unsigned int *)g_pfnVectors!=(unsigned int *) 0x00000000) {
bogdanm 15:4892fe388435 315 // CMSIS : SCB->VTOR = <address of vector table>
bogdanm 15:4892fe388435 316 *pSCB_VTOR = (unsigned int)g_pfnVectors;
bogdanm 15:4892fe388435 317 }
bogdanm 15:4892fe388435 318
bogdanm 15:4892fe388435 319 //#ifdef __USE_CMSIS
bogdanm 15:4892fe388435 320 SystemInit();
bogdanm 15:4892fe388435 321 //#endif
bogdanm 15:4892fe388435 322
bogdanm 15:4892fe388435 323 #if defined (__cplusplus)
bogdanm 15:4892fe388435 324 //
bogdanm 15:4892fe388435 325 // Call C++ library initialisation
bogdanm 15:4892fe388435 326 //
bogdanm 15:4892fe388435 327 __libc_init_array();
bogdanm 15:4892fe388435 328 #endif
bogdanm 15:4892fe388435 329
bogdanm 15:4892fe388435 330 #if defined (__REDLIB__)
bogdanm 15:4892fe388435 331 // Call the Redlib library, which in turn calls main()
bogdanm 15:4892fe388435 332 __main() ;
bogdanm 15:4892fe388435 333 #else
bogdanm 15:4892fe388435 334 main();
bogdanm 15:4892fe388435 335 #endif
bogdanm 15:4892fe388435 336
bogdanm 15:4892fe388435 337 //
bogdanm 15:4892fe388435 338 // main() shouldn't return, but if it does, we'll just enter an infinite loop
bogdanm 15:4892fe388435 339 //
bogdanm 15:4892fe388435 340 while (1) {
bogdanm 15:4892fe388435 341 ;
bogdanm 15:4892fe388435 342 }
bogdanm 15:4892fe388435 343 }
bogdanm 15:4892fe388435 344
bogdanm 15:4892fe388435 345 //*****************************************************************************
bogdanm 15:4892fe388435 346 // Default exception handlers. Override the ones here by defining your own
bogdanm 15:4892fe388435 347 // handler routines in your application code.
bogdanm 15:4892fe388435 348 //*****************************************************************************
bogdanm 15:4892fe388435 349 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 350 void NMI_Handler(void)
bogdanm 15:4892fe388435 351 {
bogdanm 15:4892fe388435 352 while(1)
bogdanm 15:4892fe388435 353 {
bogdanm 15:4892fe388435 354 }
bogdanm 15:4892fe388435 355 }
bogdanm 15:4892fe388435 356 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 357 void HardFault_Handler(void)
bogdanm 15:4892fe388435 358 {
bogdanm 15:4892fe388435 359 while(1)
bogdanm 15:4892fe388435 360 {
bogdanm 15:4892fe388435 361 }
bogdanm 15:4892fe388435 362 }
bogdanm 15:4892fe388435 363 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 364 void MemManage_Handler(void)
bogdanm 15:4892fe388435 365 {
bogdanm 15:4892fe388435 366 while(1)
bogdanm 15:4892fe388435 367 {
bogdanm 15:4892fe388435 368 }
bogdanm 15:4892fe388435 369 }
bogdanm 15:4892fe388435 370 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 371 void BusFault_Handler(void)
bogdanm 15:4892fe388435 372 {
bogdanm 15:4892fe388435 373 while(1)
bogdanm 15:4892fe388435 374 {
bogdanm 15:4892fe388435 375 }
bogdanm 15:4892fe388435 376 }
bogdanm 15:4892fe388435 377 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 378 void UsageFault_Handler(void)
bogdanm 15:4892fe388435 379 {
bogdanm 15:4892fe388435 380 while(1)
bogdanm 15:4892fe388435 381 {
bogdanm 15:4892fe388435 382 }
bogdanm 15:4892fe388435 383 }
bogdanm 15:4892fe388435 384 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 385 void SVC_Handler(void)
bogdanm 15:4892fe388435 386 {
bogdanm 15:4892fe388435 387 while(1)
bogdanm 15:4892fe388435 388 {
bogdanm 15:4892fe388435 389 }
bogdanm 15:4892fe388435 390 }
bogdanm 15:4892fe388435 391 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 392 void DebugMon_Handler(void)
bogdanm 15:4892fe388435 393 {
bogdanm 15:4892fe388435 394 while(1)
bogdanm 15:4892fe388435 395 {
bogdanm 15:4892fe388435 396 }
bogdanm 15:4892fe388435 397 }
bogdanm 15:4892fe388435 398 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 399 void PendSV_Handler(void)
bogdanm 15:4892fe388435 400 {
bogdanm 15:4892fe388435 401 while(1)
bogdanm 15:4892fe388435 402 {
bogdanm 15:4892fe388435 403 }
bogdanm 15:4892fe388435 404 }
bogdanm 15:4892fe388435 405 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 406 void SysTick_Handler(void)
bogdanm 15:4892fe388435 407 {
bogdanm 15:4892fe388435 408 while(1)
bogdanm 15:4892fe388435 409 {
bogdanm 15:4892fe388435 410 }
bogdanm 15:4892fe388435 411 }
bogdanm 15:4892fe388435 412
bogdanm 15:4892fe388435 413 //*****************************************************************************
bogdanm 15:4892fe388435 414 //
bogdanm 15:4892fe388435 415 // Processor ends up here if an unexpected interrupt occurs or a specific
bogdanm 15:4892fe388435 416 // handler is not present in the application code.
bogdanm 15:4892fe388435 417 //
bogdanm 15:4892fe388435 418 //*****************************************************************************
bogdanm 15:4892fe388435 419 __attribute__ ((section(".after_vectors")))
bogdanm 15:4892fe388435 420 void IntDefaultHandler(void)
bogdanm 15:4892fe388435 421 {
bogdanm 15:4892fe388435 422 while(1)
bogdanm 15:4892fe388435 423 {
bogdanm 15:4892fe388435 424 }
bogdanm 15:4892fe388435 425 }
bogdanm 15:4892fe388435 426
bogdanm 15:4892fe388435 427 #include <stdlib.h>
bogdanm 15:4892fe388435 428
bogdanm 15:4892fe388435 429 void *operator new(size_t size) {return malloc(size);}
bogdanm 15:4892fe388435 430 void *operator new[](size_t size){return malloc(size);}
bogdanm 15:4892fe388435 431
bogdanm 15:4892fe388435 432 void operator delete(void *p) {free(p);}
bogdanm 15:4892fe388435 433 void operator delete[](void *p) {free(p);}