Jelajahi Sumber

Fix bugs for uw2940

Per Mårtensson 2 tahun lalu
induk
melakukan
e2386bdde2
2 mengubah file dengan 11 tambahan dan 29 penghapusan
  1. 1 1
      sw/include/blacksasi.h
  2. 10 28
      sw/src/main.cpp

+ 1 - 1
sw/include/blacksasi.h

@@ -159,7 +159,7 @@ void finalizeFileLog(void);
 #define MAX_SCSIID  7          // Maximum number of supported SCSI-IDs (The minimum is 0)
 #define MAX_SCSILUN 8          // Maximum number of LUNs supported     (The minimum is 0)
 #define NUM_SCSIID  MAX_SCSIID // Number of enabled SCSI IDs
-#define NUM_SCSILUN 2          // Number of enabled LUNs
+#define NUM_SCSILUN 1          // Number of enabled LUNs
 #define READ_PARITY_CHECK 0    // Perform read parity check (unverified)
 #define DEFAULT_SCSI_ID 1
 #define DEFAULT_SCSI_LUN 0

+ 10 - 28
sw/src/main.cpp

@@ -670,9 +670,12 @@ inline byte readHandshake(void)
   
   SCSI_OUT(vREQ,active);
   while( ! SCSI_IN(vACK));
+  NOP(10);
+
   byte r = readIO();
   SCSI_OUT(vREQ,inactive)
   while( SCSI_IN(vACK));
+  NOP(10);
   return r;  
 }
 
@@ -751,6 +754,7 @@ void writeDataLoop(uint32_t blocksize, const byte* srcptr) {
     FETCH_BSRR_DB();
     WAIT_ACK_ACTIVE();
     REQ_OFF_DB_SET(bsrr_val);
+   NOP(10);
   }while(srcptr < endptr);
   WAIT_ACK_INACTIVE();
   // Finish the last bus cycle, byte is already on DB.
@@ -784,7 +788,6 @@ void writeDataPhase(int len, const byte* p)
 void writeDataPhaseSD(SCSI_DEVICE *dev, uint32_t adds, uint32_t len)
 {
   LOG (" DI(SD) ");
-
   SCSI_PHASE_CHANGE(SCSI_PHASE_DATAIN);
   //Bus settle delay 400ns, file.seek() measured at over 1000ns.
   uint64_t pos = (uint64_t)adds * dev->m_rawblocksize;
@@ -829,20 +832,9 @@ void readDataLoop(uint32_t blockSize, byte* dstptr)
   // Start of the do/while and WAIT are already aligned to 8 bytes.
   do {
     WAIT_ACK_ACTIVE();
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
+NOP(10);
+
+    
     uint32_t ret = PDREG->IDR;
     
     REQ_OFF();
@@ -856,19 +848,7 @@ void readDataLoop(uint32_t blockSize, byte* dstptr)
     asm("nop");
   } while(dstptr<endptr);
   WAIT_ACK_ACTIVE();
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
-    asm("nop");
+NOP(10);
   uint32_t ret = PDREG->IDR;
   REQ_OFF();
   *dstptr = (byte)~(((ret ) & 0b11111111) );
@@ -1061,6 +1041,8 @@ void loop()
       }
     }
   }
+
+
   LOG("CMD:");
 
   SCSI_PHASE_CHANGE(SCSI_PHASE_COMMAND);