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