From: Stephan Baerwolf Date: Mon, 30 Jul 2012 22:21:12 +0000 (+0000) Subject: improve bootloader-exit logik X-Git-Tag: 2010-07-27-stephan-201207310030~2 X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/commitdiff_plain/26bcdc1e26b2c2ccd7d399df1115a8a68a9c28ee improve bootloader-exit logik 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 --- diff --git a/firmware/main.c b/firmware/main.c index b3f1470..5e38af5 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -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(); }