From 2ddcdbcda09c921e66afe3b395fb47f06bb5bac4 Mon Sep 17 00:00:00 2001 From: seklyuts Date: Fri, 29 Mar 2024 16:55:32 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D0=B4=D1=83?= =?UTF-8?q?=D1=80=D0=B0=20=D0=B2=D0=B5=D1=80=D0=B8=D1=84=D0=B8=D0=BA=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20SPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Peripherals/i2c_init.c | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/Projects/EFC_IPC_Server_C28/src/Peripherals/i2c_init.c b/Projects/EFC_IPC_Server_C28/src/Peripherals/i2c_init.c index b6206d2..854532d 100644 --- a/Projects/EFC_IPC_Server_C28/src/Peripherals/i2c_init.c +++ b/Projects/EFC_IPC_Server_C28/src/Peripherals/i2c_init.c @@ -253,29 +253,32 @@ uint16_t I2CVerify(uint16_t slaveAddr, uint16_t byteCount, bool sendStopConditio I2caRegs.I2CMDR.bit.STT = 0x1; 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;} - if(I2caRegs.I2CSTR.bit.RRDY ==0x1) - { - RXdata = I2caRegs.I2CDRR.all; - if(I2C_Vfdata[count] != RXdata) VerErr = 1; - count++; - } + ErrI2c3++; + return 1; } - if(TimerTimeouts >= TIME_OVER) {ErrI2c2 += (byteCount - count); return 1;} - // - // Send STOP condition - // - if(sendStopCondition) + I2caRegs.I2CMDR.bit.STP = 0x1; + + for(count=0; count < byteCount; count++) { - I2caRegs.I2CMDR.bit.STP = 0x1; - TimerTimeouts = 0; - while((I2caRegs.I2CMDR.bit.STP != 0x0)&&(TimerTimeouts < TIME_OVER)); - I2caRegs.I2CSTR.bit.BYTESENT = 0x1; - if(TimerTimeouts >= TIME_OVER) {ErrI2c3++; return 1;} + RXdata = I2caRegs.I2CDRR.all; + if(I2C_Vfdata[count] != RXdata) VerErr = 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; else return 0; }