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

📄 usb_core.h

📁 arm(str710)usb功能的实现
💻 H
📖 第 1 页 / 共 2 页
字号:
/******************** (C) COPYRIGHT 2003 STMicroelectronics ********************
* File Name          : usb_core.h
* Author             : MCD Application Team
* Date First Issued  : 27/10/2003
* Description        : standard protocol processing (USB v1.1)
*
********************************************************************************/
//mss

#define INQUIRY					0x12
#define MODE_SELECT				0x15
#define MODE_SENSE				0x1A
#define PREVENT_ALLOW_REMOVAL	0x1E
#define START_STOP_UNIT			0x1B
#define READ_CAPACITY			0x25
#define TEST_UNIT_READY			0x00
#define READ_10					0x28
#define WRITE_10				0x2A
#define VERIFY					0x2F
#define REQUEST_SENSE			0x03
#define Read_Format_Capacities 	        0x23 

#define SCSI_MSPGCD_TPP		    	    0x1C
#define SCSI_MSPGCD_RETALL			    0x3F

typedef enum
{
	GOOD_STATUS,								/* BOT Good status	*/
	COMMAND_FAILED,								/* BOT Command failure status	*/
	PHASE_ERROR									/* BOT Phase error status	*/
}T_COMMAND_BLOCK_STATUS;

typedef struct
{
	UINT8		dCBWSignature_0;						/** Must be 0x43425355	*/
	UINT8		dCBWSignature_1;
	UINT8		dCBWSignature_2;
	UINT8		dCBWSignature_3;
	UINT8		dCBWTag_0;								/** Must be the same as dCSWTag	*/
	UINT8		dCBWTag_1;
	UINT8		dCBWTag_2;
	UINT8		dCBWTag_3;
	UINT8		dCBWDataTransferLength_0;				/** Number of bytes transfer	*/
	UINT8		dCBWDataTransferLength_1;
	UINT8		dCBWDataTransferLength_2;
	UINT8		dCBWDataTransferLength_3;
	UINT8		bmCBWFlags;								/** indicates the directin of the transfer : 0x80:IN (device to host) ; 0x00:OUT (host to device)	*/
	UINT8		bCBWLUN;								/**	bits 0->3: bCBWLUN	*/
	UINT8		bCBWCBLength;							/** bits 0->4:bCBWCBLength	*/
	UINT8		CBWCB[16];								/** the command bmock to be executed by the device	*/
}T_USBMS_CBW;

typedef struct
{
	UINT8		dCSWSignature_0;							/* Must be 0x53425355	*/
	UINT8		dCSWSignature_1;
	UINT8		dCSWSignature_2;
	UINT8		dCSWSignature_3;
	UINT8		dCSWTag_0;								/* Must be the same as dCBWTag	*/
	UINT8		dCSWTag_1;
	UINT8		dCSWTag_2;
	UINT8		dCSWTag_3;
	UINT8		dCSWDataResidue_0;						/* set to the difference between the amount of data expected	*/
	UINT8		dCSWDataResidue_1;						/* to be processed and trhe amount of data actually processed	*/
	UINT8		dCSWDataResidue_2;
	UINT8		dCSWDataResidue_3;
	UINT8		bCSWStatus;								/* Status odf the the operation, defined by thje T_COMMAND_BLOCK_STATUS enum*/
}T_USBMS_CSW;

typedef struct
{ 
	UINT8			operation_code;						/* operation code of the rbc request */
	UINT8			reserved[8];						/* Reserved; must be set to 0 */
	UINT8			control;							/* control code; must be set to zero */
} T_USBMS_GENERIC_RBC;

