Skip to content

Commit

Permalink
ports/samd: 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 f28603d commit bd176f0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions ports/samd/Makefile
Expand Up @@ -136,6 +136,7 @@ SHARED_SRC_C += \
shared/tinyusb/mp_cdc_common.c \
shared/tinyusb/mp_usbd.c \
shared/tinyusb/mp_usbd_descriptor.c \
shared/tinyusb/mp_usbd_runtime.c \

ASF4_SRC_C += $(addprefix lib/asf4/$(MCU_SERIES_LOWER)/,\
hal/src/hal_atomic.c \
Expand Down
3 changes: 3 additions & 0 deletions ports/samd/main.c
Expand Up @@ -93,6 +93,9 @@ void samd_main(void) {
pwm_deinit_all();
#endif
soft_timer_deinit();
#if MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
mp_usbd_deinit();
#endif
gc_sweep_all();
#if MICROPY_PY_MACHINE_I2C || MICROPY_PY_MACHINE_SPI || MICROPY_PY_MACHINE_UART
sercom_deinit_all();
Expand Down
5 changes: 5 additions & 0 deletions ports/samd/mpconfigport.h
Expand Up @@ -62,6 +62,11 @@
// SAMD unique ID is 16 bytes (hex string == 32)
#ifndef MICROPY_HW_USB_DESC_STR_MAX
#define MICROPY_HW_USB_DESC_STR_MAX (32)

#ifndef MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE
// Enable to use the 'usbd' module
#define MICROPY_HW_ENABLE_USB_RUNTIME_DEVICE (0)
#endif
#endif
#endif

Expand Down

0 comments on commit bd176f0

Please sign in to comment.