mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-08-18 01:18:52 +08:00
fix analog thread stack overflow
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 --------------------------------------------------------*/
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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_;
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user