?? main.c
字號:
/****************************************************************************
* file name : main.c
* By : www.sanhengxing.com
****************************************************************************/
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#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); //中斷有效
}
/****************************************************************************
【功能說明】系統(tǒng)主函數(shù)
****************************************************************************/
void Main(void)
{
unsigned int ps2ack;
rSYSCFG=SYSCFG_8KB; //使用8K字節(jié)的指令緩存
rNCACHBE0=((unsigned int)(Non_Cache_End>>12)<<16)|(Non_Cache_Start>>12);
//在上面的數(shù)據(jù)區(qū)域不使用高速緩存
Port_Init(); //IO端口功能、方向設定
Led_Disp(); //LED來回閃爍顯示
ChangePllValue(56,2,1); //修改系統(tǒng)主頻為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();
}
}
//***************************************************************************
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -