PokittoLib with changes to lcd refresh etc.

Dependents:   Pokittris

Fork of Pokitto by Pokitto Community Team

This is a fork by user @Spinal, and is used in Pokittris for testing. Do not import this to your own program.

Committer:
spinal
Date:
Sun Oct 15 18:03:02 2017 +0000
Revision:
11:02ad9c807a21
Parent:
5:7e5c566b1760
fixed 4color refreshRegion code

Who changed what in which revision?

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