From 997f10707cc14275095f4fc11d4aa8f51b07dd1f Mon Sep 17 00:00:00 2001 From: Julianne Date: Wed, 10 Jul 2024 01:09:45 -0700 Subject: [PATCH 1/2] Added VCU_FLT signal upon severe fault. --- VCU/Phantom/Drivers/STATE_MACHINE/state_machine.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/VCU/Phantom/Drivers/STATE_MACHINE/state_machine.c b/VCU/Phantom/Drivers/STATE_MACHINE/state_machine.c index d570658c..9b49e85e 100644 --- a/VCU/Phantom/Drivers/STATE_MACHINE/state_machine.c +++ b/VCU/Phantom/Drivers/STATE_MACHINE/state_machine.c @@ -25,6 +25,16 @@ static State SevereFault(eCarEvents event); static SystemTasks_t system_tasks; +void VCU_FLT_Set() +{ + //Toggles VCU_FLT pin defined in hardware file. + + gioSetBit(SHUTDOWN_CIRCUIT_PORT,BSPD_FAULT_PIN,1);//Check pin since no VCU_FLT pin is defined. + + LogColor(RED, "Setting VCU_FLT signal."); + + return; +} /* Public API */ @@ -138,6 +148,8 @@ static State VariousStates(State state, eCarEvents event) if (faults && state != SEVERE_FAULT) { SuspendThrottle(system_tasks.Throttle); + + VCU_FLT_Set(); LogColor(RED, "Moving to SevereFault state"); From 823bbaa0f9c46f83a8034e6bd25a5f9246fffa9e Mon Sep 17 00:00:00 2001 From: Julainne Date: Sat, 13 Jul 2024 02:52:58 -0700 Subject: [PATCH 2/2] Added test case to generate a severe fault. Added the turn off for VCU_FLT once car is reset. Tested in console and output is correct. --- .../Drivers/STATE_MACHINE/state_machine.c | 16 +++++++++++----- VCU/Phantom/Drivers/UART/Phantom_sci.c | 7 +++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/VCU/Phantom/Drivers/STATE_MACHINE/state_machine.c b/VCU/Phantom/Drivers/STATE_MACHINE/state_machine.c index 9b49e85e..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,13 +26,11 @@ static State SevereFault(eCarEvents event); static SystemTasks_t system_tasks; -void VCU_FLT_Set() +void VCU_FLT_Set(int value) { //Toggles VCU_FLT pin defined in hardware file. - gioSetBit(SHUTDOWN_CIRCUIT_PORT,BSPD_FAULT_PIN,1);//Check pin since no VCU_FLT pin is defined. - - LogColor(RED, "Setting VCU_FLT signal."); + 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; } @@ -149,7 +148,9 @@ static State VariousStates(State state, eCarEvents event) { SuspendThrottle(system_tasks.Throttle); - VCU_FLT_Set(); + VCU_FLT_Set(1);//Sets VCU_FLT to 1 + + LogColor(RED, "Setting VCU_FLT signal."); LogColor(RED, "Moving to SevereFault state"); @@ -202,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: ");