Development mbed library for MAX32630FTHR

Dependents:   blinky_max32630fthr

Committer:
switches
Date:
Fri Nov 11 20:59:50 2016 +0000
Revision:
0:5c4d7b2438d3
Initial commit

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-2015 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 Author: Przemyslaw Wirkus <Przemyslaw.Wirkus@arm.com>
switches 0:5c4d7b2438d3 18
switches 0:5c4d7b2438d3 19 """
switches 0:5c4d7b2438d3 20
switches 0:5c4d7b2438d3 21 from ioper_base import IOperTestCaseBase
switches 0:5c4d7b2438d3 22
switches 0:5c4d7b2438d3 23
switches 0:5c4d7b2438d3 24 class IOperTest_TargetID(IOperTestCaseBase):
switches 0:5c4d7b2438d3 25 """ tests related to target_id value
switches 0:5c4d7b2438d3 26 """
switches 0:5c4d7b2438d3 27
switches 0:5c4d7b2438d3 28 def __init__(self, scope=None):
switches 0:5c4d7b2438d3 29 IOperTestCaseBase.__init__(self, scope)
switches 0:5c4d7b2438d3 30 self.TARGET_ID_LEN = 24
switches 0:5c4d7b2438d3 31
switches 0:5c4d7b2438d3 32 def test_target_id_format(self, target_id, target_id_name):
switches 0:5c4d7b2438d3 33 # Expected length == 24, eg. "02400203D94B0E7724B7F3CF"
switches 0:5c4d7b2438d3 34 result = []
switches 0:5c4d7b2438d3 35 target_id_len = len(target_id) if target_id else 0
switches 0:5c4d7b2438d3 36 if target_id_len == self.TARGET_ID_LEN:
switches 0:5c4d7b2438d3 37 result.append((self.PASS, "TARGET_ID_LEN", self.scope, "%s '%s' is %d chars long " % (target_id_name, target_id, target_id_len)))
switches 0:5c4d7b2438d3 38 result.append((self.INFO, "FW_VER_STR", self.scope, "%s Version String is %s.%s.%s " % (target_id_name,
switches 0:5c4d7b2438d3 39 target_id[0:4],
switches 0:5c4d7b2438d3 40 target_id[4:8],
switches 0:5c4d7b2438d3 41 target_id[8:24],
switches 0:5c4d7b2438d3 42 )))
switches 0:5c4d7b2438d3 43 else:
switches 0:5c4d7b2438d3 44 result.append((self.ERROR, "TARGET_ID_LEN", self.scope, "%s '%s' is %d chars long. Expected %d chars" % (target_id_name, target_id, target_id_len, self.TARGET_ID_LEN)))
switches 0:5c4d7b2438d3 45 return result
switches 0:5c4d7b2438d3 46
switches 0:5c4d7b2438d3 47 def test_decode_target_id(self, target_id, target_id_name):
switches 0:5c4d7b2438d3 48 result = []
switches 0:5c4d7b2438d3 49 target_id_len = len(target_id) if target_id else 0
switches 0:5c4d7b2438d3 50 if target_id_len >= 4:
switches 0:5c4d7b2438d3 51 result.append((self.INFO, "FW_VEN_CODE", self.scope, "%s Vendor Code is '%s'" % (target_id_name, target_id[0:2])))
switches 0:5c4d7b2438d3 52 result.append((self.INFO, "FW_PLAT_CODE", self.scope, "%s Platform Code is '%s'" % (target_id_name, target_id[2:4])))
switches 0:5c4d7b2438d3 53 result.append((self.INFO, "FW_VER", self.scope, "%s Firmware Version is '%s'" % (target_id_name, target_id[4:8])))
switches 0:5c4d7b2438d3 54 result.append((self.INFO, "FW_HASH_SEC", self.scope, "%s Hash of secret is '%s'" % (target_id_name, target_id[8:24])))
switches 0:5c4d7b2438d3 55 return result
switches 0:5c4d7b2438d3 56
switches 0:5c4d7b2438d3 57 def test(self, param=None):
switches 0:5c4d7b2438d3 58 result = []
switches 0:5c4d7b2438d3 59 if param:
switches 0:5c4d7b2438d3 60 pass
switches 0:5c4d7b2438d3 61 return result
switches 0:5c4d7b2438d3 62
switches 0:5c4d7b2438d3 63
switches 0:5c4d7b2438d3 64 class IOperTest_TargetID_Basic(IOperTest_TargetID):
switches 0:5c4d7b2438d3 65 """ Basic interoperability tests checking TargetID compliance
switches 0:5c4d7b2438d3 66 """
switches 0:5c4d7b2438d3 67
switches 0:5c4d7b2438d3 68 def __init__(self, scope=None):
switches 0:5c4d7b2438d3 69 IOperTest_TargetID.__init__(self, scope)
switches 0:5c4d7b2438d3 70
switches 0:5c4d7b2438d3 71 def test(self, param=None):
switches 0:5c4d7b2438d3 72 result = []
switches 0:5c4d7b2438d3 73
switches 0:5c4d7b2438d3 74 if param:
switches 0:5c4d7b2438d3 75 result.append((self.PASS, "TARGET_ID", self.scope, "TargetID '%s' found" % param['target_id']))
switches 0:5c4d7b2438d3 76
switches 0:5c4d7b2438d3 77 # Check if target name can be decoded with mbed-ls
switches 0:5c4d7b2438d3 78 if param['platform_name']:
switches 0:5c4d7b2438d3 79 result.append((self.PASS, "TARGET_ID_DECODE", self.scope, "TargetID '%s' decoded as '%s'" % (param['target_id'][0:4], param['platform_name'])))
switches 0:5c4d7b2438d3 80 else:
switches 0:5c4d7b2438d3 81 result.append((self.ERROR, "TARGET_ID_DECODE", self.scope, "TargetID '%s'... not decoded" % (param['target_id'] if param['target_id'] else '')))
switches 0:5c4d7b2438d3 82
switches 0:5c4d7b2438d3 83 # Test for USBID and mbed.htm consistency
switches 0:5c4d7b2438d3 84 if param['target_id_mbed_htm'] == param['target_id_usb_id']:
switches 0:5c4d7b2438d3 85 result.append((self.PASS, "TARGET_ID_MATCH", self.scope, "TargetID (USBID) and TargetID (mbed.htm) match"))
switches 0:5c4d7b2438d3 86 else:
switches 0:5c4d7b2438d3 87 text = "TargetID (USBID) and TargetID (mbed.htm) don't match: '%s' != '%s'" % (param['target_id_usb_id'], param['target_id_mbed_htm'])
switches 0:5c4d7b2438d3 88 result.append((self.WARN, "TARGET_ID_MATCH", self.scope, text))
switches 0:5c4d7b2438d3 89 else:
switches 0:5c4d7b2438d3 90 result.append((self.ERROR, "TARGET_ID", self.scope, "TargetID not found"))
switches 0:5c4d7b2438d3 91 return result
switches 0:5c4d7b2438d3 92
switches 0:5c4d7b2438d3 93 class IOperTest_TargetID_MbedEnabled(IOperTest_TargetID):
switches 0:5c4d7b2438d3 94 """ Basic interoperability tests checking TargetID compliance
switches 0:5c4d7b2438d3 95 """
switches 0:5c4d7b2438d3 96
switches 0:5c4d7b2438d3 97 def __init__(self, scope=None):
switches 0:5c4d7b2438d3 98 IOperTest_TargetID.__init__(self, scope)
switches 0:5c4d7b2438d3 99
switches 0:5c4d7b2438d3 100 def test(self, param=None):
switches 0:5c4d7b2438d3 101 result = []
switches 0:5c4d7b2438d3 102
switches 0:5c4d7b2438d3 103 if param:
switches 0:5c4d7b2438d3 104 # Target ID tests:
switches 0:5c4d7b2438d3 105 result += self.test_target_id_format(param['target_id_usb_id'], "TargetId (USBID)")
switches 0:5c4d7b2438d3 106 result += self.test_target_id_format(param['target_id_mbed_htm'], "TargetId (mbed.htm)")
switches 0:5c4d7b2438d3 107
switches 0:5c4d7b2438d3 108 # Some extra info about TargetID itself
switches 0:5c4d7b2438d3 109 result += self.test_decode_target_id(param['target_id_usb_id'], "TargetId (USBID)")
switches 0:5c4d7b2438d3 110 result += self.test_decode_target_id(param['target_id_mbed_htm'], "TargetId (mbed.htm)")
switches 0:5c4d7b2438d3 111 return result