开发者

ARM AT91SAM - Simple USB Read with callback question

开发者 https://www.devze.com 2023-03-28 18:24 出处:网络
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

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

精彩评论

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