summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorAngus Gratton <angus@redyak.com.au>2023-11-23 09:48:41 +1100
committerDamien George <damien@micropython.org>2024-03-15 14:22:11 +1100
commit9d0d262be069089f01da6b40d2cd78f1da14de0f (patch)
tree197aae85f00879c35945fa32eb0a1552e5e10c1f /py
parent43904acea8b2087fdf9f283c0f8ce7d92d16e605 (diff)
downloadmicropython-9d0d262be069089f01da6b40d2cd78f1da14de0f.tar.gz
micropython-9d0d262be069089f01da6b40d2cd78f1da14de0f.zip
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>
Diffstat (limited to 'py')
-rw-r--r--py/runtime.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/py/runtime.c b/py/runtime.c
index f7e0abdb46..1836f5d92a 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -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