4040
4141#if CIRCUITPY_USB_DEVICE
4242#include "shared-bindings/supervisor/__init__.h"
43- #endif
4443
4544#if CIRCUITPY_USB_CDC
4645#include "shared-module/usb_cdc/__init__.h"
5857#include "shared-module/usb_video/__init__.h"
5958#endif
6059
60+ #endif
61+
6162#include "tusb.h"
6263
6364bool usb_enabled (void ) {
@@ -100,7 +101,7 @@ void usb_init(void) {
100101
101102 post_usb_init ();
102103
103- #if MICROPY_KBD_EXCEPTION && CIRCUITPY_USB_CDC
104+ #if MICROPY_KBD_EXCEPTION && CIRCUITPY_USB_DEVICE && CIRCUITPY_USB_CDC
104105 // Set Ctrl+C as wanted char, tud_cdc_rx_wanted_cb() usb_callback will be invoked when Ctrl+C is received
105106 // This usb_callback always got invoked regardless of mp_interrupt_char value since we only set it once here
106107
@@ -114,6 +115,7 @@ void usb_init(void) {
114115
115116// Set up USB defaults before any USB changes are made in boot.py
116117void usb_set_defaults (void ) {
118+ #if CIRCUITPY_USB_DEVICE
117119 #if CIRCUITPY_STORAGE && CIRCUITPY_USB_MSC
118120 storage_usb_set_defaults ();
119121 #endif
@@ -129,17 +131,20 @@ void usb_set_defaults(void) {
129131 #if CIRCUITPY_USB_MIDI
130132 usb_midi_set_defaults ();
131133 #endif
134+ #endif
132135};
133136
134137// Call this when ready to run code.py or a REPL, and a VM has been started.
135138void usb_setup_with_vm (void ) {
139+ #if CIRCUITPY_USB_DEVICE
136140 #if CIRCUITPY_USB_HID
137141 usb_hid_setup_devices ();
138142 #endif
139143
140144 #if CIRCUITPY_USB_MIDI
141145 usb_midi_setup_ports ();
142146 #endif
147+ #endif
143148}
144149
145150void usb_background (void ) {
@@ -155,13 +160,13 @@ void usb_background(void) {
155160 vTaskDelay (0 );
156161 #endif
157162 // No need to flush if there's no REPL.
158- #if CIRCUITPY_USB_CDC
163+ #if CIRCUITPY_USB_DEVICE && CIRCUITPY_USB_CDC
159164 if (usb_cdc_console_enabled ()) {
160165 // Console will always be itf 0.
161166 tud_cdc_write_flush ();
162167 }
163168 #endif
164- #if CIRCUITPY_USB_VIDEO
169+ #if CIRCUITPY_USB_DEVICE && CIRCUITPY_USB_VIDEO
165170 usb_video_task ();
166171 #endif
167172 }
0 commit comments