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

📄 usb.h

📁 uCOS上移植的USB。今天终于可以使用我的了
💻 H
📖 第 1 页 / 共 2 页
字号:
    USHORT idVendor;
    USHORT idProduct;
    USHORT bcdDevice;
    UCHAR iManufacturer;
    UCHAR iProduct;
    UCHAR iSerialNumber;
    UCHAR bNumConfigurations;
} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;

typedef struct _USB_ENDPOINT_DESCRIPTOR 
{
    UCHAR bLength;
    UCHAR bDescriptorType;
    UCHAR bEndpointAddress;
    UCHAR bmAttributes;
    USHORT wMaxPacketSize;
    UCHAR bInterval;
} USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;

//
// values for bmAttributes Field in
// USB_CONFIGURATION_DESCRIPTOR
//

#define BUS_POWERED                           0x80
#define SELF_POWERED                          0x40
#define REMOTE_WAKEUP                         0x20

typedef struct _USB_CONFIGURATION_DESCRIPTOR 
{
    UCHAR bLength;
    UCHAR bDescriptorType;
    USHORT wTotalLength;
    UCHAR bNumInterfaces;
    UCHAR bConfigurationValue;
    UCHAR iConfiguration;
    UCHAR bmAttributes;
    UCHAR MaxPower;
} USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;

typedef struct _USB_INTERFACE_DESCRIPTOR 
{
    UCHAR bLength;
    UCHAR bDescriptorType;
    UCHAR bInterfaceNumber;
    UCHAR bAlternateSetting;
    UCHAR bNumEndpoints;
    UCHAR bInterfaceClass;
    UCHAR bInterfaceSubClass;
    UCHAR bInterfaceProtocol;
    UCHAR iInterface;
} USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;

typedef struct _USB_STRING_DESCRIPTOR 
{
    UCHAR bLength;
    UCHAR bDescriptorType;
    UCHAR bString[1];
} USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;

//
// USB power descriptor added to core specification
//

#define USB_SUPPORT_D0_COMMAND      0x01
#define USB_SUPPORT_D1_COMMAND      0x02
#define USB_SUPPORT_D2_COMMAND      0x04
#define USB_SUPPORT_D3_COMMAND      0x08

#define USB_SUPPORT_D1_WAKEUP       0x10
#define USB_SUPPORT_D2_WAKEUP       0x20


typedef struct _USB_POWER_DESCRIPTOR {
    UCHAR bLength;
    UCHAR bDescriptorType;
    UCHAR bCapabilitiesFlags;
    USHORT EventNotification;
    USHORT D1LatencyTime;
    USHORT D2LatencyTime;
    USHORT D3LatencyTime;
    UCHAR PowerUnit;
    USHORT D0PowerConsumption;
    USHORT D1PowerConsumption;
    USHORT D2PowerConsumption;
} USB_POWER_DESCRIPTOR, *PUSB_POWER_DESCRIPTOR;


typedef struct _USB_COMMON_DESCRIPTOR {
    UCHAR bLength;
    UCHAR bDescriptorType;
} USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;


//
// Standard USB HUB definitions 
//
// See Chapter 11
//

typedef struct _USB_HUB_DESCRIPTOR {
    UCHAR        bDescriptorLength;      // Length of this descriptor
    UCHAR        bDescriptorType;        // Hub configuration type
    UCHAR        bNumberOfPorts;         // number of ports on this hub
    USHORT       wHubCharacteristics;    // Hub Charateristics
    UCHAR        bPowerOnToPowerGood;    // port power on till power good in 2ms
    UCHAR        bHubControlCurrent;     // max current in mA
    //
    // room for 255 ports power control and removable bitmask
    UCHAR        bRemoveAndPowerMask[64];
} USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;


#endif   /* __USB100_H__ */





//#include "chap_9.h"
/*
   *************************************************************************
   
                     P H I L I P S   P R O P R I E T A R Y
   
              COPYRIGHT (c)   1997 BY PHILIPS SINGAPORE.
                        --  ALL RIGHTS RESERVED  --
   
    File Name:	CHAP_9.H
    Author:		Wenkai Du
    Created:		19 Dec 97
    Modified:
    Revision:		2.0
   
   *************************************************************************
   
   *************************************************************************
*/

#define NUM_ENDPOINTS	4

#define CONFIG_DESCRIPTOR_LENGTH    sizeof(USB_CONFIGURATION_DESCRIPTOR) \
									+ sizeof(USB_INTERFACE_DESCRIPTOR) \
									+ (NUM_ENDPOINTS * sizeof(USB_ENDPOINT_DESCRIPTOR))

 //CONTROL_XFER ControlData;
 //IO_REQUEST ioRequest;
 //EPPFLAGS bEPPflags;



#ifndef __CHAP_9_H__
#define __CHAP_9_H__

/*
   *************************************************************************
    USB Protocol Layer
   *************************************************************************
*/

