OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [freertos-6.1.1/] [Demo/] [CORTEX_LPC1768_GCC_RedSuite/] [src/] [cr_startup_lpc17.c] - Blame information for rev 581

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 581 jeremybenn
//*****************************************************************************
2
//   +--+       
3
//   | ++----+   
4
//   +-++    |  
5
//     |     |  
6
//   +-+--+  |   
7
//   | +--+--+  
8
//   +----+    Copyright (c) 2009-10 Code Red Technologies Ltd.
9
//
10
// Microcontroller Startup code for use with Red Suite
11
//
12
// Software License Agreement
13
// 
14
// The software is owned by Code Red Technologies and/or its suppliers, and is 
15
// protected under applicable copyright laws.  All rights are reserved.  Any 
16
// use in violation of the foregoing restrictions may subject the user to criminal 
17
// sanctions under applicable laws, as well as to civil liability for the breach 
18
// of the terms and conditions of this license.
19
// 
20
// THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
21
// OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
22
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
23
// USE OF THIS SOFTWARE FOR COMMERCIAL DEVELOPMENT AND/OR EDUCATION IS SUBJECT
24
// TO A CURRENT END USER LICENSE AGREEMENT (COMMERCIAL OR EDUCATIONAL) WITH
25
// CODE RED TECHNOLOGIES LTD. 
26
//
27
//*****************************************************************************
28
#if defined (__cplusplus)
29
#ifdef __REDLIB__
30
#error Redlib does not support C++
31
#else
32
//*****************************************************************************
33
//
34
// The entry point for the C++ library startup
35
//
36
//*****************************************************************************
37
extern "C" {
38
        extern void __libc_init_array(void);
39
}
40
#endif
41
#endif
42
 
43
#define WEAK __attribute__ ((weak))
44
#define ALIAS(f) __attribute__ ((weak, alias (#f)))
45
 
46
// Code Red - if CMSIS is being used, then SystemInit() routine
47
// will be called by startup code rather than in application's main()
48
#if defined (__USE_CMSIS)
49
#include "system_LPC17xx.h"
50
#endif
51
 
