summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/nrf/mpconfigport.h1
-rw-r--r--ports/rp2/mpconfigport.h4
-rw-r--r--ports/rp2/usbd.c6
-rw-r--r--ports/samd/mpconfigport.h1
-rw-r--r--shared/tinyusb/mp_cdc_common.c2
-rw-r--r--shared/tinyusb/mp_usbd.c6
-rw-r--r--shared/tinyusb/mp_usbd_descriptor.c7
7 files changed, 25 insertions, 2 deletions
diff --git a/ports/nrf/mpconfigport.h b/ports/nrf/mpconfigport.h
index 4762693c8..8875e3faa 100644
--- a/ports/nrf/mpconfigport.h
+++ b/ports/nrf/mpconfigport.h
@@ -141,6 +141,7 @@
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
#define MICROPY_USE_INTERNAL_ERRNO (1)
#if MICROPY_HW_USB_CDC_1200BPS_TOUCH
+#define MICROPY_HW_ENABLE_USBDEV (1)
#define MICROPY_ENABLE_SCHEDULER (1)
#define MICROPY_SCHEDULER_STATIC_NODES (1)
#endif
diff --git a/ports/rp2/mpconfigport.h b/ports/rp2/mpconfigport.h
index fc86e33e7..d862812f9 100644
--- a/ports/rp2/mpconfigport.h
+++ b/ports/rp2/mpconfigport.h
@@ -36,8 +36,12 @@
// Board and hardware specific configuration
#define MICROPY_HW_MCU_NAME "RP2040"
+#ifndef MICROPY_HW_ENABLE_UART_REPL
#define MICROPY_HW_ENABLE_UART_REPL (0) // useful if there is no USB
+#endif
+#ifndef MICROPY_HW_ENABLE_USBDEV
#define MICROPY_HW_ENABLE_USBDEV (1)
+#endif
#if MICROPY_HW_ENABLE_USBDEV
// Enable USB-CDC serial port
diff --git a/ports/rp2/usbd.c b/ports/rp2/usbd.c
index e17c546c6..e51cef0ff 100644
--- a/ports/rp2/usbd.c
+++ b/ports/rp2/usbd.c
@@ -24,6 +24,10 @@
* THE SOFTWARE.
*/
+#include "py/mpconfig.h"
+
+#if MICROPY_HW_ENABLE_USBDEV
+
#include "mp_usbd.h"
#include "string.h"
#include "tusb.h"
@@ -42,3 +46,5 @@ void mp_usbd_port_get_serial_number(char *serial_buf) {
}
serial_buf[hexlen] = 0;
}
+
+#endif
diff --git a/ports/samd/mpconfigport.h b/ports/samd/mpconfigport.h
index a048ad54b..153ad7582 100644
--- a/ports/samd/mpconfigport.h
+++ b/ports/samd/mpconfigport.h
@@ -60,6 +60,7 @@
#define MICROPY_ENABLE_SCHEDULER (1)
#define MICROPY_SCHEDULER_STATIC_NODES (1)
#define MICROPY_MODULE_WEAK_LINKS (1)
+#define MICROPY_HW_ENABLE_USBDEV (1)
#define MICROPY_HW_USB_CDC_1200BPS_TOUCH (1)
// Control over Python builtins
diff --git a/shared/tinyusb/mp_cdc_common.c b/shared/tinyusb/mp_cdc_common.c
index 00b72e74b..cd4f5d101 100644
--- a/shared/tinyusb/mp_cdc_common.c
+++ b/shared/tinyusb/mp_cdc_common.c
@@ -28,7 +28,7 @@
#include "py/mphal.h"
#include "modmachine.h"
-#if MICROPY_HW_USB_CDC_1200BPS_TOUCH
+#if MICROPY_HW_USB_CDC_1200BPS_TOUCH && MICROPY_HW_ENABLE_USBDEV
#include "tusb.h"
diff --git a/shared/tinyusb/mp_usbd.c b/shared/tinyusb/mp_usbd.c
index 91d35a2b4..0edc48988 100644
--- a/shared/tinyusb/mp_usbd.c
+++ b/shared/tinyusb/mp_usbd.c
@@ -26,6 +26,10 @@
#include <stdlib.h>
+#include "py/mpconfig.h"
+
+#if MICROPY_HW_ENABLE_USBDEV
+
#ifndef NO_QSTR
#include "tusb.h" // TinyUSB is not avaiable when running the string preprocessor
#include "device/usbd.h"
@@ -35,3 +39,5 @@
void usbd_task(void) {
tud_task_ext(0, false);
}
+
+#endif
diff --git a/shared/tinyusb/mp_usbd_descriptor.c b/shared/tinyusb/mp_usbd_descriptor.c
index 3a21baf5b..c6d205c92 100644
--- a/shared/tinyusb/mp_usbd_descriptor.c
+++ b/shared/tinyusb/mp_usbd_descriptor.c
@@ -25,7 +25,10 @@
* THE SOFTWARE.
*/
-#include "mpconfigport.h"
+#include "py/mpconfig.h"
+
+#if MICROPY_HW_ENABLE_USBDEV
+
#include "tusb.h"
#include "mp_usbd.h"
#include "mp_usbd_internal.h"
@@ -126,3 +129,5 @@ const uint8_t *tud_descriptor_configuration_cb(uint8_t index) {
(void)index;
return mp_usbd_desc_cfg_static;
}
+
+#endif