我用CY8C34 46PVI-076创建了一个“测试”(HID)USB
PCB,并在Windows 10框(使用CyUSB。DLL)上有一个简单的“测试”应用程序(Cβ)。我可以连接到设备,并可以通过应用程序上的“发送”/“ReV”按钮发送/ReV数据,从而确认到/来自设备的
通信。我不知道,我也找不到关于它的任何信息。应用程序如何告知USB设备是否有数据可不请求?比如说,我给设备增加一个按钮。我可以用我想发送给PC应用程序的数据填充缓冲区,但是应用程序如何知道数据是可用的?是否有一些中断标志我可以测试,或者我必须轮询设备(并测试一些状态位)来查看数据是否可用。我宁愿不投票,因为叶(n)MSEC间隔,数据可能是悬而未决的,帽子可能会导致一个滞后的时候,按钮被推到时间的应用程序推送。在某个时间点增加轮询时间,以减少滞后,将使应用程序迟缓用户输入。
这可能是我面对的那些解决方案之一,但我就是看不见。
例如,从PSoC Creator来说,事情很简单,看看数据是从PC发送的,我可以做一些类似的事情;
如果(UBJGETEPSTATE(OUTHEP)= = UBSUTHOUB Buffr充分)…处理应用程序的数据。
那么,有什么类似的我可以做的应用程序?类似的东西;
如果(MyHIDDEV)???????= = iNi Buffr充分)。处理设备数据。
以上来自于百度翻译
以下为原文
I've created a 'test' (HID) USB PCB using CY8C3446PVI-076 and have a simple 'test' app (C#) on a Windows 10 box (using CyUSB.dll). I can connect to the device and can send/recv data via a "Send"/"Recv" buttons on the app, so communica
tion to/from device is confirmed. What I can't figure out, nor can I find any info about it, is.. how can the app tell if there is data available from the USB device without requesting it? For example, say I add a push button to the device. I can fill the IN buffer with the data I want to send to the PC app but how does the app know data is available? Is there some interrupt flag I can test, or do I have to poll the device (and test some status bit) to see if data is available. I'd prefer not to poll as that leaves (n)mSec intervals where data could be pending and hat may cause a lag from the time the button is pushed to the time the app acks the push .. at some point increasing poll time, to reduce the lag, will make the app sluggish to user inputs.
This is probably one of those solutions that is staring me in the face, but I just can't see it.
For example; from PSoC Creator things are simple enough; To see if data was sent from PC I can do something like;
if (USB_GetEPState(OUT_EP) == USB_OUT_BUFFER_FULL) .. process the app's data..
So, is there something similar I can do from the app? Something like;
if (myHidDev.????? == IN_BUFFER_FULL) .. process device data..
0