cleanup
This commit is contained in:
@@ -1,19 +1,18 @@
|
||||
#include "cmsis_os2.h"
|
||||
#include "usb_device.h"
|
||||
|
||||
#include <pb_decode.h>
|
||||
#include "firmware.pb.h"
|
||||
|
||||
#include "UsbDataHandler.h"
|
||||
|
||||
/* Define the task attributes */
|
||||
#define TASK_STACK_SIZE 1024
|
||||
#define TASK_PRIORITY osPriorityNormal
|
||||
|
||||
/* Declare the thread function */
|
||||
#define MAX_PACKET_SIZE 512-4 // Define your maximum packet size
|
||||
#define NUM_BUFFERS 4 // Define the number of buffers you want to use
|
||||
|
||||
|
||||
/* Define the task attributes */
|
||||
#define TASK_STACK_SIZE 1024
|
||||
#define TASK_PRIORITY osPriorityNormal
|
||||
/* Declare static memory for the task */
|
||||
static uint32_t UsbDataHandler_TaskStack[TASK_STACK_SIZE];
|
||||
static const osThreadAttr_t UsbDataHandler_TaskAttr = {
|
||||
@@ -134,6 +133,12 @@ USBD_StatusTypeDef UsbDataHandler_RxCallback(uint8_t* Buf, uint32_t Len) {
|
||||
if (dataIndex == 4) {
|
||||
/* Extract the packet length */
|
||||
packetLength = buffers[bufferIndex].pack.length;
|
||||
|
||||
if (packetLength >= MAX_PACKET_SIZE ) {
|
||||
dataIndex = 0;
|
||||
packetLength = 0;
|
||||
return USBD_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we have received a full packet */
|
||||
@@ -147,7 +152,6 @@ USBD_StatusTypeDef UsbDataHandler_RxCallback(uint8_t* Buf, uint32_t Len) {
|
||||
packetLength = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user