⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atasd.h

📁 vxworks下SD卡及DOS文件系统驱动
💻 H
字号:
#ifndef _ATASD_H_
#define _ATASD_H_

#include "DataType.h"
#include "vxworks.h"
#include "sysLib.h"
#include "stdlib.h"
#include "intLib.h"


enum
{
    MMC_CMD0_GO_IDLE_STATE=0,
    MMC_CMD1_SEND_OP_COND,
    MMC_CMD2_ALL_SEND_CID,
    MMC_CMD3_SET_RELATIVE_ADDR,
    MMC_CMD4_SET_DSR,
    MMC_CMD5_RESERVED,
    MMC_CMD6_RESERVED,
    MMC_CMD7_SELECT_CARD,
    MMC_CMD8_RESERVED,
    MMC_CMD9_SEND_CSD,
    MMC_CMD10_SEND_CID,
    MMC_CMD11_READ_DAT_UNTIL_STOP,
    MMC_CMD12_STOP_TRANSMISSION,
    MMC_CMD13_SEND_STATUS,
    MMC_CMD14_RESERVED,
    MMC_CMD15_GO_INACTIVE_STATE,
    MMC_CMD16_SET_BLOCKLEN,

    /*read commands*/
    MMC_CMD17_READ_SINGLE_BLOCK,
    MMC_CMD18_READ_MULTIPLE_BLOCK,
    MMC_CMD19_RESERVED,

    /*write commands*/
    MMC_CMD20_WRITE_DAT_UNTIL_STOP,
    MMC_CMD21_RESERVED,
    MMC_CMD22_RESERVED,
    MMC_CMD23_RESERVED,
    MMC_CMD24_WRITE_BLOCK,
    MMC_CMD25_WRITE_MULTIPLE_BLOCK,
    MMC_CMD26_PROGRAM_CID,
    MMC_CMD27_PROGRAM_CSD,

    /*block oriented write protection*/
    MMC_CMD28_SET_WRITE_PROT,
    MMC_CMD29_CLR_WRITE_PROT,
    MMC_CMD30_SEND_WRITE_PROT,
    MMC_CMD31_RESERVED,

    /*erase commands*/
    MMC_CMD32_TAG_SECTOR_START,
    MMC_CMD33_TAG_SECTOR_END,
    MMC_CMD34_UNTAG_SECTOR,
    MMC_CMD35_ERASE_GROUP_START,
    MMC_CMD36_ERASE_GROUP_END,
    MMC_CMD37_UNTAG_ERASE_GROUP,
    MMC_CMD38_ERASE,

    /*IO mode commands*/
    MMC_CMD39_FASTIO,
    MMC_CMD40_GO_IRQ_STATE,
    MMC_CMD41_RESERVED,

    /*Lock card*/
    MMC_CMD42_LOCK_UNLOCK,
    /*commands 43-54 are reserved*/

    /*Application specific commands*/
    MMC_CMD55_APP_CMD=55,
    MMC_CMD56_GEN_CMD=56,
    
    /*commands 57 are reserved*/
    MMC_CMD56_READ_OCR=58
    /*commands 59 are reserved
    commands 60-63 are reserved for manufacturers*/
};

/*command pakeage define*/
typedef struct
{
    /*the struct defined with MSB go out first*/
    U8 b6CommandIndex     :6;
    U8 b1TransmissionBit  :1;
    U8 b1StartBit         :1;

    union
    {
        U8 dwArgument[4];
        struct
        {
            U8 wStuff[2];
            U8 wArgument[2];
        }b16Argument;
    }Argument;
    
    U8 b1EndBit  :1;
    U8 b7CRC7    :7;
}t_MMC_COMMAND;

