Color Oled(SSD1331) connect to STMicroelectronics Nucleo-F466

Dependencies:   ssd1331

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?

UserRevisionLine numberNew 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 from __future__ import print_function
kadonotakashi 0:8fdf9a60065b 19 import sys
kadonotakashi 0:8fdf9a60065b 20 import os
kadonotakashi 0:8fdf9a60065b 21 import re
kadonotakashi 0:8fdf9a60065b 22
kadonotakashi 0:8fdf9a60065b 23 ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
kadonotakashi 0:8fdf9a60065b 24 sys.path.insert(0, ROOT)
kadonotakashi 0:8fdf9a60065b 25
kadonotakashi 0:8fdf9a60065b 26 from tools.options import get_default_options_parser
kadonotakashi 0:8fdf9a60065b 27
kadonotakashi 0:8fdf9a60065b 28 # Check: Extra modules which are required by core test suite
kadonotakashi 0:8fdf9a60065b 29 from tools.utils import check_required_modules
kadonotakashi 0:8fdf9a60065b 30 check_required_modules(['prettytable'])
kadonotakashi 0:8fdf9a60065b 31
kadonotakashi 0:8fdf9a60065b 32 # Imports related to mbed build api
kadonotakashi 0:8fdf9a60065b 33 from tools.build_api import mcu_toolchain_matrix
kadonotakashi 0:8fdf9a60065b 34 from tools.test_api import get_autodetected_MUTS_list
kadonotakashi 0:8fdf9a60065b 35 from tools.test_api import get_module_avail
kadonotakashi 0:8fdf9a60065b 36 from argparse import ArgumentParser
kadonotakashi 0:8fdf9a60065b 37
kadonotakashi 0:8fdf9a60065b 38 try:
kadonotakashi 0:8fdf9a60065b 39 import mbed_lstools
kadonotakashi 0:8fdf9a60065b 40 except:
kadonotakashi 0:8fdf9a60065b 41 pass
kadonotakashi 0:8fdf9a60065b 42
kadonotakashi 0:8fdf9a60065b 43 def main():
kadonotakashi 0:8fdf9a60065b 44 """Entry Point"""
kadonotakashi 0:8fdf9a60065b 45 try:
kadonotakashi 0:8fdf9a60065b 46 # Parse Options
kadonotakashi 0:8fdf9a60065b 47 parser = ArgumentParser()
kadonotakashi 0:8fdf9a60065b 48
kadonotakashi 0:8fdf9a60065b 49 parser.add_argument("-S", "--supported-toolchains",
kadonotakashi 0:8fdf9a60065b 50 action="store_true",
kadonotakashi 0:8fdf9a60065b 51 dest="supported_toolchains",
kadonotakashi 0:8fdf9a60065b 52 default=False,
kadonotakashi 0:8fdf9a60065b 53 help="Displays supported matrix of"
kadonotakashi 0:8fdf9a60065b 54 " targets and toolchains")
kadonotakashi 0:8fdf9a60065b 55
kadonotakashi 0:8fdf9a60065b 56 parser.add_argument('-f', '--filter',
kadonotakashi 0:8fdf9a60065b 57 dest='general_filter_regex',
kadonotakashi 0:8fdf9a60065b 58 default=None,
kadonotakashi 0:8fdf9a60065b 59 help='Filter targets')
kadonotakashi 0:8fdf9a60065b 60
kadonotakashi 0:8fdf9a60065b 61 parser.add_argument("-v", "--verbose",
kadonotakashi 0:8fdf9a60065b 62 action="store_true",
kadonotakashi 0:8fdf9a60065b 63 dest="verbose",
kadonotakashi 0:8fdf9a60065b 64 default=False,
kadonotakashi 0:8fdf9a60065b 65 help="Verbose diagnostic output")
kadonotakashi 0:8fdf9a60065b 66
kadonotakashi 0:8fdf9a60065b 67 options = parser.parse_args()
kadonotakashi 0:8fdf9a60065b 68
kadonotakashi 0:8fdf9a60065b 69 # Only prints matrix of supported toolchains
kadonotakashi 0:8fdf9a60065b 70 if options.supported_toolchains:
kadonotakashi 0:8fdf9a60065b 71 print(mcu_toolchain_matrix(
kadonotakashi 0:8fdf9a60065b 72 platform_filter=options.general_filter_regex))
kadonotakashi 0:8fdf9a60065b 73 exit(0)
kadonotakashi 0:8fdf9a60065b 74
kadonotakashi 0:8fdf9a60065b 75 # If auto_detect attribute is present, we assume other auto-detection
kadonotakashi 0:8fdf9a60065b 76 # parameters like 'toolchains_filter' are also set.
kadonotakashi 0:8fdf9a60065b 77 muts = get_autodetected_MUTS_list()
kadonotakashi 0:8fdf9a60065b 78
kadonotakashi 0:8fdf9a60065b 79 mcu_filter = options.general_filter_regex or ".*"
kadonotakashi 0:8fdf9a60065b 80
kadonotakashi 0:8fdf9a60065b 81 count = 0
kadonotakashi 0:8fdf9a60065b 82 for mut in muts.values():
kadonotakashi 0:8fdf9a60065b 83 if re.match(mcu_filter, mut['mcu'] or "Unknown"):
kadonotakashi 0:8fdf9a60065b 84 interface_version = get_interface_version(mut['disk'])
kadonotakashi 0:8fdf9a60065b 85 print("")
kadonotakashi 0:8fdf9a60065b 86 print("[mbed] Detected %s, port %s, mounted %s, interface "
kadonotakashi 0:8fdf9a60065b 87 "version %s:" %
kadonotakashi 0:8fdf9a60065b 88 (mut['mcu'], mut['port'], mut['disk'], interface_version))
kadonotakashi 0:8fdf9a60065b 89 print("[mbed] Supported toolchains for %s" % mut['mcu'])
kadonotakashi 0:8fdf9a60065b 90 print(mcu_toolchain_matrix(platform_filter=mut['mcu']))
kadonotakashi 0:8fdf9a60065b 91 count += 1
kadonotakashi 0:8fdf9a60065b 92
kadonotakashi 0:8fdf9a60065b 93 if count == 0:
kadonotakashi 0:8fdf9a60065b 94 print("[mbed] No mbed targets were detected on your system.")
kadonotakashi 0:8fdf9a60065b 95
kadonotakashi 0:8fdf9a60065b 96 except KeyboardInterrupt:
kadonotakashi 0:8fdf9a60065b 97 print("\n[CTRL+c] exit")
kadonotakashi 0:8fdf9a60065b 98 except Exception as exc:
kadonotakashi 0:8fdf9a60065b 99 import traceback
kadonotakashi 0:8fdf9a60065b 100 traceback.print_exc(file=sys.stdout)
kadonotakashi 0:8fdf9a60065b 101 print("[ERROR] %s" % str(exc))
kadonotakashi 0:8fdf9a60065b 102 sys.exit(1)
kadonotakashi 0:8fdf9a60065b 103
kadonotakashi 0:8fdf9a60065b 104 def get_interface_version(mount_point):
kadonotakashi 0:8fdf9a60065b 105 """ Function returns interface version from the target mounted on the specified mount point
kadonotakashi 0:8fdf9a60065b 106
kadonotakashi 0:8fdf9a60065b 107 mount_point can be acquired via the following:
kadonotakashi 0:8fdf9a60065b 108 muts = get_autodetected_MUTS_list()
kadonotakashi 0:8fdf9a60065b 109 for mut in muts.values():
kadonotakashi 0:8fdf9a60065b 110 mount_point = mut['disk']
kadonotakashi 0:8fdf9a60065b 111
kadonotakashi 0:8fdf9a60065b 112 @param mount_point Name of disk where platform is connected to host machine.
kadonotakashi 0:8fdf9a60065b 113 """
kadonotakashi 0:8fdf9a60065b 114 if get_module_avail('mbed_lstools'):
kadonotakashi 0:8fdf9a60065b 115 try :
kadonotakashi 0:8fdf9a60065b 116 mbedls = mbed_lstools.create()
kadonotakashi 0:8fdf9a60065b 117 mbeds = mbedls.list_mbeds(unique_names=True, read_details_txt=True)
kadonotakashi 0:8fdf9a60065b 118
kadonotakashi 0:8fdf9a60065b 119 for mbed in mbeds:
kadonotakashi 0:8fdf9a60065b 120 if mbed['mount_point'] == mount_point:
kadonotakashi 0:8fdf9a60065b 121
kadonotakashi 0:8fdf9a60065b 122 if 'daplink_version' in mbed:
kadonotakashi 0:8fdf9a60065b 123 return mbed['daplink_version']
kadonotakashi 0:8fdf9a60065b 124 except :
kadonotakashi 0:8fdf9a60065b 125 return 'unknown'
kadonotakashi 0:8fdf9a60065b 126
kadonotakashi 0:8fdf9a60065b 127 return 'unknown'
kadonotakashi 0:8fdf9a60065b 128
kadonotakashi 0:8fdf9a60065b 129 if __name__ == '__main__':
kadonotakashi 0:8fdf9a60065b 130 main()