mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
cmake esp32s2 and rp2040 getting along
This commit is contained in:
parent
469ca2f155
commit
ffad6eaf80
@ -8,58 +8,23 @@ set(TOP "../../..")
|
||||
get_filename_component(TOP "${TOP}" REALPATH)
|
||||
|
||||
# Check for -DFAMILY=
|
||||
if(NOT DEFINED FAMILY)
|
||||
message(FATAL_ERROR "Invalid FAMILY specified")
|
||||
endif()
|
||||
|
||||
if(FAMILY STREQUAL "esp32s2")
|
||||
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
|
||||
project(${PROJECT})
|
||||
|
||||
if(FAMILY STREQUAL "rp2040")
|
||||
|
||||
pico_sdk_init()
|
||||
|
||||
add_executable(${PROJECT})
|
||||
|
||||
# TinyUSB Stack source
|
||||
set(SRC_TINYUSB
|
||||
${TOP}/src/tusb.c
|
||||
${TOP}/src/common/tusb_fifo.c
|
||||
${TOP}/src/device/usbd.c
|
||||
${TOP}/src/device/usbd_control.c
|
||||
${TOP}/src/class/audio/audio_device.c
|
||||
${TOP}/src/class/cdc/cdc_device.c
|
||||
${TOP}/src/class/dfu/dfu_rt_device.c
|
||||
${TOP}/src/class/hid/hid_device.c
|
||||
${TOP}/src/class/midi/midi_device.c
|
||||
${TOP}/src/class/msc/msc_device.c
|
||||
${TOP}/src/class/net/net_device.c
|
||||
${TOP}/src/class/usbtmc/usbtmc_device.c
|
||||
${TOP}/src/class/vendor/vendor_device.c
|
||||
${TOP}/src/portable/raspberrypi/${FAMILY}/dcd_rp2040.c
|
||||
${TOP}/src/portable/raspberrypi/${FAMILY}/rp2040_usb.c
|
||||
)
|
||||
elseif(FAMILY STREQUAL "rp2040")
|
||||
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
|
||||
|
||||
# Example source
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
src/main.c
|
||||
${TOP}/hw/bsp/${FAMILY}/family.c
|
||||
${SRC_TINYUSB}
|
||||
)
|
||||
|
||||
# Example include
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
src/
|
||||
${TOP}/hw
|
||||
${TOP}/src
|
||||
${TOP}/hw/bsp/${FAMILY}/boards/${BOARD}
|
||||
src
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT} PUBLIC
|
||||
CFG_TUSB_MCU=OPT_MCU_RP2040
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid FAMILY specified")
|
||||
endif()
|
||||
|
@ -1,3 +1,4 @@
|
||||
# FAMILY = "esp32s2"
|
||||
idf_component_register(SRCS "main.c"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES freertos soc)
|
||||
|
@ -8,65 +8,25 @@ set(TOP "../../..")
|
||||
get_filename_component(TOP "${TOP}" REALPATH)
|
||||
|
||||
# Check for -DFAMILY=
|
||||
if(NOT DEFINED FAMILY)
|
||||
message(FATAL_ERROR "Invalid FAMILY specified")
|
||||
endif()
|
||||
|
||||
if(FAMILY STREQUAL "esp32s2")
|
||||
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
|
||||
project(${PROJECT})
|
||||
|
||||
if(FAMILY STREQUAL "rp2040")
|
||||
|
||||
pico_sdk_init()
|
||||
|
||||
add_executable(${PROJECT})
|
||||
|
||||
# TinyUSB Stack source
|
||||
set(SRC_TINYUSB
|
||||
${TOP}/src/tusb.c
|
||||
${TOP}/src/common/tusb_fifo.c
|
||||
${TOP}/src/device/usbd.c
|
||||
${TOP}/src/device/usbd_control.c
|
||||
${TOP}/src/class/audio/audio_device.c
|
||||
${TOP}/src/class/cdc/cdc_device.c
|
||||
${TOP}/src/class/dfu/dfu_rt_device.c
|
||||
${TOP}/src/class/hid/hid_device.c
|
||||
${TOP}/src/class/midi/midi_device.c
|
||||
${TOP}/src/class/msc/msc_device.c
|
||||
${TOP}/src/class/net/net_device.c
|
||||
${TOP}/src/class/usbtmc/usbtmc_device.c
|
||||
${TOP}/src/class/vendor/vendor_device.c
|
||||
${TOP}/src/portable/raspberrypi/${FAMILY}/dcd_rp2040.c
|
||||
${TOP}/src/portable/raspberrypi/${FAMILY}/rp2040_usb.c
|
||||
)
|
||||
elseif(FAMILY STREQUAL "rp2040")
|
||||
include(${TOP}/hw/bsp/${FAMILY}/family.cmake)
|
||||
|
||||
# Example source
|
||||
set(SRC_EXAMPLE
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
src/main.c
|
||||
src/msc_disk.c
|
||||
src/usb_descriptors.c
|
||||
)
|
||||
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
${SRC_EXAMPLE}
|
||||
${TOP}/hw/bsp/${FAMILY}/family.c
|
||||
${SRC_TINYUSB}
|
||||
)
|
||||
|
||||
# Example include
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
src/
|
||||
${TOP}/hw
|
||||
${TOP}/src
|
||||
${TOP}/hw/bsp/${FAMILY}/boards/${BOARD}
|
||||
src
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT} PUBLIC
|
||||
CFG_TUSB_MCU=OPT_MCU_RP2040
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid FAMILY specified")
|
||||
endif()
|
||||
|
@ -1,3 +1,49 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
set(PICO_SDK_PATH ${TOP}/hw/mcu/raspberrypi/pico-sdk)
|
||||
include(${PICO_SDK_PATH}/pico_sdk_init.cmake)
|
||||
|
||||
project(${PROJECT})
|
||||
|
||||
pico_sdk_init()
|
||||
|
||||
add_executable(${PROJECT})
|
||||
|
||||
# TinyUSB Stack source
|
||||
set(SRC_TINYUSB
|
||||
${TOP}/src/tusb.c
|
||||
${TOP}/src/common/tusb_fifo.c
|
||||
${TOP}/src/device/usbd.c
|
||||
${TOP}/src/device/usbd_control.c
|
||||
${TOP}/src/class/audio/audio_device.c
|
||||
${TOP}/src/class/cdc/cdc_device.c
|
||||
${TOP}/src/class/dfu/dfu_rt_device.c
|
||||
${TOP}/src/class/hid/hid_device.c
|
||||
${TOP}/src/class/midi/midi_device.c
|
||||
${TOP}/src/class/msc/msc_device.c
|
||||
${TOP}/src/class/net/net_device.c
|
||||
${TOP}/src/class/usbtmc/usbtmc_device.c
|
||||
${TOP}/src/class/vendor/vendor_device.c
|
||||
${TOP}/src/portable/raspberrypi/${FAMILY}/dcd_rp2040.c
|
||||
${TOP}/src/portable/raspberrypi/${FAMILY}/rp2040_usb.c
|
||||
)
|
||||
|
||||
target_sources(${PROJECT} PUBLIC
|
||||
${TOP}/hw/bsp/${FAMILY}/family.c
|
||||
${SRC_TINYUSB}
|
||||
)
|
||||
|
||||
target_include_directories(${PROJECT} PUBLIC
|
||||
${TOP}/hw
|
||||
${TOP}/src
|
||||
${TOP}/hw/bsp/${FAMILY}/boards/${BOARD}
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT} PUBLIC
|
||||
CFG_TUSB_MCU=OPT_MCU_RP2040
|
||||
CFG_TUSB_OS=OPT_OS_PICO
|
||||
)
|
||||
|
||||
target_link_libraries(${PROJECT} pico_stdlib)
|
||||
|
||||
pico_add_extra_outputs(${PROJECT})
|
||||
|
@ -1 +0,0 @@
|
||||
pico_sdk_init()
|
Loading…
x
Reference in New Issue
Block a user