summaryrefslogtreecommitdiff
path: root/mcc_generated_files
diff options
context:
space:
mode:
Diffstat (limited to 'mcc_generated_files')
-rw-r--r--mcc_generated_files/mssp2_i2c.c15
-rw-r--r--mcc_generated_files/mssp2_i2c.h3
2 files changed, 12 insertions, 6 deletions
diff --git a/mcc_generated_files/mssp2_i2c.c b/mcc_generated_files/mssp2_i2c.c
index dabd9a9..580366b 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 = 10; //Number of timer iterations since clear
+static uint8_t I2C_timeout = 0; //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,10 +188,10 @@ void __attribute__((interrupt, no_auto_psv)) _MSSP2Interrupt(void) {
}
if (SSP2STATbits.R_NOT_W == 0) // Master write (slave receive)
{
-
+ resetTimeoutCounter(); //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.
+ //resetTimeoutCounter(); //Reset our counter when a message is received.
_LATB7 = !_LATB7;
regAdd = 1; // Next byte register address
temp = SSP2BUF; // Clear BF
@@ -199,6 +199,7 @@ void __attribute__((interrupt, no_auto_psv)) _MSSP2Interrupt(void) {
}
if (SSP2STATbits.D_NOT_A == 1) // Last byte was data
{
+ //resetTimeoutCounter(); //Reset our counter when a message is received.
if (regAdd == 1) // Last byte was register add
{
index = SSP2BUF; // Load register address
@@ -225,15 +226,19 @@ void __attribute__((interrupt, no_auto_psv)) _MSSP2Interrupt(void) {
_LATB8 = !SSP2CON1bits.SSPOV;
}
-uint8_t getTimeoutCounter()
+uint8_t* getTimeoutCounter()
{
- return I2C_timeout;
+ return &I2C_timeout;
}
void incrementTimeoutCounter()
{
I2C_timeout++;
}
+void resetTimeoutCounter()
+{
+ I2C_timeout = 0x00;
+}
uint8_t getI2CArray(int index)
{
if(index < 5)return i2cArray[index];
diff --git a/mcc_generated_files/mssp2_i2c.h b/mcc_generated_files/mssp2_i2c.h
index f76d48c..329983a 100644
--- a/mcc_generated_files/mssp2_i2c.h
+++ b/mcc_generated_files/mssp2_i2c.h
@@ -149,7 +149,8 @@ typedef enum
</code>
*/
-uint8_t getTimeoutCounter(void);
+uint8_t* getTimeoutCounter(void);
+void resetTimeoutCounter(void);
void incrementTimeoutCounter(void);
void MSSP2_I2C_Initialize(void);