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 #! /usr/bin/env python2
group-onsemi 0:098463de4c5d 2 """
group-onsemi 0:098463de4c5d 3 mbed SDK
group-onsemi 0:098463de4c5d 4 Copyright (c) 2011-2013 ARM Limited
group-onsemi 0:098463de4c5d 5
group-onsemi 0:098463de4c5d 6 Licensed under the Apache License, Version 2.0 (the "License");
group-onsemi 0:098463de4c5d 7 you may not use this file except in compliance with the License.
group-onsemi 0:098463de4c5d 8 You may obtain a copy of the License at
group-onsemi 0:098463de4c5d 9
group-onsemi 0:098463de4c5d 10 http://www.apache.org/licenses/LICENSE-2.0
group-onsemi 0:098463de4c5d 11
group-onsemi 0:098463de4c5d 12 Unless required by applicable law or agreed to in writing, software
group-onsemi 0:098463de4c5d 13 distributed under the License is distributed on an "AS IS" BASIS,
group-onsemi 0:098463de4c5d 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
group-onsemi 0:098463de4c5d 15 See the License for the specific language governing permissions and
group-onsemi 0:098463de4c5d 16 limitations under the License.
group-onsemi 0:098463de4c5d 17
group-onsemi 0:098463de4c5d 18 """
group-onsemi 0:098463de4c5d 19 import sys
group-onsemi 0:098463de4c5d 20 from os.path import isdir, abspath, dirname, join
group-onsemi 0:098463de4c5d 21 from os import _exit
group-onsemi 0:098463de4c5d 22
group-onsemi 0:098463de4c5d 23 # Be sure that the tools directory is in the search path
group-onsemi 0:098463de4c5d 24 ROOT = abspath(join(dirname(__file__), ".."))
group-onsemi 0:098463de4c5d 25 sys.path.insert(0, ROOT)
group-onsemi 0:098463de4c5d 26
group-onsemi 0:098463de4c5d 27 from tools.utils import args_error
group-onsemi 0:098463de4c5d 28 from tools.options import get_default_options_parser
group-onsemi 0:098463de4c5d 29 from tools.build_api import get_config
group-onsemi 0:098463de4c5d 30 from config import Config
group-onsemi 0:098463de4c5d 31 from utils import argparse_filestring_type
group-onsemi 0:098463de4c5d 32 try:
group-onsemi 0:098463de4c5d 33 import tools.private_settings as ps
group-onsemi 0:098463de4c5d 34 except:
group-onsemi 0:098463de4c5d 35 ps = object()
group-onsemi 0:098463de4c5d 36
group-onsemi 0:098463de4c5d 37 if __name__ == '__main__':
group-onsemi 0:098463de4c5d 38 # Parse Options
group-onsemi 0:098463de4c5d 39 parser = get_default_options_parser(add_clean=False, add_options=False)
group-onsemi 0:098463de4c5d 40 parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type, required=True,
group-onsemi 0:098463de4c5d 41 default=[], help="The source (input) directory", action="append")
group-onsemi 0:098463de4c5d 42 parser.add_argument("--prefix", dest="prefix", action="append",
group-onsemi 0:098463de4c5d 43 default=[], help="Restrict listing to parameters that have this prefix")
group-onsemi 0:098463de4c5d 44 parser.add_argument("-v", "--verbose", action="store_true", dest="verbose",
group-onsemi 0:098463de4c5d 45 default=False, help="Verbose diagnostic output")
group-onsemi 0:098463de4c5d 46
group-onsemi 0:098463de4c5d 47 options = parser.parse_args()
group-onsemi 0:098463de4c5d 48
group-onsemi 0:098463de4c5d 49 # Target
group-onsemi 0:098463de4c5d 50 if options.mcu is None :
group-onsemi 0:098463de4c5d 51 args_error(parser, "argument -m/--mcu is required")
group-onsemi 0:098463de4c5d 52 target = options.mcu[0]
group-onsemi 0:098463de4c5d 53
group-onsemi 0:098463de4c5d 54 # Toolchain
group-onsemi 0:098463de4c5d 55 if options.tool is None:
group-onsemi 0:098463de4c5d 56 args_error(parser, "argument -t/--toolchain is required")
group-onsemi 0:098463de4c5d 57 toolchain = options.tool[0]
group-onsemi 0:098463de4c5d 58
group-onsemi 0:098463de4c5d 59 options.prefix = options.prefix or [""]
group-onsemi 0:098463de4c5d 60
group-onsemi 0:098463de4c5d 61 try:
group-onsemi 0:098463de4c5d 62 params, macros, features = get_config(options.source_dir, target, toolchain)
group-onsemi 0:098463de4c5d 63 if not params and not macros:
group-onsemi 0:098463de4c5d 64 print "No configuration data available."
group-onsemi 0:098463de4c5d 65 _exit(0)
group-onsemi 0:098463de4c5d 66 if params:
group-onsemi 0:098463de4c5d 67 print "Configuration parameters"
group-onsemi 0:098463de4c5d 68 print "------------------------"
group-onsemi 0:098463de4c5d 69 for p in params:
group-onsemi 0:098463de4c5d 70 for s in options.prefix:
group-onsemi 0:098463de4c5d 71 if p.startswith(s):
group-onsemi 0:098463de4c5d 72 print(str(params[p]) if not options.verbose else params[p].get_verbose_description())
group-onsemi 0:098463de4c5d 73 break
group-onsemi 0:098463de4c5d 74 print ""
group-onsemi 0:098463de4c5d 75
group-onsemi 0:098463de4c5d 76 print "Macros"
group-onsemi 0:098463de4c5d 77 print "------"
group-onsemi 0:098463de4c5d 78 if macros:
group-onsemi 0:098463de4c5d 79 print 'Defined with "macros":', Config.config_macros_to_macros(macros)
group-onsemi 0:098463de4c5d 80 print "Generated from configuration parameters:", Config.parameters_to_macros(params)
group-onsemi 0:098463de4c5d 81
group-onsemi 0:098463de4c5d 82 except KeyboardInterrupt, e:
group-onsemi 0:098463de4c5d 83 print "\n[CTRL+c] exit"
group-onsemi 0:098463de4c5d 84 except Exception,e:
group-onsemi 0:098463de4c5d 85 if options.verbose:
group-onsemi 0:098463de4c5d 86 import traceback
group-onsemi 0:098463de4c5d 87 traceback.print_exc(file=sys.stdout)
group-onsemi 0:098463de4c5d 88 else:
group-onsemi 0:098463de4c5d 89 print "[ERROR] %s" % str(e)
group-onsemi 0:098463de4c5d 90
group-onsemi 0:098463de4c5d 91 sys.exit(1)