Deferring USB control requests reply on application thread?

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
nono240
Posts: 2
Joined: Thu Apr 06, 2017 1:36 pm
Has thanked: 1 time

Deferring USB control requests reply on application thread?

Post by nono240 »

I'm building an USB frontend to some kind of (SPI) chipset and I'm planning to implement some non standard (control) requests through EP0 to expose some chipset registers ; keeping EP1 for bulk data. Currently, from my understanding, the USB requests hook is supposed to call usbSetupTransfer() macro before returning true. Since those custom control requests are going to write (or read) a few bytes through the SPI, I'd rather do that from a "server thread" handling the I/O.

Is it possible in some way or shall I have to move those requests to non-control endpoints?
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Deferring USB control requests reply on application thread?

Post by Giovanni »

Hi,

The driver is designed to handle EP0 with a state machine, moving requests to a dedicated thread is not possible. You may use another endpoint or handle messages on EP0 using the provided callbacks.

Giovanni
nono240
Posts: 2
Joined: Thu Apr 06, 2017 1:36 pm
Has thanked: 1 time

Re: Deferring USB control requests reply on application thread?

Post by nono240 »

Yes, using the provided callbacks is what I meant, but I'm assuming they're called in a ISR context, right? So I'm not able to use the synchronous message API, and doing SPI from an interrupt context (concurrently with a thread) sounds not so great :)
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Deferring USB control requests reply on application thread?

Post by Giovanni »

Hi,

All callbacks are called from ISR context, you cannot defer handling to a thread because the callback is supposed to decide "next step".

Giovanni
Post Reply