|
@@ -1,6 +1,6 @@
|
|
|
/*
|
|
|
- * F4 BlueSCSI
|
|
|
- * Copyright (c) 2021 Eric Helgeson, Tech by Androda, LLC
|
|
|
+ * BlackSASI
|
|
|
+ * Copyright (c) 2022 Per Mårtensson
|
|
|
*
|
|
|
* This file is free software: you may copy, redistribute and/or modify it
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
@@ -13,10 +13,28 @@
|
|
|
* General Public License for more details.
|
|
|
*
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
- * along with this program. If not, see https://github.com/erichelgeson/bluescsi.
|
|
|
+ * along with this program. If not, see https://git.sweproj.com/ABC80/Blackhttps://git.sweproj.com/SASI/
|
|
|
*
|
|
|
- * This file incorporates work covered by the following copyright and
|
|
|
- * permission notice:
|
|
|
+ * This file incorporates work covered by the following copyright and
|
|
|
+ * permission notice:
|
|
|
+ * F4 BlueSCSI
|
|
|
+ * Copyright (c) 2021 Eric Helgeson, Tech by Androda, LLC
|
|
|
+ *
|
|
|
+ * This file is free software: you may copy, redistribute and/or modify it
|
|
|
+ * under the terms of the GNU General Public License as published by the
|
|
|
+ * Free Software Foundation, either version 2 of the License, or (at your
|
|
|
+ * option) any later version.
|
|
|
+ *
|
|
|
+ * This file is distributed in the hope that it will be useful, but
|
|
|
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
+ * General Public License for more details.
|
|
|
+ *
|
|
|
+ * You should have received a copy of the GNU General Public License
|
|
|
+ * along with this program. If not, see https://github.com/erichelgeson/bluescsi.
|
|
|
+ *
|
|
|
+ * This file incorporates work covered by the following copyright and
|
|
|
+ * permission notice:
|
|
|
*
|
|
|
* Copyright (c) 2019 komatsu
|
|
|
*
|
|
@@ -41,122 +59,16 @@
|
|
|
#include <SPI.h>
|
|
|
#include <SdFat.h>
|
|
|
#include "sdios.h"
|
|
|
-#define SPI_CLOCK SD_SCK_MHZ(50)
|
|
|
+#include "blacksasi.h"
|
|
|
#ifdef USE_STM32_DMA
|
|
|
#warning "warning USE_STM32_DMA"
|
|
|
#endif
|
|
|
-#define DEBUG 1 // 0:No debug information output
|
|
|
- // 1: Debug information output to USB Serial
|
|
|
- // 2: Debug information output to LOG.txt (slow)
|
|
|
-
|
|
|
-#define SCSI_SELECT 0 // 0 for STANDARD
|
|
|
- // 1 for SHARP X1turbo
|
|
|
- // 2 for NEC PC98
|
|
|
-#define READ_SPEED_OPTIMIZE 1 // Faster reads
|
|
|
-#define WRITE_SPEED_OPTIMIZE 1 // Speeding up writes
|
|
|
-#define USE_DB2ID_TABLE 1 // Use table to get ID from SEL-DB
|
|
|
|
|
|
-// SCSI config
|
|
|
-#define NUM_SCSIID 7 // Maximum number of supported SCSI-IDs (The minimum is 0)
|
|
|
-#define NUM_SCSILUN 2 // Maximum number of LUNs supported (The minimum is 0)
|
|
|
-#define READ_PARITY_CHECK 0 // Perform read parity check (unverified)
|
|
|
-
|
|
|
-// HDD format
|
|
|
-#define MAX_BLOCKSIZE 2048 // Maximum BLOCK size
|
|
|
|
|
|
// SDFAT
|
|
|
SdFs SD;
|
|
|
|
|
|
-#if DEBUG == 1
|
|
|
-#define serial Serial
|
|
|
-#define LOG(XX) serial.print(XX)
|
|
|
-#define LOGHEX(XX) serial.print(XX, HEX)
|
|
|
-#define LOGDEC(XX) serial.print(XX, DEC)
|
|
|
-#define LOGBIN(XX) serial.print(XX, BIN)
|
|
|
-#define LOGN(XX) serial.println(XX)
|
|
|
-#define LOGHEXN(XX) serial.println(XX, HEX)
|
|
|
-#define LOGDECN(XX) serial.println(XX, DEC)
|
|
|
-#define LOGBIN_N(XX) serial.println(XX, BIN)
|
|
|
-#elif DEBUG == 2
|
|
|
-#define LOG(XX) LOG_FILE.print(XX); LOG_FILE.sync();
|
|
|
-#define LOGHEX(XX) LOG_FILE.print(XX, HEX); LOG_FILE.sync();
|
|
|
-#define LOGDEC(XX) LOG_FILE.print(XX, DEC); LOG_FILE.sync();
|
|
|
-#define LOGBIN(XX) LOG_FILE.print(XX, BIN); LOG_FILE.sync();
|
|
|
-#define LOGN(XX) LOG_FILE.println(XX); LOG_FILE.sync();
|
|
|
-#define LOGHEXN(XX) LOG_FILE.println(XX, HEX); LOG_FILE.sync();
|
|
|
-#define LOGDECN(XX) LOG_FILE.println(XX, DEC); LOG_FILE.sync();
|
|
|
-#define LOGBIN_N(XX) LOG_FILE.println(XX, BIN); LOG_FILE.sync();
|
|
|
-#else
|
|
|
-#define LOG(XX) //serial.print(XX)
|
|
|
-#define LOGHEX(XX) //serial.print(XX, HEX)
|
|
|
-#define LOGDEC(XX) //serial.print(XX, DEC)
|
|
|
-#define LOGBIN(XX) //serial.print(XX, BIN)
|
|
|
-#define LOGN(XX) //serial.println(XX)
|
|
|
-#define LOGHEXN(XX) //serial.println(XX, HEX)
|
|
|
-#define LOGDECN(XX) //serial.println(XX, DEC)
|
|
|
-#define LOGBIN_N(XX) //serial.println(XX, BIN)
|
|
|
-#endif
|
|
|
|
|
|
-#define active 1
|
|
|
-#define inactive 0
|
|
|
-#define high 0
|
|
|
-#define low 1
|
|
|
-
|
|
|
-#define isHigh(XX) ((XX) == high)
|
|
|
-#define isLow(XX) ((XX) != high)
|
|
|
-
|
|
|
-
|
|
|
-// GPIO register port
|
|
|
-#define PAREG GPIOA->regs
|
|
|
-#define PBREG GPIOB->regs
|
|
|
-#define PCREG GPIOC->regs
|
|
|
-#define PDREG GPIOD->regs
|
|
|
-#define PEREG GPIOE->regs
|
|
|
-
|
|
|
-// LED control
|
|
|
-#define LED1_ON() PAREG->BSRR = 0b0000000000010000;
|
|
|
-#define LED1_OFF() PAREG->BSRR = 0b0000000000010000 << 16;
|
|
|
-#define LED2_ON() PAREG->BSRR = 0b0000000000100000;
|
|
|
-#define LED2_OFF() PAREG->BSRR = 0b0000000000100000 << 16;
|
|
|
-#define LED3_ON() PAREG->BSRR = 0b0000000001000000;
|
|
|
-#define LED3_OFF() PAREG->BSRR = 0b0000000001000000 << 16;
|
|
|
-#define LED_EXT_ON() PAREG->BSRR = 0b0000000000000001;
|
|
|
-#define LED_EXT_OFF() PAREG->BSRR = 0b0000000000000001 << 16;
|
|
|
-
|
|
|
-// Termination controll
|
|
|
-#define TERMINATION_HIGH() PBREG->BSRR = 0b0000000100000000 << 16 | 0b0000001000000000 ;
|
|
|
-#define TERMINATION_LOW() PBREG->BSRR = 0b0000001000000000 << 16 | 0b0000000100000000 ;
|
|
|
-#define TERMINATION_OFF() PBREG->BSRR = 0b0000001100000000 ;
|
|
|
-
|
|
|
-// Virtual pin (Arduio compatibility is slow, so make it MCU-dependent)
|
|
|
-#define PA(BIT) (BIT)
|
|
|
-#define PB(BIT) (BIT + 16)
|
|
|
-#define PC(BIT) (BIT + 32)
|
|
|
-#define PD(BIT) (BIT + 48)
|
|
|
-#define PE(BIT) (BIT + 64)
|
|
|
-// Virtual pin decoding
|
|
|
-#define GPIOREG(VPIN) ((VPIN) >= 16 ? PBREG : PAREG)
|
|
|
-#define BITMASK(VPIN) (1 << ((VPIN) & 15))
|
|
|
-
|
|
|
-#define vATN PB(14) // SCSI:ATN
|
|
|
-#define vBSY PB(6) // SCSI:BSY
|
|
|
-#define vACK PB(7) // SCSI:ACK
|
|
|
-#define vRST PA(15) // SCSI:RST
|
|
|
-#define vMSG PE(2) // SCSI:MSG
|
|
|
-#define vSEL PE(3) // SCSI:SEL
|
|
|
-#define vCD PE(4) // SCSI:C/D
|
|
|
-#define vREQ PE(5) // SCSI:REQ
|
|
|
-#define vIO PE(6) // SCSI:I/O
|
|
|
-#define vSD_CS PB(1) // SDCARD:CS
|
|
|
-#define vDTD PC(0) // SCSI:DTD
|
|
|
-#define vIND PC(1) // SCSI:IND
|
|
|
-#define vTAD PC(2) // SCSI:TAD
|
|
|
-
|
|
|
-// SCSI output pin control: opendrain active LOW (direct pin drive)
|
|
|
-#define SCSI_OUT(VPIN,ACTIVE) { GPIOREG(VPIN)->BSRR = BITMASK(VPIN) << ((ACTIVE) ? 16 : 0); }
|
|
|
-
|
|
|
-// SCSI input pin check (inactive=0,active=1)
|
|
|
-#define SCSI_IN(VPIN) ((~GPIOREG(VPIN)->IDR >> (VPIN & 15)) & 1)
|
|
|
|
|
|
static const uint32_t scsiDbOutputRegOr = 0x55150011;
|
|
|
static const uint32_t scsiDbInputOutputAnd = 0x00C0FFCC;
|
|
@@ -290,9 +202,7 @@ static const byte db2scsiid[256]={
|
|
|
};
|
|
|
#endif
|
|
|
|
|
|
-// Log File
|
|
|
-#define VERSION "1.0-SNAPSHOT-2022-03-20-F4"
|
|
|
-#define LOG_FILENAME "LOG.txt"
|
|
|
+
|
|
|
FsFile LOG_FILE;
|
|
|
|
|
|
// SCSI Drive Vendor information
|