Skip to content

Commit db56674

Browse files
committed
fix: thread stack size
1 parent aceb2e1 commit db56674

File tree

11 files changed

+68
-66
lines changed

11 files changed

+68
-66
lines changed

Application/Inc/FreeRTOSConfig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
#define configTICK_RATE_HZ ((TickType_t)1000)
6565
#define configMAX_PRIORITIES ( 7 )
6666
#define configMINIMAL_STACK_SIZE ((uint16_t)64)
67-
#define configTOTAL_HEAP_SIZE ((size_t)14000)
67+
#define configTOTAL_HEAP_SIZE ((size_t)15000)
6868
#define configMAX_TASK_NAME_LEN ( 16 )
6969
#define configUSE_16_BIT_TICKS 0
7070
#define configUSE_MUTEXES 1

Application/Inc/Instances.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include "ADC.hpp"
55
#include "CLI.hpp"
6-
#include "CRC.hpp"
6+
// #include "CRC.hpp"
77
#include "DAC.hpp"
88
#include "Flash.hpp"
99
#include "LED.hpp"
@@ -19,6 +19,6 @@ extern Flash flash;
1919
extern CustomDAC dac;
2020
extern CustomADC adc;
2121
extern CustomRTC rtc;
22-
extern CustomCRC crc;
22+
// extern CustomCRC crc;
2323

2424
#endif /* APPLICATION_INC_INSTANCES */

Application/Inc/LED.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class LED {
6969
Injection injections;
7070
};
7171

72+
7273
// State Machine Instances
7374
StateMachine led_sm;
7475

