• AVR Freaks

Help needed for enumeration of generic and keyboard.

Author
Pic_worker34
New Member
  • Total Posts : 22
  • Reward points : 0
  • Joined: 2011/03/25 08:51:37
  • Location: 0
  • Status: offline
2011/03/25 09:29:26 (permalink)
0

Help needed for enumeration of generic and keyboard.

Hi,

I cannot get windows to enumerate one keyboard and one generic device at the same time. I'm using PIC18F4550.
Windows shows one device with an exclamation mark.
Am I missing something? Can this be done?

Here is my code if someone want to take a look at it.



[code]

usb_descriptor.c:


#include "usb.h"
#include "usb_function_hid.h"


/* Device Descriptor */
ROM USB_DEVICE_DESCRIPTOR device_dsc=
{
    0x12,    // Size of this descriptor in bytes
    USB_DESCRIPTOR_DEVICE,                // DEVICE descriptor type
    0x0200,                 // USB Spec Release Number in BCD format
    0x00,                   // Class Code
    0x00,                   // Subclass code
    0x00,                   // Protocol code
    USB_EP0_BUFF_SIZE,      // Max packet size for EP0, see usb_config.h
    0x04D8,                 // Vendor ID
    0x0043,                 // Product ID
    0x0002,                 // Device release number in BCD format
    0x01,                   // Manufacturer string index
    0x02,                   // Product string index
    0x00,                   // Device serial number string index
    0x01                    // Number of possible configurations
};

//////////////////////////// USB Vol Control///////////////////////////////////////
/* Configuration 1 Descriptor */
ROM BYTE configDescriptor1[]={
    /* Configuration Descriptor */
    0x09,//sizeof(USB_CFG_DSC),    // Size of this descriptor in bytes
    USB_DESCRIPTOR_CONFIGURATION,                // CONFIGURATION descriptor type
    0x46,0x00,            // Total length of data for this cfg (decimal= 70)
    2,                      // Number of interfaces in this cfg
    1,                      // Index value of this configuration
    0,                      // Configuration string index
    _DEFAULT | _SELF,               // Attributes, see usb_device.h
    50,                     // Max power consumption (2X mA)

    /* Interface Descriptor */
    0x09,//sizeof(USB_INTF_DSC),   // Size of this descriptor in bytes
    USB_DESCRIPTOR_INTERFACE,               // INTERFACE descriptor type
    0,                      // Interface Number
    0,                      // Alternate Setting Number
    2,                      // Number of endpoints in this intf
    HID_INTF,               // Class code
    0,     // Subclass code
    0,     // Protocol code
    0,                      // Interface string index

    /* HID Class-Specific Descriptor */
    0x09,//sizeof(USB_HID_DSC)+3,    // Size of this descriptor in bytes RRoj hack
    DSC_HID,                // HID descriptor type
    DESC_CONFIG_WORD(0x0111),                 // HID Spec Release Number in BCD format (1.11)
    0x00,                   // Country Code (0x00 for Not supported)
    HID_NUM_OF_DSC,         // Number of class descriptors, see usbcfg.h
    DSC_RPT,                // Report descriptor type
    DESC_CONFIG_WORD(33),   //sizeof(hid_rpt01),      // Size of the report descriptor
    
     /* Endpoint Descriptor */
    0x07,/*sizeof(USB_EP_DSC)*/
    USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
    HID_EP | _EP_IN,                   //EndpointAddress
    _INTERRUPT,                       //Attributes
    0x40,0x00,                  //size
    0x01,                        //Interval

    /* Endpoint Descriptor */
    0x07,/*sizeof(USB_EP_DSC)*/
    USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
    HID_EP | _EP_OUT,                   //EndpointAddress
    _INTERRUPT,                       //Attributes
    0x40,0x00,                  //size
    0x01                        //Interval

    //////////////////////////// LCD ///////////////////////////////////////
   
    /* Interface Descriptor */
    0x09, //sizeof(USB_INTF_DSC),   // Size of this descriptor in bytes
    USB_DESCRIPTOR_INTERFACE,      // INTERFACE descriptor type
    1,                      // Interface Number
    0,                      // Alternate Setting Number
    2,                      // Number of endpoints in this intf
    HID_INTF,               // Class code
    0,     // Subclass code
    0,     // Protocol code
    0,                      // Interface string index

    /* HID Class-Specific Descriptor */
    0x09,//sizeof(USB_HID_DSC)+3,   // Size of this descriptor in bytes
    DSC_HID,                 // HID descriptor type
    0x11,0x01,                 // HID Spec Release Number in BCD format (1.11)
    0x00,                   // Country Code (0x00 for Not supported)
    HID_NUM_OF_DSC,         // Number of class descriptors, see usbcfg.h
    DSC_RPT,                 // Report descriptor type
    DESC_CONFIG_WORD(31),           //sizeof(hid_rpt02),      // Size of the report descriptor


    /* Endpoint Descriptor */
    0x07,/*sizeof(USB_EP_DSC)*/
    USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
    HID_EP2 | _EP2_IN,                   //EndpointAddress
    _INTERRUPT,                       //Attributes
    0x40,0x00,                  //size
    0x01,                        //Interval

    /* Endpoint Descriptor */
    0x07,/*sizeof(USB_EP_DSC)*/
    USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
    HID_EP2 | _EP2_OUT,           //EndpointAddress
    _INTERRUPT,                 //Attributes
    0x40,0x00,                  //size
    0x01                        //Interval

   
};


