📄 main.c
字号:
#include <string.h>
#include "\inc\define.h"
#include "\inc\drives.h"
#include "\inc\TBlib.h"
#include "ps2\PS2KeyBoard.h"
#include "lcd\lcd.h"
//依次为按键abcd....xyz,所对应的键值,最后一个为0xf0,break的前导码
U8 CodeSet3_TruthTable[27]={
0x1c,
0x32,
0x21,
0x23,
0x24,
0x2b,
0x34,
0x33,
0x43,
0x3b,
0x42,
0x4b,
0x3a,
0x31,
0x44,
0x4d,
0x15,
0x2d,
0x1b,
0x2c,
0x3c,
0x2a,
0x1d,
0x22,
0x35,
0x1a,
0xf0,
};
U8 EmptyDisplay[]={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,};
extern U8 English_Alphabet[];
extern U8 hanjie_zk[];
extern U8 zifu_a[];
extern U8 C256Palette[256];
extern U8 laqbmp[];
extern U8 zxybmp[];
extern U8 Virtualbmp[];
void Main(void)
{
U8 i=0, j=0, k=0, mytemp;
DisableInt(); //Disable interrupt
BoardInitStart();
SystemClockInit();
TimerInit(TIMER_FREQ);
MemCfgInit();
PortInit();
SerialChgBaud(115200);
// ISRInit();
BoardInitEnd();
CacheFlush();
CacheEnable();
EnableInt();
Lcd_Init ();
//Led_Display(0xf);
Delay(0);
Beep(0x1,500);
Uart_Select(0);
Uart_Printf("\n----------------------------------------------------------------");
Beep(0x00,500);
Uart_Printf("\nOEM name : 浙江大学机械电子控制工程研究所 ");
Uart_Printf("\nWebsite : www.zju.edu.cn ");
Uart_Printf("\nPowered by : LSG, ZFS ");
Uart_Printf("\nEmail : zhaofengshen@gmail.com ");
Uart_Printf("\nFunction : ARMSYS44b0's PS/2 KeyBoarder test Program ");
Uart_Printf("\nUART Config: 115.2kbps,8Bit,NP,UART0 ");
Uart_Printf("\n----------------------------------------------------------------");
Uart_Printf("\nS3C44B0X Test Program Ver 2.0 rSYSCFG=0x%x MCLK=%dHz\n",rSYSCFG,MCLK_D);
//Led_Display(0x0);
draw_zf(20,20,hanjie_zk,RED,16,16);
draw_zf(40,40,hanjie_zk,RED,16,16);
do
{
PS2Command_init(0xff);//reset
}while(0xfa != PS2_GetKeyDat());
do
{
PS2Command_init(0xf5);//default disable
}while(0xfa != PS2_GetKeyDat());
do
{
PS2Command_init(0xf3);//set delay and typematic
}while(0xfa != PS2_GetKeyDat());
do
{
PS2Command_init(0x1f);//delay and typematic
}while(0xfa != PS2_GetKeyDat());
do
{
PS2Command_init(0xf0);//set scan codes
}while(0xfa != PS2_GetKeyDat());
do
{
PS2Command_init(0x03);//scan codes 3
}while(0xfa != PS2_GetKeyDat());
do
{
PS2Command_init(0xf9);// 0xf8:make and break; 0xf9: only make
}while(0xfa != PS2_GetKeyDat());
do
{
PS2Command_init(0xf4);//enable
}while(0xfa != PS2_GetKeyDat());
LcdDraw_backgroundcolor(BLUE);
for(i=0;i<100;i++)
{
_PutPixelC256(50+i,50+i,GREEN);
}
PaletteGenerator();
while(1)
{
mytemp = PS2_GetKeyDat();
switch(mytemp)
{
case 0x5a://carrage return
k++;
j = 0;
break;
case 0x66://back space
if(j>0)
{
j--;
}
draw_zf(j*8,k*16,EmptyDisplay,BLUE,8,16);
break;
case 0x29://space
draw_zf(j*8,k*16,EmptyDisplay,BLUE,8,16);
j++;
if(j==80)
{
j=0;
k++;
}
break;
default:
for(i=0;i<27;i++)
{
if(CodeSet3_TruthTable[i] == mytemp)
{
draw_zf(j*8,k*16,English_Alphabet+16*i,RED,8,16);
j++;
if(j==80)
{
j=0;
k++;
}
break;
}
}
}
}
while(1)
{
Uart_Printf("%0x\n",PS2_GetKeyDat());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -