读书人

於汇编语言的解决办法

发布时间: 2012-02-24 16:30:38 作者: rapoo

於汇编语言的
是案的程式
但我有些部分看不懂
麻大大忙我解一下

#include <avr/io.h>

//function prototypes for user defined functions
char ReadKeypad();

int main()
{
unsigned char key;

DDRA = 0xFF;

while(1)
{
key = ReadKeypad();

if (key==0xFF) continue; //不懂

PORTA = key; //不懂
}

while(1);
return 0;
}

//define a look-up table
char lookup[]={ '1 ', '2 ', '3 ', 'A ',
'4 ', '5 ', '6 ', 'B ',
'7 ', '8 ', '9 ', 'C ',
'* ', '0 ', '# ', 'D '};

char ReadKeypad()
{
//declare local variables
unsigned char row, col;
unsigned char input, shift;

//define Port D to connect to the kaypad
//PD0 - PD3 as input, PD4 - PD7 as output
DDRD = 0xF0; //不懂 什是0xF0 而不是0xFF

//write 1 's to those pins defined as input
//to enable the pull-up R 's
PORTD = 0xFF;

//prepare scanning
row = 0;//the first row //不懂
shift = 0x10;//the first row as 1 //不懂

//start scanning
for (row=0; row <4; row++)
{
PORTD = ~shift; //不懂
shift = shift < <1;//shift < <= 1; //不懂
input = PIND; //不懂

input = input | 0xF0;//screen the output pins //不懂
input = ~(input); //不懂

if (input != 0) //不懂
break;

}

//any key pressed?
if (row < 4) //不懂
{
//the loop was broken because a key was pressed
//the row output 0 is the row value

//find out the col which is 1
shift = 0x01; //不懂
for (col=0; col <4; col++) //不懂
{
if (input & shift) //不懂
{
//use input to hold the key value
input = 4*row + col; //不懂
//return input;
return lookup[input]; //不懂
}
shift = shift < <1; //不懂
}



}
input = 0xFF; //不懂
return input; //不懂
}

[解决办法]
发到C语言版吧
[解决办法]
看看 的ascii

读书人网 >C语言

热点推荐