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

4.104.11
Last change on this file since a196084 was a196084, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 16, 2008 at 7:06:10 PM

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

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