Application/Inc/Thread.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class Thread {
3030
TaskHandle_t flashSave_handle;
3131
void flashLoad();
3232
TaskHandle_t flashLoad_handle;
33-
void calculator();
34-
TaskHandle_t calculator_handle;
33+
// void calculator();
34+
// TaskHandle_t calculator_handle;
3535
void dacUpdate();
3636
TaskHandle_t dacUpdate_handle;
3737
void schedule_20Hz();

Application/Inc/main.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern "C" {
3333

3434
#include "adc.h"
3535
#include "cordic.h"
36-
#include "crc.h"
36+
// #include "crc.h"
3737
#include "dac.h"
3838
#include "dma.h"
3939
#include "fmac.h"

Application/Src/CLI.cpp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void CLI::setCommands() {
1515
cmd_map["flash"] = [this](int32_t argc, char** argv) { func_flash(argc, argv); };
1616
cmd_map["info"] = [this](int32_t argc, char** argv) { func_info(argc, argv); };
1717
cmd_map["rot"] = [this](int32_t argc, char** argv) { func_rot(argc, argv); };
18-
cmd_map["crc"] = [this](int32_t argc, char** argv) { func_crc(argc, argv); };
18+
// cmd_map["crc"] = [this](int32_t argc, char** argv) { func_crc(argc, argv); };
1919
cmd_map["dac"] = [this](int32_t argc, char** argv) { func_dac(argc, argv); };
2020
cmd_map["reset"] = [this](int32_t argc, char** argv) { func_reset(argc, argv); };
2121
}
@@ -88,9 +88,11 @@ void CLI::func_flash(int32_t argc, char** argv) {
8888
if (arg == "help" || arg == "?" || arg == "-h") {
8989
serial.sendString(help_text);
9090
} else if (arg == "save") {
91-
xTaskCreate(Thread::task<&Thread::flashSave>, "Flash Save", 200, NULL, 1, &thread.flashSave_handle);
91+
if (flash.Save()) {
92+
serial.sendString("Flash Saved\n");
93+
}
9294
} else if (arg == "load") {
93-
xTaskCreate(Thread::task<&Thread::flashLoad>, "Flash Load", 200, NULL, 1, &thread.flashLoad_handle);
95+
flash.Load();
9496
} else if (arg == "purge") {
9597
if (flash.Purge()) {
9698
serial.sendString("Flash Purged\n");
@@ -155,28 +157,28 @@ void CLI::func_rot(int32_t argc, char** argv) {
155157
}
156158
}
157159

158-
void CLI::func_crc(int32_t argc, char** argv) {
159-
// Detailed Menu
160-
const char* help_text =
161-
"\nCRC Functions:\n"
162-
" acc [#]\tAccumulate CRC\n"
163-
" cal [#]\tCalculate CRC\n\n";
164-
165-
// Sub Command
166-
if (argc > 1) {
167-
std::string arg = argv[1];
168-
if (arg == "help" || arg == "?" || arg == "-h") {
169-
serial.sendString(help_text);
170-
} else if (arg == "cal") {
171-
if (argc == 3) {
172-
uint8_t input = std::stoi(argv[2]);
173-
SM<Thread>::setState(Thread::State::CRC_CAL, thread.runner_sm, std::vector<uint8_t>{input});
174-
}
175-
} else {
176-
serial.sendString("Command not found\n");
177-
}
178-
}
179-
}
160+
// void CLI::func_crc(int32_t argc, char** argv) {
161+
// // Detailed Menu
162+
// const char* help_text =
163+
// "\nCRC Functions:\n"
164+
// " acc [#]\tAccumulate CRC\n"
165+
// " cal [#]\tCalculate CRC\n\n";
166+
167+
// // Sub Command
168+
// if (argc > 1) {
169+
// std::string arg = argv[1];
170+
// if (arg == "help" || arg == "?" || arg == "-h") {
171+
// serial.sendString(help_text);
172+
// } else if (arg == "cal") {
173+
// if (argc == 3) {
174+
// uint8_t input = std::stoi(argv[2]);
175+
// SM<Thread>::setState(Thread::State::CRC_CAL, thread.runner_sm, std::vector<uint8_t>{input});
176+
// }
177+
// } else {
178+
// serial.sendString("Command not found\n");
179+
// }
180+
// }
181+
// }
180182

181183
void CLI::func_dac(int32_t argc, char** argv) {
182184
// Detailed Menu

Application/Src/Thread.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Thread::Thread() {
4343
{ // Entry definition: (TargetState, GuardFunction, ActionFunction, Injection)
4444
{ State::OFF, {}, actionRotationStop(), {} },
4545
{ State::INIT, {}, actionRotationStart(), {} },
46-
{ State::CRC_CAL, {}, actionCRCStart(), {} },
46+
// { State::CRC_CAL, {}, actionCRCStart(), {} },
4747
},
4848
{ // Transition definition: (CurrentState, Event, NextState, GuardFunction, ActionFunction, Injection)
4949
{ State::OFF, Event::START, State::R0, {}, actionRotationStart(), {} },
@@ -54,7 +54,7 @@ Thread::Thread() {
5454
{ State::R3, Event::TASK_DONE, State::R4, {}, actionRotate(), {3} },
5555
{ State::R4, Event::TASK_DONE, State::R1, {}, actionRotate(), {4} },
5656
{ State::R1, Event::STOP, State::OFF, {}, actionRotationStop(), {} },
57-
{ State::CRC_CAL, Event::TASK_DONE, State::OFF, {}, actionCRCStop(), {} },
57+
// { State::CRC_CAL, Event::TASK_DONE, State::OFF, {}, actionCRCStop(), {} },
5858
},
5959
{ // Anonymous transition definition: (CurrentState, NextState, GuardFunction, ActionFunction, Injection)
6060
{ State::R0, State::R1, {}, [](){serial.sendString("auto\n");}, {} },
@@ -78,16 +78,16 @@ void Thread::init() {
7878
}
7979
}
8080
Action Thread::actionSystemInit() {
81-
return [this]() { xTaskCreate(task<&Thread::init>, "system init", 1100, this, 6, &init_handle); };
81+
return [this]() { xTaskCreate(task<&Thread::init>, "system init", 1000, this, 6, &init_handle); };
8282
}
8383
Action Thread::actionSystemRun() {
8484
return [this]() {
85-
xTaskCreate(task<&Thread::serialTX>, "serial send tx", 100, this, 1, &serial_handle);
86-
xTaskCreate(task<&Thread::parse>, "cli parsing", 420, this, 2, &parse_handle);
87-
xTaskCreate(task<&Thread::schedule_20Hz>, "schedule 20Hz", 64, this, 5, &schedule_20Hz_handle);
88-
xTaskCreate(task<&Thread::telemetry>, "telemetry", 400, this, 3, &telemetry_handle);
85+
xTaskCreate(task<&Thread::serialTX>, "serial send tx", 100, this, 3, &serial_handle);
86+
xTaskCreate(task<&Thread::parse>, "cli parsing", 1100, this, 6, &parse_handle);
87+
xTaskCreate(task<&Thread::schedule_20Hz>, "schedule 20Hz", 64, this, 2, &schedule_20Hz_handle);
88+
xTaskCreate(task<&Thread::telemetry>, "telemetry", 400, this, 2, &telemetry_handle);
8989
vTaskSuspend(telemetry_handle);
90-
xTaskCreate(task<&Thread::runner>, "task simulation", 420, this, 3, &runner_handle);
90+
xTaskCreate(task<&Thread::runner>, "task simulation", 200, this, 3, &runner_handle);
9191
vTaskSuspend(runner_handle);
9292
// xTaskCreate(task<&Thread::calculator>, "calculator", 200, this, 5, &calculator_handle);
9393
// vTaskSuspend(calculator_handle);
@@ -229,26 +229,26 @@ void Thread::flashLoad() {
229229
}
230230
}
231231

232-
void Thread::calculator() {
233-
while (1) {
234-
// get std::vector<uint8> input from injection
235-
std::vector<uint8_t> input = std::any_cast<std::vector<uint8_t>>(runner_sm.injections[0]);
236-
crc.setPolynomial(0x9B, 8);
237-
crc.setInitValue(0x00);
238-
auto result = crc.calculate(input.data(), 2);
239-
serial.sendString("CRC Result: ");
240-
serial.sendNumber(result);
241-
serial.sendLn();
242-
SM<Thread>::triggerEvent(Event::TASK_DONE, runner_sm);
243-
}
244-
}
245-
Action Thread::actionCRCStart() {
246-
return [this]() {
247-
BaseType_t xYieldRequired = pdTRUE;
248-
xTaskResumeFromISR(calculator_handle);
249-
portYIELD_FROM_ISR(xYieldRequired);
250-
};
251-
}
252-
Action Thread::actionCRCStop() {
253-
return [this]() { vTaskSuspend(calculator_handle); };
254-
}
232+
// void Thread::calculator() {
233+
// while (1) {
234+
// // get std::vector<uint8> input from injection
235+
// std::vector<uint8_t> input = std::any_cast<std::vector<uint8_t>>(runner_sm.injections[0]);
236+
// crc.setPolynomial(0x9B, 8);
237+
// crc.setInitValue(0x00);
238+
// auto result = crc.calculate(input.data(), 2);
239+
// serial.sendString("CRC Result: ");
240+
// serial.sendNumber(result);
241+
// serial.sendLn();
242+
// SM<Thread>::triggerEvent(Event::TASK_DONE, runner_sm);
243+
// }
244+
// }
245+
// Action Thread::actionCRCStart() {
246+
// return [this]() {
247+
// BaseType_t xYieldRequired = pdTRUE;
248+
// xTaskResumeFromISR(calculator_handle);
249+
// portYIELD_FROM_ISR(xYieldRequired);
250+
// };
251+
// }
252+
// Action Thread::actionCRCStop() {
253+
// return [this]() { vTaskSuspend(calculator_handle); };
254+
// }

Application/Src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Flash flash{};
1212
CustomDAC dac{};
1313
CustomADC adc{};
1414
CustomRTC rtc{};
15-
CustomCRC crc{};
15+
// CustomCRC crc{};
1616

1717
/**
1818
* @brief The application entry point.
@@ -33,7 +33,7 @@ int main(void) {
3333
MX_TIM2_Init();
3434
MX_TIM4_Init();
3535
MX_RTC_Init();
36-
MX_CRC_Init();
36+
// MX_CRC_Init();
3737
MX_FMAC_Init();
3838
MX_CORDIC_Init();
3939

@@ -42,7 +42,7 @@ int main(void) {
4242
led_user.setPort(&htim8.Instance->CCR2);
4343
dac.setPort(&hdac1, DAC_CHANNEL_2);
4444
rtc.setPort(&hrtc);
45-
crc.setPort(&hcrc);
45+
// crc.setPort(&hcrc);
4646

4747
// PWM Output Start
4848
HAL_TIM_PWM_Start_IT(&htim8, TIM_CHANNEL_2);
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)