takashi kadono
/
Nucleo446_SSD1331
Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466
mbed-os/tools/get_config.py@3:f3764f852aa8, 2018-10-11 (annotated)
- Committer:
- kadonotakashi
- Date:
- Thu Oct 11 02:27:46 2018 +0000
- Revision:
- 3:f3764f852aa8
- Parent:
- 0:8fdf9a60065b
Nucreo 446 + SSD1331 test version;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
kadonotakashi | 0:8fdf9a60065b | 1 | #! /usr/bin/env python2 |
kadonotakashi | 0:8fdf9a60065b | 2 | """ |
kadonotakashi | 0:8fdf9a60065b | 3 | mbed SDK |
kadonotakashi | 0:8fdf9a60065b | 4 | Copyright (c) 2011-2013 ARM Limited |
kadonotakashi | 0:8fdf9a60065b | 5 | |
kadonotakashi | 0:8fdf9a60065b | 6 | Licensed under the Apache License, Version 2.0 (the "License"); |
kadonotakashi | 0:8fdf9a60065b | 7 | you may not use this file except in compliance with the License. |
kadonotakashi | 0:8fdf9a60065b | 8 | You may obtain a copy of the License at |
kadonotakashi | 0:8fdf9a60065b | 9 | |
kadonotakashi | 0:8fdf9a60065b | 10 | http://www.apache.org/licenses/LICENSE-2.0 |
kadonotakashi | 0:8fdf9a60065b | 11 | |
kadonotakashi | 0:8fdf9a60065b | 12 | Unless required by applicable law or agreed to in writing, software |
kadonotakashi | 0:8fdf9a60065b | 13 | distributed under the License is distributed on an "AS IS" BASIS, |
kadonotakashi | 0:8fdf9a60065b | 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
kadonotakashi | 0:8fdf9a60065b | 15 | See the License for the specific language governing permissions and |
kadonotakashi | 0:8fdf9a60065b | 16 | limitations under the License. |
kadonotakashi | 0:8fdf9a60065b | 17 | |
kadonotakashi | 0:8fdf9a60065b | 18 | """ |
kadonotakashi | 0:8fdf9a60065b | 19 | from __future__ import print_function |
kadonotakashi | 0:8fdf9a60065b | 20 | import sys |
kadonotakashi | 0:8fdf9a60065b | 21 | from os.path import abspath, dirname, join |
kadonotakashi | 0:8fdf9a60065b | 22 | |
kadonotakashi | 0:8fdf9a60065b | 23 | # Be sure that the tools directory is in the search path |
kadonotakashi | 0:8fdf9a60065b | 24 | ROOT = abspath(join(dirname(__file__), "..")) |
kadonotakashi | 0:8fdf9a60065b | 25 | sys.path.insert(0, ROOT) |
kadonotakashi | 0:8fdf9a60065b | 26 | |
kadonotakashi | 0:8fdf9a60065b | 27 | from tools.utils import args_error |
kadonotakashi | 0:8fdf9a60065b | 28 | from tools.options import get_default_options_parser |
kadonotakashi | 0:8fdf9a60065b | 29 | from tools.options import extract_mcus |
kadonotakashi | 0:8fdf9a60065b | 30 | from tools.build_api import get_config |
kadonotakashi | 0:8fdf9a60065b | 31 | from tools.config import Config |
kadonotakashi | 0:8fdf9a60065b | 32 | from tools.utils import argparse_filestring_type |
kadonotakashi | 0:8fdf9a60065b | 33 | |
kadonotakashi | 0:8fdf9a60065b | 34 | if __name__ == '__main__': |
kadonotakashi | 0:8fdf9a60065b | 35 | # Parse Options |
kadonotakashi | 0:8fdf9a60065b | 36 | parser = get_default_options_parser(add_clean=False, add_options=False, |
kadonotakashi | 0:8fdf9a60065b | 37 | add_app_config=True) |
kadonotakashi | 0:8fdf9a60065b | 38 | parser.add_argument( |
kadonotakashi | 0:8fdf9a60065b | 39 | "--source", dest="source_dir", type=argparse_filestring_type, |
kadonotakashi | 0:8fdf9a60065b | 40 | required=True, default=[], help="The source (input) directory", |
kadonotakashi | 0:8fdf9a60065b | 41 | action="append") |
kadonotakashi | 0:8fdf9a60065b | 42 | parser.add_argument( |
kadonotakashi | 0:8fdf9a60065b | 43 | "--prefix", dest="prefix", action="append", default=[], |
kadonotakashi | 0:8fdf9a60065b | 44 | help="Restrict listing to parameters that have this prefix") |
kadonotakashi | 0:8fdf9a60065b | 45 | parser.add_argument( |
kadonotakashi | 0:8fdf9a60065b | 46 | "-v", "--verbose", action="store_true", dest="verbose", default=False, |
kadonotakashi | 0:8fdf9a60065b | 47 | help="Verbose diagnostic output") |
kadonotakashi | 0:8fdf9a60065b | 48 | |
kadonotakashi | 0:8fdf9a60065b | 49 | options = parser.parse_args() |
kadonotakashi | 0:8fdf9a60065b | 50 | |
kadonotakashi | 0:8fdf9a60065b | 51 | # Target |
kadonotakashi | 0:8fdf9a60065b | 52 | if options.mcu is None : |
kadonotakashi | 0:8fdf9a60065b | 53 | args_error(parser, "argument -m/--mcu is required") |
kadonotakashi | 0:8fdf9a60065b | 54 | target = extract_mcus(parser, options)[0] |
kadonotakashi | 0:8fdf9a60065b | 55 | |
kadonotakashi | 0:8fdf9a60065b | 56 | options.prefix = options.prefix or [""] |
kadonotakashi | 0:8fdf9a60065b | 57 | |
kadonotakashi | 0:8fdf9a60065b | 58 | try: |
kadonotakashi | 0:8fdf9a60065b | 59 | params, macros, features = get_config( |
kadonotakashi | 0:8fdf9a60065b | 60 | options.source_dir, |
kadonotakashi | 0:8fdf9a60065b | 61 | target, |
kadonotakashi | 0:8fdf9a60065b | 62 | options.tool[0] if options.tool else None, |
kadonotakashi | 0:8fdf9a60065b | 63 | app_config=options.app_config |
kadonotakashi | 0:8fdf9a60065b | 64 | ) |
kadonotakashi | 0:8fdf9a60065b | 65 | if not params and not macros: |
kadonotakashi | 0:8fdf9a60065b | 66 | print("No configuration data available.") |
kadonotakashi | 0:8fdf9a60065b | 67 | sys.exit(0) |
kadonotakashi | 0:8fdf9a60065b | 68 | if params: |
kadonotakashi | 0:8fdf9a60065b | 69 | print("Configuration parameters") |
kadonotakashi | 0:8fdf9a60065b | 70 | print("------------------------") |
kadonotakashi | 0:8fdf9a60065b | 71 | for p in sorted(list(params.keys())): |
kadonotakashi | 0:8fdf9a60065b | 72 | if any(p.startswith(s) for s in options.prefix): |
kadonotakashi | 0:8fdf9a60065b | 73 | if options.verbose: |
kadonotakashi | 0:8fdf9a60065b | 74 | print(params[p].get_verbose_description()) |
kadonotakashi | 0:8fdf9a60065b | 75 | else: |
kadonotakashi | 0:8fdf9a60065b | 76 | print(str(params[p])) |
kadonotakashi | 0:8fdf9a60065b | 77 | print("") |
kadonotakashi | 0:8fdf9a60065b | 78 | |
kadonotakashi | 0:8fdf9a60065b | 79 | print("Macros") |
kadonotakashi | 0:8fdf9a60065b | 80 | print("------") |
kadonotakashi | 0:8fdf9a60065b | 81 | for m in Config.config_macros_to_macros(macros): |
kadonotakashi | 0:8fdf9a60065b | 82 | if any(m.startswith(s) for s in options.prefix): |
kadonotakashi | 0:8fdf9a60065b | 83 | print(m) |
kadonotakashi | 0:8fdf9a60065b | 84 | |
kadonotakashi | 0:8fdf9a60065b | 85 | except KeyboardInterrupt as e: |
kadonotakashi | 0:8fdf9a60065b | 86 | print("\n[CTRL+c] exit") |
kadonotakashi | 0:8fdf9a60065b | 87 | except Exception as e: |
kadonotakashi | 0:8fdf9a60065b | 88 | if options.verbose: |
kadonotakashi | 0:8fdf9a60065b | 89 | import traceback |
kadonotakashi | 0:8fdf9a60065b | 90 | traceback.print_exc(file=sys.stdout) |
kadonotakashi | 0:8fdf9a60065b | 91 | else: |
kadonotakashi | 0:8fdf9a60065b | 92 | print("[ERROR] %s" % str(e)) |
kadonotakashi | 0:8fdf9a60065b | 93 | |
kadonotakashi | 0:8fdf9a60065b | 94 | sys.exit(1) |