HPGCC3 Documentation 3.0 R003

sddriver.h

Go to the documentation of this file.
00001 //& *** (c) 2006-2011 The HPGCC3 Team ***
00002 //& Claudio Lapilli
00003 //& Ingo Blank
00004 //&
00005 //& This file is licensed under the terms and conditions of the
00006 //& HPGCC3 license that is included with the source distribution.
00007 //& *** (c) 2006-2011 The HPGCC3 Team ***
00008 
00009 
00010 // $Header: sddriver.h,r42 2006-02-18 04:23:47 ingo $
00011 
00012 // SD DRIVER HEADER
00013 
00014 
00015 
00016 #define CLKREG 0x07200000
00017 #define SDREG  0x07e00000
00018 #define IOPORT 0x07a00000
00019 
00020 #define HWREG(base,off) ( (volatile unsigned int *) (((int)base+(int)off)))
00021 
00022 
00023 #define GPD(a) HWREG(IOPORT,0x30+a)
00024 #define GPE(a) HWREG(IOPORT,0x40+a)
00025 #define GPF(a) HWREG(IOPORT,0x50+a)
00026 
00027 #define SDICON HWREG(SDREG,0)
00028 #define SDIPRE HWREG(SDREG,0X4)
00029 #define SDICARG HWREG(SDREG,0x8)
00030 #define SDICCON HWREG(SDREG,0xc)
00031 #define SDICSTA HWREG(SDREG,0x10)
00032 #define SDIRSP0 HWREG(SDREG,0x14)
00033 #define SDIRSP1 HWREG(SDREG,0x18)
00034 #define SDIRSP2 HWREG(SDREG,0x1c)
00035 #define SDIRSP3 HWREG(SDREG,0x20)
00036 #define SDIDTIMER HWREG(SDREG,0x24)
00037 #define SDIBSIZE HWREG(SDREG,0x28)
00038 #define SDIDCON HWREG(SDREG,0x2c)
00039 #define SDIDCNT HWREG(SDREG,0x30)
00040 #define SDIDSTA HWREG(SDREG,0x34)
00041 #define SDIFSTA HWREG(SDREG,0x38)
00042 #define SDIDAT HWREG(SDREG,0x3c)
00043 #define SDIIMSK HWREG(SDREG,0x40)
00044 
00045 
00046 
00047 #define CON 0
00048 #define DAT 4
00049 #define PULLUP 8
00050 
00051 
00052 typedef struct {
00053 int SystemFlags;                        // 1=SDIO interface setup, 2=SDCard initialized, 4=Valid RCA obtained, 8=Bus configured OK
00054 int Rca;
00055 int BusWidth;
00056 int MaxBlockLen;
00057 int WriteBlockLen;
00058 int CurrentBLen;
00059 int CardSize;
00060 unsigned int CID[4];
00061 } SD_CARD;
00062 
00063 
00064 int SDIOSetup(SD_CARD *card,int shutdown);
00065 int SDCardInserted();
00066 int GetPCLK();
00067 int SDSetFastPCLK();
00068 void SDRestorePCLK(int original);
00069 void SDSetClock(int sdclk);
00070 int SDGetClock();
00071 void SDPowerDown();
00072 void SDPowerUp();
00073 int SDSlowDown();
00074 int SDWaitResp(int mask);
00075 int SDSendCmd(int cmdnum,int arg,int cmdmsk,int mask);
00076 int SDSendACmd(int rca,int cmdnum,int arg,int cmdmsk,int mask);
00077 int SDSendCmdNoResp(int cmdnum,int arg);
00078 int SDSendCmdShortResp(int cmdnum,int arg,int *response);
00079 int SDSendCmdLongResp(int cmdnum,int arg,int *response);
00080 int SDSendACmdShortResp(int rca,int cmdnum,int arg,int *response);
00081 int SDSendACmdLongResp(int rca,int cmdnum,int arg,int *response);
00082 void SDIOReset();
00083 int SDSelect(int RCA);
00084 int SDInit(SD_CARD *card);
00085 int SDGetNewRCA(int *_CID);
00086 void SDDResetFIFO();
00087 int SDDStop();
00088 int SDDSetBlockLen(SD_CARD *card,int bitlen);
00089 int SDDInTransfer(SD_CARD *card);
00090 int SDDRead(int SDAddr,int NumBytes,char *buffer, SD_CARD *card);
00091 int SDCardInit(SD_CARD * card);
00092 int SDDWrite(int SDAddr,int NumBytes,char *buffer, SD_CARD *card);
00093