introduce new feature: BOOTLOADER_IGNOREPROGBUTTON
[pub/USBaspLoader.git] / firmware / main.c
index c609439..038368c 100644 (file)
@@ -493,7 +493,12 @@ static uchar    replyBuffer[4];
     }else if(rq->bRequest == USBASP_FUNC_DISCONNECT){
 
 #if BOOTLOADER_CAN_EXIT
     }else if(rq->bRequest == USBASP_FUNC_DISCONNECT){
 
 #if BOOTLOADER_CAN_EXIT
+#      ifdef CONFIG_HAVE__BOOTLOADER_ABORTTIMEOUTONACT
+      /* let the main loop know for ever that here was activity */
+      stayinloader        &= (0xfc);
+#      else
       stayinloader        &= (0xfe);
       stayinloader        &= (0xfe);
+#      endif
 #endif
     }else{
         /* ignore: others, but could be USBASP_FUNC_CONNECT */
 #endif
     }else{
         /* ignore: others, but could be USBASP_FUNC_CONNECT */
@@ -761,7 +766,12 @@ int __attribute__((__noreturn__)) main(void)
         initForUsbConnectivity();
         do{
 #if ((BOOTLOADER_LOOPCYCLES_TIMEOUT) && (BOOTLOADER_CAN_EXIT))
         initForUsbConnectivity();
         do{
 #if ((BOOTLOADER_LOOPCYCLES_TIMEOUT) && (BOOTLOADER_CAN_EXIT))
-       if (stayinloader & 0x1) {
+#      ifdef CONFIG_HAVE__BOOTLOADER_ABORTTIMEOUTONACT
+       if (stayinloader != 0x0e) {
+         /* can be reached, since high-nibble is decreased every cycle... */
+#else
+       if (stayinloader & 0x01) {
+#endif
          timeout_remaining = BOOTLOADER_LOOPCYCLES_TIMEOUT;
        } else {
          __loopscycles++;
          timeout_remaining = BOOTLOADER_LOOPCYCLES_TIMEOUT;
        } else {
          __loopscycles++;
@@ -773,6 +783,21 @@ int __attribute__((__noreturn__)) main(void)
 #endif
             usbPoll();
 #if BOOTLOADER_CAN_EXIT
 #endif
             usbPoll();
 #if BOOTLOADER_CAN_EXIT
+#if BOOTLOADER_IGNOREPROGBUTTON
+  /* 
+   * remove the high nibble as it would be subtracted due to:
+   * "(!bootLoaderConditionSimple())"
+   */ 
+#if USE_EXCESSIVE_ASSEMBLER
+asm  volatile  (
+  "andi                %[sil],         0x0f\n\t"
+  : [sil]        "+d" (stayinloader)
+  :
+);
+#else
+  stayinloader &= 0x0f;
+#endif
+#else
 #if USE_EXCESSIVE_ASSEMBLER
 asm  volatile  (
   "cpi         %[sil],         0x10\n\t"
 #if USE_EXCESSIVE_ASSEMBLER
 asm  volatile  (
   "cpi         %[sil],         0x10\n\t"
@@ -804,6 +829,7 @@ asm  volatile  (
        }
 #endif
 #endif
        }
 #endif
 #endif
+#endif
 
 #if BOOTLOADER_CAN_EXIT
         }while (stayinloader); /* main event loop, if BOOTLOADER_CAN_EXIT*/
 
 #if BOOTLOADER_CAN_EXIT
         }while (stayinloader); /* main event loop, if BOOTLOADER_CAN_EXIT*/