Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:05

0001 /*
0002  *  LPC22XX/LPC21xx Startup code
0003  */
0004 
0005 /*
0006  *  Copyright (c) 2007 by Ray Xu <rayx.cn@gmail.com>
0007  *
0008  *  The license and distribution terms for this file may be
0009  *  found in the file LICENSE in this distribution or at
0010  *  http://www.rtems.org/license/LICENSE.
0011  */
0012 
0013 #include <bsp.h>
0014 #include <bsp/irq-generic.h>
0015 #include <lpc22xx.h>
0016 
0017 /*
0018  * bsp_start_default - BSP initialization function
0019  *
0020  * This function is called before RTEMS is initialized and used
0021  * adjust the kernel's configuration.
0022  *
0023  * This function also configures the CPU's memory protection unit.
0024  *
0025  * RESTRICTIONS/LIMITATIONS:
0026  *   Since RTEMS is not configured, no RTEMS functions can be called.
0027  */
0028 static void bsp_start_default( void )
0029 {
0030   PINSEL2 =0x0f814914;
0031   BCFG0 = 0x1000ffef;
0032   BCFG1 = 0x1000ffef;
0033 
0034   MEMMAP = 0x2;  //debug and excute outside chip
0035 
0036   PLLCON = 1;
0037   #if (Fpclk / (Fcclk / 4)) == 1
0038     VPBDIV = 0;
0039   #endif
0040   #if (Fpclk / (Fcclk / 4)) == 2
0041     VPBDIV = 2;
0042   #endif
0043   #if (Fpclk / (Fcclk / 4)) == 4
0044     VPBDIV = 1;
0045   #endif
0046 
0047   #if (Fcco / Fcclk) == 2
0048     PLLCFG = ((Fcclk / Fosc) - 1) | (0 << 5);
0049   #endif
0050   #if (Fcco / Fcclk) == 4
0051     PLLCFG = ((Fcclk / Fosc) - 1) | (1 << 5);
0052   #endif
0053   #if (Fcco / Fcclk) == 8
0054     PLLCFG = ((Fcclk / Fosc) - 1) | (2 << 5);
0055   #endif
0056   #if (Fcco / Fcclk) == 16
0057     PLLCFG = ((Fcclk / Fosc) - 1) | (3 << 5);
0058   #endif
0059   PLLFEED = 0xaa;
0060   PLLFEED = 0x55;
0061   while((PLLSTAT & (1 << 10)) == 0);
0062   PLLCON = 3;
0063   PLLFEED = 0xaa;
0064   PLLFEED = 0x55;
0065 
0066   /* memory configure */
0067   /* it is not needed in my formatter board */
0068   //MAMCR = 0;
0069   // MAMTIM = 3;
0070   //MAMCR = 2;
0071 
0072   UART0_Ini();
0073 
0074   /*
0075    * Init rtems interrupt management
0076    */
0077   bsp_interrupt_initialize();
0078 } /* bsp_start */
0079 
0080 /*
0081  *  By making this a weak alias for bsp_start_default, a brave soul
0082  *  can override the actual bsp_start routine used.
0083  */
0084 void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));