Includes library modifications to allow access to AIN_4 (AIN_0 / 5)

Committer:
bryantaylor
Date:
Tue Sep 20 21:26:12 2016 +0000
Revision:
0:eafc3fd41f75
hackathon

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bryantaylor 0:eafc3fd41f75 1 """
bryantaylor 0:eafc3fd41f75 2 mbed SDK
bryantaylor 0:eafc3fd41f75 3 Copyright (c) 2011-2016 ARM Limited
bryantaylor 0:eafc3fd41f75 4
bryantaylor 0:eafc3fd41f75 5 Licensed under the Apache License, Version 2.0 (the "License");
bryantaylor 0:eafc3fd41f75 6 you may not use this file except in compliance with the License.
bryantaylor 0:eafc3fd41f75 7 You may obtain a copy of the License at
bryantaylor 0:eafc3fd41f75 8
bryantaylor 0:eafc3fd41f75 9 http://www.apache.org/licenses/LICENSE-2.0
bryantaylor 0:eafc3fd41f75 10
bryantaylor 0:eafc3fd41f75 11 Unless required by applicable law or agreed to in writing, software
bryantaylor 0:eafc3fd41f75 12 distributed under the License is distributed on an "AS IS" BASIS,
bryantaylor 0:eafc3fd41f75 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
bryantaylor 0:eafc3fd41f75 14 See the License for the specific language governing permissions and
bryantaylor 0:eafc3fd41f75 15 limitations under the License.
bryantaylor 0:eafc3fd41f75 16 """
bryantaylor 0:eafc3fd41f75 17 from os.path import basename, join, dirname
bryantaylor 0:eafc3fd41f75 18 from project_generator_definitions.definitions import ProGenDef
bryantaylor 0:eafc3fd41f75 19
bryantaylor 0:eafc3fd41f75 20 from tools.export.exporters import Exporter, ExporterTargetsProperty
bryantaylor 0:eafc3fd41f75 21 from tools.targets import TARGET_MAP, TARGET_NAMES
bryantaylor 0:eafc3fd41f75 22
bryantaylor 0:eafc3fd41f75 23 # If you wish to add a new target, add it to project_generator_definitions, and then
bryantaylor 0:eafc3fd41f75 24 # define progen_target name in the target class (`` self.progen_target = 'my_target_name' ``)
bryantaylor 0:eafc3fd41f75 25 # There are 2 default mbed templates (predefined settings) uvision.uvproj and uvproj_microlib.uvproj.tmpl
bryantaylor 0:eafc3fd41f75 26 class Uvision4(Exporter):
bryantaylor 0:eafc3fd41f75 27 """
bryantaylor 0:eafc3fd41f75 28 Exporter class for uvision. This class uses project generator.
bryantaylor 0:eafc3fd41f75 29 """
bryantaylor 0:eafc3fd41f75 30 # These 2 are currently for exporters backward compatiblity
bryantaylor 0:eafc3fd41f75 31 NAME = 'uvision'
bryantaylor 0:eafc3fd41f75 32 TOOLCHAIN = 'ARM'
bryantaylor 0:eafc3fd41f75 33 # PROGEN_ACTIVE contains information for exporter scripts that this is using progen
bryantaylor 0:eafc3fd41f75 34 PROGEN_ACTIVE = True
bryantaylor 0:eafc3fd41f75 35
bryantaylor 0:eafc3fd41f75 36 MBED_CONFIG_HEADER_SUPPORTED = True
bryantaylor 0:eafc3fd41f75 37
bryantaylor 0:eafc3fd41f75 38 @ExporterTargetsProperty
bryantaylor 0:eafc3fd41f75 39 def TARGETS(cls):
bryantaylor 0:eafc3fd41f75 40 if not hasattr(cls, "_targets_supported"):
bryantaylor 0:eafc3fd41f75 41 cls._targets_supported = []
bryantaylor 0:eafc3fd41f75 42 progendef = ProGenDef('uvision')
bryantaylor 0:eafc3fd41f75 43 for target in TARGET_NAMES:
bryantaylor 0:eafc3fd41f75 44 try:
bryantaylor 0:eafc3fd41f75 45 if (progendef.is_supported(str(TARGET_MAP[target])) or
bryantaylor 0:eafc3fd41f75 46 progendef.is_supported(TARGET_MAP[target].progen['target'])):
bryantaylor 0:eafc3fd41f75 47 cls._targets_supported.append(target)
bryantaylor 0:eafc3fd41f75 48 except AttributeError:
bryantaylor 0:eafc3fd41f75 49 # target is not supported yet
bryantaylor 0:eafc3fd41f75 50 continue
bryantaylor 0:eafc3fd41f75 51 return cls._targets_supported
bryantaylor 0:eafc3fd41f75 52
bryantaylor 0:eafc3fd41f75 53 def get_toolchain(self):
bryantaylor 0:eafc3fd41f75 54 return TARGET_MAP[self.target].default_toolchain
bryantaylor 0:eafc3fd41f75 55
bryantaylor 0:eafc3fd41f75 56 def generate(self):
bryantaylor 0:eafc3fd41f75 57 """ Generates the project files """
bryantaylor 0:eafc3fd41f75 58 project_data = self.progen_get_project_data()
bryantaylor 0:eafc3fd41f75 59 tool_specific = {}
bryantaylor 0:eafc3fd41f75 60 # Expand tool specific settings by uvision specific settings which are required
bryantaylor 0:eafc3fd41f75 61 try:
bryantaylor 0:eafc3fd41f75 62 if TARGET_MAP[self.target].progen['uvision']['template']:
bryantaylor 0:eafc3fd41f75 63 tool_specific['uvision'] = TARGET_MAP[self.target].progen['uvision']
bryantaylor 0:eafc3fd41f75 64 except KeyError:
bryantaylor 0:eafc3fd41f75 65 # use default template
bryantaylor 0:eafc3fd41f75 66 # by the mbed projects
bryantaylor 0:eafc3fd41f75 67 tool_specific['uvision'] = {
bryantaylor 0:eafc3fd41f75 68 'template': [join(dirname(__file__), 'uvision.uvproj.tmpl')],
bryantaylor 0:eafc3fd41f75 69 }
bryantaylor 0:eafc3fd41f75 70
bryantaylor 0:eafc3fd41f75 71 project_data['tool_specific'] = {}
bryantaylor 0:eafc3fd41f75 72 project_data['tool_specific'].update(tool_specific)
bryantaylor 0:eafc3fd41f75 73
bryantaylor 0:eafc3fd41f75 74 # get flags from toolchain and apply
bryantaylor 0:eafc3fd41f75 75 project_data['misc'] = {}
bryantaylor 0:eafc3fd41f75 76 # need to make this a string for progen. Only adds preprocessor when "macros" set
bryantaylor 0:eafc3fd41f75 77 asm_flag_string = '--cpreproc --cpreproc_opts=-D__ASSERT_MSG,' + ",".join(
bryantaylor 0:eafc3fd41f75 78 list(set(self.flags['asm_flags'])))
bryantaylor 0:eafc3fd41f75 79 # asm flags only, common are not valid within uvision project, they are armcc specific
bryantaylor 0:eafc3fd41f75 80 project_data['misc']['asm_flags'] = [asm_flag_string]
bryantaylor 0:eafc3fd41f75 81 # cxx flags included, as uvision have them all in one tab
bryantaylor 0:eafc3fd41f75 82 project_data['misc']['c_flags'] = list(set(['-D__ASSERT_MSG']
bryantaylor 0:eafc3fd41f75 83 + self.flags['common_flags']
bryantaylor 0:eafc3fd41f75 84 + self.flags['c_flags']
bryantaylor 0:eafc3fd41f75 85 + self.flags['cxx_flags']))
bryantaylor 0:eafc3fd41f75 86 # not compatible with c99 flag set in the template
bryantaylor 0:eafc3fd41f75 87 project_data['misc']['c_flags'].remove("--c99")
bryantaylor 0:eafc3fd41f75 88 # cpp is not required as it's implicit for cpp files
bryantaylor 0:eafc3fd41f75 89 project_data['misc']['c_flags'].remove("--cpp")
bryantaylor 0:eafc3fd41f75 90 # we want no-vla for only cxx, but it's also applied for C in IDE, thus we remove it
bryantaylor 0:eafc3fd41f75 91 project_data['misc']['c_flags'].remove("--no_vla")
bryantaylor 0:eafc3fd41f75 92 project_data['misc']['ld_flags'] = self.flags['ld_flags']
bryantaylor 0:eafc3fd41f75 93
bryantaylor 0:eafc3fd41f75 94 project_data['build_dir'] = project_data['build_dir'] + '\\' + 'uvision4'
bryantaylor 0:eafc3fd41f75 95 self.progen_gen_file(project_data)