cancel
Showing results for 
Search instead for 
Did you mean: 

My contribution to VCOM: semi-blocking way to receive from USB

pandoraems
Associate II
Posted on October 29, 2008 at 13:29

My contribution to VCOM: semi-blocking way to receive from USB

1 REPLY 1
pandoraems
Associate II
Posted on May 17, 2011 at 12:49

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