diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 30 |
1 files changed, 16 insertions, 14 deletions
@@ -47,6 +47,7 @@ */
#include "mcc_generated_files/system.h"
#include "SPI.h"
+#include <stdbool.h>
/*
@@ -54,7 +55,7 @@ */
uint8_t nullarray = {0x00, 0x00, 0x00};
uint8_t desired150, desired68, current150, current68 = 0;
-uint8_t relay_delay_counter = 0;
+bool relay_delay = false;
void TMR1_Process(void);
@@ -64,7 +65,7 @@ int main(void) SYSTEM_Initialize();
//OSCCONbits.SOSCEN = 0;
SPI_slaveDeselect();
- _LATA0 = _LATA1 = 1;//_LATA4 = 1; //Activate gate driver chips
+ _LATA0 = _LATA1 = 0;//_LATA4 = 1; //Activate gate driver chips
_LATA4 = 1;
SPI_slaveSelect();
@@ -82,15 +83,16 @@ int main(void) while (1)
{
- desired150 = getI2CArray(0x01) & 0b00001111;
- desired68 = (getI2CArray(0x01) & 0b01110000) >> 4;
+ desired150 = getI2CArray(1) & 0x0F;
+ desired68 = (getI2CArray(1) & 0x70) >> 4;
- if((relay_delay_counter % 2 == 0)&&(getTimeoutCounter() < 2))
- {
+ //if((relay_delay)&&(getTimeoutCounter() < 2))
+ //{
+ //relay_delay = false;
SPI_slaveSelect();
- current150 = active150();
+ current150 = current150();
SPI_slaveDeselect();
-
+ /*
SPI_slaveSelect();
current68 = active68();
SPI_slaveDeselect();
@@ -121,19 +123,19 @@ int main(void) }
}
- else { //Open contactors if I2C communication is broken.
+ if(getTimeoutCounter() > 2){ //Open contactors if I2C communication is broken.
SPI_slaveSelect();
Message_OUT(0, 0, 0);
SPI_slaveDeselect();
_LATB8 = 0;
_LATB7 = 1;
- }
- /*
+ }*/
+
SPI_slaveSelect();
- Message_OUT(15, 5, 0);
+ Message_OUT(desired150, 0, relay_delay);
SPI_slaveDeselect();
-
+ /*
SPI_slaveSelect();
Message_OUT(15, 5, 0);
SPI_slaveDeselect();
@@ -156,7 +158,7 @@ int main(void) void __attribute__ ((weak)) TMR1_Process(void)
{
- relay_delay_counter++;
+ relay_delay = !relay_delay;
incrementTimeoutCounter();
}
/**
|