rust-embedded-community / usb-device

Experimental device-side USB framework for microcontrollers in Rust.
MIT License
414 stars 77 forks source link

Add make_device_builder to test class #54

Closed mciantyre closed 3 years ago

mciantyre commented 3 years ago

The imxrt-usbd driver requires that the user sets the EP0 max packet size to 64 bytes. To meet the requirement in our test_class example, we need access to the UsbDeviceBuilder. Ideally, we could access the builder without duplicating the make_device method.

This commit adds a new method, make_device_builder, for the test class. It sets the required device properties, then returns the builder to the caller for any additional configurations.

Disasm commented 3 years ago

The imxrt-usbd driver requires that the user sets the EP0 max packet size to 64 bytes.

This sounds like a bug. IMXRT1060RM also contains a table (42-42 "Typical Low-/Full-speed Transaction Times") that mentions 8-byte control transactions.

mciantyre commented 3 years ago

Thanks for this comment. I was convinced I needed the larger packet size given some earlier experiments. But I tried again, and you're right that it works. I've removed the requirement from imxrt-usbd.

This PR may still be useful for anyone who's interested in testing across the allowable EP0 packet sizes. I'll keep this open, but feel free to close if we feel otherwise.

mvirkkunen commented 3 years ago

Thanks! Letting people configure the TestClass sure doesn't hurt.