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

📄 setscsiinfo.h

📁 瑞萨单片机开发软代码.非常实用小巧的平台,很多应用都可以在上面实现.
💻 H
字号:
/*
****************************************************************************
					H I T A C H I    P R O P R I E T A R Y

	COPYRIGHT (c)	2001 BY Semiconductor & Integrated Circuits,Hitachi,Ltd.
						---  ALL RIGHTS RESERVED  ---

	File Name	:SetSCSIInfo.h
	Working		:SCSI command data
	Created		:Rev 2001_11_28 {Author : T.Ishikawa}
****************************************************************************
*/

#ifndef _SCSIINFO_H
#define _SCSIINFO_H                   

#include "catprotype.h"


/*	if you want to change DiskSize	*/
/*	change this value and set [SDRAM_DATA_S]and[SDRAM_DATA_E]	*/
//#define	DISK_ALL_BYTE					0x00040000	/*	221k	FAT 12	*/
//#define	DISK_ALL_BYTE					0x00100000	/*	1M	FAT 12	*/
//#define	DISK_ALL_BYTE					0x00f00000	/*	14.9M	FAT 12	*/
//#define	DISK_ALL_BYTE					0x01000000	/*	15.8M	FAT 16	*/
#define	DISK_ALL_BYTE					0x01FF0000	/*	31.6M	FAT 16	*/


/*	Calculate How many SECTORs	*/
#if ((DISK_ALL_BYTE & 0x0000001F) == 0x00000000)
#define	DISK_ALL_SECTOR					(DISK_ALL_BYTE>>9) 
#else
#define	DISK_ALL_SECTOR					(DISK_ALL_BYTE>>9 + 1)
#endif								
#define ACCESS_SECTORS		(DISK_ALL_SECTOR - 0x00000020)

/*	select FAT type 	*/

#if (DISK_ALL_SECTOR < 0x8000)	//	We tested Approx. 
								//	2M,4M,8M,16M,32M,64M,128M,256M,512M
								//	1G,1.9G
//FAT 12
#define PARTITION_TYPE				0x01,
#define PARTITION_ALL_SECTORS		(unsigned char)ACCESS_SECTORS,(unsigned char)(ACCESS_SECTORS >> 8),0x00,0x00,

#define FAT_SECTORS_PER_CLUSTER		0x08,//FAT 12

//#define FAT_ROOT_ENTRIES			0x00,0x02,
#define FAT_ROOT_ENTRIES			0xE0,0x00,
#define FAT_ALL_SECTORS_SMALL		(unsigned char)ACCESS_SECTORS,(unsigned char)(ACCESS_SECTORS >> 8),

#define FAT_SECTORS_PER_FAT			(unsigned char)(((ACCESS_SECTORS + (ACCESS_SECTORS <<1)) >> 13) + 0x0001),0x00,

#define FAT_ALL_SECTORS_LARGE		0x00,0x00,0x00,0x00,
#define FAT_VOLUME_LABEL			0x4E,0x4F,0x20,0x4E,0x41,0x4D,0x45,0x20,0x20,0x20,0x20,
#define FAT_SYSTEM_ID				0x46,0x41,0x54,0x31,0x32,0x20,0x20,0x20,
		


#elif (DISK_ALL_SECTOR < 0x00010000)	//32M

//FAT 16 (small)
#define PARTITION_TYPE				0x04
#define PARTITION_ALL_SECTORS		(unsigned char)ACCESS_SECTORS,(unsigned char)(ACCESS_SECTORS >> 8),0x00,0x00

#define FAT_SECTORS_PER_CLUSTER		0x01

#define FAT_ROOT_ENTRIES			0x00,0x02 //FAT 16 (small)
#define FAT_ALL_SECTORS_SMALL		(unsigned char)ACCESS_SECTORS,(unsigned char)(ACCESS_SECTORS >> 8)

#define FAT_SECTORS_PER_FAT			(unsigned char)(ACCESS_SECTORS >> 8),0x00


#define FAT_ALL_SECTORS_LARGE		0x00,0x00,0x00,0x00
#define FAT_VOLUME_LABEL			0x4E,0x4F,0x20,0x4E,0x41,0x4D,0x45,0x20,0x20,0x20,0x20
#define FAT_SYSTEM_ID				0x46,0x41,0x54,0x31,0x36,0x20,0x20,0x20
	
#elif(DISK_ALL_SECTOR < 0x003ff000)	//<2G

//FAT 16 (large)
#if (DISK_ALL_SECTOR < 0x0003f000)		//1		//<128M

#define FAT_SECTORS_PER_CLUSTER		0x04
#define BIT_SIFT_S_PER_C			0x02

