fix analog thread stack overflow

This commit is contained in:
Samuel Sadok
2021-09-03 18:30:08 +02:00
parent e535ed630c
commit 2e0926e562
6 changed files with 16 additions and 3 deletions
+4 -2
View File
@@ -25,6 +25,7 @@
/* Global constant data ------------------------------------------------------*/
constexpr float adc_full_scale = static_cast<float>(1UL << 12UL);
constexpr float adc_ref_voltage = 3.3f;
const uint32_t stack_size_analog_thread = 1024; // Bytes
/* Global variables ----------------------------------------------------------*/
// This value is updated by the DC-bus reading ADC.
@@ -34,6 +35,7 @@ float ibus_ = 0.0f; // exposed for monitoring only
bool brake_resistor_armed = false;
bool brake_resistor_saturated = false;
float brake_resistor_current = 0.0f;
osThreadId analog_thread = 0;
/* Private constant data -----------------------------------------------------*/
/* CPU critical section helpers ----------------------------------------------*/
@@ -404,6 +406,6 @@ static void analog_polling_thread(void *)
}
void start_analog_thread() {
osThreadDef(thread_def, analog_polling_thread, osPriorityLow, 0, 512 / sizeof(StackType_t));
osThreadCreate(osThread(thread_def), NULL);
osThreadDef(analog_thread_def, analog_polling_thread, osPriorityLow, 0, stack_size_analog_thread / sizeof(StackType_t));
analog_thread = osThreadCreate(osThread(analog_thread_def), NULL);
}
+2
View File
@@ -23,6 +23,8 @@ extern bool brake_resistor_armed;
extern bool brake_resistor_saturated;
extern float brake_resistor_current;
extern uint16_t adc_measurements_[ADC_CHANNEL_COUNT];
extern osThreadId analog_thread;
extern const uint32_t stack_size_analog_thread;
/* Exported macro ------------------------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
+3
View File
@@ -270,18 +270,21 @@ void vApplicationIdleHook(void) {
odrv.system_stats_.max_stack_usage_uart = stack_size_uart_thread - uxTaskGetStackHighWaterMark(uart_thread) * sizeof(StackType_t);
odrv.system_stats_.max_stack_usage_startup = stack_size_default_task - uxTaskGetStackHighWaterMark(defaultTaskHandle) * sizeof(StackType_t);
odrv.system_stats_.max_stack_usage_can = odrv.can_.stack_size_ - uxTaskGetStackHighWaterMark(odrv.can_.thread_id_) * sizeof(StackType_t);
odrv.system_stats_.max_stack_usage_analog = stack_size_analog_thread - uxTaskGetStackHighWaterMark(analog_thread) * sizeof(StackType_t);
odrv.system_stats_.stack_size_axis = axes[0].stack_size_;
odrv.system_stats_.stack_size_usb = stack_size_usb_thread;
odrv.system_stats_.stack_size_uart = stack_size_uart_thread;
odrv.system_stats_.stack_size_startup = stack_size_default_task;
odrv.system_stats_.stack_size_can = odrv.can_.stack_size_;
odrv.system_stats_.stack_size_analog = stack_size_analog_thread;
odrv.system_stats_.prio_axis = osThreadGetPriority(axes[0].thread_id_);
odrv.system_stats_.prio_usb = osThreadGetPriority(usb_thread);
odrv.system_stats_.prio_uart = osThreadGetPriority(uart_thread);
odrv.system_stats_.prio_startup = osThreadGetPriority(defaultTaskHandle);
odrv.system_stats_.prio_can = osThreadGetPriority(odrv.can_.thread_id_);
odrv.system_stats_.prio_analog = osThreadGetPriority(analog_thread);
status_led_controller.update();
}
+3
View File
@@ -33,18 +33,21 @@ typedef struct {
uint32_t max_stack_usage_uart;
uint32_t max_stack_usage_startup;
uint32_t max_stack_usage_can;
uint32_t max_stack_usage_analog;
uint32_t stack_size_axis;
uint32_t stack_size_usb;
uint32_t stack_size_uart;
uint32_t stack_size_startup;
uint32_t stack_size_can;
uint32_t stack_size_analog;
int32_t prio_axis;
int32_t prio_usb;
int32_t prio_uart;
int32_t prio_startup;
int32_t prio_can;
int32_t prio_analog;
USBStats_t& usb = usb_stats_;
I2CStats_t& i2c = i2c_stats_;
+3
View File
@@ -143,16 +143,19 @@ interfaces:
max_stack_usage_uart: readonly uint32
max_stack_usage_can: readonly uint32
max_stack_usage_startup: readonly uint32
max_stack_usage_analog: readonly uint32
stack_size_axis: readonly uint32
stack_size_usb: readonly uint32
stack_size_uart: readonly uint32
stack_size_startup: readonly uint32
stack_size_can: readonly uint32
stack_size_analog: readonly uint32
prio_axis: readonly int32
prio_usb: readonly int32
prio_uart: readonly int32
prio_startup: readonly int32
prio_can: readonly int32
prio_analog: readonly int32
usb:
c_is_class: False
attributes:
+1 -1
View File
@@ -38,7 +38,7 @@ to publish packages with the name odrive.
is_release = True
# Set to true to make an official post-release, rather than dev of new version
is_post_release = True
is_post_release = False
post_rel_num = 0
# To test higher numbered releases, bump to the next rev