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

📄 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 "44b.h"
#include "board.h"
#include "datatype.h"
#include "timer.h"
#include "serial.h"  
#include "system.h" 
#include "led.h" 

static void port_Init(void);


/**************************************************************************************************
* Description: Default Interrupt Service Routine
* Notes:         Interrupt is enabled at any ISR
**************************************************************************************************/
void default_isr( void )
{  
    /* Do something here to handle the interrupts */

}


/**************************************************************************************************
* Description: timer interrupt service routine
**************************************************************************************************/
void tm_isr(void)
{  

    U32 cpu_flags = sys_disableInterrupt();

    rI_ISPC = ( 0x01 << 13 );

    sys_restoreCpuFlags( cpu_flags );

    tm_tick();
}

/**************************************************************************************************
* Description: timer low level initializing
**************************************************************************************************/
void tm_init(void)
{
    /* dead zone=0, pre0= 150 */
    rTCFG0 = 0x00000095;

    /* all interrupt, mux0= 1/16 */
    rTCFG1 = 0x00000003;

    /*  set T0 count */
   rTCNTB0 = _CLOCK;

    /* update T0  */
    rTCON = 0x00000002;

   /* Vectored,IRQ enable,FIQ disable  */
   rINTCON = 0x1;

    /*  Non maksed TIMER0  */
    rINTMSK=~( BIT_TIMER0 | BIT_GLOBAL );	

    /* autoreload and start */
    rTCON = 0x9;		

}

/**************************************************************************************************
* Description: initialize board
**************************************************************************************************/
void bd_initBoard( void )
{
    /* Configure Cache */
    rSYSCFG = SYSCFG_8KB ;				/* 使用8K字节的指令缓存*/

    rNCACHBE0=((unsigned int)(Non_Cache_End>>12)<<16)|(Non_Cache_Start>>12);

    port_Init();

    led_delay( 5000 ) ;		

    led_dispChar( 0x0f );		

    led_delay( 5000 ) ;		

    led_dispChar( 0x00 );		

    uart0_init(2400);    

    /* Set frquency */
    rPLLCON = ( 58 << 12) | ( 3 << 4) | 1;

    /*  Non-vectored,IRQ disable,FIQ disable     */
    rINTCON = 0x0 ;	  

    /* All=IRQ mode */
    rINTMOD = 0x0 ;	  

    /*  All interrupt is masked. */
    rINTMSK = BIT_GLOBAL;

}









/**************************************************************************************************
* Locally called functions
/**************************************************************************************************/
static void port_Init(void)
{
	// PORT A GROUP
	/*  BIT 9	8	7	6	5	4	3	2	1	0	*/
	/*  A24	  A23	A22	A21	A20	A19	A18	A17	A16	A0	*/	      
	/*  1		1	1	1	1	1	1	1	1	1	*/
	rPCONA = 0x3ff;	

	// PORT B GROUP
	/* BIT 10   9    8       7      6        5     4     3     2     1     0    */
	/*     /CS5 /CS4 /CS3    /CS2   /CS1     nWBE3 nWBE2 /SRAS /SCAS SCLS  SCKE	*/
	/*     NC   NC   RTL8019 USBD12 NV_Flash NC    NC    Sdram Sdram Sdram Sdram*/
	/*     0,   0,   1,      1,     1,       0,    0,    1,    1,    1,    1    */
	rPDATB = 0x1cf;
	rPCONB = 0x1cf;
    
	//PORT C GROUP
	//BUSWIDTH=16													*/
	/*  PC15		14		13		12		11		10		9		8	*/
	/*	o		o		RXD1	TXD1	o		o		o		o	*/
	/*	NC		NC		Uart1	Uart1	NC		NC		NC		NC	*/
	/*   01		01		11		11		01		01		01		00	*/

	/*  PC7		6		5		4		3		2		1		0	*/
	/*   o		o		o		o		o		o		o		o	*/
	/*   NC		NC		NC		NC		NFALE 	NFCLE 	NFCE 	NFRB*/
	/*   01		01		01		01		01		01		01		00	*/
	rPDATC = 0x0001;	//All IO is low
	rPCONC = 0x5f545554;	
	rPUPC  = 0x0300;	//PULL UP RESISTOR should be enabled to I/O

	//PORT D GROUP
	/*  PORT D GROUP(I/O OR LCD)										*/
	/*  BIT7		6		5		4		3		2		1		0	*/
	/*      VF		VM		VLINE	VCLK	VD3		VD2		VD1		VD0	*/
	/*	   01		01		01		01		01		01		01		01	*/
	rPDATD= 0x55;
	rPCOND= 0xaaaa;	
	rPUPD = 0x00;
	//These pins must be set only after CPU's internal LCD controller is enable
	
	//PORT E GROUP 
	/*  Bit 8		7		6		5		4		3		2		1		0		*/
	/*		ENDLAN	LED3	LED2	LED1	LED0	BEEP	RXD0	TXD0	CLKOUT	*/ 
	/*      00		01		01		01		01		01		10		10		11		*/
	rPCONE	= 0x26568;	//0->input, 1 2->TXD0 RXD0, 3 4->input, 5->led, 6->buzzer, 7->led, 8->CODECLK
	rPDATE	= 0x60;
	rPUPE	= 0x000;	//disable all pull-up
	
	//PORT F GROUP
	/*  Bit8		7		6		5		 4		3		2		1		0		*/   
	/*  IISCLK	IISDI	IISDO	IISLRCK	Input	Input	Input	IICSDA	IICSCL	*/
	/*	100		010		010		001		00		01		01		10		10		*/
	rPDATF = 0x0;
	rPCONF = 0x22445a;
	rPUPF  = 0x1d3;

	//PORT G GROUP
	/*  BIT7		6		5		4		3		2		1		0	 */
	/*	INT7		INT6		INT5		INT4		INT3		INT2		INT1		INT0	*/
	/*    S3		S4		S5		S6		NIC		EXT		IDE		USB	*/
	/*      11      11      11      11      11      11      11      11       */
	rPDATG = 0xff;
	rPCONG = 0x000c; //eint1 is eth interrupt in FS44B0
	rPUPG  = 0x00;	//should be enabled  

	rSPUCR=0x7;  //D15-D0 pull-up disable

	rSPUCR=0x7;  //D15-D0 pull-up disable

	/*所有的外部硬件中断为低电平触发*/
	rEXTINT=0x0;
}




⌨️ 快捷键说明

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