//Language code string descriptor
ROM struct{BYTE bLength;BYTE bDscType;WORD string[1];}sd000={
sizeof(sd000),USB_DESCRIPTOR_STRING,{0x0409
}};

//Manufacturer string descriptor
ROM struct{BYTE bLength;BYTE bDscType;WORD string[25];}sd001={
sizeof(sd001),USB_DESCRIPTOR_STRING,
{'M','i','c','r','o','c','h','i','p',' ',
'T','e','c','h','n','o','l','o','g','y',' ','I','n','c','.'
}};

//Product string descriptor
ROM struct{BYTE bLength;BYTE bDscType;WORD string[20];}sd002={
sizeof(sd002),USB_DESCRIPTOR_STRING,
{'V','O','L','U','M','E',' ','C','O','N','T','R','O','L',' ','P','I','C','1','8'
}};

//Class specific descriptor - HID mouse USB Vol Control 
ROM struct{BYTE report[HID_RPT01_SIZE];}hid_rpt01={
    {    
    0x05, 0x0c,                    // USAGE_PAGE (Consumer Devices)
    0x09, 0x01,                    // USAGE (Consumer Control)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x85, 0x01,                    //   REPORT_ID (1) 
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
    0x09, 0xe9,                    //   USAGE (Volume Up)
    0x09, 0xea,                    //   USAGE (Volume Down)
    0x75, 0x01,                    //   REPORT_SIZE (1)
    0x95, 0x02,                    //   REPORT_COUNT (2)
    0x81, 0x06,                    //   INPUT (Data,Var,Rel)
    0x09, 0xe2,                    //   USAGE (Mute)
    0x95, 0x01,                    //   REPORT_COUNT (1)
    0x81, 0x06,                    //   INPUT (Data,Var,Rel)
    0x95, 0x05,                    //   REPORT_COUNT (5)
    0x81, 0x07,                    //   INPUT (Cnst,Var,Rel)
    0xc0                           // END_COLLECTION
}
};


