1 | /* |
---|
2 | * LPC22XX/LPC21xx Startup code |
---|
3 | * |
---|
4 | * Copyright (c) 2007 by Ray Xu <rayx.cn@gmail.com> |
---|
5 | * |
---|
6 | * The license and distribution terms for this file may be |
---|
7 | * found in the file LICENSE in this distribution or at |
---|
8 | * http://www.rtems.com/license/LICENSE. |
---|
9 | * |
---|
10 | * $Id$ |
---|
11 | */ |
---|
12 | |
---|
13 | #include <bsp.h> |
---|
14 | #include <lpc22xx.h> |
---|
15 | |
---|
16 | /* |
---|
17 | * Function prototypes |
---|
18 | */ |
---|
19 | extern void rtems_irq_mngt_init(void); |
---|
20 | extern void UART0_Ini(void); |
---|
21 | extern void printi(unsigned long); |
---|
22 | |
---|
23 | /* |
---|
24 | * bsp_start_default - BSP initialization function |
---|
25 | * |
---|
26 | * This function is called before RTEMS is initialized and used |
---|
27 | * adjust the kernel's configuration. |
---|
28 | * |
---|
29 | * This function also configures the CPU's memory protection unit. |
---|
30 | * |
---|
31 | * RESTRICTIONS/LIMITATIONS: |
---|
32 | * Since RTEMS is not configured, no RTEMS functions can be called. |
---|
33 | * |
---|
34 | */ |
---|
35 | void bsp_start_default( void ) |
---|
36 | { |
---|
37 | PINSEL2 =0x0f814914; |
---|
38 | BCFG0 = 0x1000ffef; |
---|
39 | BCFG1 = 0x1000ffef; |
---|
40 | |
---|
41 | MEMMAP = 0x2; //debug and excute outside chip |
---|
42 | |
---|
43 | PLLCON = 1; |
---|
44 | #if (Fpclk / (Fcclk / 4)) == 1 |
---|
45 | VPBDIV = 0; |
---|
46 | #endif |
---|
47 | #if (Fpclk / (Fcclk / 4)) == 2 |
---|
48 | VPBDIV = 2; |
---|
49 | #endif |
---|
50 | #if (Fpclk / (Fcclk / 4)) == 4 |
---|
51 | VPBDIV = 1; |
---|
52 | #endif |
---|
53 | |
---|
54 | #if (Fcco / Fcclk) == 2 |
---|
55 | PLLCFG = ((Fcclk / Fosc) - 1) | (0 << 5); |
---|
56 | #endif |
---|
57 | #if (Fcco / Fcclk) == 4 |
---|
58 | PLLCFG = ((Fcclk / Fosc) - 1) | (1 << 5); |
---|
59 | #endif |
---|
60 | #if (Fcco / Fcclk) == 8 |
---|
61 | PLLCFG = ((Fcclk / Fosc) - 1) | (2 << 5); |
---|
62 | #endif |
---|
63 | #if (Fcco / Fcclk) == 16 |
---|
64 | PLLCFG = ((Fcclk / Fosc) - 1) | (3 << 5); |
---|
65 | #endif |
---|
66 | PLLFEED = 0xaa; |
---|
67 | PLLFEED = 0x55; |
---|
68 | while((PLLSTAT & (1 << 10)) == 0); |
---|
69 | PLLCON = 3; |
---|
70 | PLLFEED = 0xaa; |
---|
71 | PLLFEED = 0x55; |
---|
72 | |
---|
73 | /* memory configure */ |
---|
74 | /* it is not needed in my formatter board */ |
---|
75 | //MAMCR = 0; |
---|
76 | // MAMTIM = 3; |
---|
77 | //MAMCR = 2; |
---|
78 | |
---|
79 | /* init VIC */ |
---|
80 | VICIntEnClr = 0xffffffff; |
---|
81 | VICVectAddr = 0; |
---|
82 | VICIntSelect = 0; |
---|
83 | |
---|
84 | /* disable interrupts */ |
---|
85 | /* Setup interrupt controller.*/ |
---|
86 | VICProtection = 0; |
---|
87 | |
---|
88 | UART0_Ini(); |
---|
89 | |
---|
90 | /* |
---|
91 | * Init rtems exceptions management |
---|
92 | */ |
---|
93 | rtems_exception_init_mngt(); |
---|
94 | |
---|
95 | /* |
---|
96 | * Init rtems interrupt management |
---|
97 | */ |
---|
98 | rtems_irq_mngt_init(); |
---|
99 | } /* bsp_start */ |
---|
100 | |
---|
101 | /* |
---|
102 | * By making this a weak alias for bsp_start_default, a brave soul |
---|
103 | * can override the actual bsp_start routine used. |
---|
104 | */ |
---|
105 | |
---|
106 | void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default"))); |
---|