cherry-embedded / CherryUSB

CherryUSB is a tiny and portable USB Stack (device & host) for embedded system with USB IP
https://cherryusb.readthedocs.io/
Apache License 2.0
1.14k stars 244 forks source link

How to implement USB host class driver that supports many vid/pid pairs? #195

Closed harbaum closed 2 months ago

harbaum commented 2 months ago

I've implemented a USB host class driver for xbox controllers here: https://github.com/harbaum/CherryUSB/tree/master/class/xbox

This needs support for a long list of vid/pid pairs like e.g. https://github.com/harbaum/CherryUSB/blob/master/class/xbox/usbh_xbox.c#L111-L215

To achieve this I have changed the single vid/pid entry to point to an array of entries like so: https://github.com/harbaum/CherryUSB/blob/master/core/usbh_core.h#L63

This is imcompatible with upstream cherryusb.

How do I properly implement a driver that supports multiple vid/pid pairs in cherryusb?

sakumisu commented 2 months ago

Thanks, i will support id table for you.

harbaum commented 2 months ago

I've just updated my port to the latest bouffalolab_sdk and the cherryusb 1.2,0. Feel free to re-use any part you want.

I've also updated https://github.com/harbaum/bouffalo_sdk/blob/master/drivers/lhal/src/bflb_usb_v2.c for the latest cherryusb 1.2.0

sakumisu commented 2 months ago

Thank you sir, i have reviewed your code, and give you a few suggestions:

And after doing all, you can create a pr, sincerely wait and thank you for your pr.

harbaum commented 2 months ago

Solved in a local branch. Thanks

sakumisu commented 2 months ago

Add this feature refer to your code, thank you.