Deferring USB control requests reply on application thread?

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

Deferring USB control requests reply on application thread?

Postby nono240 » Thu Apr 06, 2017 6:40 pm

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: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Deferring USB control requests reply on application thread?

Postby Giovanni » Thu Apr 06, 2017 9:30 pm

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?

Postby nono240 » Thu Apr 06, 2017 11:02 pm

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: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Deferring USB control requests reply on application thread?

Postby Giovanni » Fri Apr 07, 2017 7:46 am

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


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 6 guests