|
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. 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.
How can I fix this? Or is there a better method for achiving the same thing?
Thanks
|