#elif (DISK_ALL_SECTOR < 0x0007f000)	//1		//<256M

#define FAT_SECTORS_PER_CLUSTER		0x08
#define BIT_SIFT_S_PER_C			0x03

#elif (DISK_ALL_SECTOR < 0x000ff000)	//1		//<512M

#define FAT_SECTORS_PER_CLUSTER		0x10
#define BIT_SIFT_S_PER_C			0x04

#elif (DISK_ALL_SECTOR < 0x001ff000)	//1		//<1024M

#define FAT_SECTORS_PER_CLUSTER		0x20
#define BIT_SIFT_S_PER_C			0x05

#else 								//1		//<2G

#define FAT_SECTORS_PER_CLUSTER		0x40
#define BIT_SIFT_S_PER_C			0x06

#endif	//1

#define PARTITION_TYPE				0x06	//FAT16 Large
#define PARTITION_ALL_SECTORS		(unsigned char)ACCESS_SECTORS,(unsigned char)(ACCESS_SECTORS >> 8),(unsigned char)(ACCESS_SECTORS >> 16),(unsigned char)(ACCESS_SECTORS >> 24)

#define FAT_ROOT_ENTRIES			0x00,(unsigned char)(ACCESS_SECTORS >> (12 + BIT_SIFT_S_PER_C))	//	about 1/16 of cluster
#define FAT_ALL_SECTORS_SMALL		0x00,0x00

#define FAT_SECTORS_PER_FAT			(unsigned char)(ACCESS_SECTORS >> (8 + BIT_SIFT_S_PER_C)),(unsigned char)(ACCESS_SECTORS >> (16 + BIT_SIFT_S_PER_C))


#define FAT_ALL_SECTORS_LARGE		PARTITION_ALL_SECTORS
#define FAT_VOLUME_LABEL			0x4E,0x4F,0x20,0x4E,0x41,0x4D,0x45,0x20,0x20,0x20,0x20
#define FAT_SYSTEM_ID				0x46,0x41,0x54,0x31,0x36,0x20,0x20,0x20

#else
	/*	FAT 32	or other FAT system	*/
#endif



/*	CBW	*/
CBWDataType		cbwDataGVar[] = {
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00
};

/*	CSW	*/
CSWDataType		cswDataGVar[] = {
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00
};


/*	for return all 0 datas ,etc	*/
ReturnDataType	returnData[] = {
	0x00000000,0x00000000,0x00000000,0x00000000,
	0x00000000,0x00000000,0x00000000,0x00000000,
	0x00000000,0x00000000,0x00000000,0x00000000,
	0x00000000,0x00000000,0x00000000,0x00000000
};


