SKY-20210407USB\Administrator пре 2 месеци
родитељ
комит
70801b9273
2 измењених фајлова са 14 додато и 6 уклоњено
  1. 9 4
      IAP_YMODEM_ATY.c
  2. 5 2
      IAP_YMODEM_ATY.h

+ 9 - 4
IAP_YMODEM_ATY.c

@@ -144,6 +144,7 @@ HAL_StatusTypeDef Interface_Receive(uint8_t* bytes, uint16_t size, uint32_t time
         if(timeoutCount > timeoutFinal){
             timeoutCount = 0;
             USBD_CDC_ReceivePacket(&hUsbDeviceFS);
+            bytes[0] = 0;
             return HAL_TIMEOUT;
         }
         HAL_Delay(1);
@@ -317,14 +318,12 @@ void Main_Cycle(void)
             {
                 if(sKey[0] == 'S')
                 {
-                    uint8_t verStr[] = "BLA_V_1_01_250705\r\n";
-                    Interface_Transmit(verStr, sizeof(verStr), 100);
                     if(sKey[1] == '3'){
                         Interface_Clean();
                         Interface_PutString("\r\nStart program execution...\r\n");
                         JumpToAppWithReset();
                     }
-                   
+
                     else if(sKey[1] == '1'){
                         Interface_Clean();
                         if(Interface_Download() != COM_OK){
@@ -772,6 +771,8 @@ uint8_t aFileName[FILE_NAME_LENGTH];
   * @retval HAL_OK: normally return
   *         HAL_BUSY: abort by user
   */
+ uint8_t byteOneTmp = 0;
+ HAL_StatusTypeDef statusA;
 static HAL_StatusTypeDef ReceivePacket(uint8_t* p_data, uint32_t* p_length, uint32_t timeout)
 {
     uint32_t crc;
@@ -781,6 +782,8 @@ static HAL_StatusTypeDef ReceivePacket(uint8_t* p_data, uint32_t* p_length, uint
 
     *p_length = 0;
     status = Interface_Receive(&byteOne, 1, timeout);
+    statusA = status;
+    byteOneTmp = byteOne;
 
     if(status == HAL_OK)
     {
@@ -998,6 +1001,7 @@ uint8_t CalcChecksum(const uint8_t* p_data, uint32_t size)
   * @param  p_size The size of the file.
   * @retval COM_StatusTypeDef result of reception/programming
   */
+HAL_StatusTypeDef statA = HAL_OK;
 COM_StatusTypeDef Ymodem_Receive(uint32_t* p_size)
 {
     uint32_t i, packet_length, session_done = 0, file_done, errors = 0, session_begin = 0;
@@ -1015,7 +1019,8 @@ COM_StatusTypeDef Ymodem_Receive(uint32_t* p_size)
         file_done = 0;
         while((file_done == 0) && (result == COM_OK))
         {
-            switch(ReceivePacket(aPacketData, &packet_length, DOWNLOAD_TIMEOUT))
+            statA = ReceivePacket(aPacketData, &packet_length, DOWNLOAD_TIMEOUT);
+            switch(statA)
             {
                 case HAL_OK:
                     errors = 0;

+ 5 - 2
IAP_YMODEM_ATY.h

@@ -38,7 +38,7 @@
 /******************************* For user *************************************/
 // do not forget change USER_VECT_TAB_ADDRESS VECT_TAB_OFFSET at system_stm32f1xx.c
 #ifndef IAP_YMODEM_ATY_DBG
-// #define IAP_YMODEM_ATY_DBG
+#define IAP_YMODEM_ATY_DBG
 #endif
 
 // #ifndef IAP_YMODEM_ATY_USB
@@ -46,8 +46,11 @@
 // #endif
 
 #ifndef IAP_S_TIME
+#ifndef IAP_YMODEM_ATY_USB
+#define IAP_S_TIME 1000
+#else
 #define IAP_S_TIME RX_TIMEOUT
-// #define IAP_S_TIME 1000
+#endif
 #endif
 #ifndef IAP_3_TIME
 #define IAP_3_TIME 5000