/*---------------------------------------------------------------------*/
/* --- STC MCU Limited ------------------------------------------------*/
/* --- STC 1T Series MCU Demo Programme -------------------------------*/
/* --- Mobile: (86)13922805190 ----------------------------------------*/
/* --- Fax: 86-0513-55012956,55012947,55012969 ------------------------*/
/* --- Tel: 86-0513-55012928,55012929,55012966 ------------------------*/
/* --- Web: www.STCAI.com ---------------------------------------------*/
/* --- BBS: www.STCAIMCU.com  -----------------------------------------*/
/* --- QQ:  800003751 -------------------------------------------------*/
/* 如果要在程序中使用此代码,请在程序中注明使用了STC的资料及程序        */
/*---------------------------------------------------------------------*/

#include "stc.h"
#include "usb_desc.h"

char code DEVICEDESC[18] =
{
    0x12,       // bLength(18);
    0x01,       // bDescriptorType(Device);
    0x00, 0x02, // bcdUSB(2.00);
    0xFF,       // bDeviceClass(0);
    0xFF,       // bDeviceSubClass0);
    0xFF,       // bDeviceProtocol(0);
    0x40,       // bMaxPacketSize0(64);
    0x5e, 0x04, // idVendor(34BF);
    0x8e, 0x02, // idProduct(FF04);
    0x14, 0x01, // bcdDevice(1.00);
    0x01,       // iManufacturer(1);
    0x02,       // iProduct(2);
    0x03,       // iSerialNumber(0);
    0x01,       // bNumConfigurations(1);
};

char code CONFIGDESC[153]=
{
    0x09,       // bLength(9);
    0x02,       // bDescriptorType(Configuration);
    0x99, 0x00, // wTotalLength(41);
    0x04,       // bNumInterfaces(1);
    0x01,       // bConfigurationValue(1);
    0x00,       // iConfiguration(0);
    0xa0,       // bmAttributes(BUSPower);
    0xfa,       // MaxPower(100mA);

    /* ---------------------------------------------------- */
    // Interface 0: Control Data
    0x09, // bLength
    0x04, // bDescriptorType (INTERFACE)
    0x00, // bInterfaceNumber
    0x00, // bAlternateSetting
    0x02, // bNumEndpoints
    0xFF, // bInterfaceClass
    0x5D, // bInterfaceSubClass
    0x01, // bInterfaceProtocol
    0x00, // iInterface
    // Unknown Descriptor (If0)
    0x11,                         // bLength
    0x21,                         // bDescriptorType
    0x00, 0x01, 0x01, 0x25,       // ???
    0x81,                         // bEndpointAddress (IN, 1)
    0x14,                         // bMaxDataSize
    0x00, 0x00, 0x00, 0x00, 0x13, // ???
    0x01,                         // bEndpointAddress (OUT, 1)
    0x08,                         // bMaxDataSize
    0x00, 0x00,                   // ???
    // Endpoint 1: Control Surface Send
    0x07,       // bLength
    0x05,       // bDescriptorType (ENDPOINT)
    0x81,       // bEndpointAddress (IN, 1)
    0x03,       // bmAttributes
    0x20, 0x00, // wMaxPacketSize
    0x04,       // bInterval
    // Endpoint 1: Control Surface Receive
    0x07,       // bLength
    0x05,       // bDescriptorType (ENDPOINT)
    0x01,       // bEndpointAddress (OUT, 1)
    0x03,       // bmAttributes
    0x20, 0x00, // wMaxPacketSize
    0x08,       // bInterval
    /* ---------------------------------------------------- */
    // Interface 1: Headset (and Expansion Port?)
    0x09, // bLength
    0x04, // bDescriptorType (INTERFACE)
    0x01, // bInterfaceNumber
    0x00, // bAlternateSetting
    0x04, // bNumEndpoints
    0xFF, // bInterfaceClass
    0x5D, // bInterfaceSubClass
    0x03, // bInterfaceProtocol
    0x00, // iInterface
    // Unknown Descriptor (If1)
    0x1B,                               // bLength
    0x21,                               // bDescriptorType
    0x00, 0x01, 0x01, 0x01,             // ???
    0x82,                               // bEndpointAddress (IN, 2)
    0x40,                               // bMaxDataSize
    0x01,                               // ???
    0x02,                               // bEndpointAddress (OUT, 2)
    0x20,                               // bMaxDataSize
    0x16,                               // ???
    0x83,                               // bEndpointAddress (IN, 3)
    0x00,                               // bMaxDataSize
    0x00, 0x00, 0x00, 0x00, 0x00, 0x16, // ???
    0x03,                               // bEndpointAddress (OUT, 3)
    0x00,                               // bMaxDataSize
    0x00, 0x00, 0x00, 0x00, 0x00,       // ???
    // Endpoint 2: Microphone Data Send
    0x07,       // bLength
    0x05,       // bDescriptorType (ENDPOINT)
    0x82,       // bEndpointAddress (IN, 2)
    0x03,       // bmAttributes
    0x20, 0x00, // wMaxPacketSize
    0x02,       // bInterval
    // Endpoint 2: Headset Audio Receive
    0x07,       // bLength
    0x05,       // bDescriptorType (ENDPOINT)
    0x02,       // bEndpointAddress (OUT, 2)
    0x03,       // bmAttributes
    0x20, 0x00, // wMaxPacketSize
    0x04,       // bInterval
    // Endpoint 3: Unknown, Send
    0x07,       // bLength
    0x05,       // bDescriptorType (ENDPOINT)
    0x83,       // bEndpointAddress (IN, 3)
    0x03,       // bmAttributes
    0x20, 0x00, // wMaxPacketSize
    0x40,       // bInterval
    // Endpoint 3: Unknown, Receive
    0x07,       // bLength
    0x05,       // bDescriptorType (ENDPOINT)
    0x03,       // bEndpointAddress (OUT, 3)
    0x03,       // bmAttributes
    0x20, 0x00, // wMaxPacketSize
    0x10,       // bInterval
    /* ---------------------------------------------------- */
    // Interface 2: Unknown
    0x09, // bLength
    0x04, // bDescriptorType (INTERFACE)
    0x02, // bInterfaceNumber
    0x00, // bAlternateSetting
    0x01, // bNumEndpoints
    0xFF, // bInterfaceClass
    0x5D, // bInterfaceSubClass
    0x02, // bInterfaceProtocol
    0x00, // iInterface
    // Unknown Descriptor (If2)
    0x09,                   // bLength
    0x21,                   // bDescriptorType
    0x00, 0x01, 0x01, 0x22, // ???
    0x84,                   // bEndpointAddress (IN, 4)
    0x07,                   // bMaxDataSize
    0x00,                   // ???
    // Endpoint 4: Unknown, Send
    0x07,       // bLength
    0x05,       // bDescriptorType (ENDPOINT)
    0x84,       // bEndpointAddress (IN, 4)
    0x03,       // bmAttributes
    0x20, 0x00, // wMaxPacketSize
    0x10,       // bInterval
    /* ---------------------------------------------------- */
    // Interface 3: Security Method
    0x09, // bLength
    0x04, // bDescriptorType (INTERFACE)
    0x03, // bInterfaceNumber
    0x00, // bAlternateSetting
    0x00, // bNumEndpoints
    0xFF, // bInterfaceClass
    0xFD, // bInterfaceSubClass
    0x13, // bInterfaceProtocol
    0x04, // iInterface
    // Unknown Descriptor (If3)
    0x06,                   // bLength
    0x41,                   // bDescriptorType
    0x00, 0x01, 0x01, 0x03, // ???
};

