I'm creating a touch screen emulator. I'm using M-Stack with a Pic18F25K50. When I plug the device it, windows will create the three sub devices. Then it will mark each of those devices with a can't start error. I've looked through the code, and I don't see any mistakes. I'm sure I did something wrong with the descriptors. Since that is the only thing that makes sense. But I'm at a loss. USBlyzer, gives some information.
Here is the configuration code,
struct configuration_1_packet {
struct configuration_descriptor config;
struct interface_descriptor interface;
struct hid_descriptor hid;
struct endpoint_descriptor ep;
struct interface_descriptor interface2;
struct hid_descriptor hid2;
struct endpoint_descriptor ep2;
struct endpoint_descriptor ep2_out;
struct interface_descriptor interface3;
struct hid_descriptor hid3;
struct endpoint_descriptor ep3;
};
/* Device Descriptor
*
* Each device has a single device descriptor describing the device. The
* format is described in Chapter 9 of the USB specification from usb.org.
* USB_DEVICE_DESCRIPTOR needs to be defined to the name of this object in
* usb_config.h. For more information, see USB_DEVICE_DESCRIPTOR in usb.h.
*/
const ROMPTR struct device_descriptor this_device_descriptor =
{
sizeof(struct device_descriptor), // bLength
DESC_DEVICE, // bDescriptorType
0x0200, // 0x0200 = USB 2.0, 0x0110 = USB 1.1
0x00, // Device class
0x00, // Device Subclass
0x00, // Protocol.
EP_0_LEN, // bMaxPacketSize0
0x2965, // Vendor
0x5042, // Product 5023 is the actual kortek module we use
0x0100, // device release (1.0)
1, // Manufacturer
2, // Product
3, // Serial
1 // NumConfigurations
};
static const ROMPTR struct configuration_1_packet configuration_1 =
{
{
// Members from struct configuration_descriptor
sizeof(struct configuration_descriptor),
0x02,//Configuration Descriptor bDescriptorType
sizeof(configuration_1), // wTotalLength (length of the whole packet)
3, // bNumInterfaces
1, // bConfigurationValue
0, // iConfiguration (index of string descriptor)
0b10100000,//bmAttributes
100/2, // 100/2 indicates 100mA
},
{
// Members from struct interface_descriptor
sizeof(struct interface_descriptor), // bLength;
0x04,//Descriptor Type
0x00, // InterfaceNumber
0x00, // AlternateSetting
0x01, // bNumEndpoints (num besides endpoint 0)
0x03, // bInterfaceClass 3=HID, 0xFF=VendorDefined
0x00, // bInterfaceSubclass (0=NoBootInterface for HID)
0x00, // bInterfaceProtocol
0x04, // iInterface (index of string describing interface)
},
{
// Members from struct hid_descriptor
sizeof(struct hid_descriptor),
0x21,
0x0110, // bcdHID
0x0, // bCountryCode
1, // bNumDescriptors
0x22, // bDescriptorType2
sizeof(mouse_report_descriptor), // wDescriptorLength supposed to be 22F
},
{
// Members of the Endpoint Descriptor (EP1 IN)
sizeof(struct endpoint_descriptor),
0x05, //bDescriptorType Endpoint
0x84, // endpoint #1 0x80=IN
0b00000011, // bmAttributes
EP_1_IN_LEN, // wMaxPacketSize
1, // bInterval in ms.
},
/* Second Interface */
{
// Members from struct interface_descriptor
sizeof(struct interface_descriptor), // bLength;
0x04, //Interface
0x01, // InterfaceNumber
0x00, // AlternateSetting
0x02, // bNumEndpoints (num besides endpoint 0)
0x03, // bInterfaceClass 3=HID, 0xFF=VendorDefined
0x00, // bInterfaceSubclass (0=NoBootInterface for HID)
0x00, // bInterfaceProtocol
0x05, // iInterface (index of string describing interface)
},
{
// Members from struct hid_descriptor
sizeof(struct hid_descriptor),
0x21, //bDescriptorType HID
0x0110, // bcdHID
0x00, // bCountryCode
1, // bNumDescriptors
0x22, // bDescriptorType2
sizeof(mouse_report_descriptor_1), // wDescriptorLength supposed to be 27Bytes
},
{
// Members of the Endpoint Descriptor (EP1 OUT)
sizeof(struct endpoint_descriptor),
0x05, //bDescriptorType Endpoint
0x85 /*| 0x00*/, // endpoint #1 0x00=OUT
0b00000011, // bmAttributes
EP_1_OUT_LEN, // wMaxPacketSize
1, // bInterval in ms.
},
{
// Members of the Endpoint Descriptor (EP1 IN)
sizeof(struct endpoint_descriptor),
0x05,//bDescriptorType Endpoint
0x05, // endpoint #1 0x80=IN
0b00000011, // bmAttributes
EP_2_IN_LEN, // wMaxPacketSize
1, // bInterval in ms.
},
/* Third Interface */
{
// Members from struct interface_descriptor
sizeof(struct interface_descriptor), // bLength;
0x04, //bDescriptorType Interface
0x02, // InterfaceNumber
0x00, // AlternateSetting
0x01, // bNumEndpoints (num besides endpoint 0)
0x03, // bInterfaceClass 3=HID, 0xFF=VendorDefined
0x00, // bInterfaceSubclass (0=NoBootInterface for HID)
0x02, // bInterfaceProtocol
0x06, // iInterface (index of string describing interface)
},
{
// Members from struct hid_descriptor
sizeof(struct hid_descriptor),
0x21, //bDescriptorType HID
0x0110, // bcdHID
0x00, // bCountryCode
0x01, // bNumDescriptors
0x22, // bDescriptorType Report
sizeof(mouse_report_descriptor_2), // wDescriptorLength supposed to be 56bytes
},
{
// Members of the Endpoint Descriptor (EP1 OUT)
sizeof(struct endpoint_descriptor),
0x05, //bDescriptorType Endpoint
0x83, // endpoint #1 0x00=OUT
0b00000011, // bmAttributes
EP_2_OUT_LEN, // wMaxPacketSize
1, // bInterval in ms.
},
};
Here are the 3 descriptors
static const ROMPTR uint8_t mouse_report_descriptor[] ={
0x5,0x0D,//Usage Page (Digitizer)
0x9,0x4,//Usage (Touch Screen)
0xA1,0x1,//Collection (Application)
0x85,0x73,// Report ID (115)
0x9,0x54,// Usage (Contact Count)
0x15,0x0,// Logical Minimum (0)
0x25,0x1F,// Logical Maximum (31)
0x75,0x8,// Report Size (8)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x22,// Usage (Finger)
0xA1,0x2,// Collection (Logical)
0x9,0x51,// Usage (Contact Identifier)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0,// Logical Maximum (255)
0x75,0x8,// Report Size (8)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x42,// Usage (Tip Switch)
0x15,0x0,// Logical Minimum (0)
0x25,0x1,// Logical Maximum (1)
0x75,0x1,// Report Size (1)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x32,// Usage (In Range)
0x15,0x0,// Logical Minimum (0)
0x25,0x1,// Logical Maximum (1)
0x75,0x1,// Report Size (1)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x75,0x6,// Report Size (6)
0x95,0x1,// Report Count (1)
0x81,0x3,// Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x1,// Usage Page (Generic Desktop)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0F,// Logical Maximum (4095)
0x35,0x0,// Physical Minimum (0)
0x46,0xFF,0x0F,// Physical Maximum (4095)
0x75,0x10,// Report Size (16)
0x95,0x1,// Report Count (1)
0x9,0x30,// Usage (X)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x31,// Usage (Y)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x0D,// Usage Page (Digitizer)
0xC0,// End Collection
0x9,0x22,// Usage (Finger)
0xA1,0x2,// Collection (Logical)
0x9,0x51,// Usage (Contact Identifier)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0,// Logical Maximum (255)
0x75,0x8,// Report Size (8)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x42,// Usage (Tip Switch)
0x15,0x0,// Logical Minimum (0)
0x25,0x1,// Logical Maximum (1)
0x75,0x1,// Report Size (1)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x32,// Usage (In Range)
0x15,0x0,// Logical Minimum (0)
0x25,0x1,// Logical Maximum (1)
0x75,0x1,// Report Size (1)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x75,0x6,// Report Size (6)
0x95,0x1,// Report Count (1)
0x81,0x3,// Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x1,// Usage Page (Generic Desktop)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0F,// Logical Maximum (4095)
0x35,0x0,// Physical Minimum (0)
0x46,0xFF,0x0F,// Physical Maximum (4095)
0x75,0x10,// Report Size (16)
0x95,0x1,// Report Count (1)
0x9,0x30,// Usage (X)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x31,// Usage (Y)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x0D,// Usage Page (Digitizer)
0xC0,// End Collection
0x9,0x22,// Usage (Finger)
0xA1,0x2,// Collection (Logical)
0x9,0x51,// Usage (Contact Identifier)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0,// Logical Maximum (255)
0x75,0x8,// Report Size (8)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x42,// Usage (Tip Switch)
0x15,0x0,// Logical Minimum (0)
0x25,0x1,// Logical Maximum (1)
0x75,0x1,// Report Size (1)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x32,// Usage (In Range)
0x15,0x0,// Logical Minimum (0)
0x25,0x1,// Logical Maximum (1)
0x75,0x1,// Report Size (1)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x75,0x6,// Report Size (6)
0x95,0x1,// Report Count (1
0x81,0x3,// Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x1,// Usage Page (Generic Desktop)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0F,// Logical Maximum (4095)
0x35,0x0,// Physical Minimum (0)
0x46,0xFF,0x0F,// Physical Maximum (4095)
0x75,0x10,// Report Size (16)
0x95,0x1,// Report Count (1)
0x9,0x30,// Usage (X)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x31,// Usage (Y)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x0D,// Usage Page (Digitizer)
0xC0,// End
0x9,0x22,// Usage (Finger)
0xA1,0x2,// Collection (Logical)
0x9,0x51,// Usage (Contact Identifier)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0,// Logical Maximum (255)
0x75,0x8,// Report Size (8)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x42,// Usage (Tip Switch)
0x15,0x0,// Logical Minimum (0)
0x25,0x1,// Logical Maximum (1)
0x75,0x1,// Report Size (1)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x32,// Usage (In Range)
0x15,0x0,// Logical Minimum (0)
0x25,0x1,// Logical Maximum (1)
0x75,0x1,// Report Size (1)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x75,0x6,// Report Size (6)
0x95,0x1,// Report Count (1)
0x81,0x3,// Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x1,// Usage Page (Generic Desktop)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0F,// Logical Maximum (4095)
0x35,0x0,// Physical Minimum (0)
0x46,0xFF,0x0F,// Physical Maximum (4095)
0x75,0x10,// Report Size (16)
0x95,0x1,// Report Count (1)
0x9,0x30,// Usage (X)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x31,// Usage (Y)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x0D,// Usage Page (Digitizer)
0xC0,// End Collection
0x9,0x22,// Usage (Finger)
0xA1,0x2,// Collection (Logical)
0x9,0x51,// Usage (Contact Identifier)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0,// Logical Maximum (255)
0x75,0x8,// Report Size (8)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x42,// Usage (Tip Switch)
0x15,0x0,// Logical Minimum (0)
0x25,0x1,// Logical Maximum (1)
0x75,0x1,// Report Size (1)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x32,// Usage (In Range)
0x15,0x0,// Logical Minimum (0)
0x25,0x1,// Logical Maximum (1)
0x75,0x1,// Report Size (1)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x75,0x6,// Report Size (6)
0x95,0x1,// Report Count (1)
0x81,0x3,// Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x1,// Usage Page (Generic Desktop)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0F,// Logical Maximum (4095)
0x35,0x0,// Physical Minimum (0)
0x46,0xFF,0x0F,// Physical Maximum (4095)
0x75,0x10,// Report Size (16)
0x95,0x1,// Report Count (1)
0x9,0x30,// Usage (X)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x31,// Usage (Y)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x0D,// Usage Page (Digitizer)
0xC0,// End Collection
0x5,0x0D,// Usage Page (Digitizer)
0x15,0x0,// Logical Minimum (0)
0x27,0xFF,0xFF,0x0,// Logical Maximum (65535)
0x55,0x0C,// Unit Exponent (-4)
0x66,0x1,0x10,// Unit (SI Lin: Time (s))
0x75,0x10,// Report Size (16)
0x95,0x1,// Report Count (1)
0x9,0x56,// Usage (Scan Time)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x85,0x74,// Report ID (116)
0x9,0x55,// Usage (Contact Count Maximum)
0x15,0x0,// Logical Minimum (0)
0x25,0x1F,// Logical Maximum (31)
0x75,0x8,// Report Size (8)
0x95,0x1,// Report Count (1)
0xB1,0x2,// Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)
0x85,0x75,// Report ID (117)
0x6,0x0,0xFF,// Usage Page (Vendor-Defined 1)
0x9,0xC5,// Usage (Vendor-Defined 197)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0,// Logical Maximum (255)
0x75,0x8,// Report Size (8)
0x96,0x0,0x1,// Report Count (256)
0xB1,0x2,// Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)
0xC0,//End Collection
0x5,0x0D,//Usage Page (Digitizer)
0x9,0x0,//Usage (Undefined)
0xA1,0x1,//Collection (Application)
0x85,0x77,// Report ID (119)
0x9,0x20,// Usage (Stylus)
0xA1,0x2,// Collection (Logical)
0x15,0x0,// Logical Minimum (0)
0x25,0x1,// Logical Maximum (1)
0x75,0x1,// Report Size (1)
0x95,0x1,// Report Count (1)
0x9,0x42,// Usage (Tip Switch)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x32,// Usage (In Range)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x44,// Usage (Barrel Switch)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x45,// Usage (Eraser)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x95,0x4,// Report Count (4)
0x81,0x3,// Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x1,// Usage Page (Generic Desktop)
0x55,0x0,// Unit Exponent (0)
0x65,0x11,// Unit (SI Lin: Length (cm))
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0F,// Logical Maximum (4095)
0x35,0x0,// Physical Minimum (0)
0x46,0xFF,0x0F,// Physical Maximum (4095)
0x75,0x10,// Report Size (16)
0x95,0x1,// Report Count (1)
0x9,0x30,// Usage (X)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x31,// Usage (Y)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x0D,// Usage Page (Digitizer)
0x9,0x30,// Usage (Tip Pressure)
0x15,0x1,// Logical Minimum (1)
0x26,0xFF,0x0,// Logical Maximum (255)
0x75,0x8,// Report Size (8)
0x95,0x1,// Report Count (1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0xC0,// End Collection
0xC0,//End Collection
0x5,0x0D,//Usage Page (Digitizer)
0x9,0x0E,//Usage (Configuration)
0xA1,0x1,//Collection (Application)
0x85,0x71,// Report ID (113)
0x9,0x23,// Usage (Device Settings)
0xA1,0x2,// Collection (Logical)
0x9,0x52,// Usage (Device Mode)
0x9,0x53,// Usage (Device Identifier)
0x15,0x0,// Logical Minimum (0)
0x25,0x0A,// Logical Maximum (10)
0x75,0x8,// Report Size (8)
0x95,0x2,// Report Count (2)
0xB1,0x2,// Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)
0xC0,// End Collection
0xC0//End Collection
};
static const ROMPTR uint8_t mouse_report_descriptor_1[]={
0x6,0x0,0xFF,//Usage Page (Vendor-Defined 1)
0x9,0x1,//Usage (Vendor-Defined 1)
0xA1,0x1,//Collection (Application)
0x85,0x76,// Report ID (118)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0,// Logical Maximum (255)
0x75,0x8,// Report Size (8)
0x95,0x3F,// Report Count (63)
0x9,0x1,// Usage (Vendor-Defined 1)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x9,0x1,// Usage (Vendor-Defined 1)
0x91,0x2,// Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)
0xc0
};
static const ROMPTR uint8_t mouse_report_descriptor_2[]={
0x5,0x01,//Usage Page (Generic Desktop)
0x9,0x02,//Usage (Mouse)
0xA1,0x1,//Collection (Application)
0x85,0x72,// Report ID (114)
0x9,0x1,// Usage (Pointer)
0xA1,0x0,// Collection (Physical)
0x5,0x9,// Usage Page (Button)
0x19,0x1,// Usage Minimum (Button 1)
0x29,0x2,// Usage Maximum (Button 2)
0x15,0x0,// Logical Minimum (0)
0x25,0x1,// Logical Maximum (1)
0x75,0x1,// Report Size (1)
0x95,0x2,// Report Count (2)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x95,0x6,// Report Count (6)
0x81,0x3,// Input (Cnst,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x5,0x1,// Usage Page (Generic Desktop)
0x9,0x30,// Usage (X)
0x9,0x31,// Usage (Y)
0x15,0x0,// Logical Minimum (0)
0x26,0xFF,0x0F,// Logical Maximum (4095)
0x35,0x0,// Physical Minimum (0)
0x46,0xFF,0x0F,// Physical Maximum (4095)
0x75,0x10,// Report Size (16)
0x95,0x2,// Report Count (2)
0x81,0x2,// Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0xC0,// End Collection
0xC0,//End Collection
};
I'll put what I saw with USBlyzer in the next post.