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

📄 sd_defs.h

📁 基于S3C2440处理器的sd卡驱动程序
💻 H
📖 第 1 页 / 共 2 页
字号:
#define SECTOR_SIZE_POS1	5			//SECTOR_SIZE upper 5-bit#define SECTOR_SIZE_POS2	4			//SECTOR_SIZE lower 2-bit#define R2WFACTOR_POS 		3			//R2WFACTOR_POS//CSD中一些域的掩码#define TAAC_MSK			0x07		//TACC 域掩码#define NSAC_MSK			0x78		//NSAC 域掩码#define READ_BL_LEN_MSK		0x0F		//READ_BL_LEN 的掩码#define C_SIZE_MSK1			0x03		//C_SIZE 高2位掩码#define C_SIZE_MSK3			0xC0		//C_SIZE 低2位掩码#define C_SIZE_MULT_MSK1 	0x03		//C_SIZE_MULT 的高2位掩码#define C_SIZE_MULT_MSK2 	0x80		//C_SIZE_MULT 的低2位掩码#define R2WFACTOR_MSK		0x1C		//R2WFACTOR 掩码#define SECTOR_SIZE_MSK1	0x3F		//SECTOR_SIZE 的高5位#define SECTOR_SIZE_MSK2	0x80		//SECTOR_SIZE 的低2位



/*
 *******************************************************
	
		SD 卡的相关命令与响应宏定义
	
 *******************************************************
*/

/* 命令响应定义 define command's response */
#define SD_R0 		0								/* 用于SD模式 */
#define SD_R1 		1
#define SD_R1B 		2
#define SD_R2 		3
#define SD_R3	 	4
#define SD_R6 		7

#define CARDSTATUS_ERR_MSK3	  0xFF
#define CARDSTATUS_ERR_MSK2	  0xF9
#define CARDSTATUS_ERR_MSK1	  0xE0
#define CARDSTATUS_ERR_MSK0	  0x08

#define SD_CRC_STATUS_MSK	  0x1C
#define SD_CRC_STATUS_OK	  0x08	


#define SDI_MAX_TX_FIFO 		64
#define SDI_MAX_RX_FIFO			64

#define SDICSTA_SENT			0x800
#define SDICSTA_TOUT			0x400
#define SDICSTA_RSP				0x200

#define SDIDSTA_TOUT			0x20
#define SDIFSTA_RX				0x1000
#define SDIFSTA_CNT				0x3f

#define SDIFSTA_TX				1<<13
#define SDIDSTA_DFIN			0x10

#define SDICCON_START			0x100
#define SDICCON_WRSP			0x200
#define SDICCON_LRSP			0x400
#define SDIDCON_TARSP_1			0x100000
#define SDIDCON_TX				0x3000

#define SDIFSTA_RX_LAST			0x200
#define SDIFSTA_RX_FULL			0x100

#define SDIFSTA_TX_EMP			0x400


#define SDIDCON_RACMD_1			0x80000
#define SDIDCON_BLK				0x20000
#define SDIDCON_RX				0x2000
#define SDIDCON_WIDE			0x10000
/*
*********************************************

     SD卡 命令集

*********************************************
*/

/******************************** 基本命令集 Basic command set **************************/
/* 复位SD 卡 Reset cards to idle state */
#define CMD0 0
#define CMD0_R SD_R0


/* 读所有SD总线上的SD卡的CID寄存器 asks any device to send their CID numbers on the CMD Line*/
#define  CMD1   	1
#define	 CMD1_R	 	SD_R3

/* 读所有SD总线上的SD卡的CID寄存器 asks any device to send their CID numbers on the CMD Line*/
#define CMD2 2
#define CMD2_R SD_R2

/* 要求设备发送一个新的相对地址 asks the device to publish a new relative adderss */
#define CMD3 3
#define CMD3_R SD_R6

/* 选择/断开选择卡 select/deselect card */
#define	CMD7 7
#define CMD7_R SD_R1

/* 读CSD寄存器 Card sends the CSD */
#define CMD9 9
#define CMD9_R SD_R2

/* 读CID寄存器 Card sends CID */
#define CMD10 10
#define CMD10_R SD_R2

