Per Mårtensson 2 gadi atpakaļ
vecāks
revīzija
cef9036835
3 mainītis faili ar 27 papildinājumiem un 21 dzēšanām
  1. 3 3
      sw/include/blacksasi.h
  2. 3 2
      sw/platformio.ini
  3. 21 16
      sw/src/main.cpp

+ 3 - 3
sw/include/blacksasi.h

@@ -237,13 +237,13 @@ static const uint32_t scsiDbInputOutputPullAnd_PDREG  = 0b0000000000000001010101
 // Control pins
 //                                                         5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 
 static const uint32_t scsiDbInputOutputPullAnd_PEREG  = 0b00000000000000000001010101010001;
-
+static const uint32_t scsiDbInputOutputPullAnd_PBREG  = 0b00010000000000000101000000000000;
 // Put DB and DP in output mode and control buffers
 #define SCSI_DB_OUTPUT() { PDREG->MODER = (PDREG->MODER & scsiDbInputOutputAnd_PDREG) | scsiDbOutputRegOr_PDREG;  SCSI_DATABUS_OUT() ;}
 
 // Put DB and DP in input mode and control buffers
 #define SCSI_DB_INPUT()  { PDREG->MODER = (PDREG->MODER & scsiDbInputOutputAnd_PDREG); SCSI_DATABUS_IN();}
-#define SCSI_SET_PULL()  { PDREG->PUPDR |= scsiDbInputOutputPullAnd_PDREG; PEREG->PUPDR |= scsiDbInputOutputPullAnd_PEREG; }
+#define SCSI_SET_PULL()  { PDREG->PUPDR |= scsiDbInputOutputPullAnd_PDREG; PEREG->PUPDR = PEREG->PUPDR | scsiDbInputOutputPullAnd_PEREG; PBREG->PUPDR = PBREG->PUPDR | scsiDbInputOutputPullAnd_PBREG; }
 
 // Transceiver control definitions
 #define TRANSCEIVER_IO_SET(VPIN,TRX_INPUT) { GPIOREG(VPIN)->BSRR = BITMASK(VPIN) << ((TRX_INPUT) ? 16 : 0); }
