ARM AT91SAM - 带有回调问题的简单 USB 读取
我有一个关于 USB 读取和回调的非常简单的问题。
我想设置对缓冲区的读取,然后等到传输完成后再使用缓冲区中的数据。该芯片的框架已设置为通过调用 USBD_Read 来启动 USB 传输,如果传输正确启动,则将返回成功。当传输完成时,回调将被调用。这就是我目前正在做的事情:
volatile unsigned char readArrayLock = 0;
//USB 读取回调
void readNextDataArrayCallback(void *pArg, unsigned char status, unsigned int transfered, unsigned int remaining){
readArrayLock = 0;
}
//读取 USB 数据
readArrayLock = ! USBD_Read(0x2, g_pucDataArray, g_iDataPacketSize, (TransferCallback)readNextDataArrayCallback, 0);
//等待
while (readArrayLocked);
//然后使用数据
我遇到的问题是,在 while 循环中似乎永远不会调用中断。如果我注释掉 while 循环,则会调用中断。基本上我的问题是如何使用回调中断 while 循环?
我该如何解决这个问题?或者有更好的方法来实现同样的目标吗?
谢谢
I have a very simple question about USB reads with call backs.
I want to set up a read to a buffer then wait until the transfer is complete before using the data in the buffer. The framework for the chip is set up so that you start the USB transfer by calling USBD_Read, which will return success if the transfer started correctly. The callback will then be called when the transfer is finsihed. This is how I am currently doing it:
volatile unsigned char readArrayLock = 0;
//USB read callback
void readNextDataArrayCallback(void *pArg, unsigned char status, unsigned int transfered, unsigned int remaining){
readArrayLock = 0;
}
//To read the usb data
readArrayLock = ! USBD_Read(0x2, g_pucDataArray, g_iDataPacketSize, (TransferCallback)readNextDataArrayCallback, 0);
// waiting
while (readArrayLocked);
//Then use data
The problem I am having is that the interupt never seems to be called whilst in the while loop. If i comment out the while loop the interupt is called. Basically my question is how can I interupt the while loop using the callback?
How can I fix this? Or is there a better method for achiving the same thing?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论