Browse Source

fix usb stuck maybe

JY 4 months ago
parent
commit
8618917594
2 changed files with 10 additions and 3 deletions
  1. 6 1
      IAP_YMODEM_ATY.c
  2. 4 2
      IAP_YMODEM_ATY.h

+ 6 - 1
IAP_YMODEM_ATY.c

@@ -36,11 +36,13 @@
 /******************************* For user *************************************/
 uint8_t EmptyBuf[1] = {0};
 
+#ifdef IAP_YMODEM_ATY_USB
 USBD_CDC_HandleTypeDef* hcdc;
 uint32_t ucdcRcvLength = 0;
 uint8_t ucdcRcvOverFlag = 1;
 uint32_t ucdcRcvLastTime = 0;
 uint8_t ucdcRcvBuffer[APP_RX_DATA_SIZE] = {0};
+#endif
 
 void All_Reset(void)
 {
@@ -92,6 +94,7 @@ void Interface_Clean(void)
 #endif
 }
 
+#ifdef IAP_YMODEM_ATY_USB
 void PUT_IN_CDC_Receive_FS(uint8_t* Buf, uint32_t* Len)
 {
     if(ucdcRcvOverFlag == 1){ // new start
@@ -119,7 +122,7 @@ void PUT_IN_CDC_Receive_FS(uint8_t* Buf, uint32_t* Len)
     // USBD_CDC_ReceivePacket(&hUsbDeviceFS);
     // return (USBD_OK);
 }
-
+#endif
 
 uint32_t timeoutCount = 0;
 uint32_t timeoutFinal = 100;
@@ -297,11 +300,13 @@ void Main_Cycle(void)
     Interface_PutString("\r\n\r\nS to start\r\n\r\n");
     while(1)
     {
+        #ifdef IAP_YMODEM_ATY_USB
         if(hcdc->RxLength > 1024){
             uint8_t t[1] = {0};
             Interface_Receive(t, 1, 10);
             continue; 
         }
+        #endif
         if(1)
         {
             if(Interface_Receive(sKey, 2, IAP_S_TIME) == HAL_OK)

+ 4 - 2
IAP_YMODEM_ATY.h

@@ -46,8 +46,8 @@
 // #endif
 
 #ifndef IAP_S_TIME
-#define IAP_S_TIME RX_TIMEOUT
-// #define IAP_S_TIME 1000
+//#define IAP_S_TIME RX_TIMEOUT
+ #define IAP_S_TIME 1000
 #endif
 #ifndef IAP_3_TIME
 #define IAP_3_TIME 5000
@@ -56,11 +56,13 @@
 extern UART_HandleTypeDef huart3;
 #define Interface_UART huart3
 
+#ifdef IAP_YMODEM_ATY_USB
 #include "usbd_def.h"
 #include "usb_device.h"
 #include "usbd_cdc_if.h"
 extern USBD_HandleTypeDef hUsbDeviceFS;
 void PUT_IN_CDC_Receive_FS(uint8_t* Buf, uint32_t* Len);
+#endif
 
 void Main_Menu(void);
 void Main_Cycle(void);