Skip to content

Commit

Permalink
Merge branch 'master' into 2025_ioc_approvals
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucien950 authored Feb 1, 2025
2 parents f163daf + 77a1b3a commit 21ac4a5
Show file tree
Hide file tree
Showing 60 changed files with 377 additions and 665 deletions.
3 changes: 2 additions & 1 deletion firmware/quadruna/BMS/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,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_taskMonitor.c"
)
set(IO_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/io" "${SHARED_IO_INCLUDE_DIR}" "${SHARED_IO_INCLUDE_QUADRUNA_DIR}")

Expand All @@ -43,7 +44,6 @@ list(APPEND HW_SRCS
"${SHARED_HW_INCLUDE_DIR}/hw_spi.c"
"${SHARED_HW_INCLUDE_DIR}/hw_pwmInput.c"
"${SHARED_HW_INCLUDE_DIR}/hw_watchdog.c"
"${SHARED_HW_INCLUDE_DIR}/hw_stackWaterMark.c"
"${SHARED_HW_INCLUDE_DIR}/hw_assert.c"
"${SHARED_HW_INCLUDE_DIR}/hw_uart.c"
"${SHARED_HW_INCLUDE_DIR}/hw_error.c"
Expand Down Expand Up @@ -156,6 +156,7 @@ elseif ("${TARGET}" STREQUAL "test")

# FAKE IO
set(HEADERS_TO_FAKE
"${SHARED_IO_INCLUDE_DIR}/io_taskMonitor.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/ltc6813/io_ltc6813CellTemps.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/ltc6813/io_ltc6813CellVoltages.h"
"${CMAKE_CURRENT_SOURCE_DIR}/src/io/ltc6813/io_ltc6813Shared.h"
Expand Down
5 changes: 1 addition & 4 deletions firmware/quadruna/BMS/src/app/app_heartbeatMonitors.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ static HeartbeatBoard heartbeat_boards[1] = {
}
};

HeartbeatMonitor hb_monitor = { .boards = heartbeat_boards,
.board_count = 1,
.block_faults = false,
.own_heartbeat = app_canTx_BMS_Heartbeat_set };
HeartbeatMonitor hb_monitor = { .boards = heartbeat_boards, .board_count = 1, .block_faults = false };
20 changes: 20 additions & 0 deletions firmware/quadruna/BMS/src/app/app_stackWaterMarks.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "app_stackWaterMarks.h"
#include "io_taskMonitors.h"
#include "app_canAlerts.h"

/** @brief The stack watermark threshold as a percentage of the stack size */
#define STACK_HIGH_WATERMARK_THRESHOLD 0.7f

void app_stackWaterMarkConfig_check(void)
{
app_canAlerts_BMS_Warning_StackWaterMarkHighTask1Hz_set(
io_taskMonitor_getStackUsage(&task_1_hz_monitor) > STACK_HIGH_WATERMARK_THRESHOLD);
app_canAlerts_BMS_Warning_StackWaterMarkHighTask100Hz_set(
io_taskMonitor_getStackUsage(&task_100_hz_monitor) > STACK_HIGH_WATERMARK_THRESHOLD);
app_canAlerts_BMS_Warning_StackWaterMarkHighTask1kHz_set(
io_taskMonitor_getStackUsage(&task_1_khz_monitor) > STACK_HIGH_WATERMARK_THRESHOLD);
app_canAlerts_BMS_Warning_StackWaterMarkHighTaskCanRx_set(
io_taskMonitor_getStackUsage(&task_can_rx_monitor) > STACK_HIGH_WATERMARK_THRESHOLD);
app_canAlerts_BMS_Warning_StackWaterMarkHighTaskCanTx_set(
io_taskMonitor_getStackUsage(&task_can_tx_monitor) > STACK_HIGH_WATERMARK_THRESHOLD);
}
14 changes: 13 additions & 1 deletion firmware/quadruna/BMS/src/cubemx/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern "C"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

#include "cmsis_os.h"
/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
Expand All @@ -53,6 +53,18 @@ extern "C"
extern TIM_HandleTypeDef htim3;
extern TIM_HandleTypeDef htim15;
extern UART_HandleTypeDef huart1;

extern osThreadId_t Task1HzHandle;
extern osThreadId_t Task100HzHandle;
extern osThreadId_t Task1kHzHandle;
extern osThreadId_t TaskCanRxHandle;
extern osThreadId_t TaskCanTxHandle;

extern const osThreadAttr_t Task100Hz_attributes;
extern const osThreadAttr_t TaskCanRx_attributes;
extern const osThreadAttr_t TaskCanTx_attributes;
extern const osThreadAttr_t Task1kHz_attributes;
extern const osThreadAttr_t Task1Hz_attributes;
/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
Expand Down
82 changes: 0 additions & 82 deletions firmware/quadruna/BMS/src/hw/hw_stackWaterMarkConfig.c

This file was deleted.

8 changes: 0 additions & 8 deletions firmware/quadruna/BMS/src/hw/hw_stackWaterMarkConfig.h

This file was deleted.

8 changes: 8 additions & 0 deletions firmware/quadruna/BMS/src/io/io_taskMonitors.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "io_taskMonitors.h"
#include "main.h"

const TaskMonitor task_1_hz_monitor = { .handle = &Task1HzHandle, .attributes = &Task1Hz_attributes },
task_100_hz_monitor = { .handle = &Task100HzHandle, .attributes = &Task100Hz_attributes },
task_1_khz_monitor = { .handle = &Task1kHzHandle, .attributes = &Task1kHz_attributes },
task_can_rx_monitor = { .handle = &TaskCanRxHandle, .attributes = &TaskCanRx_attributes },
task_can_tx_monitor = { .handle = &TaskCanTxHandle, .attributes = &TaskCanTx_attributes };
5 changes: 5 additions & 0 deletions firmware/quadruna/BMS/src/io/io_taskMonitors.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once
#include "io_taskMonitor.h"

extern const TaskMonitor task_1_hz_monitor, task_100_hz_monitor, task_1_khz_monitor, task_can_rx_monitor,
task_can_tx_monitor;
7 changes: 6 additions & 1 deletion firmware/quadruna/BMS/src/jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "states/app_initState.h"
#include "app_commitInfo.h"
#include "app_heartbeatMonitors.h"
#include "app_stackWaterMarks.h"

#include "io_canMsg.h"
#include "io_canQueue.h"
Expand Down Expand Up @@ -41,8 +42,12 @@ void jobs_init(void)
// broadcast commit info
app_canTx_BMS_Hash_set(GIT_COMMIT_HASH);
app_canTx_BMS_Clean_set(GIT_COMMIT_CLEAN);
app_canTx_BMS_Heartbeat_set(true);
}
void jobs_run1Hz_tick(void)
{
app_stackWaterMark_check();
}
void jobs_run1Hz_tick(void) {}
void jobs_run100Hz_tick(void) {}
void jobs_run1kHz_tick(void) {}

Expand Down
7 changes: 0 additions & 7 deletions firmware/quadruna/BMS/src/tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,28 @@
#include "cmsis_os.h"

#include "hw_adcs.h"
#include "hw_gpios.h"
#include "hw_hardFaultHandler.h"
#include "hw_bootup.h"
#include "hw_utils.h"
#include "hw_spi.h"
#include "hw_pwmInput.h"
#include "hw_stackWaterMarkConfig.h"
#include "hw_watchdogConfig.h"
#include "hw_watchdog.h"
#include "hw_uarts.h"
#include "hw_sd.h"
#include "hw_crc.h"

#include "io_canTx.h"
#include "io_sd.h"
#include "io_faultLatch.h"
#include "io_imd.h"
#include "ltc6813/io_ltc6813Shared.h"
#include "io_tractiveSystem.h"
#include "io_log.h"
#include "io_chimera.h"
#include "io_bmsShdn.h"

#include "app_canRx.h"
#include "app_accumulator.h"
#include "app_globals.h"
#include "app_stateMachine.h"
#include "app_heartbeatMonitors.h"

#include "shared.pb.h"

Expand Down Expand Up @@ -130,7 +124,6 @@ _Noreturn void tasks_run1Hz(void)

for (;;)
{
hw_stackWaterMarkConfig_check();
app_stateMachine_tick1Hz();

const bool debug_mode_enabled = app_canRx_Debug_EnableDebugMode_get();
Expand Down
7 changes: 7 additions & 0 deletions firmware/quadruna/BMS/test/test_iovars.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extern "C"
{
#include "io_taskMonitors.h"
}

const TaskMonitor task_1_hz_monitor{}, task_100_hz_monitor{}, task_1_khz_monitor{}, task_can_rx_monitor{},
task_can_tx_monitor{};
3 changes: 2 additions & 1 deletion firmware/quadruna/CRIT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ list(APPEND IO_SRCS
"${SHARED_IO_INCLUDE_DIR}/io_time.c"
"${SHARED_IO_INCLUDE_DIR}/io_chimera.c"
"${SHARED_IO_INCLUDE_DIR}/io_rgbLed.c"
"${SHARED_IO_INCLUDE_DIR}/io_taskMonitor.c"
)
set(IO_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/io" "${SHARED_IO_INCLUDE_DIR}" "${SHARED_IO_INCLUDE_QUADRUNA_DIR}")

Expand All @@ -40,7 +41,6 @@ list(APPEND HW_SRCS
"${SHARED_HW_INCLUDE_DIR}/hw_bootup.c"
"${SHARED_HW_INCLUDE_DIR}/hw_pwmInputFreqOnly.c"
"${SHARED_HW_INCLUDE_DIR}/hw_watchdog.c"
"${SHARED_HW_INCLUDE_DIR}/hw_stackWaterMark.c"
"${SHARED_HW_INCLUDE_DIR}/hw_assert.c"
"${SHARED_HW_INCLUDE_DIR}/hw_uart.c"
"${SHARED_HW_INCLUDE_DIR}/hw_gpio.c"
Expand Down Expand Up @@ -148,6 +148,7 @@ elseif ("${TARGET}" STREQUAL "test")

# FakeIO
set(HEADERS_TO_FAKE
"${SHARED_IO_INCLUDE_DIR}/io_taskMonitor.h"
"${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"
Expand Down
5 changes: 1 addition & 4 deletions firmware/quadruna/CRIT/src/app/app_heartbeatMonitors.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,4 @@ static HeartbeatBoard heartbeat_boards[4] = {
.timeout_ms = 200 }
};

HeartbeatMonitor hb_monitor = { .boards = heartbeat_boards,
.board_count = 4,
.block_faults = false,
.own_heartbeat = app_canTx_CRIT_Heartbeat_set };
HeartbeatMonitor hb_monitor = { .boards = heartbeat_boards, .board_count = 4, .block_faults = false };
21 changes: 21 additions & 0 deletions firmware/quadruna/CRIT/src/app/app_stackWaterMarks.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "app_stackWaterMarks.h"
#include "io_taskMonitors.h"
#include "app_canAlerts.h"

/** @brief The stack watermark threshold as a percentage of the stack size */
#define STACK_HIGH_WATERMARK_THRESHOLD 0.7f

void app_stackWaterMark_check(void)
{
// io_stackWaterMark_check(stack_watermarks, NUM_ELEMENTS_IN_ARRAY(stack_watermarks));
app_canAlerts_CRIT_Warning_StackWaterMarkHighTask1Hz_set(
io_taskMonitor_getStackUsage(&task_1hz_monitor) > STACK_HIGH_WATERMARK_THRESHOLD);
app_canAlerts_CRIT_Warning_StackWaterMarkHighTask100Hz_set(
io_taskMonitor_getStackUsage(&task_100hz_monitor) > STACK_HIGH_WATERMARK_THRESHOLD);
app_canAlerts_CRIT_Warning_StackWaterMarkHighTask1kHz_set(
io_taskMonitor_getStackUsage(&task_1khz_monitor) > STACK_HIGH_WATERMARK_THRESHOLD);
app_canAlerts_CRIT_Warning_StackWaterMarkHighTaskCanRx_set(
io_taskMonitor_getStackUsage(&task_can_rx_monitor) > STACK_HIGH_WATERMARK_THRESHOLD);
app_canAlerts_CRIT_Warning_StackWaterMarkHighTaskCanTx_set(
io_taskMonitor_getStackUsage(&task_can_tx_monitor) > STACK_HIGH_WATERMARK_THRESHOLD);
}
14 changes: 13 additions & 1 deletion firmware/quadruna/CRIT/src/cubemx/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern "C"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

#include "cmsis_os.h"
/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
Expand All @@ -48,6 +48,18 @@ extern "C"
extern IWDG_HandleTypeDef hiwdg;
extern TIM_HandleTypeDef htim3;
extern UART_HandleTypeDef huart2;

extern osThreadId_t Task1HzHandle;
extern osThreadId_t Task100HzHandle;
extern osThreadId_t Task1kHzHandle;
extern osThreadId_t TaskCanRxHandle;
extern osThreadId_t TaskCanTxHandle;

extern const osThreadAttr_t Task1kHz_attributes;
extern const osThreadAttr_t Task100Hz_attributes;
extern const osThreadAttr_t TaskCanRx_attributes;
extern const osThreadAttr_t TaskCanTx_attributes;
extern const osThreadAttr_t Task1Hz_attributes;
/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
Expand Down
Loading

0 comments on commit 21ac4a5

Please sign in to comment.