www.pudn.com > armmousecouter.rar > Main.c
/**************************************************************************** * file name : main.c * By : hugang, hgx2000@mail.china.com ****************************************************************************/ #include#include #include #include "../inc/option.h" #include "../inc/44b.h" #include "../inc/44blib.h" #include "../inc/def.h" #include "../ps2/ps2.h" volatile char which_int=0; unsigned int SERIAL_BAUD = 57600; __irq void EInt4567Isr(void) { which_int = rEXTINTPND; rEXTINTPND = 0xf; //clear EXTINTPND reg. rI_ISPC |= BIT_EINT4567; //clear pending_bit ps2_interrupt(); } /**************************************************************************** 【功能说明】中断初始化 ****************************************************************************/ void Isr_Init(void) { rINTCON = 0x1; //中断控制寄存器设置 rINTMOD=0x0; // All=IRQ mode pISR_EINT4567= (unsigned) EInt4567Isr; rPCONG = (rPCONG&(~(0xf<<12))) | (0xc<<12); rPUPG |= 0x3f; rEXTINT = (rEXTINT&(~(0x7<<28))) | (0x2<<28); rINTMSK=~(BIT_GLOBAL | BIT_EINT4567); //中断有效 } /**************************************************************************** 【功能说明】系统主函数 ****************************************************************************/ void Main(void) { unsigned int ps2ack; rSYSCFG=SYSCFG_8KB; //使用8K字节的指令缓存 rNCACHBE0=((unsigned int)(Non_Cache_End>>12)<<16)|(Non_Cache_Start>>12); //在上面的数据区域不使用高速缓存 Port_Init(); //IO端口功能、方向设定 Led_Disp(); //LED来回闪烁显示 ChangePllValue(56,2,1); //修改系统主频为8倍频 Uart_Init(0,SERIAL_BAUD); //异步串行口初始化,设置波特率为115200 Delay(0); Isr_Init(); //中断初始化 ps2_command(0xff); ps2_waitack(1, &ps2ack); if((ps2ack&0xff)==0xfa) Uart_Printf("PS2 reset ok\n"); else Uart_Printf("PS2 reset error\n"); ps2_command(0xf2); ps2_waitack(3, &ps2ack); if((ps2ack&0xffff)==0xab83) Uart_Printf("Find PS2 Keyboard\n"); else Uart_Printf("Unkonwn PS2 device id : %x\n", ps2ack); while(1) { ps2_buffer_check(); } } //***************************************************************************