diff --git a/VCU/Phantom/Drivers/STATE_MACHINE/state_machine.c b/VCU/Phantom/Drivers/STATE_MACHINE/state_machine.c index d570658c..4afd279f 100644 --- a/VCU/Phantom/Drivers/STATE_MACHINE/state_machine.c +++ b/VCU/Phantom/Drivers/STATE_MACHINE/state_machine.c @@ -14,6 +14,7 @@ #include "task_event_handler.h" #include "task_throttle.h" #include "task_logger.h" +#include "board_hardware.h" static void UpdateStateMachine(void* data); static State VariousStates(State state, eCarEvents event); @@ -25,6 +26,14 @@ static State SevereFault(eCarEvents event); static SystemTasks_t system_tasks; +void VCU_FLT_Set(int value) +{ + //Toggles VCU_FLT pin defined in hardware file. + + gioSetBit(SHUTDOWN_CIRCUIT_PORT,BSPD_FAULT_PIN,value);//Check pin since no VCU_FLT pin is defined in the hardware file. We assumed no latch is available thus fault must stay until car reset. + + return; +} /* Public API */ @@ -138,6 +147,10 @@ static State VariousStates(State state, eCarEvents event) if (faults && state != SEVERE_FAULT) { SuspendThrottle(system_tasks.Throttle); + + VCU_FLT_Set(1);//Sets VCU_FLT to 1 + + LogColor(RED, "Setting VCU_FLT signal."); LogColor(RED, "Moving to SevereFault state"); @@ -190,6 +203,11 @@ static State SevereFault(eCarEvents event) if (event == EVENT_RESET_CAR) { LogColor(CYN, "Moving from SevereFault to TractiveOff"); + + VCU_FLT_Set(0); //Clearing VCU FLT --> Assuming the reset car event triggers. + + LogColor(CYN, "Clearing VCU_FLT signal"); + return TRACTIVE_OFF; } diff --git a/VCU/Phantom/Drivers/UART/Phantom_sci.c b/VCU/Phantom/Drivers/UART/Phantom_sci.c index d66cf970..49207e6c 100644 --- a/VCU/Phantom/Drivers/UART/Phantom_sci.c +++ b/VCU/Phantom/Drivers/UART/Phantom_sci.c @@ -31,6 +31,7 @@ enum eCommands{ RESET_CAR='r', START_ENGINE='s', TURN_TRACTIVE_ON='o', + SEVERE_FAULT_TEST='f', }; static volatile uint8_t messageCounter = 0; @@ -228,6 +229,12 @@ void sciReceiveCallback(sciBASE_t *sci, uint32 flags, uint8 data) break; } + case SEVERE_FAULT_TEST: + { + NotifyStateMachineFromISR(EVENT_UNRESPONSIVE_APPS); + + break; + } default: { LogFromISR(UWHT, "Unknown: ");