读取字节:
读取字节:
uint8_t Read_Byte(){
uint8_t i=0;
unsigned char temp=0x00;
Set(STB);
Write_Byte(0x42); //传按键检测命令
delay_us(1); //与之后的读取要至少有1us的延时
Reset(STB);
GPIO1(); //将GPIO口从输出变为输入 !!!
// Set(DIO);
Reset(CLK);
delay_us(2);
for(i=0;i<8;i++){ //一次读取8bit
Set(CLK); //拉高CLK开始读取数据
//read
delay_us(4);
temp = temp>>1;
if(Get(DIO) !=0 ){
temp = (temp |0x80 );
}
else {
temp &= 0x7f;
}
Reset(CLK);
delay_us(4);
}
Set(CLK);
Set(STB);
return temp;
}
</