Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions projects/front_controller/src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ using State = TxFcStatus::State_t;
static State state = State::START_DASHBOARD;
static uint32_t elapsed = 0;

static UBaseType_t UpdateMinHighWaterMark(UBaseType_t* min_hwm) {
UBaseType_t current = uxTaskGetStackHighWaterMark(NULL);
if (current < *min_hwm) {
*min_hwm = current;
}
return *min_hwm;
}

static void Update_100Hz(void) {
using enum State;
using DashState = RxDashStatus::State_t;
Expand Down Expand Up @@ -271,7 +279,10 @@ void task_1hz(void* argument) {

TickType_t wake_time = xTaskGetTickCount();

static UBaseType_t min_hwm = STACK_SIZE_WORDS;

while (true) {
fsm::UpdateMinHighWaterMark(&min_hwm);
veh_can_bus.Send(TxFcGitHash{
.commit = macfe::generated::GIT_HASH,
.dirty = macfe::generated::GIT_DIRTY,
Expand All @@ -287,7 +298,10 @@ void task_10hz(void* argument) {

TickType_t wake_time = xTaskGetTickCount();

static UBaseType_t min_hwm = STACK_SIZE_WORDS;

while (true) {
fsm::UpdateMinHighWaterMark(&min_hwm);
ToggleDebugLed();
UpdateErrorLeds();
dbc_hash::Update_10Hz(veh_can_bus);
Expand Down Expand Up @@ -340,7 +354,10 @@ void task_100hz(void* argument) {

TickType_t wake_time = xTaskGetTickCount();

static UBaseType_t min_hwm = STACK_SIZE_WORDS;

while (true) {
fsm::UpdateMinHighWaterMark(&min_hwm);
sensors::driver::Update_100Hz();
sensors::dynamics::Update_100Hz();
driver_interface::Update_100Hz();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ to exclude the API function. */
#define INCLUDE_vTaskDelay 1
#define INCLUDE_xTaskGetSchedulerState 1

#define INCLUDE_uxTaskGetStackHighWaterMark 1

/* Cortex-M specific definitions. */
#ifdef __NVIC_PRIO_BITS
/* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */
Expand Down Expand Up @@ -149,6 +151,7 @@ standard names. */
/* USER CODE BEGIN Defines */
/* Section where parameter definitions can be added (for instance, to override
* default ones in FreeRTOS.h) */
#define configCHECK_FOR_STACK_OVERFLOW 2
/* USER CODE END Defines */

#endif /* FREERTOS_CONFIG_H */
Loading