2 Replies Latest reply on Apr 13, 2020 9:45 AM by LuCu_4098176

    how to check if there is data available on a fx3 ?

    LuCu_4098176

      Hello,

       

      I need to check from the PC if I have data available before initiate a bulk read on the PC.

      Should I need to implement myself a Vendor request that replies with the CyU3PGpifGetSMState() for example ?

      (or something similar ?)

       

      I see it responds to the standard commands get_status 0x80, 0x81, 0x82 but I don't see these giving me any useful information.

       

      Any Help ?

       

      Luis C.

        • 1. Re: how to check if there is data available on a fx3 ?
          YatheeshK_36

          Hello,

           

          There are no standard commands to know if the endpoint is filled with data.

          One thing that you can do is to use a manual DMA channel and continuously monitor the event CY_U3P_DMA_CB_PROD_EVENT and CY_U3P_DMA_CB_CONS_EVENT. Declare a variable and increment it whenever a PROD event occurs and decrement the same when a CONS event occurs. If the variable value is non zero then there is data buffer available to be read from the endpoint .

           

          Best Regards,

          Yatheesh

          • 2. Re: how to check if there is data available on a fx3 ?
            LuCu_4098176

            Hello Yatheesh,

             

            Thanks for your reply. Indeed very helpful.

             

            As the SlaveFifo design for FX3 actually uses a manual DMA I firstly had to modify the

            dmaCfg.notification

             

            from:

                 /* Enabling the callback for produce event. */

                 dmaCfg.notification = CY_U3P_DMA_CB_PROD_EVENT;

             

            to:

                 /* Enabling the callback for produce and consume events. */

                dmaCfg.notification = CY_U3P_DMA_CB_PROD_EVENT | CY_U3P_DMA_CB_CONS_EVENT;

             

            Then added at the end of the DMA callback function "CyFxSlFifoPtoUDmaCallback"

             

            ...

                if (type == CY_U3P_DMA_CB_PROD_EVENT) 

                    BufferAvailable++; 

                if (type == CY_U3P_DMA_CB_CONS_EVENT)

                    BufferAvailable--; 

            }

             

            Works perfectly.

             

            Thanks.

            Luis C.