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

📄 mmc_lib.h

📁 用ATMEL AVR CPU开发MMC CARD 的MMC库
💻 H
字号:
/*-------------------------------------------------
	Interface for MultiMediaCard via SPI
	Thanks to Ulrich Radig for his code!
	
	Stefan Seegel 7/2004
---------------------------------------------------*/

#define MMC_PORT PORTB
#define MMC_DDR DDRB

#define SPI_MISO	PB6		//DataOut of MMC 
#define SPI_MOSI	PB5		//DataIn of  MMC
#define SPI_CLK  	PB7		//Clock of MMC
#define MMC_CS		PB4		//ChipSelect of MMC

typedef struct {
    unsigned char csd_structure:2;
    unsigned char spec_vers:4;
    const unsigned char reserved:2;
    
   	unsigned char taac;
   	unsigned char nsac; 
		unsigned char tran_speed;
		
		unsigned short ccc:12;
		unsigned short read_blk_len:4;
		
		unsigned char read_blk_partial:1;
		unsigned char write_blk_misalign:1;
		unsigned char read_blk_misalgin:1;
		unsigned char dsr_imp:1;
} CSD;

extern unsigned char mmc_init(void);
/*			
*		Call mmc_init one time after a new card has been connected to the 礐's SPI bus!
*	
*		return values:
*			0: MMC initialized successfully
*			1: Error while trying to reset MMC
*			2: Error/Timeout while trying to initialize MMC
*/


extern unsigned char mmc_read_sector(unsigned long sector, char *buffer);
/*	
*		mmc_read_sector reads a block of 512 bytes from mmc.
*		Make sure that buffer points to an allocated memory with at least 512 bytes!
*
*		Parameters:
*			sector: specifies which sector to be read
*			buffer:	pointer to allocated memory where to store data
*
*		Return values:
*			0: Sector read successfully
*			1: No response after read command from MMC
*			2: No startbyte received
*/

extern unsigned char mmc_write_sector(unsigned long sector, char *buffer);
/*
*		mmc_write_sector writes a block of 512 bytes to mmc.
*
*		Parameters:
*			sector: specifies which sector to be read
*			buffer:	pointer to data to write in MMC
*
*		Return Values:
*			0: Sector written successfully
*			1: No response after write command from MMC
*			2: MMC busy timeout after writing block
*/

extern unsigned char mmc_read_csd(char *buffer);
/*	
*		reads the CSD (Card Specific Data) register from MMC.
*		Make sure that buffer points to an allocated memory with at least 16 bytes!

*
*		Parameters:
*			buffer:	pointer to allocated memory where to store data
*
*		Return values:
*			0: block read successfully
*			1: No response after read command from MMC
*			2: No startbyte received
*/

extern unsigned char mmc_read_cid(char *buffer);
/*	
*		reads the CID (Card Identification) register from MMC.
*		Make sure that buffer points to an allocated memory with at least 16 bytes!

*
*		Parameters:
*			buffer:	pointer to allocated memory where to store data
*
*		Return values:
*			0: block read successfully
*			1: No response after read command from MMC
*			2: No startbyte received
*/

⌨️ 快捷键说明

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