source: rtems/c/src/lib/libbsp/arm/rtl22xx/startup/bspstart.c @ a012d18

4.104.115
Last change on this file since a012d18 was f560d0a, checked in by Joel Sherrill <joel.sherrill@…>, on 09/14/08 at 20:22:57

2008-09-14 Joel Sherrill <joel.sherrill@…>

  • Makefile.am, configure.ac, startup/bspstart.c: Split out bsp_get_work_area() into its own file and user BSP Framework to perform more initialization. Use same shared implementation as edb7312 and csb336.
  • Property mode set to 100644
File size: 2.5 KB
Line 
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 <rtems/libcsupport.h>
15#include <rtems/libio.h>
16#include <lpc22xx.h>
17
18/*
19 * Function prototypes
20 */
21extern void rtems_irq_mngt_init(void);
22void bsp_libc_init( void *, uint32_t, int );
23extern void  UART0_Ini(void);
24extern void printi(unsigned long);
25
26/*
27 * bsp_start_default - BSP initialization function
28 *
29 * This function is called before RTEMS is initialized and used
30 * adjust the kernel's configuration.
31 *
32 * This function also configures the CPU's memory protection unit.
33 *
34 * RESTRICTIONS/LIMITATIONS:
35 *   Since RTEMS is not configured, no RTEMS functions can be called.
36 *
37 */
38void bsp_start_default( void )
39{
40  PINSEL2 =0x0f814914;
41  BCFG0 = 0x1000ffef;
42  BCFG1 = 0x1000ffef;
43
44  MEMMAP = 0x2;  //debug and excute outside chip
45
46  PLLCON = 1;
47  #if (Fpclk / (Fcclk / 4)) == 1
48    VPBDIV = 0;
49  #endif
50  #if (Fpclk / (Fcclk / 4)) == 2
51    VPBDIV = 2;
52  #endif
53  #if (Fpclk / (Fcclk / 4)) == 4
54    VPBDIV = 1;
55  #endif
56
57  #if (Fcco / Fcclk) == 2
58    PLLCFG = ((Fcclk / Fosc) - 1) | (0 << 5);
59  #endif
60  #if (Fcco / Fcclk) == 4
61    PLLCFG = ((Fcclk / Fosc) - 1) | (1 << 5);
62  #endif
63  #if (Fcco / Fcclk) == 8
64    PLLCFG = ((Fcclk / Fosc) - 1) | (2 << 5);
65  #endif
66  #if (Fcco / Fcclk) == 16
67    PLLCFG = ((Fcclk / Fosc) - 1) | (3 << 5);
68  #endif
69  PLLFEED = 0xaa;
70  PLLFEED = 0x55;
71  while((PLLSTAT & (1 << 10)) == 0);
72  PLLCON = 3;
73  PLLFEED = 0xaa;
74  PLLFEED = 0x55;
75
76  /* memory configure */
77  /* it is not needed in my formatter board */
78  //MAMCR = 0;
79  // MAMTIM = 3;
80  //MAMCR = 2;
81
82  /* init VIC */
83  VICIntEnClr = 0xffffffff;
84  VICVectAddr = 0;
85  VICIntSelect = 0;
86
87  /* disable interrupts */
88  /* Setup interrupt controller.*/
89  VICProtection = 0;
90
91  UART0_Ini();
92
93  /*
94   * Init rtems exceptions management
95   */
96  rtems_exception_init_mngt();
97
98  /*
99   * Init rtems interrupt management
100   */
101  rtems_irq_mngt_init();
102} /* bsp_start */
103
104
105/**
106 *  Reset the system.
107 *
108 *  This functions enables the watchdog and waits for it to
109 *  fire, thus resetting the system.
110 */
111void bsp_reset(void)
112{
113    rtems_interrupt_level level;
114
115    rtems_interrupt_disable(level);
116
117    while(1);
118}
119
120/*
121 *  By making this a weak alias for bsp_start_default, a brave soul
122 *  can override the actual bsp_start routine used.
123 */
124
125void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
Note: See TracBrowser for help on using the repository browser.