introduce new feature: BOOTLOADER_LOOPCYCLES_TIMEOUT
[pub/USBaspLoader.git] / firmware / bootloaderconfig.h
index e3520b4..072aa81 100644 (file)
@@ -322,6 +322,31 @@ these macros are defined, the boot loader usees them.
  * user intervention
  */
 
+#ifdef CONFIG_NO__BOOTLOADER_HIDDENEXITCOMMAND
+#      define HAVE_BOOTLOADER_HIDDENEXITCOMMAND 0
+#else
+#      define HAVE_BOOTLOADER_HIDDENEXITCOMMAND 0xff
+#endif
+/* 
+ * When enabling "BOOTLOADER_HIDDENEXITCOMMAND", then
+ * sending the RAW-ISP command "0xff 0xXX 0xXX 0xXX"
+ * will cause the bootloader to start the firmware
+ * as soon as the programming software disconnects.
+ */
+
+#ifndef BOOTLOADER_LOOPCYCLES_TIMEOUT
+#      define BOOTLOADER_LOOPCYCLES_TIMEOUT    0
+#endif
+/* 
+ * When greater than "0", "BOOTLOADER_LOOPCYCLES_TIMEOUT"
+ * defines how many 16bit loopcycles can be cycled,
+ * before bootloader times out and starts user
+ * firmware.
+ * Of course "BOOTLOADER_CAN_EXIT" must be enabled.
+ * If value is even too small, bootloader  will not
+ * exit as long as bootLoaderConditionSimple stays on.
+ */
+
 //#define SIGNATURE_BYTES             0x1e, 0x93, 0x07, 0     /* ATMega8 */
 /* This macro defines the signature bytes returned by the emulated USBasp to
  * the programmer software. They should match the actual device at least in
@@ -389,7 +414,8 @@ static volatile uint8_t __BOOTLOADERENTRY_FROMSOFTWARE__bootup_MCUCSR __attribut
 
 static inline bool bootLoaderCondition(void)
 {
-  if (__BOOTLOADERENTRY_FROMSOFTWARE__bootup_MCUCSR & (_BV(WDRF))) {
+  if (__BOOTLOADERENTRY_FROMSOFTWARE__bootup_MCUCSR & (~(_BV(WDRF)))) {
+  } else {
     if (__BOOTLOADERENTRY_FROMSOFTWARE__bootup_RAMEND_doesmatch == (__BOOTLOADERENTRY_FROMSOFTWARE__EXPECTEDADDRESS & 0xff)) {
       // anything else: match - the firmware is calling the bootloader
       return true;