-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2134 from clhenry/non-bus-powered-re-enumeration
Non-bus-powered MSP430 support.
- Loading branch information
Showing
12 changed files
with
322 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
if (TOOLCHAIN STREQUAL "gcc") | ||
set(FREERTOS_PORT GCC_MSP430F449 CACHE INTERNAL "") | ||
|
||
elseif (TOOLCHAIN STREQUAL "iar") | ||
set(FREERTOS_PORT IAR_MSP430 CACHE INTERNAL "") | ||
|
||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
set(CMAKE_SYSTEM_NAME Generic) | ||
|
||
if (NOT DEFINED CMAKE_C_COMPILER) | ||
set(CMAKE_C_COMPILER "msp430-elf-gcc") | ||
endif () | ||
|
||
if (NOT DEFINED CMAKE_CXX_COMPILER) | ||
set(CMAKE_CXX_COMPILER "msp430-elf-g++") | ||
endif () | ||
|
||
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) | ||
|
||
set(CMAKE_SIZE "msp430-elf-size" CACHE FILEPATH "") | ||
set(CMAKE_OBJCOPY "msp430-elf-objcopy" CACHE FILEPATH "") | ||
set(CMAKE_OBJDUMP "msp430-elf-objdump" CACHE FILEPATH "") | ||
|
||
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE) | ||
|
||
# Look for includes and libraries only in the target system prefix. | ||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) | ||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | ||
|
||
# pass TOOLCHAIN_CPU to | ||
set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_SYSTEM_PROCESSOR) | ||
|
||
include(${CMAKE_CURRENT_LIST_DIR}/../cpu/${CMAKE_SYSTEM_PROCESSOR}.cmake) | ||
|
||
# enable all possible warnings for building examples | ||
list(APPEND TOOLCHAIN_COMMON_FLAGS | ||
-fdata-sections | ||
-ffunction-sections | ||
-fsingle-precision-constant | ||
-fno-strict-aliasing | ||
) | ||
|
||
list(APPEND TOOLCHAIN_EXE_LINKER_FLAGS | ||
-Wl,--print-memory-usage | ||
-Wl,--gc-sections | ||
-Wl,--cref | ||
) | ||
|
||
include(${CMAKE_CURRENT_LIST_DIR}/set_flags.cmake) | ||
|
||
# try_compile is cmake test compiling its own example, | ||
# pass -nostdlib to skip stdlib linking | ||
get_property(IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE) | ||
if (IS_IN_TRY_COMPILE) | ||
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -nostdlib") | ||
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -nostdlib") | ||
endif () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ifeq ($(TOOLCHAIN),gcc) | ||
# nothing to add | ||
else ifeq ($(TOOLCHAIN),iar) | ||
# nothing to add | ||
endif | ||
|
||
# For freeRTOS port source | ||
FREERTOS_PORTABLE_SRC ?= $(FREERTOS_PORTABLE_PATH)/GCC_MSP430F449 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
set(MCU_VARIANT msp430f5529) | ||
set(LD_FILE_GNU ${SDK_DIR}/msp430f5529.ld) | ||
|
||
function(update_board TARGET) | ||
target_compile_definitions(${TARGET} INTERFACE | ||
__MSP430F5529__ | ||
) | ||
|
||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CFLAGS += \ | ||
-D__MSP430F5529__ \ | ||
|
||
LD_FILE = ${SDK_DIR}/msp430f5529.ld |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
include_guard() | ||
|
||
set(SDK_DIR ${TOP}/hw/mcu/ti/msp430/msp430-gcc-support-files/include) | ||
|
||
# include board specific | ||
include(${CMAKE_CURRENT_LIST_DIR}/boards/${BOARD}/board.cmake) | ||
|
||
# toolchain set up | ||
set(CMAKE_SYSTEM_PROCESSOR msp430 CACHE INTERNAL "System Processor") | ||
set(CMAKE_TOOLCHAIN_FILE ${TOP}/examples/build_system/cmake/toolchain/msp430_${TOOLCHAIN}.cmake) | ||
|
||
set(FAMILY_MCUS MSP430x5xx CACHE INTERNAL "") | ||
|
||
|
||
#------------------------------------ | ||
# BOARD_TARGET | ||
#------------------------------------ | ||
# only need to be built ONCE for all examples | ||
function(add_board_target BOARD_TARGET) | ||
if (NOT TARGET ${BOARD_TARGET}) | ||
add_library(${BOARD_TARGET} INTERFACE) | ||
target_compile_definitions(${BOARD_TARGET} INTERFACE | ||
CFG_TUD_ENDPOINT0_SIZE=8 | ||
CFG_EXAMPLE_VIDEO_READONLY | ||
CFG_EXAMPLE_MSC_READONLY | ||
) | ||
target_include_directories(${BOARD_TARGET} INTERFACE | ||
${CMAKE_CURRENT_FUNCTION_LIST_DIR} | ||
${SDK_DIR} | ||
) | ||
|
||
update_board(${BOARD_TARGET}) | ||
|
||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU") | ||
target_link_options(${BOARD_TARGET} INTERFACE | ||
"LINKER:--script=${LD_FILE_GNU}" | ||
-L${SDK_DIR} | ||
) | ||
elseif (CMAKE_C_COMPILER_ID STREQUAL "IAR") | ||
target_link_options(${BOARD_TARGET} INTERFACE | ||
"LINKER:--config=${LD_FILE_IAR}" | ||
) | ||
endif () | ||
endif () | ||
endfunction() | ||
|
||
|
||
#------------------------------------ | ||
# Functions | ||
#------------------------------------ | ||
function(family_configure_example TARGET RTOS) | ||
family_configure_common(${TARGET} ${RTOS}) | ||
|
||
# Board target | ||
add_board_target(board_${BOARD}) | ||
|
||
#---------- Port Specific ---------- | ||
# These files are built for each example since it depends on example's tusb_config.h | ||
target_sources(${TARGET} PUBLIC | ||
# BSP | ||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/family.c | ||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../board.c | ||
) | ||
target_include_directories(${TARGET} PUBLIC | ||
# family, hw, board | ||
${CMAKE_CURRENT_FUNCTION_LIST_DIR} | ||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/../../ | ||
${CMAKE_CURRENT_FUNCTION_LIST_DIR}/boards/${BOARD} | ||
) | ||
|
||
# Add TinyUSB target and port source | ||
family_add_tinyusb(${TARGET} OPT_MCU_MSP430x5xx ${RTOS}) | ||
target_sources(${TARGET}-tinyusb PUBLIC | ||
${TOP}/src/portable/ti/msp430x5xx/dcd_msp430x5xx.c | ||
) | ||
target_link_libraries(${TARGET}-tinyusb PUBLIC board_${BOARD}) | ||
|
||
# Link dependencies | ||
target_link_libraries(${TARGET} PUBLIC board_${BOARD} ${TARGET}-tinyusb) | ||
|
||
# Flashing | ||
family_add_bin_hex(${TARGET}) | ||
family_flash_msp430flasher(${TARGET}) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.