/* 停止读多块时的数据传输 Stop a multiple block (stream) read/write operation */
#define CMD12 12
#define CMD12_R SD_R1B

/* 读 Card_Status 寄存器 Get the addressed card's status register */
#define CMD13 13
#define CMD13_R SD_R1

/* 设置设备处于停止状态 set the device to inactive state */
#define CMD15 15
#define CMD15_R SD_R0

/*  sets the block length (in bytes) for all
	following block commands (read and write). Default block length is specified
	in the CSD
*/
/* 设置块的长度 Set the block length */
#define CMD16 16
#define CMD16_R SD_R1

/* 读单块 Read a single block */
#define CMD17 17
#define CMD17_R SD_R1

/* 读多块,直至主机发送CMD12为止 Read multiple blocks until a CMD12 */
#define CMD18 18
#define CMD18_R SD_R1

/***************************** 块写命令集 Block write commands *************************/
/* 写单块 Write a block of the size selected with CMD16 */
#define CMD24 24
#define CMD24_R SD_R1

/* 写多块 Multiple block write until a CMD12 */
#define CMD25 25
#define CMD25_R SD_R1

/* 写CSD寄存器 Program the programmable bits of the CSD */
#define CMD27 27
#define CMD27_R SD_R1

/***************************** 写保护 Write protection *****************************/
/* Set the write protection bit of the addressed group */
#define CMD28 28
#define CMD28_R SD_R1B

/* Clear the write protection bit of the addressed group */
#define CMD29 29
#define CMD29_R SD_R1B

/* Ask the card for the status of the write protection bits */
#define CMD30 30
#define CMD30_R SD_R1

/***************************** 擦除命令 Erase commands *******************************/
/* 设置擦除块的起始地址 Set the address of the first write block to be erased */
#define CMD32 32
#define CMD32_R SD_R1

/* 设置擦除块的终止地址 Set the address of the last write block to be erased */
#define CMD33 33
#define CMD33_R SD_R1

/* 擦除所选择的块 Erase the selected write blocks */
#define CMD38 38
#define CMD38_R SD_R1B

/***************************** 锁卡命令 Lock Card commands ***************************/
/* 设置/复位密码或上锁/解锁卡 Set/reset the password or lock/unlock the card */
#define CMD42 42
#define CMD42_R	SD_R1B
/* Commands from 42 to 54, not defined here */

/***************************** 应用命令 Application-specific commands ****************/
/* 禁止下一个命令为应用命令  Flag that the next command is application-specific */
#define CMD55 55
#define CMD55_R SD_R1

/* 应用命令的通用I/O  General purpose I/O for application-specific commands */
#define CMD56 56
#define CMD56_R SD_R1

/* 读OCR寄存器,只用于SPI模式  Read the OCR (SPI mode only) */
#define CMD58 58
#define CMD58_R SD_R3

/* 使能或禁止 CRC Turn CRC on or off */    //SD卡没有此功能
#define CMD59 59						   //SD卡没有此功能
#define CMD59_R SD_R1						   //SD卡没有此功能

/***************************** 应用命令 Application-specific commands ***************/
#define ACMD6 6
#define ACMD6_R SD_R1

/* 获取 SD Status寄存器 Get the SD card's status */
#define ACMD13 13
#define ACMD13_R SD_R1

/* 得到已写入卡中的块的个数 Get the number of written write blocks (Minus errors ) */
#define ACMD22 22
#define ACMD22_R SD_R1

/* 在写之前,设置预先擦除的块的个数 Set the number of write blocks to be pre-erased before writing */
#define ACMD23 23
#define ACMD23_R SD_R1

/* 读取OCR寄存器 Get the card's OCR (SD mode) */
#define ACMD41 41
#define ACMD41_R SD_R3

/* 连接/断开CD/DATA[3]引脚上的上拉电阻 Connect or disconnect the 50kOhm internal pull-up on CD/DAT[3] */
#define ACMD42 42
#define ACMD42_R SD_R1

/* 读取SCR寄存器 Get the SD configuration register */
#define ACMD51 51
#define ACMD51_R SD_R1
#endif

⌨️ 快捷键说明

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