?? main.c
字號:
#include <string.h>
#include <stdio.h>
#include "Target\44b.h"
#include "Target\44blib.h"
/********************************************/
// ARMSYS實驗五:I/O應用測試
// 描述:矩陣鍵盤掃描讀入
/********************************************/
const char Keyboard[4][4] = {
{'7','8','9','/'},
{'4','5','6','*'},
{'1','2','3','-'},
{'0','.','+','\n'}};
char ReadKeybd(void)
{
unsigned int PCONFback=0;
unsigned int PUPFback=0;
unsigned char scanvalue[4] ={0xfe,0xfd,0xfb,0xf7};
unsigned char i,j,x,temp;
char keyvalue=0;
PCONFback = rPCONF;
rPCONF = 0x55;//pf0-pf3:output, pf4-pf7:input
PUPFback=rPUPG;
rPUPF=0xff;//disable pull-up
rPDATF=0xf0;//pf0-pf3:0
if((temp=(rPDATF&0xf0))!=0xf0){
for(i=0;i<4;i++){
rPDATF=scanvalue[i];
for(x=0;x<100;x++);
if((temp=(rPDATF&0xf0))!=0xf0){
temp=(~(temp>>4))&0x0f;
for(j=0;j<4;j++){
if(temp==0x01){
keyvalue=Keyboard[j][i];
return keyvalue;
}
else
temp=temp>>1;
}
}
}
}
rPCONF=PCONFback;
rPUPF=PUPFback;
return keyvalue;
}
void Main(void)
{
char aa,ch1=0,ch2=0;
unsigned char keyflg=0;
Port_Init();
Led_Display(0xf);
Beep(0x1);
Uart_Printf("\n\n*************************************************************************");
Beep(0x0);
Uart_Printf("\n* 立泰電子 *");
Uart_Printf("\n* -S3C44B0X功能部件:I/O測試- *");
Uart_Printf("\n* Version 1.11 *");
Uart_Printf("\n* Email:rao_dali@263.net *");
Uart_Printf("\n* UART Config--COM:115.2kbps,8Bit,NP,UART0 *");
Uart_Printf("\n*------------------Begin to Start IO test,OK? (Y/N)--------------------*");
Led_Display(0x0);
aa= Uart_Getch();
if((aa=='Y')||(aa=='y'))
{
Uart_Printf("\nBegin Keyboard Scan...");
while(1)
{
ch1=ReadKeybd();
if(ch1!=0){
if((keyflg==1)&&(ch1==ch2))//Co
{
Uart_SendByte(ch1);
while((rPDATF&0xf0)!=0xf0);//等待按鍵釋放
}
else{
keyflg=1;
ch2=ch1;
}
}
else{
keyflg=0;
ch2=0;
}
Delay(1000);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -