📄 main.c
字号:
#include "option.h"
#include "def.h"
#include "44b.h"
#include "44blib.h"
void Isr_Init(void);
void HaltUndef(void);
void HaltSwi(void);
void HaltPabort(void);
void HaltDabort(void);
void __irq keyboard(void);
void clr_pf(char onebit);
void setb_pf(char onebit);
void __irq keyboard(void)
{
char x=0,y=0,yrecord;
rINTMSK=(BIT_GLOBAL|BIT_EINT3);
Delay(200);
Uart_Printf("come in, \n");
if((rPDATE&0xf0)==0xf0)
{
rPDATF=0X1f;
rINTMSK=~(BIT_GLOBAL|BIT_EINT3);
rI_ISPC = BIT_EINT3;
return;
}
else
{
for (x=5; x<9; x++)
{
rPDATF=0X1ff;
clr_pf(x);
if ((rPDATE&0xf0) !=0xf0)
{
yrecord=(~((rPDATE&0xf0)>>4))&0xf;
for (y=0; yrecord!=0; y++)
{
yrecord=(yrecord>>1);
}
setb_pf(x);
Uart_Printf("输入的键值是 %d \n", (y+(x-5)*4-1));
Delay(100);
switch(y+(x-5)*4-1)
{
case 0:
break;
default:
break;
}
rPDATF=0X1F;
rINTMSK=~(BIT_GLOBAL|BIT_EINT3);
rI_ISPC = BIT_EINT3;
return;
}
setb_pf(x);
}
rPDATF=0X1F;
rINTMSK=~(BIT_GLOBAL|BIT_EINT3);
rI_ISPC = BIT_EINT3;
return;
}
}
/*********************************************************/
void setb_pf(char onebit)
{
rPCONF=(rPCONF&0x03ff)|(1<<10)|(1<<13)|(1<<16)|(1<<19) ;
rPDATF=(rPDATF&0x1ff)|(0x1<<onebit);
}
/*********************************************************/
void clr_pf(char onebit)
{
unsigned int i,s=0;
for(i=0; i<onebit; i++)
{
s=(s|(0x1<<i));
}
rPDATF=(rPDATF&0x1ff)&((0x1fe<<onebit)|s);
}
/***********************************************************************/
void Main(void)
{
U8 aa;
int i=0,j=0;
rSYSCFG=SYSCFG_8KB;
#if (PLLON==1)
ChangePllValue(PLL_M,PLL_P,PLL_S);
#endif
Isr_Init();
Port_Init();
Uart_Init(0,115200);
Uart_Select(0);
Delay(0); //calibrate Delay()
Led_Display(7);
Delay(1000); //calibrate Delay()
Led_Display(0);
Delay(5000); //calibrate Delay()
Led_Display(7);
Uart_Printf("\n start \n");
rEXTINT=0x22222222;
rINTCON=0x5;
pISR_EINT3=(unsigned)keyboard;
rPCONF=(rPCONF&0x03ff)|(1<<10)|(1<<13)|(1<<16)|(1<<19) ; //0x92400; //rPCONG=(rPCONG&0x00ff)|0x5500;
Uart_Printf("\n请作键盘输入,将会在超级终端看到键值\n");
rINTMSK =~(BIT_GLOBAL|BIT_EINT3);
while(!Uart_GetKey())
{
;
}
rINTMSK|=BIT_EINT3;
}
void Isr_Init(void)
{
U32 i;
pISR_UNDEF=(unsigned)HaltUndef;
pISR_SWI =(unsigned)HaltSwi;
pISR_PABORT=(unsigned)HaltPabort;
pISR_DABORT=(unsigned)HaltDabort;
for(i=_RAM_STARTADDRESS;i<(_RAM_STARTADDRESS+0x20);i+=4)
{
*((volatile unsigned *)i)=0xEA000000+0x1FFE;
}
rINTCON=0x5; // Non-vectored,IRQ enable,FIQ disable
rINTMOD=0x0; // All=IRQ mode
rINTMSK|=BIT_GLOBAL|BIT_EINT3; // All interrupt is masked.
}
void HaltUndef(void)
{
Uart_Printf("Undefined instruction exception!!!\n");
while(1);
}
void HaltSwi(void)
{
Uart_Printf("SWI exception!!!\n");
while(1);
}
void HaltPabort(void)
{
Uart_Printf("Pabort exception!!!\n");
while(1);
}
void HaltDabort(void)
{
Uart_Printf("Dabort exception!!!\n");
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -