This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: TI-RTOS
In pdk_omapl138_1_0_5/packages/ti/drv/usb/src/usb_func/device/usb_dev_dman.c I see
/** \brief Global variable to contain the request which is to be made to * the lower layer driver. */ usbDevRequest_t req;
Which pretty much means there can only be one request "in flight" at a time.
I'm using the USB bulk device, and I'd like to be doing reads in one task while doing writes in another task, because I'll be constantly producing data, and host writes will be only occasional.
It seems this global request variable will be clobbered by the two tasks.
Is my design goal reasonable? (i.e. would the hardware support it if the driver were written properly?)
Or do I just not understand how USB Bulk devices are supposed to work?
I don't think my question came across well.
You are correct that an individual *endpoint* is unidirectional.
My question is about a device with *TWO* USB endpoints, one IN_EP and one OUT_EP, as in the PDK 1.0.5 USB Bulk Device example.
In the PDK, both USBD_bulkRead and USBD_bulkWrite are blocking operations
If you try to do a USBD_bulkRead, you will block forever, until the HOST sends something.
If the host then tries to read something, it will get nothing, because you can't USBD_bulkWrite on the other endpoint, because you're still blocked inside USBD_bulkRead for your first endpoint.
Now I wanted to decouple this, so I thought I could just do USBD_bulkRead in one task and USBD_bulkWrite in another. This is desirable because I do not know the timing or order of reads/writes a-priori.
It seems like this should be possible if the drivers are well written; when you get a USB interrupt for an endpoint, you dispatch it based whatever is going on for that endpoint. Operations on one endpoint should NOT affect operations on other endpoints.
Digging down into usbdbulk.c, you can see both the USBD_bulkRead and USBD_bulkWrite call usbSetupEpReq(), which fills in this GLOBAL usbDevRequest_t req (which I assume gets picked up by a dispatcher of some sort). *ugh*. This seems like a glaring design flaw. This should be a queue of request objects, so multiple Tasks can queue up transactions on different endpoints and not clobber each other.