Use MPU9250 with nRF51822

Dependencies:   eMPL_MPU

Fork of Seeed_Tiny_BLE_Flash by Darren Huang

Committer:
yihui
Date:
Thu Dec 10 08:00:18 2015 +0000
Revision:
5:9b240c1d5251
get 9dof data from mpu9250

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 5:9b240c1d5251 1 #
yihui 5:9b240c1d5251 2 # mbed-2 yotta-compatible build system
yihui 5:9b240c1d5251 3 #
yihui 5:9b240c1d5251 4
yihui 5:9b240c1d5251 5 # make sure necessary features are enabled:
yihui 5:9b240c1d5251 6 project(mbed-classic)
yihui 5:9b240c1d5251 7 enable_language(ASM)
yihui 5:9b240c1d5251 8
yihui 5:9b240c1d5251 9 # override compilation flags:
yihui 5:9b240c1d5251 10 if(CMAKE_C_COMPILER_ID MATCHES GNU)
yihui 5:9b240c1d5251 11 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
yihui 5:9b240c1d5251 12 endif()
yihui 5:9b240c1d5251 13
yihui 5:9b240c1d5251 14 # the mbed.a library is built from two sets of source files + include
yihui 5:9b240c1d5251 15 # directories:
yihui 5:9b240c1d5251 16 #
yihui 5:9b240c1d5251 17 # MBED_COMMON_SOURCES: the source files that are the same for all targets,
yihui 5:9b240c1d5251 18 # these are easily found by globbing:
yihui 5:9b240c1d5251 19 #
yihui 5:9b240c1d5251 20 file(GLOB MBED_COMMON_SOURCES "common/*.cpp" "common/*.c")
yihui 5:9b240c1d5251 21 #
yihui 5:9b240c1d5251 22 # (always include the hal header directory, too)
yihui 5:9b240c1d5251 23 set(MBED_COMMON_INCLUDE_DIRS "hal")
yihui 5:9b240c1d5251 24
yihui 5:9b240c1d5251 25 # and MBED_TARGET_SOURCES: these depend on which target we are building for. To
yihui 5:9b240c1d5251 26 # find these we need to walk the directories in targets/, and wherever we see a
yihui 5:9b240c1d5251 27 # TARGET_<something> name, recurse only if <something> matches what we're
yihui 5:9b240c1d5251 28 # currently building for
yihui 5:9b240c1d5251 29 macro(mbed_find_target_dirs PARENT_DIRECTORY SOURCES_LIST INCLUDES_LIST)
yihui 5:9b240c1d5251 30 # append this directory to the search path:
yihui 5:9b240c1d5251 31 list(APPEND ${INCLUDES_LIST} "${PARENT_DIRECTORY}")
yihui 5:9b240c1d5251 32 # add all source files in this directory to the sources list:
yihui 5:9b240c1d5251 33 file(GLOB sources "${PARENT_DIRECTORY}/*.cpp" "${PARENT_DIRECTORY}/*.c" "${PARENT_DIRECTORY}/*.s" "${PARENT_DIRECTORY}/*.S" )
yihui 5:9b240c1d5251 34 list(APPEND ${SOURCES_LIST} ${sources})
yihui 5:9b240c1d5251 35
yihui 5:9b240c1d5251 36 # get a list of all subdirectories that we want to recurse into:
yihui 5:9b240c1d5251 37 file(GLOB dir_children RELATIVE "${PARENT_DIRECTORY}" "${PARENT_DIRECTORY}/*")
yihui 5:9b240c1d5251 38 set(matching_subdirs "")
yihui 5:9b240c1d5251 39 foreach(child ${dir_children})
yihui 5:9b240c1d5251 40 if(IS_DIRECTORY "${PARENT_DIRECTORY}/${child}")
yihui 5:9b240c1d5251 41 # is this directory name a magic one?
yihui 5:9b240c1d5251 42 if("${child}" MATCHES "^TARGET_")
yihui 5:9b240c1d5251 43 # target-magic: recurse if the MBED_LEGACY_TARGET_DEFINITIONS **list**
yihui 5:9b240c1d5251 44 # contains a matching value:
yihui 5:9b240c1d5251 45 foreach(legacy_magic_def ${MBED_LEGACY_TARGET_DEFINITIONS})
yihui 5:9b240c1d5251 46 # we could probably unroll the list into a single regex if
yihui 5:9b240c1d5251 47 # this is a performance problem:
yihui 5:9b240c1d5251 48 if("${child}" MATCHES "^TARGET_${legacy_magic_def}$")
yihui 5:9b240c1d5251 49 list(APPEND matching_subdirs ${child})
yihui 5:9b240c1d5251 50 break()
yihui 5:9b240c1d5251 51 endif()
yihui 5:9b240c1d5251 52 endforeach()
yihui 5:9b240c1d5251 53 elseif("${child}" MATCHES "^TOOLCHAIN_")
yihui 5:9b240c1d5251 54 # toolchain-magic: (recurse if the MBED_LEGACY_TOOLCHAIN matches
yihui 5:9b240c1d5251 55 # this name)
yihui 5:9b240c1d5251 56 if("${child}" MATCHES "^TOOLCHAIN_${MBED_LEGACY_TOOLCHAIN}$")
yihui 5:9b240c1d5251 57 list(APPEND matching_subdirs "${child}")
yihui 5:9b240c1d5251 58 endif()
yihui 5:9b240c1d5251 59 else()
yihui 5:9b240c1d5251 60 # not special: always recurse into this directory
yihui 5:9b240c1d5251 61 list(APPEND matching_subdirs "${child}")
yihui 5:9b240c1d5251 62 endif()
yihui 5:9b240c1d5251 63 endif()
yihui 5:9b240c1d5251 64 endforeach()
yihui 5:9b240c1d5251 65 #message("matching_subdirs: ${matching_subdirs}")
yihui 5:9b240c1d5251 66
yihui 5:9b240c1d5251 67 # recurse:
yihui 5:9b240c1d5251 68 foreach(subdir ${matching_subdirs})
yihui 5:9b240c1d5251 69 mbed_find_target_dirs("${PARENT_DIRECTORY}/${subdir}" ${SOURCES_LIST} ${INCLUDES_LIST})
yihui 5:9b240c1d5251 70 endforeach()
yihui 5:9b240c1d5251 71 endmacro()
yihui 5:9b240c1d5251 72
yihui 5:9b240c1d5251 73 set(MBED_TARGET_SOURCES "")
yihui 5:9b240c1d5251 74 set(MBED_TARGET_INCLUDE_DIRS "")
yihui 5:9b240c1d5251 75 mbed_find_target_dirs("${CMAKE_CURRENT_SOURCE_DIR}/targets" MBED_TARGET_SOURCES MBED_TARGET_INCLUDE_DIRS)
yihui 5:9b240c1d5251 76 #message("found target sources: ${MBED_TARGET_SOURCES}")
yihui 5:9b240c1d5251 77 #message("found target include dirs: ${MBED_TARGET_INCLUDE_DIRS}")
yihui 5:9b240c1d5251 78
yihui 5:9b240c1d5251 79 # unfortunately, for ARMCC, the startup code needs to be provided as an object
yihui 5:9b240c1d5251 80 # on the command line (not as part of an archive). To do this we override the
yihui 5:9b240c1d5251 81 # CMake add_executable command.
yihui 5:9b240c1d5251 82 if(CMAKE_C_COMPILER_ID STREQUAL "ARMCC")
yihui 5:9b240c1d5251 83 set(MBED_TARGET_STARTUP_CODE_SOURCES "")
yihui 5:9b240c1d5251 84 foreach(src ${MBED_TARGET_SOURCES})
yihui 5:9b240c1d5251 85 if("${src}" MATCHES .*startup_.*\\.[sS])
yihui 5:9b240c1d5251 86 LIST(APPEND MBED_TARGET_STARTUP_CODE_SOURCES "${src}")
yihui 5:9b240c1d5251 87 endif()
yihui 5:9b240c1d5251 88 endforeach()
yihui 5:9b240c1d5251 89 add_library(mbed_classic_startupcod OBJECT ${MBED_TARGET_STARTUP_CODE_SOURCES})
yihui 5:9b240c1d5251 90 macro (add_executable _name)
yihui 5:9b240c1d5251 91 _add_executable(${ARGV} $<TARGET_OBJECTS:mbed_classic_startupcod>)
yihui 5:9b240c1d5251 92 endmacro()
yihui 5:9b240c1d5251 93 endif()
yihui 5:9b240c1d5251 94
yihui 5:9b240c1d5251 95 # we have to append any target-specific include dirs to the global include dirs
yihui 5:9b240c1d5251 96 # list, so that any indirect includes (e.g. via mbed.h) of files in those
yihui 5:9b240c1d5251 97 # directories will work:
yihui 5:9b240c1d5251 98 # (non-target-specific include dirs are listed in extraIncludes in module.json)
yihui 5:9b240c1d5251 99 foreach(dir ${MBED_TARGET_INCLUDE_DIRS})
yihui 5:9b240c1d5251 100 set_property(GLOBAL APPEND PROPERTY YOTTA_GLOBAL_INCLUDE_DIRS ${dir})
yihui 5:9b240c1d5251 101 endforeach()
yihui 5:9b240c1d5251 102
yihui 5:9b240c1d5251 103 # finally, we can construct a library using the determined set of include paths
yihui 5:9b240c1d5251 104 # + source files. Note that the library name must match the name of the yotta
yihui 5:9b240c1d5251 105 # module (defined in module.json) for this module to link properly with other
yihui 5:9b240c1d5251 106 # yotta modules.
yihui 5:9b240c1d5251 107 include_directories(${MBED_COMMON_INCLUDE_DIRS})
yihui 5:9b240c1d5251 108 include_directories(${MBED_TARGET_INCLUDE_DIRS})
yihui 5:9b240c1d5251 109 add_library(mbed-classic
yihui 5:9b240c1d5251 110 ${MBED_COMMON_SOURCES}
yihui 5:9b240c1d5251 111 ${MBED_TARGET_SOURCES}
yihui 5:9b240c1d5251 112 )