1 Reply Latest reply on Mar 5, 2020 11:32 PM by YatheeshK_36

    UVC host application KSP_NODE vs UVC extension unit descriptor


      I use test host application provided in the following link.

      UVC Extension unit




      I didn't change the UVC extension part in uvc.c and cyfxuvcdscr.c files.   UVC_EXTENSION_UNIT is enabled in uvc.h file.  The test host application works well with the AN75779 UVC firmware in terms of set and get complete firmware version.


      Now I am trying to implement SPI read/write sensor registers through  UVC extension.

      cyfxuvcdscr.c file, UVC EXTENSION UNIT descriptor is modified to be


              /* Extension Unit Descriptor */

              0x1C,                           /* Descriptor size */

              0x24,                           /* Class specific interface desc type */

              0x06,                           /* Extension Unit Descriptor type */

              0x03,                           /* ID of this terminal */

              //static const GUID <<name>> =

              //{ 0xacb6890c, 0xa3b3, 0x4060,{ 0x8b, 0x9a, 0xdf, 0x34, 0xee, 0xf3, 0x9a, 0x2e } };

              0x0C, 0x89, 0xB6, 0xAC,         /* GUID specific to AN75779 firmware. Obtained from Visual studio */

              0xB3, 0xA3, 0x60, 0x40,

              0x8B, 0x9A, 0xDF, 0x34,

              0xEE, 0xF3, 0x9A, 0x2E,

              0x02,                           /* Number of controls in this terminal */

              0x01,                           /* Number of input pins in this terminal */

              0x02,                           /* Source ID : 2 : Connected to Proc Unit */

              0x03,                           /* Size of controls field for this terminal : 3 bytes */

              0x03, 0x00, 0x00,               /* Controls supported */

              0x00,                           /* String descriptor index : Not used */

      uvc.h file add wvalue for SPI command


      /* Extension Unit Terminal Controls specific UVC control selector codes */

      #define CY_FX_UVC_XU_GET_FIRMWARE_VERSION_CONTROL           (uint16_t)(0x0100)

      #define CY_FX_UVC_XU_SPI_COMMAND                                         (uint16_t)(0x0200)

      /* Customer specific controls can be added here */



      But I am not sure on how to modify the function below to match like to identify read/write in the following function. There are 2 sensors needs be be configured using SPI. For example, SPI write sensor 1, register 0x02 with value 0x0001,

      SetGetExtensionUnit(xuGuidAN75779, 2, 2, flags, (void*)SPIparameter, 3, &readCount),


      in UVCHandleExtensionUnitRqts () function, bRequest value is used to identity which sensor, read/write operation. How the parameters in the above function is related to the bRequest value?


                  switch (bRequest)


                      case CY_FX_USB_UVC_SPI_SENSOR1_WR:   /* write to sensor 1  */

                  apiRetStatus = CyU3PUsbGetEP0Data (CY_FX_UVC_MAX_PROBE_SETTING_ALIGNED,

                                  glEp0Buffer, &readCount);

                          if (apiRetStatus == CY_U3P_SUCCESS)


                              /* Copy spi parameters sent by Host application */

                              CyU3PMemCopy(glFxUvcSPIbuf, glEp0Buffer, 3);




                      case CY_FX_USB_UVC_SPI_SENSOR1_WR: /* read from sensor 1 */

                          CyFxSpiReadReg2B(RegAddr, rd_buf)

                          CyU3PMemCopy(glEp0Buffer, glFxUvcSPIbuf, 5);

                          sendData = CyTrue;



      If it is the flags parameter,  how to use it? for KSPROPERTY_TYPE_SET | KSPROPERTY_TYPE_TOPOLOGY ?


      Thank you in advance.

        • 1. Re: UVC host application KSP_NODE vs UVC extension unit descriptor



          You can add the switch statement for sensor 1 and sensor 2 and their respective read and writes under CY_FX_USB_UVC_SET_CUR_REQ case in the firmware.

          The data received in the control endpoint can be used to select among the sensors and for read/write operation. The data buffer that is sent to the device needs to be altered accordingly.. for example, bit 0 of the data buffer is set to 1 to select sensor 1, and bit 1 of the data buffer is set for a write operation, the reset of the buffer can be filled with data. 

          In the host application only the data passed to the  SetGetExtensionUnit() function needs to be changed in that case.