extmod/machine_usb_device: Add support for Python USB devices.

This new machine-module driver provides a "USBDevice" singleton object and
a shim TinyUSB "runtime" driver that delegates the descriptors and all of
the TinyUSB callbacks to Python functions.  This allows writing arbitrary
USB devices in pure Python.  It's also possible to have a base built-in
USB device implemented in C (eg CDC, or CDC+MSC) and a Python USB device
added on top of that.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
Angus Gratton
2023-11-23 09:48:41 +11:00
committed by Damien George
parent 43904acea8
commit 9d0d262be0
14 changed files with 1384 additions and 118 deletions

View File

@@ -171,6 +171,10 @@ void mp_init(void) {
MP_STATE_VM(bluetooth) = MP_OBJ_NULL;
#endif
#if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
MP_STATE_VM(usbd) = MP_OBJ_NULL;
#endif
#if MICROPY_PY_THREAD_GIL
mp_thread_mutex_init(&MP_STATE_VM(gil_mutex));
#endif