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

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
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

Post by baoshi »

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: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

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

Post by Giovanni »

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

Post by baoshi »

Got it. In ibnotify of hal_serial_usb.c
Thanks!
Post Reply