@@ -317,7 +317,7 @@ static uint32_t genBSRR(uint32_t data) {
 
   // BSRR set REQ if specified
   // Only set > 0 if it's in the same GPIO block as DB and DBP
-  if (reqPosition >= 0) {
+  if (reqPosition > 0) {
     output |= 0x01 << reqPosition;
   }
 

+ 3 - 2
sw/platformio.ini

@@ -11,6 +11,7 @@
 [env:blacksasi_f411]
 platform = ststm32
 board = blacksasi_f411m
+board_build.f_cpu = 960000000L
 ;board.variants_dir = /home/pm/project/stm32/BlackSASI/sw/variant/blacksasi_f411m
 
 board.variants_dir = C:\Users\martenssonp\projects\BlackSASI\sw\variant\blacksasi_f411m
@@ -18,7 +19,7 @@ framework = arduino
 board_build.core = maple
 lib_deps =
   greiman/SdFat@^2.2.0
-  ;bblanchon/ArduinoJson @ ^6.19.3
+  bblanchon/ArduinoJson @ ^6.19.3
 upload_protocol = stlink
 debug_tool = stlink
 ; Different gcc versions produce much different binaries in terms of speed.
@@ -31,7 +32,7 @@ debug_tool = stlink
 ; 1.90301.200702 ; default - 955kb/sec
 platform_packages = platformio/toolchain-gccarmnoneeabi@1.60301.0
 ;toolchain-gccarmnoneeabi@1.60301.0
-;toolchain-gccarmnoneeabi@1.90301.200702
+;platform_packages =platformio/toolchain-gccarmnoneeabi@1.90301.200702
 build_unflags = 
     -Os
     -DARDUINO_ARCH_STM32F4

+ 21 - 16
sw/src/main.cpp

@@ -43,7 +43,7 @@
 #include <setjmp.h>
 #include <libmaple/exti.h>
 
-#define DEBUG            1      // 0:No debug information output
+#define DEBUG            0      // 0:No debug information output
                                 // 1: Debug information output to USB Serial
                                 // 2: Debug information output to LOG.txt (slow)
 
@@ -86,6 +86,7 @@ SCSI_INQUIRY_DATA default_hdd, default_optical;
 // function table
 byte (*scsi_command_table[MAX_SCSI_COMMAND])(SCSI_DEVICE *dev, const byte *cdb);
 uint32_t db_bsrr[256];
+uint32_t test=0;
 // scsi command functions
 SCSI_COMMAND_HANDLER(onUnimplemented);
 SCSI_COMMAND_HANDLER(onNOP);
@@ -699,7 +700,7 @@ inline void writeHandshake(byte d)
   while(!SCSI_IN(vACK));
   // ACK.Fall to REQ.Raise delay 500ns(typ.) (DTC-510B)
   uint32_t bsrrCall = (db_bsrr[0xff] );
-  GPIOE->regs->BSRR = bsrrCall;  // DB=0xFF , SCSI_OUT(vREQ,inactive) //PM2022 should wirite data to bus
+  GPIOD->regs->BSRR = bsrrCall;  // DB=0xFF , SCSI_OUT(vREQ,inactive) //PM2022 should wirite data to bus
   SCSI_OUT(vREQ,inactive)
   // REQ.Raise to DB hold time 0ns
   SCSI_DB_INPUT() // (150ns)
@@ -925,12 +926,14 @@ void loop()
   // Precaution against bugs or jumps which don't clean up properly
   SCSI_DB_INPUT();
   TRANSCEIVER_IO_SET(vDTD,DB_INPUT)
-  SCSI_TARGET_INACTIVE();
   TRANSCEIVER_IO_SET(vIND,TR_INPUT)
+    SCSI_TARGET_INACTIVE();
+    SCSI_OUT(vACK,inactive);
+    SCSI_SET_PULL();
+  //pinMode(vBSY,INPUT_PULLUP);
   // Reset target state bits (BSY, MSG, CD, REQ, IO)
-
-  LED3_ON();
-
+  GPIOE->regs->BSRR = 0x00000074; // MSG, CD, REQ, IO
+  GPIOB->regs->BSRR = 0x00000040; // BSY
   //int msg = 0;
   m_msg = 0;
   m_lun = 0xff;
@@ -954,9 +957,9 @@ void loop()
   }
   // We've been selected
   SCSI_OUT(vATN,inactive);
-  SCSI_OUT(vACK,inactive);
+
   TRANSCEIVER_IO_SET(vTAD,TR_OUTPUT);
-  LOGN("SELECTED");
+
  
   SCSI_TARGET_ACTIVE()  // (BSY), REQ, MSG, CD, IO output turned on
 
@@ -1138,14 +1141,14 @@ void loop()
 Status:
   LOG(" STS:"); LOGHEX(m_sts);
 
-  //SCSI_PHASE_CHANGE(SCSI_PHASE_STATUS);
-  SCSI_OUT(vCD,inactive);
+  SCSI_PHASE_CHANGE(SCSI_PHASE_STATUS);
+  //SCSI_OUT(vCD,inactive);
   // Bus settle delay 400ns built in to writeHandshake
   writeHandshake(m_sts);
 
   LOG(" MI:"); LOGHEX(m_msg);
-  //SCSI_PHASE_CHANGE(SCSI_PHASE_MESSAGEIN);
-  SCSI_OUT(vMSG,active);
+  SCSI_PHASE_CHANGE(SCSI_PHASE_MESSAGEIN);
+  //SCSI_OUT(vMSG,active);
   // Bus settle delay 400ns built in to writeHandshake
   writeHandshake(m_msg);
 
@@ -1159,7 +1162,6 @@ BusFree:
   //SCSI_OUT(vBSY,inactive)
   SCSI_TARGET_INACTIVE() // Turn off BSY, REQ, MSG, CD, IO output
   TRANSCEIVER_IO_SET(vTAD,TR_INPUT);
-  TRANSCEIVER_IO_SET(vIND,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.
@@ -1168,6 +1170,7 @@ BusFree:
   asm("nop.w");
 }
 
+
 static byte onUnimplemented(SCSI_DEVICE *dev, const byte *cdb)
 {
   // does nothing!
@@ -1281,20 +1284,22 @@ static byte onRead10(SCSI_DEVICE *dev, const byte *cdb)
 {
   unsigned adds = ((uint32_t)cdb[2] << 24) | ((uint32_t)cdb[3] << 16) | ((uint32_t)cdb[4] << 8) | cdb[5];
   unsigned len = ((uint32_t)cdb[7] << 8) | cdb[8];
-  
+  /*
   LOG (" Read10 ");
   LOG("A:");
   LOGHEX(adds);
   LOG(":");
   LOGHEX(len);
   LOG(" ");
-  
+  */
+  LED3_ON();
   byte sts = checkBlockCommand(dev, adds, len);
   if (sts) {
     return sts;
   }
-  
+   LED3_OFF(); 
   writeDataPhaseSD(dev, adds, len);
+  LED3_OFF();
   return SCSI_STATUS_GOOD;
 }