[tuxdroid-svn] r1034 - in firmware/fuxusb/branches/HID: . modules/usb_enum
Status: Beta
Brought to you by:
ks156
From: Paul_R <c2m...@c2...> - 2008-04-30 13:12:11
|
Author: Paul_R Date: 2008-04-30 10:19:03 +0200 (Wed, 30 Apr 2008) New Revision: 1034 Modified: firmware/fuxusb/branches/HID/config.h firmware/fuxusb/branches/HID/modules/usb_enum/USB_ENUM.H firmware/fuxusb/branches/HID/modules/usb_enum/usb_enum.c Log: * Changed the interface3 from a vendor-specific class to a HID class. The HID report descriptor defines 1 collection (app) with 2 usages : Usage1 : Vendor defined / input / logical : 0..255 / 8bits\data / 64bytes\frames. Usage2 : Vendor defined / output / logical : 0..255 / 8bits\data / 5 bytes\frames. Added 3 functions for the HID class-specific requests. (set_report, set_idle, get_idle). Modified: firmware/fuxusb/branches/HID/config.h =================================================================== --- firmware/fuxusb/branches/HID/config.h 2008-04-30 08:01:05 UTC (rev 1033) +++ firmware/fuxusb/branches/HID/config.h 2008-04-30 08:19:03 UTC (rev 1034) @@ -81,10 +81,10 @@ /* CONFIGURATION DESCRIPTOR */ #ifdef TTS_INTERFACE_ENABLED -# define CONF_LENGTH 0x2001 // 288 +# define CONF_LENGTH 0x2901 // 297 # define NB_INTERFACE 6 #else -# define CONF_LENGTH 0xC500 // 197 +# define CONF_LENGTH 0xCE00 // 206 # define NB_INTERFACE 4 #endif @@ -130,12 +130,10 @@ #define USB_SERIAL_NUMBER {'1'<<8, '0'<<8, '0'<<8, '0'<<8, '1'<<8} #define USB_SN_LENGTH 5 - #define USB_CONFIG_NAME {'T'<<8, 'u'<<8, 'x'<<8, 'D'<<8, \ 'r'<<8, 'o'<<8, 'i'<<8, 'd'<<8} #define USB_CONFIG_LENGTH 8 - #define AUDIO_NORMAL_NAME {'T'<<8, 'u'<<8, 'x'<<8, 'D'<<8, \ 'r'<<8, 'o'<<8, 'i'<<8, 'd'<<8, '-'<<8, 'A'<<8, 'u'<<8, 'd'<<8, \ 'i'<<8, 'o'<<8} Modified: firmware/fuxusb/branches/HID/modules/usb_enum/USB_ENUM.H =================================================================== --- firmware/fuxusb/branches/HID/modules/usb_enum/USB_ENUM.H 2008-04-30 08:01:05 UTC (rev 1033) +++ firmware/fuxusb/branches/HID/modules/usb_enum/USB_ENUM.H 2008-04-30 08:19:03 UTC (rev 1034) @@ -1,461 +1,480 @@ -/*H************************************************************************** - * NAME: usb_cdc_enum.h - *---------------------------------------------------------------------------- - * Copyright (c) 2004 Atmel. - *---------------------------------------------------------------------------- - * RELEASE: c5131-usb-cdc-1_0_2 - * REVISION: 1.2 - *---------------------------------------------------------------------------- - * PURPOSE: - * This file contains the USB task definition - *****************************************************************************/ - -#ifndef _USB_ENUM_H_ -#define _USB_ENUM_H_ - -/*_____ I N C L U D E S ____________________________________________________*/ - - -/*_____ M A C R O S ________________________________________________________*/ - - - - -/*_____ S T A N D A R D R E Q U E S T S ______bRequest____________________*/ - -#define GET_STATUS 0x00 -#define GET_DEVICE 0x01 -#define CLEAR_FEATURE 0x01 /* see FEATURES below */ -#define GET_STRING 0x03 -#define SET_FEATURE 0x03 /* see FEATURES below */ -#define SET_ADDRESS 0x05 -#define GET_DESCRIPTOR 0x06 -#define SET_DESCRIPTOR 0x07 -#define GET_CONFIGURATION 0x08 -#define SET_CONFIGURATION 0x09 -#define GET_INTERFACE 0x0A -#define SET_INTERFACE 0x0B -#define SYNCH_FRAME 0x0C - -/*_____ A U D I O C L A S S R E Q U E S T S_____________________________*/ - -#define SET_CURRENT 0x01 -#define SET_MIN 0x02 -#define SET_MAX 0x03 -#define SET_RES 0x04 - -#define GET_CURRENT 0x81 -#define GET_MIN 0x82 -#define GET_MAX 0x83 -#define GET_RES 0x84 - - -#define GET_DEVICE_DESCRIPTOR 1 -#define GET_CONFIGURATION_DESCRIPTOR 4 - -/* CDC specific */ -#define GET_LINE_CODING 0x21 -#define SET_LINE_CODING 0x20 -#define SET_CONTROL_LINE_STATE 0x22 -#define SEND_BREAK 0x23 -#define SEND_ENCAPSULATED_COMMAND 0x00 -#define GET_ENCAPSULATED_COMMAND 0x01 -/* *** */ - -#define REQUEST_DEVICE_STATUS 0x80 -#define REQUEST_INTERFACE_STATUS 0x81 -#define REQUEST_ENDPOINT_STATUS 0x82 - -#define ZERO_TYPE 0x00 -#define INTERFACE_TYPE 0x01 -#define ENDPOINT_TYPE 0x02 - -/*_____ D E S C R I P T O R T Y P E S ____________________________________*/ - -#define DEVICE 0x01 -#define CONFIGURATION 0x02 -#define STRING 0x03 -#define INTERFACE 0x04 -#define ENDPOINT 0x05 - - -/*_____ S T A N D A R D F E A T U R E S __________________________________*/ - -#define DEVICE_REMOTE_WAKEUP_FEATURE 0x01 -#define ENDPOINT_HALT_FEATURE 0x00 - -/*_____ D E V I C E S T A T U S ___________________________________________*/ - -#define SELF_POWERED 1 - -/*_____ D E V I C E S T A T E _____________________________________________*/ - -#define ATTACHED 0 -#define POWERED 1 -#define DEFAULT 2 -#define ADDRESSED 3 -#define CONFIGURED 4 -#define SUSPENDED 5 - -#define USB_CONFIG_BUSPOWERED 0x80 -#define USB_CONFIG_SELFPOWERED 0x40 -#define USB_CONFIG_REMOTEWAKEUP 0x20 - -/*_____ E N D P O I N T _____________________________________________*/ - -#define OUT_ENDPOINT1 0x01 -#define OUT_ENDPOINT2 0x02 -#define OUT_ENDPOINT3 0x03 -#define OUT_ENDPOINT4 0x04 -#define OUT_ENDPOINT5 0x05 -#define OUT_ENDPOINT6 0x06 - -#define IN_ENDPOINT1 0x81 -#define IN_ENDPOINT2 0x82 -#define IN_ENDPOINT3 0x83 -#define IN_ENDPOINT4 0x84 -#define IN_ENDPOINT5 0x85 -#define IN_ENDPOINT6 0x86 - -/*_________________________________________________________ S T R U C T _____*/ -/*_____ U S B D E V I C E R E Q U E S T _________________________________*/ -struct Endpoint_information_st -{ - Uint16 fifo_size ; /* size of the endpoint FIFO */ - Uint16 fifo_left ; -}; - -struct USB_request_st -{ - Uchar bmRequestType; /* Characteristics of the request */ - Uchar bRequest; /* Specific request */ - Uint16 wValue; /* field that varies according to request */ - Uint16 wIndex; /* field that varies according to request */ - Uint16 wLength; /* Number of bytes to transfer if Data */ -}; - - -/*_____ U S B D E V I C E D E S C R I P T O R ___________________________*/ - -struct usb_st_device_descriptor -{ - Uchar bLength; /* Size of this descriptor in bytes */ - Uchar bDescriptorType; /* DEVICE descriptor type */ - Uint16 bscUSB; /* Binay Coded Decimal Spec. release */ - Uchar bDeviceClass; /* Class code assigned by the USB */ - Uchar bDeviceSubClass; /* Sub-class code assigned by the USB */ - Uchar bDeviceProtocol; /* Protocol code assigned by the USB */ - Uchar bMaxPacketSize0; /* Max packet size for EP0 */ - Uint16 idVendor; /* Vendor ID. ATMEL = 0x03EB */ - Uint16 idProduct; /* Product ID assigned by the manufacturer */ - Uint16 bcdDevice; /* Device release number */ - Uchar iManufacturer; /* Index of manu. string descriptor */ - Uchar iProduct; /* Index of prod. string descriptor */ - Uchar iSerialNumber; /* Index of S.N. string descriptor */ - Uchar bNumConfigurations; /* Number of possible configurations */ -}; - - -/*_____ U S B C O N F I G U R A T I O N D E S C R I P T O R _____________*/ - -struct usb_st_configuration_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* CONFIGURATION descriptor type */ - Uint16 wTotalLength; /* total length of data returned */ - Uchar bNumInterfaces; /* number of interfaces for this conf. */ - Uchar bConfigurationValue; /* value for SetConfiguration resquest */ - Uchar iConfiguration; /* index of string descriptor */ - Uchar bmAttibutes; /* Configuration characteristics */ - Uchar MaxPower; /* maximum power consumption */ -}; - - -/*_____ U S B I N T E R F A C E D E S C R I P T O R _____________________*/ - -struct usb_st_interface_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bInterfaceNumber; /* Number of interface */ - Uchar bAlternateSetting; /* value to select alternate setting */ - Uchar bNumEndpoints; /* Number of EP except EP 0 */ - Uchar bInterfaceClass; /* Class code assigned by the USB */ - Uchar bInterfaceSubClass; /* Sub-class code assigned by the USB */ - Uchar bInterfaceProtocol; /* Protocol code assigned by the USB */ - Uchar iInterface; /* Index of string descriptor */ -}; - -/*_____ U S B E N D P O I N T D E S C R I P T O R _______________________*/ - -struct usb_st_endpoint_descriptor -{ - Uchar bLength; /* Size of this descriptor in bytes */ - Uchar bDescriptorType; /* ENDPOINT descriptor type */ - Uchar bEndpointAddress; /* Address of the endpoint */ - Uchar bmAttributes; /* Endpoint's attributes */ - Uint16 wMaxPacketSize; /* Maximum packet size for this EP */ - Uchar bInterval; /* Interval for polling EP in ms */ -}; - - -/*_____ U S B M A N U F A C T U R E R D E S C R I P T O R _______________*/ - -struct usb_st_manufacturer -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[USB_MN_LENGTH];/* unicode characters */ -}; - - -/*_____ U S B P R O D U C T D E S C R I P T O R _________________________*/ - -struct usb_st_product -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[USB_PN_LENGTH];/* unicode characters */ -}; - - -/*_____ U S B S E R I A L N U M B E R D E S C R I P T O R _____________*/ - -struct usb_st_serial_number -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[USB_SN_LENGTH];/* unicode characters */ -}; - -/*_____ U S B C O N F I G D E S C R I P T O R _________________________*/ - -struct usb_st_config -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[USB_CONFIG_LENGTH];/* unicode characters */ -}; - -/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/ - -struct usb_st_language_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[USB_CONFIG_LENGTH]; /* language id */ -}; - - -/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/ - -struct usb_st_speaker_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[AUDIO_SPEAKER_LENGTH]; /* language id */ -}; - -/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/ - -struct usb_st_micro_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[AUDIO_MICRO_LENGTH]; /* language id */ -}; - -/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/ - -struct usb_st_tts_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[AUDIO_TTS_LENGTH]; /* language id */ /* language id */ -}; - - -struct usb_st_audio_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* STRING descriptor type */ - Uint16 wstring[AUDIO_NORMAL_LENGTH]; /* language id */ /* language id */ -}; - - -/* HID specific */ -/*_____ U S B H I D D E S C R I P T O R __________________________________*/ - -struct usb_st_hid_descriptor -{ - Uchar bLength; /* Size of this descriptor in bytes */ - Uchar bDescriptorType; /* HID descriptor type */ - Uint16 bscHID; /* Binay Coded Decimal Spec. release */ - Uchar bCountryCode; /* Hardware target country */ - Uchar bNumDescriptors; /* Number of HID class descriptors to follow */ - Uchar bRDescriptorType; /* Report descriptor type */ - Uint16 wDescriptorLength; /* Total length of Report descriptor */ -}; - -/* Audio Class specific */ - -/*_____ U S B S T D AUDIO CONTROL I N T E R F A C E D E S C R I P T O R _____________________*/ - -struct usb_Audio_st_ACinterface_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bInterfaceNumber; /* Number of interface */ - Uchar bAlternateSetting; /* value to select alternate setting */ - Uchar bNumEndpoints; /* Number of EP except EP 0 */ - Uchar bInterfaceClass; /* Class code assigned by the USB */ - Uchar bInterfaceSubClass; /* Sub-class code assigned by the USB */ - Uchar bInterfaceProtocol; /* Protocol code assigned by the USB */ - Uchar iInterface; /* Index of string descriptor */ -}; - -/*_____ U S B C S AUDIO CONTROL I N T E R F A C E D E S C R I P T O R _____________________*/ - -struct usb_Audio_cs_ACinterface_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ - Uint16 bcdADC; /* Audio Device Class Specification Release Number in Binary-Coded Decimal */ - Uint16 wTotalLength; /* Total number of bytes returned for the class-specific AudioControl interface descriptor */ - Uchar bInCollection; /* Number of EP except EP 0 */ - Uchar baInterfaceNr[2]; /* Class code assigned by the USB */ -}; - -struct usb_Audio_cs_ACinterface_descriptor_NbCol1 -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ - Uint16 bcdADC; /* Audio Device Class Specification Release Number in Binary-Coded Decimal */ - Uint16 wTotalLength; /* Total number of bytes returned for the class-specific AudioControl interface descriptor */ - Uchar bInCollection; /* Number of EP except EP 0 */ - Uchar baInterfaceNr[1]; /* Class code assigned by the USB */ -}; - -/*_____ U S B I N P U T T E R M I N A L D E S C R I P T O R ___________________________*/ - -struct usb_Audio_InputTerminal_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ - Uchar bTerminalID; /* CConstant characterizing the type of Termina*/ - Uint16 wTerminalType; /* Constant characterizing the type of Terminal.*/ - Uchar bAssocTerminal; /* ID of the Output Terminal to which this Input Terminal is associated */ - Uchar bNrChannels; /* Number of logical output channels in the Terminals output audio channel cluster. */ - Uint16 wChannelConfig; /* Describes the spatial location of the logical channels.*/ - Uchar iChannelNames; /*Index of a string descriptor, describing the name of the first logical channel */ - Uchar iTerminal; /*Index of a string descriptor, describing the Input Terminal. */ -}; - -/*_____ U S B O U T P U T T E R M I N A L D E S C R I P T O R ___________________________*/ - -struct usb_Audio_OutputTerminal_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ - Uchar bTerminalID; /* CConstant characterizing the type of Termina*/ - Uint16 wTerminalType; /* Constant characterizing the type of Terminal.*/ - Uchar bAssocTerminal; /* ID of the Output Terminal to which this Input Terminal is associated */ - Uchar bSourceID; /*ID of the Unit or Terminal to which this Terminal is connected */ - Uchar iTerminal; /*Index of a string descriptor, describing the Input Terminal. */ -}; - -/*_____ U S B F E A T U R E U N I T D E S C R I P T O R ___________________________*/ - -struct usb_Audio_FeatureUnit_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ - Uchar bUnitID; /* Constant uniquely identifying the Unit within the audio function.*/ - Uchar bSourceID; /* Constant characterizing the type of Terminal.*/ - Uchar bControlSize; /* Size in bytes of an element of the bmaControls() array: n*/ - Uchar bmaControls[2]; /*ID of the Unit or Terminal to which this Terminal is connected */ - Uchar iFeature; /*Index of a string descriptor, describing this Feature Unit.. */ -}; - -/*_____ U S B S T D AUDIO STREAM I N T E R F A C E D E S C R I P T O R _____________________*/ - -struct usb_Audio_st_ASinterface_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bInterfaceNumber; /* Number of interface */ - Uchar bAlternateSetting; /* value to select alternate setting */ - Uchar bNumEndpoints; /* Number of EP except EP 0 */ - Uchar bInterfaceClass; /* Class code assigned by the USB */ - Uchar bInterfaceSubClass; /* Sub-class code assigned by the USB */ - Uchar bInterfaceProtocol; /* Protocol code assigned by the USB */ - Uchar iInterface; /* Index of string descriptor */ -}; - -/*_____ U S B C S AUDIO STREAM I N T E R F A C E D E S C R I P T O R _____________________*/ - -struct usb_Audio_cs_ASinterface_descriptor -{ - Uchar bLength; /* size of this descriptor in bytes */ - Uchar bDescriptorType; /* INTERFACE descriptor type */ - Uchar bDescriptorSubtype; /* AS_GENERAL descriptor subtype.*/ - Uchar bTerminalLink; /* The Terminal ID of the Terminal to which the endpoint of this interface is connected.*/ - Uchar bDelay; /* Delay (d) introduced by the data path */ - Uint16 wFormatTag; /* Class code assigned by the USB */ -}; - -/*_____ U S B AUDIO ST E N D P O I N T D E S C R I P T O R _______________________*/ - -struct usb_Audio_st_endpoint_descriptor -{ - Uchar bLength; /* Size of this descriptor in bytes */ - Uchar bDescriptorType; /* ENDPOINT descriptor type */ - Uchar bEndpointAddress; /* Address of the endpoint */ - Uchar bmAttributes; /* Endpoint's attributes */ - Uint16 wMaxPacketSize; /* Maximum packet size for this EP */ - Uchar bInterval; /* Interval for polling EP in ms */ - Uchar bRefresh; /* Reset to 0.*/ - Uchar bSynchAddress; /* The address of the endpoint used to communicate synchronization information if required by this endpoint..*/ -}; - -/*_____ U S B AUDIO S T E N D P O I N T D E S C R I P T O R _______________________*/ - -struct usb_Audio_cs_ASendpoint_descriptor -{ - Uchar bLength; /* Size of this descriptor in bytes */ - Uchar bDescriptorType; /* ENDPOINT descriptor type */ - Uchar bDescriptorSubtype; /* EP_GENERAL descriptor subtype. */ - Uchar bmAttributes; /* Endpoint's attributes */ - Uchar bLockDelayUnits; /*Indicates the units used for the wLockDelay field:*/ - Uint16 wLockDelay; /* Reset to 0.*/ -}; - -/*_____ U S B AUDIO S T E N D P O I N T D E S C R I P T O R _______________________*/ - -struct usb_Audio_TYPEI_FormatType_descriptor -{ - Uchar bLength; /* Size of this descriptor in bytes */ - Uchar bDescriptorType; /* ENDPOINT descriptor type */ - Uchar bDescriptorSubtype; /* EP_GENERAL descriptor subtype. */ - Uchar bFormatType; /* FORMAT_TYPE_I. Constant identifying the Format Type the AudioStreaming interface is using.*/ - Uchar bNrChannels; /*Indicates the number of physical channels in the audio data stream.:*/ - Uchar bSubframeSize; /* The number of bytes occupied by one audio subframe. Can be 1, 2, 3 or 4.*/ - Uchar bBitResolution; /* The number of effectively used bits from the available bits in an audio subframe.*/ - Uchar bSamFreqType; /*Indicates how the sampling frequency can be programmed */ - Uchar bSamFreqTbl[3]; /*See sampling frequency tables*/ -}; - -/*_____ D E C L A R A T I O N ______________________________________________*/ - - -void usb_var_init(void); -void usb_ep_init(void); -void usb_enumeration_process(void); - - -#endif /* _USB_ENUM_H_ */ +/*H************************************************************************** + * NAME: usb_cdc_enum.h + *---------------------------------------------------------------------------- + * Copyright (c) 2004 Atmel. + *---------------------------------------------------------------------------- + * RELEASE: c5131-usb-cdc-1_0_2 + * REVISION: 1.2 + *---------------------------------------------------------------------------- + * PURPOSE: + * This file contains the USB task definition + *****************************************************************************/ + +#ifndef _USB_ENUM_H_ +#define _USB_ENUM_H_ + +/*_____ I N C L U D E S ____________________________________________________*/ + + +/*_____ M A C R O S ________________________________________________________*/ + + + + +/*_____ S T A N D A R D R E Q U E S T S ______bRequest____________________*/ + +#define GET_STATUS 0x00 +#define GET_DEVICE 0x01 +#define CLEAR_FEATURE 0x01 /* see FEATURES below */ +#define GET_STRING 0x03 +#define SET_FEATURE 0x03 /* see FEATURES below */ +#define SET_ADDRESS 0x05 +#define GET_DESCRIPTOR 0x06 +#define SET_DESCRIPTOR 0x07 +#define GET_CONFIGURATION 0x08 +#define SET_CONFIGURATION 0x09 +#define GET_INTERFACE 0x0A +#define SET_INTERFACE 0x0B +#define SYNCH_FRAME 0x0C + +/* HID specific */ +#define HID_SET_IDLE 0x0A +#define HID_GET_IDLE 0x02 +/* *** */ + +/*_____ A U D I O C L A S S R E Q U E S T S_____________________________*/ + +#define SET_CURRENT 0x01 +#define SET_MIN 0x02 +#define SET_MAX 0x03 +#define SET_RES 0x04 + +#define GET_CURRENT 0x81 +#define GET_MIN 0x82 +#define GET_MAX 0x83 +#define GET_RES 0x84 + + +#define GET_DEVICE_DESCRIPTOR 1 +#define GET_CONFIGURATION_DESCRIPTOR 4 + +/* CDC specific */ +#define GET_LINE_CODING 0x21 +#define SET_LINE_CODING 0x20 +#define SET_CONTROL_LINE_STATE 0x22 +#define SEND_BREAK 0x23 +#define SEND_ENCAPSULATED_COMMAND 0x00 +#define GET_ENCAPSULATED_COMMAND 0x01 +/* *** */ + +/* HID specific */ +#define HID 0x21 +#define REPORT 0x22 +/* *** */ + +#define REQUEST_DEVICE_STATUS 0x80 +#define REQUEST_INTERFACE_STATUS 0x81 +#define REQUEST_ENDPOINT_STATUS 0x82 + +#define ZERO_TYPE 0x00 +#define INTERFACE_TYPE 0x01 +#define ENDPOINT_TYPE 0x02 + +/*_____ D E S C R I P T O R T Y P E S ____________________________________*/ + +#define DEVICE 0x01 +#define CONFIGURATION 0x02 +#define STRING 0x03 +#define INTERFACE 0x04 +#define ENDPOINT 0x05 + + +/*_____ S T A N D A R D F E A T U R E S __________________________________*/ + +#define DEVICE_REMOTE_WAKEUP_FEATURE 0x01 +#define ENDPOINT_HALT_FEATURE 0x00 + +/*_____ D E V I C E S T A T U S ___________________________________________*/ + +#define SELF_POWERED 1 + +/*_____ D E V I C E S T A T E _____________________________________________*/ + +#define ATTACHED 0 +#define POWERED 1 +#define DEFAULT 2 +#define ADDRESSED 3 +#define CONFIGURED 4 +#define SUSPENDED 5 + +#define USB_CONFIG_BUSPOWERED 0x80 +#define USB_CONFIG_SELFPOWERED 0x40 +#define USB_CONFIG_REMOTEWAKEUP 0x20 + +/*_____ E N D P O I N T _____________________________________________*/ + +#define OUT_ENDPOINT1 0x01 +#define OUT_ENDPOINT2 0x02 +#define OUT_ENDPOINT3 0x03 +#define OUT_ENDPOINT4 0x04 +#define OUT_ENDPOINT5 0x05 +#define OUT_ENDPOINT6 0x06 + +#define IN_ENDPOINT1 0x81 +#define IN_ENDPOINT2 0x82 +#define IN_ENDPOINT3 0x83 +#define IN_ENDPOINT4 0x84 +#define IN_ENDPOINT5 0x85 +#define IN_ENDPOINT6 0x86 + +/*_________________________________________________________ S T R U C T _____*/ +/*_____ U S B D E V I C E R E Q U E S T _________________________________*/ +struct Endpoint_information_st +{ + Uint16 fifo_size ; /* size of the endpoint FIFO */ + Uint16 fifo_left ; +}; + +struct USB_request_st +{ + Uchar bmRequestType; /* Characteristics of the request */ + Uchar bRequest; /* Specific request */ + Uint16 wValue; /* field that varies according to request */ + Uint16 wIndex; /* field that varies according to request */ + Uint16 wLength; /* Number of bytes to transfer if Data */ +}; + + +/*_____ U S B D E V I C E D E S C R I P T O R ___________________________*/ + +struct usb_st_device_descriptor +{ + Uchar bLength; /* Size of this descriptor in bytes */ + Uchar bDescriptorType; /* DEVICE descriptor type */ + Uint16 bscUSB; /* Binay Coded Decimal Spec. release */ + Uchar bDeviceClass; /* Class code assigned by the USB */ + Uchar bDeviceSubClass; /* Sub-class code assigned by the USB */ + Uchar bDeviceProtocol; /* Protocol code assigned by the USB */ + Uchar bMaxPacketSize0; /* Max packet size for EP0 */ + Uint16 idVendor; /* Vendor ID. ATMEL = 0x03EB */ + Uint16 idProduct; /* Product ID assigned by the manufacturer */ + Uint16 bcdDevice; /* Device release number */ + Uchar iManufacturer; /* Index of manu. string descriptor */ + Uchar iProduct; /* Index of prod. string descriptor */ + Uchar iSerialNumber; /* Index of S.N. string descriptor */ + Uchar bNumConfigurations; /* Number of possible configurations */ +}; + + +/*_____ U S B C O N F I G U R A T I O N D E S C R I P T O R _____________*/ + +struct usb_st_configuration_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* CONFIGURATION descriptor type */ + Uint16 wTotalLength; /* total length of data returned */ + Uchar bNumInterfaces; /* number of interfaces for this conf. */ + Uchar bConfigurationValue; /* value for SetConfiguration resquest */ + Uchar iConfiguration; /* index of string descriptor */ + Uchar bmAttibutes; /* Configuration characteristics */ + Uchar MaxPower; /* maximum power consumption */ +}; + +struct usb_hid_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* INTERFACE descriptor type */ + Uint16 bcdHID; /* HID spec. */ + Uchar bCountryCode; /* Country code value*/ + Uchar bNumDescriptors; /* Number of reports descriptor */ + Uchar bDescriptorTypeRep; /* Type of the class-specific descriptor */ + Uint16 wDescriptorLength; /* Size of the report descriptor */ +}; +/*_____ U S B I N T E R F A C E D E S C R I P T O R _____________________*/ + +struct usb_st_interface_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* INTERFACE descriptor type */ + Uchar bInterfaceNumber; /* Number of interface */ + Uchar bAlternateSetting; /* value to select alternate setting */ + Uchar bNumEndpoints; /* Number of EP except EP 0 */ + Uchar bInterfaceClass; /* Class code assigned by the USB */ + Uchar bInterfaceSubClass; /* Sub-class code assigned by the USB */ + Uchar bInterfaceProtocol; /* Protocol code assigned by the USB */ + Uchar iInterface; /* Index of string descriptor */ +}; + +/*_____ U S B E N D P O I N T D E S C R I P T O R _______________________*/ + +struct usb_st_endpoint_descriptor +{ + Uchar bLength; /* Size of this descriptor in bytes */ + Uchar bDescriptorType; /* ENDPOINT descriptor type */ + Uchar bEndpointAddress; /* Address of the endpoint */ + Uchar bmAttributes; /* Endpoint's attributes */ + Uint16 wMaxPacketSize; /* Maximum packet size for this EP */ + Uchar bInterval; /* Interval for polling EP in ms */ +}; + + +/*_____ U S B M A N U F A C T U R E R D E S C R I P T O R _______________*/ + +struct usb_st_manufacturer +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* STRING descriptor type */ + Uint16 wstring[USB_MN_LENGTH];/* unicode characters */ +}; + + +/*_____ U S B P R O D U C T D E S C R I P T O R _________________________*/ + +struct usb_st_product +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* STRING descriptor type */ + Uint16 wstring[USB_PN_LENGTH];/* unicode characters */ +}; + + +/*_____ U S B S E R I A L N U M B E R D E S C R I P T O R _____________*/ + +struct usb_st_serial_number +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* STRING descriptor type */ + Uint16 wstring[USB_SN_LENGTH];/* unicode characters */ +}; + +/*_____ U S B C O N F I G D E S C R I P T O R _________________________*/ + +struct usb_st_config +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* STRING descriptor type */ + Uint16 wstring[USB_CONFIG_LENGTH];/* unicode characters */ +}; + +/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/ + +struct usb_st_language_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* STRING descriptor type */ + Uint16 wstring[USB_CONFIG_LENGTH]; /* language id */ +}; + + +/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/ + +struct usb_st_speaker_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* STRING descriptor type */ + Uint16 wstring[AUDIO_SPEAKER_LENGTH]; /* language id */ +}; + +/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/ + +struct usb_st_micro_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* STRING descriptor type */ + Uint16 wstring[AUDIO_MICRO_LENGTH]; /* language id */ +}; + +/*_____ U S B L A N G U A G E D E S C R I P T O R ______________________*/ + +struct usb_st_tts_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* STRING descriptor type */ + Uint16 wstring[AUDIO_TTS_LENGTH]; /* language id */ /* language id */ +}; + + +struct usb_st_audio_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* STRING descriptor type */ + Uint16 wstring[AUDIO_NORMAL_LENGTH]; /* language id */ /* language id */ +}; + + +/* HID specific */ +/*_____ U S B H I D D E S C R I P T O R __________________________________*/ + +struct usb_st_hid_descriptor +{ + Uchar bLength; /* Size of this descriptor in bytes */ + Uchar bDescriptorType; /* HID descriptor type */ + Uint16 bscHID; /* Binay Coded Decimal Spec. release */ + Uchar bCountryCode; /* Hardware target country */ + Uchar bNumDescriptors; /* Number of HID class descriptors to follow */ + Uchar bRDescriptorType; /* Report descriptor type */ + Uint16 wDescriptorLength; /* Total length of Report descriptor */ +}; + +/* Audio Class specific */ + +/*_____ U S B S T D AUDIO CONTROL I N T E R F A C E D E S C R I P T O R _____________________*/ + +struct usb_Audio_st_ACinterface_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* INTERFACE descriptor type */ + Uchar bInterfaceNumber; /* Number of interface */ + Uchar bAlternateSetting; /* value to select alternate setting */ + Uchar bNumEndpoints; /* Number of EP except EP 0 */ + Uchar bInterfaceClass; /* Class code assigned by the USB */ + Uchar bInterfaceSubClass; /* Sub-class code assigned by the USB */ + Uchar bInterfaceProtocol; /* Protocol code assigned by the USB */ + Uchar iInterface; /* Index of string descriptor */ +}; + +/*_____ U S B C S AUDIO CONTROL I N T E R F A C E D E S C R I P T O R _____________________*/ + +struct usb_Audio_cs_ACinterface_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* INTERFACE descriptor type */ + Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ + Uint16 bcdADC; /* Audio Device Class Specification Release Number in Binary-Coded Decimal */ + Uint16 wTotalLength; /* Total number of bytes returned for the class-specific AudioControl interface descriptor */ + Uchar bInCollection; /* Number of EP except EP 0 */ + Uchar baInterfaceNr[2]; /* Class code assigned by the USB */ +}; + +struct usb_Audio_cs_ACinterface_descriptor_NbCol1 +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* INTERFACE descriptor type */ + Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ + Uint16 bcdADC; /* Audio Device Class Specification Release Number in Binary-Coded Decimal */ + Uint16 wTotalLength; /* Total number of bytes returned for the class-specific AudioControl interface descriptor */ + Uchar bInCollection; /* Number of EP except EP 0 */ + Uchar baInterfaceNr[1]; /* Class code assigned by the USB */ +}; + +/*_____ U S B I N P U T T E R M I N A L D E S C R I P T O R ___________________________*/ + +struct usb_Audio_InputTerminal_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* INTERFACE descriptor type */ + Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ + Uchar bTerminalID; /* CConstant characterizing the type of Termina*/ + Uint16 wTerminalType; /* Constant characterizing the type of Terminal.*/ + Uchar bAssocTerminal; /* ID of the Output Terminal to which this Input Terminal is associated */ + Uchar bNrChannels; /* Number of logical output channels in the Terminals output audio channel cluster. */ + Uint16 wChannelConfig; /* Describes the spatial location of the logical channels.*/ + Uchar iChannelNames; /*Index of a string descriptor, describing the name of the first logical channel */ + Uchar iTerminal; /*Index of a string descriptor, describing the Input Terminal. */ +}; + +/*_____ U S B O U T P U T T E R M I N A L D E S C R I P T O R ___________________________*/ + +struct usb_Audio_OutputTerminal_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* INTERFACE descriptor type */ + Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ + Uchar bTerminalID; /* CConstant characterizing the type of Termina*/ + Uint16 wTerminalType; /* Constant characterizing the type of Terminal.*/ + Uchar bAssocTerminal; /* ID of the Output Terminal to which this Input Terminal is associated */ + Uchar bSourceID; /*ID of the Unit or Terminal to which this Terminal is connected */ + Uchar iTerminal; /*Index of a string descriptor, describing the Input Terminal. */ +}; + +/*_____ U S B F E A T U R E U N I T D E S C R I P T O R ___________________________*/ + +struct usb_Audio_FeatureUnit_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* INTERFACE descriptor type */ + Uchar bDescriptorSubtype; /* HEADER descriptor subtype.*/ + Uchar bUnitID; /* Constant uniquely identifying the Unit within the audio function.*/ + Uchar bSourceID; /* Constant characterizing the type of Terminal.*/ + Uchar bControlSize; /* Size in bytes of an element of the bmaControls() array: n*/ + Uchar bmaControls[2]; /*ID of the Unit or Terminal to which this Terminal is connected */ + Uchar iFeature; /*Index of a string descriptor, describing this Feature Unit.. */ +}; + +/*_____ U S B S T D AUDIO STREAM I N T E R F A C E D E S C R I P T O R _____________________*/ + +struct usb_Audio_st_ASinterface_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* INTERFACE descriptor type */ + Uchar bInterfaceNumber; /* Number of interface */ + Uchar bAlternateSetting; /* value to select alternate setting */ + Uchar bNumEndpoints; /* Number of EP except EP 0 */ + Uchar bInterfaceClass; /* Class code assigned by the USB */ + Uchar bInterfaceSubClass; /* Sub-class code assigned by the USB */ + Uchar bInterfaceProtocol; /* Protocol code assigned by the USB */ + Uchar iInterface; /* Index of string descriptor */ +}; + +/*_____ U S B C S AUDIO STREAM I N T E R F A C E D E S C R I P T O R _____________________*/ + +struct usb_Audio_cs_ASinterface_descriptor +{ + Uchar bLength; /* size of this descriptor in bytes */ + Uchar bDescriptorType; /* INTERFACE descriptor type */ + Uchar bDescriptorSubtype; /* AS_GENERAL descriptor subtype.*/ + Uchar bTerminalLink; /* The Terminal ID of the Terminal to which the endpoint of this interface is connected.*/ + Uchar bDelay; /* Delay (d) introduced by the data path */ + Uint16 wFormatTag; /* Class code assigned by the USB */ +}; + +/*_____ U S B AUDIO ST E N D P O I N T D E S C R I P T O R _______________________*/ + +struct usb_Audio_st_endpoint_descriptor +{ + Uchar bLength; /* Size of this descriptor in bytes */ + Uchar bDescriptorType; /* ENDPOINT descriptor type */ + Uchar bEndpointAddress; /* Address of the endpoint */ + Uchar bmAttributes; /* Endpoint's attributes */ + Uint16 wMaxPacketSize; /* Maximum packet size for this EP */ + Uchar bInterval; /* Interval for polling EP in ms */ + Uchar bRefresh; /* Reset to 0.*/ + Uchar bSynchAddress; /* The address of the endpoint used to communicate synchronization information if required by this endpoint..*/ +}; + +/*_____ U S B AUDIO S T E N D P O I N T D E S C R I P T O R _______________________*/ + +struct usb_Audio_cs_ASendpoint_descriptor +{ + Uchar bLength; /* Size of this descriptor in bytes */ + Uchar bDescriptorType; /* ENDPOINT descriptor type */ + Uchar bDescriptorSubtype; /* EP_GENERAL descriptor subtype. */ + Uchar bmAttributes; /* Endpoint's attributes */ + Uchar bLockDelayUnits; /*Indicates the units used for the wLockDelay field:*/ + Uint16 wLockDelay; /* Reset to 0.*/ +}; + +/*_____ U S B AUDIO S T E N D P O I N T D E S C R I P T O R _______________________*/ + +struct usb_Audio_TYPEI_FormatType_descriptor +{ + Uchar bLength; /* Size of this descriptor in bytes */ + Uchar bDescriptorType; /* ENDPOINT descriptor type */ + Uchar bDescriptorSubtype; /* EP_GENERAL descriptor subtype. */ + Uchar bFormatType; /* FORMAT_TYPE_I. Constant identifying the Format Type the AudioStreaming interface is using.*/ + Uchar bNrChannels; /*Indicates the number of physical channels in the audio data stream.:*/ + Uchar bSubframeSize; /* The number of bytes occupied by one audio subframe. Can be 1, 2, 3 or 4.*/ + Uchar bBitResolution; /* The number of effectively used bits from the available bits in an audio subframe.*/ + Uchar bSamFreqType; /*Indicates how the sampling frequency can be programmed */ + Uchar bSamFreqTbl[3]; /*See sampling frequency tables*/ +}; + +/*_____ D E C L A R A T I O N ______________________________________________*/ + + +void usb_var_init(void); +void usb_ep_init(void); +void usb_enumeration_process(void); + + +#endif /* _USB_ENUM_H_ */ Modified: firmware/fuxusb/branches/HID/modules/usb_enum/usb_enum.c =================================================================== --- firmware/fuxusb/branches/HID/modules/usb_enum/usb_enum.c 2008-04-30 08:01:05 UTC (rev 1033) +++ firmware/fuxusb/branches/HID/modules/usb_enum/usb_enum.c 2008-04-30 08:19:03 UTC (rev 1034) @@ -32,6 +32,7 @@ /*_____ D E F I N I T I O N ________________________________________________*/ +#define SIZE_OF_REPORT 0x22 @@ -83,8 +84,6 @@ struct usb_Audio_InputTerminal_descriptor SpkInputTerminalDescriptor; struct usb_Audio_OutputTerminal_descriptor MicOutputTerminal1Descriptor; struct usb_Audio_OutputTerminal_descriptor SpkOutputTerminalDescriptor; - // struct usb_Audio_FeatureUnit_descriptor MicFeatureUnitDescriptor; - // struct usb_Audio_FeatureUnit_descriptor SpkFeatureUnitDescriptor; // Interface 1 :: Audio Stream Microphone //-------------------------------------------------------------------------- @@ -105,12 +104,13 @@ struct usb_Audio_cs_ASendpoint_descriptor SpkEndpointDescriptor; //---------------------------------------------------------------------------- - // "HID" LIB USB + // "HID" //---------------------------------------------------------------------------- // Interface 3 :: Command / Status Interface //-------------------------------------------------------------------------- struct usb_st_interface_descriptor HIDInterfaceDescriptor; - struct usb_st_endpoint_descriptor HID_InEndpointDescriptor; + struct usb_hid_descriptor hid; + struct usb_st_endpoint_descriptor HID_InEndpointDescriptor; struct usb_st_endpoint_descriptor HID_OutEndpointDescriptor; #ifdef TTS_INTERFACE_ENABLED @@ -120,7 +120,6 @@ struct usb_Audio_cs_ACinterface_descriptor_NbCol1 SpecificACInterfaceDescriptor_TTS; struct usb_Audio_InputTerminal_descriptor SpkInputTerminalDescriptor_TTS; struct usb_Audio_OutputTerminal_descriptor SpkOutputTerminalDescriptor_TTS; - // struct usb_Audio_FeatureUnit_descriptor SpkFeatureUnitDescriptor_TTS; // Interface 5 :: Audio Stream //-------------------------------------------------------------------------- @@ -131,6 +130,10 @@ struct usb_Audio_st_endpoint_descriptor SpkStandardEndpointDescriptor_TTS; struct usb_Audio_cs_ASendpoint_descriptor SpkEndpointDescriptor_TTS; #endif + + // Report descriptor + //------------------------------------------------------------------------- + Uchar rep[SIZE_OF_REPORT]; } usb_configuration = { @@ -228,37 +231,7 @@ 0x02, // bSourceID From Input Termianl 0x05 // iTerminal Unused }, - /* - // MicFeatureUnitDescriptor[] = - //------------------------------------- - { - 0x09, // length of descriptor (9 bytes) - 0x24, // descriptor type (CS_INTERFACE) - 0x06, // FeatureUnit SubType - 0x05, // Const - 0x01, // COnnect to Terminal 1 - 0x02, // bmaControl Size - 0x00, // bmaControl - 0x00, - 0x00 - }, - // SpkFeatureUnitDescriptor[] = - //------------------------------------- - { - 0x09, // length of descriptor (9 bytes) - 0x24, // descriptor type (CS_INTERFACE) - 0x06, // FeatureUnit SubType - 0x06, // Const - 0x02, // COnnect to Terminal 2 - 0x02, // bmaControl Size - 0x00, // bmaControl - 0x00, - 0x00 - }, - */ - - //---------------------------------------------------------------------------- // Microphone //---------------------------------------------------------------------------- @@ -430,44 +403,46 @@ //---------------------------------------------------------------------------- // Interface 3 :: Command / Status Interface //-------------------------------------------------------------------------- + { // Interface Descriptor + 0x09, // Descriptor size + 0x04, // Descriptor type (Interface) + 0x03, // Interface number + 0x00, // Alternate setting number + 0x02, // Number of endpoints in this interface + 0x03, // Interface class (HID) + 0x00, // Interface sub-class (vendor-specific) + 0x00, // Interface protocol (vendor-specific) + 0x00 // Interface string index + }, + + { // HID Descriptor + 0x09, // Descriptor size + 0x21, // Descriptor type (HID) + 0x1001, // HID Spec (1.1) + 0x00, // Country code (undef) + 0x01, // Number of subordinate class descriptors + 0x22, // Descriptor type (report) + 0x2200 // Report descriptor size + }, - // HIDInterfaceDescriptor[] = - //------------------------------------- - { - 0x09, // length of descriptor (9 bytes) - 0x04, // descriptor type (INTERFACE) - 0x03, // interface number Index of this interface - 0x00, // alternate setting Index of this alternate setting - 0x02, // number of endpoints - 0x00, // interface class HID - 0x00, // interface sub-class - 0x00, // interface protocol - 0x00 // interface string index - }, + { // Endpoint Descriptor + 0x07, // Descriptor size + 0x05, // Descriptor type (Endpoint) + IN_ENDPOINT4, // Endpoint nb and direction + 0x03, // Endpoint type + 0x4000, // Maximum packet size + 0x00 // Polling interval + }, - // HID_InEndpointDescriptor[] = - //------------------------------------- - { - 0x07, // descriptor length (7 bytes) - 0x05, // descriptor type - IN_ENDPOINT4, - 0x03, // bMAttributes (interrupt) bit 7 :: max paket - 0x4000, // Max packet size (64 Bytes) - 0x01 // polling interval 1ms - }, - // HID_OutEndpointDescriptor[] = - //------------------------------------- - { - 0x07, // descriptor length (7 bytes) - 0x05, // descriptor type - OUT_ENDPOINT5, - 0x03, // bMAttributes (interrupt) bit 7 :: max paket - 0x4000, // Max packet size (64 Bytes) - 0x01 // polling interval 1ms -#ifndef TTS_INTERFACE_ENABLED - } -#else - }, + { // Endpoint Descriptor + 0x07, // Descriptor size + 0x05, // Descriptor type (Endpoint) + OUT_ENDPOINT5, // Endpoint nb and direction + 0x03, // Endpoint type + 0x4000, // Maximum packet size + 0x00 // Polling interval + }, +#ifdef TTS_INTERFACE_ENABLED //---------------------------------------------------------------------------- // Audio //---------------------------------------------------------------------------- @@ -528,21 +503,7 @@ 0x07, // bSourceID From Input Termianl 0x07 // iTerminal Unused }, - /* - // SpkFeatureUnitDescriptor[] = - //------------------------------------- - { - 0x09, // length of descriptor (9 bytes) - 0x24, // descriptor type (CS_INTERFACE) - 0x06, // FeatureUnit SubType - 0x09, // Const - 0x07, // COnnect to Terminal 7 - 0x02, // bmaControl Size - 0x00, // bmaControl - 0x00, - 0x00 - }, - */ + //---------------------------------------------------------------------------- // Speaker //---------------------------------------------------------------------------- @@ -625,8 +586,43 @@ 0x00, // bMAttributes bit 7 :: max paket 0x00, // bLockDelayUnits Unused 0x0000 // LockDelay - } -#endif + }, +#endif + //---------------------------------------------------------------------------- + // HID Report descriptor + //---------------------------------------------------------------------------- + // This descriptor defines the HID device. + // Size : 47 bytes + // The size of this descriptor is not considered for the global descr. size. + //-------------------------------------------------------------------------- + { // Report descriptor + 0x06, 0x00, 0xFF, // Usage page (vendor-defined) + 0x09, 0x01, // Usage (Vendor-defined) + 0xA1, 0x01, // Collection (Application) + + 0x09, 0x03, // Usage (vendor defined) + 0x15, 0x00, // Logical Minimum (0) + 0x26, 0xFF, 0x00, // Logical maximum (255) + 0x95, 0x40, // Report count (64) + 0x75, 0x08, // Report size (8 bits) + 0x81, 0x02, // input (data, variable, absolute) + + 0x09, 0x04, // Usage (vendor defined) + 0x15, 0x00, // Logical Minimum (0) + 0x26, 0xFF, 0x00, // Logical maximum (255) + 0x95, 0x05, // Report count (5) + 0x75, 0x08, // Report size (8 bits) + 0x91, 0x02, // output (data, variable, absolute) + +// 0x09, 0x05, // Usage (vendor defined) +// 0x15, 0x00, // Logical Minimum (0) +// 0x26, 0xFF, 0x00, // Logical maximum (255) +// 0x75, 0x08, // Report size (8 bits) +// 0x95, 0x02, // Report count (2) +// 0xB1, 0x02, // feature (data, variable, absolute) + + 0xC0 // End collection + } }; static bit zlp; @@ -661,6 +657,10 @@ static void usb_set_max(void); static void usb_set_res(void); +static void usb_hid_set_report (void); +static void usb_hid_set_idle (void); +static void usb_hid_get_idle (void); + /*F************************************************************************** * NAME: usb_var_init *---------------------------------------------------------------------------- @@ -798,8 +798,10 @@ usb_get_configuration(); break; case SET_ADDRESS: usb_set_address(); break; - case SET_CONFIGURATION: - usb_set_configuration(); break; + case SET_CONFIGURATION: /* or SET_REPORT */ + if (bmRequestType == 0) { usb_set_configuration(); } + else { usb_hid_set_report(); } + break; /* case CLEAR_FEATURE: // or GET_ENCPASULATED_COMMAND // if(bmRequestType == 0xA1) { cdc_get_encapsulated_command(); } @@ -814,15 +816,18 @@ if(bmRequestType == 0x21) { cdc_send_encapsulated_command(); } else {usb_get_status();} break; */ - /* - case GET_INTERFACE: - usb_get_interface(); break; - */ + case GET_INTERFACE: /* HID_SET_IDLE */ + if (bmRequestType == 0x81) { usb_get_interface(); } + else { usb_hid_set_idle(); } + break; case SET_INTERFACE: usb_set_interface(); break; + /* HID Specific request */ + case HID_GET_IDLE: + usb_hid_get_idle(); break; case SET_DESCRIPTOR: case SYNCH_FRAME: @@ -1139,20 +1144,19 @@ break; } - /* case REPORT: - { - data_to_transfer = SIZE_OF_REPORT; - pbuffer = &(usb_configuration.rep[0]); - break; - } + case REPORT: + { + data_to_transfer = SIZE_OF_REPORT; + pbuffer = &(usb_configuration.rep[0]); + break; + } - case HID: - { - data_to_transfer = sizeof(usb_configuration.hid); - pbuffer = &(usb_configuration.hid.bLength); - break; - } - */ + case HID: + { + data_to_transfer = sizeof(usb_configuration.hid); + pbuffer = &(usb_configuration.hid.bLength); + break; + } case STRING: { #ifdef USB_ENUM_DEBUG @@ -1850,10 +1854,94 @@ } } +/*F************************************************************************** +* NAME: usb_hid_set_report +*---------------------------------------------------------------------------- +* PARAMS: +* +* return: +*---------------------------------------------------------------------------- +* PURPOSE: +* This function manages the SET_REPORT request (HID Class) +*---------------------------------------------------------------------------- +* EXAMPLE: +*---------------------------------------------------------------------------- +* NOTE: +*---------------------------------------------------------------------------- +* REQUIREMENTS: +*****************************************************************************/ +void usb_hid_set_report (void) +{ + Usb_clear_rx_setup(); + + while(!Usb_rx_complete() ); + Usb_clear_rx(); + Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ + while(!(Usb_tx_complete())); + Usb_clear_tx_complete(); +} +/*F************************************************************************** +* NAME: usb_hid_set_idle +*---------------------------------------------------------------------------- +* PARAMS: +* +* return: +*---------------------------------------------------------------------------- +* PURPOSE: +* This function manages the HID_SET_IDLE request. +*---------------------------------------------------------------------------- +* EXAMPLE: +*---------------------------------------------------------------------------- +* NOTE: +*---------------------------------------------------------------------------- +* REQUIREMENTS: +*****************************************************************************/ +void usb_hid_set_idle (void) +{ + ACC = Usb_read_byte(); + hid_idle_duration = Usb_read_byte(); /* wValue contains the duration */ + Usb_clear_rx_setup(); + Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ + while(!(Usb_tx_complete())); + Usb_clear_tx_complete(); +} +/*F************************************************************************** +* NAME: usb_hid_get_idle +*---------------------------------------------------------------------------- +* PARAMS: +* +* return: +*---------------------------------------------------------------------------- +* PURPOSE: +* This function manages the GET_IDLE request. +*---------------------------------------------------------------------------- +* EXAMPLE: +*---------------------------------------------------------------------------- +* NOTE: +*---------------------------------------------------------------------------- +* REQUIREMENTS: +*****************************************************************************/ +void usb_hid_get_idle (void) +{ + Usb_clear_rx_setup(); + Usb_set_DIR(); + Usb_write_byte(hid_idle_duration); + Usb_set_tx_ready(); /* send a ZLP for STATUS phase */ + while(!(Usb_tx_complete())); + Usb_clear_tx_complete(); + + while (!(Usb_rx_complete())); + Usb_clear_rx(); + Usb_clear_DIR(); +} + + + + /*_____ E N D O F F I L E _________________________________________________*/ |