исправлена процедура верификации SPI
This commit is contained in:
parent
f858d0f702
commit
2ddcdbcda0
@ -253,29 +253,32 @@ uint16_t I2CVerify(uint16_t slaveAddr, uint16_t byteCount, bool sendStopConditio
|
|||||||
I2caRegs.I2CMDR.bit.STT = 0x1;
|
I2caRegs.I2CMDR.bit.STT = 0x1;
|
||||||
|
|
||||||
TimerTimeouts = 0;
|
TimerTimeouts = 0;
|
||||||
while((count < (byteCount))&&(TimerTimeouts < TIME_OVER))
|
while( (I2caRegs.I2CFFRX.bit.RXFFST < byteCount) && (TimerTimeouts < TIME_OVER*byteCount));
|
||||||
|
if(TimerTimeouts >= TIME_OVER)
|
||||||
{
|
{
|
||||||
// if(count == (byteCount-1)) {I2caRegs.I2CMDR.bit.NACKMOD = 0x1; I2caRegs.I2CMDR.bit.STP = 0x1;}
|
ErrI2c3++;
|
||||||
if(I2caRegs.I2CSTR.bit.RRDY ==0x1)
|
return 1;
|
||||||
{
|
|
||||||
RXdata = I2caRegs.I2CDRR.all;
|
|
||||||
if(I2C_Vfdata[count] != RXdata) VerErr = 1;
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(TimerTimeouts >= TIME_OVER) {ErrI2c2 += (byteCount - count); return 1;}
|
|
||||||
|
|
||||||
//
|
I2caRegs.I2CMDR.bit.STP = 0x1;
|
||||||
// Send STOP condition
|
|
||||||
//
|
for(count=0; count < byteCount; count++)
|
||||||
if(sendStopCondition)
|
|
||||||
{
|
{
|
||||||
I2caRegs.I2CMDR.bit.STP = 0x1;
|
RXdata = I2caRegs.I2CDRR.all;
|
||||||
TimerTimeouts = 0;
|
if(I2C_Vfdata[count] != RXdata) VerErr = 1;
|
||||||
while((I2caRegs.I2CMDR.bit.STP != 0x0)&&(TimerTimeouts < TIME_OVER));
|
|
||||||
I2caRegs.I2CSTR.bit.BYTESENT = 0x1;
|
|
||||||
if(TimerTimeouts >= TIME_OVER) {ErrI2c3++; return 1;}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
I2caRegs.I2CMDR.bit.NACKMOD = 0x1;
|
||||||
|
|
||||||
|
TimerTimeouts = 0;
|
||||||
|
while((I2caRegs.I2CMDR.bit.STP != 0x0)&&(TimerTimeouts < TIME_OVER));
|
||||||
|
if(TimerTimeouts >= TIME_OVER)
|
||||||
|
{
|
||||||
|
ErrI2c5++;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
I2caRegs.I2CSTR.bit.BYTESENT = 0x1;
|
||||||
|
I2caRegs.I2CFFRX.bit.RXFFINTCLR = 0;
|
||||||
if(VerErr) return 2;
|
if(VerErr) return 2;
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user