Przeglądaj źródła

Some more gpio fixes

Per Mårtensson 3 lat temu
rodzic
commit
cbde0ac493
2 zmienionych plików z 9 dodań i 38 usunięć
  1. 9 7
      sw/include/blacksasi.h
  2. 0 31
      sw/src/main.cpp

+ 9 - 7
sw/include/blacksasi.h

@@ -70,7 +70,6 @@
 #define isHigh(XX) ((XX) == high)
 #define isLow(XX) ((XX) != high)
 
-
 // GPIO register port
 #define PAREG GPIOA->regs
 #define PBREG GPIOB->regs
@@ -78,22 +77,22 @@
 #define PDREG GPIOD->regs
 #define PEREG GPIOE->regs
 
-
-
-// Termination controll
+// Termination control (LOW is active)
+//                                                12   8   4   0             12   8   4   0
 #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
+//                                                12   8   4   0
 #define SCSI_OUTPUT_ENABLE()    PBREG->BSRR = 0b0001000000000000 << 16 ;
 #define SCSI_OUTPUT_DISABLE()   PBREG->BSRR = 0b0001000000000000;
 
 
 // SCSI Data Direction
-//BLACKSASI verify dir
-#define SCSI_BUFFERS_IN()        PCREG->BSRR = 0b0000000000000001 << 16 ;
-#define SCSI_BUFFERS_OUT()       PCREG->BSRR = 0b0000000000000001;
+//                                                12   8   4   0
+#define SCSI_BUFFERS_IN()       PCREG->BSRR = 0b0000000000000001 << 16 ;
+#define SCSI_BUFFERS_OUT()      PCREG->BSRR = 0b0000000000000001;
 
 // Virtual pin (Arduio compatibility is slow, so make it MCU-dependent)
 #define PA(BIT)       (BIT)
@@ -104,6 +103,7 @@
 
 // Virtual pin decoding
 #define GPIOREG(VPIN)     ((VPIN) >= 16 ? ((VPIN) >= 32 ? ((VPIN) >= 48 ? ((VPIN) >= 48 ? PEREG : PDREG) : PCREG) : PBREG) : PAREG)
+//BLACKSASI need to be fixed
 #define BITMASK(VPIN)     (1 << ((VPIN) & 15))
 
 #define vATN       PB(14)     // SCSI:ATN
@@ -121,9 +121,11 @@
 #define vTAD       PC(2)      // SCSI:TAD
 #define vTRANS_OE  PB(12)     // SCSI:TRANS_OE
 // SCSI output pin control: opendrain active LOW (direct pin drive)
+//BLACKSASI need to be fixed
 #define SCSI_OUT(VPIN,ACTIVE) { GPIOREG(VPIN)->BSRR = BITMASK(VPIN) << ((ACTIVE) ? 16 : 0); }
 
 // SCSI input pin check (inactive=0,active=1)
+//BLACKSASI need to be fixed
 #define SCSI_IN(VPIN) ((~GPIOREG(VPIN)->IDR >> (VPIN & 15)) & 1)
 
 // HDDiamge file

+ 0 - 31
sw/src/main.cpp

@@ -121,7 +121,6 @@ byte          m_msb[256];             // Command storage bytes
 /**
  * BSRR register generator
  * Totally configurable for which pin is each data bit, which pin is PTY, and which pin is REQ.
- * The only requirement is that data and parity pins are in the same GPIO block.
  * REQ can be specified as -1 to ignore, as it doens't have to be in the same GPIO block.
  * This is dramatically slower than the original static array, but is easier to configure
  */
@@ -228,7 +227,6 @@ byte SCSI_INFO_BUF[SCSI_INFO_BUF_SIZE] = {
 inline byte readIO(void)
 {
   // Port input data register
-  // FIXED FOR BLACKSASI
   uint32_t ret = GPIOD->regs->IDR;
   byte bret = (byte)(~(ret)); 
 
@@ -248,7 +246,6 @@ inline byte readIO(void)
  */
 inline byte readHandshake(void)
 {
-  // FIXED FOR BLACKSASI
   SCSI_OUT(vREQ,active)
   //SCSI_DB_INPUT()
   while( ! SCSI_IN(vACK)) { if(m_isBusReset) return 0; }
@@ -328,34 +325,6 @@ void setup()
   //Check which image to load
   switchImage();
 
-/*
-Should not be used due to buffers
-  // set up OTYPER for open drain on SCSI pins of PA and PB
-  // PA 0-7, 11-14
-  uint32_t oTypeA_And = 0x000078FF;
-  // PA 8, 9, 10, 15
-  uint32_t oTypeA_Or = 0x00008700;
-  GPIOA->regs->OTYPER = (GPIOA->regs->OTYPER & oTypeA_And) | oTypeA_Or;
-
-  // PB 1, 11 are not used
-  uint32_t oTypeB_And = 0x00000000;
-  // PB 0, 2-10, 12-15 are used for SCSI, set open drain
-  uint32_t oTypeB_Or = 0x0000F7FD;
-  GPIOB->regs->OTYPER = (GPIOB->regs->OTYPER & oTypeB_And) | oTypeB_Or;
-
-
-  // PD 8-15 are not used
-  uint32_t oTypeD_And = 0b00000000000000001111111100000000;
-  // PD 0-7 are used for SCSI, set open drain
-  uint32_t oTypeD_Or  = 0b00000000000000000000000011111111;
-  GPIOD->regs->OTYPER = (GPIOD->regs->OTYPER & oTypeD_And) | oTypeD_Or;
-
-  // PE 1, 7-15 are not used
-  uint32_t oTypeE_And = 0b00000000000000001111111110000010;
-  // PE 0,2-6 are used for SCSI, set open drain
-  uint32_t oTypeE_Or  = 0b00000000000000000000000001111101;
-  GPIOD->regs->OTYPER = (GPIOE->regs->OTYPER & oTypeE_And) | oTypeE_Or;
-*/
   // Turn off the output port
   SCSI_TARGET_INACTIVE()