4 Replies Latest reply on Mar 17, 2012 11:56 PM by anand.srinivasan.asokan

    CyAPI.lib XferData Interrupt

    michael.courtney

      I have gotten the CyAPI.lib interface working for data transfers in both directions. Right now, it seems that the only way to know if data has been received from the USB peripheral is to poll the IN endpoint using XferData and then check the return value. I would like to have an interrupt or windows message to let me know when data has arrived so that the code doesn't waste time polling. Is there a way to do this?

        • 1. Re: CyAPI.lib XferData Interrupt
          gayathri.vasudevan

           Hi,

             

           

             

          There is no way the device can intimate the host when the data is ready. Since the USB protocol is host controlled, it is the host that has to request for data. If there is data in the buffer, device will respond by sending the data and Xferdata will return TRUE, else FALSE. So, polling is the only way out. This is so in USB2.0.

             

          This polling feature has been improved upon in USB 3.0. In USB 3.0 device can send Asynchronous notifications to the device, instead of host polling.

             

           

             

          Regards,

             

          Gayathri

          • 2. Re: CyAPI.lib XferData Interrupt
            al.jumper

            Is it possible to solve this problem using INTERRUPT endpoint? Is this case the host controller in PC iself will poll the endopint without loading of user app. Does anybody have the experience of doing so? Does CYPRESS provode an example code (like BUKLOOP example) for demonstration of interrupt transfer functionality and configuring FX2, user application and CyApi to use windows messages for notification of data availiability?

            • 3. Re: CyAPI.lib XferData Interrupt
              gayathri.vasudevan

               Hi,

                 

               

                 

              Even for INTERRUPT endpoints, the application will have to poll for the data from INTERRUPT IN endpoint, if you are using some vendor ecific spdevice bound to CyUSB.sys. But if the device is something like a mouse/keyboard that is bound to the Windows HID driver, then the polling will be taken care of by that. But in the other case, the application itself has to keep calling the XferData for reading the data in fixed intervals.

                 

               

                 

              Regards,

                 

              Gayathri

              • 4. Re: CyAPI.lib XferData Interrupt
                anand.srinivasan.asokan

                Hi,

                   

                Though USB protocol defines the polling interval for interrupt endpoint the host won't poll unless it has buffer to store the received data i.e. the application or driver has to setup the buffer and then send reqeust to interrupt endpoint.

                   

                For class specific devices like HID devices the host has a native driver and knows what to do with the data so it polls by default and processes the data. In custom class devices we define how the data is being used and what it is needed so host won't poll by default. So you either have to queue up requests in the application or move the  polling to the driver by writing a custom driver if you want the polling at regular intervals.

                   

                Regards,

                   

                Anand