5.2.1 - Updated I2C files
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
tools/options.py@1:f30bdcd2b33b, 2017-02-27 (annotated)
- Committer:
- jacobjohnson
- Date:
- Mon Feb 27 17:45:05 2017 +0000
- Revision:
- 1:f30bdcd2b33b
- Parent:
- 0:098463de4c5d
changed the inputscale from 1 to 7 in analogin_api.c. This will need to be changed later, and accessed from the main level, but for now this allows the adc to read a value from 0 to 3.7V, instead of just up to 1V.;
Who changed what in which revision?
User | Revision | Line number | New 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 json import load |
group-onsemi | 0:098463de4c5d | 18 | from os.path import join, dirname |
group-onsemi | 0:098463de4c5d | 19 | from os import listdir |
group-onsemi | 0:098463de4c5d | 20 | from argparse import ArgumentParser |
group-onsemi | 0:098463de4c5d | 21 | from tools.toolchains import TOOLCHAINS |
group-onsemi | 0:098463de4c5d | 22 | from tools.targets import TARGET_NAMES |
group-onsemi | 0:098463de4c5d | 23 | from tools.utils import argparse_force_uppercase_type, \ |
group-onsemi | 0:098463de4c5d | 24 | argparse_lowercase_hyphen_type, argparse_many, \ |
group-onsemi | 0:098463de4c5d | 25 | argparse_filestring_type, args_error, argparse_profile_filestring_type,\ |
group-onsemi | 0:098463de4c5d | 26 | argparse_deprecate |
group-onsemi | 0:098463de4c5d | 27 | |
group-onsemi | 0:098463de4c5d | 28 | FLAGS_DEPRECATION_MESSAGE = "Please use the --profile argument instead.\n"\ |
group-onsemi | 0:098463de4c5d | 29 | "Documentation may be found in "\ |
group-onsemi | 0:098463de4c5d | 30 | "docs/Toolchain_Profiles.md" |
group-onsemi | 0:098463de4c5d | 31 | |
group-onsemi | 0:098463de4c5d | 32 | def get_default_options_parser(add_clean=True, add_options=True, |
group-onsemi | 0:098463de4c5d | 33 | add_app_config=False): |
group-onsemi | 0:098463de4c5d | 34 | """Create a new options parser with the default compiler options added |
group-onsemi | 0:098463de4c5d | 35 | |
group-onsemi | 0:098463de4c5d | 36 | Keyword arguments: |
group-onsemi | 0:098463de4c5d | 37 | add_clean - add the clean argument? |
group-onsemi | 0:098463de4c5d | 38 | add_options - add the options argument? |
group-onsemi | 0:098463de4c5d | 39 | """ |
group-onsemi | 0:098463de4c5d | 40 | parser = ArgumentParser() |
group-onsemi | 0:098463de4c5d | 41 | |
group-onsemi | 0:098463de4c5d | 42 | targetnames = TARGET_NAMES |
group-onsemi | 0:098463de4c5d | 43 | targetnames.sort() |
group-onsemi | 0:098463de4c5d | 44 | toolchainlist = list(TOOLCHAINS) |
group-onsemi | 0:098463de4c5d | 45 | toolchainlist.sort() |
group-onsemi | 0:098463de4c5d | 46 | |
group-onsemi | 0:098463de4c5d | 47 | parser.add_argument("-m", "--mcu", |
group-onsemi | 0:098463de4c5d | 48 | help=("build for the given MCU (%s)" % |
group-onsemi | 0:098463de4c5d | 49 | ', '.join(targetnames)), |
group-onsemi | 0:098463de4c5d | 50 | metavar="MCU", |
group-onsemi | 0:098463de4c5d | 51 | type=argparse_many( |
group-onsemi | 0:098463de4c5d | 52 | argparse_force_uppercase_type( |
group-onsemi | 0:098463de4c5d | 53 | targetnames, "MCU"))) |
group-onsemi | 0:098463de4c5d | 54 | |
group-onsemi | 0:098463de4c5d | 55 | parser.add_argument("-t", "--tool", |
group-onsemi | 0:098463de4c5d | 56 | help=("build using the given TOOLCHAIN (%s)" % |
group-onsemi | 0:098463de4c5d | 57 | ', '.join(toolchainlist)), |
group-onsemi | 0:098463de4c5d | 58 | metavar="TOOLCHAIN", |
group-onsemi | 0:098463de4c5d | 59 | type=argparse_many( |
group-onsemi | 0:098463de4c5d | 60 | argparse_force_uppercase_type( |
group-onsemi | 0:098463de4c5d | 61 | toolchainlist, "toolchain"))) |
group-onsemi | 0:098463de4c5d | 62 | |
group-onsemi | 0:098463de4c5d | 63 | parser.add_argument("--color", |
group-onsemi | 0:098463de4c5d | 64 | help="print Warnings, and Errors in color", |
group-onsemi | 0:098463de4c5d | 65 | action="store_true", default=False) |
group-onsemi | 0:098463de4c5d | 66 | |
group-onsemi | 0:098463de4c5d | 67 | parser.add_argument("--cflags", |
group-onsemi | 0:098463de4c5d | 68 | type=argparse_deprecate(FLAGS_DEPRECATION_MESSAGE), |
group-onsemi | 0:098463de4c5d | 69 | help="Deprecated. " + FLAGS_DEPRECATION_MESSAGE) |
group-onsemi | 0:098463de4c5d | 70 | |
group-onsemi | 0:098463de4c5d | 71 | parser.add_argument("--asmflags", |
group-onsemi | 0:098463de4c5d | 72 | type=argparse_deprecate(FLAGS_DEPRECATION_MESSAGE), |
group-onsemi | 0:098463de4c5d | 73 | help="Deprecated. " + FLAGS_DEPRECATION_MESSAGE) |
group-onsemi | 0:098463de4c5d | 74 | |
group-onsemi | 0:098463de4c5d | 75 | parser.add_argument("--ldflags", |
group-onsemi | 0:098463de4c5d | 76 | type=argparse_deprecate(FLAGS_DEPRECATION_MESSAGE), |
group-onsemi | 0:098463de4c5d | 77 | help="Deprecated. " + FLAGS_DEPRECATION_MESSAGE) |
group-onsemi | 0:098463de4c5d | 78 | |
group-onsemi | 0:098463de4c5d | 79 | if add_clean: |
group-onsemi | 0:098463de4c5d | 80 | parser.add_argument("-c", "--clean", action="store_true", default=False, |
group-onsemi | 0:098463de4c5d | 81 | help="clean the build directory") |
group-onsemi | 0:098463de4c5d | 82 | |
group-onsemi | 0:098463de4c5d | 83 | if add_options: |
group-onsemi | 0:098463de4c5d | 84 | parser.add_argument("--profile", dest="profile", action="append", |
group-onsemi | 0:098463de4c5d | 85 | type=argparse_profile_filestring_type, |
group-onsemi | 0:098463de4c5d | 86 | help="Build profile to use. Can be either path to json" \ |
group-onsemi | 0:098463de4c5d | 87 | "file or one of the default one ({})".format(", ".join(list_profiles())), |
group-onsemi | 0:098463de4c5d | 88 | default=[]) |
group-onsemi | 0:098463de4c5d | 89 | if add_app_config: |
group-onsemi | 0:098463de4c5d | 90 | parser.add_argument("--app-config", default=None, dest="app_config", |
group-onsemi | 0:098463de4c5d | 91 | type=argparse_filestring_type, |
group-onsemi | 0:098463de4c5d | 92 | help="Path of an app configuration file (Default is to look for 'mbed_app.json')") |
group-onsemi | 0:098463de4c5d | 93 | |
group-onsemi | 0:098463de4c5d | 94 | return parser |
group-onsemi | 0:098463de4c5d | 95 | |
group-onsemi | 0:098463de4c5d | 96 | def list_profiles(): |
group-onsemi | 0:098463de4c5d | 97 | """Lists available build profiles |
group-onsemi | 0:098463de4c5d | 98 | |
group-onsemi | 0:098463de4c5d | 99 | Checks default profile directory (mbed-os/tools/profiles/) for all the json files and return list of names only |
group-onsemi | 0:098463de4c5d | 100 | """ |
group-onsemi | 0:098463de4c5d | 101 | return [fn.replace(".json", "") for fn in listdir(join(dirname(__file__), "profiles")) if fn.endswith(".json")] |
group-onsemi | 0:098463de4c5d | 102 | |
group-onsemi | 0:098463de4c5d | 103 | def extract_profile(parser, options, toolchain, fallback="default"): |
group-onsemi | 0:098463de4c5d | 104 | """Extract a Toolchain profile from parsed options |
group-onsemi | 0:098463de4c5d | 105 | |
group-onsemi | 0:098463de4c5d | 106 | Positional arguments: |
group-onsemi | 0:098463de4c5d | 107 | parser - parser used to parse the command line arguments |
group-onsemi | 0:098463de4c5d | 108 | options - The parsed command line arguments |
group-onsemi | 0:098463de4c5d | 109 | toolchain - the toolchain that the profile should be extracted for |
group-onsemi | 0:098463de4c5d | 110 | """ |
group-onsemi | 0:098463de4c5d | 111 | profile = {'c': [], 'cxx': [], 'ld': [], 'common': [], 'asm': []} |
group-onsemi | 0:098463de4c5d | 112 | filenames = options.profile or [join(dirname(__file__), "profiles", |
group-onsemi | 0:098463de4c5d | 113 | fallback + ".json")] |
group-onsemi | 0:098463de4c5d | 114 | for filename in filenames: |
group-onsemi | 0:098463de4c5d | 115 | contents = load(open(filename)) |
group-onsemi | 0:098463de4c5d | 116 | try: |
group-onsemi | 0:098463de4c5d | 117 | for key in profile.iterkeys(): |
group-onsemi | 0:098463de4c5d | 118 | profile[key] += contents[toolchain][key] |
group-onsemi | 0:098463de4c5d | 119 | except KeyError: |
group-onsemi | 0:098463de4c5d | 120 | args_error(parser, ("argument --profile: toolchain {} is not" |
group-onsemi | 0:098463de4c5d | 121 | " supported by profile {}").format(toolchain, |
group-onsemi | 0:098463de4c5d | 122 | filename)) |
group-onsemi | 0:098463de4c5d | 123 | return profile |