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

📄 sdconfig.h

📁 SD卡的SPI驱动程序
💻 H
字号:
/****************************************Copyright (c)**************************************************
**                               Guangzhou ZLG-MCU Development Co.,LTD.
**                                      graduate school
**                                 http://www.zlgmcu.com
**
**--------------File Info-------------------------------------------------------------------------------
** File name:			sdconfig.h
** Last modified Date:	2005-1-6
** Last Version:		V1.0
** Descriptions:		Soft Packet of SD Card Driver: configuration header file
**
**------------------------------------------------------------------------------------------------------
** Created by:			Ming Yuan Zheng
** Created date:		2005-1-6
** Version:				V1.0
** Descriptions:		The original version
**
**------------------------------------------------------------------------------------------------------
** Modified by:			Jing.Zhang
** Modified date:		2005-12-19
** Version:				
** Descriptions:		Some low-level operations related to the specific hardware
**                      have been modified for being integrated into NiosII HAL.  
**
**------------------------------------------------------------------------------------------------------
** Modified by: 
** Modified date:
** Version:	
** Descriptions: 
**
********************************************************************************************************/
#ifndef __SD_CONFIG_H__
#define __SD_CONFIG_H__

#include  "system.h"
#include  "altera_avalon_pio_regs.h"

/*
 * User should modify these Macro definitions according to the real SOPC system
 */
 
//For detecting Card
#ifndef SD_INSERT_BASE             //这是SD_INSERT_PIO核的基地址
#define SD_INSERT_BASE  0xffffffff //user's definition here
#endif

#if SD_INSERT_BASE == 0xffffffff
#error "No definition of SD_INSERT PIO core.\n"
#endif

//For controlling power
#ifndef SD_POWER_BASE             //这是SD_POWER_PIO核的基地址
#define SD_POWER_BASE  0xffffffff //user's definition here
#endif

#if SD_POWER_BASE == 0xffffffff
#error "No definition of SD_POWER PIO core.\n"
#endif

//For detecting write protection
#ifndef SD_WP_BASE             //这是SD_WP_PIO核的基地址
#define SD_WP_BASE  0xffffffff //user's definition here
#endif

#if SD_WP_BASE == 0xffffffff
#error "No definition of SD_WP PIO core.\n"
#endif

//PIO for controlling the power of SD card
#ifndef SD_PWR_BASE             //这是SD_PWR核的基地址
#define SD_PWR_BASE  0xffffffff //user's definition here
#endif

#if SD_PWR_BASE == 0xffffffff
#error "No definition of SD_PWR PIO core.\n"
#endif

/*
 * No more modification below...
 */
/*****************************************************************************************
/                                              DATA TYPES
/                                         (Compiler Specific)
*****************************************************************************************/

/* This is the definition for NiosII.  */
typedef unsigned char  BOOLEAN;
typedef unsigned char  INT8U;                    /* Unsigned  8 bit quantity                           */
typedef signed   char  INT8S;                    /* Signed    8 bit quantity                           */
typedef unsigned short INT16U;                   /* Unsigned 16 bit quantity                           */
typedef signed   short INT16S;                   /* Signed   16 bit quantity                           */
typedef unsigned long  INT32U;                   /* Unsigned 32 bit quantity                           */
typedef signed   long  INT32S;                   /* Signed   32 bit quantity                           */
typedef float          FP32;                     /* Single precision floating point                    */
typedef double         FP64;                     /* Double precision floating point                    */


/* CRC used in the process of the data transmission */
#define SD_CRC_EN		   		1          //1 means use; 0 means unuse.

/* The max size of the block in SD card is 512 bytes*/
#define SD_BLOCKSIZE 			512	
/* the work frequency of SPI core: 400Khz           */
#define SPI_CLOCK               400000		

#define SD_BLOCKSIZE_NBITS		9  

/* Those flags are used to configure the SD card driver */

#define SD_ReadMultiBlock_EN    0			//1: support multiblock read; 0: unsupport

#define SD_WriteMultiBlock_EN   0			//1: support multiblock write; 0: unsupport

#define SD_EraseBlock_EN		1			//1: support Erase Block; 0: unsupport

#define SD_ProgramCSD_EN   		0			//1: support CSD register operation; 0: unsupport
	
#define SD_ReadCID_EN	   		0			//1: support CID register operation; 0: unsupport
	
#define	SD_ReadSD_Status_EN		0			//1: support SD_Status register operation; 0: unsupport

#define	SD_ReadSCR_EN			0			//1: support SCR register operation; 0: unsupport

/*  Initialize the SD card control pins                */
#define SD_CTL_PIN_INIT()       do {  }while(0)
								    
                                    //IOWR_ALTERA_AVALON_PIO_DIRECTION(SD_POWER_BASE,1);
						
/* Turn the power off */
#define  SD_POWER_OFF()  do{\
                                IOWR_ALTERA_AVALON_PIO_DATA(SD_POWER_BASE,1); \
                                IOWR_ALTERA_AVALON_PIO_DATA(SD_PWR_BASE,0);\
                             }while(0) 
/* Turn the power on */                            
#define  SD_POWER_ON()   do{\
                                IOWR_ALTERA_AVALON_PIO_DATA(SD_POWER_BASE,0);\
                                IOWR_ALTERA_AVALON_PIO_DATA(SD_PWR_BASE,1); \
                              }while(0) 

/* Check whether there is a SD Card inserted */
		
#define  SD_INSERT_STATUS()  	(IORD_ALTERA_AVALON_PIO_DATA(SD_INSERT_BASE))	

/* Check whether the SD Card is in the status of write-protection */

#define  SD_WP_STATUS()  		(IORD_ALTERA_AVALON_PIO_DATA(SD_WP_BASE))


#endif /* __SD_CONFIG_H__ */

⌨️ 快捷键说明

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