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

Separate usb2 usb3 stacks #9

Closed kauwua closed 9 months ago

kauwua commented 10 months ago

Support separate USB2/USB3 stacks : by default, both are set to use usb_device_0 so the user does not need to be concerned with this. But if the user wants to, the variables usb2_backend_current_usb_device and usb3_backend_current_usb_device can be modified to point to usb_device_0 and usb_device_1 (or another device struct).

You need the Hydradancer board for that (HydraUSB3 board with a USB3 port without USB2 downgrade, as the USB2 downgrade is used as a separate USB connection).

All examples have been tested for regressions with the new Hydradancer board and the previous HydraUSB3 boards, and a new example _test_firmware_usb_loopback_separate_usb_stacks_ has been added to test the separate stacks by creating two loopback devices on the same WCH569 chip. The script test_loopback.py has been updated to select a device by adding --num_device to run the test in parallel for both devices.

usb_device_0 and usb_device_1 are predefined with default values so that the user does not have to set all endpoint handlers, even for endpoints that are not used (which isn't intuitive). I've also thought about letting the user define the devices and only give the pointer, but i'm leaving this for now.