From 17375b41d8a550900bfbf9181fb0343ac1da6406 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 8 Nov 2017 19:40:52 -0500 Subject: [PATCH] Remove memcpy from set_cmd_buffer --- Firmware/MotorControl/commands.c | 9 +++++---- Firmware/MotorControl/commands.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Firmware/MotorControl/commands.c b/Firmware/MotorControl/commands.c index fa5425e1..2b8c1e4e 100644 --- a/Firmware/MotorControl/commands.c +++ b/Firmware/MotorControl/commands.c @@ -22,7 +22,7 @@ SerialPrintf_t serial_printf_select = SERIAL_PRINTF_IS_NONE; static const GpioMode_t gpio_mode = GPIO_MODE_UART; //GPIO 1,2 is UART Tx,Rx // static const GpioMode_t gpio_mode = GPIO_MODE_STEP_DIR; //GPIO 1,2 is M0 Step,Dir -static uint8_t usb_buf[64]; +static uint8_t* usb_buf; static uint32_t usb_len; extern USBD_HandleTypeDef hUsbDeviceFS; @@ -344,7 +344,8 @@ void cmd_parse_thread(void const * argument) { } } } - osStatus sem_stat = osSemaphoreWait(sem_usb_rx, 1); + // Check if there is USB processing to do. + osStatus sem_stat = osSemaphoreWait(sem_usb_rx, 0); if(sem_stat == osOK){ motor_parse_cmd(usb_buf, usb_len, SERIAL_PRINTF_IS_USB); USBD_CDC_ReceivePacket(&hUsbDeviceFS); // Allow next packet @@ -357,8 +358,8 @@ void cmd_parse_thread(void const * argument) { // Called from CDC_Receive_FS callback function, this allows motor_parse_cmd to access the // incoming USB data -void set_cmd_buffer(const uint8_t *buf, uint32_t len) { - memcpy(usb_buf, buf, len); +void set_cmd_buffer(uint8_t *buf, uint32_t len) { + usb_buf = buf; usb_len = len; } diff --git a/Firmware/MotorControl/commands.h b/Firmware/MotorControl/commands.h index 80d1b77a..1cb5ad31 100644 --- a/Firmware/MotorControl/commands.h +++ b/Firmware/MotorControl/commands.h @@ -27,7 +27,7 @@ void init_communication(); void cmd_parse_thread(void const * argument); void motor_parse_cmd(uint8_t* buffer, int len, SerialPrintf_t response_interface); -void set_cmd_buffer(const uint8_t *buf, uint32_t len); +void set_cmd_buffer(uint8_t *buf, uint32_t len); void usb_update_thread(); #endif /* COMMANDS_H */