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

📄 d12_define.h

📁 c51单片机+pdiusbd12芯片的假u盘设计
💻 H
字号:
#ifndef _D12_Define_
#define _D12_Define_

#include <reg52.h>
//D12控制线定义
sbit		D12_A0	=	P0^0;
#define 	D12_WR		WR
#define 	D12_RD		RD
#define 	D12_Data	P1
//D12控制线定义

#define SWAP(A)	(((uint16)A<<8)|((uint16)A>>8))
#define LSB(B)	((uchar)((uint16)B))
#define MSB(C)	((uchar)((uint16)C>>8))
#define DSWAP(E) (((E)>>24)|(((E)>>8)&0x0000ff00)|(((E)<<8)&0x00ff0000)|((E)<<24))
#define MMSB(D) ((uchar)((uint16)(D>>12)))
//软件标志位


//变量全局
extern uint16 Interrupter_register;
extern uchar Interrupter;
extern uchar idata Max_Lun;
extern unsigned long int wLength;
extern unsigned long int wCount;
extern unsigned long int * lpData;
extern uchar idata SD_Buffer[103];













typedef struct _SOFT_FLAG
{
	uchar Enable_Control_In	:1;	
	uchar TxtoPc				:1;
	uchar PctoTx				:1;
	uchar Not_End				:1;
	uchar Allow_Main_In			:1;
	uchar Enp4					:1;
	uchar Enp5					:1;
	uchar success				:1;
	uchar Data					:1;
}SOFT_FLAG;
extern	SOFT_FLAG idata Soft_Flag;

////////////////////////////

//宏定义
#define set_address	0xd0
#define enable_enp	0xd8
#define set_mode	0xf3
#define read_interrupter_register 0xf4
//中断寄存器掩码
#define Control_Out	0x0100
#define Control_In	0x0200
#define Enp1_Out	0x0400
#define Enp1_In		0x0800
#define Main_Out	0x1000
#define Main_In		0x2000
#define Bus_Reset	0x4000
#define Suspend_Change	0x8000
#define DMA_EOT		0x0001
//中断寄存器掩码

//选择端点掩码
#define Enp_Stop	0x02
#define Enp_Full_Empty 0x01
//选择端点掩码

//端点状态掩码
 
//端点状态掩码

//端点最后处理状态掩码
#define Setup_Pack	0x20
//端点最后处理状态掩码
#define Stand_Request 0x00
#define Class_Request 0x20
#define Mask		  0x60








//标准请求的结构体
typedef struct _DEVICE_REQUEST
{
	uchar bmRequestType;
	uchar bRequest;
	uint16 wValue;
	uint16 wIndex;
	uint16 wLength;
}DEVICE_REQUEST;

typedef struct _DEVICE_REQUEST_BUFFER
{
	DEVICE_REQUEST Device_Request;
	uchar wLength;
	uchar wCount;
	uchar *pData;
}DEVICE_REQUEST_BUFFER;
extern DEVICE_REQUEST_BUFFER idata Device_Request_Buffer;

typedef struct _DEVICE_DESCRIPTOR
{
	uchar bLength;
	uchar bDescriptorType;
	uint16 bcdUSB;
	uchar bDeviceClass;
	uchar bDeviceSubClass;
	uchar bDeviceProtocol;
	uchar bMaxPackSize0;
	uint16 idVendor;
	uint16 idProduct;
	uint16 bcdDevice;
	uchar iManufacturer;
	uchar iProduct;
	uchar iSeriaNumber;
	uchar bNumConfiguations;
}DEVICE_DESCRIPTOR; 

typedef struct _CONFIGURATION_DESCRIPTOR
{
	uchar bLength;
	uchar bDescriptorType;
	uint16 wTotalLength;
	uchar bNumInterfaces;
	uchar bConfigurationValue;
	uchar iConfiguration;
	uchar bmAttributes;
	uchar ManPower;
}CONFIGURATION_DESCRIPTOR;

typedef struct _INTERFACE_DESCRIPTOR
{
	uchar bLength;
	uchar bDescriptorType;
	uchar bInterfaceNumber;
	uchar bAlternateSetting;
	uchar bNumberEndpoint;
	uchar bInterfaceClass;
	uchar bInterfaceSubClass;
	uchar bInterfaceProtocol;
	uchar iInterface;
}INTERFACE_DESCRIPTOR;

typedef struct _ENDP_DESCRIPTOR
{
	uchar bLength;
	uchar bDescriptorType;
	uchar bEndpointAddress;
	uchar bmAttributes;
	uint16 wMaxPacketSize;
	uchar bInterval;	
}ENDP_DESCRIPTOR;

typedef struct _CON_INTER_ENDP_DESCRIPTOR
{
	CONFIGURATION_DESCRIPTOR Configuration_Descriptor;
	INTERFACE_DESCRIPTOR	 Interface_Descriptor;
	ENDP_DESCRIPTOR Endp_Descriptor[2];	
}CON_INTER_ENDP_DESCRIPTOR;	


typedef struct _CBWCB
{
	uchar Operation_Code;
	uchar Logical_Unit_Number;
	unsigned long int LBA;
	unsigned long int TPA_Length;
	uchar Reserved;
	uchar Control;
}CBWCB;

typedef struct _CBW
{
	unsigned long int dCBWSignature;
	unsigned long int dCBWTag;
	unsigned long int dCBWDataTransferLength;
	uchar bmCBWFlags;
	uchar bCBWLUN;
	uchar bCBWCBLength;
	CBWCB cbwcb;
	uchar :8;
	uchar :8;
	uchar :8;	
	uchar :8;
}CBW;
extern CBW cbw;

typedef struct _CSW
{
	unsigned long int dCSWSignature;
	unsigned long int dCSWTag;
	unsigned long int dCSWDataResidue;
	uchar bCSWStatus;	 
}CSW;
extern CSW csw;

















#endif

⌨️ 快捷键说明

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