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

📄 sd.h

📁 C8051F340读写SD卡,带文件系统
💻 H
字号:
#ifndef _SD_H_
#define _SD_H_

/*命令宏*/
#define CMD0	(0x40+0)	/* GO_IDLE_STATE */
#define CMD1	(0x40+1)	/* SEND_OP_COND */
#define ACMD41	(0xC0+41)	/* SEND_OP_COND */
#define CMD8	(0x40+8)	/* SEND_IF_COND */
#define CMD9	(0x40+9)	/* SEND_CSD */
#define CMD10	(0x40+10)	/* SEND_CID */
#define CMD12	(0x40+12)	/* STOP_TRANSMISSION */
#define ACMD13	(0xC0+13)	/* SD_STATUS */
#define CMD16	(0x40+16)	/* SET_BLOCKLEN */
#define CMD17	(0x40+17)	/* READ_SINGLE_BLOCK */
#define CMD18	(0x40+18)	/* READ_MULTIPLE_BLOCK */
#define ACMD23	(0xC0+23)	/* SET_WR_BLK_ERASE_COUNT */
#define CMD24	(0x40+24)	/* WRITE_BLOCK */
#define CMD25	(0x40+25)	/* WRITE_MULTIPLE_BLOCK */
#define CMD32	(0x40+32)	/* ERASE_BLOCK_START_ADDR */
#define CMD33	(0x40+33)	/* ERASE_BLOCK_END_ADDR */
#define CMD38	(0x40+38)	/* ERASE_SELECTED_BLOCKS */
#define CMD55	(0x40+55)	/* APP_CMD */
#define CMD58	(0x40+58)	/* READ_OCR */

#define SD_CS_ASSERT     (CS = 0)
#define SD_CS_DEASSERT   (CS = 1)

/*SD卡初始化*/
unsigned char SD_init(void);

/*命令发送函数*/
unsigned char SD_sendCommand(unsigned char cmd, unsigned long arg);

/*读单块*/
unsigned char SD_readSingleBlock(unsigned char *buff, unsigned long startBlock);

/*写单块*/
unsigned char SD_writeSingleBlock(unsigned char *buff, unsigned long startBlock);

/*读多块*/
unsigned char SD_readMultipleBlock (unsigned char *buff, unsigned long startBlock, unsigned long totalBlocks);

/*写单块*/
unsigned char SD_writeMultipleBlock(unsigned char *buff, unsigned long startBlock, unsigned long totalBlocks);

/*块擦除*/
unsigned char SD_erase (unsigned long startBlock, unsigned long totalBlocks);

/*块接收*/
static unsigned char receive_DataBlock(unsigned char *buff, unsigned int btr);

/*块发送*/
static unsigned char transmit_DataBlock(const unsigned char *buff, unsigned char token);

#endif

⌨️ 快捷键说明

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