X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/blobdiff_plain/a3d7386c66be4c2479a15ebfa60eb733c0005dbc..8ce9055cc4df6de93528cf3e12a4b69d5fcc1a19:/firmware/main.c diff --git a/firmware/main.c b/firmware/main.c index 98703f9..038368c 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -493,9 +493,9 @@ static uchar replyBuffer[4]; }else if(rq->bRequest == USBASP_FUNC_DISCONNECT){ #if BOOTLOADER_CAN_EXIT -# if (BOOTLOADER_LOOPCYCLES_TIMEOUT) - timeout_remaining = BOOTLOADER_LOOPCYCLES_TIMEOUT; - stayinloader = (0xfe); +# ifdef CONFIG_HAVE__BOOTLOADER_ABORTTIMEOUTONACT + /* let the main loop know for ever that here was activity */ + stayinloader &= (0xfc); # else stayinloader &= (0xfe); # endif @@ -766,14 +766,38 @@ int __attribute__((__noreturn__)) main(void) initForUsbConnectivity(); do{ #if ((BOOTLOADER_LOOPCYCLES_TIMEOUT) && (BOOTLOADER_CAN_EXIT)) - __loopscycles++; - if (!(__loopscycles)) { - if(timeout_remaining) timeout_remaining--; - else stayinloader&=0xf1; +# 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++; + if (!(__loopscycles)) { + if(timeout_remaining) timeout_remaining--; + else stayinloader&=0xf1; + } } #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" @@ -805,6 +829,7 @@ asm volatile ( } #endif #endif +#endif #if BOOTLOADER_CAN_EXIT }while (stayinloader); /* main event loop, if BOOTLOADER_CAN_EXIT*/