www.pudn.com > MMC_SD.rar > MMC_SD.h, change:2009-06-01,size:1366b


 
#ifndef __MMC_SD_h__ 
#define __MMC_SD_h__ 
 
#include <p18F66j10.h> 
 
#define uint8  unsigned char 
#define  int8    signed char 
#define uint16 unsigned int 
#define  int16   signed int 
#define uint32 unsigned long 
#define  int32   signed long 
 
#define MMC_SD_CS			PORTCbits.RC2 
#define MMC_SD_CS_TRIS		TRISCbits.TRISC2 
 
#define MMC_SD_SCK			PORTCbits.RC3 
#define MMC_SD_SCK_TRIS	TRISCbits.TRISC3 
 
#define MMC_SD_MOSI		PORTCbits.RC5 
#define MMC_SD_MOSI_TRIS	TRISCbits.TRISC5 
 
#define MMC_SD_MISO		PORTCbits.RC4 
#define MMC_SD_MISO_TRIS	TRISCbits.TRISC4 
 
/****************************************************************/ 
 
#define MMC_SD_PORT_INI  {\ 
							MMC_SD_CS=1;\ 
							MMC_SD_SCK=1;\ 
							MMC_SD_MOSI=1;\ 
							MMC_SD_MISO=1;\ 
							\ 
							MMC_SD_CS_TRIS =0;\ 
							MMC_SD_SCK_TRIS =0;\ 
							MMC_SD_MOSI_TRIS =0;\ 
							MMC_SD_MISO_TRIS =1;\ 
						}							 
 
#define SPI_CS_Assert   MMC_SD_CS=0  
#define SPI_CS_Deassert MMC_SD_CS=1 
 
 
void SPI_Low(void); 
void SPI_High(void); 
uint8 SPI_WriteByte(uint8 val); 
uint8 SPI_ReadByte(void); 
uint8 MMC_SD_SendCommand(uint8 cmd, uint32 arg); 
uint8 MMC_SD_Init(void); 
uint8 MMC_SD_ReadSingleBlock(uint32 sector, uint8* buffer);//读一个扇区 
uint8 MMC_SD_WriteSingleBlock(uint32 sector, uint8* buffer);//写一个扇区 
uint32 MMC_SD_ReadCapacity(); 
 
#endif