Skip to content

Commit 0baa3b5

Browse files
projectgusdpgeorge
authored andcommitted
rp2: Enable support for Python USB devices.
This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton <[email protected]>
1 parent 9d0d262 commit 0baa3b5

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

ports/rp2/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ set(MICROPY_SOURCE_LIB
108108
${MICROPY_DIR}/shared/tinyusb/mp_cdc_common.c
109109
${MICROPY_DIR}/shared/tinyusb/mp_usbd.c
110110
${MICROPY_DIR}/shared/tinyusb/mp_usbd_descriptor.c
111+
${MICROPY_DIR}/shared/tinyusb/mp_usbd_runtime.c
111112
)
112113

113114
set(MICROPY_SOURCE_DRIVERS
@@ -146,6 +147,7 @@ set(MICROPY_SOURCE_QSTR
146147
${MICROPY_DIR}/shared/readline/readline.c
147148
${MICROPY_DIR}/shared/runtime/mpirq.c
148149
${MICROPY_DIR}/shared/runtime/sys_stdio_mphal.c
150+
${MICROPY_DIR}/shared/tinyusb/mp_usbd_runtime.c
149151
${MICROPY_PORT_DIR}/machine_adc.c
150152
${MICROPY_PORT_DIR}/machine_i2c.c
151153
${MICROPY_PORT_DIR}/machine_pin.c

ports/rp2/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ int main(int argc, char **argv) {
221221
mp_thread_deinit();
222222
#endif
223223
soft_timer_deinit();
224+
#if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
225+
mp_usbd_deinit();
226+
#endif
227+
224228
gc_sweep_all();
225229
mp_deinit();
226230
}

ports/rp2/mpconfigport.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
#ifndef MICROPY_HW_USB_MSC
5353
#define MICROPY_HW_USB_MSC (0)
5454
#endif
55+
56+
#ifndef MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
57+
#define MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE (1) // Support machine.USBDevice
58+
#endif
5559
#endif
5660

5761
#ifndef MICROPY_CONFIG_ROM_LEVEL

0 commit comments

Comments
 (0)