From: Stephan Baerwolf Date: Tue, 31 Jul 2012 09:55:18 +0000 (+0200) Subject: bugfix bootloader exit logik X-Git-Tag: 2010-07-27-stephan-201207311220^0 X-Git-Url: http://git.linex4red.de/pub/USBaspLoader.git/commitdiff_plain/f40c1589de8337dcff85ba7333b848a01bb30768?ds=inline bugfix bootloader exit logik Signed-off-by: Stephan Baerwolf --- diff --git a/firmware/main.c b/firmware/main.c index 5e38af5..727081e 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -99,7 +99,7 @@ typedef union longConverter{ #if BOOTLOADER_CAN_EXIT static uchar requestBootLoaderExit; #endif -static volatile unsigned char stayinloader = 1; +static volatile unsigned char stayinloader = 0xfe; static longConverter_t currentAddress; /* in bytes */ static uchar bytesRemaining; @@ -222,12 +222,12 @@ static uchar replyBuffer[4]; } }else if(rq->bRequest == USBASP_FUNC_DISCONNECT){ - stayinloader &= (0x7f); + stayinloader &= (0xfe); #if BOOTLOADER_CAN_EXIT requestBootLoaderExit = 1; /* allow proper shutdown/close of connection */ #endif }else if(rq->bRequest == USBASP_FUNC_CONNECT){ - stayinloader |= (0x80); + stayinloader |= (0x01); }else{ /* ignore: others */ } @@ -368,13 +368,13 @@ int __attribute__((noreturn)) main(void) } } #endif - if (stayinloader & 0x1) { + if (stayinloader > 0x04) { if (!bootLoaderCondition()) { - stayinloader = (stayinloader & 0xfc) | 0x2; + stayinloader-=0x04; } } else { if (bootLoaderCondition()) { - stayinloader &= 0xfc; + stayinloader &= 0x01; } }