2008-10-29 05:29 AM
My contribution to VCOM: semi-blocking way to receive from USB
2011-05-17 03:49 AM
Hi all
I needed a way to receive arbitrary size chunks of data from USB host. Inspired by Lanchon's modified VCOM, i created my semi-blocking version of it. What semi-blocking means is that it doesn't just sit in a busy loop and waits until all the data arrives, but gives user more control over the polling frequency. Here is how to use it: 1. request data: call getData() providing buffer and data size to receive 2. call handleData() once in a while (this lets control the polling, making things more real-time) 3. check rx_done flag after each handleData() call is complete. If the flag is set (1), the data is ready and copied into the user buffer Took me some time to sort out all the logic to get it to work as expected. Hope this example will save someone's time. Note: attached is usb_endp.txt file, rename it to usb_endp.c (didn't allow attaching *.c files) Enjoy