summaryrefslogtreecommitdiff
path: root/mcc_generated_files/mssp2_i2c.c
diff options
context:
space:
mode:
authorJoshua Drake <Joshua.Ellis.Drake@gmail.com>2024-05-04 11:11:46 -0500
committerJoshua Drake <Joshua.Ellis.Drake@gmail.com>2024-05-04 11:11:46 -0500
commit3ee1a69c65589a744b67f770001022a884fe32ba (patch)
treeef53fc0b4d58ceee84a1e9d6b2956e6775cd5003 /mcc_generated_files/mssp2_i2c.c
parentdf6a4c2b5711ba7cda3cadd91d4b625c7a06da9d (diff)
Code is fully functional with delay timer at uC level.
Diffstat (limited to 'mcc_generated_files/mssp2_i2c.c')
-rw-r--r--mcc_generated_files/mssp2_i2c.c15
1 files changed, 10 insertions, 5 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];