Parcourir la source

Fix initiator DIP switch workaround for early RP2040 boards

There was a regression affecting a small number of early RP2040
boards that have Diodes Incorporated 74LVT245B tranceivers.
These have higher bus hold current than Texas Instruments parts
used in later revisions, requiring a software workaround.

This regression caused initiator mode DIP switch not to work
on the affected boards, starting with firmware version 2023-10-20.
Petteri Aimonen il y a 11 mois
Parent
commit
a1a4479102
1 fichiers modifiés avec 21 ajouts et 2 suppressions
  1. 21 2
      lib/ZuluSCSI_platform_RP2MCU/ZuluSCSI_platform.cpp

+ 21 - 2
lib/ZuluSCSI_platform_RP2MCU/ZuluSCSI_platform.cpp

@@ -283,9 +283,24 @@ void platform_init()
 
     }
 # else
-    g_scsi_initiator = SETUP_TRUE == read_setup_ack_pin();
+    pin_setup_state_t dip_state = read_setup_ack_pin();
+    if (dip_state == SETUP_UNDETERMINED)
+    {
+        // This path is used for the few early RP2040 boards assembled with
+        // Diodes Incorporated 74LVT245B, which has higher bus hold
+        // current.
+        working_dip = false;
+        g_scsi_initiator = !gpio_get(DIP_INITIATOR); // Read fallback value
+    }
+    else
+    {
+        g_scsi_initiator = (SETUP_TRUE == dip_state);
+        termination = !gpio_get(DIP_TERM);
+    }
+
+    // dbglog DIP switch works in any case, as it does not have bus hold.
     dbglog = !gpio_get(DIP_DBGLOG);
-    termination = !gpio_get(DIP_TERM);
+    g_log_debug = dbglog;
 # endif
 #else
     delay(10);
@@ -319,9 +334,13 @@ void platform_init()
     else
     {
         logmsg("SCSI termination is determined by the DIP switch labeled \"TERM\"");
+
+#if defined(ZULUSCSI_PICO) || defined(ZULUSCSI_PICO_2)
         logmsg("Debug logging can only be enabled via INI file \"DEBUG=1\" under [SCSI] in zuluscsi.ini");
         logmsg("-- DEBUG DIP switch setting is ignored on ZuluSCSI Pico FS Rev. 2023b and 2023c boards");
         g_log_debug = false;
+#endif
+
     }
 #else
     g_log_debug = false;