5.2.1 - Updated I2C files

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Committer:
group-onsemi
Date:
Wed Jan 25 20:34:15 2017 +0000
Revision:
0:098463de4c5d
Initial commit

Who changed what in which revision?

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