Force unit-attention-condition off for pre-SCSI2 hosts
[SCSI2SD-V6.git] / software / SCSI2SD / src / scsi.c
index 581c17a..7a9d359 100755 (executable)
@@ -48,6 +48,10 @@ static void doReserveRelease(void);
 \r
 static void enter_BusFree()\r
 {\r
+       // This delay probably isn't needed for most SCSI hosts, but it won't\r
+       // hurt either. It's possible some of the samplers needed this delay.\r
+       CyDelayUs(2);\r
+\r
        SCSI_ClearPin(SCSI_Out_BSY);\r
        // We now have a Bus Clear Delay of 800ns to release remaining signals.\r
        SCSI_ClearPin(SCSI_Out_MSG);\r
@@ -178,14 +182,7 @@ static void process_DataIn()
        if ((scsiDev.dataPtr >= scsiDev.dataLen) &&\r
                (transfer.currentBlock == transfer.blocks))\r
        {\r
-               if (scsiDev.postDataOutHook != NULL)\r
-               {\r
-                       scsiDev.postDataOutHook();\r
-               }\r
-               else\r
-               {\r
-                       enter_Status(GOOD);\r
-               }\r
+               enter_Status(GOOD);\r
        }\r
 }\r
 \r
@@ -219,7 +216,14 @@ static void process_DataOut()
        if ((scsiDev.dataPtr >= scsiDev.dataLen) &&\r
                (transfer.currentBlock == transfer.blocks))\r
        {\r
-               enter_Status(GOOD);\r
+               if (scsiDev.postDataOutHook != NULL)\r
+               {\r
+                       scsiDev.postDataOutHook();\r
+               }\r
+               else\r
+               {\r
+                       enter_Status(GOOD);\r
+               }\r
        }\r
 }\r
 \r
@@ -492,9 +496,16 @@ static void process_SelectionPhase()
                (goodParity || !config->enableParity) && (maskBitCount <= 2))\r
        {\r
                // Do we enter MESSAGE OUT immediately ? SCSI 1 and 2 standards says\r
-               // move to MESSAGE OUT if ATN is true before we release BSY.\r
-               // The initiate should assert ATN with SEL.\r
+               // move to MESSAGE OUT if ATN is true before we assert BSY.\r
+               // The initiator should assert ATN with SEL.\r
                scsiDev.atnFlag = SCSI_ReadPin(SCSI_ATN_INT);\r
+               \r
+               // Unit attention breaks many older SCSI hosts. Disable it completely for\r
+               // SCSI-1 (and older) hosts, regardless of our configured setting.\r
+               if (!scsiDev.atnFlag)\r
+               {\r
+                       scsiDev.unitAttention = 0;\r
+               }\r
 \r
                // We've been selected!\r
                // Assert BSY - Selection success!\r