-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: file:///Users/ces/dev/mist-subversion/trunk@721 8578a998-a533-420b-88ed-89baca3f5bf4
- Loading branch information
1 parent
da367dd
commit 3fe4aa8
Showing
20 changed files
with
3,449 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,31 @@ | ||
PROJECT=sd_card | ||
NOWARN = # --report-unoptflat # -Wno-UNOPTFLAT | ||
XTRA_OBJS = mmc2.o utils.o diskio_mmc.o pff.o pff_file.o | ||
ODIR = obj_dir | ||
XTRA_OBJS_PATH=$(addprefix $(ODIR)/, $(XTRA_OBJS)) | ||
|
||
all: $(PROJECT).vcd | ||
|
||
$(ODIR)/%.o: %.c $(DEPS) | ||
$(CC) -c -o $@ $< $(CFLAGS) | ||
|
||
$(ODIR)/stamp: $(PROJECT).v $(PROJECT)_tb.cpp | ||
verilator $(NOWARN) --cc --trace --exe $(PROJECT).v $(PROJECT)_tb.cpp $(XTRA_OBJS) | ||
touch $(ODIR)/stamp | ||
|
||
$(ODIR)/V$(PROJECT): $(ODIR)/stamp $(XTRA_OBJS_PATH) | ||
make -j -C $(ODIR)/ -f V$(PROJECT).mk V$(PROJECT) | ||
|
||
$(PROJECT).vcd: $(ODIR)/V$(PROJECT) | ||
$(ODIR)/V$(PROJECT) | ||
|
||
run: $(ODIR)/V$(PROJECT) | ||
$(ODIR)/V$(PROJECT) | ||
|
||
clean: | ||
rm -rf $(ODIR) | ||
rm -f $(PROJECT).vcd | ||
rm -f *~ | ||
|
||
view: $(PROJECT).vcd | ||
gtkwave $< $(PROJECT).sav & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,42 @@ | ||
/*----------------------------------------------------------------------- | ||
/ PFF - Low level disk interface modlue include file (C)ChaN, 2009 | ||
/-----------------------------------------------------------------------*/ | ||
|
||
#ifndef _DISKIO | ||
|
||
#include "integer.h" | ||
|
||
|
||
/* Status of Disk Functions */ | ||
typedef BYTE DSTATUS; | ||
|
||
|
||
/* Results of Disk Functions */ | ||
typedef enum { | ||
RES_OK = 0, /* 0: Function succeeded */ | ||
RES_ERROR, /* 1: Disk error */ | ||
RES_NOTRDY, /* 2: Not ready */ | ||
RES_PARERR /* 3: Invalid parameter */ | ||
} DRESULT; | ||
|
||
|
||
/*---------------------------------------*/ | ||
/* Prototypes for disk control functions */ | ||
|
||
DSTATUS disk_initialize (void); | ||
DRESULT disk_readp (BYTE*, DWORD, WORD, WORD); | ||
DRESULT disk_writep (const BYTE* buff, DWORD sofs, DWORD count); | ||
void disk_writeflush(); | ||
|
||
#define STA_NOINIT 0x01 /* Drive not initialized */ | ||
#define STA_NODISK 0x02 /* No medium in the drive */ | ||
|
||
/* Card type flags (CardType) */ | ||
#define CT_MMC 0x01 /* MMC ver 3 */ | ||
#define CT_SD1 0x02 /* SD ver 1 */ | ||
#define CT_SD2 0x04 /* SD ver 2 */ | ||
#define CT_SDC (CT_SD1|CT_SD2) /* SD */ | ||
#define CT_BLOCK 0x08 /* Block addressing */ | ||
|
||
#define _DISKIO | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,147 @@ | ||
#include "diskio.h" | ||
|
||
#include "mmc.h" | ||
#include "spi.h" | ||
|
||
//#include "printf.h" | ||
|
||
void mmcReadCached(u32 sector); | ||
u32 n_actual_mmc_sector; | ||
extern unsigned char mmc_sector_buffer[512]; | ||
|
||
void mmcReadCached(u32 sector) | ||
{ | ||
//debug("mmcReadCached"); | ||
//plotnext(toatarichar(' ')); | ||
//plotnextnumber(sector); | ||
//debug("\n"); | ||
if(sector==n_actual_mmc_sector) return; | ||
//debug("mmcReadREAL"); | ||
//plotnext(toatarichar(' ')); | ||
//plotnextnumber(sector); | ||
//debug("\n"); | ||
|
||
u08 ret,retry; | ||
//predtim nez nacte jiny, musi ulozit soucasny | ||
// TODO mmcWriteCachedFlush(); | ||
//az ted nacte novy | ||
retry=0; //zkusi to maximalne 256x | ||
do | ||
{ | ||
ret = mmcRead(sector); //vraci 0 kdyz ok | ||
retry--; | ||
} while (ret && retry); | ||
while(ret); //a pokud se vubec nepovedlo, tady zustane zablokovany cely SDrive! | ||
n_actual_mmc_sector=sector; | ||
} | ||
|
||
|
||
|
||
/*-----------------------------------------------------------------------*/ | ||
/* Initialize Disk Drive */ | ||
/*-----------------------------------------------------------------------*/ | ||
|
||
DSTATUS disk_initialize (void) | ||
{ | ||
DSTATUS stat; | ||
|
||
//printf(" in init "); | ||
n_actual_mmc_sector = 0xffffffff; | ||
for(;;) | ||
{ | ||
mmc_init(); | ||
if (0==mmcRead(1)) | ||
break; | ||
} | ||
|
||
//printf(" setting freq "); | ||
|
||
set_spi_clock_freq(); | ||
|
||
stat = RES_OK; | ||
|
||
return stat; | ||
} | ||
|
||
|
||
|
||
/*-----------------------------------------------------------------------*/ | ||
/* Read Partial Sector */ | ||
/*-----------------------------------------------------------------------*/ | ||
|
||
DRESULT disk_readp ( | ||
BYTE* dest, /* Pointer to the destination object */ | ||
DWORD sector, /* Sector number (LBA) */ | ||
WORD sofs, /* Offset in the sector */ | ||
WORD count /* Byte count (bit15:destination) */ | ||
) | ||
{ | ||
DRESULT res; | ||
|
||
/*debug("readp:"); | ||
plotnextnumber(sector); | ||
debug(" "); | ||
plotnextnumber((int)dest); | ||
debug(" "); | ||
plotnextnumber(sofs); | ||
debug(" "); | ||
plotnextnumber(count); | ||
debug(" "); | ||
plotnextnumber(atari_sector_buffer); | ||
debug(" "); | ||
plotnextnumber(mmc_sector_buffer); | ||
debug("\n"); | ||
*/ | ||
// Put your code here | ||
mmcReadCached(sector); | ||
for(;count>0; sofs,--count) | ||
{ | ||
unsigned char x = mmc_sector_buffer[sofs]; | ||
//printf("char:%c loc:%d ", x,sofs); | ||
*dest = x; | ||
} | ||
|
||
res = RES_OK; | ||
|
||
return res; | ||
} | ||
|
||
|
||
|
||
/*-----------------------------------------------------------------------*/ | ||
/* Write Partial Sector */ | ||
/*-----------------------------------------------------------------------*/ | ||
|
||
DRESULT disk_writep (const BYTE* buff, DWORD sofs, DWORD count) | ||
{ | ||
DRESULT res; | ||
|
||
int i=sofs; | ||
int end=sofs count; | ||
int pos = 0; | ||
for (;i!=end; i, pos) | ||
{ | ||
mmc_sector_buffer[i] = buff[pos]; | ||
//printf("char:%c loc:%d,", buff[pos],i); | ||
} | ||
|
||
res = RES_OK; | ||
|
||
return res; | ||
} | ||
|
||
void disk_writeflush() | ||
{ | ||
// Finalize write process | ||
int retry=16; //zkusi to maximalne 16x | ||
int ret; | ||
//printf(":WSECT:%d",n_actual_mmc_sector); | ||
do | ||
{ | ||
ret = mmcWrite(n_actual_mmc_sector); //vraci 0 kdyz ok | ||
retry--; | ||
} while (ret && retry); | ||
//printf(":WD:"); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,37 @@ | ||
/*-------------------------------------------*/ | ||
/* Integer type definitions for FatFs module */ | ||
/*-------------------------------------------*/ | ||
|
||
#ifndef _FF_INTEGER | ||
#define _FF_INTEGER | ||
|
||
#ifdef _WIN32 /* FatFs development platform */ | ||
|
||
#include <windows.h> | ||
#include <tchar.h> | ||
|
||
#else /* Embedded platform */ | ||
|
||
/* This type MUST be 8 bit */ | ||
typedef unsigned char BYTE; | ||
typedef unsigned char u08; | ||
typedef unsigned char uint8_t; | ||
|
||
/* These types MUST be 16 bit */ | ||
typedef short SHORT; | ||
typedef unsigned short WORD; | ||
typedef unsigned short WCHAR; | ||
typedef unsigned short u16; | ||
|
||
/* These types MUST be 16 bit or 32 bit */ | ||
typedef int INT; | ||
typedef unsigned int UINT; | ||
|
||
/* These types MUST be 32 bit */ | ||
typedef long LONG; | ||
typedef unsigned int DWORD; | ||
typedef unsigned int u32; | ||
|
||
#endif | ||
|
||
#endif |
Oops, something went wrong.