Understanding the OUT EP handling in Serial-over-USB driver

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
baoshi
Posts: 9
Joined: Wed May 15, 2013 5:49 am
Been thanked: 1 time

Understanding the OUT EP handling in Serial-over-USB driver

Postby baoshi » Thu Jun 22, 2017 3:06 am

Hi,
First let me say the driver works perfectly OK.

But when I digging into the code, some part I cannot understand. Here I'm based on ChibiOS 17.6.0, I think the part in 16.1.8 is identical.
When an OUT packet arrives at data EP, here is what happens:
1. The USB lld saves the packet to assigned buffer. When small packet received or buffer full, user callback (sduDataReceived) is called.
2. In sduDataReceived, received buffer is filled in ibqueue. CHN_INPUT_AVAILABLE is fired and waiting thread are waked up *later* to process the queue.
3. sduDataReceived prepares next receiving using sdu_start_receive()
4. sdu_start_receive() will start receiving if: USB state is ACTIVE or READY; USB is not receiving; ibqueue has an empty buffer.
Suppose the thread waiting for ibqueue is not fast enough to empty the queue, sdu_start_receive() will not start receiving, and subsequent USB OUT packet will be NAKed.

My question is: when the OUT endpoint will be armed again once ibqueue becomes empty? I'm not able to locate the code does this.

Thanks

Baoshi

User avatar
Giovanni
Site Admin
Posts: 14455
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1076 times
Been thanked: 922 times
Contact:

Re: Understanding the OUT EP handling in Serial-over-USB driver

Postby Giovanni » Thu Jun 22, 2017 10:33 am

Hi,

The buffers object has callbacks, OUT transactions are restarted in callbacks.

Giovanni

baoshi
Posts: 9
Joined: Wed May 15, 2013 5:49 am
Been thanked: 1 time

Re: Understanding the OUT EP handling in Serial-over-USB driver

Postby baoshi » Thu Jun 22, 2017 12:05 pm

Got it. In ibnotify of hal_serial_usb.c
Thanks!


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 6 guests