From 18f10b1538f6d3f9dccf25faeb54936a554cd258 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Thu, 15 Sep 2022 12:44:03 +0300 Subject: [PATCH] RP2040: Fix SCSI2 mode not getting enabled due to ATN handling This caused 1 ms of extra latency on requests. --- lib/ZuluSCSI_platform_RP2040/scsiPhy.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/ZuluSCSI_platform_RP2040/scsiPhy.cpp b/lib/ZuluSCSI_platform_RP2040/scsiPhy.cpp index 46fd572d..1be2ae46 100644 --- a/lib/ZuluSCSI_platform_RP2040/scsiPhy.cpp +++ b/lib/ZuluSCSI_platform_RP2040/scsiPhy.cpp @@ -56,8 +56,9 @@ void scsi_bsy_deassert_interrupt() if (sel_id >= 0) { - uint8_t atn_flag = SCSI_IN(ATN) ? SCSI_STS_SELECTION_ATN : 0; - g_scsi_sts_selection = SCSI_STS_SELECTION_SUCCEEDED | atn_flag | sel_id; + // Set ATN flag here unconditionally, real value is only known after + // OUT_BSY is enabled in scsiStatusSEL() below. + g_scsi_sts_selection = SCSI_STS_SELECTION_SUCCEEDED | SCSI_STS_SELECTION_ATN | sel_id; } // selFlag is required for Philips P2000C which releases it after 600ns @@ -80,7 +81,13 @@ extern "C" bool scsiStatusSEL() // On RP2040 hardware the ATN signal is only available after OUT_BSY enables // the IO buffer U105, so check the signal status here. delay_100ns(); - scsiDev.atnFlag |= scsiStatusATN(); + if (!scsiStatusATN()) + { + // This is a SCSI1 host that does send IDENTIFY message + scsiDev.atnFlag = 0; + scsiDev.target->unitAttention = 0; + scsiDev.compatMode = COMPAT_SCSI1; + } } return SCSI_IN(SEL);