//	INQUIRY return data	
unsigned char		ansInquiryData[] = {
	0x00,
	0x80,                                        // removeable device
	0x02,                                        // might or might not comply  ANSI standard
	0x02,                                        // 
	0x20,                                        // additional length
	0x00,0x00,0x00,
	0x48,0x49,0x54,0x41,0x43,0x48,0x49,0x20,	 //	vendor = HITACHI
    0x48,0x38,0x53,0x2f,0x32,0x32,0x31,0x35,
    0x46,0x44,0x2D,0x53,0x46,0x20,0x20,0x20,     // product name = H8S/2215FD-SF
	0x31,0x2E,0x30,0x30,						 //	version	= 1.00
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
        
//	MBR partition table 1 and EOF	
const	MBRDataType		mbrData[] = {
	0x80,0x00,0x00,0x00,PARTITION_TYPE,0x00,0x00,0x00,0x20,0x00,0x00,0x00,PARTITION_ALL_SECTORS,	/*	Prt1	*/
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,	/*	Prt2	*/
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,	/*	Prt3	*/
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,	/*	Prt4	*/
	0x55,0xAA	/*	EOF	*/
};


// PBR
const	PBRDataType		pbrData[] = {
	0xEB,0x3C,0x90,								// 3, jump code
	0x48,0x4D,0x53,0x41,0x48,0x4B,0x44,0x43,	// 8, OEM name "HMSAHKDC"  
	0x00,0x02,									// 2, byte per sector (512 bytes)
	FAT_SECTORS_PER_CLUSTER,					// 1, SPC, Sector Per Cluster
	0x01,0x00,									// 2, reserved sector (1, fixed)
	0x02,										// 1, no. of FAT (2, fixed)
	FAT_ROOT_ENTRIES,							// 2, max root dir entries
	FAT_ALL_SECTORS_SMALL,						// 2, no of sectors (<32MB)
	0xF8,										// 1, media
	FAT_SECTORS_PER_FAT,							// 2, SPF, Sector Per FAT
	0x3F,0x00,									// 2, SPT, Sector Per Track
	0xFF,0x00,									// 2, no of heads        
	0x20,0x00,0x00,0x00,						// 4, no of hidden sector
	FAT_ALL_SECTORS_LARGE,						// 4, no of sectors in partition (>32MB)
	0x80,										// 1, logical drive number
	0x00,
	0x29,                                       // 1, extended signature (0x29 fixed)
	0x00,0x00,0x00,0x00,						// 4, serial number
	FAT_VOLUME_LABEL,							// 11, volume name
	FAT_SYSTEM_ID,								// 8, name of FAT
	0x00,0x00
};	



/*	READ CAPACITY return value	*/
unsigned long	readCapaData[] = {
	0x00000000,
	0x00000000
};


//	READ CAPACITY return value, added by hmsa-hk
unsigned char	readFormatCapData[] = {
	0x00,0x00,0x00,             // reserved
	0x08,                       // return length (no. of bytes) after
	0x00,0x00,0x00,0x00,        // number of blocks
	0x00,                       // descriptor type
	0x00,0x00,0x00              // block length
};


/*	REQUEST SENSE return value	*/
unsigned char		reqSensDataGVar[] = {
	0x70,0x00,
	0x00,
	0x00,0x00,0x00,0x00,
	0x0C,
	0x00,0x00,0x00,0x00,
	0x00,
	0x00,
	0x00,0x00,0x00,0x00
};

// use for unit state
// 0x00 = normal, 0x01 = removed
unsigned char		unit_state[]={0x00};


unsigned char		modeSensBlockDescriptorGVar[8] = {
	0x00,0x00,0x00,0x00,
	0x00,0x00,0x02,0x00
};
unsigned char		modeSens_1C_GVar[] = {
/*
	0x9A,0x0A,0x08,0x00,
	0x00,0x00,0x02,0x00,
	0x00,0x00,0x02,0x00
*/
	0x1C,0x06,0x00,0x01,
	0x00,0x00,0x00,0x00,
	
};



/*	interrupt enable register bits	*/
InterruptType	interruptEnableBitsGVar = {0xFFFFFFFF};



/*	function and "EpInfo" number for each interrupt	*/
LinkType	jump[] = {
	{0x80000000,0,0,ActBusReset},		/*	Bus_Reset interrupt	*/
	{0x01000000,0,0,ActControl},		/*	Setup_TS	*/
	{0x0E000000,1,0,ActControlInOut},	/*	EP0o_TS, EP0i_TR, EP0i_TS	*/
	{0x00040000,3,5,ActBulkOnly},		/*	EP1_Full		*/
	{0x00030000,4,6,ActBulkOnly},		/*	EP2_Empty, EP2_TR	*/
	{0x00000080,0,0,SetUsbModule},		/*	PLL_Ready Interrupt	*/
	{0x00000001,0,0,ActBusVcc},			/*	USB Bus Connect (VBUS) Interrupt	*/
	{0x00000000,255,0,0}				/*	table end	*/
};


/*	register information for each Endpoint	*/
EpInfoType	EpInfo[] = {
	/*	0	EP0-Setup (Control Transfer Setup Stage)	*/	/*	clear EP0o, EP0i FIFOs	*/
	{0,	CONTROL,	&writeFifoSizeGVar[0],	&USBFM.UEDR0S.BYTE,	0x00,				0x00,	0x01,	0x06,	0x01,	WAIT,	8},
	/*	1	EP0-In (Control IN Transfer)	*/
	{0,	CONTROL,	&writeFifoSizeGVar[1],	&USBFM.UEDR0I.BYTE,	0x00,				0x02,	0x04,	0x02,	0x01,	WAIT,	64},
	/*	2	EP0-Out (Control OUT Transfer)	*/
	{0,	CONTROL,	&USBFM.UESZ0O,			&USBFM.UEDR0O.BYTE,	0x00,				0x02,	0x04,	0x04,	0x01,	WAIT,	64},
	/*	3	EP1-BulkOut	*/
	{1,	BULK,		&USBFM.UESZ2O,			&USBFM.UEDR2O.BYTE,	&USBFM.UEDR2O.LONG,	0x00,	0x20,	0x20,	0x20,	WAIT,	64},
	/*	4	EP2-BulkIn	*/
	{2,	BULK,		&writeFifoSizeGVar[1],	&USBFM.UEDR2I.BYTE,	&USBFM.UEDR2I.LONG,	0x10,	0x00,	0x10,	0x10,	WAIT,	64}
};



/*	data buffer information	*/
BuffType	BufPtr[] = {
	{&controlBeginGVar[0],&controlBeginGVar[0]},	/*	Control Transfer	*/
	{0,0},	/*	not use	*/
	{0,0},	/*	not use	*/
	{0,0},	/*	Bulk OUT Transfer	*/
	{0,0},	/*	Bulk IN Transfer	*/

	/*	CBW/CSW transfer data pointer for BOT	*/
	{&cbwDataGVar->byteVal[0],&cbwDataGVar->byteVal[0]},
	/*	Storage/Sense transfer data pointer for BOT	*/
	{0,0}
};



BuffType	contCMDGPtr = {&ep0PacketGVar.byteVal[0],&ep0PacketGVar.byteVal[0]};



/*	data buffer pointer for Control OUT transfer	*/
ControlType transStageGPtr = {0,0};



/*	Max Packet Size	*/
unsigned char	writeFifoSizeGVar[] = {8,64};



/*	Descriptor information	*/
/*	Device Descriptor	*/
unsigned char		DeviceItem[] = {
	0x12,
	0x01,
	0x10,0x01,
	0x08,
	0x00,
	0x01,
	0x40,

	0x5B,0x04,	//VID
	0x03,0x00,  //PID
	0x00,0x01,
	0x01,
	0x02,
	0x03,
	0x01	//	Vender=Hitachi. No String
};


DiscriptorType		deviceDiscriptorGVar[] = {
	{18,DeviceItem}
};



/*	Configuration Descriptoer ( data length=32Byte )	*/
unsigned char		configurationItem[] = {
	0x09,0x02,0x20,0x00,0x01,0x01,0x00,0x80,0x30,	/*	not use remoteWakeup	*/
	0x09,0x04,0x00,0x00,0x02,0x08,0x06,0x50,0x00,	/*	Interface / Endpoint number is 2 , Mass Storage Class Bulk Only Transport	*/

//	BulkIn-EP2, BulkOut-EP1
//	0x07,0x05,0x82,0x02,0x40,0x00,0x00,				/*	EP2 / BalkIn MaxPacket=64	*/
//	0x07,0x05,0x01,0x02,0x40,0x00,0x00				/*	EP1 / BalkOut MaxPacket=64	*/

//  BulkIn-EP1, BulkOut-EP2
	0x07,0x05,0x81,0x02,0x40,0x00,0x00,				/*	EP1 / BalkIn MaxPacket=64	*/
	0x07,0x05,0x02,0x02,0x40,0x00,0x00				/*	EP2 / BalkOut MaxPacket=64	*/
};

DiscriptorType		configurationDiscriptorGVar[] = {
	{32,configurationItem}
};


/*	String Descriptor (sample)	*/
unsigned char		StringItem0[] = {0x04,0x03,0x09,0x04};	    /*	LANGID Descriptor	*/
unsigned char		StringItem1[] = {0x16,0x03,0x48,0x00,0x4d,0x00,0x53,0x00,0x41,0x00,0x2d,0x00,0x48,0x00,0x4b,0x00,0x44,0x00,0x43,0x00};	/*	Manufacture String Descriptor Information (sample)	*/
unsigned char		StringItem2[] = {0x2c,0x03,0x48,0x00,0x38,0x00,0x53,0x00,0x2f,0x00,0x32,0x00,0x32,0x00,0x31,0x00,0x35,0x00,0x20,0x00,0x46,0x00,0x6c,0x00,0x61,0x00,0x73,0x00,0x68,0x00,0x44,0x00,0x69,0x00,0x73,0x00,0x6b,0x00,0x2d,0x00,0x53,0x00,0x46,0x00};	/*	Product String Descriptor Information (sample)	*/
unsigned char       StringItem3[] = {0x1A,0x03,0x31,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x30,0x00,0x33,0x00,0x00,0x00};  // 100000000003
unsigned char		StringItem4[] = {0x71,0x72,0x73,0x74,0x75};	/*	Configuration String Descriptor Information (sample)	*/
unsigned char		StringItem5[] = {0x71,0x72,0x73,0x74,0x75};	/*	Interface String Descriptor Information (sample)	*/

DiscriptorType		stringDiscriptorGVar[] = {
	{4,StringItem0},
	{20,StringItem1},
	{44,StringItem2},
	{26,StringItem3},
	{1,StringItem4},
	{1,StringItem5}

};

SetupDataType	ep0PacketGVar = {
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};                                                

unsigned char	controlBeginGVar[CONTROL_DATA_AREA] = {
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};                                                
	


#endif

⌨️ 快捷键说明

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