Wykres commitów

10 Commity (eb583b49e52274402c6d7c48e3dc99dc36aa3e59)

Autor SHA1 Wiadomość Data
Angus Gratton eb583b49e5 usb-device-midi: Add additional console output on TX.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-09 14:07:40 +10:00
Angus Gratton 87cc34e202 usb-device-{cdc, hid}: Fix handling of zero length OUT control xfers.
This fix relies on a corresponding change in the low-level USBDevice class.
Without the low-level change, HID and CDC devices may not work correctly at
all.

Zero length OUT control requests were being processed on the device but
stalling the endpoint so the host saw a failure (or hang followed by
failure).

Specifically:

- CDC set control line state and send break requests
- HID set idle or set protocol

This commit also simplifies HID set report logic (tested to still work even
when buffer size doesn't match report length).

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-05 15:40:03 +11:00
Angus Gratton a215fc47bb usb-device-cdc: Fix short delays when timeout is 0.
Previously even with timeout set to zero, a read could block
for up to 1ms + machine.idle() timeout period.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-05 15:40:03 +11:00
Angus Gratton 163f8ea953 usb-device: Fix max_power_ma value if not using built-in driver.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-05 15:39:36 +11:00
Angus Gratton d90e654384 usb-device-midi: Keep the built-in driver in midi_example.py.
The example prints to console, so no reason not to do this similar to the
other examples.

Tested Windows 10, Linux.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-03 16:12:31 +11:00
Angus Gratton 575251fb01 usb-device: Default bDeviceClass, bDeviceSubClass, bDeviceProtocol to 0.
These values are apparently interpreted as "interface defined", which is
a good fit for what happens here (more than one interface might show up in
the device).

It works as expected for the examples in Linux and Windows 10. There will
probably be some scenarios where a different value needs to be explicitly
passed in for the device.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-03 16:12:31 +11:00
Angus Gratton e40dd53300 usb-device: Keep the built-in driver's MaxPower value if not set.
Previously, if unset this value reverted to 100mA.

Now also respects the units provided in the argument.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-03 16:12:31 +11:00
Angus Gratton 9cc9abed05 usb-device-midi: Fix midi class driver descriptors.
Missing custom USB audio class standard descriptor extensions, as required
by Windows usbaudio.sys (it seems).

Also fixed the wTotalLength field which was incorrect for both the old and
new versions of this code.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-03 16:12:22 +11:00
Angus Gratton b876d149f2 usb-device: Rename descriptor.append to extend.
Nitpicky change, but what it does is closer to the latter wrt bytearrays
and similar in Python.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-04-03 15:34:05 +11:00
Angus Gratton 744f8c4ea5 usb: Add USB device support packages.
These packages build on top of machine.USBDevice() to provide high level
and flexible support for implementing USB devices in Python code.

Additional credits, as per included copyright notices:

- CDC support based on initial implementation by @hoihu with fixes by
  @linted.

- MIDI support based on initial implementation by @paulhamsh.

- HID keypad example based on work by @turmoni.

- Everyone who tested and provided feedback on early versions of these
  packages.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
2024-03-27 14:12:11 +11:00