typedef struct
{
	UINT8			operation_code;						/* Operation code : 0x28	*/
	UINT8			reserved_1;							/* reserved; must not be used	*/
	UINT8			block_address_3;					/* byte 3 of the start block address	*/
	UINT8			block_address_2;					/* byte 2 of the start block address	*/
	UINT8			block_address_1;					/* byte 1 of the start block address	*/
	UINT8			block_address_0;					/* byte 0 of the start block address	*/
	UINT8			reserved_2;							/* reserved; must not be used	*/
	UINT8			xfer_len_1;							/* byte 1 of the data length	*/
	UINT8			xfer_len_0;							/* byte 0 of the data length	*/
	UINT8			control;							/* control code must be set to 0	*/
} T_USBMS_READ_10;

typedef struct
{
	UINT8		operation_code;							/* Operation code : 0x25*/
	UINT8		reserved[8];							/* Must not be used	*/
	UINT8		control;								/* Control code, set to zero	*/
} T_USBMS_READ_CAPACITY;


#define PWR_CONDITION	0xF0
#define START			0x01
typedef struct
{
	UINT8		operation_code;							/** Operation code : 0x1b*/
	UINT8		immediate;								/**	Only bit 0 is used, the other bits are reserved	*/
	UINT8		reserved_2[2];							/** Must not be used	*/
	UINT8		flags;
	UINT8		control;								/* Control code, set to zero	*/
} T_USBMS_START_STOP_UNIT;


typedef struct
{
	UINT8		operation_code;							/* Operation code : 0x2F*/
	UINT8		reserved_0;								/* Must not be used	*/
	UINT8		block_address_3;						/* byte 3 of the address of the first block to be verified	*/
	UINT8		block_address_2;						/* byte 2 of the address of the first block to be verified	*/
	UINT8		block_address_1;						/* byte 1 of the address of the first block to be verified	*/
	UINT8		block_address_0;						/* byte 0 of the address of the first block to be verified	*/
	UINT8		reserved_1;								/* Must not be used	*/
	UINT8		xfer_len_1;								/* byte 1 of the number of block to verify	*/
	UINT8		xfer_len_0;								/* byte 0 of the number of block to verify	*/
	UINT8		control;								/* Must be set to 0	*/
} T_USBMS_VERIFY;

#define	ENAVLE_VPD	0x01
typedef struct
{
	UINT8		operation_code;							/* Operation code : 0x12*/
	UINT8		enable_vpd;								/** Only the bits 0 is used*/
	UINT8		page_code;								/* specifies which vital product data shall be returned	*/
	UINT16		length;									/* 	*/
	UINT8		control;								/* Must be set to 0	*/
} T_USBMS_INQUIRY;


typedef struct
{
	UINT8		operation_code;							/* Operation code : 0x35*/
	UINT8		reserved_1;								/* Must not be used	*/
	UINT8		block_address_3;						/* byte 3 of the address of the first block to be written	*/
	UINT8		block_address_2;						/* byte 2 of the address of the first block to be written	*/
	UINT8		block_address_1;						/* byte 1 of the address of the first block to be written	*/
	UINT8		block_address_0;						/* byte 0 of the address of the first block to be written	*/
	UINT8		reserved_2;								/* Must not be used	*/
	UINT8		xfer_len_1;								/* byte 1 of the number of block to transfer	*/
	UINT8		xfer_len_0;								/* byte 0 of the number of block to transfer	*/
	UINT8		control;								/* Must be set to 0	*/
} T_USBMS_WRITE_10;



typedef struct
{	
	UINT8		operation_code;							/* Operation code : 0x15	*/
	//UINT8		sp:1;									/* not supported	*/
	//UINT8		reserved_0:3;							/* Must not be used	*/
	//UINT8		pf;										/* page format : 0x01	*/
	//UINT8		reserved_1:3;							/* Must not be used	*/
	UINT8		sp_pf;									/** bit 0:SP	*/
														/** bit 4:PF	*/
	UINT8		reserved_2;								/* Must not be used	*/
	UINT8		reserved_3;								/* Must not be used	*/
	UINT8		parameter_list_length;					/* */
	UINT8		reserved_4;								/* Must not be used	*/
	UINT8		control;								/* Control code : 0x00	*/
}T_USBMS_MODE_SELECT;

