sdcard.h
来自「ARM7 lpc2132+vs1003+sdcard 制作的 MP3 此程序在」· C头文件 代码 · 共 417 行 · 第 1/2 页
H
417 行
基本命令集 Basic command set
**********************************************/
#define CMD0 0 /* 复位SD 卡 Reset cards to idle state */
#define CMD0_R R1
#define CMD1 1 /* 读OCR寄存器 Read the OCR (MMC mode, do not use for SD cards) */
#define CMD1_R R1
#define CMD9 9 /* 读CSD寄存器 Card sends the CSD */
#define CMD9_R R1
#define CMD10 10 /* 读CID寄存器 Card sends CID */
#define CMD10_R R1
#define CMD12 12 /* 停止读多块时的数据传输 Stop a multiple block (stream) read/write operation */
#define CMD12_R R1B
#define CMD13 13 /* 读 Card_Status 寄存器 Get the addressed card's status register */
#define CMD13_R R2
/***************************** 块读命令集 Block read commands **************************/
#define CMD16 16 /* 设置块的长度 Set the block length */
#define CMD16_R R1
#define CMD17 17 /* 读单块 Read a single block */
#define CMD17_R R1
#define CMD18 18 /* 读多块,直至主机发送CMD12为止 Read multiple blocks until a CMD12 */
#define CMD18_R R1
/***************************** 块写命令集 Block write commands *************************/
#define CMD24 24 /* 写单块 Write a block of the size selected with CMD16 */
#define CMD24_R R1
#define CMD25 25 /* 写多块 Multiple block write until a CMD12 */
#define CMD25_R R1
#define CMD27 27 /* 写CSD寄存器 Program the programmable bits of the CSD */
#define CMD27_R R1
/***************************** 写保护 Write protection *****************************/
#define CMD28 28 /* Set the write protection bit of the addressed group */
#define CMD28_R R1B
#define CMD29 29 /* Clear the write protection bit of the addressed group */
#define CMD29_R R1B
#define CMD30 30 /* Ask the card for the status of the write protection bits */
#define CMD30_R R1
/***************************** 擦除命令 Erase commands *******************************/
#define CMD32 32 /* 设置擦除块的起始地址 Set the address of the first write block to be erased */
#define CMD32_R R1
#define CMD33 33 /* 设置擦除块的终止地址 Set the address of the last write block to be erased */
#define CMD33_R R1
#define CMD38 38 /* 擦除所选择的块 Erase the selected write blocks */
#define CMD38_R R1B
/***************************** 锁卡命令 Lock Card commands ***************************/
#define CMD42 42 /* 设置/复位密码或上锁/解锁卡 Set/reset the password or lock/unlock the card */
#define CMD42_R R1B
/* Commands from 42 to 54, not defined here */
/***************************** 应用命令 Application-specific commands ****************/
#define CMD55 55 /* 禁止下一个命令为应用命令 Flag that the next command is application-specific */
#define CMD55_R R1
#define CMD56 56 /* 应用命令的通用I/O General purpose I/O for application-specific commands */
#define CMD56_R R1
#define CMD58 58 /* 读OCR寄存器 Read the OCR (SPI01 mode only) */
#define CMD58_R R3
#define CMD59 59 /* 使能或禁止 CRC Turn CRC on or off */
#define CMD59_R R1
/***************************** 应用命令 Application-specific commands ***************/
#define ACMD13 13 /* 获取 SD Status寄存器 Get the SD card's status */
#define ACMD13_R R2
#define ACMD22 22 /* 得到已写入卡中的块的个数 Get the number of written write blocks (Minus errors ) */
#define ACMD22_R R1
#define ACMD23 23 /* 在写之前,设置预先擦除的块的个数 Set the number of write blocks to be pre-erased before writing */
#define ACMD23_R R1
#define ACMD41 41 /* 读取OCR寄存器 Get the card's OCR (SD mode) */
#define ACMD41_R R1
#define ACMD42 42 /* 连接/断开CD/DATA[3]引脚上的上拉电阻 Connect or disconnect the 50kOhm internal pull-up on CD/DAT[3] */
#define ACMD42_R R1
#define ACMD51 51 /* 读取SCR寄存器 Get the SD configuration register */
#define ACMD51_R R1
#define SD_CRC_EN 0 /* 设置数据传输时是否使用CRC */
#define SPI1_CLOCK 5529600 /* 正常通信时,SPI1时钟频率 frequency (Hz) */
#define SD_BLOCKSIZE 512 /* SD卡块的长度 */
#define SD_BLOCKSIZE_NBITS 9
/* 下面函数不常用,如果用户不需要,可置为 0 裁剪指定函数 */
#define SD_ReadMultiBlock_EN 0 /* 是否使能读多块函数 */
#define SD_WriteMultiBlock_EN 0 /* 是否使能写多块函数 */
#define SD_EraseBlock_EN 0 /* 是否使能擦卡函数 */
#define SD_ProgramCSD_EN 0 /* 是否使能写CSD寄存器函数 */
#define SD_ReadCID_EN 0 /* 是否使能读CID寄存器函数 */
#define SD_ReadSD_Status_EN 0 /* 是否使能读SD_Status寄存器函数 */
#define SD_ReadSCR_EN 0 /* 是否使能读SCR寄存器函数 */
extern void SD_Power(void);
extern void SPI1_Init(uint8 speed);
extern uint8 SPI1_SrByte(INT8U byte);
extern void SD_SPI1Delay(INT8U value);
extern INT8U SD_ChkCard(void);
#if SD_CRC_EN
extern INT16U const CRCTable[256] ;
extern INT16U SD_GetCRC16(INT8U *pSource, INT16U len);
extern INT8U SD_GetCmdByte6(INT8U cmd, INT8U *param);
#endif
extern INT8U SD_SendCmd(INT8U cmd, INT8U *param, INT8U resptype, INT8U *resp);
extern INT8U SD_ReadReg(INT32U len, INT8U *recbuf);
extern INT8U SD_ReadCSD(INT8U csdlen, INT8U *recbuf);
extern void SD_CalTimeout(INT8U *csdbuf);
extern INT8U SD_ActiveInit(void);
extern INT16U SD_GetSDVer(void);
extern void SD_PackParam(INT8U *parameter, INT32U value);
extern INT8U SD_BlockCommand(INT8U cmd, INT8U resptype, INT32U parameter);
extern INT8U SD_ResetSD(void);
extern INT8U SD_GetCardInfo(void);
#if SD_ReadCID_EN
extern INT8U SD_ReadCID(INT8U cidlen, INT8U *recbuf);
#endif
extern INT8U SD_StopTransmission(void);
extern INT8U SD_ReadCard_Status(INT8U len, INT8U *buffer);
extern INT8U SD_SetBlockLen(INT32U length);
extern INT8U SD_ReadSingleBlock(INT32U blockaddr);
extern INT8U SD_ReadMultipleBlock(INT32U blockaddr);
extern INT8U SD_WriteSingleBlock(INT32U blockaddr);
extern INT8U SD_WriteMultipleBlock(INT32U blockaddr);
#if SD_ProgramCSD_EN
extern INT8U SD_ProgramCSD(INT8U len, INT8U *buff);
extern INT8U SD_GetCRC7(INT8U *pSource, INT16U len);
#endif
#if SD_EraseBlock_EN
extern INT8U SD_EraseStartBlock(INT32U startblock);
extern INT8U SD_EraseEndBlock(INT32U endblock);
extern INT8U SD_EraseSelectedBlock(void);
extern INT8U SD_EraseBlock(INT32U startaddr, INT32U blocknum);
#endif
extern INT8U SD_WaitBusy(INT8U waittype);
extern INT8U SD_ReadOCR(INT8U ocrlen, INT8U *recbuf);
#if SD_CRC_EN
INT8U SD_EnableCRC(INT8U bEnable);
#endif
#if SD_ReadSD_Status_EN
SD_ReadSD_Status(INT8U sdslen, INT8U *recbuf);
#endif
#if SD_WriteMultiBlock_EN
extern INT8U SD_GetNumWRBlcoks(INT32U *blocknum);
#endif
extern INT8U SD_ReadBlockData(INT32U len, INT8U *recbuf);
extern INT8U SD_WriteBlockData(INT8U bmulti, INT32U len, INT8U *sendbuf);
extern void SD_StopMultiToken(void);
extern INT8U SD_ReadBlock(INT32U blockaddr, INT8U *recbuf);
extern INT8U SD_WriteBlock(INT32U blockaddr, INT8U *sendbuf);
extern INT8U SD_Initialize(void);
#if SD_ReadMultiBlock_EN
extern INT8U SD_ReadMultiBlock(INT32U blockaddr, INT32U blocknum, INT8U *recbuf);
#endif
#if SD_WriteMultiBlock_EN
extern INT8U SD_WriteMultiBlock(INT32U blockaddr, INT32U blocknum, INT8U *sendbuf);
#endif
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?