⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 board.c

📁 一个小型的嵌入式操作系统内核,可用于多种硬件平台
💻 C
字号:
/**************************************************************************************************
                                      EDL RTOS Kernel
                              (c) Copyright 2005, Wu Jun
                                    All Rights Reserved    
                For further information, please visit http://www.enjoydigitallife.com

* Description:      None
* History:          
    Date                         Remarks
    2005-01-06                   Created initial version
    2005-12-12                   Finished the version 2.01
**************************************************************************************************/

#include "LPC2294.h"
#include "board.h"
#include "datatype.h"
#include "timer.h"
#include "serial.h"  
#include "system.h" 








/**************************************************************************************************
* Description: timer interrupt service routine
**************************************************************************************************/
void tm_isr(void)
{  
    U32 cpu_flags = sys_disableInterrupt();

    T0IR = 0x01;
    VICVectAddr = 0x00;	

    sys_restoreCpuFlags( cpu_flags );

    tm_tick();
}

/**************************************************************************************************
* Description: timer low level initializing
**************************************************************************************************/
void tm_init(void)
{
   
    T0TC = 0;
	T0PR = 0;			    					
	T0MCR = 0x03;
	T0MR0 = 11059200 / TICKS_PER_SECOND;
	T0TCR = 0x03;		
	T0TCR = 0x01; 
	
	VICVectCntl0 = ( 0x20 | 4 );
	VICVectAddr0 = (U32)tm_isr; 
	VICIntEnable = (U32)( 1 << 4 );

}

/**************************************************************************************************
* Description: initialize board
**************************************************************************************************/
void bd_initBoard( void )
{

    
    /* configure PLL,VPB */    
    PLLCON = 1;
#if (Fpclk / (Fcclk / 4)) == 1
    VPBDIV = 0;
#endif
#if (Fpclk / (Fcclk / 4)) == 2
    VPBDIV = 2;
#endif
#if (Fpclk / (Fcclk / 4)) == 4
    VPBDIV = 1;
#endif

#if (Fcco / Fcclk) == 2
    PLLCFG = ((Fcclk / Fosc) - 1) | (0 << 5);
#endif
#if (Fcco / Fcclk) == 4
    PLLCFG = ((Fcclk / Fosc) - 1) | (1 << 5);
#endif
#if (Fcco / Fcclk) == 8
    PLLCFG = ((Fcclk / Fosc) - 1) | (2 << 5);
#endif
#if (Fcco / Fcclk) == 16
    PLLCFG = ((Fcclk / Fosc) - 1) | (3 << 5);
#endif
    PLLFEED = 0xaa;
    PLLFEED = 0x55;
    while((PLLSTAT & (1 << 10)) == 0);
    PLLCON = 3;
    PLLFEED = 0xaa;
    PLLFEED = 0x55;        

    /* Set memory accelerater module*/
    MAMCR = 0;
#if Fcclk < 20000000
    MAMTIM = 1;
#else
#if Fcclk < 40000000
    MAMTIM = 2;
#else
    MAMTIM = 3;
#endif
#endif
    MAMCR = 2;


    /* initialize interrupt vectors */
    VICIntEnClr = 0xffffffff;
    VICVectAddr = 0;
    VICIntSelect = 0;    


    uart0_init(2400);    



}






⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -