usbus: add descriptor prefix support#12429
Conversation
dylad
left a comment
There was a problem hiding this comment.
Quick overview, just typos or styles issues.
sys/include/usb/usbus.h
Outdated
| * | ||
| * Must return the length of the header that will be generated by | ||
| * @ref get_header | ||
| * Must return the length total length of the descriptors that will be |
There was a problem hiding this comment.
| * Must return the length total length of the descriptors that will be | |
| * Must return the total length of the descriptor that will be |
There was a problem hiding this comment.
Same as below, multiple descriptors can be generated
sys/include/usb/usbus.h
Outdated
| size_t (*get_header_len)(usbus_t *usbus, void *arg); | ||
| size_t fixed_len; /**< length of the header if it is a fixed length */ | ||
| size_t fixed_len; /**< total length of the generated | ||
| descripors if they are fixed length */ |
There was a problem hiding this comment.
| descripors if they are fixed length */ | |
| descriptors if they are fixed length */ |
There was a problem hiding this comment.
Wait, shouldn't have applied your suggestion, the fixed length must be the sum of the prefixed descriptor and the appended descriptor, so "descriptors" is correct here.
There was a problem hiding this comment.
Also clarified this one a bit
There was a problem hiding this comment.
what is bothering me here is the missing T
There was a problem hiding this comment.
what is bothering me here is the missing T
I might have accidentally fixed that with my fixups
sys/usb/usbus/usbus_fmt.c
Outdated
| static inline size_t _get_pre_header(usbus_t *usbus, usbus_hdr_gen_t *hdr) | ||
| { | ||
| return hdr->funcs->get_header(usbus, hdr->arg); | ||
| return hdr->funcs->fmt_pre_descriptor != NULL |
There was a problem hiding this comment.
| return hdr->funcs->fmt_pre_descriptor != NULL | |
| return (hdr->funcs->fmt_pre_descriptor != NULL) |
sys/usb/usbus/usbus_fmt.c
Outdated
|
|
||
| static inline size_t _get_additional_header(usbus_t *usbus, usbus_hdr_gen_t *hdr) | ||
| { | ||
| return hdr->funcs->get_header != NULL |
There was a problem hiding this comment.
| return hdr->funcs->get_header != NULL | |
| (return hdr->funcs->get_header != NULL) |
dylad
left a comment
There was a problem hiding this comment.
Changes look good, I'll test on hardware just to ensure nothing is broken during the weekend.
You can squash if you want.
d5d881d to
bce70bf
Compare
|
Squashed |
dylad
left a comment
There was a problem hiding this comment.
Tested on SAME54 with cdc_acm, and lsusb. Everything looks sane.
Thanks for reviewing! |
Contribution description
This PR adds support to the descriptor generators to prepend descriptors to the current element. This is required to add an interface association descriptor before the CDC ACM control interface descriptor. With this descriptor, Windows should correctly detect a RIOT-based CDC ACM peripheral and use the
USBser.sysdriver out of the box.Testing procedure
Test together with #12430, the interface association should always be right before the Communications Abstract modem interface descriptor.
Issues/PRs references
Required for #12430
Another PR is required to straighten out the terminology
s/header/descriptor/gto increase alignment with the USB spec.