This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/MSP430F5529: Linking error USB CDC

Part Number: MSP430F5529

Tool/software: TI C/C++ Compiler

Error[e27]: Entry "CdcReadCtrl" in module descriptors ( C:\00Gyro_072618\00Gyro\Debug\Obj\descriptors.r43 ) redefined in module UsbCdc ( C:\00Gyro_072618\00Gyro\Debug\Obj\

I get this error using IAR and the USB CDC files that I add to my project. I can see where this is defined in UsbCdc.h, but can't find the offending definition.

Any help is appreciated.

  • Hello,

    Could you please provide more information on what example project you are building and what versions of MSPWare, CCS, compiler, etc. you are using so that I can try to recreate the issue?

    Best regards,

    Matt
  • Sorry, will do. Give me a bit.
  • IAR 7.12.2
    USB DEVELOPERS PKG 5_20_06_02
    CDC_virtualCOMport project.

    I ran the descriptor tool and generated the descriptors.c/h.
    It all compiles with just the one linker error above.

    Thank you for your help.
  • The sample project compiles and links just fine.]
    I'm adding just a CDC subset to an existing project using the instructions given in the USB API programmers guide page 26.
  • Thank you for providing that additional information!

    I am going to loop in an engineer in the MSP430 SW team who will be able to provide further assistance using the USB development package. Thank you for your patience.

    Best regards,

    Matt
  • Thanks so much.
  • Hi,

    Can I see the contents of your descriptors.c and descriptors.h that you generated from the descriptor tool?

    Thanks,
    Wallace
  • Yes. Here they are:

    //<MUDTCG_COPYRIGHT>
    //<MUDTCG_DATE>
    /*-----------------------------------------------------------------------------+
    | Include files 
    |-----------------------------------------------------------------------------*/
    #include "device.h"
    #include "defMSP430USB.h"
    #include "usb.h"             // USB-specific Data Structures
    #include "descriptors.h"
    #include "UsbCdc.h"
    //#include <USB_API/USB_HID_API/UsbHidReq.h>
    
    
    /*-----------------------------------------------------------------------------+
    | Device Descriptor 
    |-----------------------------------------------------------------------------*/
    uint8_t const abromDeviceDescriptor[SIZEOF_DEVICE_DESCRIPTOR] = {
        SIZEOF_DEVICE_DESCRIPTOR,               // Length of this descriptor
        DESC_TYPE_DEVICE,                       // Type code of this descriptor
        0x00, 0x02,                             // Release of USB spec
        0x02,                                   // Device's base class code
        0x00,                                   // Device's sub class code
        0x00,                                   // Device's protocol type code
        EP0_PACKET_SIZE,                        // End point 0's packet size
        USB_VID&0xFF, USB_VID>>8,               // Vendor ID for device, TI=0x0451
                                                // You can order your own VID at www.usb.org"
        USB_PID&0xFF, USB_PID>>8,               // Product ID for device,
                                                // this ID is to only with this example
        VER_FW_L, VER_FW_H,                     // Revision level of device
        1,                                      // Index of manufacturer name string desc
        2,                                      // Index of product name string desc
        USB_STR_INDEX_SERNUM,                   // Index of serial number string desc
        1                                       //  Number of configurations supported
    };
    
    /*-----------------------------------------------------------------------------+
    | Configuration Descriptor                                                     |
    |-----------------------------------------------------------------------------*/
    const struct abromConfigurationDescriptorGroup abromConfigurationDescriptorGroup=
    {
        /* Generic part */
        {
            // CONFIGURATION DESCRIPTOR (9 bytes)
            SIZEOF_CONFIG_DESCRIPTOR,                          // bLength
            DESC_TYPE_CONFIG,                                  // bDescriptorType
            DESCRIPTOR_TOTAL_LENGTH, 0x00,                     // wTotalLength
            USB_NUM_INTERFACES,                                // bNumInterfaces
            USB_CONFIG_VALUE,                                  // bConfigurationvalue
            CONFIG_STRING_INDEX,                               // iConfiguration Description offset
            USB_SUPPORT_SELF_POWERED | USB_SUPPORT_REM_WAKE,   // bmAttributes, bus power, remote wakeup
            USB_MAX_POWER                                      // Max. Power Consumption
        },
        /******************************************************* start of CDC*************************************/
    
        {
            /* start CDC[0] */
            {
    
            //INTERFACE DESCRIPTOR (9 bytes)
            0x09,                              // bLength: Interface Descriptor size
            DESC_TYPE_INTERFACE,               // bDescriptorType: Interface
            CDC0_COMM_INTERFACE,               // bInterfaceNumber
            0x00,                              // bAlternateSetting: Alternate setting
            0x01,                              // bNumEndpoints: Three endpoints used
            0x02,                              // bInterfaceClass: Communication Interface Class
            0x02,                              // bInterfaceSubClass: Abstract Control Model
            0x01,                              // bInterfaceProtocol: Common AT commands
            INTF_STRING_INDEX + 0,             // iInterface:
    
            //Header Functional Descriptor
            0x05,                                // bLength: Endpoint Descriptor size
            0x24,                                // bDescriptorType: CS_INTERFACE
            0x00,                                // bDescriptorSubtype: Header Func Desc
            0x10,                                // bcdCDC: spec release number
            0x01,
    
            //Call Managment Functional Descriptor
            0x05,                                // bFunctionLength
            0x24,                                // bDescriptorType: CS_INTERFACE
            0x01,                                // bDescriptorSubtype: Call Management Func Desc
            0x00,                                // bmCapabilities: D0+D1
            CDC0_DATA_INTERFACE,                // bDataInterface: 0
    
            //ACM Functional Descriptor
            0x04,                                // bFunctionLength
            0x24,                                // bDescriptorType: CS_INTERFACE
            0x02,                                // bDescriptorSubtype: Abstract Control Management desc
            0x02,                                // bmCapabilities
    
            // Union Functional Descriptor
            0x05,                               // Size, in bytes
            0x24,                               // bDescriptorType: CS_INTERFACE
            0x06,                                // bDescriptorSubtype: Union Functional Desc
            CDC0_COMM_INTERFACE,                // bMasterInterface -- the controlling intf for the union
            CDC0_DATA_INTERFACE,                // bSlaveInterface -- the controlled intf for the union
    
            //EndPoint Descriptor for Interrupt endpoint
            SIZEOF_ENDPOINT_DESCRIPTOR,         // bLength: Endpoint Descriptor size
            DESC_TYPE_ENDPOINT,                 // bDescriptorType: Endpoint
            CDC0_INTEP_ADDR,                    // bEndpointAddress: (IN2)
            EP_DESC_ATTR_TYPE_INT,                // bmAttributes: Interrupt
            0x40, 0x00,                         // wMaxPacketSize, 64 bytes
            0xFF,                                // bInterval
    
            //DATA INTERFACE DESCRIPTOR (9 bytes)
            0x09,                                // bLength: Interface Descriptor size
            DESC_TYPE_INTERFACE,                // bDescriptorType: Interface
            CDC0_DATA_INTERFACE,                // bInterfaceNumber
            0x00,                               // bAlternateSetting: Alternate setting
            0x02,                               // bNumEndpoints: Three endpoints used
            0x0A,                               // bInterfaceClass: Data Interface Class
            0x00,                               // bInterfaceSubClass:
            0x00,                               // bInterfaceProtocol: No class specific protocol required
            0x00,                                // iInterface:
    
            //EndPoint Descriptor for Output endpoint
            SIZEOF_ENDPOINT_DESCRIPTOR,         // bLength: Endpoint Descriptor size
            DESC_TYPE_ENDPOINT,                    // bDescriptorType: Endpoint
            CDC0_OUTEP_ADDR,                    // bEndpointAddress: (OUT3)
            EP_DESC_ATTR_TYPE_BULK,                // bmAttributes: Bulk
            0x40, 0x00,                         // wMaxPacketSize, 64 bytes
            0xFF,                                 // bInterval: ignored for Bulk transfer
    
            //EndPoint Descriptor for Input endpoint
            SIZEOF_ENDPOINT_DESCRIPTOR,         // bLength: Endpoint Descriptor size
            DESC_TYPE_ENDPOINT,                    // bDescriptorType: Endpoint
            CDC0_INEP_ADDR,                        // bEndpointAddress: (IN3)
            EP_DESC_ATTR_TYPE_BULK,                // bmAttributes: Bulk
            0x40, 0x00,                         // wMaxPacketSize, 64 bytes
            0xFF                                // bInterval: ignored for bulk transfer
            }
    
            /* end CDC[0]*/
        }    /******************************************************* end of CDC**************************************/
    
        
            
                
    };
    
    /*-----------------------------------------------------------------------------+
    | String Descriptor                                                            |
    |-----------------------------------------------------------------------------*/
    uint8_t const abromStringDescriptor[] = {
        // String index0, language support
    
        4,        // Length of language descriptor ID
        3,        // LANGID tag
        0x09, 0x04,    // 0x0409 for English
    
    
        // String index1, Manufacturer
    
        36,        // Length of this string descriptor
        3,        // bDescriptorType
        'T',0x00,'e',0x00,'x',0x00,'a',0x00,'s',0x00,' ',0x00,
        'I',0x00,'n',0x00,'s',0x00,'t',0x00,'r',0x00,'u',0x00,
        'm',0x00,'e',0x00,'n',0x00,'t',0x00,'s',0x00,
    
        // String index2, Product
    
        38,        // Length of this string descriptor
        3,        // bDescriptorType
        'M',0x00,'S',0x00,'P',0x00,'4',0x00,'3',0x00,'0',0x00,
        '-',0x00,'U',0x00,'S',0x00,'B',0x00,' ',0x00,'E',0x00,
        'x',0x00,'a',0x00,'m',0x00,'p',0x00,'l',0x00,'e',0x00,
    
        // String index3, Serial Number
    
        4,        // Length of this string descriptor
        3,        // bDescriptorType
        '0',0x00,
    
        // String index4, Configuration String
    
        22,        // Length of this string descriptor
        3,        // bDescriptorType
        'M',0x00,'S',0x00,'P',0x00,'4',0x00,'3',0x00,'0',0x00,
        ' ',0x00,'U',0x00,'S',0x00,'B',0x00,
    
    
        // String index5, Interface String
        46,        // Length of this string descriptor
        3,        // bDescriptorType
        'V',0x00,'i',0x00,'r',0x00,'t',0x00,'u',0x00,'a',0x00,
        'l',0x00,' ',0x00,'C',0x00,'O',0x00,'M',0x00,' ',0x00,
        'P',0x00,'o',0x00,'r',0x00,'t',0x00,' ',0x00,'(',0x00,
        'C',0x00,'D',0x00,'C',0x00,')',0x00
    };
    
    
    
    /**** Populating the endpoint information handle here ****/
    const struct tUsbHandle stUsbHandle[]=
    {
        {
            CDC0_INEP_ADDR,
            CDC0_OUTEP_ADDR,
            1,
            CDC_CLASS,
            IEP1_X_BUFFER_ADDRESS,
            IEP1_Y_BUFFER_ADDRESS,
            OEP2_X_BUFFER_ADDRESS,
            OEP2_Y_BUFFER_ADDRESS,
            IEP2_X_BUFFER_ADDRESS,
            IEP2_Y_BUFFER_ADDRESS
        }
    
        
            
                
    };
    
    //-------------DEVICE REQUEST LIST---------------------------------------------
    
    const tDEVICE_REQUEST_COMPARE tUsbRequestList[] = 
    {
    
        {
            //---- CDC0Class Requests -----//
            // GET LINE CODING
            USB_REQ_TYPE_INPUT | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE,
            USB_CDC_GET_LINE_CODING,
            0x00,0x00,                                 // always zero
            CDC0_COMM_INTERFACE,0x00,                 // CDC interface is0
            0x07,0x00,                                 // Size of Structure (data length)
            0xff,&usbGetLineCoding,
        },
        {
            // SET LINE CODING
            USB_REQ_TYPE_OUTPUT | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE,
            USB_CDC_SET_LINE_CODING,
            0x00,0x00,                                 // always zero
            CDC0_COMM_INTERFACE,0x00,                  // CDC interface is 0
            0x07,0x00,                                 // Size of Structure (data length)
            0xff,&usbSetLineCoding,
        },
        {
            // SET CONTROL LINE STATE
            USB_REQ_TYPE_OUTPUT | USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE,
            USB_CDC_SET_CONTROL_LINE_STATE,
            0xff,0xff,                                 // Contains data
            CDC0_COMM_INTERFACE,0x00,                 // CDC interface is 0
            0x00,0x00,                                 // No further data
            0xcf,&usbSetControlLineState,
            },
    
    
        {
            //---- USB Standard Requests -----//
                // clear device feature
                USB_REQ_TYPE_OUTPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE,
                USB_REQ_CLEAR_FEATURE,
                FEATURE_REMOTE_WAKEUP,0x00,         // feature selector
                0x00,0x00,
                0x00,0x00,
                0xff,&usbClearDeviceFeature,
        },
        {
    
                // clear endpoint feature
                USB_REQ_TYPE_OUTPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_ENDPOINT,
                USB_REQ_CLEAR_FEATURE,
                FEATURE_ENDPOINT_STALL,0x00,
                0xff,0x00,
                0x00,0x00,
                0xf7,&usbClearEndpointFeature,
        },
        {
                // get configuration
                USB_REQ_TYPE_INPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE,
                USB_REQ_GET_CONFIGURATION,
                0x00,0x00, 
                0x00,0x00, 
                0x01,0x00,
                0xff,&usbGetConfiguration,
        },
        {
                // get device descriptor
                USB_REQ_TYPE_INPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE,
                USB_REQ_GET_DESCRIPTOR,
                0xff,DESC_TYPE_DEVICE,              // bValueL is index and bValueH is type
                0xff,0xff,
                0xff,0xff,
                0xd0,&usbGetDeviceDescriptor,
        },
        {
                // get configuration descriptor
                USB_REQ_TYPE_INPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE,
                USB_REQ_GET_DESCRIPTOR,
                0xff,DESC_TYPE_CONFIG,              // bValueL is index and bValueH is type
                0xff,0xff,
                0xff,0xff,
                0xd0,&usbGetConfigurationDescriptor,
        },
        {
                // get string descriptor
                USB_REQ_TYPE_INPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE,
                USB_REQ_GET_DESCRIPTOR,
                0xff,DESC_TYPE_STRING,              // bValueL is index and bValueH is type
                0xff,0xff,
                0xff,0xff,
                0xd0,&usbGetStringDescriptor,
        },
        {
               // get interface
                USB_REQ_TYPE_INPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_INTERFACE,
                USB_REQ_GET_INTERFACE,
                0x00,0x00,
                0xff,0xff,
                0x01,0x00,
                0xf3,&usbGetInterface,
        },
        {
                // get device status
                USB_REQ_TYPE_INPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE,
                USB_REQ_GET_STATUS,
                0x00,0x00,
                0x00,0x00,
                0x02,0x00,
                0xff,&usbGetDeviceStatus, 
        },
        {
                // get interface status
                USB_REQ_TYPE_INPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_INTERFACE,
                USB_REQ_GET_STATUS,
                0x00,0x00,
                0xff,0x00,
                0x02,0x00,
                0xf7,&usbGetInterfaceStatus,
        },
        {
                // get endpoint status
                USB_REQ_TYPE_INPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_ENDPOINT,
                USB_REQ_GET_STATUS,
                0x00,0x00,
                0xff,0x00,
                0x02,0x00,
                0xf7,&usbGetEndpointStatus,
        },
        {
                // set address
                USB_REQ_TYPE_OUTPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE,
                USB_REQ_SET_ADDRESS,
                0xff,0x00,
                0x00,0x00,
                0x00,0x00,
                0xdf,&usbSetAddress,
        },
        {
                // set configuration
                USB_REQ_TYPE_OUTPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE,
                USB_REQ_SET_CONFIGURATION,
                0xff,0x00,
                0x00,0x00,
                0x00,0x00,
                0xdf,&usbSetConfiguration,
        },
        {
               // set device feature
                USB_REQ_TYPE_OUTPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_DEVICE,
                USB_REQ_SET_FEATURE,
                0xff,0x00,                      // feature selector
                0x00,0x00,
                0x00,0x00,
                0xdf,&usbSetDeviceFeature,
        },
        {
                // set endpoint feature
                USB_REQ_TYPE_OUTPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_ENDPOINT,
                USB_REQ_SET_FEATURE,
                0xff,0x00,                      // feature selector
                0xff,0x00,                      // endpoint number <= 127
                0x00,0x00,
                0xd7,&usbSetEndpointFeature,
        },
        {
                // set interface
                USB_REQ_TYPE_OUTPUT | USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_INTERFACE,
                USB_REQ_SET_INTERFACE,
                0xff,0x00,                      // feature selector
                0xff,0x00,                      // interface number
                0x00,0x00,
                0xd7,&usbSetInterface,
        },
        {
    
                // end of usb descriptor -- this one will be matched to any USB request
                // since bCompareMask is 0x00.
                0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 
                0x00,&usbInvalidRequest     // end of list
        }
    	
    };
    
    
    /*-----------------------------------------------------------------------------+
    | END OF Descriptor.c FILE
    |-----------------------------------------------------------------------------*/
    
    
    //Released_Version_5_20_06_02
    
    // Generated by MSP USB Descriptor Tool: Fri Feb 15 11:23:15 EST 2019
    
    
    #include <stdint.h>
    #include "usb.h"
    
    #ifndef _DESCRIPTORS_H_
    #define _DESCRIPTORS_H_
    
    #ifdef __cplusplus
    extern "C"
    {
    #endif
    
    /*-----------------------------------------------------------------------------+
    | Include files                                                                |
    |-----------------------------------------------------------------------------*/
    
    //***********************************************************************************************
    // CDC or HID - Define both for composite support
    //***********************************************************************************************
    #define _CDC_          // Needed for CDC inteface
    
    //***********************************************************************************************
    // CONFIGURATION CONSTANTS
    //***********************************************************************************************
    // These constants configure the API stack and help define the USB descriptors.
    // Refer to Sec. 6 of the MSP430 USB CDC API Programmer's Guide for descriptions of these constants.
    
    // Configuration Constants that can change
    // #define that relates to Device Descriptor
    #define USB_VID               0x2047    // Vendor ID (VID)
    #define USB_PID               0x03DF        // Product ID (PID)
    
    /*----------------------------------------------------------------------------+
    | Firmware Version                                                            |
    | How to detect version number of the FW running on MSP430?                   |
    | on Windows Open ControlPanel->Systems->Hardware->DeviceManager->Ports->     |
    |         Msp430->ApplicationUART->Details                                    |
    +----------------------------------------------------------------------------*/
    #define VER_FW_H              0x02          // Device release number, in binary-coded decimal
    #define VER_FW_L              0x00          // Device release number, in binary-coded decimal
    
    // If a serial number is to be reported, set this to the index within the string descriptor
    //of the dummy serial number string.  It will then be automatically handled by the API.
    // If no serial number is to be reported, set this to 0.
    #define USB_STR_INDEX_SERNUM  3
    #define PHDC_ENDPOINTS_NUMBER               2  // bulk in, bulk out
    
    
    #define DESCRIPTOR_TOTAL_LENGTH            67            // wTotalLength, This is the sum of configuration descriptor length  + CDC descriptor length  + HID descriptor length
    #define USB_NUM_INTERFACES                  2            //Number of implemented interfaces.
    
    #define CDC0_COMM_INTERFACE                0              // Comm interface number of CDC0
    #define CDC0_DATA_INTERFACE                1              // Data interface number of CDC0
    #define CDC0_INTEP_ADDR                    0x81              // Interrupt Endpoint Address of CDC0
    #define CDC0_OUTEP_ADDR                    0x02              // Output Endpoint Address of CDC0
    #define CDC0_INEP_ADDR                    0x82              // Input Endpoint Address of CDC0
    
    #define CDC_NUM_INTERFACES                   1           //  Total Number of CDCs implemented. should set to 0 if there are no CDCs implemented.
    #define HID_NUM_INTERFACES                   0           //  Total Number of HIDs implemented. should set to 0 if there are no HIDs implemented.
    #define MSC_NUM_INTERFACES                   0           //  Total Number of MSCs implemented. should set to 0 if there are no MSCs implemented.
    #define PHDC_NUM_INTERFACES                  0           //  Total Number of PHDCs implemented. should set to 0 if there are no PHDCs implemented.
    // Interface numbers for the implemented CDSs and HIDs, This is to use in the Application(main.c) and in the interupt file(UsbIsr.c).
    #define CDC0_INTFNUM                0
    #define MSC_MAX_LUN_NUMBER                   1           // Maximum number of LUNs supported
    
    #define PUTWORD(x)      ((x)&0xFF),((x)>>8)
    #define USB_OUTEP_INT_EN BIT0 | BIT2 
    #define USB_INEP_INT_EN BIT0 | BIT1 | BIT2 
    #define USB_USE_INTERNAL_3V3LDO TRUE
    #define USB_XT2_BYPASS_MODE FALSE
    
    
    // MCLK frequency of MCU, in Hz
    // For running higher frequencies the Vcore voltage adjustment may required.
    // Please refer to Data Sheet of the MSP430 device you use
    #define USB_PLL_XT        2                  // Defines which XT is used by the PLL (1=XT1, 2=XT2)
    #define USB_DISABLE_XT_SUSPEND 0             // If non-zero, then USB_suspend() will disable the oscillator
                                                 // that is designated by USB_PLL_XT; if zero, USB_suspend won't
                                                 // affect the oscillator
    #define USB_DMA_CHAN           DMA_CHANNEL_0   // Set to 0xFF if no DMA channel will be used 0..7 for selected DMA channel
    
    // Controls whether the remote wakeup feature is supported by this device.
    // A value of 0x20 indicates that is it supported (this value is the mask for
    // the bmAttributes field in the configuration descriptor).
    // A value of zero indicates remote wakeup is not supported.
    // Other values are undefined, as they will interfere with bmAttributes.
    #define USB_SUPPORT_REM_WAKE 0x00
    // Controls whether the application is self-powered to any degree.  Should be
    // set to 0x40, unless the USB device is fully supplied by the bus.
    #define USB_SUPPORT_SELF_POWERED 0xc0
    
    // Controls what the device reports to the host regarding how much power it will
    // consume from VBUS.  Expressed in 2mA units; that is, the number of mA
    // communicated is twice the value of this field.
    #define USB_MAX_POWER 0x32
    //Configuration constants that can not change ( Fixed Values)
    #define CDC_CLASS  2
    #define HID_CLASS  3
    #define MSC_CLASS  4
    #define PHDC_CLASS 5
    
    #define MAX_PACKET_SIZE   0x40              // Max size of the USB packets.
    
    //***********************************************************************************************
    // DESCRIPTOR CONSTANTS
    //***********************************************************************************************
    #define SIZEOF_DEVICE_DESCRIPTOR  0x12
    #define MAX_STRING_DESCRIPTOR_INDEX 5
    //#define SIZEOF_REPORT_DESCRIPTOR  36
    //#define USBHID_REPORT_LENGTH      64  // length of whole HID report (including Report ID)
    #define CONFIG_STRING_INDEX       4
    #define INTF_STRING_INDEX         5
    #define USB_CONFIG_VALUE          0x01
    //***********************************************************************************************
    // OUTWARD DECLARATIONS
    //***********************************************************************************************
    
    //Calculates the endpoint descriptor block number from given address
    #define EDB(addr) ((addr&0x07)-1)
    
    /* Structure for generic part of configuration descriptor */
    struct abromConfigurationDescriptorGenric
    {
        uint8_t sizeof_config_descriptor;            // bLength
         uint8_t desc_type_config;                    // bDescriptorType: 2
        uint8_t sizeof_configuration_descriptor1;    // wTotalLength
        uint8_t sizeof_configuration_descriptor2;
        uint8_t usb_num_configurations;              // bNumInterfaces
        uint8_t bconfigurationvalue;                 // bConfigurationValue
        uint8_t  config_string_index;                // iConfiguration Description offset
         uint8_t mattributes;                         // bmAttributes, bus power, remote wakeup
        uint8_t usb_max_power;                       // Max. Power Consumption at 2mA unit
    };
    
    /************************************************CDC Descriptor**************************/
    struct abromConfigurationDescriptorCdc
    {
    // interface descriptor (9 bytes)
        uint8_t blength_intf;                          // blength: interface descriptor size
        uint8_t desc_type_interface;                  // bdescriptortype: interface
        uint8_t interface_number_cdc;                // binterfacenumber
        uint8_t balternatesetting;                   // balternatesetting: alternate setting
        uint8_t bnumendpoints;                       // bnumendpoints: three endpoints used
        uint8_t binterfaceclass;                     // binterfaceclass: communication interface class
        uint8_t binterfacesubclass;                  // binterfacesubclass: abstract control model
        uint8_t binterfaceprotocol;                  // binterfaceprotocol: common at commands 
        uint8_t intf_string_index;                      // interface:
    //header functional descriptor
        uint8_t blength_header;                      // blength: endpoint descriptor size
        uint8_t bdescriptortype_header;              // bdescriptortype: cs_interface
        uint8_t bdescriptorsubtype_header;              // bdescriptorsubtype: header func desc
        uint8_t bcdcdc1;
        uint8_t bcdcdc2;                              // bcdcdc: spec release number
    
    //call managment functional descriptor
        uint8_t bfunctionlength;                      // bfunctionlength
        uint8_t bdescriptortype_c;                      // bdescriptortype: cs_interface
        uint8_t bdescriptorsubtype_c;                  // bdescriptorsubtype: call management func desc
        uint8_t bmcapabilities;                      // bmcapabilities: d0+d1
        uint8_t intf_number_cdc;                     // bdatainterface: 0
    
    //acm functional descriptor
        uint8_t bfunctionlength_acm;                  // bfunctionlength
        uint8_t bdescriptortype_acm;                  // bdescriptortype: cs_interface
        uint8_t bdescriptorsubtype_acm;              // bdescriptorsubtype: abstract control management desc
        uint8_t bmcapabilities_acm;                  // bmcapabilities
    
    // Union Functional Descriptor
        uint8_t bLength_ufd;                         // Size, in bytes
        uint8_t bdescriptortype_ufd;                 // bDescriptorType: CS_INTERFACE
        uint8_t bdescriptorsubtype_ufd;              // bDescriptorSubtype: Union Functional Desc
        uint8_t bmasterinterface_ufd;                // bMasterInterface -- the controlling intf for the union
        uint8_t bslaveinterface_ufd;                 // bSlaveInterface -- the controlled intf for the union
    
    //Interrupt end point related fields
        uint8_t sizeof_epintep_descriptor;           // blength: endpoint descriptor size
        uint8_t desc_type_epintep;                      // bdescriptortype: endpoint
        uint8_t cdc_intep_addr;                      // bendpointaddress: (in2)
        uint8_t epintep_desc_attr_type_int;          // bmattributes: interrupt
        uint8_t epintep_wmaxpacketsize1;
        uint8_t epintep_wmaxpacketsize;                 // wmaxpacketsize, 64 bytes
        uint8_t epintep_binterval;                   // binterval
    
    // Data interface descriptor (9 bytes)
        uint8_t blength_slaveintf;                      // blength: interface descriptor size
        uint8_t desc_type_slaveinterface;              // bdescriptortype: interface
        uint8_t interface_number_slavecdc;           // binterfacenumber
        uint8_t balternatesetting_slave;             // balternatesetting: alternate setting
        uint8_t bnumendpoints_slave;                 // bnumendpoints: three endpoints used
        uint8_t binterfaceclass_slave;               // binterfaceclass: data interface class
        uint8_t binterfacesubclass_slave;            // binterfacesubclass: abstract control model
        uint8_t binterfaceprotocol_slave;            // binterfaceprotocol: common at commands
        uint8_t intf_string_index_slave;              // interface:
    
    // Bulk out end point related fields
        uint8_t sizeof_outep_descriptor;             // blength: endpoint descriptor size
        uint8_t desc_type_outep;                      // bdescriptortype: endpoint
        uint8_t cdc_outep_addr;                      // bendpointaddress: (out3)
        uint8_t outep_desc_attr_type_bulk;              // bmattributes: bulk
        uint8_t outep_wmaxpacketsize1;
        uint8_t outep_wmaxpacketsize2;               // wmaxpacketsize, 64 bytes
        uint8_t outep_binterval;                       // binterval: ignored for bulk transfer
    
    // Bulk in related fields
        uint8_t sizeof_inep_descriptor;              // blength: endpoint descriptor size
        uint8_t desc_type_inep;                      // bdescriptortype: endpoint
        uint8_t cdc_inep_addr;                          // bendpointaddress: (in3)
        uint8_t inep_desc_attr_type_bulk;              // bmattributes: bulk
        uint8_t inep_wmaxpacketsize1;
        uint8_t inep_wmaxpacketsize2;                // wmaxpacketsize, 64 bytes
        uint8_t inep_binterval;                      // binterval: ignored for bulk transfer
    }    ;
    
    /**************************************HID descriptor structure *************************/
    struct abromConfigurationDescriptorHid
    {
    //INTERFACE DESCRIPTOR (9 bytes)
        uint8_t sizeof_interface_descriptor;        // Desc Length
        uint8_t desc_type_interface;                // DescriptorType
        uint8_t interface_number_hid;               // Interface number
        uint8_t balternatesetting;                  // Any alternate settings if supported
        uint8_t bnumendpoints;                      // Number of end points required
        uint8_t binterfaceclass;                    // Class ID
        uint8_t binterfacesubclass;                 // Sub class ID
        uint8_t binterfaceprotocol;                 // Protocol
        uint8_t intf_string_index;                  // String Index
    
    //hid descriptor (9 bytes)
        uint8_t blength_hid_descriptor;             // HID Desc length
        uint8_t hid_descriptor_type;                // HID Desc Type
        uint8_t hidrevno1;                          // Rev no 
        uint8_t hidrevno2;                          // Rev no - 2nd part
        uint8_t tcountry;                              // Country code 
        uint8_t numhidclasses;                      // Number of HID classes to follow    
        uint8_t report_descriptor_type;             // Report desc type 
        uint8_t tlength;                            // Total length of report descriptor
        uint8_t size_rep_desc;
    
    //input end point descriptor (7 bytes)
        uint8_t size_inp_endpoint_descriptor;       // End point desc size
        uint8_t desc_type_inp_endpoint;             // Desc type
        uint8_t hid_inep_addr;                      // Input end point address
        uint8_t ep_desc_attr_type_inp_int;          // Type of end point
        uint8_t  inp_wmaxpacketsize1;               // Max packet size
        uint8_t  inp_wmaxpacketsize2;
        uint8_t inp_binterval;                      // bInterval in ms
    
     // Output end point descriptor; (7 bytes)
        uint8_t size_out_endpoint_descriptor;       // Output endpoint desc size
        uint8_t desc_type_out_endpoint;             // Desc type
        uint8_t hid_outep_addr;                     // Output end point address
        uint8_t ep_desc_attr_type_out_int;          // End point type
        uint8_t out_wmaxpacketsize1;                // Max packet size
        uint8_t out_wmaxpacketsize2;
        uint8_t out_binterval;                      // bInterval in ms
    };
    
    /**************************************MSC descriptor structure *************************/
    struct abromConfigurationDescriptorMsc
    {
    // INTERFACE DESCRIPTOR (9 bytes)
        uint8_t sizeof_interface_descriptor;         // Desc Length
        uint8_t desc_type_interface;                 // DescriptorType
        uint8_t interface_number_hid;                // Interface number
        uint8_t balternatesetting;                   // Any alternate settings if supported
        uint8_t bnumendpoints;                       // Number of end points required
        uint8_t binterfaceclass;                     // Class ID
        uint8_t binterfacesubclass;                  // Sub class ID
        uint8_t binterfaceprotocol;                  // Protocol
        uint8_t intf_string_index;                   // String Index
    
    // input end point descriptor (7 bytes)
        uint8_t size_inp_endpoint_descriptor;        // End point desc size
        uint8_t desc_type_inp_endpoint;              // Desc type
        uint8_t hid_inep_addr;                       // Input end point address
        uint8_t ep_desc_attr_type_inp_int;           // Type of end point
        uint8_t  inp_wmaxpacketsize1;                // Max packet size
        uint8_t  inp_wmaxpacketsize2;
        uint8_t inp_binterval;                       // bInterval in ms
    
    // Output end point descriptor; (7 bytes)
        uint8_t size_out_endpoint_descriptor;        // Output endpoint desc size
        uint8_t desc_type_out_endpoint;              // Desc type
        uint8_t hid_outep_addr;                      // Output end point address
        uint8_t ep_desc_attr_type_out_int;           // End point type
        uint8_t out_wmaxpacketsize1;                 // Max packet size
        uint8_t out_wmaxpacketsize2;
        uint8_t out_binterval;                       // bInterval in ms
    };
    
    /* Global structure having Generic,CDC,HID, MSC structures */
    struct  abromConfigurationDescriptorGroup
    {
        /* Generic part of config descriptor */
        const struct abromConfigurationDescriptorGenric abromConfigurationDescriptorGenric;
    #ifdef _MSC_
        /* MSC descriptor structure */
        const struct abromConfigurationDescriptorMsc stMsc[MSC_NUM_INTERFACES];
    #endif
    #ifdef _CDC_ 
        /* CDC descriptor structure */
        const struct abromConfigurationDescriptorCdc stCdc[CDC_NUM_INTERFACES];
    #endif
    #ifdef _HID_
        /* HID descriptor structure */
        const struct abromConfigurationDescriptorHid stHid[HID_NUM_INTERFACES];
    #endif
    #ifdef _PHDC_
    /* PDC descriptor structure */
        const struct abromConfigurationDescriptorPhdc stPhdc[PHDC_NUM_INTERFACES];
    #endif
    };
    
    extern const struct  abromConfigurationDescriptorGroup abromConfigurationDescriptorGroup;
    extern uint8_t const abromDeviceDescriptor[SIZEOF_DEVICE_DESCRIPTOR];
    extern uint8_t const abromStringDescriptor[];
    //extern uint8_t const abromReportDescriptor[SIZEOF_REPORT_DESCRIPTOR];
    
    /* Handle Structure - Will be populated in descriptors.c based on number of CDC,HID interfaces */
    struct tUsbHandle
    {
        uint8_t ep_In_Addr;               // Input EP Addr 
        uint8_t ep_Out_Addr;              // Output EP Addr 
        uint8_t edb_Index;                // The EDB index 
        uint8_t dev_Class;                // Device Class- 2 for CDC, 3 for HID 
        uint16_t intepEP_X_Buffer;         // Interupt X Buffer Addr 
        uint16_t intepEP_Y_Buffer;         // Interupt Y Buffer Addr 
        uint16_t oep_X_Buffer;             // Output X buffer Addr 
        uint16_t oep_Y_Buffer;             // Output Y buffer Addr 
        uint16_t iep_X_Buffer;             // Input X Buffer Addr 
        uint16_t iep_Y_Buffer;             // Input  Y Buffer Addr 
    };
    
    extern const struct tUsbHandle stUsbHandle[CDC_NUM_INTERFACES + HID_NUM_INTERFACES + MSC_NUM_INTERFACES + PHDC_NUM_INTERFACES]; 
    extern const tDEVICE_REQUEST_COMPARE tUsbRequestList[];
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif
    
    /*------------------------ Nothing Below This Line --------------------------*/
    
    //Released_Version_5_20_06_02
    

  • Any help here? Thank you.
  • Hi:

    Forgive my delay in response.

    Is this the full error?

    Error[e27]: Entry "CdcReadCtrl" in module descriptors ( C:\00Gyro_072618\00Gyro\Debug\Obj\descriptors.r43 ) redefined in module UsbCdc ( C:\00Gyro_072618\00Gyro\Debug\Obj\

    I see what you mean now, although as expected, I wasn't able to reproduce this from my side because this is most likely a local pathing issue. I notice that in your descriptors, you had changed some of the #includes from "USB_API/USB_Common/device.h" to "device.h". If everything is done correctly, this shouldn't be an issue, but I would like to ask, were there any steps in section 4.4 of the USB Programmer's Guide that were confusing and not sure if done correctly in the project?

    Alternatively, the easiest and fastest way to resolve this is if you were able to send me your IAR project either here or through private message, then I can take a full look at your project settings.

  • Well, I believe I did it all correctly but it looks like something is included twice or some such. I would like to send the whole project through private message. How do I do this? Thank you for your help.
  • This issue was resolved, simply make sure to mark your project with "Multi-file Compilation" option.

    Also use this post as reference:

**Attention** This is a public forum