Includes library modifications to allow access to AIN_4 (AIN_0 / 5)

Committer:
bryantaylor
Date:
Tue Sep 20 21:26:12 2016 +0000
Revision:
0:eafc3fd41f75
hackathon

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bryantaylor 0:eafc3fd41f75 1 """
bryantaylor 0:eafc3fd41f75 2 mbed SDK
bryantaylor 0:eafc3fd41f75 3 Copyright (c) 2011-2013 ARM Limited
bryantaylor 0:eafc3fd41f75 4
bryantaylor 0:eafc3fd41f75 5 Licensed under the Apache License, Version 2.0 (the "License");
bryantaylor 0:eafc3fd41f75 6 you may not use this file except in compliance with the License.
bryantaylor 0:eafc3fd41f75 7 You may obtain a copy of the License at
bryantaylor 0:eafc3fd41f75 8
bryantaylor 0:eafc3fd41f75 9 http://www.apache.org/licenses/LICENSE-2.0
bryantaylor 0:eafc3fd41f75 10
bryantaylor 0:eafc3fd41f75 11 Unless required by applicable law or agreed to in writing, software
bryantaylor 0:eafc3fd41f75 12 distributed under the License is distributed on an "AS IS" BASIS,
bryantaylor 0:eafc3fd41f75 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bryantaylor 0:eafc3fd41f75 14 See the License for the specific language governing permissions and
bryantaylor 0:eafc3fd41f75 15 limitations under the License.
bryantaylor 0:eafc3fd41f75 16 """
bryantaylor 0:eafc3fd41f75 17 from tools.paths import MBED_RTX, RTOS_LIBRARIES, MBED_LIBRARIES, MBED_RPC,\
bryantaylor 0:eafc3fd41f75 18 RTOS_ABSTRACTION, RPC_LIBRARY, USB, USB_LIBRARIES, USB_HOST,\
bryantaylor 0:eafc3fd41f75 19 USB_HOST_LIBRARIES, FAT_FS, DSP_ABSTRACTION, DSP_CMSIS, DSP_LIBRARIES,\
bryantaylor 0:eafc3fd41f75 20 SD_FS, FS_LIBRARY, ETH_SOURCES, LWIP_SOURCES, ETH_LIBRARY, UBLOX_SOURCES,\
bryantaylor 0:eafc3fd41f75 21 UBLOX_LIBRARY, CELLULAR_SOURCES, CELLULAR_USB_SOURCES, CPPUTEST_SRC,\
bryantaylor 0:eafc3fd41f75 22 CPPUTEST_PLATFORM_SRC, CPPUTEST_TESTRUNNER_SCR, CPPUTEST_LIBRARY,\
bryantaylor 0:eafc3fd41f75 23 CPPUTEST_INC, CPPUTEST_PLATFORM_INC, CPPUTEST_TESTRUNNER_INC,\
bryantaylor 0:eafc3fd41f75 24 CPPUTEST_INC_EXT
bryantaylor 0:eafc3fd41f75 25 from tools.data.support import DEFAULT_SUPPORT
bryantaylor 0:eafc3fd41f75 26 from tools.tests import TEST_MBED_LIB
bryantaylor 0:eafc3fd41f75 27
bryantaylor 0:eafc3fd41f75 28
bryantaylor 0:eafc3fd41f75 29 LIBRARIES = [
bryantaylor 0:eafc3fd41f75 30 # RTOS libraries
bryantaylor 0:eafc3fd41f75 31 {
bryantaylor 0:eafc3fd41f75 32 "id": "rtx",
bryantaylor 0:eafc3fd41f75 33 "source_dir": MBED_RTX,
bryantaylor 0:eafc3fd41f75 34 "build_dir": RTOS_LIBRARIES,
bryantaylor 0:eafc3fd41f75 35 "dependencies": [MBED_LIBRARIES],
bryantaylor 0:eafc3fd41f75 36 },
bryantaylor 0:eafc3fd41f75 37 {
bryantaylor 0:eafc3fd41f75 38 "id": "rtos",
bryantaylor 0:eafc3fd41f75 39 "source_dir": RTOS_ABSTRACTION,
bryantaylor 0:eafc3fd41f75 40 "build_dir": RTOS_LIBRARIES,
bryantaylor 0:eafc3fd41f75 41 "dependencies": [MBED_LIBRARIES, MBED_RTX],
bryantaylor 0:eafc3fd41f75 42 },
bryantaylor 0:eafc3fd41f75 43
bryantaylor 0:eafc3fd41f75 44 # RPC
bryantaylor 0:eafc3fd41f75 45 {
bryantaylor 0:eafc3fd41f75 46 "id": "rpc",
bryantaylor 0:eafc3fd41f75 47 "source_dir": MBED_RPC,
bryantaylor 0:eafc3fd41f75 48 "build_dir": RPC_LIBRARY,
bryantaylor 0:eafc3fd41f75 49 "dependencies": [MBED_LIBRARIES],
bryantaylor 0:eafc3fd41f75 50 },
bryantaylor 0:eafc3fd41f75 51
bryantaylor 0:eafc3fd41f75 52 # USB Device libraries
bryantaylor 0:eafc3fd41f75 53 {
bryantaylor 0:eafc3fd41f75 54 "id": "usb",
bryantaylor 0:eafc3fd41f75 55 "source_dir": USB,
bryantaylor 0:eafc3fd41f75 56 "build_dir": USB_LIBRARIES,
bryantaylor 0:eafc3fd41f75 57 "dependencies": [MBED_LIBRARIES],
bryantaylor 0:eafc3fd41f75 58 },
bryantaylor 0:eafc3fd41f75 59
bryantaylor 0:eafc3fd41f75 60 # USB Host libraries
bryantaylor 0:eafc3fd41f75 61 {
bryantaylor 0:eafc3fd41f75 62 "id": "usb_host",
bryantaylor 0:eafc3fd41f75 63 "source_dir": USB_HOST,
bryantaylor 0:eafc3fd41f75 64 "build_dir": USB_HOST_LIBRARIES,
bryantaylor 0:eafc3fd41f75 65 "dependencies": [MBED_LIBRARIES, FAT_FS, MBED_RTX, RTOS_ABSTRACTION],
bryantaylor 0:eafc3fd41f75 66 },
bryantaylor 0:eafc3fd41f75 67
bryantaylor 0:eafc3fd41f75 68 # DSP libraries
bryantaylor 0:eafc3fd41f75 69 {
bryantaylor 0:eafc3fd41f75 70 "id": "dsp",
bryantaylor 0:eafc3fd41f75 71 "source_dir": [DSP_ABSTRACTION, DSP_CMSIS],
bryantaylor 0:eafc3fd41f75 72 "build_dir": DSP_LIBRARIES,
bryantaylor 0:eafc3fd41f75 73 "dependencies": [MBED_LIBRARIES]
bryantaylor 0:eafc3fd41f75 74 },
bryantaylor 0:eafc3fd41f75 75
bryantaylor 0:eafc3fd41f75 76 # File system libraries
bryantaylor 0:eafc3fd41f75 77 {
bryantaylor 0:eafc3fd41f75 78 "id": "fat",
bryantaylor 0:eafc3fd41f75 79 "source_dir": [FAT_FS, SD_FS],
bryantaylor 0:eafc3fd41f75 80 "build_dir": FS_LIBRARY,
bryantaylor 0:eafc3fd41f75 81 "dependencies": [MBED_LIBRARIES]
bryantaylor 0:eafc3fd41f75 82 },
bryantaylor 0:eafc3fd41f75 83
bryantaylor 0:eafc3fd41f75 84 # Network libraries
bryantaylor 0:eafc3fd41f75 85 {
bryantaylor 0:eafc3fd41f75 86 "id": "eth",
bryantaylor 0:eafc3fd41f75 87 "source_dir": [ETH_SOURCES, LWIP_SOURCES],
bryantaylor 0:eafc3fd41f75 88 "build_dir": ETH_LIBRARY,
bryantaylor 0:eafc3fd41f75 89 "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES]
bryantaylor 0:eafc3fd41f75 90 },
bryantaylor 0:eafc3fd41f75 91
bryantaylor 0:eafc3fd41f75 92 {
bryantaylor 0:eafc3fd41f75 93 "id": "ublox",
bryantaylor 0:eafc3fd41f75 94 "source_dir": [UBLOX_SOURCES, CELLULAR_SOURCES, CELLULAR_USB_SOURCES,
bryantaylor 0:eafc3fd41f75 95 LWIP_SOURCES],
bryantaylor 0:eafc3fd41f75 96 "build_dir": UBLOX_LIBRARY,
bryantaylor 0:eafc3fd41f75 97 "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, USB_HOST_LIBRARIES],
bryantaylor 0:eafc3fd41f75 98 },
bryantaylor 0:eafc3fd41f75 99
bryantaylor 0:eafc3fd41f75 100 # Unit Testing library
bryantaylor 0:eafc3fd41f75 101 {
bryantaylor 0:eafc3fd41f75 102 "id": "cpputest",
bryantaylor 0:eafc3fd41f75 103 "source_dir": [CPPUTEST_SRC, CPPUTEST_PLATFORM_SRC,
bryantaylor 0:eafc3fd41f75 104 CPPUTEST_TESTRUNNER_SCR],
bryantaylor 0:eafc3fd41f75 105 "build_dir": CPPUTEST_LIBRARY,
bryantaylor 0:eafc3fd41f75 106 "dependencies": [MBED_LIBRARIES],
bryantaylor 0:eafc3fd41f75 107 'inc_dirs': [CPPUTEST_INC, CPPUTEST_PLATFORM_INC,
bryantaylor 0:eafc3fd41f75 108 CPPUTEST_TESTRUNNER_INC, TEST_MBED_LIB],
bryantaylor 0:eafc3fd41f75 109 'inc_dirs_ext': [CPPUTEST_INC_EXT],
bryantaylor 0:eafc3fd41f75 110 'macros': ["CPPUTEST_USE_MEM_LEAK_DETECTION=0",
bryantaylor 0:eafc3fd41f75 111 "CPPUTEST_USE_STD_CPP_LIB=0", "CPPUTEST=1"],
bryantaylor 0:eafc3fd41f75 112 },
bryantaylor 0:eafc3fd41f75 113 ]
bryantaylor 0:eafc3fd41f75 114
bryantaylor 0:eafc3fd41f75 115
bryantaylor 0:eafc3fd41f75 116 LIBRARY_MAP = dict([(library['id'], library) for library in LIBRARIES])
bryantaylor 0:eafc3fd41f75 117
bryantaylor 0:eafc3fd41f75 118
bryantaylor 0:eafc3fd41f75 119 class Library(object):
bryantaylor 0:eafc3fd41f75 120 """A library representation that allows for querying of support"""
bryantaylor 0:eafc3fd41f75 121 def __init__(self, lib_id):
bryantaylor 0:eafc3fd41f75 122 lib = LIBRARY_MAP[lib_id]
bryantaylor 0:eafc3fd41f75 123 self.supported = lib.get("supported", DEFAULT_SUPPORT)
bryantaylor 0:eafc3fd41f75 124 self.dependencies = lib.get("dependencies", None)
bryantaylor 0:eafc3fd41f75 125 # Include dirs required by library build
bryantaylor 0:eafc3fd41f75 126 self.inc_dirs = lib.get("inc_dirs", None)
bryantaylor 0:eafc3fd41f75 127 # Include dirs required by others to use with this library
bryantaylor 0:eafc3fd41f75 128 self.inc_dirs_ext = lib.get("inc_dirs_ext", None)
bryantaylor 0:eafc3fd41f75 129 # Additional macros you want to define when building library
bryantaylor 0:eafc3fd41f75 130 self.macros = lib.get("macros", None)
bryantaylor 0:eafc3fd41f75 131
bryantaylor 0:eafc3fd41f75 132 self.source_dir = lib["source_dir"]
bryantaylor 0:eafc3fd41f75 133 self.build_dir = lib["build_dir"]
bryantaylor 0:eafc3fd41f75 134
bryantaylor 0:eafc3fd41f75 135 def is_supported(self, target, toolchain):
bryantaylor 0:eafc3fd41f75 136 """Check if a target toolchain combination is supported
bryantaylor 0:eafc3fd41f75 137
bryantaylor 0:eafc3fd41f75 138 Positional arguments:
bryantaylor 0:eafc3fd41f75 139 target - the MCU or board
bryantaylor 0:eafc3fd41f75 140 toolchain - the compiler
bryantaylor 0:eafc3fd41f75 141 """
bryantaylor 0:eafc3fd41f75 142 if not hasattr(self, 'supported'):
bryantaylor 0:eafc3fd41f75 143 return True
bryantaylor 0:eafc3fd41f75 144 return (target.name in self.supported) and \
bryantaylor 0:eafc3fd41f75 145 (toolchain in self.supported[target.name])