Rtos API example

Committer:
marcozecchini
Date:
Sat Feb 23 12:13:36 2019 +0000
Revision:
0:9fca2b23d0ba
final commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
marcozecchini 0:9fca2b23d0ba 1 """
marcozecchini 0:9fca2b23d0ba 2 mbed SDK
marcozecchini 0:9fca2b23d0ba 3 Copyright (c) 2011-2013 ARM Limited
marcozecchini 0:9fca2b23d0ba 4
marcozecchini 0:9fca2b23d0ba 5 Licensed under the Apache License, Version 2.0 (the "License");
marcozecchini 0:9fca2b23d0ba 6 you may not use this file except in compliance with the License.
marcozecchini 0:9fca2b23d0ba 7 You may obtain a copy of the License at
marcozecchini 0:9fca2b23d0ba 8
marcozecchini 0:9fca2b23d0ba 9 http://www.apache.org/licenses/LICENSE-2.0
marcozecchini 0:9fca2b23d0ba 10
marcozecchini 0:9fca2b23d0ba 11 Unless required by applicable law or agreed to in writing, software
marcozecchini 0:9fca2b23d0ba 12 distributed under the License is distributed on an "AS IS" BASIS,
marcozecchini 0:9fca2b23d0ba 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
marcozecchini 0:9fca2b23d0ba 14 See the License for the specific language governing permissions and
marcozecchini 0:9fca2b23d0ba 15 limitations under the License.
marcozecchini 0:9fca2b23d0ba 16 """
marcozecchini 0:9fca2b23d0ba 17 from tools.paths import MBED_LIBRARIES,\
marcozecchini 0:9fca2b23d0ba 18 MBED_RPC, RPC_LIBRARY, USB, USB_LIBRARIES, \
marcozecchini 0:9fca2b23d0ba 19 DSP_ABSTRACTION, DSP_CMSIS, DSP_LIBRARIES,\
marcozecchini 0:9fca2b23d0ba 20 CPPUTEST_SRC,\
marcozecchini 0:9fca2b23d0ba 21 CPPUTEST_PLATFORM_SRC, CPPUTEST_TESTRUNNER_SCR, CPPUTEST_LIBRARY,\
marcozecchini 0:9fca2b23d0ba 22 CPPUTEST_INC, CPPUTEST_PLATFORM_INC, CPPUTEST_TESTRUNNER_INC,\
marcozecchini 0:9fca2b23d0ba 23 CPPUTEST_INC_EXT
marcozecchini 0:9fca2b23d0ba 24 from tools.data.support import DEFAULT_SUPPORT
marcozecchini 0:9fca2b23d0ba 25 from tools.tests import TEST_MBED_LIB
marcozecchini 0:9fca2b23d0ba 26
marcozecchini 0:9fca2b23d0ba 27
marcozecchini 0:9fca2b23d0ba 28 LIBRARIES = [
marcozecchini 0:9fca2b23d0ba 29 # RPC
marcozecchini 0:9fca2b23d0ba 30 {
marcozecchini 0:9fca2b23d0ba 31 "id": "rpc",
marcozecchini 0:9fca2b23d0ba 32 "source_dir": MBED_RPC,
marcozecchini 0:9fca2b23d0ba 33 "build_dir": RPC_LIBRARY,
marcozecchini 0:9fca2b23d0ba 34 "dependencies": [MBED_LIBRARIES],
marcozecchini 0:9fca2b23d0ba 35 },
marcozecchini 0:9fca2b23d0ba 36
marcozecchini 0:9fca2b23d0ba 37 # USB Device libraries
marcozecchini 0:9fca2b23d0ba 38 {
marcozecchini 0:9fca2b23d0ba 39 "id": "usb",
marcozecchini 0:9fca2b23d0ba 40 "source_dir": USB,
marcozecchini 0:9fca2b23d0ba 41 "build_dir": USB_LIBRARIES,
marcozecchini 0:9fca2b23d0ba 42 "dependencies": [MBED_LIBRARIES],
marcozecchini 0:9fca2b23d0ba 43 },
marcozecchini 0:9fca2b23d0ba 44
marcozecchini 0:9fca2b23d0ba 45 # DSP libraries
marcozecchini 0:9fca2b23d0ba 46 {
marcozecchini 0:9fca2b23d0ba 47 "id": "dsp",
marcozecchini 0:9fca2b23d0ba 48 "source_dir": [DSP_ABSTRACTION, DSP_CMSIS],
marcozecchini 0:9fca2b23d0ba 49 "build_dir": DSP_LIBRARIES,
marcozecchini 0:9fca2b23d0ba 50 "dependencies": [MBED_LIBRARIES]
marcozecchini 0:9fca2b23d0ba 51 },
marcozecchini 0:9fca2b23d0ba 52
marcozecchini 0:9fca2b23d0ba 53 # Unit Testing library
marcozecchini 0:9fca2b23d0ba 54 {
marcozecchini 0:9fca2b23d0ba 55 "id": "cpputest",
marcozecchini 0:9fca2b23d0ba 56 "source_dir": [CPPUTEST_SRC, CPPUTEST_PLATFORM_SRC,
marcozecchini 0:9fca2b23d0ba 57 CPPUTEST_TESTRUNNER_SCR],
marcozecchini 0:9fca2b23d0ba 58 "build_dir": CPPUTEST_LIBRARY,
marcozecchini 0:9fca2b23d0ba 59 "dependencies": [MBED_LIBRARIES],
marcozecchini 0:9fca2b23d0ba 60 'inc_dirs': [CPPUTEST_INC, CPPUTEST_PLATFORM_INC,
marcozecchini 0:9fca2b23d0ba 61 CPPUTEST_TESTRUNNER_INC, TEST_MBED_LIB],
marcozecchini 0:9fca2b23d0ba 62 'inc_dirs_ext': [CPPUTEST_INC_EXT],
marcozecchini 0:9fca2b23d0ba 63 'macros': ["CPPUTEST_USE_MEM_LEAK_DETECTION=0",
marcozecchini 0:9fca2b23d0ba 64 "CPPUTEST_USE_STD_CPP_LIB=0", "CPPUTEST=1"],
marcozecchini 0:9fca2b23d0ba 65 },
marcozecchini 0:9fca2b23d0ba 66 ]
marcozecchini 0:9fca2b23d0ba 67
marcozecchini 0:9fca2b23d0ba 68
marcozecchini 0:9fca2b23d0ba 69 LIBRARY_MAP = dict([(library['id'], library) for library in LIBRARIES])
marcozecchini 0:9fca2b23d0ba 70
marcozecchini 0:9fca2b23d0ba 71
marcozecchini 0:9fca2b23d0ba 72 class Library(object):
marcozecchini 0:9fca2b23d0ba 73 """A library representation that allows for querying of support"""
marcozecchini 0:9fca2b23d0ba 74 def __init__(self, lib_id):
marcozecchini 0:9fca2b23d0ba 75 lib = LIBRARY_MAP[lib_id]
marcozecchini 0:9fca2b23d0ba 76 self.supported = lib.get("supported", DEFAULT_SUPPORT)
marcozecchini 0:9fca2b23d0ba 77 self.dependencies = lib.get("dependencies", None)
marcozecchini 0:9fca2b23d0ba 78 # Include dirs required by library build
marcozecchini 0:9fca2b23d0ba 79 self.inc_dirs = lib.get("inc_dirs", None)
marcozecchini 0:9fca2b23d0ba 80 # Include dirs required by others to use with this library
marcozecchini 0:9fca2b23d0ba 81 self.inc_dirs_ext = lib.get("inc_dirs_ext", None)
marcozecchini 0:9fca2b23d0ba 82 # Additional macros you want to define when building library
marcozecchini 0:9fca2b23d0ba 83 self.macros = lib.get("macros", None)
marcozecchini 0:9fca2b23d0ba 84
marcozecchini 0:9fca2b23d0ba 85 self.source_dir = lib["source_dir"]
marcozecchini 0:9fca2b23d0ba 86 self.build_dir = lib["build_dir"]
marcozecchini 0:9fca2b23d0ba 87
marcozecchini 0:9fca2b23d0ba 88 def is_supported(self, target, toolchain):
marcozecchini 0:9fca2b23d0ba 89 """Check if a target toolchain combination is supported
marcozecchini 0:9fca2b23d0ba 90
marcozecchini 0:9fca2b23d0ba 91 Positional arguments:
marcozecchini 0:9fca2b23d0ba 92 target - the MCU or board
marcozecchini 0:9fca2b23d0ba 93 toolchain - the compiler
marcozecchini 0:9fca2b23d0ba 94 """
marcozecchini 0:9fca2b23d0ba 95 if not hasattr(self, 'supported'):
marcozecchini 0:9fca2b23d0ba 96 return True
marcozecchini 0:9fca2b23d0ba 97 return (target.name in self.supported) and \
marcozecchini 0:9fca2b23d0ba 98 (toolchain in self.supported[target.name])