Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
changes to accommodate ever-changing pico_sdk build requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
majbthrd committed Jan 27, 2022
1 parent 7233ae5 commit 5be18ff
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 55 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "CMSIS_5"]
path = CMSIS_5
url = https://github.com/ARM-software/CMSIS_5.git
[submodule "pico-sdk"]
path = pico-sdk
url = https://github.com/raspberrypi/pico-sdk
86 changes: 38 additions & 48 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,51 +1,41 @@
# use directory name for project id
cmake_minimum_required(VERSION 3.5)

include(${CMAKE_CURRENT_SOURCE_DIR}/tinyusb/hw/bsp/family_support.cmake)

# gets PROJECT name for the example (e.g. <BOARD>-<DIR_NAME>)
get_filename_component(PROJECT ${CMAKE_CURRENT_SOURCE_DIR} NAME)
set(PROJECT ${BOARD}-${PROJECT})

# TOP is absolute path to root directory of TinyUSB git repo
set(TOP "./tinyusb")
get_filename_component(TOP "${TOP}" REALPATH)

# Check for -DFAMILY=
if(FAMILY STREQUAL "rp2040")
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})

include(${TOP}/hw/bsp/${FAMILY}/family.cmake)

# Example source
target_sources(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/main.c
${CMAKE_CURRENT_SOURCE_DIR}/usb_descriptors.c
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/DAP.c
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/JTAG_DP.c
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/DAP_vendor.c
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/SWO.c
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/SW_DP.c
${CMAKE_CURRENT_SOURCE_DIR}/bsp/${FAMILY}/cdc_uart.c
)

# Example include
target_include_directories(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Include/
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/Core/Include/
${CMAKE_CURRENT_SOURCE_DIR}/bsp/${FAMILY}/
${CMAKE_CURRENT_SOURCE_DIR}/bsp/default/
)

# Example defines
target_compile_definitions(${PROJECT} PUBLIC
)

target_link_libraries(${PROJECT} pico_stdlib pico_fix_rp2040_usb_device_enumeration pico_unique_id)

pico_add_extra_outputs(${PROJECT})

else()
message(FATAL_ERROR "Invalid FAMILY specified")
endif()
project(${PROJECT})

# Checks this example is valid for the family and initializes the project
family_initialize_project(${PROJECT} ${CMAKE_CURRENT_LIST_DIR})

add_executable(${PROJECT})

# Example source
target_sources(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/main.c
${CMAKE_CURRENT_SOURCE_DIR}/usb_descriptors.c
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/DAP.c
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/JTAG_DP.c
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/DAP_vendor.c
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/SWO.c
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Source/SW_DP.c
${CMAKE_CURRENT_SOURCE_DIR}/bsp/${FAMILY}/cdc_uart.c
)

# Example include
target_include_directories(${PROJECT} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/DAP/Firmware/Include/
${CMAKE_CURRENT_SOURCE_DIR}/CMSIS_5/CMSIS/Core/Include/
${CMAKE_CURRENT_SOURCE_DIR}/bsp/${FAMILY}/
${CMAKE_CURRENT_SOURCE_DIR}/bsp/default/
)

target_link_libraries(${PROJECT} PUBLIC pico_unique_id)

# Configure compilation flags and libraries for the example... see the corresponding function
# in hw/bsp/FAMILY/family.cmake for details.
family_configure_device_example(${PROJECT})
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
include ./tinyusb/tools/top.mk
include ./tinyusb/examples/make.mk

PICO_SDK_PATH = ../../pico-sdk

INC += \
. \
./CMSIS_5/CMSIS/DAP/Firmware/Include \
Expand All @@ -13,11 +15,11 @@ APP_SOURCE += $(wildcard ./*.c)
SRC_C += $(addprefix $(CURRENT_PATH)/, $(APP_SOURCE))

SRC_C += \
./CMSIS_5/CMSIS/DAP/Firmware/Source/DAP.c \
./CMSIS_5/CMSIS/DAP/Firmware/Source/JTAG_DP.c \
./CMSIS_5/CMSIS/DAP/Firmware/Source/DAP_vendor.c \
./CMSIS_5/CMSIS/DAP/Firmware/Source/SWO.c \
./CMSIS_5/CMSIS/DAP/Firmware/Source/SW_DP.c \
./bsp/$(BOARD)/cdc_uart.c
./CMSIS_5/CMSIS/DAP/Firmware/Source/DAP.c \
./CMSIS_5/CMSIS/DAP/Firmware/Source/JTAG_DP.c \
./CMSIS_5/CMSIS/DAP/Firmware/Source/DAP_vendor.c \
./CMSIS_5/CMSIS/DAP/Firmware/Source/SWO.c \
./CMSIS_5/CMSIS/DAP/Firmware/Source/SW_DP.c \
./bsp/$(BOARD)/cdc_uart.c

include ./tinyusb/examples/rules.mk
1 change: 1 addition & 0 deletions pico-sdk
Submodule pico-sdk added at 206237
3 changes: 2 additions & 1 deletion tusb_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@
#error "Incorrect RHPort configuration"
#endif

// This example doesn't use an RTOS
#ifndef CFG_TUSB_OS
#define CFG_TUSB_OS OPT_OS_NONE
#endif

// CFG_TUSB_DEBUG is defined by compiler in DEBUG build
// #define CFG_TUSB_DEBUG 0
Expand Down

0 comments on commit 5be18ff

Please sign in to comment.