From be85c16280015d192128e85170f79eddd487e447 Mon Sep 17 00:00:00 2001 From: Joshua Drake Date: Fri, 26 Apr 2024 16:41:10 -0500 Subject: Changes made during testing. --- mcc_generated_files/mssp2_i2c.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'mcc_generated_files/mssp2_i2c.c') diff --git a/mcc_generated_files/mssp2_i2c.c b/mcc_generated_files/mssp2_i2c.c index 2a07931..dabd9a9 100644 --- a/mcc_generated_files/mssp2_i2c.c +++ b/mcc_generated_files/mssp2_i2c.c @@ -128,7 +128,7 @@ uint8_t yeah; #define ARRAY_CNT 6 // Number of bytes in array uint8_t slaveAddress = 0x30; // 7-bit slave address uint8_t index = 0; // Array pointer -uint8_t I2C_timeout = 0; //Number of timer iterations since clear +uint8_t I2C_timeout = 10; //Number of timer iterations since clear uint8_t temp = 0; // Temp register uint8_t regAdd = 1; // First data byte was reg add uint8_t i2cArray[ARRAY_CNT] = @@ -188,9 +188,10 @@ void __attribute__((interrupt, no_auto_psv)) _MSSP2Interrupt(void) { } if (SSP2STATbits.R_NOT_W == 0) // Master write (slave receive) { - I2C_timeout = 0x00; //Reset our counter when a message is received. + if (SSP2STATbits.D_NOT_A == 0) // Last byte was an address - { + { + I2C_timeout = 0; //Reset our counter when a message is received. _LATB7 = !_LATB7; regAdd = 1; // Next byte register address temp = SSP2BUF; // Clear BF @@ -233,7 +234,7 @@ void incrementTimeoutCounter() { I2C_timeout++; } -uint8_t getI2CArray(uint8_t index) +uint8_t getI2CArray(int index) { if(index < 5)return i2cArray[index]; else return 0; -- cgit v1.2.3