实用文档
if(PassCount == I2C_NUMBYTES) {
pass(); } else {
fail(); }
//检查完毕
} }
} // end of stop condition detected // Interrupt source = Register Access Ready
// This interrupt is used to determine when the EEPROM address setup portion of the //该中断用于判断读数据通讯中何时完成EEPROM数据地址的设置;
// read data communication is complete. Since no stop bit is commanded, this flag //由于不产生停止位,这个标志(ARDY)告诉我们地址数据是否发送完成。
// tells us when the message has been sent instead of the SCD flag. If a NACK is //如果收到NACK,清除NACK位,并设置产生一个停止位。
// received, clear the NACK bit and command a stop. Otherwise, move on to the read //否则,继续读取通讯数据。
// data portion of the communication. else if(IntSource == I2C_ARDY_ISRC) //IIC模块准备好中断:包括【复位,发完一个数据单元(1~8bits的数据)
{ //却没收到ACK/STOP或者出现counter=0】都可引发该中断 ARDY_ISRC_number++;
if(I2caRegs.I2CSTR.bit.NACK == 1) //因为EEPROM处理数据忙而回复的NACK {
I2caRegs.I2CMDR.bit.STP = 1; //产生一个STOP停止位,从而引发一次SCD中断。 I2caRegs.I2CSTR.all = I2C_CLR_NACK_BIT; //清除NACK位 }
else if(CurrentMsgPtr->MsgStatus == I2C_MSGSTAT_SEND_NOSTOP_BUSY) {
CurrentMsgPtr->MsgStatus = I2C_MSGSTAT_RESTART;//更新为重发START位状态,为接收数据准备 }
} // end of register access ready else {
// Generate some error due to invalid interrupt source asm(\
ARDY_ISRC_NACK_number++;
文案大全
实用文档
}
// Enable future I2C (PIE Group 8) interrupts
PieCtrlRegs.PIEACK.all = PIEACK_GROUP8; //重启中断允许 }
void pass() {
asm(\ for(;;); }
void fail() {
asm(\ for(;;); }
//=========================================================================== // No more.
//===========================================================================
文案大全