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

4.11
Last change on this file since dd8df59 was dd8df59, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 14, 2012 at 12:59:27 PM

bsps: Interrupt initialization error is fatal

  • Property mode set to 100644
File size: 2.1 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
11#include <bsp.h>
12#include <bsp/irq-generic.h>
13#include <lpc22xx.h>
14
15/*
16 * Function prototypes
17 */
18extern void rtems_exception_init_mngt(void);
19extern void  UART0_Ini(void);
20extern void printi(unsigned long);
21
22/*
23 * bsp_start_default - BSP initialization function
24 *
25 * This function is called before RTEMS is initialized and used
26 * adjust the kernel's configuration.
27 *
28 * This function also configures the CPU's memory protection unit.
29 *
30 * RESTRICTIONS/LIMITATIONS:
31 *   Since RTEMS is not configured, no RTEMS functions can be called.
32 *
33 */
34void bsp_start_default( void )
35{
36  PINSEL2 =0x0f814914;
37  BCFG0 = 0x1000ffef;
38  BCFG1 = 0x1000ffef;
39
40  MEMMAP = 0x2;  //debug and excute outside chip
41
42  PLLCON = 1;
43  #if (Fpclk / (Fcclk / 4)) == 1
44    VPBDIV = 0;
45  #endif
46  #if (Fpclk / (Fcclk / 4)) == 2
47    VPBDIV = 2;
48  #endif
49  #if (Fpclk / (Fcclk / 4)) == 4
50    VPBDIV = 1;
51  #endif
52
53  #if (Fcco / Fcclk) == 2
54    PLLCFG = ((Fcclk / Fosc) - 1) | (0 << 5);
55  #endif
56  #if (Fcco / Fcclk) == 4
57    PLLCFG = ((Fcclk / Fosc) - 1) | (1 << 5);
58  #endif
59  #if (Fcco / Fcclk) == 8
60    PLLCFG = ((Fcclk / Fosc) - 1) | (2 << 5);
61  #endif
62  #if (Fcco / Fcclk) == 16
63    PLLCFG = ((Fcclk / Fosc) - 1) | (3 << 5);
64  #endif
65  PLLFEED = 0xaa;
66  PLLFEED = 0x55;
67  while((PLLSTAT & (1 << 10)) == 0);
68  PLLCON = 3;
69  PLLFEED = 0xaa;
70  PLLFEED = 0x55;
71
72  /* memory configure */
73  /* it is not needed in my formatter board */
74  //MAMCR = 0;
75  // MAMTIM = 3;
76  //MAMCR = 2;
77
78  UART0_Ini();
79
80  /*
81   * Init rtems exceptions management
82   */
83  rtems_exception_init_mngt();
84
85  /*
86   * Init rtems interrupt management
87   */
88  bsp_interrupt_initialize();
89} /* bsp_start */
90
91/*
92 *  By making this a weak alias for bsp_start_default, a brave soul
93 *  can override the actual bsp_start routine used.
94 */
95
96void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
Note: See TracBrowser for help on using the repository browser.