@@ -45,16 +45,13 @@ INC += -I. \
4545 -Iasf4/$(CHIP_FAMILY ) /hpl/tc \
4646 -Iasf4/$(CHIP_FAMILY ) /include \
4747 -Iasf4/$(CHIP_FAMILY ) /CMSIS/Include \
48- -Iasf4/$(CHIP_FAMILY ) /usb \
49- -Iasf4/$(CHIP_FAMILY ) /usb/class/cdc \
50- -Iasf4/$(CHIP_FAMILY ) /usb/class/hid \
51- -Iasf4/$(CHIP_FAMILY ) /usb/class/msc \
52- -Iasf4/$(CHIP_FAMILY ) /usb/device \
5348 -Iasf4_conf/$(CHIP_FAMILY ) \
5449 -Iboards/$(BOARD ) \
5550 -Iboards/ \
5651 -Iperipherals/ \
5752 -Ifreetouch \
53+ -I../../lib/tinyusb/src \
54+ -I../../supervisor/shared/usb \
5855 -I$(BUILD )
5956
6057BASE_CFLAGS = \
@@ -90,11 +87,15 @@ BASE_CFLAGS = \
9087# NDEBUG disables assert() statements. This reduces code size pretty dramatically, per tannewt.
9188
9289ifeq ($(CHIP_FAMILY ) , samd21)
93- CFLAGS = -Os -DNDEBUG
90+ CFLAGS += -Os -DNDEBUG
91+ # TinyUSB defines
92+ CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD21 -DCFG_TUD_CDC_RX_BUFSIZE=128 -DCFG_TUD_CDC_TX_BUFSIZE=128 -DCFG_TUD_MSC_BUFSIZE=512
9493endif
9594
9695ifeq ($(CHIP_FAMILY ) , samd51)
97- CFLAGS = -Os -DNDEBUG
96+ CFLAGS += -O0 -DNDEBUG
97+ # TinyUSB defines
98+ CFLAGS += -DCFG_TUSB_MCU=OPT_MCU_SAMD51 -DCFG_TUD_CDC_RX_BUFSIZE=256 -DCFG_TUD_CDC_TX_BUFSIZE=256 -DCFG_TUD_MSC_BUFSIZE=1024
9899endif
99100
100101# Debugging/Optimization
@@ -104,7 +105,7 @@ ifeq ($(DEBUG), 1)
104105 # You may want to disable -flto if it interferes with debugging.
105106 CFLAGS += -flto
106107 # You may want to enable these flags to make setting breakpoints easier.
107- # # CFLAGS += -fno-inline -fno-ipa-sra
108+ # CFLAGS += -fno-inline -fno-ipa-sra
108109 ifeq ($(CHIP_FAMILY), samd21)
109110 CFLAGS += -DENABLE_MICRO_TRACE_BUFFER
110111 endif
@@ -204,7 +205,6 @@ SRC_ASF := \
204205 hal/src/hal_spi_m_sync.c \
205206 hal/src/hal_timer.c \
206207 hal/src/hal_usart_async.c \
207- hal/src/hal_usb_device.c \
208208 hpl/adc/hpl_adc.c \
209209 hpl/core/hpl_init.c \
210210 hpl/dac/hpl_dac.c \
@@ -214,12 +214,6 @@ SRC_ASF := \
214214 hpl/rtc/hpl_rtc.c \
215215 hpl/sercom/hpl_sercom.c \
216216 hpl/systick/hpl_systick.c \
217- hpl/usb/hpl_usb.c \
218- usb/class/cdc/device/cdcdf_acm.c \
219- usb/class/hid/device/hiddf_generic.c \
220- usb/class/msc/device/mscdf.c \
221- usb/device/usbdc.c \
222- usb/usb_protocol.c \
223217 hal/utils/src/utils_list.c \
224218 hal/utils/src/utils_ringbuffer.c \
225219
@@ -246,7 +240,6 @@ SRC_C = \
246240 board_busses.c \
247241 background.c \
248242 fatfs_port.c \
249- flash_api.c \
250243 mphalport.c \
251244 reset.c \
252245 peripherals/samd/clocks.c \
@@ -265,15 +258,15 @@ SRC_C = \
265258 peripherals/samd/$(CHIP_FAMILY ) /sercom.c \
266259 peripherals/samd/$(CHIP_FAMILY ) /timers.c \
267260 tick.c \
268- usb.c \
269- usb_mass_storage.c \
270261 bindings/samd/__init__.c \
271262 bindings/samd/Clock.c \
272263 boards/$(BOARD ) /board.c \
273264 boards/$(BOARD ) /pins.c \
274265 lib/oofatfs/ff.c \
275266 lib/oofatfs/option/ccsbcs.c \
276267 lib/timeutils/timeutils.c \
268+ lib/tinyusb/src/portable/microchip/$(CHIP_FAMILY ) /dcd.c \
269+ lib/tinyusb/src/portable/microchip/$(CHIP_FAMILY ) /hal.c \
277270 lib/utils/buffer_helper.c \
278271 lib/utils/context_manager_helpers.c \
279272 lib/utils/interrupt_char.c \
@@ -282,7 +275,6 @@ SRC_C = \
282275 lib/utils/sys_stdio_mphal.c \
283276 lib/libc/string0.c \
284277 lib/mp-readline/readline.c \
285- $(BUILD ) /autogen_usb_descriptor.c \
286278 freetouch/adafruit_ptc.c \
287279 supervisor/shared/memory.c
288280
@@ -306,19 +298,6 @@ SRC_MOD += $(addprefix $(WIZNET5K_DIR)/,\
306298endif # MICROPY_PY_WIZNET5K
307299endif # MICROPY_PY_NETWORK
308300
309- # Choose which flash filesystem impl to use.
310- # (Right now INTERNAL_FLASH_FILESYSTEM and SPI_FLASH_FILESYSTEM are mutually exclusive.
311- # But that might not be true in the future.)
312- ifeq ($(INTERNAL_FLASH_FILESYSTEM ) ,1)
313- SRC_C += internal_flash.c
314- endif
315- ifeq ($(SPI_FLASH_FILESYSTEM ) ,1)
316- SRC_C += external_flash/external_flash.c external_flash/spi_flash.c
317- endif
318- ifeq ($(QSPI_FLASH_FILESYSTEM ) ,1)
319- SRC_C += external_flash/external_flash.c external_flash/qspi_flash.c
320- endif
321-
322301SRC_COMMON_HAL = \
323302 board/__init__.c \
324303 busio/__init__.c \
@@ -339,7 +318,6 @@ SRC_COMMON_HAL = \
339318 rotaryio/IncrementalEncoder.c \
340319 rtc/__init__.c \
341320 rtc/RTC.c \
342- storage/__init__.c \
343321 supervisor/__init__.c \
344322 supervisor/Runtime.c \
345323 time/__init__.c \
@@ -352,10 +330,8 @@ SRC_COMMON_HAL = \
352330 pulseio/PulseIn.c \
353331 pulseio/PulseOut.c \
354332 pulseio/PWMOut.c \
355- usb_hid/__init__.c \
356- usb_hid/Device.c \
357333 touchio/__init__.c \
358- touchio/TouchIn.c \
334+ touchio/TouchIn.c
359335
360336ifeq ($(INTERNAL_LIBM ) ,1)
361337SRC_LIBM = $(addprefix lib/,\
@@ -412,12 +388,17 @@ SRC_SHARED_MODULE = \
412388 _stage/__init__.c \
413389 _stage/Layer.c \
414390 _stage/Text.c \
391+ storage/__init__.c \
415392 os/__init__.c \
416393 random/__init__.c \
417- storage/__init__.c \
418394 struct/__init__.c \
419395 uheap/__init__.c \
420- ustack/__init__.c
396+ ustack/__init__.c \
397+ usb_hid/__init__.c \
398+ usb_hid/Device.c
399+
400+ # usb_midi/__init__.c
401+ # usb_midi/Port.c
421402
422403ifeq ($(MICROPY_PY_NETWORK ) ,1)
423404SRC_SHARED_MODULE += socket/__init__.c network/__init__.c
@@ -489,21 +470,6 @@ $(BUILD)/firmware.uf2: $(BUILD)/firmware.bin
489470 $(STEPECHO ) " Create $@ "
490471 $(Q )$(PYTHON3 ) $(TOP ) /tools/uf2/utils/uf2conv.py -b $(BOOTLOADER_SIZE ) -c -o $@ $^
491472
492- $(BUILD ) /autogen_usb_descriptor.c $(BUILD ) /genhdr/autogen_usb_descriptor.h : autogen_usb_descriptor.intermediate
493-
494- .INTERMEDIATE : autogen_usb_descriptor.intermediate
495-
496- autogen_usb_descriptor.intermediate : tools/gen_usb_descriptor.py Makefile | $(HEADER_BUILD )
497- $(STEPECHO ) " GEN $@ "
498- $(Q ) install -d $(BUILD ) /genhdr
499- $(Q )$(PYTHON3 ) tools/gen_usb_descriptor.py \
500- --manufacturer $(USB_MANUFACTURER ) \
501- --product $(USB_PRODUCT ) \
502- --vid $(USB_VID ) \
503- --pid $(USB_PID ) \
504- --output_c_file $(BUILD ) /autogen_usb_descriptor.c\
505- --output_h_file $(BUILD ) /genhdr/autogen_usb_descriptor.h
506-
507473deploy : $(BUILD ) /firmware.bin
508474 $(ECHO ) " Writing $< to the board"
509475 $(BOSSAC ) -u $<
0 commit comments