hydrausb3 / wch-ch56x-lib

Library for WCH CH56x-based boards with tested USB3/USB2/HSPI/SerDes drivers, logging and deferred interrupts
Apache License 2.0
7 stars 2 forks source link

Review usage of Zero-length Packets (ZLPs) #5

Closed kauwua closed 6 months ago

kauwua commented 11 months ago

I've regularly read that a transfer should end with a ZLP (Zero-length packet) if the last packet transmitted is of full size. A short packets ends a transfer, but a full-size packet would not end the transfer if the client requested more data than the host can provide. Sending a ZLP would then mark the end of the transfer.

Right now, NAKs are sent if there is not data available anymore. If the client expected more data, it will timeout (thus adding delay in the app).

Todo: -> check what the USB2 spec says. -> implement the ZLP for control transfers that are hardcoded in the USB drivers -> maybe add an option in "send" functions like "last_packet_in_transfer", so that a ZLP is sent if there is no data left and the user does not forget about it

kauwua commented 6 months ago

Fixed by https://github.com/hydrausb3/wch-ch56x-lib/pull/12