Improve IRQ handler responsiveness
[SCSI2SD-V6.git] / src / firmware / scsiPhy.c
index b7b55e027a5ab69640d9b0ba29ab308552628159..684887dcdfeb16435a066c5d3d3481a65159f38f 100755 (executable)
@@ -329,12 +329,15 @@ scsiRead(uint8_t* data, uint32_t count, int* parityError)
 \r
                scsiReadPIO(data + i, chunk, parityError);\r
 \r
-               __disable_irq();\r
                while (!scsiPhyComplete() && likely(!scsiDev.resetFlag))\r
                {\r
-                       __WFI();\r
+                   __disable_irq();\r
+            if (!scsiPhyComplete() && likely(!scsiDev.resetFlag))\r
+            {\r
+                       __WFI();\r
+            }\r
+                   __enable_irq();\r
                }\r
-               __enable_irq();\r
 \r
                i += chunk;\r
        }\r
@@ -479,12 +482,15 @@ scsiWrite(const uint8_t* data, uint32_t count)
 \r
                scsiWritePIO(data + i, chunk);\r
 \r
-               __disable_irq();\r
                while (!scsiPhyComplete() && likely(!scsiDev.resetFlag))\r
                {\r
-                       __WFI();\r
+                   __disable_irq();\r
+                   if (!scsiPhyComplete() && likely(!scsiDev.resetFlag))\r
+            {\r
+                       __WFI();\r
+            }\r
+                   __enable_irq();\r
                }\r
-               __enable_irq();\r
 \r
                i += chunk;\r
        }\r