📄 obj_usbdesc.h
字号:
//*----------------------------------------------------------------------------//* ATMEL Microcontroller Software Support - ROUSSET -//*----------------------------------------------------------------------------//* The software is delivered "AS IS" without warranty or condition of any//* kind, either express, implied or statutory. This includes without//* limitation any warranty or condition with respect to merchantability or//* fitness for any particular purpose, or against the infringements of//* intellectual property rights of others.//*----------------------------------------------------------------------------//* File Name : obj_udpdesc.h//* Object : USB peripheral library.//*//* 1.0 Sept 3rd 01 ODi : Creation//*----------------------------------------------------------------------------#ifndef obj_usbdesc_h#define obj_usbdesc_h#include "periph/udp/lib_udp.h"/* *********************************************************************** *//* Following definitions corresponds to the USB specification Rev. 1.1 *//* They are used during the USB enumeration *//* *********************************************************************** *//* USB standard request code */#define USB_GET_STATUS 0#define USB_CLEAR_FEATURE 1#define USB_SET_FEATURE 3#define USB_SET_ADDRESS 5#define USB_GET_DESCRIPTOR 6#define USB_SET_DESCRIPTOR 7#define USB_GET_CONFIGURATION 8#define USB_SET_CONFIGURATION 9#define USB_GET_INTERFACE 10#define USB_SET_INTERFACE 11#define USB_SYNCH_FRAME 12/* USB descriptor types */#define USB_DEVICE 1#define USB_CONFIGURATION 2#define USB_STRING 3#define USB_INTERFACE 4#define USB_ENDPOINT 5/* USB standard feature selectors */#define USB_DEVICE_REMOTE_WAKEUP 1#define USB_ENDPOINT_HALT 0/*---------------------------*//* USB Setup Data *//*---------------------------*/typedef struct _AT91S_UsbSetup { char bmRequestType; /* Characteristics of request */ char bRequest; /* Specific request */ short wValue; /* Word-sized field */ short wIndex; /* Word-sized field; used to pass an index or an offset */ short wLength; /* Number of bytes to transfert */} AT91S_UsbSetup, *AT91PS_UsbSetup;/*-------------------------------------------*//* USB Standard device descriptor *//*-------------------------------------------*/typedef __packed struct _AT91S_UsbDevice { char bLength; /* Size of this descriptor */ char bDescriptorType; /* DEVICE descriptor type */ short bcdUSB; /* USB Specification release Number */ char bDeviceClass; /* Class code (assigned by the USB) */ char bDeviceSubClass; /* Subclass code (assigned by the USB) */ char bDeviceProtocol; /* Protool code (assigned by the USB) */ char bMaxPacketSize0; /* Maximum packet size for endpoint 0 */ short idVendor; /* Vendor ID */ short idProduct; /* Product ID */ short bcdDevice; /* Device release number */ char iManufacturer; /* Index of string descriptor describing manufacturer*/ char iProduct; /* Index of string descriptor describing the product */ char iSerialNumber; /* Index of string descriptor describing the device's serial number */ char bNumConfigurations; /* Number of possible configurations */} AT91S_UsbDevice, *AT91PS_UsbDevice;/*-------------------------------------------*//* USB Standard configuration descriptor *//*-------------------------------------------*/typedef __packed struct _AT91S_UsbConfiguration { char bLength; /* Size of this descriptor */ char bDescriptorType; /* CONFIGURATION descriptor type */ short wTotalLength; /* Total length of data returned for this configuration */ char bNumInterfaces; /* Number of interfaces supported by this configuration */ char bConfigurationValue; /* Value to use as an argument to the set configuration() request */ char iConfiguration; /* Index of string descriptor describing this configuration */ char bmAttributes; /* Configuration characteristics */ char MaxPower; /* Maximum Power consumption */} AT91S_UsbConfiguration, *AT91PS_UsbConfiguration;__inline u_short wTotalLength(char const *pCfg) { return ((pCfg[3] << 8) | pCfg[2]); }/*---------------------------------------*//* USB Standard interface descriptor *//*---------------------------------------*/typedef __packed struct _AT91S_UsbInterface { char bLength; /* Size of this descriptor */ char bDescriptorType; /* INTERFACE descriptor type */ char bInterfaceNumber; /* Number of interface */ char bAlternateSetting; /* Number of interfaces supported by this configuration */ char bNumEndpoints; /* Number of endpoints used by this interface */ char bInterfaceClass; /* Class code */ char bInterfaceSubClass; /* Subclass code */ char bInterfaceProtocol; /* Protocol code */ char iInterface; /* Index of string descriptor describing this interface */} AT91S_UsbInterface, *AT91PS_UsbInterface;/*--------------------------------------*//* USB Standard endpoint descriptor *//*--------------------------------------*/typedef __packed struct _AT91S_UsbEndpoint { char bLength; /* Size of this descriptor */ char bDescriptorType; /* ENDP諭NT descriptor type */ char bEndpointAddress; /* Address of the endpoint on the USB device described by this descriptor */ char bmAttributes; /* Bitmap */ short wMaxPacketSize; /* Maximum packet size this endpoint is capable of sending or receiving */ char bInterval; /* Interval for polling endpoint for data transfers */} AT91S_UsbEndpoint, *AT91PS_UsbEndpoint;__inline char bEndpointAddress(char const *pEp) { return (pEp[2] & 0x0F); }__inline unsigned short wMaxPacketSize (char const *pEp) { return ((pEp[5] << 8) | pEp[4]); }/*------------------------------------------*//* USB Standard UNICODE string descriptor *//*-----------------------------------------*/typedef __packed struct _AT91S_UsbString { char bLength; /* Size of this descriptor */ char bDescriptorType; /* STRING descriptor type */ char *bString; /* UNICODE encoded string */} AT91S_UsbString, *AT91PS_UsbString;/* *********************************************************************** *//* Following structure must be defined by the application *//* Each pointer to function corresponds to standard request from the host *//* defined by the USB spec. Rev. 1.1 *//* *//* If the request is not supported, the field must be set to 0. A STALL *//* handshake will be initialized with the host. *//* *********************************************************************** */typedef struct _AT91S_UsbDesc {/* Following function is the entry point for the application */ void (*DispatchRequest) ( struct _AT91S_UsbDesc *pUsbDesc, /* Pointer to this structure */ AT91PS_UsbSetup pSetup); /* Descriptor type *//* ======================================================================= *//* Following functions are called by usbDispatchRequest() if a class or a *//* vendor request has been detected *//* ======================================================================= */ void (*DispatchClassRequest) ( AT91PS_UsbSetup pSetup, /* Descriptor type */ void *pPrivateClassData); /* Pointer to private datas */ void (*DispatchVendorRequest) ( AT91PS_UsbSetup pSetup, /* Descriptor type */ void *pPrivateVendorData); /* Pointer to private datas *//* ======================================================================= *//* Following functions are called after the request has been checked *//* according to the USB macro status *//* ======================================================================= */ void (*ClearFeature) (
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -