SuperDave
Joined: 22 May 2008 Posts: 63 Location: Madison, TN
|
USB Descriptor |
Posted: Tue Oct 07, 2014 9:21 am |
|
|
Trying to make a combination mouse and other data (A/D) array device. Starting with usb_desc_mouse.h and adding an extra interface and two endpoints. The code below compiles. Is it likely to work? The PC end will use Delphi 2010 and the Jedi HidDeviceController to read the extra endpoints. In order to make the descriptor below a reasonable size, I've replaced the unchanged code with UNCHANGED and eliminated a lot of the generic comments.
Code: |
///////////////////////////////////////////////////////////////////////////
//// ////
/// usb_desc_Test.h from usb_desc_mouse.h ////
//// ////
///////////////////////////////////////////////////////////////////////////
#IFNDEF __USB_DESCRIPTORS__
#DEFINE __USB_DESCRIPTORS__
///////// config options, UNCHANGED
//turn on EP1 for IN interrupt transfers. (IN = PIC -> PC) HID
#undef USB_EP1_TX_ENABLE
#define USB_EP1_TX_ENABLE USB_ENABLE_INTERRUPT
#undef USB_EP1_TX_SIZE
#define USB_EP1_TX_SIZE 8 //max packet size of this endpoint
// these are 49 for two arrays of 48 each
//turn on EP2 for IN interrupt transfers. (IN = PIC -> PC) Ary1
#undef USB_EP2_TX_ENABLE
#define USB_EP2_TX_ENABLE USB_ENABLE_INTERRUPT
#undef USB_EP2_TX_SIZE
#define USB_EP2_TX_SIZE 49 //max packet size of this endpoint
//turn on EP3 for IN interrupt transfers. (IN = PIC -> PC) Ary2
#undef USB_EP3_TX_ENABLE
#define USB_EP3_TX_ENABLE USB_ENABLE_INTERRUPT
#undef USB_EP3_TX_SIZE
#define USB_EP3_TX_SIZE 49 //max packet size of this endpoint
#include <usb.h>
/// HID Report. UNCHANGED
const char USB_CLASS_SPECIFIC_DESC[] = //UNCHANGED ;
const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP[USB_NUM_CONFIGURATIONS][1] =
{ 0 }; //UNCHANGED
const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[USB_NUM_CONFIGURATIONS][1] =
{
//config 1 //interface 0
sizeof(USB_CLASS_SPECIFIC_DESC) }; UNCHANGED
/////////////////////////////////////////////////////////////////
///
/// start config descriptor
//////////////////////////////////////////////////////////////////
#DEFINE USB_TOTAL_CONFIG_LEN 57 //config+interface+class+endpoint
const char USB_CONFIG_DESC[] = {
//config_descriptor for config index 1 UNCHANGED EXCEPT CHANGED NUM INTERFACES
2, //number of interfaces this device supports ==5 CHANGED
//interface descriptor 1 UNCHANGED
//class descriptor 1 (HID) UNCHANGED
//endpoint descriptor UNCHANGED
//END HID DEMO CODE
// ADD ARRAY CODE ALL BELOW ADDED
//interface descriptor for interrupt
USB_DESC_INTERFACE_LEN, //length of descriptor ==35
USB_DESC_INTERFACE_TYPE, //constant INTERFACE (0x04) ==36
0x01, //number defining this interface ==37
0x00, //alternate setting ==38
2, //number of endpoints, except 0. ==39
0xFF, //class code, FF = vendor defined ==40
0xFF, //subclass code, FF = vendor ==41
0xFF, //protocol code, FF = vendor ==42
0x00, //index of string descriptor for interface ==43
//endpoint descriptor
USB_DESC_ENDPOINT_LEN, //length of descriptor ==44
USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (0x05) ==45
0x82, //endpoint number and direction (0x82 = EP2 IN) ==46
0x03, //transfer type supported (3 is interrupt) ==47
USB_EP2_TX_SIZE,0x00, //maximum packet size supported ==49,49
0x01, //polling interval in ms. (for interrupt transfers ONLY) ==50
//endpoint descriptor
USB_DESC_ENDPOINT_LEN, //length of descriptor ==51
USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (0x05) ==52
0x83, //endpoint number and direction (0x83 = EP3 IN) ==53
0x03, //transfer type supported (3 is interrupt) ==54
USB_EP3_TX_SIZE,0x00, //maximum packet size supported ==55,56
0x01, //polling interval in ms. (for interrupt transfers ONLY) ==57
//end ARY CODE
};
#define USB_NUM_HID_INTERFACES 1 //UNCHANGED
#define USB_MAX_NUM_INTERFACES 2 //CHANGED
const char USB_NUM_INTERFACES[USB_NUM_CONFIGURATIONS]={2}; //CHANGED
const int16 USB_CLASS_DESCRIPTORS[USB_NUM_CONFIGURATIONS][USB_NUM_HID_INTERFACES][1]= //UNCHANGED
{ 18 };
const char USB_DEVICE_DESC[] = { //UNCHANGED
/// start string descriptors UNCHANGED
|
|
|