u8 Matrixkey(void)
{
u8 j=20;
u16 temp1,temp;
RCC->APB2ENR|=1<<2; //????PORTA?±??
JTAG_Set(SWD_ENABLE); //??±?JTAG,????SWD
JTAG_Set(JTAG_SWD_DISABLE) ;
//-----------------------------------------------------------
GPIOA->CRL&=0X0000FFF0; //????
GPIOA->CRL|=0X88880003; //PB0~PB3 ???ì????,PB4~PB7???????
if((GPIOA->IDR & 0X00f0)==0x00f0) //????°??ü
return j;
else
{
temp=(GPIOA->IDR & 0x00f0);
delay_ms(10); //°??ü????
if((GPIOA->IDR & 0X00f0)==0x00f0) //????°??ü
return j;
else
{
temp1=(GPIOA->IDR & 0x00f0);
while(temp==temp1){};
switch(temp1)
{
case 0x00ee:j=0;break;
case 0x00de:j=1;break;
case 0x00be:j=2;break;
case 0x007e:j=3;break;
default:break;
}
}
}
//----------------------------------------------
GPIOA->CRL&=0XFFFFFF0F; //
GPIOA->CRL|=0X88880030; //
//------------------------------------------------
if((GPIOA->IDR & 0X00f0)==0x00f0) //????°??ü
return j;
else
{
temp=(GPIOA->IDR & 0x00f0);
delay_ms(10); //°??ü????
if((GPIOA->IDR & 0X00f0)==0x00f0) //????°??ü
return j;
else
{
temp1=(GPIOA->IDR & 0x00f0);
while(temp==temp1){};
switch(temp1)
{
case 0x00ed:j=4;break;
case 0x00dd:j=5;break;
case 0x00bd:j=6;break;
case 0x007d:j=7;break;
default:break;
}
}
}
//--------------------------------------------------------------
GPIOA->CRL&=0XFFFFF0FF; //
GPIOA->CRL|=0X88880300; //PB0~PB3 ???ì????
//------------------------------------------------
if((GPIOA->IDR & 0X00f0)==0x00f0) //????°??ü
return j;
else
{
temp=(GPIOA->IDR & 0x00f0);
delay_ms(10); //°??ü????
if((GPIOA->IDR & 0X00f0)==0x00f0) //????°??ü
return j;
else
{
temp1=(GPIOA->IDR & 0x00f0);
while(temp==temp1){};
switch(temp1)
{
case 0x00eb:j=8;break;
case 0x00db:j=9;break;
case 0x00bb:j=10;break;
case 0x007b:j=11;break;
default:break;
}
}
}
//--------------------------------------------------------------
GPIOA->CRL&=0XFFFF0FFF; //
GPIOA->CRL|=0X88883000; //PB0~PB3 ???ì????
//------------------------------------------------
if((GPIOA->IDR & 0X00f0)==0x00f0) //????°??ü
return j;
else
{
temp=(GPIOA->IDR & 0x00f0);
delay_ms(10); //°??ü????
if((GPIOA->IDR & 0X00f0)==0x00f0) //????°??ü
return j;
else
{
temp1=(GPIOA->IDR & 0x00f0);
while(temp==temp1){};
switch(temp1)
{
case 0x00e7:j=15;break;
case 0x00d7:j=14;break;
case 0x00b7:j=13;break;
case 0x0077:j=12;break;
default:break;
}
}
}
}
一周热门 更多>