[INFO] Changes to USB driver

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
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:

[INFO] Changes to USB driver

Postby Giovanni » Fri Dec 25, 2015 9:57 am

Hello,

Because performance concerns the USB driver has been modified by removing the "queued" API, now the driver is generally simpler and only supports linear transfers. The Serial-USB driver has been modified to work with the linear API and uses a new buffering mechanism.

At application level there are no visible changes except that the SOF callback must call sduSOFHookI(), it is used for periodic buffers flushing.

The change allows to use DMA for PMA<->Memory transfers where a DMA is available, the queues requirement made the use of DMAs too complex or impossible.

Existing drivers must be modified by removing references to the queued code, matter of minutes.

Something I am considering is adding to the USB driver a synchronous API like other drivers: usbReceive() and usbTransmit() would complement usbStartReceive() and usbStartTransmit(). That would make the driver easier to use without Serial-USB.

Thoughts?

Giovanni

Jacon
Posts: 141
Joined: Wed Dec 08, 2010 7:52 am
Has thanked: 48 times
Been thanked: 5 times

Re: [INFO] Changes to USB driver

Postby Jacon » Fri Dec 25, 2015 11:38 am

Giovanni wrote:...
Thoughts?
Giovanni

Only positive :)
The more uniformity in our HAL, the better.

User avatar
kreyl
Posts: 59
Joined: Sun Jan 13, 2013 11:46 pm
Been thanked: 4 times
Contact:

Re: [INFO] Changes to USB driver

Postby kreyl » Fri Dec 25, 2015 10:23 pm

The simpler, the better. Do it :)

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: [INFO] Changes to USB driver

Postby Giovanni » Thu Dec 31, 2015 12:35 pm

Hi,

Changes finished, look at the new \testhal\STM32\STM32F7xx\USB_RAW demo, it uses the new synchronous API and, I hope, it is easy to understand and efficient. It implements a CDC device without the Serial-USB abstraction.

The direct USB API is recommended when the maximum performance is required from USB.

While at it I implemented various optimizations to the USBv1 driver, it is smaller and faster now.

Giovanni

User avatar
Korken
Posts: 270
Joined: Wed Apr 02, 2014 4:09 pm
Location: Luleå, Sweden
Has thanked: 5 times
Been thanked: 6 times
Contact:

Re: [INFO] Changes to USB driver

Postby Korken » Sat Jan 09, 2016 2:58 pm

Is there a way to have a timeout for the synchronous API?
I would like to have a standard chunk to read, but if no more data comes for xxx ms or so, then it should return.

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: [INFO] Changes to USB driver

Postby Giovanni » Sat Jan 09, 2016 3:58 pm

It would be problematic to abort an USB transaction once it is started, this is why there is no timeout. The wait is only interrupted if the USB becomes non-active.

Giovanni

User avatar
Korken
Posts: 270
Joined: Wed Apr 02, 2014 4:09 pm
Location: Luleå, Sweden
Has thanked: 5 times
Been thanked: 6 times
Contact:

Re: [INFO] Changes to USB driver

Postby Korken » Sat Jan 09, 2016 11:53 pm

Ahh, I see. And with non-active, is it enough that no data is coming or does it have to suspend or something like that?

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: [INFO] Changes to USB driver

Postby Giovanni » Sun Jan 10, 2016 8:35 am

By non-active I mean a reset or suspend condition, it happens when you unplug the cable for example.

Giovanni

User avatar
Korken
Posts: 270
Joined: Wed Apr 02, 2014 4:09 pm
Location: Luleå, Sweden
Has thanked: 5 times
Been thanked: 6 times
Contact:

Re: [INFO] Changes to USB driver

Postby Korken » Sun Jan 10, 2016 10:53 am

Sorry, this confuses me. For sending data I understand the usage, but how is this then applicable for read operations?
As you generally cannot know the amount of data that is coming, so the transaction might wait indefinitely if there is no continuous data stream.
Or is there a way around this? Maybe I have misunderstood its usage?

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: [INFO] Changes to USB driver

Postby Giovanni » Sun Jan 10, 2016 11:04 am

The read operation continues until the specified number of bytes have been received OR a short packet is received. This is how the host signals that there is no immediate data to follow, it is part of the USB specification.

You could specify 1024 and receive a single byte. The amount you specify is what you can handle in a single transfer.

Giovanni


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 9 guests