User defined descriptors

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
himc_284346
Level 3
Level 3
Welcome! 10 replies posted 5 replies posted

Hi,

   

I have a PSoC Creator project with USBFS component. How can I use my own descriptors, with this project?

   

Regards,

   

HiZ

0 Likes
3 Replies
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

 User can provide descriptor for the USBFS component. If you place a USBFS component you will get USBFS_descr.c. In this file you have section to provide user supplied descriptor. In that section you can add the statement

   


#define USER_SUPPLIED_DESCRIPTORS
and then add your descriptor. Similar to the default descriptor you can give

uint8 CYCODE USBFS_1_DEVICE0_DESCR[] = {}
and give the values inside.

0 Likes
Anonymous
Not applicable

 Let me elaborate more on what PSoCRulez was trying to say:

   

After you add the USBFS component to a project and you compile it. You will see the following in the USBFS_descr.c file

   

/*****************************************************************************

   

*  User supplied descriptors.  If you want to specify your own descriptors,

   

*  remove the comments around the define USER_SUPPLIED_DESCRIPTORS below and

   

*  add your descriptors.

   

*****************************************************************************/

   

/* `#START USER_DESCRIPTORS_DECLARATIONS` Place your declaration here */

   

/* `#END` */

   

So simply remove the above comments. Write the Code:

   

#define USER_SUPPLIED_DESCRIPTORS

   

and then define all the descriptors - i.e. Device descriprtors, Configuration descriptors and String descriptors, HID descriptors.

   

But there is one very important thing. The whole code between #if !defined(USER_SUPPLIED_DESCRIPTORS) and #endif is no more defined. So you will have to:

   

1. Define all the descriptors that you will need, as none of these variables get defined.

   

2. Besides the descriptors there are many important LUTs - Look Up Tables that are defined after the descriptors. These LUTs are very crucial. They are being used by the APIs internally to get pointers to the descriptors when needed (eg: the setupcommand requires the LUT to point to the device descriptor).

   

You will require to define these LUTs as well.

   

Making the LUTs can be tedious and tricky.

   

It is better that you use the configuration window only to define the descriptors which will generate the proper LUT.

   

In case if you want to add something like an IAD (interface association descriptor), then generate the whole descriptors first, and then copy and paste them, do the changes here and there. You will not need any change in the LUTs in such a case and you can simply copy them.

   

Look once into the extra arrays in the end, other than the descriptors; you will understand my point.

   

Cheers.!!!

0 Likes
Anonymous
Not applicable

Hi there,

   

I am trying to add my own descriptor too and got stuck there. This is the extra descriptor:
 

   

#define USER_DESCRIPTORS_DECLARATIONS

   


/* Standard Device Qualifier Descriptor */

   

const uint8 CyFxUSBDeviceQualDscr[10u] =
    {
        0x0A,                           /* Descriptor Size */
        0x06,       /* Device Qualifier Descriptor Type */
        0x00,0x02,                      /* USB 2.0 */
        0x00,                           /* Device Class */
        0x00,                           /* Device Sub-class */
        0x00,                           /* Device protocol */
        0x40,                           /* Maxpacket size for EP0 : 64 bytes */
        0x01,                           /* Number of configurations */
        0x00                            /* Reserved */
    };
// #endif

   


 

   

So my questions are, first of all is this code correct? Is the #endif important, should I un-comment it? Is there any way I can add the Device Qualifier Descriptor from the configuration window? If not do I need to add LUTs for this descriptor too, and how? Thanks a bunch. Looking forward for your replies.

0 Likes