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