Merge pull request #2134 from clhenry/non-bus-powered-re-enumeration
Non-bus-powered MSP430 support.
This commit is contained in:
@@ -460,6 +460,21 @@ function(family_flash_dfu_util TARGET OPTION)
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(family_flash_msp430flasher TARGET)
|
||||
if (NOT DEFINED MSP430Flasher)
|
||||
set(MSP430FLASHER MSP430Flasher)
|
||||
endif ()
|
||||
|
||||
# set LD_LIBRARY_PATH to find libmsp430.so (directory containing MSP430Flasher)
|
||||
find_program(MSP430FLASHER_PATH MSP430Flasher)
|
||||
get_filename_component(MSP430FLASHER_PARENT_DIR "${MSP430FLASHER_PATH}" DIRECTORY)
|
||||
add_custom_target(${TARGET}-msp430flasher
|
||||
DEPENDS ${TARGET}
|
||||
COMMAND ${CMAKE_COMMAND} -E env LD_LIBRARY_PATH=${MSP430FLASHER_PARENT_DIR}
|
||||
${MSP430FLASHER} -w $<TARGET_FILE_DIR:${TARGET}>/${TARGET}.hex -z [VCC]
|
||||
)
|
||||
endfunction()
|
||||
|
||||
#----------------------------------
|
||||
# Family specific
|
||||
#----------------------------------
|
||||
|
9
hw/bsp/msp430/boards/msp_exp430f5529lp/board.cmake
Normal file
9
hw/bsp/msp430/boards/msp_exp430f5529lp/board.cmake
Normal file
@@ -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()
|
4
hw/bsp/msp430/boards/msp_exp430f5529lp/board.mk
Normal file
4
hw/bsp/msp430/boards/msp_exp430f5529lp/board.mk
Normal file
@@ -0,0 +1,4 @@
|
||||
CFLAGS += \
|
||||
-D__MSP430F5529__ \
|
||||
|
||||
LD_FILE = ${SDK_DIR}/msp430f5529.ld
|
84
hw/bsp/msp430/family.cmake
Normal file
84
hw/bsp/msp430/family.cmake
Normal file
@@ -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()
|
@@ -2,21 +2,21 @@ CROSS_COMPILE = msp430-elf-
|
||||
DEPS_SUBMODULES += hw/mcu/ti
|
||||
SKIP_NANOLIB = 1
|
||||
|
||||
SDK_DIR = hw/mcu/ti/msp430/msp430-gcc-support-files/include
|
||||
|
||||
include $(TOP)/$(BOARD_PATH)/board.mk
|
||||
|
||||
CFLAGS += \
|
||||
-D__MSP430F5529__ \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_MSP430x5xx \
|
||||
-DCFG_EXAMPLE_MSC_READONLY \
|
||||
-DCFG_TUD_ENDPOINT0_SIZE=8
|
||||
|
||||
# All source paths should be relative to the top level.
|
||||
LD_FILE = hw/mcu/ti/msp430/msp430-gcc-support-files/include/msp430f5529.ld
|
||||
LDINC += $(TOP)/hw/mcu/ti/msp430/msp430-gcc-support-files/include
|
||||
LDFLAGS += $(addprefix -L,$(LDINC))
|
||||
LDFLAGS += -L${TOP}/${SDK_DIR}
|
||||
|
||||
SRC_C += src/portable/ti/msp430x5xx/dcd_msp430x5xx.c
|
||||
|
||||
INC += \
|
||||
$(TOP)/hw/mcu/ti/msp430/msp430-gcc-support-files/include \
|
||||
${TOP}/${SDK_DIR} \
|
||||
$(TOP)/$(BOARD_PATH)
|
||||
|
||||
# export for libmsp430.so to same installation
|
||||
|
Reference in New Issue
Block a user