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) 2014-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 exporters import Exporter
bryantaylor 0:eafc3fd41f75 18 from os.path import split,splitext, basename
bryantaylor 0:eafc3fd41f75 19
bryantaylor 0:eafc3fd41f75 20 class Folder:
bryantaylor 0:eafc3fd41f75 21 def __init__(self, name):
bryantaylor 0:eafc3fd41f75 22 self.name = name
bryantaylor 0:eafc3fd41f75 23 self.children = []
bryantaylor 0:eafc3fd41f75 24
bryantaylor 0:eafc3fd41f75 25 def contains(self, folderName):
bryantaylor 0:eafc3fd41f75 26 for child in self.children:
bryantaylor 0:eafc3fd41f75 27 if child.name == folderName:
bryantaylor 0:eafc3fd41f75 28 return True
bryantaylor 0:eafc3fd41f75 29 return False
bryantaylor 0:eafc3fd41f75 30
bryantaylor 0:eafc3fd41f75 31 def __str__(self):
bryantaylor 0:eafc3fd41f75 32 retval = self.name + " "
bryantaylor 0:eafc3fd41f75 33 if len(self.children) > 0:
bryantaylor 0:eafc3fd41f75 34 retval += "[ "
bryantaylor 0:eafc3fd41f75 35 for child in self.children:
bryantaylor 0:eafc3fd41f75 36 retval += child.__str__()
bryantaylor 0:eafc3fd41f75 37 retval += " ]"
bryantaylor 0:eafc3fd41f75 38
bryantaylor 0:eafc3fd41f75 39 return retval
bryantaylor 0:eafc3fd41f75 40
bryantaylor 0:eafc3fd41f75 41 def findChild(self, folderName):
bryantaylor 0:eafc3fd41f75 42 for child in self.children:
bryantaylor 0:eafc3fd41f75 43 if child.name == folderName:
bryantaylor 0:eafc3fd41f75 44 return child
bryantaylor 0:eafc3fd41f75 45 return None
bryantaylor 0:eafc3fd41f75 46
bryantaylor 0:eafc3fd41f75 47 def addChild(self, folderName):
bryantaylor 0:eafc3fd41f75 48 if folderName == '':
bryantaylor 0:eafc3fd41f75 49 return None
bryantaylor 0:eafc3fd41f75 50
bryantaylor 0:eafc3fd41f75 51 if not self.contains(folderName):
bryantaylor 0:eafc3fd41f75 52 self.children.append(Folder(folderName))
bryantaylor 0:eafc3fd41f75 53
bryantaylor 0:eafc3fd41f75 54 return self.findChild(folderName)
bryantaylor 0:eafc3fd41f75 55
bryantaylor 0:eafc3fd41f75 56 class SimplicityV3(Exporter):
bryantaylor 0:eafc3fd41f75 57 NAME = 'SimplicityV3'
bryantaylor 0:eafc3fd41f75 58 TOOLCHAIN = 'GCC_ARM'
bryantaylor 0:eafc3fd41f75 59
bryantaylor 0:eafc3fd41f75 60 TARGETS = [
bryantaylor 0:eafc3fd41f75 61 'EFM32GG_STK3700',
bryantaylor 0:eafc3fd41f75 62 'EFM32ZG_STK3200',
bryantaylor 0:eafc3fd41f75 63 'EFM32LG_STK3600',
bryantaylor 0:eafc3fd41f75 64 'EFM32WG_STK3800',
bryantaylor 0:eafc3fd41f75 65 'EFM32HG_STK3400',
bryantaylor 0:eafc3fd41f75 66 'EFM32PG_STK3401'
bryantaylor 0:eafc3fd41f75 67 ]
bryantaylor 0:eafc3fd41f75 68
bryantaylor 0:eafc3fd41f75 69 PARTS = {
bryantaylor 0:eafc3fd41f75 70 'EFM32GG_STK3700': 'com.silabs.mcu.si32.efm32.efm32gg.efm32gg990f1024',
bryantaylor 0:eafc3fd41f75 71 'EFM32ZG_STK3200': 'com.silabs.mcu.si32.efm32.efm32zg.efm32zg222f32',
bryantaylor 0:eafc3fd41f75 72 'EFM32LG_STK3600': 'com.silabs.mcu.si32.efm32.efm32lg.efm32lg990f256',
bryantaylor 0:eafc3fd41f75 73 'EFM32WG_STK3800': 'com.silabs.mcu.si32.efm32.efm32wg.efm32wg990f256',
bryantaylor 0:eafc3fd41f75 74 'EFM32HG_STK3400': 'com.silabs.mcu.si32.efm32.efm32hg.efm32hg322f64',
bryantaylor 0:eafc3fd41f75 75 'EFM32PG_STK3401': 'com.silabs.mcu.si32.efm32.efm32pg1b.efm32pg1b200f256gm48'
bryantaylor 0:eafc3fd41f75 76 }
bryantaylor 0:eafc3fd41f75 77
bryantaylor 0:eafc3fd41f75 78 KITS = {
bryantaylor 0:eafc3fd41f75 79 'EFM32GG_STK3700': 'com.silabs.kit.si32.efm32.efm32gg.stk3700',
bryantaylor 0:eafc3fd41f75 80 'EFM32ZG_STK3200': 'com.silabs.kit.si32.efm32.efm32zg.stk3200',
bryantaylor 0:eafc3fd41f75 81 'EFM32LG_STK3600': 'com.silabs.kit.si32.efm32.efm32lg.stk3600',
bryantaylor 0:eafc3fd41f75 82 'EFM32WG_STK3800': 'com.silabs.kit.si32.efm32.efm32wg.stk3800',
bryantaylor 0:eafc3fd41f75 83 'EFM32HG_STK3400': 'com.silabs.kit.si32.efm32.efm32hg.slstk3400a',
bryantaylor 0:eafc3fd41f75 84 'EFM32PG_STK3401': 'com.silabs.kit.si32.efm32.efm32pg.slstk3401a'
bryantaylor 0:eafc3fd41f75 85 }
bryantaylor 0:eafc3fd41f75 86
bryantaylor 0:eafc3fd41f75 87 FILE_TYPES = {
bryantaylor 0:eafc3fd41f75 88 'c_sources':'1',
bryantaylor 0:eafc3fd41f75 89 'cpp_sources':'1',
bryantaylor 0:eafc3fd41f75 90 's_sources':'1'
bryantaylor 0:eafc3fd41f75 91 }
bryantaylor 0:eafc3fd41f75 92
bryantaylor 0:eafc3fd41f75 93 EXCLUDED_LIBS = [
bryantaylor 0:eafc3fd41f75 94 'm',
bryantaylor 0:eafc3fd41f75 95 'c',
bryantaylor 0:eafc3fd41f75 96 'gcc',
bryantaylor 0:eafc3fd41f75 97 'nosys',
bryantaylor 0:eafc3fd41f75 98 'supc++',
bryantaylor 0:eafc3fd41f75 99 'stdc++'
bryantaylor 0:eafc3fd41f75 100 ]
bryantaylor 0:eafc3fd41f75 101
bryantaylor 0:eafc3fd41f75 102 DOT_IN_RELATIVE_PATH = False
bryantaylor 0:eafc3fd41f75 103
bryantaylor 0:eafc3fd41f75 104 MBED_CONFIG_HEADER_SUPPORTED = True
bryantaylor 0:eafc3fd41f75 105
bryantaylor 0:eafc3fd41f75 106 orderedPaths = Folder("Root")
bryantaylor 0:eafc3fd41f75 107
bryantaylor 0:eafc3fd41f75 108 def check_and_add_path(self, path):
bryantaylor 0:eafc3fd41f75 109 levels = path.split('/')
bryantaylor 0:eafc3fd41f75 110 base = self.orderedPaths
bryantaylor 0:eafc3fd41f75 111 for level in levels:
bryantaylor 0:eafc3fd41f75 112 if base.contains(level):
bryantaylor 0:eafc3fd41f75 113 base = base.findChild(level)
bryantaylor 0:eafc3fd41f75 114 else:
bryantaylor 0:eafc3fd41f75 115 base.addChild(level)
bryantaylor 0:eafc3fd41f75 116 base = base.findChild(level)
bryantaylor 0:eafc3fd41f75 117
bryantaylor 0:eafc3fd41f75 118
bryantaylor 0:eafc3fd41f75 119 def generate(self):
bryantaylor 0:eafc3fd41f75 120 # "make" wants Unix paths
bryantaylor 0:eafc3fd41f75 121 self.resources.win_to_unix()
bryantaylor 0:eafc3fd41f75 122
bryantaylor 0:eafc3fd41f75 123 main_files = []
bryantaylor 0:eafc3fd41f75 124
bryantaylor 0:eafc3fd41f75 125 EXCLUDED_LIBS = [
bryantaylor 0:eafc3fd41f75 126 'm',
bryantaylor 0:eafc3fd41f75 127 'c',
bryantaylor 0:eafc3fd41f75 128 'gcc',
bryantaylor 0:eafc3fd41f75 129 'nosys',
bryantaylor 0:eafc3fd41f75 130 'supc++',
bryantaylor 0:eafc3fd41f75 131 'stdc++'
bryantaylor 0:eafc3fd41f75 132 ]
bryantaylor 0:eafc3fd41f75 133
bryantaylor 0:eafc3fd41f75 134 for r_type in ['s_sources', 'c_sources', 'cpp_sources']:
bryantaylor 0:eafc3fd41f75 135 r = getattr(self.resources, r_type)
bryantaylor 0:eafc3fd41f75 136 if r:
bryantaylor 0:eafc3fd41f75 137 for source in r:
bryantaylor 0:eafc3fd41f75 138 self.check_and_add_path(split(source)[0])
bryantaylor 0:eafc3fd41f75 139
bryantaylor 0:eafc3fd41f75 140 if not ('/' in source):
bryantaylor 0:eafc3fd41f75 141 main_files.append(source)
bryantaylor 0:eafc3fd41f75 142
bryantaylor 0:eafc3fd41f75 143 libraries = []
bryantaylor 0:eafc3fd41f75 144 for lib in self.resources.libraries:
bryantaylor 0:eafc3fd41f75 145 l, _ = splitext(basename(lib))
bryantaylor 0:eafc3fd41f75 146 if l[3:] not in EXCLUDED_LIBS:
bryantaylor 0:eafc3fd41f75 147 libraries.append(l[3:])
bryantaylor 0:eafc3fd41f75 148
bryantaylor 0:eafc3fd41f75 149 defines = []
bryantaylor 0:eafc3fd41f75 150 for define in self.toolchain.get_symbols():
bryantaylor 0:eafc3fd41f75 151 if '=' in define:
bryantaylor 0:eafc3fd41f75 152 keyval = define.split('=')
bryantaylor 0:eafc3fd41f75 153 defines.append( (keyval[0], keyval[1]) )
bryantaylor 0:eafc3fd41f75 154 else:
bryantaylor 0:eafc3fd41f75 155 defines.append( (define, '') )
bryantaylor 0:eafc3fd41f75 156
bryantaylor 0:eafc3fd41f75 157 self.check_and_add_path(split(self.resources.linker_script)[0])
bryantaylor 0:eafc3fd41f75 158
bryantaylor 0:eafc3fd41f75 159 ctx = {
bryantaylor 0:eafc3fd41f75 160 'name': self.project_name,
bryantaylor 0:eafc3fd41f75 161 'main_files': main_files,
bryantaylor 0:eafc3fd41f75 162 'recursiveFolders': self.orderedPaths,
bryantaylor 0:eafc3fd41f75 163 'object_files': self.resources.objects,
bryantaylor 0:eafc3fd41f75 164 'include_paths': self.resources.inc_dirs,
bryantaylor 0:eafc3fd41f75 165 'library_paths': self.resources.lib_dirs,
bryantaylor 0:eafc3fd41f75 166 'linker_script': self.resources.linker_script,
bryantaylor 0:eafc3fd41f75 167 'libraries': libraries,
bryantaylor 0:eafc3fd41f75 168 'defines': defines,
bryantaylor 0:eafc3fd41f75 169 'part': self.PARTS[self.target],
bryantaylor 0:eafc3fd41f75 170 'kit': self.KITS[self.target],
bryantaylor 0:eafc3fd41f75 171 'loopcount': 0
bryantaylor 0:eafc3fd41f75 172 }
bryantaylor 0:eafc3fd41f75 173 ctx.update(self.flags)
bryantaylor 0:eafc3fd41f75 174
bryantaylor 0:eafc3fd41f75 175 ## Strip main folder from include paths because ssproj is not capable of handling it
bryantaylor 0:eafc3fd41f75 176 if '.' in ctx['include_paths']:
bryantaylor 0:eafc3fd41f75 177 ctx['include_paths'].remove('.')
bryantaylor 0:eafc3fd41f75 178
bryantaylor 0:eafc3fd41f75 179 '''
bryantaylor 0:eafc3fd41f75 180 Suppress print statements
bryantaylor 0:eafc3fd41f75 181 print('\n')
bryantaylor 0:eafc3fd41f75 182 print(self.target)
bryantaylor 0:eafc3fd41f75 183 print('\n')
bryantaylor 0:eafc3fd41f75 184 print(ctx)
bryantaylor 0:eafc3fd41f75 185 print('\n')
bryantaylor 0:eafc3fd41f75 186 print(self.orderedPaths)
bryantaylor 0:eafc3fd41f75 187 for path in self.orderedPaths.children:
bryantaylor 0:eafc3fd41f75 188 print(path.name + "\n")
bryantaylor 0:eafc3fd41f75 189 for bpath in path.children:
bryantaylor 0:eafc3fd41f75 190 print("\t" + bpath.name + "\n")
bryantaylor 0:eafc3fd41f75 191 '''
bryantaylor 0:eafc3fd41f75 192
bryantaylor 0:eafc3fd41f75 193 self.gen_file('simplicityv3_slsproj.tmpl', ctx, '%s.slsproj' % self.project_name)