开发者

ARM AT91SAM - Simple USB Read with callback question

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;

//U开发者_开发百科SB 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