Skip to content

Commit

Permalink
Merge branch 'master' into cmake-cleanup-2024
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucien950 authored Aug 30, 2024
2 parents cb6f813 + 8044bdd commit ad254b3
Show file tree
Hide file tree
Showing 83 changed files with 11,012 additions and 1,461 deletions.
3 changes: 2 additions & 1 deletion firmware/quadruna/BMS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ list(APPEND APP_SRCS
"${SHARED_APP_INCLUDE_DIR}/app_timer.c"
"${SHARED_APP_INCLUDE_DIR}/app_math.c"
"${SHARED_APP_INCLUDE_DIR}/app_heartbeatMonitor.c"
"${SHARED_APP_INCLUDE_DIR}/app_shdnLoop.c"
"${SHARED_APP_INCLUDE_DIR}/app_shdnLoopNode.c"
)
set(APP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/app" "${SHARED_APP_INCLUDE_DIR}" "${SHARED_APP_INCLUDE_QUADRUNA_DIR}")

Expand Down Expand Up @@ -166,6 +166,7 @@ elseif ("${TARGET}" STREQUAL "test")
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/io_tractiveSystem.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/io_sd.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/io_bspdTest.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/io_bmsShdn.h"
)
create_fake_library(
"quadruna_BMS_fakes"
Expand Down
13 changes: 13 additions & 0 deletions firmware/quadruna/BMS/src/app/app_shdnNode.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "app_shdnLoop.h"
#include "app_shdnLoopNode.h"
#include "io_bmsShdn.h"
#include "app_canTx.h"

static const BoardShdnNode ts_ilck_ok_node = { &io_bmsShdn_TS_ILCK_OK_get, &app_canTx_BMS_TSIlckOKStatus_set };
static const BoardShdnNode hvd_ok_node = { &io_bmsShdn_HVD_OK_get, &app_canTx_BMS_HVDShdnOKStatus_set };

void app_shdnLoop_broadcast(void)
{
app_shdnLoopNode_broadcast(&ts_ilck_ok_node);
app_shdnLoopNode_broadcast(&hvd_ok_node);
}
10 changes: 0 additions & 10 deletions firmware/quadruna/BMS/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@
#include "app_canRx.h"
#include "app_canAlerts.h"
#include "app_commitInfo.h"
#include "app_thermistors.h"
#include "app_accumulator.h"
#include "app_soc.h"
#include "app_globals.h"
#include "states/app_initState.h"
#include "states/app_inverterOnState.h"
#include "app_stateMachine.h"
#include "app_shdnLoop.h"

#include "shared.pb.h"
#include "BMS.pb.h"
Expand Down Expand Up @@ -286,11 +283,6 @@ static const BmsShdnConfig bms_shdn_pin_config = {
.hvd_ok_gpio = hvd_ok_shdn_pin,
};

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)
{
// After booting, re-enable interrupts and ensure the core is using the application's vector table.
Expand Down Expand Up @@ -343,8 +335,6 @@ void tasks_init(void)
app_globals_init(&globals_config);
app_stateMachine_init(app_initState_get());

app_shdnLoop_init(bms_bshdn_nodes, BMS_SHDN_NODE_COUNT);

app_heartbeatMonitor_init(
heartbeatMonitorChecklist, heartbeatGetters, heartbeatUpdaters, &app_canTx_BMS_Heartbeat_set,
heartbeatFaultSetters, heartbeatFaultGetters);
Expand Down
3 changes: 2 additions & 1 deletion firmware/quadruna/CRIT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ list(APPEND APP_SRCS
"${SHARED_APP_INCLUDE_DIR}/app_rangeCheck.c"
"${SHARED_APP_INCLUDE_DIR}/app_signal.c"
"${SHARED_APP_INCLUDE_DIR}/app_timer.c"
"${SHARED_APP_INCLUDE_DIR}/app_shdnLoop.c"
"${SHARED_APP_INCLUDE_DIR}/app_shdnLoopNode.c"
)
set(APP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/app" "${SHARED_APP_INCLUDE_DIR}" "${SHARED_APP_INCLUDE_QUADRUNA_DIR}")

Expand Down Expand Up @@ -149,6 +149,7 @@ elseif ("${TARGET}" STREQUAL "test")
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/io_driveMode.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/io_leds.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/io_switches.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/io_critShdn.h"
)
create_fake_library(
"quadruna_CRIT_fakes"
Expand Down
6 changes: 1 addition & 5 deletions firmware/quadruna/CRIT/src/app/app_driveMode.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
#include "app_driveMode.h"
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#include "app_canTx.h"
#include "app_canAlerts.h"
#include "io_driveMode.h"
#include "app_canTx.h"

void app_driveMode_broadcast(void)
{
Expand Down
9 changes: 0 additions & 9 deletions firmware/quadruna/CRIT/src/app/app_globals.c

This file was deleted.

23 changes: 0 additions & 23 deletions firmware/quadruna/CRIT/src/app/app_globals.h

This file was deleted.

15 changes: 15 additions & 0 deletions firmware/quadruna/CRIT/src/app/app_shdnLoop.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "app_shdnLoop.h"
#include "app_shdnLoopNode.h"
#include "io_critShdn.h"
#include "app_canTx.h"

static const BoardShdnNode inertia_sen_node = { &io_critShdn_get_INERTIA_SEN_OK_get,
&app_canTx_CRIT_InertiaSenOKStatus_set };
static const BoardShdnNode cockpit_estop_node = { &io_critShdn_COCKPIT_ESTOP_OK_get,
&app_canTx_CRIT_CockpitEStopOKStatus_set };

void app_shdnLoop_broadcast(void)
{
app_shdnLoopNode_broadcast(&inertia_sen_node);
app_shdnLoopNode_broadcast(&cockpit_estop_node);
}
12 changes: 0 additions & 12 deletions firmware/quadruna/CRIT/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include "app_heartbeatMonitor.h"
#include "app_stateMachine.h"
#include "app_mainState.h"
#include "app_globals.h"
#include "app_shdnLoop.h"
// io
#include "io_log.h"
#include "io_chimera.h"
Expand Down Expand Up @@ -332,8 +330,6 @@ const AdcChannel id_to_adc[] = {

static const UART debug_uart = { .handle = &huart2 };

static const GlobalsConfig globals_config = { .drive_mode = &drive_mode };

static const Leds led_config = {
.imd_led = &imd_led,
.bspd_led = &bspd_led,
Expand Down Expand Up @@ -405,11 +401,6 @@ 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[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)
{
hw_bootup_enableInterruptsForApp();
Expand Down Expand Up @@ -447,14 +438,11 @@ void tasks_init(void)
app_canTx_init();
app_canRx_init();

app_shdnLoop_init(crit_bshdn_nodes, CRIT_SHDN_NODE_COUNT);

app_heartbeatMonitor_init(
heartbeatMonitorChecklist, heartbeatGetters, heartbeatUpdaters, &app_canTx_CRIT_Heartbeat_set,
heartbeatFaultSetters, heartbeatFaultGetters);

app_stateMachine_init(app_mainState_get());
app_globals_init(&globals_config);

// broadcast commit info
app_canTx_CRIT_Hash_set(GIT_COMMIT_HASH);
Expand Down
9 changes: 0 additions & 9 deletions firmware/quadruna/CRIT/test/test_critBaseStateMachineTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ extern "C"
#include "app_canUtils.h"
#include "app_utils.h"
#include "app_mainState.h"
#include "app_globals.h"
}

// Test fixture definition for any test requiring the state machine. Can also be used for non-state machine related
Expand All @@ -33,7 +32,6 @@ class CritBaseStateMachineTest : public BaseStateMachineTest
app_heartbeatMonitor_init(
heartbeatMonitorChecklist, heartbeatGetters, heartbeatUpdaters, &app_canTx_CRIT_Heartbeat_set,
heartbeatFaultSetters, heartbeatFaultGetters);
app_globals_init(&globals_config);
app_stateMachine_init(app_mainState_get());

// Disable heartbeat monitor in the nominal case. To use representative heartbeat behavior,
Expand Down Expand Up @@ -64,9 +62,6 @@ class CritBaseStateMachineTest : public BaseStateMachineTest
fake_io_switches_regen_get_reset();
fake_io_switches_torquevec_get_reset();
}
// dummy used to initialize shdn_sen_pin
const DriveMode drive_mode = {};

// config to forward can functions to shared heartbeat
// DIM rellies on all boards but itself
const bool heartbeatMonitorChecklist[HEARTBEAT_BOARD_COUNT] = {
Expand Down Expand Up @@ -111,8 +106,4 @@ class CritBaseStateMachineTest : public BaseStateMachineTest
[DIM_HEARTBEAT_BOARD] = NULL,
[CRIT_HEARTBEAT_BOARD] = NULL
};

const GlobalsConfig globals_config = {
.drive_mode = &drive_mode,
};
};
3 changes: 2 additions & 1 deletion firmware/quadruna/FSM/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ list(APPEND APP_SRCS
"${SHARED_APP_INCLUDE_DIR}/app_rangeCheck.c"
"${SHARED_APP_INCLUDE_DIR}/app_signal.c"
"${SHARED_APP_INCLUDE_DIR}/app_timer.c"
"${SHARED_APP_INCLUDE_DIR}/app_shdnLoop.c"
"${SHARED_APP_INCLUDE_DIR}/app_shdnLoopNode.c"
)
set(APP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/app" "${SHARED_APP_INCLUDE_DIR}" "${SHARED_APP_INCLUDE_QUADRUNA_DIR}")

Expand Down Expand Up @@ -154,6 +154,7 @@ elseif ("${TARGET}" STREQUAL "test")
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/io_brake.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/io_suspension.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/io_loadCell.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/io_fsmShdn.h"
)
create_fake_library(
"quadruna_FSM_fakes"
Expand Down
11 changes: 4 additions & 7 deletions firmware/quadruna/FSM/src/app/app_apps.c
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#include "app_apps.h"
#include <assert.h>
#include <stdlib.h>
#include <math.h>
#include "app_signal.h"
#include "app_canTx.h"
#include "app_canAlerts.h"
#include "io_apps.h"
#include "io_brake.h"

Signal papps_ocsc_signal;
Signal sapps_ocsc_signal;
Signal papps_sapps_disagreement_signal;
static Signal papps_ocsc_signal;
static Signal sapps_ocsc_signal;
static Signal papps_sapps_disagreement_signal;

void app_apps_init(void)
{
Expand All @@ -21,7 +18,7 @@ void app_apps_init(void)
PAPPS_SAPPS_DISAGREEMENT_TIME_TO_CLEAR);
}

void app_apps_broadcast()
void app_apps_broadcast(void)
{
float papps_pedal_percentage = io_apps_getPrimary();
float sapps_pedal_percentage = io_apps_getSecondary();
Expand Down
3 changes: 0 additions & 3 deletions firmware/quadruna/FSM/src/app/app_mainState.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#include "app_mainState.h"
#include <stddef.h>
#include "app_utils.h"
#include "app_canTx.h"
#include "app_canRx.h"
#include "app_canAlerts.h"
#include "app_steering.h"
#include "app_wheels.h"
#include "app_apps.h"
Expand Down
11 changes: 11 additions & 0 deletions firmware/quadruna/FSM/src/app/app_shdnLoop.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "app_shdnLoop.h"
#include "app_shdnLoopNode.h"
#include "io_fsmShdn.h"
#include "app_canTx.h"

static const BoardShdnNode bots_node = { &io_fsmShdn_FSM_SHDN_OK_get, &app_canTx_FSM_BOTSOKStatus_set };

void app_shdnLoop_broadcast(void)
{
app_shdnLoopNode_broadcast(&bots_node);
}
2 changes: 0 additions & 2 deletions firmware/quadruna/FSM/src/app/app_steering.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#include "app_steering.h"
#include <stdlib.h>
#include <assert.h>
#include "app_canTx.h"
#include "app_rangeCheck.h"
#include "app_canAlerts.h"
Expand Down
2 changes: 1 addition & 1 deletion firmware/quadruna/FSM/src/app/app_suspension.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ void app_suspension_broadcast(void)

// app_canAlerts_FSM_Warning_LeftSuspensionOCSC_set(io_suspension_leftSensorOCSC());
// app_canAlerts_FSM_Warning_RightSuspensionOCSC_set(io_suspension_rightSensorOCSC());
}
}
8 changes: 1 addition & 7 deletions firmware/quadruna/FSM/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include "app_canRx.h"
#include "app_canAlerts.h"
#include "app_commitInfo.h"
#include "app_shdnLoop.h"
#include "app_apps.h"

#include "io_jsoncan.h"
Expand All @@ -30,7 +29,7 @@
#include "hw_hardFaultHandler.h"
#include "hw_watchdog.h"
#include "hw_watchdogConfig.h"
#include "hw_stackWaterMark.h"
#include "hw_stackWaterMark.h" // TODO enable stackwatermark on the FSM
#include "hw_stackWaterMarkConfig.h"
#include "hw_adc.h"
#include "hw_gpio.h"
Expand Down Expand Up @@ -135,9 +134,6 @@ void tasks_preInit(void)

static const FsmShdnConfig fsm_shdn_pin_config = { .fsm_shdn_ok_gpio = fsm_shdn };

static const BoardShdnNode fsm_bshdn_nodes[FSM_SHDN_NODE_COUNT] = { { &io_fsmShdn_FSM_SHDN_OK_get,
&app_canTx_FSM_BOTSOKStatus_set } };

void tasks_init(void)
{
// Configure and initialize SEGGER SystemView.
Expand All @@ -162,8 +158,6 @@ void tasks_init(void)
app_canTx_init();
app_canRx_init();

app_shdnLoop_init(fsm_bshdn_nodes, FSM_SHDN_NODE_COUNT);

io_apps_init(&apps_config);
io_brake_init(&brake_config);
io_loadCell_init(&load_cell_config);
Expand Down
2 changes: 1 addition & 1 deletion firmware/quadruna/VC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ list(APPEND APP_SRCS
"${SHARED_APP_INCLUDE_DIR}/app_heartbeatMonitor.c"
"${SHARED_APP_INCLUDE_DIR}/app_stateMachine.c"
"${SHARED_APP_INCLUDE_DIR}/app_timer.c"
"${SHARED_APP_INCLUDE_DIR}/app_shdnLoop.c"
"${SHARED_APP_INCLUDE_DIR}/app_shdnLoopNode.c"
"${SHARED_APP_INCLUDE_DIR}/app_signal.c"
)
set(APP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/app" "${CMAKE_CURRENT_SOURCE_DIR}/src/app/vehicle_dynamics" "${SHARED_APP_INCLUDE_DIR}" "${SHARED_APP_INCLUDE_QUADRUNA_DIR}")
Expand Down
34 changes: 24 additions & 10 deletions firmware/quadruna/VC/src/app/app_efuse.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
#include "app_efuse.h"

#include <stdbool.h>
#include <stddef.h>

#include "io_efuse.h"
#include "io_log.h"
#include "app_canTx.h"

static void (*const *efuse_enabled_can_setters)(bool);
static void (*const *efuse_current_can_setters)(float);
static void (*const efuse_enabled_can_setters[NUM_EFUSE_CHANNELS])(bool) = {
[EFUSE_CHANNEL_SHDN] = app_canTx_VC_ShdnStatus_set,
[EFUSE_CHANNEL_LV] = app_canTx_VC_LvStatus_set,
[EFUSE_CHANNEL_PUMP] = app_canTx_VC_PumpStatus_set,
[EFUSE_CHANNEL_AUX] = app_canTx_VC_AuxStatus_set,
[EFUSE_CHANNEL_INV_R] = app_canTx_VC_InvRStatus_set,
[EFUSE_CHANNEL_INV_L] = app_canTx_VC_InvLStatus_set,
[EFUSE_CHANNEL_TELEM] = NULL,
[EFUSE_CHANNEL_BUZZER] = NULL,
};

void app_efuse_init(
void (*const enabled_setters[NUM_EFUSE_CHANNELS])(bool),
void (*const current_setters[NUM_EFUSE_CHANNELS])(float))
{
efuse_enabled_can_setters = enabled_setters;
efuse_current_can_setters = current_setters;
}
static void (*const efuse_current_can_setters[NUM_EFUSE_CHANNELS])(float) = {
[EFUSE_CHANNEL_SHDN] = app_canTx_VC_ShdnCurrent_set,
[EFUSE_CHANNEL_LV] = app_canTx_VC_LvCurrent_set,
[EFUSE_CHANNEL_PUMP] = app_canTx_VC_PumpCurrent_set,
[EFUSE_CHANNEL_AUX] = app_canTx_VC_AuxCurrent_set,
[EFUSE_CHANNEL_INV_R] = app_canTx_VC_InvRCurrent_set,
[EFUSE_CHANNEL_INV_L] = app_canTx_VC_InvLCurrent_set,
[EFUSE_CHANNEL_TELEM] = NULL,
[EFUSE_CHANNEL_BUZZER] = NULL,
};

void app_efuse_broadcast(void)
{
Expand Down
Loading

0 comments on commit ad254b3

Please sign in to comment.