📄 usbch9.h
字号:
/*
* usbch9.h
*
* Def's for USB device communications stack - "Standard Request" layer,
* conforming to USB 2.0 specification, Chapter 9.
*
* Adapted from Philips PDIUSBD12 firmware library (CHAP_9.H)
* MJB Nov.2005
*/
#ifndef __CHAP_9_H__
#define __CHAP_9_H__
#include "gendef.h"
#include "usbdef.h"
/***
#define Wakeup_from_Suspend_flag 0xC3
***/
#define NUMBER_STD_REQ 13
#define NUMBER_VENDOR_REQ 16
typedef struct PACKED_USB_CONFIG_DESCR_T
{
uchar bLength0;
uchar bDescriptorType0;
ushort wTotalLength0;
uchar bNumInterfaces0;
uchar bConfigurationValue0;
uchar iConfiguration0;
uchar bmAttributes0;
uchar MaxPower0;
uchar bLength1;
uchar bDescriptorType1;
uchar bInterfaceNumber1;
uchar bAlternateSetting1;
uchar bNumEndpoints1;
uchar bInterfaceClass1;
uchar bInterfaceSubClass1;
uchar bInterfaceProtocol1;
uchar iInterface1;
uchar bLength2;
uchar bDescriptorType2;
uchar bEndpointAddress2;
uchar bmAttributes2;
uchar bMaxPacketSizeLo2;
uchar bMaxPacketSizeHi2;
uchar bInterval2;
uchar bLength3;
uchar bDescriptorType3;
uchar bEndpointAddress3;
uchar bmAttributes3;
uchar bMaxPacketSizeLo3;
uchar bMaxPacketSizeHi3;
uchar bInterval3;
uchar bLength4;
uchar bDescriptorType4;
uchar bEndpointAddress4;
uchar bmAttributes4;
uchar bMaxPacketSizeLo4;
uchar bMaxPacketSizeHi4;
uchar bInterval4;
} PACKED_USB_CONFIG_DESCR;
/**************
* String Descriptors... redefine to suit device application.
*/
#define UNICODE_LANGUAGE_STR_ID (0) /* Index values */
#define MANUFACTURER_STR_ID (1)
#define PRODUCT_NAME_STR_ID (2)
#define SERIAL_NUM_STR_ID (3)
#define UNICODE_ENGLISH (0x0409) /* US_English (Ref: USB_LANGIDs.pdf) */
struct USB_STRING_DESCR_LANG
{
uchar bLength; /* Size of descriptor */
uchar bDescrType; /* Type of descriptor (ie. STRING) */
ushort wLangID; /* Language code (16b word) */
};
struct USB_STRING_DESCR_MANU
{
uchar bLength; /* Size of descriptor */
uchar bDescrType; /* Type of descriptor (ie. STRING) */
uchar bString[16]; /* UNICODE string [chars X2] */
};
struct USB_STRING_DESCR_PROD
{
uchar bLength; /* Size of descriptor */
uchar bDescrType; /* Type of descriptor (ie. STRING) */
uchar bString[16]; /* UNICODE string [chars X2] */
};
struct USB_STRING_DESCR_SNUM
{
uchar bLength; /* Size of descriptor */
uchar bDescrType; /* Type of descriptor (ie. STRING) */
uchar bString[16]; /* UNICODE string [chars X2] */
};
/***********
* Control endpoint packet structures
*/
typedef struct _device_request
{
uchar bmRequestType;
uchar bRequest;
ushort wValue;
ushort wIndex;
ushort wLength;
} DEVICE_REQUEST;
#define MAX_CONTROLDATA_SIZE 16
typedef struct _control_xfer
{
DEVICE_REQUEST DeviceRequest;
ushort wLength; /* Transfer size (from last Rx'd device request) */
ushort wCount; /* Bytes sent/rec'd so far in current transfer */
uchar * pData; /* Pointer to source data for TX transfer (Ctrl IN) */
uchar dataBuffer[MAX_CONTROLDATA_SIZE]; /* Buffer for RX data transsfer (Ctrl OUT) */
} CONTROL_XFER;
extern CONTROL_XFER ControlData;
/************************************************************************** */
/* USB standard device requests */
/************************************************************************** */
extern const pfnvoid StandardDeviceRequest[];
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 req_undefined( void );
/************************************************************************** */
/* USB utility functions */
/************************************************************************** */
void stall_ep0(void);
void USB_init(void);
void disconnect_USB(void);
void connect_USB(void);
void reconnect_USB(void);
void maintain_usb_connection( void );
void configure_device(void);
void unconfigure_device(void);
void single_transmit(uchar * buf, uchar len);
void control_transmit(const uchar * pRomData, ushort len);
ulong LittleEndianToLong( uchar * pSource );
void toLittleEndian( ulong value, uchar * pDestin );
#endif /* __CHAP_9_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -