initialize USB interrupt pump before initializing USB device

This commit is contained in:
Samuel Sadok
2018-04-20 21:15:59 -07:00
parent 27574234d5
commit dee8efef22
4 changed files with 13 additions and 23 deletions
+2 -1
View File
@@ -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 */
-14
View File
@@ -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 */
+9 -7
View File
@@ -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 (;;) {
+2 -1
View File
@@ -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;