Skip to content

Commit

Permalink
ports/rp2: Add support for USB devices defined in Python.
Browse files Browse the repository at this point in the history
Currently disabled by default, set MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE to
enable.

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
  • Loading branch information
projectgus committed Mar 13, 2024
1 parent 7fdd00e commit f28603d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ports/rp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ set(MICROPY_SOURCE_LIB
${MICROPY_DIR}/shared/tinyusb/mp_cdc_common.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd_descriptor.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd_runtime.c
)

set(MICROPY_SOURCE_DRIVERS
Expand Down Expand Up @@ -146,6 +147,7 @@ set(MICROPY_SOURCE_QSTR
${MICROPY_DIR}/shared/readline/readline.c
${MICROPY_DIR}/shared/runtime/mpirq.c
${MICROPY_DIR}/shared/runtime/sys_stdio_mphal.c
${MICROPY_DIR}/shared/tinyusb/mp_usbd_runtime.c
${MICROPY_PORT_DIR}/machine_adc.c
${MICROPY_PORT_DIR}/machine_i2c.c
${MICROPY_PORT_DIR}/machine_pin.c
Expand Down
4 changes: 4 additions & 0 deletions ports/rp2/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ int main(int argc, char **argv) {
mp_thread_deinit();
#endif
soft_timer_deinit();
#if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
mp_usbd_deinit();
#endif

gc_sweep_all();
mp_deinit();
}
Expand Down
5 changes: 5 additions & 0 deletions ports/rp2/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@
#ifndef MICROPY_HW_USB_MSC
#define MICROPY_HW_USB_MSC (0)
#endif

#ifndef MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
// Enable to support machine.USBDevice
#define MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE (0)
#endif
#endif

#ifndef MICROPY_CONFIG_ROM_LEVEL
Expand Down

0 comments on commit f28603d

Please sign in to comment.