bugfix bootloader exit logik 2010-07-27-stephan-201207311220
authorStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Tue, 31 Jul 2012 09:55:18 +0000 (11:55 +0200)
committerStephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
Tue, 31 Jul 2012 10:17:50 +0000 (10:17 +0000)
Signed-off-by: Stephan Baerwolf <stephan.baerwolf@tu-ilmenau.de>
firmware/main.c

index 5e38af5..727081e 100644 (file)
@@ -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;
          }
        }