52
//*****************************************************************************
53
#if defined (__cplusplus)
54
extern "C" {
55
#endif
56
 
57
//*****************************************************************************
58
//
59
// Forward declaration of the default handlers. These are aliased.
60
// When the application defines a handler (with the same name), this will 
61
// automatically take precedence over these weak definitions
62
//
63
//*****************************************************************************
64
     void ResetISR(void);
65
WEAK void NMI_Handler(void);
66
WEAK void HardFault_Handler(void);
67
WEAK void MemManage_Handler(void);
68
WEAK void BusFault_Handler(void);
69
WEAK void UsageFault_Handler(void);
70
WEAK void SVCall_Handler(void);
71
WEAK void DebugMon_Handler(void);
72
WEAK void PendSV_Handler(void);
73
WEAK void SysTick_Handler(void);
74
WEAK void IntDefaultHandler(void);
75
 
76
//*****************************************************************************
77
//
78
// Forward declaration of the specific IRQ handlers. These are aliased
79
// to the IntDefaultHandler, which is a 'forever' loop. When the application
80
// defines a handler (with the same name), this will automatically take 
81
// precedence over these weak definitions
82
//
83
//*****************************************************************************
84
void WDT_IRQHandler(void) ALIAS(IntDefaultHandler);
85
void TIMER0_IRQHandler(void) ALIAS(IntDefaultHandler);
86
void TIMER1_IRQHandler(void) ALIAS(IntDefaultHandler);
87
void TIMER2_IRQHandler(void) ALIAS(IntDefaultHandler);
88
void TIMER3_IRQHandler(void) ALIAS(IntDefaultHandler);
89
void UART0_IRQHandler(void) ALIAS(IntDefaultHandler);
90
void UART1_IRQHandler(void) ALIAS(IntDefaultHandler);
91
void UART2_IRQHandler(void) ALIAS(IntDefaultHandler);
92
void UART3_IRQHandler(void) ALIAS(IntDefaultHandler);
93
void PWM1_IRQHandler(void) ALIAS(IntDefaultHandler);
94
void I2C0_IRQHandler(void) ALIAS(IntDefaultHandler);
95
void I2C1_IRQHandler(void) ALIAS(IntDefaultHandler);
96
void I2C2_IRQHandler(void) ALIAS(IntDefaultHandler);
97
void SPI_IRQHandler(void) ALIAS(IntDefaultHandler);
98
void SSP0_IRQHandler(void) ALIAS(IntDefaultHandler);
99
void SSP1_IRQHandler(void) ALIAS(IntDefaultHandler);
100
void PLL0_IRQHandler(void) ALIAS(IntDefaultHandler);
101
void RTC_IRQHandler(void) ALIAS(IntDefaultHandler);
102
void EINT0_IRQHandler(void) ALIAS(IntDefaultHandler);
103
void EINT1_IRQHandler(void) ALIAS(IntDefaultHandler);
104
void EINT2_IRQHandler(void) ALIAS(IntDefaultHandler);
105
void EINT3_IRQHandler(void) ALIAS(IntDefaultHandler);
106
void ADC_IRQHandler(void) ALIAS(IntDefaultHandler);
107
void BOD_IRQHandler(void) ALIAS(IntDefaultHandler);
108
void USB_IRQHandler(void) ALIAS(IntDefaultHandler);
109
void CAN_IRQHandler(void) ALIAS(IntDefaultHandler);
110
void DMA_IRQHandler(void) ALIAS(IntDefaultHandler);
111
void I2S_IRQHandler(void) ALIAS(IntDefaultHandler);
112
void ENET_IRQHandler(void) ALIAS(IntDefaultHandler);
113
void RIT_IRQHandler(void) ALIAS(IntDefaultHandler);
114
void MCPWM_IRQHandler(void) ALIAS(IntDefaultHandler);
115
void QEI_IRQHandler(void) ALIAS(IntDefaultHandler);
116
void PLL1_IRQHandler(void) ALIAS(IntDefaultHandler);
117
void USBActivity_IRQHandler(void) ALIAS(IntDefaultHandler);
118
void CANActivity_IRQHandler(void) ALIAS(IntDefaultHandler);
119
 
120
extern void xPortSysTickHandler(void);
121
extern void xPortPendSVHandler(void);
122
extern void vPortSVCHandler( void );
123
extern void vEMAC_ISR( void );
124
 
125
//*****************************************************************************
126
//
127
// The entry point for the application.
128
// __main() is the entry point for Redlib based applications
129
// main() is the entry point for Newlib based applications
130
//
131
//*****************************************************************************
132
#if defined (__REDLIB__)
133
extern void __main(void);
134
#endif
135
extern int main(void);
136
//*****************************************************************************
137
//
138
// External declaration for the pointer to the stack top from the Linker Script
139
//
140
//*****************************************************************************
141
extern void _vStackTop(void);
142
 
143
//*****************************************************************************
144
#if defined (__cplusplus)
145
} // extern "C"
146
#endif
147
//*****************************************************************************
148
//
149
// The vector table.
150
// This relies on the linker script to place at correct location in memory.
151
//
152
//*****************************************************************************
153
extern void (* const g_pfnVectors[])(void);
154
__attribute__ ((section(".isr_vector")))
155
void (* const g_pfnVectors[])(void) =
156
{
157
        // Core Level - CM3
158
        (void *)&_vStackTop,                                    // The initial stack pointer
159
        ResetISR,                                                               // The reset handler
160
        NMI_Handler,                                                    // The NMI handler
161
        HardFault_Handler,                                              // The hard fault handler
162
        MemManage_Handler,                                              // The MPU fault handler
163
        BusFault_Handler,                                               // The bus fault handler
164
        UsageFault_Handler,                                             // The usage fault handler
165
        0,                                                                               // Reserved
166
        0,                                                                               // Reserved
167
        0,                                                                               // Reserved
168
        0,                                                                               // Reserved
169
        vPortSVCHandler,                        // SVCall handler
170
        DebugMon_Handler,                                               // Debug monitor handler
171
        0,                                                                               // Reserved
172
        xPortPendSVHandler,                     // The PendSV handler
173
        xPortSysTickHandler,                    // The SysTick handler
174
 
175
        // Chip Level - LPC17
176
        WDT_IRQHandler,                                                 // 16, 0x40 - WDT
177
        TIMER0_IRQHandler,                                              // 17, 0x44 - TIMER0
178
        TIMER1_IRQHandler,                                              // 18, 0x48 - TIMER1
179
        TIMER2_IRQHandler,                                              // 19, 0x4c - TIMER2
180
        TIMER3_IRQHandler,                                              // 20, 0x50 - TIMER3
181
        UART0_IRQHandler,                                               // 21, 0x54 - UART0
182
        UART1_IRQHandler,                                               // 22, 0x58 - UART1
183
        UART2_IRQHandler,                                               // 23, 0x5c - UART2
184
        UART3_IRQHandler,                                               // 24, 0x60 - UART3
185
        PWM1_IRQHandler,                                                // 25, 0x64 - PWM1
186
        I2C0_IRQHandler,                                                // 26, 0x68 - I2C0
187
        I2C1_IRQHandler,                                                // 27, 0x6c - I2C1
188
        I2C2_IRQHandler,                                                // 28, 0x70 - I2C2
189
        SPI_IRQHandler,                                                 // 29, 0x74 - SPI
190
        SSP0_IRQHandler,                                                // 30, 0x78 - SSP0
191
        SSP1_IRQHandler,                                                // 31, 0x7c - SSP1
192
        PLL0_IRQHandler,                                                // 32, 0x80 - PLL0 (Main PLL)
193
        RTC_IRQHandler,                                                 // 33, 0x84 - RTC
194
        EINT0_IRQHandler,                                               // 34, 0x88 - EINT0
195
        EINT1_IRQHandler,                                               // 35, 0x8c - EINT1
196
        EINT2_IRQHandler,                                               // 36, 0x90 - EINT2
197
        EINT3_IRQHandler,                                               // 37, 0x94 - EINT3
198
        ADC_IRQHandler,                                                 // 38, 0x98 - ADC
199
        BOD_IRQHandler,                                                 // 39, 0x9c - BOD
200
        USB_IRQHandler,                                                 // 40, 0xA0 - USB
201
        CAN_IRQHandler,                                                 // 41, 0xa4 - CAN
202
        DMA_IRQHandler,                                                 // 42, 0xa8 - GP DMA
203
        I2S_IRQHandler,                                                 // 43, 0xac - I2S
204
            vEMAC_ISR,                                  // Ethernet.
205
        RIT_IRQHandler,                                                 // 45, 0xb4 - RITINT
206
        MCPWM_IRQHandler,                                               // 46, 0xb8 - Motor Control PWM
207
        QEI_IRQHandler,                                                 // 47, 0xbc - Quadrature Encoder
208
        PLL1_IRQHandler,                                                // 48, 0xc0 - PLL1 (USB PLL)
209
        USBActivity_IRQHandler,                                 // 49, 0xc4 - USB Activity interrupt to wakeup
210
        CANActivity_IRQHandler,                                 // 50, 0xc8 - CAN Activity interrupt to wakeup
211
};
212
 
