Fix bug in using nor flash storage without SD
This commit is contained in:
parent
b6bac91911
commit
026583b1fd
|
@ -67,7 +67,7 @@ static int usbReady;
|
||||||
static void initBoardConfig(S2S_BoardConfig* config) {
|
static void initBoardConfig(S2S_BoardConfig* config) {
|
||||||
memcpy(
|
memcpy(
|
||||||
config,
|
config,
|
||||||
(
|
(const void*)(
|
||||||
CY_FLASH_BASE +
|
CY_FLASH_BASE +
|
||||||
(CY_FLASH_SIZEOF_ARRAY * (size_t) SCSI_CONFIG_ARRAY) +
|
(CY_FLASH_SIZEOF_ARRAY * (size_t) SCSI_CONFIG_ARRAY) +
|
||||||
(CY_FLASH_SIZEOF_ROW * SCSI_CONFIG_BOARD_ROW)
|
(CY_FLASH_SIZEOF_ROW * SCSI_CONFIG_BOARD_ROW)
|
||||||
|
@ -472,7 +472,7 @@ void debugPoll()
|
||||||
dbgHidBuffer[61] = sdCard.capacity;
|
dbgHidBuffer[61] = sdCard.capacity;
|
||||||
|
|
||||||
dbgHidBuffer[62] = FIRMWARE_VERSION >> 8;
|
dbgHidBuffer[62] = FIRMWARE_VERSION >> 8;
|
||||||
dbgHidBuffer[63] = FIRMWARE_VERSION;
|
dbgHidBuffer[63] = FIRMWARE_VERSION & 0xFF;
|
||||||
|
|
||||||
USBFS_LoadInEP(USB_EP_DEBUG, (uint8 *)&dbgHidBuffer, sizeof(dbgHidBuffer));
|
USBFS_LoadInEP(USB_EP_DEBUG, (uint8 *)&dbgHidBuffer, sizeof(dbgHidBuffer));
|
||||||
usbDebugEpState = USB_DATA_SENT;
|
usbDebugEpState = USB_DATA_SENT;
|
||||||
|
|
|
@ -576,8 +576,14 @@ void scsiDiskPoll()
|
||||||
// Wait for the next DMA interrupt. It's beneficial to halt the
|
// Wait for the next DMA interrupt. It's beneficial to halt the
|
||||||
// processor to give the DMA controller more memory bandwidth to
|
// processor to give the DMA controller more memory bandwidth to
|
||||||
// work with.
|
// work with.
|
||||||
int scsiBusy = 1;
|
int scsiBusy;
|
||||||
int sdBusy = 1;
|
int sdBusy;
|
||||||
|
{
|
||||||
|
uint8_t intr = CyEnterCriticalSection();
|
||||||
|
scsiBusy = scsiDMABusy();
|
||||||
|
sdBusy = isSDDevice && sdDMABusy();
|
||||||
|
CyExitCriticalSection(intr);
|
||||||
|
}
|
||||||
while (scsiBusy && sdBusy && isSDDevice)
|
while (scsiBusy && sdBusy && isSDDevice)
|
||||||
{
|
{
|
||||||
uint8_t intr = CyEnterCriticalSection();
|
uint8_t intr = CyEnterCriticalSection();
|
||||||
|
|
|
@ -47,7 +47,7 @@ static void spiFlash_erase(S2S_Device* dev, uint32_t sectorNumber, uint32_t coun
|
||||||
static void spiFlash_read(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
static void spiFlash_read(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
||||||
static void spiFlash_readAsync(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
static void spiFlash_readAsync(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
||||||
static int spiFlash_readAsyncPoll(S2S_Device* dev);
|
static int spiFlash_readAsyncPoll(S2S_Device* dev);
|
||||||
static void spiFlash_write(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
static void spiFlash_write(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, const uint8_t* buffer);
|
||||||
|
|
||||||
SpiFlash spiFlash = {
|
SpiFlash spiFlash = {
|
||||||
{
|
{
|
||||||
|
@ -298,7 +298,7 @@ static void spiFlash_erase(S2S_Device* dev, uint32_t sectorNumber, uint32_t coun
|
||||||
nNOR_CS_Write(1); // Deselect
|
nNOR_CS_Write(1); // Deselect
|
||||||
}
|
}
|
||||||
|
|
||||||
static void spiFlash_write(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer)
|
static void spiFlash_write(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, const uint8_t* buffer)
|
||||||
{
|
{
|
||||||
// SpiFlash* spiFlash = (SpiFlash*)dev;
|
// SpiFlash* spiFlash = (SpiFlash*)dev;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
|
|
||||||
const char* Notice = "Copyright (C) 2015-2018 Michael McMaster <michael@codesrc.com>";
|
const char* Notice = "Copyright (C) 2015-2021 Michael McMaster <michael@codesrc.com>";
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|
|
@ -309,11 +309,11 @@ doTxSingleDMA(const uint8* data, uint32 count)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
scsiWriteDMA(const uint8* data, uint32 count)
|
scsiWriteDMA(const uint8_t* data, uint32 count)
|
||||||
{
|
{
|
||||||
dmaSentCount = 0;
|
dmaSentCount = 0;
|
||||||
dmaTotalCount = count;
|
dmaTotalCount = count;
|
||||||
dmaBuffer = data;
|
dmaBuffer = (uint8_t*) data;
|
||||||
|
|
||||||
uint32_t singleCount = (count > MAX_DMA_BYTES) ? MAX_DMA_BYTES : count;
|
uint32_t singleCount = (count > MAX_DMA_BYTES) ? MAX_DMA_BYTES : count;
|
||||||
doTxSingleDMA(data, singleCount);
|
doTxSingleDMA(data, singleCount);
|
||||||
|
|
|
@ -38,7 +38,7 @@ static void sd_erase(S2S_Device* dev, uint32_t sectorNumber, uint32_t count);
|
||||||
static void sd_read(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
static void sd_read(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
||||||
static void sd_readAsync(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
static void sd_readAsync(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
||||||
static int sd_readAsyncPoll(S2S_Device* dev);
|
static int sd_readAsyncPoll(S2S_Device* dev);
|
||||||
static void sd_write(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
static void sd_write(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, const uint8_t* buffer);
|
||||||
|
|
||||||
|
|
||||||
// Global
|
// Global
|
||||||
|
@ -1139,7 +1139,7 @@ static int sd_readAsyncPoll(S2S_Device* dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void sd_write(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer)
|
static void sd_write(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, const uint8_t* buffer)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ struct S2S_DeviceStruct
|
||||||
void (*read)(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
void (*read)(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
||||||
void (*readAsync)(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
void (*readAsync)(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
||||||
int (*readAsyncPoll)(S2S_Device* dev);
|
int (*readAsyncPoll)(S2S_Device* dev);
|
||||||
void (*write)(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, uint8_t* buffer);
|
void (*write)(S2S_Device* dev, uint32_t sectorNumber, uint32_t count, const uint8_t* buffer);
|
||||||
|
|
||||||
MEDIA_STATE mediaState;
|
MEDIA_STATE mediaState;
|
||||||
CONFIG_STOREDEVICE deviceType;
|
CONFIG_STOREDEVICE deviceType;
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue