Hi,
I'm developing a USB MSC disk application for a board based on an RT1010.
I have the following working:
- I receive a `kUSB_DeviceMscEventWriteRequest` event which sets up a buffer for the USB stack to fill.
- I receive a `kUSB_DeviceMscEventWriteResponse` which contains the data received via USB.
- In the same place while handling the MSC event in `USB_DeviceMscCallback()`, I pass the buffer to a function that handles the received data. That data could end up being sent via UART, written to Flash memory, etc.
The problem I have is that all of this is executed from `USB_DeviceMscCallback()` which is called from an interrupt context. What I want to do is buffer the received data in a queue, and process it later in a thread context.
I found an example project that seems to show what I'm looking for, but I don't understand how it works.
It looks like the example application changes something so that `USB_DeviceMscCallback()` is no longer called from an interrupt context, but from a thread context.
The application calls `xQueueReceive()`, not `xQueueReceiveFromISR()` when handling `kUSB_DeviceMscEventWriteRequest` .
How does the application make this work?
EDIT: another question would be: is it okay to make a blocking call to `xQueueReceiveFromISR()` in the USB interrupt context? Or what is the right way to handle write requests when my application doesn't have enough resources to buffer the incoming data?