|
@@ -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:
|
|
|
+ * along with this program. If not, see https:
|
|
|
*
|
|
|
- * 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:
|
|
|
+ *
|
|
|
+ * 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
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-#define SCSI_SELECT 0
|
|
|
-
|
|
|
-
|
|
|
-#define READ_SPEED_OPTIMIZE 1
|
|
|
-#define WRITE_SPEED_OPTIMIZE 1
|
|
|
-#define USE_DB2ID_TABLE 1
|
|
|
|
|
|
-
|
|
|
-#define NUM_SCSIID 7
|
|
|
-#define NUM_SCSILUN 2
|
|
|
-#define READ_PARITY_CHECK 0
|
|
|
-
|
|
|
-
|
|
|
-#define MAX_BLOCKSIZE 2048
|
|
|
|
|
|
|
|
|
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)
|
|
|
-#define LOGHEX(XX)
|
|
|
-#define LOGDEC(XX)
|
|
|
-#define LOGBIN(XX)
|
|
|
-#define LOGN(XX)
|
|
|
-#define LOGHEXN(XX)
|
|
|
-#define LOGDECN(XX)
|
|
|
-#define LOGBIN_N(XX)
|
|
|
-#endif
|
|
|
|
|
|
-#define active 1
|
|
|
-#define inactive 0
|
|
|
-#define high 0
|
|
|
-#define low 1
|
|
|
-
|
|
|
-#define isHigh(XX) ((XX) == high)
|
|
|
-#define isLow(XX) ((XX) != high)
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-#define PAREG GPIOA->regs
|
|
|
-#define PBREG GPIOB->regs
|
|
|
-#define PCREG GPIOC->regs
|
|
|
-#define PDREG GPIOD->regs
|
|
|
-#define PEREG GPIOE->regs
|
|
|
-
|
|
|
-
|
|
|
-#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;
|
|
|
-
|
|
|
-
|
|
|
-#define TERMINATION_HIGH() PBREG->BSRR = 0b0000000100000000 << 16 | 0b0000001000000000 ;
|
|
|
-#define TERMINATION_LOW() PBREG->BSRR = 0b0000001000000000 << 16 | 0b0000000100000000 ;
|
|
|
-#define TERMINATION_OFF() PBREG->BSRR = 0b0000001100000000 ;
|
|
|
-
|
|
|
-
|
|
|
-#define PA(BIT) (BIT)
|
|
|
-#define PB(BIT) (BIT + 16)
|
|
|
-#define PC(BIT) (BIT + 32)
|
|
|
-#define PD(BIT) (BIT + 48)
|
|
|
-#define PE(BIT) (BIT + 64)
|
|
|
-
|
|
|
-#define GPIOREG(VPIN) ((VPIN) >= 16 ? PBREG : PAREG)
|
|
|
-#define BITMASK(VPIN) (1 << ((VPIN) & 15))
|
|
|
-
|
|
|
-#define vATN PB(14)
|
|
|
-#define vBSY PB(6)
|
|
|
-#define vACK PB(7)
|
|
|
-#define vRST PA(15)
|
|
|
-#define vMSG PE(2)
|
|
|
-#define vSEL PE(3)
|
|
|
-#define vCD PE(4)
|
|
|
-#define vREQ PE(5)
|
|
|
-#define vIO PE(6)
|
|
|
-#define vSD_CS PB(1)
|
|
|
-#define vDTD PC(0)
|
|
|
-#define vIND PC(1)
|
|
|
-#define vTAD PC(2)
|
|
|
-
|
|
|
-
|
|
|
-#define SCSI_OUT(VPIN,ACTIVE) { GPIOREG(VPIN)->BSRR = BITMASK(VPIN) << ((ACTIVE) ? 16 : 0); }
|
|
|
-
|
|
|
-
|
|
|
-#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
|
|
|
|
|
|
-
|
|
|
-#define VERSION "1.0-SNAPSHOT-2022-03-20-F4"
|
|
|
-#define LOG_FILENAME "LOG.txt"
|
|
|
+
|
|
|
FsFile LOG_FILE;
|
|
|
|
|
|
|