@@ -17,93 +17,32 @@ endif()
17
17
if (EXISTS ${PICO_TINYUSB_PATH} /${TINYUSB_TEST_PATH} )
18
18
message ("TinyUSB available at ${PICO_TINYUSB_PATH} /${TINYUSB_TEST_PATH} ; adding USB support." )
19
19
20
- add_library (tinyusb_common INTERFACE )
21
- target_link_libraries (tinyusb_common INTERFACE
22
- hardware_structs
23
- hardware_irq
24
- hardware_resets
25
- pico_sync
26
- )
27
-
28
- target_sources (tinyusb_common INTERFACE
29
- ${PICO_TINYUSB_PATH} /src/tusb.c
30
- ${PICO_TINYUSB_PATH} /src/common/tusb_fifo.c
31
- )
20
+ pico_register_common_scope_var(PICO_TINYUSB_PATH)
32
21
33
- set (TINYUSB_DEBUG_LEVEL 0)
34
- if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
35
- message ("Compiling TinyUSB with CFG_TUSB_DEBUG=1" )
36
- set (TINYUSB_DEBUG_LEVEL 1)
37
- endif ()
22
+ set (BOARD pico_sdk)
23
+ include (${PICO_TINYUSB_PATH} /hw/bsp/rp2040/family.cmake)
38
24
39
- target_compile_definitions (tinyusb_common INTERFACE
40
- CFG_TUSB_MCU=OPT_MCU_RP2040
41
- CFG_TUSB_OS=OPT_OS_PICO #seems examples are hard coded to OPT_OS_NONE
42
- CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL}
43
- )
44
-
45
- target_include_directories (tinyusb_common INTERFACE
46
- ${PICO_TINYUSB_PATH} /src
47
- ${PICO_TINYUSB_PATH} /src/common
48
- ${PICO_TINYUSB_PATH} /hw
49
- )
25
+ add_library (tinyusb_common INTERFACE )
26
+ target_link_libraries (tinyusb_common INTERFACE tinyusb_common_base)
50
27
51
28
add_library (tinyusb_device_unmarked INTERFACE )
52
- target_sources (tinyusb_device_unmarked INTERFACE
53
- ${PICO_TINYUSB_PATH} /src/portable/raspberrypi/rp2040/dcd_rp2040.c
54
- ${PICO_TINYUSB_PATH} /src/portable/raspberrypi/rp2040/rp2040_usb.c
55
- ${PICO_TINYUSB_PATH} /src/device/usbd.c
56
- ${PICO_TINYUSB_PATH} /src/device/usbd_control.c
57
- ${PICO_TINYUSB_PATH} /src/class/audio/audio_device.c
58
- ${PICO_TINYUSB_PATH} /src/class/cdc/cdc_device.c
59
- ${PICO_TINYUSB_PATH} /src/class/dfu/dfu_rt_device.c
60
- ${PICO_TINYUSB_PATH} /src/class/hid/hid_device.c
61
- ${PICO_TINYUSB_PATH} /src/class/midi/midi_device.c
62
- ${PICO_TINYUSB_PATH} /src/class/msc/msc_device.c
63
- ${PICO_TINYUSB_PATH} /src/class/net/net_device.c
64
- ${PICO_TINYUSB_PATH} /src/class/usbtmc/usbtmc_device.c
65
- ${PICO_TINYUSB_PATH} /src/class/vendor/vendor_device.c
66
- )
67
-
29
+ target_link_libraries (tinyusb_device_unmarked INTERFACE tinyusb_device_base)
68
30
target_compile_definitions (tinyusb_device_unmarked INTERFACE
69
31
# off by default note TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX defaults from PICO_RP2040_USB_DEVICE_ENUMERATION_FIX
70
32
# TUD_OPT_RP2040_USB_DEVICE_ENUMERATION_FIX=1
71
33
)
72
34
73
35
# unmarked version used by stdio USB
74
- target_link_libraries (tinyusb_device_unmarked INTERFACE tinyusb_common pico_fix_rp2040_usb_device_enumeration)
36
+ target_link_libraries (tinyusb_device_unmarked INTERFACE tinyusb_common pico_fix_rp2040_usb_device_enumeration tinyusb_device_base )
75
37
76
38
pico_add_impl_library(tinyusb_device)
77
39
target_link_libraries (tinyusb_device INTERFACE tinyusb_device_unmarked)
78
- target_compile_definitions (tinyusb_device INTERFACE
79
- RP2040_USB_DEVICE_MODE=1 #define is used by tinyusb still
80
- )
81
40
82
41
pico_add_impl_library(tinyusb_host)
83
- target_sources (tinyusb_host INTERFACE
84
- ${PICO_TINYUSB_PATH} /src/portable/raspberrypi/rp2040/hcd_rp2040.c
85
- ${PICO_TINYUSB_PATH} /src/portable/raspberrypi/rp2040/rp2040_usb.c
86
- ${PICO_TINYUSB_PATH} /src/host/usbh.c
87
- ${PICO_TINYUSB_PATH} /src/host/usbh_control.c
88
- ${PICO_TINYUSB_PATH} /src/host/hub.c
89
- ${PICO_TINYUSB_PATH} /src/class/cdc/cdc_host.c
90
- ${PICO_TINYUSB_PATH} /src/class/hid/hid_host.c
91
- ${PICO_TINYUSB_PATH} /src/class/msc/msc_host.c
92
- ${PICO_TINYUSB_PATH} /src/class/vendor/vendor_host.c
93
- )
94
-
95
- # Sometimes have to do host specific actions in mostly
96
- # common functions
97
- target_compile_definitions (tinyusb_host INTERFACE
98
- RP2040_USB_HOST_MODE=1 #define is used by tinyusb still
99
- )
100
-
101
- target_link_libraries (tinyusb_host INTERFACE tinyusb_common)
42
+ target_link_libraries (tinyusb_host INTERFACE tinyusb_host_base tinyusb_common)
102
43
103
44
pico_add_impl_library(tinyusb_board)
104
- target_sources (tinyusb_board INTERFACE
105
- ${PICO_TINYUSB_PATH} /hw/bsp/raspberry_pi_pico/board_raspberry_pi_pico.c
106
- )
45
+ target_link_libraries (tinyusb_board INTERFACE tinyusb_bsp)
107
46
47
+ pico_promote_common_scope_vars()
108
48
endif ()
109
-
0 commit comments