Kaynağa Gözat

Correct direct mode init order and blinking

Direct mode was still looking for images and files on the SD card.
This skips those and sets the blinking for direct mode to
1 normal blink for the board initializing properly and the 4 quick
blinks to denote that is in direct mode.
Morio 2 yıl önce
ebeveyn
işleme
584f398a2d
1 değiştirilmiş dosya ile 36 ekleme ve 37 silme
  1. 36 37
      src/ZuluSCSI.cpp

+ 36 - 37
src/ZuluSCSI.cpp

@@ -71,12 +71,16 @@ static bool g_sdcard_present;
 
 void blinkStatus(int count)
 {
+  uint8_t blink_delay = 250;
+  if (count == BLINK_DIRECT_MODE)
+    blink_delay = 100;
+
   for (int i = 0; i < count; i++)
   {
     LED_ON();
-    delay(250);
+    delay(blink_delay);
     LED_OFF();
-    delay(250);
+    delay(blink_delay);
   }
 }
 
@@ -577,10 +581,17 @@ static bool mountSDCard()
 
 static void reinitSCSI()
 {
+#if defined(ZULUSCSI_HARDWARE_CONFIG)
+  if (!g_hw_config.is_active() && ini_getbool("SCSI", "Debug", 0, CONFIGFILE))
+  {
+    g_log_debug = true;
+  }
+#else
   if (ini_getbool("SCSI", "Debug", 0, CONFIGFILE))
   {
     g_log_debug = true;
   }
+#endif
 
 #ifdef PLATFORM_HAS_INITIATOR_MODE
   if (platform_is_initiator_mode_enabled())
@@ -598,18 +609,6 @@ static void reinitSCSI()
 #endif
 
   scsiDiskResetImages();
-  readSCSIDeviceConfig();
-  findHDDImages();
-
-  // Error if there are 0 image files
-  if (scsiDiskCheckAnyImagesConfigured())
-  {
-    // Ok, there is an image, turn LED on for the time it takes to perform init
-    LED_ON();
-    delay(100);
-  }
-  else
-  {
 #if defined(ZULUSCSI_HARDWARE_CONFIG)
   if (g_hw_config.is_active())
   {
@@ -621,33 +620,33 @@ static void reinitSCSI()
     {
       blinkStatus(BLINK_STATUS_OK);
     }
+    delay(250);
+    blinkStatus(BLINK_DIRECT_MODE);
   }
   else
 #endif // ZULUSCSI_HARDWARE_CONFIG
-#ifdef RAW_FALLBACK_ENABLE
-  {
-    logmsg("No images found, enabling RAW fallback partition");
-    scsiDiskOpenHDDImage(RAW_FALLBACK_SCSI_ID, "RAW:0:0xFFFFFFFF", RAW_FALLBACK_SCSI_ID, 0,
-                         RAW_FALLBACK_BLOCKSIZE);
-  }
-#else
-    logmsg("No valid image files found!");
-#endif // RAW_FALLBACK_ENABLE
+  { 
+    readSCSIDeviceConfig();
+    findHDDImages();
 
-#ifdef ZULUSCSI_HARDWARE_CONFIG
-  if (g_hw_config.is_active())
-  {
-    // At this point the board has already blinked once for ok
-    // So subtracting 1 to blink the correct amount
-    blinkStatus(BLINK_DIRECT_MODE - 1);
-  }
-  else
-  {
-    blinkStatus(BLINK_ERROR_NO_IMAGES);
-  }
-#else
-   blinkStatus(BLINK_ERROR_NO_IMAGES);
-#endif
+    // Error if there are 0 image files
+    if (scsiDiskCheckAnyImagesConfigured())
+    {
+      // Ok, there is an image, turn LED on for the time it takes to perform init
+      LED_ON();
+      delay(100);
+    }
+    else
+    {
+  #ifdef RAW_FALLBACK_ENABLE
+      logmsg("No images found, enabling RAW fallback partition");
+      scsiDiskOpenHDDImage(RAW_FALLBACK_SCSI_ID, "RAW:0:0xFFFFFFFF", RAW_FALLBACK_SCSI_ID, 0,
+                          RAW_FALLBACK_BLOCKSIZE);
+  #else
+      logmsg("No valid image files found!");
+  #endif // RAW_FALLBACK_ENABLE
+      blinkStatus(BLINK_ERROR_NO_IMAGES);
+    }
   }
 
   scsiPhyReset();