typedef struct
{	
	UINT8		operation_code;							/* Operation code : 0x1A	*/
	//UINT8		reserved_0:3;							/* Must not be used	*/
	//UINT8		dbd:1;									/* Disable block descriptors : 0x01	*/
	//UINT8		reserved:4;								/* Must not be used	*/
	UINT8		dbd;									/** bit 3 : DBD	*/
	//UINT8		page_code:6;							/* page code	*/
	//UINT8		pc:2;									/* page control	*/
	UINT8		code_control;							/** bits 0->5: Page Code	*/
														/** bits 6->7: Page Control	*/
	UINT8		subpage_code;							/* subpage code	*/
	UINT8		allocation_length;						/* allocatrion length	*/
	UINT8		control;								/* control code : 0x00	*/
}T_USBMS_MODE_SENSE;


typedef struct
{	
	UINT8		operation_code;							/* Operation code : 0x1E	*/
	UINT8		reserved_0;								/* Must not be used	*/
	UINT8		reserved_1;								/* Must not be used	*/
	UINT8		reserved_2;								/* Must not be used	*/
	//UINT8		prevent:2;								/* specifies if removal is allowed or not	*/
	//UINT8		reserved_3:6;							/* Must not be used	*/
	UINT8		prevent;								/** bits 0->1: Prevent	*/
	UINT8		control;								/* Must be set to 0	*/
}T_USBMS_MEDIA_REMOVAL;


typedef struct
{	
	UINT8		operation_code;							/* Operation code : 0x03	*/
	//UINT8		desc:1;									/* */
	//UINT8		reserved_0:7;							/* Must not be used	*/
	UINT8		desc;									/** bit 0:Desc	*/
	UINT8		reserved_1;								/* Must not be used	*/
	UINT8		reserved_2;								/* Must not be used	*/
	UINT8		allocation_length;						/* 	*/	
	UINT8		control;								/* Must be set to 0x00	*/
}T_USBMS_REQUEST_SENSE;


typedef struct
{	
	UINT8	operation_code;					/** OPeration code must be 0x00	*/
	UINT8	reserved_0;
	UINT8	reserved_1;
	UINT8	reserved_2;
	UINT8	reserved_3;
	UINT8	control;
}T_USBMS_TEST_UNIT_READY;

typedef union
{	
	T_USBMS_GENERIC_RBC		generic_rbc;
	T_USBMS_READ_10			read;
	T_USBMS_READ_CAPACITY	read_capacity;
	T_USBMS_START_STOP_UNIT	start_stop;
	T_USBMS_VERIFY			verify;
	T_USBMS_WRITE_10		write;
	T_USBMS_INQUIRY			inquiry;
	T_USBMS_MODE_SELECT		mode_select;
	T_USBMS_MODE_SENSE		mode_sense;
	T_USBMS_MEDIA_REMOVAL	media_removal;
	T_USBMS_REQUEST_SENSE	request_sense;
	T_USBMS_TEST_UNIT_READY	test_unit_ready;
}T_USBMS_BOT_CDB;


typedef struct
{
	UINT8		device;									/** bits 0->5:device_type (0x0e), bits 6->8:qualifier*/
	UINT8		removable;								/** only the bit 0 is used*/
	UINT8		version;								/* Must be set to 0, because this device does not claim conformance to any standard	*/
	UINT8		rdf_hisup_naca;							/** bits 0->3: response data format; */
	UINT8		additionnal_length;						/* Must be set to : sizeof(T_INQUIRY_DATA)-5	*/
	UINT8		protect_tpc_alua_acc_sccs;				/** bits 0: protect ;	*/
														/** bits 3: tpc ;	*/
														/** bits 4->5: alua ;	*/

⌨️ 快捷键说明

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