瀏覽代碼

Merge pull request #63 from ZuluSCSI/rp2040_sel_without_bsy

RP2040: Add support for SCSI-1 single initiator mode (#61)
Alex Perez 3 年之前
父節點
當前提交
b9afa10c98
共有 1 個文件被更改,包括 9 次插入4 次删除
  1. 9 4
      lib/ZuluSCSI_platform_RP2040/scsiPhy.cpp

+ 9 - 4
lib/ZuluSCSI_platform_RP2040/scsiPhy.cpp

@@ -113,9 +113,9 @@ static void scsi_rst_assert_interrupt()
 
 static void scsiPhyIRQ(uint gpio, uint32_t events)
 {
-    if (gpio == SCSI_IN_BSY)
+    if (gpio == SCSI_IN_BSY || gpio == SCSI_IN_SEL)
     {
-        // Note BSY interrupts only when we are not driving OUT_BSY low ourselves.
+        // Note BSY / SEL interrupts only when we are not driving OUT_BSY low ourselves.
         // The BSY input pin may be shared with other signals.
         if (sio_hw->gpio_out & (1 << SCSI_OUT_BSY))
         {
@@ -138,11 +138,16 @@ extern "C" void scsiPhyReset(void)
 
     scsi_accel_rp2040_init();
 
-    // Enable BSY and RST interrupts
+    // Enable BSY, RST and SEL interrupts
     // Note: RP2040 library currently supports only one callback,
     // so it has to be same for both pins.
     gpio_set_irq_enabled_with_callback(SCSI_IN_BSY, GPIO_IRQ_EDGE_RISE, true, scsiPhyIRQ);
-    gpio_set_irq_enabled_with_callback(SCSI_IN_RST, GPIO_IRQ_EDGE_FALL, true, scsiPhyIRQ);
+    gpio_set_irq_enabled(SCSI_IN_RST, GPIO_IRQ_EDGE_FALL, true);
+
+    // Check BSY line status when SEL goes active.
+    // This is needed to handle SCSI-1 hosts that use the single initiator mode.
+    // The host will just assert the SEL directly, without asserting BSY first.
+    gpio_set_irq_enabled(SCSI_IN_SEL, GPIO_IRQ_EDGE_FALL, true);
 }
 
 /************************/