Skip to content

Commit

Permalink
intergration changes from Jun 6 (#1301)
Browse files Browse the repository at this point in the history
### Changelist 
<!-- Give a list of the changes covered in this PR. This will help both
you and the reviewer keep this PR within scope. -->

Cleaned stuff up + reworked VC fault behavior. Now, if there's a fault,
we just go to inverter on state. We only go back to init state leaves
drive state.

### Testing Done
<!-- Outline the testing that was done to demonstrate the changes are
solid. This could be unit tests, integration tests, testing on the car,
etc. Include relevant code snippets, screenshots, etc as needed. -->

None yet
  • Loading branch information
gtaharaedmonds authored Jun 7, 2024
1 parent 0418f38 commit f1e86fb
Show file tree
Hide file tree
Showing 54 changed files with 279 additions and 346 deletions.
20 changes: 9 additions & 11 deletions can_bus/quadruna/RSM/RSM_alerts.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,24 @@
"CoolantPressureBOCSC": {
"id": 417,
"description": "Coolant pressure B open or short circuit"
}
},
"faults": {
},
"FlowMeterUnderflow": {
"id": 451,
"description": "Coolant flow meter underflow"
},
}
},
"faults": {
"MissingVCHeartbeat": {
"id": 452,
"description": "VC Missing Heart beat"
},
"MissingFSMHeartbeat": {
"id" :453,
"description" : "FSM Missing Heart beat"
"id": 453,
"description": "FSM Missing Heart beat"
},
"MissingBMSHeartbeat": {
"id" :454,
"description" : "BMS Missing Heart beat"


"id": 454,
"description": "BMS Missing Heart beat"
}
}
}
}
12 changes: 0 additions & 12 deletions firmware/cmake/dependencies.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# Host system specific settings
#IF (WIN32)
# set(ARM_COMPILER "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-win32.zip")
#ELSEIF (APPLE)
# set(ARM_COMPILER "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-mac.tar.bz2")
#ELSEIF (UNIX)
# set(ARM_COMPILER "https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2")
#ENDIF ()

