?? sdcmd.h
字號:
/****************************************Copyright (c)**************************************************
** Guangzhou ZLG-MCU Development Co.,LTD.
** graduate school
** http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name: sdcmd.h
** Last modified Date: 2005-3-11
** Last Version: V2.0
** Descriptions: SD/MMC 讀寫模塊: 物理層 ---- SD/MMC 卡SPI模式支持的命令(頭文件)
** Soft Packet of SD/MMC Card : commands that SD/MMC card supported
** in spi mode(header file)
**------------------------------------------------------------------------------------------------------
** Created by: Ming Yuan Zheng
** Created date: 2005-1-6
** Version: V1.0
** Descriptions: SD/MMC 讀寫模塊: 物理層 ---- SD卡SPI模式支持的命令
**
**------------------------------------------------------------------------------------------------------
** Modified by: Ming Yuan Zheng
** Modified date: 2005-3-11
** Version: V2.0
** Descriptions: 增加了對MMC卡的支持,并使用本模塊既可以運行于前后臺系統,也可運行于uCOS-II中.
**
**------------------------------------------------------------------------------------------------------
** Modified by: Ming Yuan Zheng
** Modified date: 2007-5-19
** Version: V3.0
** Descriptions: 1. 對原來SPI模式下的函數名進行修改, 改為以 SpiCmd_ 為開頭, 數據流函數以 SdSpi_ 為開頭
**
** 2. 增加了對SD總線模式的支持, 函數名以 SdCmd_ 為開頭
**
********************************************************************************************************/
#ifndef __SDCMD_H__
#define __SDCMD_H__
/*
*******************************************************
本文件主要是 SD/MMC 卡的相關命令與響應宏定義
包括: SD總線模式和SPI模式
*******************************************************
*/
/*********************************************************************************
SD/MMC 卡 SD總線模式命令及響應
**********************************************************************************/
#if SDBUS_MODE_EN
/* 命令響應定義 define command's response */
#define R0 0 /* 用于SD模式 */
#define R1 1
#define R1B 2
#define R2 3
#define R3 4
#define R6 7
/*
*******************************
SD/MMC卡 命令集
*******************************
*/
/******************************** 基本命令集 Basic command set **************************/
/* 復位SD 卡 Reset cards to idle state */
#define CMD0 0
#define CMD0_R R0
/* 讀所有SD總線上的SD卡的CID寄存器 asks any device to send their CID numbers on the CMD Line*/
#define CMD1 1
#define CMD1_R R3
/* 讀所有SD總線上的SD卡的CID寄存器 asks any device to send their CID numbers on the CMD Line*/
#define CMD2 2
#define CMD2_R R2
/* 要求設備發送一個新的相對地址 asks the device to publish a new relative adderss */
#define CMD3 3
#define CMD3_R R6
/* 選擇/斷開選擇卡 select/deselect card */
#define CMD7 7
#define CMD7_R R1
/* 讀CSD寄存器 Card sends the CSD */
#define CMD9 9
#define CMD9_R R2
/* 讀CID寄存器 Card sends CID */
#define CMD10 10
#define CMD10_R R2
/* 停止讀多塊時的數據傳輸 Stop a multiple block (stream) read/write operation */
#define CMD12 12
#define CMD12_R R1B
/* 讀 Card_Status 寄存器 Get the addressed card's status register */
#define CMD13 13
#define CMD13_R R1
/* 設置設備處于停止狀態 set the device to inactive state */
#define CMD15 15
#define CMD15_R R0
/* 設置塊的長度 Set the block length */
#define CMD16 16
#define CMD16_R R1
/* 讀單塊 Read a single block */
#define CMD17 17
#define CMD17_R R1
/* 讀多塊,直至主機發送CMD12為止 Read multiple blocks until a CMD12 */
#define CMD18 18
#define CMD18_R R1
/***************************** 塊寫命令集 Block write commands *************************/
/* 寫單塊 Write a block of the size selected with CMD16 */
#define CMD24 24
#define CMD24_R R1
/* 寫多塊 Multiple block write until a CMD12 */
#define CMD25 25
#define CMD25_R R1
/* 寫CSD寄存器 Program the programmable bits of the CSD */
#define CMD27 27
#define CMD27_R R1
/***************************** 寫保護 Write protection *****************************/
/* Set the write protection bit of the addressed group */
#define CMD28 28
#define CMD28_R R1B
/* Clear the write protection bit of the addressed group */
#define CMD29 29
#define CMD29_R R1B
/* Ask the card for the status of the write protection bits */
#define CMD30 30
#define CMD30_R R1
/***************************** 擦除命令 Erase commands *******************************/
/* 設置擦除塊的起始地址 Set the address of the first write block to be erased */
#define CMD32 32
#define CMD32_R R1
/* 設置擦除塊的終止地址 Set the address of the last write block to be erased */
#define CMD33 33
#define CMD33_R R1
/* 設置擦除塊的起始地址(僅適用于MMC卡) */
#define CMD35 35
#define CMD35_R R1
/* 設置擦除塊的終止地址(僅適用于MMC卡) */
#define CMD36 36
#define CMD36_R R1
/* 擦除所選擇的塊 Erase the selected write blocks */
#define CMD38 38
#define CMD38_R R1B
/***************************** 鎖卡命令 Lock Card commands ***************************/
/* 設置/復位密碼或上鎖/解鎖卡 Set/reset the password or lock/unlock the card */
#define CMD42 42
#define CMD42_R 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 R1
/* 應用命令的通用I/O General purpose I/O for application-specific commands */
#define CMD56 56
#define CMD56_R R1
/* 讀OCR寄存器,只用于SPI模式 Read the OCR (SPI mode only) */
#define CMD58 58
#define CMD58_R R3
/* 使能或禁止 CRC Turn CRC on or off */ //SD卡沒有此功能
#define CMD59 59 //SD卡沒有此功能
#define CMD59_R R1 //SD卡沒有此功能
/***************************** 應用命令 Application-specific commands ***************/
#define ACMD6 6
#define ACMD6_R R1
/* 獲取 SD Status寄存器 Get the SD card's status */
#define ACMD13 13
#define ACMD13_R R1
/* 得到已寫入卡中的塊的個數 Get the number of written write blocks (Minus errors ) */
#define ACMD22 22
#define ACMD22_R R1
/* 在寫之前,設置預先擦除的塊的個數 Set the number of write blocks to be pre-erased before writing */
#define ACMD23 23
#define ACMD23_R R1
/* 讀取OCR寄存器 Get the card's OCR (SD mode) */
#define ACMD41 41
#define ACMD41_R R3
/* 連接/斷開CD/DATA[3]引腳上的上拉電阻 Connect or disconnect the 50kOhm internal pull-up on CD/DAT[3] */
#define ACMD42 42
#define ACMD42_R R1
/* 讀取SCR寄存器 Get the SD configuration register */
#define ACMD51 51
#define ACMD51_R R1
/*
* SD 總線模式下, Card_Status寄存器相關狀態位
*/
#define CARD_STATUS_ACMD_ENABLE (1 << 5) /* 僅用于SD卡 */
#define CARD_STATUS_ERASE_RESET (1 << 13)
/* 卡各種狀態掩碼 */
#define CARD_STATUS_RDY_DATA (0x01 << 8)
#define CARD_STATUS_CURRENT_STATE (0x0F << 9)
#define CARD_STATUS_IDLE (0x00 << 9) /* 空閑 */
#define CARD_STATUS_READY (0x01 << 9) /* 接收 */
#define CARD_STATUS_IDENT (0x02 << 9) /* 識別 */
#define CARD_STATUS_STBY (0x03 << 9) /* 待機 */
#define CARD_STATUS_TRAN (0x04 << 9) /* 數據發送 */
#define CARD_STATUS_DATA (0x05 << 9) /* 數據 */
#define CARD_STATUS_REC (0x06 << 9) /* 數據接收 */
#define CARD_STATUS_PRG (0x07 << 9) /* 卡編程 */
#define CARD_STATUS_DIS (0x08 << 9) /* 卡斷開 */
/* sdcmd.c文件導出的函數 */
extern INT8U SdCmd_Go_Idle_State(sd_struct *sds);
extern INT8U SdCmd_Send_OP_Cond(sd_struct *sds);
extern INT8U SdCmd_Send_ACMD(sd_struct *sds);
extern INT8U SdCmd_SD_App_OP_Cond(sd_struct *sds);
extern INT8U SdCmd_All_Send_CID(sd_struct *sds, INT8U cidlen, INT8U *cidbuf);
extern INT8U SdCmd_Set_Relative_Addr(sd_struct *sds);
extern INT8U SdCmd_Send_CSD(sd_struct *sds, INT8U csdlen, INT8U *csdbuf);
extern INT8U SdCmd_Stop_Transmission(sd_struct *sds);
extern INT8U SdCmd_Send_Status(sd_struct *sds, INT32U *status);
extern INT8U SdCmd_Select_Card(sd_struct *sds);
extern INT8U SdCmd_Set_Bus_Width(sd_struct *sds, INT8U bWideBus);
extern INT8U SdCmd_Set_BlockLen(sd_struct *sds, INT32U blockLen);
extern INT8U SdCmd_Read_Single_Block(sd_struct *sds, INT32U blockadddr);
extern INT8U SdCmd_Read_Multiple_Block(sd_struct *sds, INT32U blockadddr);
extern INT8U SdCmd_Deselect_Card(sd_struct *sds, INT32U RCA);
extern INT8U SdCmd_Write_Single_Block(sd_struct *sds, INT32U blockadddr);
extern INT8U SdCmd_Write_Multiple_Block(sd_struct *sds, INT32U blockadddr);
extern INT8U SdCmd_Erase_Wr_Blk_Start(sd_struct *sds, INT32U blockadddr);
extern INT8U SdCmd_Erase_Wr_Blk_End(sd_struct *sds, INT32U blockadddr);
extern INT8U SdCmd_Erase(sd_struct *sds);
#endif // end of SDBUS_MODE_EN
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -