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

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

cross mob
LuCu_4098176
Level 3
Level 3

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.

0 Likes
1 Solution
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

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

View solution in original post

0 Likes
2 Replies
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

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

0 Likes

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.

0 Likes