# Git Submodules
execute_process(COMMAND "git submodule update --init --recursive" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
message("✅ Git Submodules Updated")
Expand Down Expand Up @@ -45,9 +36,6 @@ ENDIF ()

# arm toolchain
IF ("${TARGET}" STREQUAL "deploy")
# arm binary
# CPMAddPackage(URL ${ARM_COMPILER} NAME gcc-arm-none-eabi-9 DOWNLOAD_ONLY)
# message("🔖 ARM Compiler Installed At ${gcc-arm-none-eabi-9_SOURCE_DIR}")
set(TOOLCHAIN_PREFIX "")
IF (WIN32)
# openocd
Expand Down
2 changes: 1 addition & 1 deletion firmware/quadruna/BMS/src/app/states/app_allStates.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ bool app_allStates_runOnTick100Hz(void)
app_tractiveSystem_broadcast();
app_imd_broadcast();
app_airs_broadcast();
app_shdn_loop_broadcast();
app_shdnLoop_broadcast();

if (io_airs_isNegativeClosed() && io_airs_isPositiveClosed())
{
Expand Down
4 changes: 2 additions & 2 deletions firmware/quadruna/BMS/src/io/io_bmsShdn.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ void io_bmsShdn_init(const BmsShdnConfig *bms_shdn_config)
shdn_config = bms_shdn_config;
}

bool io_get_TS_ILCK_OK(void)
bool io_bmsShdn_TS_ILCK_OK_get(void)
{
return hw_gpio_readPin(&shdn_config->ts_ilck_ok_gpio);
}

bool io_get_HVD_OK(void)
bool io_bmsShdn_HVD_OK_get(void)
{
return hw_gpio_readPin(&shdn_config->hvd_ok_gpio);
}
6 changes: 3 additions & 3 deletions firmware/quadruna/BMS/src/io/io_bmsShdn.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ typedef struct
EMPTY_STRUCT(BmsShdnConfig);
#endif

#define BmsShdnNodeCount 2
#define BMS_SHDN_NODE_COUNT 2

void io_bmsShdn_init(const BmsShdnConfig *bms_shdn_config);

bool io_get_TS_ILCK_OK(void);
bool io_bmsShdn_TS_ILCK_OK_get(void);

bool io_get_HVD_OK(void);
bool io_bmsShdn_HVD_OK_get(void);
10 changes: 5 additions & 5 deletions firmware/quadruna/BMS/src/io/io_tractiveSystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ float io_tractiveSystem_getVoltage()

if (ts_vsense < 0.0f)
{
return NAN;
return 0.0f;
}
else
{
Expand All @@ -79,11 +79,11 @@ float io_tractiveSystem_getVoltage()

float io_tractiveSystem_getCurrentHighResolution()
{
const float adc_voltage = hw_adc_getVoltage(config->ts_isense_high_res_channel);
float adc_voltage = hw_adc_getVoltage(config->ts_isense_high_res_channel);

if (adc_voltage < 0.0f)
{
return NAN;
adc_voltage = 0.0f;
}

// DHAB S/124 Output 1 (+/- 75A):
Expand Down Expand Up @@ -116,11 +116,11 @@ float io_tractiveSystem_getCurrentHighResolution()

float io_tractiveSystem_getCurrentLowResolution()
{
const float adc_voltage = hw_adc_getVoltage(config->ts_isense_low_res_channel);
float adc_voltage = hw_adc_getVoltage(config->ts_isense_low_res_channel);

if (adc_voltage < 0.0f)
{
return NAN;
adc_voltage = 0.0f;
}

// DHAB S/124 Output 2 (+/- 500A):
Expand Down
8 changes: 4 additions & 4 deletions firmware/quadruna/BMS/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ static const BmsShdnConfig bms_shdn_pin_config = {
.hvd_ok_gpio = hvd_ok_shdn_pin,
};

static const BoardShdnNode bms_bshdn_nodes[BmsShdnNodeCount] = {
{ &io_get_TS_ILCK_OK, &app_canTx_BMS_TSIlckOKStatus_set },
{ &io_get_HVD_OK, &app_canTx_BMS_HVDShdnOKStatus_set }
static const BoardShdnNode bms_bshdn_nodes[BMS_SHDN_NODE_COUNT] = {
{ &io_bmsShdn_TS_ILCK_OK_get, &app_canTx_BMS_TSIlckOKStatus_set },
{ &io_bmsShdn_HVD_OK_get, &app_canTx_BMS_HVDShdnOKStatus_set }
};

void tasks_preInit(void)
Expand Down Expand Up @@ -344,7 +344,7 @@ void tasks_init(void)
app_globals_init(&globals_config);
app_stateMachine_init(app_initState_get());

app_shdn_loop_init(bms_bshdn_nodes, BmsShdnNodeCount);
app_shdnLoop_init(bms_bshdn_nodes, BMS_SHDN_NODE_COUNT);

app_heartbeatMonitor_init(
heartbeatMonitorChecklist, heartbeatGetters, heartbeatUpdaters, &app_canTx_BMS_Heartbeat_set,
Expand Down
2 changes: 1 addition & 1 deletion firmware/quadruna/CRIT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ list(APPEND IO_SRCS
"${SHARED_IO_INCLUDE_DIR}/io_jsoncan.c"
"${SHARED_IO_INCLUDE_DIR}/io_time.c"
"${SHARED_IO_INCLUDE_DIR}/io_chimera.c"
"${SHARED_IO_INCLUDE_DIR}/io_rgbLed.c"
)
set(IO_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/io" "${SHARED_IO_INCLUDE_DIR}" "${SHARED_IO_INCLUDE_QUADRUNA_DIR}")

Expand All @@ -30,7 +31,6 @@ file(GLOB_RECURSE HW_SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/src/cubemx/Src/*.c"
)
list(APPEND HW_SRCS
"${SHARED_HW_INCLUDE_DIR}/hw_rgbLed.c"
"${SHARED_HW_INCLUDE_DIR}/hw_hardFaultHandler.c"
"${SHARED_HW_INCLUDE_DIR}/hw_adcConversions.c"
"${SHARED_HW_INCLUDE_DIR}/hw_can.c"
Expand Down
35 changes: 26 additions & 9 deletions firmware/quadruna/CRIT/src/app/app_leds.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,51 @@
#include "app_canAlerts.h"
#include "io_leds.h"

BoardLEDStatus board_worst_status(CanAlertBoard b)
static BoardLEDStatus worstBoardStatus(CanAlertBoard board)
{
bool is_missing_heartbeat;
switch (b)
switch (board)
{
case BMS_ALERT_BOARD:
{
is_missing_heartbeat = app_canAlerts_CRIT_Fault_MissingBMSHeartbeat_get();
break;
}
case CRIT_ALERT_BOARD:
{
is_missing_heartbeat = false; // lmao like
break;
}
case FSM_ALERT_BOARD:
{
is_missing_heartbeat = app_canAlerts_CRIT_Fault_MissingFSMHeartbeat_get();
break;
}
case RSM_ALERT_BOARD:
{
is_missing_heartbeat = app_canAlerts_CRIT_Fault_MissingRSMHeartbeat_get();
break;
}
case VC_ALERT_BOARD:
{
is_missing_heartbeat = app_canAlerts_CRIT_Fault_MissingVCHeartbeat_get();
break;
}
}

if (is_missing_heartbeat)
{
return BOARD_LED_STATUS_MISSING_HEARTBEAT;
if (app_canAlerts_BoardHasFault(b))
}
else if (app_canAlerts_BoardHasFault(board))
{
return BOARD_LED_STATUS_FAULT;
if (app_canAlerts_BoardHasWarning(b))
}
else if (app_canAlerts_BoardHasWarning(board))
{
return BOARD_LED_STATUS_WARNING;
}

return BOARD_LED_STATUS_OK;
}

Expand All @@ -54,19 +71,19 @@ void app_leds_update(void)
app_canRx_VC_FirstFaultNode_get() == SHDN_OK ? BOARD_LED_STATUS_OK : BOARD_LED_STATUS_FAULT;
io_led_shutdown_set(shutdown_sensor_ok);

const BoardLEDStatus bms_status = board_worst_status(BMS_ALERT_BOARD);
const BoardLEDStatus bms_status = worstBoardStatus(BMS_ALERT_BOARD);
io_led_bms_status_set(bms_status);

const BoardLEDStatus fsm_status = board_worst_status(FSM_ALERT_BOARD);
const BoardLEDStatus fsm_status = worstBoardStatus(FSM_ALERT_BOARD);
io_led_fsm_status_set(fsm_status);

const BoardLEDStatus vc_status = board_worst_status(VC_ALERT_BOARD);
const BoardLEDStatus vc_status = worstBoardStatus(VC_ALERT_BOARD);
io_led_vc_status_set(vc_status);

const BoardLEDStatus crit_status = board_worst_status(CRIT_ALERT_BOARD);
const BoardLEDStatus crit_status = worstBoardStatus(CRIT_ALERT_BOARD);
io_led_crit_status_set(crit_status);

const BoardLEDStatus rsm_status = board_worst_status(RSM_ALERT_BOARD);
const BoardLEDStatus rsm_status = worstBoardStatus(RSM_ALERT_BOARD);
io_led_rsm_status_set(rsm_status);

// TODO AUX status
Expand Down
2 changes: 1 addition & 1 deletion firmware/quadruna/CRIT/src/app/app_mainState.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static void mainStateRunOnTick100Hz(void)
app_switches_broadcast();
app_driveMode_broadcast();

app_shdn_loop_broadcast();
app_shdnLoop_broadcast();

app_heartbeatMonitor_checkIn();
app_heartbeatMonitor_broadcastFaults();
Expand Down
4 changes: 2 additions & 2 deletions firmware/quadruna/CRIT/src/io/io_critShdn.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ void io_critShdn_init(const CritShdnConfig *crit_shdn_config)
shdn_config = crit_shdn_config;
}

bool io_get_COCKPIT_ESTOP_OK(void)
bool io_critShdn_COCKPIT_ESTOP_OK_get(void)
{
return hw_gpio_readPin(&shdn_config->cockpit_estop_gpio);
}

bool io_get_INERTIA_SEN_OK(void)
bool io_critShdn_get_INERTIA_SEN_OK_get(void)
{
return hw_gpio_readPin(&shdn_config->inertia_sen_ok_gpio);
}
6 changes: 3 additions & 3 deletions firmware/quadruna/CRIT/src/io/io_critShdn.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ typedef struct
EMPTY_STRUCT(CritShdnConfig);
#endif

#define CritShdnNodeCount 2
#define CRIT_SHDN_NODE_COUNT 2

void io_critShdn_init(const CritShdnConfig *crit_shdn_config);

bool io_get_COCKPIT_ESTOP_OK(void);
bool io_critShdn_COCKPIT_ESTOP_OK_get(void);

bool io_get_INERTIA_SEN_OK(void);
bool io_critShdn_get_INERTIA_SEN_OK_get(void);
10 changes: 5 additions & 5 deletions firmware/quadruna/CRIT/src/io/io_leds.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,19 @@ void set_led_from_board_status(const RgbLed *led, const BoardLEDStatus status)
switch (status)
{
case BOARD_LED_STATUS_FAULT:
hw_rgbLed_enable(led, RGB_RED);
io_rgbLed_enable(led, RGB_RED);
break;
case BOARD_LED_STATUS_OK:
hw_rgbLed_enable(led, RGB_GREEN);
io_rgbLed_enable(led, RGB_GREEN);
break;
case BOARD_LED_STATUS_WARNING:
hw_rgbLed_enable(led, RGB_YELLOW);
io_rgbLed_enable(led, RGB_YELLOW);
break;
case BOARD_LED_STATUS_NOT_IMPLEMENTED:
hw_rgbLed_enable(led, RGB_WHITE);
io_rgbLed_enable(led, RGB_WHITE);
break;
case BOARD_LED_STATUS_MISSING_HEARTBEAT:
hw_rgbLed_enable(led, RGB_OFF);
io_rgbLed_enable(led, RGB_OFF);
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion firmware/quadruna/CRIT/src/io/io_leds.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#ifdef TARGET_EMBEDDED
#include "hw_rgbLed.h"
#include "io_rgbLed.h"
#include "io_led.h"

typedef struct
Expand Down
10 changes: 5 additions & 5 deletions firmware/quadruna/CRIT/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "io_chimera.h"
#include "io_led.h"
#include "io_switch.h"
#include "hw_rgbLed.h"
#include "io_rgbLed.h"
#include "io_critShdn.h"
#include "io_leds.h"
#include "io_switches.h"
Expand Down Expand Up @@ -406,9 +406,9 @@ static bool (*const heartbeatFaultGetters[HEARTBEAT_BOARD_COUNT])(void) = {
static const CritShdnConfig crit_shdn_pin_config = { .cockpit_estop_gpio = shdn_sen_pin,
.inertia_sen_ok_gpio = inertia_sen_pin };

static const BoardShdnNode crit_bshdn_nodes[CritShdnNodeCount] = {
{ &io_get_INERTIA_SEN_OK, &app_canTx_CRIT_InertiaSenOKStatus_set },
{ &io_get_COCKPIT_ESTOP_OK, &app_canTx_CRIT_CockpitEStopOKStatus_set }
static const BoardShdnNode crit_bshdn_nodes[CRIT_SHDN_NODE_COUNT] = {
{ &io_critShdn_get_INERTIA_SEN_OK_get, &app_canTx_CRIT_InertiaSenOKStatus_set },
{ &io_critShdn_COCKPIT_ESTOP_OK_get, &app_canTx_CRIT_CockpitEStopOKStatus_set }
};

void tasks_preInit(void)
Expand Down Expand Up @@ -448,7 +448,7 @@ void tasks_init(void)
app_canTx_init();
app_canRx_init();

app_shdn_loop_init(crit_bshdn_nodes, CritShdnNodeCount);
app_shdnLoop_init(crit_bshdn_nodes, CRIT_SHDN_NODE_COUNT);

app_heartbeatMonitor_init(
heartbeatMonitorChecklist, heartbeatGetters, heartbeatUpdaters, &app_canTx_CRIT_Heartbeat_set,
Expand Down
Loading

0 comments on commit f1e86fb

Please sign in to comment.