213
//*****************************************************************************
214
//
215
// The following are constructs created by the linker, indicating where the
216
// the "data" and "bss" segments reside in memory.  The initializers for the
217
// for the "data" segment resides immediately following the "text" segment.
218
//
219
//*****************************************************************************
220
extern unsigned long _etext;
221
extern unsigned long _data;
222
extern unsigned long _edata;
223
extern unsigned long _bss;
224
extern unsigned long _ebss;
225
 
226
//*****************************************************************************
227
// Reset entry point for your code.
228
// Sets up a simple runtime environment and initializes the C/C++
229
// library.
230
//
231
//*****************************************************************************
232
void
233
ResetISR(void) {
234
    unsigned long *pulSrc, *pulDest;
235
 
236
    //
237
    // Copy the data segment initializers from flash to SRAM.
238
    //
239
    pulSrc = &_etext;
240
    for(pulDest = &_data; pulDest < &_edata; )
241
    {
242
        *pulDest++ = *pulSrc++;
243
    }
244
 
245
    //
246
    // Zero fill the bss segment.  This is done with inline assembly since this
247
    // will clear the value of pulDest if it is not kept in a register.
248
    //
249
    __asm("    ldr     r0, =_bss\n"
250
          "    ldr     r1, =_ebss\n"
251
          "    mov     r2, #0\n"
252
          "    .thumb_func\n"
253
          "zero_loop:\n"
254
          "        cmp     r0, r1\n"
255
          "        it      lt\n"
256
          "        strlt   r2, [r0], #4\n"
257
          "        blt     zero_loop");
258
 
259
#ifdef __USE_CMSIS
260
        SystemInit();
261
#endif
262
 
263
#if defined (__cplusplus)
264
        //
265
        // Call C++ library initialisation
266
        //
267
        __libc_init_array();
268
#endif
269
 
270
#if defined (__REDLIB__)
271
        // Call the Redlib library, which in turn calls main()
272
        __main() ;
273
#else
274
        main();
275
#endif
276
 
277
        //
278
        // main() shouldn't return, but if it does, we'll just enter an infinite loop 
279
        //
280
        while (1) {
281
                ;
282
        }
283
}
284
 
285
//*****************************************************************************
286
//
287
// This is the code that gets called when the processor receives a NMI.  This
288
// simply enters an infinite loop, preserving the system state for examination
289
// by a debugger.
290
//
291
//*****************************************************************************
292
void NMI_Handler(void)
293
{
294
    while(1)
295
    {
296
    }
297
}
298
 
299
void HardFault_Handler(void)
300
{
301
    while(1)
302
    {
303
    }
304
}
305
 
306
void MemManage_Handler(void)
307
{
308
    while(1)
309
    {
310
    }
311
}
312
 
313
void BusFault_Handler(void)
314
{
315
    while(1)
316
    {
317
    }
318
}
319
 
320
void UsageFault_Handler(void)
321
{
322
    while(1)
323
    {
324
    }
325
}
326
 
327
 
328
void DebugMon_Handler(void)
329
{
330
    while(1)
331
    {
332
    }
333
}
334
 
335
//*****************************************************************************
336
//
337
// Processor ends up here if an unexpected interrupt occurs or a handler
338
// is not present in the application code.
339
//
340
//*****************************************************************************
341
void IntDefaultHandler(void)
342
{
343
    //
344
    // Go into an infinite loop.
345
    //
346
    while(1)
347
    {
348
    }
349
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.