/*
   *************************************************************************
    USB standard device requests
   *************************************************************************
*/
void get_status(void);
void clear_feature(void);
void set_feature(void);
void set_address(void);
void get_descriptor(void);
void get_configuration(void);
void set_configuration(void);
void get_interface(void);
void set_interface(void);

void reserved(void);

void control_handler(void);

#endif





#ifndef __PROTODMA_H__
#define __PROTODMA_H__

/*
   *************************************************************************
    USB vendor device requests
   *************************************************************************
*/

void read_write_register(void);

#endif




//#include "EPPHAL.H"


#ifndef __EPPHAL_H__
#define __EPPHAL_H__

	#define CPLD_CNT0 0x00
	#define CPLD_CNT1 0x01

	#define COUNT_L   0x00
	#define COUNT_H   0x00
	#define EPP_PORT  P1
	#define DATA_BUS  P0


/*	sbit MCU_SWM0     = P1^0;
	sbit MCU_SWM1     = P1^1;
	sbit MCU_LED0	  = P1^2;
	sbit MCU_LED1	  = P1^3;

	sbit MCU_D12CS	  = P1^6;
	sbit MCU_D12RST   = P1^7;


	sbit D12SUSPD	  = P3^3;  */
	

/*	#define DISABLE		cli();  \
				EIMSK&=0xFE; \
				EIFR=0x00;
	#define ENABLE		EIFR=0x00; \
	                        sei();  \
				EIMSK|=0x01;
*/
	#define DISABLE		cli(); 
	#define ENABLE		sei(); 				
//	#define DISABLE		SREG|=0<<7
//	#define ENABLE		SREG|=1<<7

#endif


//#include "ISR.h"


//#include "d12ci.h"
   #define D12_DATA    0xef02
#define D12_COMMAND   0xef03

#ifndef __D12CI_H__
#define __D12CI_H__

#define D12_NOLAZYCLOCK			0x02
#define D12_CLOCKRUNNING        0x04
#define D12_INTERRUPTMODE		0x08
#define D12_SOFTCONNECT			0x10
#define D12_ENDP_NONISO			0x00
#define D12_ENDP_ISOOUT			0x40
#define D12_ENDP_ISOIN			0x80
#define D12_ENDP_ISOIO			0xC0

#define D12_CLOCK_12M			0x03
#define D12_CLOCK_4M			0x0b
#define D12_SETTOONE            0x40
#define D12_SOFONLY				0x80

#define D12_DMASINGLE			0x00
#define D12_BURST_4				0x01
#define D12_BURST_8				0x02
#define D12_BURST_16			0x03
#define D12_DMAENABLE           0x04
#define D12_DMA_INTOKEN			0x08
#define D12_AUTOLOAD			0x10
#define D12_NORMALPLUSSOF		0x20
#define D12_ENDP4INTENABLE		0x40
#define D12_ENDP5INTENABLE		0x80	// bug fixed in V2.1

#define D12_INT_ENDP0OUT		0x01
#define D12_INT_ENDP0IN			0x02
#define D12_INT_ENDP1OUT		0x04
#define D12_INT_ENDP1IN			0x08
#define D12_INT_ENDP2OUT		0x10
#define D12_INT_ENDP2IN			0x20
#define D12_INT_BUSRESET		0x40
#define D12_INT_SUSPENDCHANGE	0x80
#define D12_INT_EOT				0x0100

#define D12_SETUPPACKET			0x20

#define D12_BUFFER0FULL			0x20
#define D12_BUFFER1FULL			0x40

#define D12_FULLEMPTY			0x01
#define D12_STALL				0x02

void D12_SetAddressEnable(unsigned char bAddress, unsigned char bEnable);
void D12_SetEndpointEnable(unsigned char bEnable);
void D12_SetMode(unsigned char bConfig, unsigned char bClkDiv);
void D12_SetDMA(unsigned char bMode);
unsigned char D12_GetDMA(void);
unsigned short D12_ReadInterruptRegister(void);
unsigned char D12_SelectEndpoint(unsigned char bEndp);
unsigned char D12_ReadLastTransactionStatus(unsigned char bEndp);
unsigned char D12_ReadEndpointStatus(unsigned char bEndp);
void D12_SetEndpointStatus(unsigned char bEndp, unsigned char bStalled);
void D12_SetBufEnable(void);
void D12_SendResume(void);
unsigned short D12_ReadCurrentFrameNumber(void);
unsigned short D12_ReadChipID(void);

unsigned char D12_ReadEndpoint(unsigned char endp, unsigned char len, unsigned char * buf);
unsigned char D12_WriteEndpoint(unsigned char endp, unsigned char len, unsigned char * buf);
void D12_AcknowledgeEndpoint(unsigned char endp);

unsigned char D12_ReadMainEndpoint(unsigned char * buf); // V2.2

unsigned char D12Eval_inportb(void);
void D12Eval_outportb(unsigned char val, unsigned char mask);

#endif




⌨️ 快捷键说明

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