Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Dec 16 16:27:57 2016 +0000
Revision:
3:1198227e6421
Parent:
0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms

Who changed what in which revision?

UserRevisionLine numberNew contents of line
switches 0:5c4d7b2438d3 1 """
switches 0:5c4d7b2438d3 2 mbed SDK
switches 0:5c4d7b2438d3 3 Copyright (c) 2011-2016 ARM Limited
switches 0:5c4d7b2438d3 4
switches 0:5c4d7b2438d3 5 Licensed under the Apache License, Version 2.0 (the "License");
switches 0:5c4d7b2438d3 6 you may not use this file except in compliance with the License.
switches 0:5c4d7b2438d3 7 You may obtain a copy of the License at
switches 0:5c4d7b2438d3 8
switches 0:5c4d7b2438d3 9 http://www.apache.org/licenses/LICENSE-2.0
switches 0:5c4d7b2438d3 10
switches 0:5c4d7b2438d3 11 Unless required by applicable law or agreed to in writing, software
switches 0:5c4d7b2438d3 12 distributed under the License is distributed on an "AS IS" BASIS,
switches 0:5c4d7b2438d3 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
switches 0:5c4d7b2438d3 14 See the License for the specific language governing permissions and
switches 0:5c4d7b2438d3 15 limitations under the License.
switches 0:5c4d7b2438d3 16 """
switches 0:5c4d7b2438d3 17
switches 0:5c4d7b2438d3 18 from tools.build_api import get_config
switches 0:5c4d7b2438d3 19 from tools.targets import set_targets_json_location, Target
switches 0:5c4d7b2438d3 20 from tools.config import ConfigException, Config
switches 0:5c4d7b2438d3 21 import os, sys
switches 0:5c4d7b2438d3 22
switches 0:5c4d7b2438d3 23 # Compare the output of config against a dictionary of known good results
switches 0:5c4d7b2438d3 24 def compare_config(cfg, expected):
switches 0:5c4d7b2438d3 25 try:
switches 0:5c4d7b2438d3 26 for k in cfg:
switches 0:5c4d7b2438d3 27 if cfg[k].value != expected[k]:
switches 0:5c4d7b2438d3 28 return "'%s': expected '%s', got '%s'" % (k, expected[k], cfg[k].value)
switches 0:5c4d7b2438d3 29 except KeyError:
switches 0:5c4d7b2438d3 30 raise
switches 0:5c4d7b2438d3 31 return "Unexpected key '%s' in configuration data" % k
switches 0:5c4d7b2438d3 32 for k in expected:
switches 0:5c4d7b2438d3 33 if k not in ["desc", "expected_macros", "expected_features"] + cfg.keys():
switches 0:5c4d7b2438d3 34 return "Expected key '%s' was not found in configuration data" % k
switches 0:5c4d7b2438d3 35 return ""
switches 0:5c4d7b2438d3 36
switches 0:5c4d7b2438d3 37 def test_tree(full_name, name):
switches 0:5c4d7b2438d3 38 failed = 0
switches 0:5c4d7b2438d3 39 sys.path.append(full_name)
switches 0:5c4d7b2438d3 40 if "test_data" in sys.modules:
switches 0:5c4d7b2438d3 41 del sys.modules["test_data"]
switches 0:5c4d7b2438d3 42 import test_data
switches 0:5c4d7b2438d3 43 # If the test defines custom targets, they must exist in a file called
switches 0:5c4d7b2438d3 44 # "targets.json" in the test's directory.
switches 0:5c4d7b2438d3 45 if os.path.isfile(os.path.join(full_name, "targets.json")):
switches 0:5c4d7b2438d3 46 set_targets_json_location(os.path.join(full_name, "targets.json"))
switches 0:5c4d7b2438d3 47 else: # uset the regular set of targets
switches 0:5c4d7b2438d3 48 set_targets_json_location()
switches 0:5c4d7b2438d3 49 for target, expected in test_data.expected_results.items():
switches 0:5c4d7b2438d3 50 sys.stdout.write("%s:'%s'(%s) " % (name, expected["desc"], target))
switches 0:5c4d7b2438d3 51 sys.stdout.flush()
switches 0:5c4d7b2438d3 52 err_msg = None
switches 0:5c4d7b2438d3 53 try:
switches 0:5c4d7b2438d3 54 cfg, macros, features = get_config(full_name, target, "GCC_ARM")
switches 0:5c4d7b2438d3 55 macros = Config.config_macros_to_macros(macros)
switches 0:5c4d7b2438d3 56 except ConfigException as e:
switches 0:5c4d7b2438d3 57 err_msg = e.message
switches 0:5c4d7b2438d3 58 if err_msg:
switches 0:5c4d7b2438d3 59 if expected.has_key("exception_msg"):
switches 0:5c4d7b2438d3 60 if err_msg.find(expected["exception_msg"]) == -1:
switches 0:5c4d7b2438d3 61 print "FAILED!"
switches 0:5c4d7b2438d3 62 sys.stderr.write(" Unexpected error message!\n")
switches 0:5c4d7b2438d3 63 sys.stderr.write(" Expected: '%s'\n" % expected["exception_msg"])
switches 0:5c4d7b2438d3 64 sys.stderr.write(" Got: '%s'\n" % err_msg)
switches 0:5c4d7b2438d3 65 failed += 1
switches 0:5c4d7b2438d3 66 else:
switches 0:5c4d7b2438d3 67 print "OK"
switches 0:5c4d7b2438d3 68 else:
switches 0:5c4d7b2438d3 69 print "FAILED!"
switches 0:5c4d7b2438d3 70 sys.stderr.write(" Error while getting configuration!\n")
switches 0:5c4d7b2438d3 71 sys.stderr.write(" " + err_msg + "\n")
switches 0:5c4d7b2438d3 72 failed += 1
switches 0:5c4d7b2438d3 73 else:
switches 0:5c4d7b2438d3 74 res = compare_config(cfg, expected)
switches 0:5c4d7b2438d3 75 expected_macros = expected.get("expected_macros", None)
switches 0:5c4d7b2438d3 76 expected_features = expected.get("expected_features", None)
switches 0:5c4d7b2438d3 77
switches 0:5c4d7b2438d3 78 if res:
switches 0:5c4d7b2438d3 79 print "FAILED!"
switches 0:5c4d7b2438d3 80 sys.stdout.write(" " + res + "\n")
switches 0:5c4d7b2438d3 81 failed += 1
switches 0:5c4d7b2438d3 82 elif expected_macros is not None:
switches 0:5c4d7b2438d3 83 if sorted(expected_macros) != sorted(macros):
switches 0:5c4d7b2438d3 84 print "FAILED!"
switches 0:5c4d7b2438d3 85 sys.stderr.write(" List of macros doesn't match\n")
switches 0:5c4d7b2438d3 86 sys.stderr.write(" Expected: '%s'\n" % ",".join(sorted(expected_macros)))
switches 0:5c4d7b2438d3 87 sys.stderr.write(" Got: '%s'\n" % ",".join(sorted(expected_macros)))
switches 0:5c4d7b2438d3 88 failed += 1
switches 0:5c4d7b2438d3 89 else:
switches 0:5c4d7b2438d3 90 print "OK"
switches 0:5c4d7b2438d3 91 elif expected_features is not None:
switches 0:5c4d7b2438d3 92 if sorted(expected_features) != sorted(features):
switches 0:5c4d7b2438d3 93 print "FAILED!"
switches 0:5c4d7b2438d3 94 sys.stderr.write(" List of features doesn't match\n")
switches 0:5c4d7b2438d3 95 sys.stderr.write(" Expected: '%s'\n" % ",".join(sorted(expected_features)))
switches 0:5c4d7b2438d3 96 sys.stderr.write(" Got: '%s'\n" % ",".join(sorted(expected_features)))
switches 0:5c4d7b2438d3 97 failed += 1
switches 0:5c4d7b2438d3 98 else:
switches 0:5c4d7b2438d3 99 print "OK"
switches 0:5c4d7b2438d3 100 else:
switches 0:5c4d7b2438d3 101 print "OK"
switches 0:5c4d7b2438d3 102 sys.path.remove(full_name)
switches 0:5c4d7b2438d3 103 return failed
switches 0:5c4d7b2438d3 104
switches 0:5c4d7b2438d3 105 failed = 0
switches 0:5c4d7b2438d3 106 root_dir = os.path.abspath(os.path.dirname(__file__))
switches 0:5c4d7b2438d3 107 tlist = sorted(os.listdir(root_dir), key = lambda e: int(e[4:]) if e.startswith('test') else -1)
switches 0:5c4d7b2438d3 108 for test_name in tlist:
switches 0:5c4d7b2438d3 109 full_name = os.path.join(root_dir, test_name)
switches 0:5c4d7b2438d3 110 if os.path.isdir(full_name) and test_name.startswith('test'):
switches 0:5c4d7b2438d3 111 failed += test_tree(full_name, test_name)
switches 0:5c4d7b2438d3 112 sys.exit(failed)
switches 0:5c4d7b2438d3 113