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

📄 mmc.h

📁 butterfly MP3源代码
💻 H
字号:
/***************************************************************************		Title:	MultiMedia Card low level Functions	File:	mmc.h	Author:	Nick Lott 	Date:	September 2004	This file represents a convergence of a number of code snippets found 	on the web, some of the Yampp system by Jesper Hansen and the work    done by Sylvain.Bissonnette@microsyl.com. The goal is to produce an 	adaptable library for doing low level MMC activities over the SPI bus.	This file came about really as Jesper's code had problems when porting 	to a different AVR. This code was written with the Atmega169V in mind 	(aka "Butterfly").		For details Concerning the MMC spec see www.sandisk.com. I refered to 	"SanDisk MultiMediaCard and Reduced-Size MultiMediaCard Product Manual"	Doc No. 80-36-00320 v1.0 during the writing of this code.		This program is free software; you can redistribute it and/or	modify it under the terms of the GNU General Public License	as published by the Free Software Foundation; either version 2	of the License, or (at your option) any later version.	This program is distributed in the hope that it will be useful,	but WITHOUT ANY WARRANTY; without even the implied warranty of	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the	GNU General Public License for more details.	You should have received a copy of the GNU General Public License	along with this program; if not, write to the Free Software Foundation, 	Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.***************************************************************************//***************************************************************************History:24-26 Sep 2004: Initial write and port of functions collected over last few 	months March 2005:		Add improvements based around Circuit cellar article				ADD***************************************************************************/// MMC Hardware connections#define MMC_PORT	PORTE#define MMC_PIN		PINE#define MMC_DDR		DDRE#define MMC_CS		PE4#define SPI_PORT	PORTB#define SPI_DDR 	DDRB#define SPI_SS		PB0#define SPI_SCK		PB1#define SPI_MOSI	PB2#define SPI_MISO	PB3// MMC commands#define MMC_GO_IDLE_STATE		0#define MMC_SEND_OP_COND		1#define MMC_SEND_CSD			9#define MMC_SEND_CID			10#define MMC_SEND_STATUS			13#define MMC_SET_BLOCKLEN		16#define MMC_READ_SINGLE_BLOCK	17#define MMC_WRITE_BLOCK			24#define MMC_PROGRAM_CSD			27#define MMC_SET_WRITE_PROT		28#define MMC_CLR_WRITE_PROT		29#define MMC_SEND_WRITE_PROT		30#define MMC_TAG_SECTOR_START		32#define MMC_TAG_SECTOR_END		33#define MMC_UNTAG_SECTOR		34#define MMC_TAG_ERASE_GROUP_START 	35#define MMC_TAG_ERARE_GROUP_END		36#define MMC_UNTAG_ERASE_GROUP		37#define MMC_ERASE			38#define MMC_CRC_ON_OFF			59// R1 Response bit-defines#define MMC_R1_BUSY					0x80#define MMC_R1_PARAMETER			0x40#define MMC_R1_ADDRESS				0x20#define MMC_R1_ERASE_SEQ			0x10#define MMC_R1_COM_CRC				0x08#define MMC_R1_ILLEGAL_COM			0x04#define MMC_R1_ERASE_RESET			0x02#define MMC_R1_IDLE_STATE			0x01// Data Start tokens#define MMC_STARTBLOCK_READ			0xFE#define MMC_STARTBLOCK_WRITE		0xFE#define MMC_STARTBLOCK_MWRITE		0xFC// Data Stop tokens#define MMC_STOPTRAN_WRITE			0xFD// Data Error Token values#define MMC_DE_MASK					0x1F#define MMC_DE_ERROR				0x01#define MMC_DE_CC_ERROR				0x02#define MMC_DE_ECC_FAIL				0x04#define MMC_DE_OUT_OF_RANGE			0x04#define MMC_DE_CARD_LOCKED			0x04// Data Response Token values#define MMC_DR_MASK					0x1F#define MMC_DR_ACCEPT				0x05#define MMC_DR_REJECT_CRC			0x0B#define MMC_DR_REJECT_WRITE_ERROR	0x0D#ifndef MMC_C#include "types.h"extern uint8 mmc_sbuf[];// 512 byte sector buffer in internal RAMextern uint8 mmc_scratch[]; // 32 byte Scratch buffer for CSD/CID/ ops//// Prototypes//void SpiInit(void); 				// init AVR HWuint8 SpiByte(unsigned char byte); // xmit/recv over SPIuint8 MMC_Reset(void);				// init mmcuint16 MMC_Check(void);				// check statusuint8 MMC_Read(uint32 lba);uint8 MMC_Write(uint32 lba);uint8 MMC_Identify(void);	// get CID datauint8 MMC_CardType(void);  // get CSD datauint32 MMC_Capacity(void); // get capacity in Bytesuint8 MMC_Name(void); // get MMC Nameuint8 MMC_WriteProtect(uint8 set);void MMC_Flush(void);BOOL MMC_Detect(void);#endif

⌨️ 快捷键说明

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