PokittoLib is the library needed for programming the Pokitto DIY game console (www.pokitto.com)

Dependents:   YATTT sd_map_test cPong SnowDemo ... more

PokittoLib

Library for programming Pokitto hardware

How to Use

  1. Import this library to online compiler (see button "import" on the right hand side
  2. DO NOT import mbed-src anymore, a better version is now included inside PokittoLib
  3. Change My_settings.h according to your project
  4. Start coding!
Committer:
Pokitto
Date:
Wed Dec 25 23:59:52 2019 +0000
Revision:
71:531419862202
Parent:
5:ea7377f3d1af
Changed Mode2 C++ refresh code (graphical errors)

Who changed what in which revision?

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