/*CSD define 128*/
typedef struct
{
    /*readonly part*/
    char b2CSDStructure  :2;    	/*CSD structure*/
    char b4SpecVers      :4;    	/*System specification version*/
    char b2Reserved1     :2;    	/*reserved*/

    char byTAAC;                	/*Data read-access-time-1*/
    char byNSAC;                	/*Data read-access-time-2 in CLK cycles (NSAC*100)*/
    char byTranSpeed;           	/*max data transfer rate*/

	int b12CCC;					/*card command classes*/

    char b4ReadBLLen     :4;		/*Max read data block length*/
    char b1ReadBLPartial :1;    	/*Partial blocks for read allowed*/
    char b1WriteBlkMisalign:1;  	/*Write block misalignment*/
    char b1ReadBlkMisalign:1;  		/*Read block misalignment*/
    char b1DSRImp        :1;    	/*DSR implemented*/

    char b2Reserved2     :2;    	/*reserved*/

    int b12CSize;			    	/*Device size*/

    char b3VDDRCurrMin   :3;    	/*Max read current @ VDD max*/
    char b3VDDRCurrMax   :3;    	/*Max read current @ VDD max*/
    char b3VDDWCurrMin   :3;    	/*Max write current @ VDD min*/
    char b3VDDWCurrMax   :3;   		/*Max write current @ VDD max*/
    char b3CSizeMult     :3;    	/*Device size multiplier*/
    char b5EraseGrpSize  :5;    	/*Erase group size*/
    char b5EraseGrpMult  :5;    	/*erase group size multiplier*/
    char b5WPGrpSize     :5;    	/*Write protect group size*/

    char b1WPGrpEnable   :1;    	/*Write protect group enable*/
    char b2DefaultECC    :2;    	/*Manufacturer default ECC*/
    char b3R2WFactor     :3;    	/*Write speed factor*/
    char b4WriteBLLen    :4;    	/*Max write data block length*/
    char b1WriteBLPartial:1;    	/*Partial blocks for write allowed*/
    char b4Reserved3     :4;    	/*Reserved*/
    char b1ContentProtAPP:1;    	/*Content protection application*/

    /*rewriteable part*/
    char b1FileFormatGrp   :1;  	/*File format group*/
    char b1Copy            :1;  	/*Is data a copy?*/
    char b1PermWriteProtect:1;  	/*Permenant write protect flag (Write Once)*/
    char b1TmpWriteProtect :1;  	/*Temporary write protect flag*/
    char b2FileFormat      :2;  	/*File format*/
    char b2ECC             :2;  	/*Error correction code type*/
    char b7CRC             :7;  	/*CRC*/
    char b1NouUsed         :1;  	/*not used, always '1'*/
}t_MMC_CSD;


/* SD Interface     */
#define rCLKCON             (*((volatile unsigned*)0x4c00000c))

#define rSDIDAT             (*((volatile unsigned *)0x5a00003c))           
#define rSDIIMSK            (*((volatile unsigned *)0x5a000040))  
   
#define SD_BASE             0x5a000000 
#define IO_BASE             0x56000040
typedef  struct SD{

 UINT32  rSDICON;       /* SDI control                  */
 UINT32  rSDIPRE;       /* SDI baud rate prescaler      */
 UINT32  rSDICMDARG;    /* SDI command argument         */
 UINT32  rSDICMDCON;    /* SDI command control          */
 UINT32  rSDICMDSTA;    /* SDI command status           */
 UINT32  rSDIRSP0;      /* SDI response 0               */
 UINT32  rSDIRSP1;      /* SDI response 1               */
 UINT32  rSDIRSP2;      /* SDI response 2               */
 UINT32  rSDIRSP3;      /* SDI response 3               */
 UINT32  rSDIDTIMER;    /* SDI data/busy timer          */
 UINT32  rSDIBSIZE;     /* SDI block size               */
 UINT32  rSDIDATCON;    /* SDI data control             */
 UINT32  rSDIDATCNT;    /* SDI data remain counter      */
 UINT32  rSDIDATSTA;    /* SDI data status              */
 UINT32  rSDIFSTA;      /* SDI FIFO status              */
} MMCreg;

typedef struct IOT{
 UINT32 rGPECON;
 UINT32 rGPEDAT;
 UINT32 rGPEUP;
}EIOreg;

UINT32 InitSDMMC(void);
void sdDosFs(void);

#endif 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -