Browse Source

Added pullup for scsi data and control

Per Mårtensson 3 years ago
parent
commit
12f6a52a48
3 changed files with 34 additions and 15 deletions
  1. 13 3
      sw/include/blacksasi.h
  2. 1 0
      sw/src/gpio.cpp
  3. 20 12
      sw/src/main.cpp

+ 13 - 3
sw/include/blacksasi.h

@@ -81,9 +81,19 @@
 
 
 // Termination controll
-#define TERMINATION_HIGH()  PBREG->BSRR = 0b0000000100000000 << 16 | 0b0000001000000000 ;
-#define TERMINATION_LOW()   PBREG->BSRR = 0b0000001000000000 << 16 | 0b0000000100000000 ;
-#define TERMINATION_OFF()   PBREG->BSRR = 0b0000001100000000 ;
+#define TERMINATION_HIGH()      PBREG->BSRR = 0b0000000100000000 << 16 | 0b0000001000000000;
+#define TERMINATION_LOW()       PBREG->BSRR = 0b0000001000000000 << 16 | 0b0000000100000000;
+#define TERMINATION_OFF()       PBREG->BSRR = 0b0000001100000000;
+
+// Enable SCSI buffers
+#define SCSI_OUTPUT_ENABLE()    PBREG->BSRR = 0b0001000000000000 << 16 ;
+#define SCSI_OUTPUT_DISABLE()   PBREG->BSRR = 0b0001000000000000;
+
+
+// SCSI Data Direction
+//BLACKSASI verify dir
+#define SCSI_OUTPUT_IN()        PCREG->BSRR = 0b0000000000000001 << 16 ;
+#define SCSI_OUTPUT_OUT()       PCREG->BSRR = 0b0000000000000001;
 
 // Virtual pin (Arduio compatibility is slow, so make it MCU-dependent)
 #define PA(BIT)       (BIT)

+ 1 - 0
sw/src/gpio.cpp

@@ -40,6 +40,7 @@ bool gpioInit(void){
     pinMode(BOARD_SCSI_IND, OUTPUT);
     pinMode(BOARD_SCSI_TAD, OUTPUT);
     pinMode(BOARD_TRANS_OE, OUTPUT);
+
     digitalWrite(BOARD_TRANS_OE, HIGH);
 }
   

+ 20 - 12
sw/src/main.cpp

@@ -72,12 +72,18 @@ SdFs SD;
 FsFile LOG_FILE;
 
 // Data pins
-//                                                    5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 
-static const uint32_t scsiDbOutputRegOr_PDREG    = 0b00000000000000000101010101010101;
-static const uint32_t scsiDbInputOutputAnd_PDREG = 0b00000000000000000000000000000000;
-//                                                    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;
+//                                                         5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 
+static const uint32_t scsiDbOutputRegOr_PDREG         = 0b00000000000000000101010101010101;
+static const uint32_t scsiDbInputOutputAnd_PDREG      = 0b00000000000000000000000000000000;
+static const uint32_t scsiDbInputOutputPullAnd_PDREG  = 0b00000000000000000101010101010101;
+// Control pins
+//                                                         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;
+
+
+
 
 
 
@@ -88,7 +94,7 @@ static const uint32_t scsiDbInputOutputAnd_PEREG = 0b000000000000000000111111111
 
 // Put DB and DP in input mode
 #define SCSI_DB_INPUT()  { PDREG->MODER = (PDREG->MODER & scsiDbInputOutputAnd_PDREG); PEREG->MODER = (PEREG->MODER & scsiDbInputOutputAnd_PEREG); SCSI_OUTPUT_IN();}
-
+#define SCSI_SET_PULL()  { PDREG->PUPDR |= scsiDbInputOutputPullAnd_PDREG; PEREG->PUPDR |= scsiDbInputOutputPullAnd_PEREG; }
 
 // BSY,REQ,MSG,CD,IO Turn off output, BSY is the last input
 #define SCSI_TARGET_INACTIVE() { SCSI_OUT(vREQ,inactive); SCSI_OUT(vMSG,inactive); SCSI_OUT(vCD,inactive); SCSI_OUT(vIO,inactive); SCSI_OUT(vBSY,inactive); pinMode(BOARD_SCSI_BSY, INPUT); }
@@ -300,8 +306,15 @@ bool hddimageOpen(HDDIMG *h,const char *image_name,int id,int lun,int blocksize)
  */
 void setup()
 {
+  //Setup GPIO
   gpioInit();
   
+  SCSI_OUTPUT_IN() ;
+
+  SCSI_SET_PULL();
+  
+  //Default turn termination off
+  TERMINATION_HIGH();
 #if DEBUG > 0
   Serial.begin(19200);
   delay(3000);
@@ -310,11 +323,6 @@ void setup()
 
 #endif
 
-
-
-  //Default turn termination off
-  TERMINATION_HIGH();
-
   //Turn Power LED ON
   LED2_ON();
   //Check if SD card is inserted