下面这个程序谁帮我翻译一下?发送命令10+0+000(操作码+锁定位+块0地址)之后捕捉第0页块0的数据。
说白了就是要在什么情况下被翻译为0,什么情况下被翻译为1.看得晕晕的,忘高手指点一二。
#define EMda1 C1OUT;
#define EMda1 (!C1OUT);
unsigned char readBIT(void)
{
unsigned char t;
while(1)
{
if(TMR0>40) break; //大于40FC=320us
}
TMR0 = 0;
if(EMda1)
{
while(1)
{
t=TMR0;
if(t>44) return 3;
if(EMda0) break;
}
TMR0=0;
if(t>8) return 1;
return 4;
}
else
{
while(1)
{
t=TMR0;
if(t>44) return 5;
if(EMda1) break;
}
TMR0=0;
if(t>8) return 0;
return 6;
}
}
unsigned char ReadWord(unsigned char *cd, unsigned char len)
{
unsigned char ch, i, j, b;
for (i=0; i<len; i++)
{
ch = 0;
for (j=0; j<8; j++)
{
ch <<= 1;
b = readBIT();
if (b > 1) return 1;
if (b)
{
ch |= 0x01;
}
}
cd = ch;
}
return 0;
}
unsigned char Read_T5557(void)
{
unsigned char step=0;
OSCTUNE = osctune_picc;
EnableRFDecode();
RFON();
for (TMR_Counter=0; TMR_Counter<10; )
{
if (GetPreamble()==0)
{
if (ReadWord(appdat, 32) == 0)
{
step =1;
break;
}
}
}
RFOFF();
DisableRFDecode();
OSCTUNE = 0;
return step;
}
void BlockRead5557(void)
{
unsigned char ch, i;
ch = 0x80; //| (1<<2);
RFOFF(); TMR0 = 0;
for (i=0; i<2; i++)
{
while(TMR0<MaskGapS) {};
RFON();
if (ch & 0x80) TMR0 = 0;
else TMR0 = Mask5557_1-Mask5557_0;
ch <<= 1;
while(TMR0<Mask5557_1) {};
RFOFF(); TMR0 = MaskGapS-MaskGapW;
}
while(TMR0<MaskGapS) {};
RFON();
__delay_ms(600);
RFOFF();
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>