improve bootloader-exit logik
authorStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Mon, 30 Jul 2012 22:21:12 +0000 (22:21 +0000)
committerStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Mon, 30 Jul 2012 22:21:12 +0000 (22:21 +0000)
Do not wait until a user does one transaction. Just wait for a
repress of the JUMPER-Button.
Also: if there is a transaction going on - do NOT exit!

Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
firmware/main.c

index b3f1470..5e38af5 100644 (file)
@@ -222,12 +222,14 @@ static uchar    replyBuffer[4];
         }
 
     }else if(rq->bRequest == USBASP_FUNC_DISCONNECT){
-      stayinloader         = 0;
+      stayinloader        &= (0x7f);
 #if BOOTLOADER_CAN_EXIT
       requestBootLoaderExit = 1;      /* allow proper shutdown/close of connection */
 #endif
+    }else if(rq->bRequest == USBASP_FUNC_CONNECT){
+      stayinloader        |= (0x80);
     }else{
-        /* ignore: USBASP_FUNC_CONNECT */
+        /* ignore: others */
     }
     return len;
 }
@@ -366,7 +368,17 @@ int __attribute__((noreturn)) main(void)
                 }
             }
 #endif
-        }while ((stayinloader) || (!bootLoaderCondition()));  /* main event loop */
+       if (stayinloader & 0x1) {
+         if (!bootLoaderCondition()) {
+           stayinloader = (stayinloader & 0xfc) | 0x2;
+         } 
+       } else {
+         if (bootLoaderCondition()) {
+           stayinloader &= 0xfc;
+         }
+       }
+
+        }while (stayinloader);  /* main event loop */
     }
     leaveBootloader();
 }