0 Replies Latest reply on Jun 27, 2013 2:14 PM by garimag_

    Using two PIDs for a device (the same firmware)- changing PID of a device in runtime, or based on a GPIO Pin status

       One of our customers wanted to implement something unique. I thought of posting it here. He wanted to use a single firmware for two devices and on the basis of the value of an external pin, it would enumerate with either of two PIDs. Say if GPIOx is 0, it enumerates as PID 0xABCD and if GPIOx is 1, it enumerates as PID 0x1234.




      There are multiple ways of implementing this:




      1. Use of two set of device descriptors: This can be done by defining two sets of descriptors in the USBFS configuration window, and then start the USBFS component with either of the device descriptors. USBFS_Start(uint8 device, uint8 mode) , here device will be 0 for first device descriptors and 1 for second. This will use more memory. You will need to store the same set of descriptors, which only differ by a PID at two memory locations.




      2. Define the descriptors in the Data memory (they are originally defined as constants) and change the PID in the descriptor in firmware: After the file USBFS_descr.c is created, one can copy all the descriptors in between the Custom Generated Descriptors comments and add "#define USER_SUPPLIED_DESCRIPTORS" before defining the descriptors . The keyword constant can be removed from the descriptor which we want to alter in firmware, in our case the device descriptors. For accessing the PID of the device, change USBFS_DEVICE0_DESCR[11] for LSB of PID and USBFS_DEVICE0_DESCR[12] for MSB of PID.
      Stop the component and Start it again. The device this time comes up as a device with the changed PID.

          Hope this information is helpful.