diff --git a/Firmware/Board/v3/Src/freertos.c b/Firmware/Board/v3/Src/freertos.c index b247994a..9d266640 100644 --- a/Firmware/Board/v3/Src/freertos.c +++ b/Firmware/Board/v3/Src/freertos.c @@ -53,7 +53,7 @@ /* USER CODE BEGIN Includes */ #include "freertos_vars.h" -#include "axis_c_interface.h" +#include "communication.h" int odrive_main(void); /* USER CODE END Includes */ @@ -126,6 +126,7 @@ void MX_FREERTOS_Init(void) { osSemaphoreDef(sem_usb_tx); sem_usb_tx = osSemaphoreCreate(osSemaphore(sem_usb_tx), 1); + init_deferred_interrupts(); /* USER CODE END RTOS_SEMAPHORES */ /* USER CODE BEGIN RTOS_TIMERS */ diff --git a/Firmware/MotorControl/axis_c_interface.h b/Firmware/MotorControl/axis_c_interface.h deleted file mode 100644 index f891e19b..00000000 --- a/Firmware/MotorControl/axis_c_interface.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __AXIS_C_INTERFACE_H -#define __AXIS_C_INTERFACE_H - -#ifdef __cplusplus -extern "C" { -#endif - -void axis_thread_entry(void const * temp_motor_ptr); - -#ifdef __cplusplus -} -#endif - -#endif /* __AXIS_C_INTERFACE_H */ diff --git a/Firmware/MotorControl/communication.cpp b/Firmware/MotorControl/communication.cpp index 87711595..ce1d2360 100644 --- a/Firmware/MotorControl/communication.cpp +++ b/Firmware/MotorControl/communication.cpp @@ -128,8 +128,8 @@ private: } uart4_stream_output; #if defined(UART_PROTOCOL_NATIVE) -PacketToStreamConverter uart4_packet_sender(uart4_stream_output); -BidirectionalPacketBasedChannel uart4_channel(endpoints, NUM_ENDPOINTS, uart4_packet_sender); +PacketToStreamConverter uart4_packet_output(uart4_stream_output); +BidirectionalPacketBasedChannel uart4_channel(uart4_packet_output); StreamToPacketConverter uart4_stream_input(uart4_channel); #endif @@ -145,16 +145,18 @@ void enter_dfu_mode() { NVIC_SystemReset(); } +void init_deferred_interrupts(void) { + // Start USB interrupt handler thread + osThreadDef(task_usb_pump, usb_deferred_interrupt_thread, osPriorityAboveNormal, 0, 512); + thread_usb_pump = osThreadCreate(osThread(task_usb_pump), NULL); +} + void init_communication(void) { printf("hi!\r\n"); // Start command handling thread osThreadDef(task_cmd_parse, communication_task, osPriorityNormal, 0, 5000 /* in 32-bit words */); // TODO: fix stack issues thread_cmd_parse = osThreadCreate(osThread(task_cmd_parse), NULL); - - // Start USB interrupt handler thread - osThreadDef(task_usb_pump, usb_update_thread, osPriorityAboveNormal, 0, 512); - thread_usb_pump = osThreadCreate(osThread(task_usb_pump), NULL); } @@ -304,7 +306,7 @@ void set_cmd_buffer(uint8_t *buf, uint32_t len) { usb_len = len; } -void usb_update_thread(void * ctx) { +void usb_deferred_interrupt_thread(void * ctx) { (void) ctx; // unused parameter for (;;) { diff --git a/Firmware/MotorControl/communication.h b/Firmware/MotorControl/communication.h index 88e37921..18522ffe 100644 --- a/Firmware/MotorControl/communication.h +++ b/Firmware/MotorControl/communication.h @@ -13,10 +13,11 @@ extern "C" { #endif +void init_deferred_interrupts(void); void init_communication(void); void communication_task(void * ctx); void set_cmd_buffer(uint8_t *buf, uint32_t len); -void usb_update_thread(void * ctx); +void usb_deferred_interrupt_thread(void * ctx); void USB_receive_packet(const uint8_t *buffer, size_t length); extern uint64_t serial_number;