/*
Input Report:
0   Buttons (D0:LButton D1:RButton D2:MButton [D3:D7]:Pad)
1	X displacement (>0:right; <0:left)
2	Y displacement (>0:down; <0:up)
*/
char code HIDREPORTDESC[50] =
{
    0x05, 0x01, // USAGE_PAGE(Generic Desktop);
    0x09, 0x02, // USAGE(Mouse);
    0xa1, 0x01, // COLLECTION(Application);
    0x09, 0x01, //  USAGE(Pointer);
    0xa1, 0x00, //  COLLECTION(Physical);
    0x05, 0x09, //    USAGE_PAGE(Buttons);
    0x19, 0x01, //    USAGE_MINIMUM(1);
    0x29, 0x03, //    USAGE_MAXIMUM(3);
    0x15, 0x00, //    LOGICAL_MINIMUM(0);
    0x25, 0x01, //    LOGICAL_MAXIMUM(1);
    0x75, 0x01, //    REPORT_SIZE(1);
    0x95, 0x03, //    REPORT_COUNT(3);
    0x81, 0x02, //    INPUT(Data,Variable,Absolute);
    0x75, 0x05, //    REPORT_SIZE(5);
    0x95, 0x01, //    REPORT_COUNT(1);
    0x81, 0x01, //    INPUT(Constant);
    0x05, 0x01, //    USAGE_PAGE(Generic Desktop);
    0x09, 0x30, //    USAGE(X);
    0x09, 0x31, //    USAGE(Y);
    0x15, 0x81, //    LOGICAL_MINIMUM(-127);
    0x25, 0x7f, //    LOGICAL_MAXIMUM(127);
    0x75, 0x08, //    REPORT_SIZE(8);
    0x95, 0x02, //    REPORT_COUNT(2);
    0x81, 0x06, //    INPUT(Data, Variable, Relative);
    0xc0,       //  END_COLLECTION;
    0xc0,       // END_COLLECTION;
};

char code LANGIDDESC[4] =
{
    0x04,
    0x03,
    0x09,
    0x04,
};

char code MANUFACTDESC[8] =
{
    0x08,
    0x03,
    'S',
    0,
    'T',
    0,
    'C',
    0,
};

char code PRODUCTDESC[28] =
{
    0x1c,
    0x03,
    'S',
    0,
    'T',
    0,
    'C',
    0,
    ' ',
    0,
    'U',
    0,
    'S',
    0,
    'B',
    0,
    ' ',
    0,
    'M',
    0,
    'o',
    0,
    'u',
    0,
    's',
    0,
    'e',
    0,
};

char code PACKET0[2] =
{
    0,
    0,
};

char code PACKET1[2] =
{
    1,
    0,
};
