Skip to content

Commit 3380712

Browse files
committed
Add make_device_builder to test class
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.
1 parent 49890d9 commit 3380712

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/test_class.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,23 @@ impl<B: UsbBus> TestClass<'_, B> {
8383

8484
/// Convenience method to create a UsbDevice that is configured correctly for TestClass.
8585
pub fn make_device<'a, 'b>(&'a self, usb_bus: &'b UsbBusAllocator<B>) -> UsbDevice<'b, B> {
86+
self.make_device_builder(usb_bus).build()
87+
}
88+
89+
/// Convenience method to create a UsbDeviceBuilder that is configured correctly for TestClass.
90+
///
91+
/// The methods sets
92+
///
93+
/// - manufacturer
94+
/// - product
95+
/// - serial number
96+
///
97+
/// on the returned builder. You should not change these values.
98+
pub fn make_device_builder<'a, 'b> (&'a self, usb_bus: &'b UsbBusAllocator<B>) -> UsbDeviceBuilder<'b, B> {
8699
UsbDeviceBuilder::new(&usb_bus, UsbVidPid(VID, PID))
87100
.manufacturer(MANUFACTURER)
88101
.product(PRODUCT)
89102
.serial_number(SERIAL_NUMBER)
90-
.build()
91103
}
92104

93105
/// Must be called after polling the UsbDevice.

0 commit comments

Comments
 (0)