//Class specific descriptor - Generic device LCD 
ROM struct{BYTE report[HID_RPT02_SIZE];}hid_rpt02={
{
    0x06, 0x00, 0xFF,       // Usage Page = 0xFF00 (Vendor Defined Page 1)
    0x09, 0x01,             // Usage (Vendor Usage 1)
    0xA1, 0x01,             // Collection (Application)
    0x85, 0x02,             //   REPORT_ID (2) 
    0x19, 0x01,             // Usage Minimum 
    0x29, 0x40,             //      Usage Maximum //64 input usages total (0x01 to 0x40)
    0x15, 0x00,             //      Logical Minimum (data bytes in the report may have minimum value = 0x00)
    0x26, 0xFF, 0x00,   //      Logical Maximum (data bytes in the report may have maximum value = 0x00FF = unsigned 255)
    0x75, 0x08,             //      Report Size: 8-bit field size
    0x95, 0x40,             //      Report Count: Make sixty-four 8-bit fields (the next time the parser hits an "Input", "Output", or "Feature" item)
    0x81, 0x00,             //      Input (Data, Array, Abs): Instantiates input packet fields based on the above report size, count, logical min/max, and usage.
    0x19, 0x01,             //      Usage Minimum 
    0x29, 0x40,             //      Usage Maximum //64 output usages total (0x01 to 0x40)
    0x91, 0x00,             //      Output (Data, Array, Abs): Instantiates output packet fields.  Uses same report size and count as "Input" fields, since nothing new/different was specified to the parser since the "Input" item.
    0xC0}                   // End Collection
};                  
                  


//Array of configuration descriptors
ROM BYTE *ROM USB_CD_Ptr[]=
{
    (ROM BYTE *ROM)&configDescriptor1
};

//Array of string descriptors
ROM BYTE *ROM USB_SD_Ptr[]=
{
    (ROM BYTE *ROM)&sd000,
    (ROM BYTE *ROM)&sd001,
    (ROM BYTE *ROM)&sd002
};

/** EOF usb_descriptors.c ***************************************************/

#endif


usb_config.h

/** ENDPOINTS ALLOCATION *******************************************/

/* HID */

#define HID_EP 1
#define HID_EP2                 2       // endpoint address for the second HID IF <--- add this line

#define HID_INT_OUT_EP_SIZE     1
#define HID_INT_IN_EP_SIZE      3

#define HID_NUM_OF_DSC          1

#define HID_RPT01_SIZE          33
#define HID_RPT02_SIZE          31

#define HID_INTF_ID 0x00
#define HID_INTF_ID1           0x01       // interface number for the second HID IF <--- add this line


usb_function_hid.c:

void USBCheckHIDRequest(void)
{
    if(SetupPkt.Recipient != USB_SETUP_RECIPIENT_INTERFACE_BITFIELD) return;
    if((SetupPkt.bIntfID != HID_INTF_ID) && (SetupPkt.bIntfID != HID_INTF_ID_1)) return;
    
    /*
     * There are two standard requests that hid.c may support.
     * 1. GET_DSC(DSC_HID,DSC_RPT,DSC_PHY);
     * 2. SET_DSC(DSC_HID,DSC_RPT,DSC_PHY);
     */
    if(SetupPkt.bRequest == USB_REQUEST_GET_DESCRIPTOR)
    {
        switch(SetupPkt.bDescriptorType)
        {
            case DSC_HID: //HID Descriptor          
               if(USBActiveConfiguration == 1)
                 {
                     if (SetupPkt.bIntfID == HID_INTF_ID)
                     {
                         USBEP0SendROMPtr(
                             (ROM BYTE*)&configDescriptor1 + 18,
                             sizeof(USB_HID_DSC)+3,
                             USB_EP0_INCLUDE_ZERO);
                     }
                     if (SetupPkt.bIntfID == HID_INTF_ID_1)
                     {
                         USBEP0SendROMPtr(
                             (ROM BYTE*)&configDescriptor1 + 43,
                             sizeof(USB_HID_DSC)+3,
                             USB_EP0_INCLUDE_ZERO);
                     }
                 }
                 break;

            case DSC_RPT:  //Report Descriptor           
               if(USBActiveConfiguration == 1)
                 {
                     if (SetupPkt.bIntfID == HID_INTF_ID)
                     {
                         USBEP0SendROMPtr(
                             (ROM BYTE*)&hid_rpt01,
                             HID_RPT01_SIZE,
                             USB_EP0_INCLUDE_ZERO);
                     }
                     if (SetupPkt.bIntfID == HID_INTF_ID_1)
                     {
                     USBEP0SendROMPtr(
                         (ROM BYTE*)&hid_rpt02,
                         HID_RPT02_SIZE,
                         USB_EP0_INCLUDE_ZERO);
                     }
                 }
                 break;
            case DSC_PHY:  //Physical Descriptor
//Note: The below placeholder code is commented out.  HID Physical Descriptors are optional and are not used
//in many types of HID applications.  If an application does not have a physical descriptor,
//then the device should return STALL in response to this request (stack will do this automatically
//if no-one claims ownership of the control transfer).
//If an application does implement a physical descriptor, then make sure to declare
//hid_phy01 (rom structure containing the descriptor data), and hid_phy01 (the size of the descriptors in bytes),
//and then uncomment the below code.
                //if(USBActiveConfiguration == 1)
                //{
                //    USBEP0SendROMPtr((ROM BYTE*)&hid_phy01, sizeof(hid_phy01), USB_EP0_INCLUDE_ZERO);
                //}
                break;
        }//end switch(SetupPkt.bDescriptorType)
    }//end if(SetupPkt.bRequest == GET_DSC)



[code]








#1

2 Replies Related Threads

    chinzei
    Super Member
    • Total Posts : 2250
    • Reward points : 0
    • Joined: 2003/11/07 12:39:02
    • Location: Tokyo, Japan
    • Status: offline
    Re:Help needed for enumeration of generic and keyboard. 2011/03/25 21:45:47 (permalink)
    0
    /* Configuration Descriptor */ 
     ..
     0x46,0x00,            // Total length of data for this cfg (decimal= 70)

    The total length is 73
    Write down this field as follows, so that the compiler calculates it for you.
    DESC_CONFIG_WORD( 9 + 2 * (9 + 9 + 7 + 7) ),

     
    //Class specific descriptor - HID mouse USB Vol Control 
    ROM struct{BYTE report[HID_RPT01_SIZE];}hid_rpt01={
        {    
        0x05, 0x0c,                    // USAGE_PAGE (Consumer Devices)
        0x09, 0x01,                    // USAGE (Consumer Control)
        0xa1, 0x01,                    // COLLECTION (Application)
        0x85, 0x01,                    //   REPORT_ID (1)         // <------ no report ID required
        0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
        0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
        0x09, 0xe9,                    //   USAGE (Volume Up)
        0x09, 0xea,                    //   USAGE (Volume Down)
        0x75, 0x01,                    //   REPORT_SIZE (1)
        0x95, 0x02,                    //   REPORT_COUNT (2)
        0x81, 0x06,                    //   INPUT (Data,Var,Rel)  // <------ 0x81, 0x02, // INPUT (Data,Var,Abs)

    You are making a composite device, in which two HID interfaces are independent each other. You don't need the report ID, because the two report descriptors are also independent.
    In the second report descriptor, too, no report ID is required.

    Volume up/down is RTC (Re-Trigger Control) type. This type of control has to be absolute, instead of relative.
    Mute definition is fine.

    Tsuneo
    post edited by chinzei - 2011/03/25 22:01:29
    #2
    Pic_worker34
    New Member
    • Total Posts : 22
    • Reward points : 0
    • Joined: 2011/03/25 08:51:37
    • Location: 0
    • Status: offline
    Re:Help needed for enumeration of generic and keyboard. 2011/03/29 08:43:55 (permalink)
    0
    Thanx a lot chinzei! My device now enumerates.
    The length of the config was indeed wrong.
    Another site that helped me alot to create the enumeration process for composite device is this one:

    http://www.waitingforfriday.com/index.php/C64_VICE_Front-End

    Here is my device descriptor working:



    usb_descriptor.c


    #ifndef __USB_DESCRIPTORS_C
    #define __USB_DESCRIPTORS_C


    /** INCLUDES *******************************************************/
    #include "usb.h"
    #include "LCD_monitor_hid.h"




    /** CONSTANTS ******************************************************/


    /* Device Descriptor */
    ROM USB_DEVICE_DESCRIPTOR device_dsc=
    {
        0x12,                         // Size of this descriptor in bytes
        USB_DESCRIPTOR_DEVICE,        // DEVICE descriptor type
        0x0200,                  // USB Spec Release Number in BCD format
        0x00,                    // Class Code
        0x00,                    // Subclass code
        0x00,                    // Protocol code
        USB_EP0_BUFF_SIZE,        // Max packet size for EP0, see usb_config.h
        MY_VID,                  // Vendor ID, see usb_config.h
        MY_PID,                  // Product ID, see usb_config.h
        0x0002,                  // Device release number in BCD format
        0x01,                    // Manufacturer string index
        0x02,                    // Product string index
        0x00,                    // Device serial number string index
        0x01                      // Number of possible configurations
    };


    /* Configuration 1 Descriptor */
    ROM BYTE configDescriptor1[]={
        /* Configuration Descriptor */
        0x09,                         //sizeof(USB_CFG_DSC),Size of this descriptor in bytes
        USB_DESCRIPTOR_CONFIGURATION, // CONFIGURATION descriptor type
        DESC_CONFIG_WORD(0x0049),     // Total length of data for this cfg (73)
        2,                            // Number of interfaces in this cfg
        1,                        // Index value of this configuration
        0,                        // Configuration string index
        _DEFAULT | _SELF,             // Attributes, see usb_device.h
        50,                      // Max power consumption (2X mA)

        /*Keyboard HID Interface Descriptor */
        0x09,                         //sizeof(USB_INTF_DSC), Size of this descriptor in bytes
        USB_DESCRIPTOR_INTERFACE,     // INTERFACE descriptor type
        0,                            // Interface Number
        0,                            // Alternate Setting Number
        2,                            // Number of endpoints in this intf
        HID_INTF,                     // Class code
        0,                            // Subclass code
        0,                            // Protocol code
        2,                            // Interface string index


        /* HID Class-Specific Descriptor */
         0x09,                        //sizeof(USB_HID_DSC)+3, Size of this descriptor in bytes RRoj hack
        DSC_HID,                      // HID descriptor type
        DESC_CONFIG_WORD(0x0111),     // HID Spec Release Number in BCD format (1.11)
        0x00,                         // Country Code (0x00 for Not supported)
        HID_NUM_OF_DSC_1,             // Number of class descriptors, see usbcfg.h
        DSC_RPT,                      // Report descriptor type
        DESC_CONFIG_WORD(HID_RPT01_SIZE), //Size of the 1st report descriptor
        
        /*Keyboard HID Endpoint Descriptor */
        0x07,                         /*sizeof(USB_EP_DSC)*/
        USB_DESCRIPTOR_ENDPOINT,     //Endpoint Descriptor
        HID_EP_1 | _EP_IN,           //EndpointAddress
        _INTERRUPT,                  //Attributes
        DESC_CONFIG_WORD(64),        //size
        0x01,                        //Interval


        /*Keyboard HID Endpoint Descriptor */
        0x07,/*sizeof(USB_EP_DSC)*/
        USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
        HID_EP_1 | _EP_OUT,         //EndpointAddress
        _INTERRUPT,                 //Attributes
        DESC_CONFIG_WORD(64),       //size
        0x01,                       //Interval

    /*LCD Monitor Generic Interface Descriptor */
        0x09,                       //sizeof(USB_INTF_DSC) Size of this descriptor in bytes
        USB_DESCRIPTOR_INTERFACE,   // INTERFACE descriptor type
        1,                          // Interface Number
        0,                          // Alternate Setting Number
        2,                          // Number of endpoints in this intf
        HID_INTF,                   // Class code
        0,        // Subclass code
        0,        // Protocol code
        3,                          // Interface string index


        /* LCD Monitor Generic Class-Specific Descriptor */
        0x09,                       //sizeof(USB_HID_DSC)+3, Size of this descriptor in bytes
        DSC_HID,                 // HID descriptor type
        DESC_CONFIG_WORD(0x0111),   // HID Spec Release Number in BCD format (1.11)
        0x00,                       // Country Code (0x00 for Not supported)
        HID_NUM_OF_DSC_2,         // Number of class descriptors, see usbcfg.h
        DSC_RPT,                 // Report descriptor type
        DESC_CONFIG_WORD(HID_RPT02_SIZE),// Size of the 2nd report descriptor
        
        /* LCD Monitor Generic Endpoint Descriptor */
        0x07,/*sizeof(USB_EP_DSC)*/
        USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
        HID_EP_2 | _EP_IN,          //EndpointAddress
        _INTERRUPT,                 //Attributes
        DESC_CONFIG_WORD(64),       //size
        0x01,                       //Interval


        /*LCD Monitor Generic  Endpoint Descriptor */
        0x07,/*sizeof(USB_EP_DSC)*/
        USB_DESCRIPTOR_ENDPOINT,    //Endpoint Descriptor
        HID_EP_2 | _EP_OUT,         //EndpointAddress
        _INTERRUPT,                 //Attributes
        DESC_CONFIG_WORD(64),       //size
        0x01                        //Interval


    };




    //Language code string descriptor
    ROM struct{BYTE bLength;BYTE bDscType;WORD string[1];}sd000={
    sizeof(sd000),USB_DESCRIPTOR_STRING,{0x0409
    }};


    //Manufacturer string descriptor
    ROM struct{BYTE bLength;BYTE bDscType;WORD string[25];}sd001={
    sizeof(sd001),USB_DESCRIPTOR_STRING,
    {'M','i','c','r','o','c','h','i','p',' ',
    'T','e','c','h','n','o','l','o','g','y',' ','I','n','c','.'
    }};


    //Keyboard HID string descriptor
    ROM struct{BYTE bLength;BYTE bDscType;WORD string[20];}sd002={
    sizeof(sd002),USB_DESCRIPTOR_STRING,
    {'V','O','L','U','M','E',' ','C','O','N','T','R','O','L',' ','P','I','C','1','8'
    }};




    //LCD Monitor string descriptor
    ROM struct{BYTE bLength;BYTE bDscType;WORD string[11];}sd003={
    sizeof(sd003),USB_DESCRIPTOR_STRING,
    {'L','C','D',' ','M','O','N','I','T','O','R'
    }};




    //Array of configuration descriptors
    ROM BYTE *ROM USB_CD_Ptr[]=
    {
        (ROM BYTE *ROM)&configDescriptor1
    };




    //Array of string descriptors
    ROM BYTE *ROM USB_SD_Ptr[]=
    {
        (ROM BYTE *ROM)&sd000,
        (ROM BYTE *ROM)&sd001,
        (ROM BYTE *ROM)&sd002,
    (ROM BYTE *ROM)&sd003
        
    };


    //Class specific descriptor USB VOLUME CONTROL KEYBOARD - HID 
    ROM struct{BYTE report[HID_RPT01_SIZE];}hid_rpt01={
        {    
        0x05, 0x0c,                    // USAGE_PAGE (Consumer Devices)
        0x09, 0x01,                    // USAGE (Consumer Control)
        0xa1, 0x01,                    // COLLECTION (Application)
        0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
        0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
        0x09, 0xe9,                    //   USAGE (Volume Up)
        0x09, 0xea,                    //   USAGE (Volume Down)
        0x75, 0x01,                    //   REPORT_SIZE (1)
        0x95, 0x02,                    //   REPORT_COUNT (2)
        0x81, 0x06,                    //   INPUT (Data,Var,Rel)
        0x09, 0xe2,                    //   USAGE (Mute)
        0x95, 0x01,                    //   REPORT_COUNT (1)
        0x81, 0x06,                    //   INPUT (Data,Var,Rel)
        0x95, 0x05,                    //   REPORT_COUNT (5)
        0x81, 0x07,                    //   INPUT (Cnst,Var,Rel)
        0xc0                           // END_COLLECTION
    }
    };  


    //Class specific descriptor - LCD MONITOR GENERIC HID 
    ROM struct{BYTE report[HID_RPT02_SIZE];}hid_rpt02={
    {
        0x06, 0x00, 0xFF,       // Usage Page = 0xFF00 (Vendor Defined Page 1)
        0x09, 0x01,             // Usage (Vendor Usage 1)
        0xA1, 0x01,             // Collection (Application)
        0x19, 0x01,             //      Usage Minimum 
        0x29, 0x40,             //      Usage Maximum //64 input usages total (0x01 to 0x40)
        0x15, 0x00,             //      Logical Minimum (data bytes in the report may have minimum value = 0x00)
        0x26, 0xFF, 0x00,   //      Logical Maximum (data bytes in the report may have maximum value = 0x00FF = unsigned 255)
        0x75, 0x08,             //      Report Size: 8-bit field size
        0x95, 0x40,             //      Report Count: Make sixty-four 8-bit fields (the next time the parser hits an "Input", "Output", or "Feature" item)
        0x81, 0x00,             //      Input (Data, Array, Abs): Instantiates input packet fields based on the above report size, count, logical min/max, and usage.
        0x19, 0x01,             //      Usage Minimum 
        0x29, 0x40,             //      Usage Maximum //64 output usages total (0x01 to 0x40)
        0x91, 0x00,             //      Output (Data, Array, Abs): Instantiates output packet fields.  Uses same report size and count as "Input" fields, since nothing new/different was specified to the parser since the "Input" item.
        0xC0}                   // End Collection
    };                                  


    #endif





    usb_config.h


    /********************************************************************
     FileName:     usb_config.h
     Dependencies: Always: GenericTypeDefs.h, usb_device.h
                   Situational: usb_function_hid.h, usb_function_cdc.h, usb_function_msd.h, etc.
     Processor: PIC18 or PIC24 USB Microcontrollers
     Hardware: The code is natively intended to be used on the following
      hardware platforms: PICDEM™ FS USB Demo Board, 
      PIC18F87J50 FS USB Plug-In Module, or
      Explorer 16 + PIC24 USB PIM.  The firmware may be
      modified for use on other USB platforms by editing the
      HardwareProfile.h file.
     Complier:   Microchip C18 (for PIC18) or C30 (for PIC24)
     Company: Microchip Technology, Inc.


     Software License Agreement:


     The software supplied herewith by Microchip Technology Incorporated
     (the “Company”) for its PIC® Microcontroller is intended and
     supplied to you, the Company’s customer, for use solely and
     exclusively on Microchip PIC Microcontroller products. The
     software is owned by the Company and/or its supplier, and is
     protected under applicable copyright laws. All rights are reserved.
     Any use in violation of the foregoing restrictions may subject the
     user to criminal sanctions under applicable laws, as well as to
     civil liability for the breach of the terms and conditions of this
     license.


     THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
     WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
     TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
     PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
     IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
     CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.


    ********************************************************************
     File Description:


     Change History:
      Rev   Date         Description
      1.0   11/19/2004   Initial release
      2.1   02/26/2007   Updated for simplicity and to use common
                         coding style
     *******************************************************************/


    /*********************************************************************
     * Descriptor specific type definitions are defined in: usbd.h
     ********************************************************************/


    #ifndef USBCFG_H
    #define USBCFG_H


    /** DEFINITIONS ****************************************************/
    #define USB_EP0_BUFF_SIZE 8 // Valid Options: 8, 16, 32, or 64 bytes.
    // Using larger options take more SRAM, but
    // does not provide much advantage in most types
    // of applications.  Exceptions to this, are applications
    // that use EP0 IN or OUT for sending large amounts of
    // application related data.

    #define USB_MAX_NUM_INT     1   // For tracking Alternate Setting
    #define USB_MAX_EP_NUMBER    2


    //Device descriptor - if these two definitions are not defined then
    //  a ROM USB_DEVICE_DESCRIPTOR variable by the exact name of device_dsc
    //  must exist.
    #define USB_USER_DEVICE_DESCRIPTOR &device_dsc
    #define USB_USER_DEVICE_DESCRIPTOR_INCLUDE extern ROM USB_DEVICE_DESCRIPTOR device_dsc


    //Configuration descriptors - if these two definitions do not exist then
    //  a ROM BYTE *ROM variable named exactly USB_CD_Ptr[] must exist.
    #define USB_USER_CONFIG_DESCRIPTOR USB_CD_Ptr
    #define USB_USER_CONFIG_DESCRIPTOR_INCLUDE extern ROM BYTE *ROM USB_CD_Ptr[]


    //Make sure only one of the below "#define USB_PING_PONG_MODE"
    //is uncommented.
    //#define USB_PING_PONG_MODE USB_PING_PONG__NO_PING_PONG
    #define USB_PING_PONG_MODE USB_PING_PONG__FULL_PING_PONG
    //#define USB_PING_PONG_MODE USB_PING_PONG__EP0_OUT_ONLY
    //#define USB_PING_PONG_MODE USB_PING_PONG__ALL_BUT_EP0 //NOTE: This mode is not supported in PIC18F4550 family rev A3 devices




    #define USB_POLLING
    //#define USB_INTERRUPT


    /* Parameter definitions are defined in usb_device.h */
    #define USB_PULLUP_OPTION USB_PULLUP_ENABLE
    //#define USB_PULLUP_OPTION USB_PULLUP_DISABLED


    #define USB_TRANSCEIVER_OPTION USB_INTERNAL_TRANSCEIVER
    //External Transceiver support is not available on all product families.  Please
    //  refer to the product family datasheet for more information if this feature
    //  is available on the target processor.
    //#define USB_TRANSCEIVER_OPTION USB_EXTERNAL_TRANSCEIVER


    #define USB_SPEED_OPTION USB_FULL_SPEED
    //#define USB_SPEED_OPTION USB_LOW_SPEED //(not valid option for PIC24F devices)


    #define USB_SUPPORT_DEVICE
    #define MY_VID 0x04D8
    #define MY_PID 0x0081
    #define USB_NUM_STRING_DESCRIPTORS 6


    //#define USB_INTERRUPT_LEGACY_CALLBACKS
    #define USB_ENABLE_ALL_HANDLERS
    //#define USB_ENABLE_SUSPEND_HANDLER
    //#define USB_ENABLE_WAKEUP_FROM_SUSPEND_HANDLER
    //#define USB_ENABLE_SOF_HANDLER
    //#define USB_ENABLE_ERROR_HANDLER
    //#define USB_ENABLE_OTHER_REQUEST_HANDLER
    //#define USB_ENABLE_SET_DESCRIPTOR_HANDLER
    //#define USB_ENABLE_INIT_EP_HANDLER
    //#define USB_ENABLE_EP0_DATA_HANDLER
    //#define USB_ENABLE_TRANSFER_COMPLETE_HANDLER


    /** DEVICE CLASS USAGE *********************************************/
    #define USB_USE_HID


    /** ENDPOINTS ALLOCATION *******************************************/


    /* Volume Control Keyboard HID */
    #define HID_INTF_ID_1           0x00
    #define HID_EP_1 1
    #define HID_INT_OUT_EP_SIZE_1   1
    #define HID_INT_IN_EP_SIZE_1    3
    #define HID_NUM_OF_DSC_1        1
    #define HID_RPT01_SIZE          31




    /* LCD Monitor generic HID */
    #define HID_INTF_ID_2           0x01
    #define HID_EP_2 2
    #define HID_INT_OUT_EP_SIZE_2   3
    #define HID_INT_IN_EP_SIZE_2    3
    #define HID_NUM_OF_DSC_2        1
    #define HID_RPT02_SIZE          29


    /** DEFINITIONS ****************************************************/


    #endif //USBCFG_H









    #3
    Jump to:
    © 2019 APG vNext Commercial Version 4.5