Per Mårtensson 2 years ago
parent
commit
142a7cbab2
2 changed files with 14 additions and 4 deletions
  1. 3 3
      sw/include/blacksasi.h
  2. 11 1
      sw/src/main.cpp

+ 3 - 3
sw/include/blacksasi.h

@@ -262,7 +262,7 @@ static const uint32_t scsiDbInputOutputPullAnd_PDREG  = 0b0000000000000000010101
 //                                                         5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 
 static const uint32_t scsiDbOutputRegOr_PEREG         = 0b00000000000000000000000000000001;
 static const uint32_t scsiDbInputOutputAnd_PEREG      = 0b00000000000000000011111111110000;
-static const uint32_t scsiDbInputOutputPullAnd_PEREG  = 0b00000000000000000101010101010001;
+static const uint32_t scsiDbInputOutputPullAnd_PEREG  = 0b00000000000000000001010101010001;
 
 // Put DB and DP in output mode and control buffers
 #define SCSI_DB_OUTPUT() { PDREG->MODER = (PDREG->MODER & scsiDbInputOutputAnd_PDREG) | scsiDbOutputRegOr_PDREG; PEREG->MODER = (PEREG->MODER & scsiDbInputOutputAnd_PEREG) | scsiDbOutputRegOr_PEREG; SCSI_DATABUS_OUT() ;}
@@ -291,8 +291,8 @@ static const uint32_t scsiDbInputOutputAnd = 0x00C0FFCC;
 #define vTR_DBP          PC(0) // Data Pins Transceiver Control Pin
 #define vTR_INITIATOR    PC(1) // Initiator Transciever Control Pin
 
-#define TR_INPUT 1
-#define TR_OUTPUT 0
+#define TR_INPUT 0
+#define TR_OUTPUT 1
 
 // Transceiver control definitions
 #define TRANSCEIVER_IO_SET(VPIN,TR_INPUT) { GPIOREG(VPIN)->BSRR = BITMASK(VPIN) << ((TR_INPUT) ? 16 : 0); }

+ 11 - 1
sw/src/main.cpp

@@ -299,6 +299,7 @@ void setup()
     db_bsrr[i] = genBSRR(i);
   }
   gpioInit();
+  digitalWrite( BOARD_TRANS_OE ,0);
   // Default all SCSI command handlers to onUnimplemented
   for(unsigned i = 0; i < MAX_SCSI_COMMAND; i++)
   {
@@ -389,6 +390,7 @@ void setup()
   pinMode(TR_DBP, OUTPUT);
   
   TRANSCEIVER_IO_SET(vTR_INITIATOR,TR_INPUT);
+  TRANSCEIVER_IO_SET(vTR_TARGET,TR_INPUT);
 #else
   // set up OTYPER for open drain on SCSI pins of PA and PB
   // PA 0-7, 11-14
@@ -1052,6 +1054,8 @@ void loop()
   TRANSCEIVER_IO_SET(vTR_DBP,TR_INPUT)
   SCSI_TARGET_INACTIVE();
   TRANSCEIVER_IO_SET(vTR_TARGET,TR_INPUT)
+
+
   // Reset target state bits (BSY, MSG, CD, REQ, IO)
   GPIOB->regs->BSRR = 0x000000E8; // MSG, CD, REQ, IO
   GPIOA->regs->BSRR = 0x00000200; // BSY
@@ -1064,7 +1068,11 @@ void loop()
   m_lun = 0xff;
   SCSI_DEVICE *dev = (SCSI_DEVICE *)0; // HDD image for current SCSI-ID, LUN
   serial.println("test");
-  do {} while( SCSI_IN(vBSY) || !SCSI_IN(vSEL) || SCSI_IN(vRST));
+  do {
+    serial.print(SCSI_IN(vBSY));
+    serial.print(SCSI_IN(vSEL));
+    serial.println(SCSI_IN(vRST));
+  } while( SCSI_IN(vBSY) || !SCSI_IN(vSEL) || SCSI_IN(vRST));
   //do {} while( !SCSI_IN(vBSY) || SCSI_IN(vRST));
   // We're in ARBITRATION
   //LOG(" A:"); LOGHEX(readIO()); LOG(" ");
@@ -1082,6 +1090,7 @@ void loop()
 
 #if XCVR == 1
   TRANSCEIVER_IO_SET(vTR_TARGET,TR_OUTPUT);
+  TRANSCEIVER_IO_SET(vTR_INITIATOR,TR_OUTPUT);
 #endif
   SCSI_TARGET_ACTIVE()  // (BSY), REQ, MSG, CD, IO output turned on
 
@@ -1280,6 +1289,7 @@ BusFree:
   SCSI_TARGET_INACTIVE() // Turn off BSY, REQ, MSG, CD, IO output
 #if XCVR == 1
   TRANSCEIVER_IO_SET(vTR_TARGET,TR_INPUT);
+  TRANSCEIVER_IO_SET(vTR_INITIATOR,TR_INPUT);
   // Something in code linked after this function is performing better with a +4 alignment.
   // Adding this nop is causing the next function (_GLOBAL__sub_I_SD) to have an address with a last digit of 0x4.
   // Last digit of 0xc also works.