From: Michael McMaster Date: Mon, 3 May 2021 04:25:56 +0000 (+1000) Subject: Few bug fixes to wait for SD card to be finished X-Git-Tag: v6.4.2~3 X-Git-Url: http://git.codesrc.com/gitweb.cgi?a=commitdiff_plain;h=ca667508cedd218752a36bd0341e03e31cb19803;p=SCSI2SD-V6.git Few bug fixes to wait for SD card to be finished --- diff --git a/src/firmware/config.c b/src/firmware/config.c index e75be816..5f25635a 100755 --- a/src/firmware/config.c +++ b/src/firmware/config.c @@ -36,7 +36,7 @@ #include -static const uint16_t FIRMWARE_VERSION = 0x0641; +static const uint16_t FIRMWARE_VERSION = 0x0642; // Optional static config extern uint8_t* __fixed_config; diff --git a/src/firmware/disk.c b/src/firmware/disk.c index 1f849eca..7c4c5bce 100755 --- a/src/firmware/disk.c +++ b/src/firmware/disk.c @@ -635,7 +635,8 @@ void scsiDiskPoll() (prep - i < buffers) && (prep < totalSDSectors) && ((totalSDSectors - prep) >= sdPerScsi) && - (likely(!useSlowDataCount) || scsiPhyComplete())) + (likely(!useSlowDataCount) || scsiPhyComplete()) && + (HAL_SD_GetState(&hsd) != HAL_SD_STATE_BUSY)) // rx complete but IRQ not fired yet. { // Start an SD transfer if we have space. uint32_t startBuffer = prep % buffers; @@ -714,6 +715,11 @@ void scsiDiskPoll() } __enable_irq(); + while (HAL_SD_GetState(&hsd) == HAL_SD_STATE_BUSY) + { + // Wait while keeping BSY. + } + if (scsiDev.phase == DATA_IN) { scsiDev.phase = STATUS; diff --git a/src/firmware/fpga.c b/src/firmware/fpga.c index 460d9088..752488b2 100755 --- a/src/firmware/fpga.c +++ b/src/firmware/fpga.c @@ -76,7 +76,7 @@ void s2s_fpgaInit() void s2s_fpgaReset() { HAL_GPIO_WritePin(FPGA_RST_GPIO_Port, FPGA_RST_Pin, GPIO_PIN_SET); - s2s_delay_clocks(4); + s2s_delay_clocks(12); HAL_GPIO_WritePin(FPGA_RST_GPIO_Port, FPGA_RST_Pin, GPIO_PIN_RESET); } diff --git a/src/firmware/scsiPhy.c b/src/firmware/scsiPhy.c index b90fd6c6..b7b55e02 100755 --- a/src/firmware/scsiPhy.c +++ b/src/firmware/scsiPhy.c @@ -94,6 +94,11 @@ scsiSetDataCount(uint32_t count) *SCSI_DATA_CNT_MID = (count >> 8) & 0xff; *SCSI_DATA_CNT_LO = count & 0xff; *SCSI_DATA_CNT_SET = 1; + +#ifdef STM32F4xx + __NOP(); + __NOP(); +#endif } int scsiFifoReady(void) @@ -106,6 +111,8 @@ int scsiFifoReady(void) __NOP(); #ifdef STM32F4xx __NOP(); + __NOP(); + __NOP(); #endif return HAL_GPIO_ReadPin(GPIOE, FPGA_GPIO3_Pin) != 0; }