关于EEPROM(I2C mini2440)的随机读取数据问题
flag=2;buf=0x0;locate=0x10;
rIICDS=0xa0;//伪写第一阶段,写从机地址
delay(1000);
rIICCON=0xe1;
rIICSTAT=0xf0;
return 0;
}
void irq_process()
{
int puts(unsigned char*);
int printx(unsigned long);
int i;
rSRCPND=~0;
rINTPND=~0;
if(flag==1)//NO ACK
{
puts("flag 1\r\n");
buf=rIICDS;
printx(rIICDS); puts(" ");printx(rIICCON);puts(" ");printx(rIICSTAT);
rIICCON=0x61;//no ACK
flag=0;
}
else if(flag==2)//伪写的第二个阶段,发送数据起始地址
{
puts("flag 2\r\n");
printx(rIICDS); puts(" ");printx(rIICCON);puts(" ");printx(rIICSTAT);
puts("\r\n");
rIICDS=locate;//想读的数据起的始地址
delay(1000);
printx(rIICDS); puts(" ");printx(rIICCON);puts(" ");printx(rIICSTAT);
rIICCON=0xe1;
flag=3;
}
else if(flag==3)//M_R restart
{
puts("flag 3\r\n");
printx(rIICDS); puts(" ");printx(rIICCON);puts(" ");printx(rIICSTAT);
puts("\r\n");
rIICDS=0xa0;//以主读方式再次发送开始信号
delay(1000);
rIICSTAT=0xb0;
rIICCON=0xe1;
printx(rIICDS); puts(" ");printx(rIICCON);puts(" ");printx(rIICSTAT);
flag=1;
}
else if(!flag)
{
puts("flag 0\r\n");
buf=rIICDS;
//printx(buf);//读取数据
printx(rIICDS); puts(" ");printx(rIICCON);puts(" ");printx(rIICSTAT);
flag=4;
rIICSTAT=0x90;
}
else
puts("flag 4 \r\n");
puts("INT\r\n");
}