dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
nexpaq
Date:
Sat Sep 17 16:32:05 2016 +0000
Revision:
1:55a6170b404f
checking in for sharing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nexpaq 1:55a6170b404f 1 """
nexpaq 1:55a6170b404f 2 mbed SDK
nexpaq 1:55a6170b404f 3 Copyright (c) 2014-2016 ARM Limited
nexpaq 1:55a6170b404f 4
nexpaq 1:55a6170b404f 5 Licensed under the Apache License, Version 2.0 (the "License");
nexpaq 1:55a6170b404f 6 you may not use this file except in compliance with the License.
nexpaq 1:55a6170b404f 7 You may obtain a copy of the License at
nexpaq 1:55a6170b404f 8
nexpaq 1:55a6170b404f 9 http://www.apache.org/licenses/LICENSE-2.0
nexpaq 1:55a6170b404f 10
nexpaq 1:55a6170b404f 11 Unless required by applicable law or agreed to in writing, software
nexpaq 1:55a6170b404f 12 distributed under the License is distributed on an "AS IS" BASIS,
nexpaq 1:55a6170b404f 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nexpaq 1:55a6170b404f 14 See the License for the specific language governing permissions and
nexpaq 1:55a6170b404f 15 limitations under the License.
nexpaq 1:55a6170b404f 16 """
nexpaq 1:55a6170b404f 17 from exporters import Exporter
nexpaq 1:55a6170b404f 18 from os.path import split,splitext, basename
nexpaq 1:55a6170b404f 19
nexpaq 1:55a6170b404f 20 class Folder:
nexpaq 1:55a6170b404f 21 def __init__(self, name):
nexpaq 1:55a6170b404f 22 self.name = name
nexpaq 1:55a6170b404f 23 self.children = []
nexpaq 1:55a6170b404f 24
nexpaq 1:55a6170b404f 25 def contains(self, folderName):
nexpaq 1:55a6170b404f 26 for child in self.children:
nexpaq 1:55a6170b404f 27 if child.name == folderName:
nexpaq 1:55a6170b404f 28 return True
nexpaq 1:55a6170b404f 29 return False
nexpaq 1:55a6170b404f 30
nexpaq 1:55a6170b404f 31 def __str__(self):
nexpaq 1:55a6170b404f 32 retval = self.name + " "
nexpaq 1:55a6170b404f 33 if len(self.children) > 0:
nexpaq 1:55a6170b404f 34 retval += "[ "
nexpaq 1:55a6170b404f 35 for child in self.children:
nexpaq 1:55a6170b404f 36 retval += child.__str__()
nexpaq 1:55a6170b404f 37 retval += " ]"
nexpaq 1:55a6170b404f 38
nexpaq 1:55a6170b404f 39 return retval
nexpaq 1:55a6170b404f 40
nexpaq 1:55a6170b404f 41 def findChild(self, folderName):
nexpaq 1:55a6170b404f 42 for child in self.children:
nexpaq 1:55a6170b404f 43 if child.name == folderName:
nexpaq 1:55a6170b404f 44 return child
nexpaq 1:55a6170b404f 45 return None
nexpaq 1:55a6170b404f 46
nexpaq 1:55a6170b404f 47 def addChild(self, folderName):
nexpaq 1:55a6170b404f 48 if folderName == '':
nexpaq 1:55a6170b404f 49 return None
nexpaq 1:55a6170b404f 50
nexpaq 1:55a6170b404f 51 if not self.contains(folderName):
nexpaq 1:55a6170b404f 52 self.children.append(Folder(folderName))
nexpaq 1:55a6170b404f 53
nexpaq 1:55a6170b404f 54 return self.findChild(folderName)
nexpaq 1:55a6170b404f 55
nexpaq 1:55a6170b404f 56 class SimplicityV3(Exporter):
nexpaq 1:55a6170b404f 57 NAME = 'SimplicityV3'
nexpaq 1:55a6170b404f 58 TOOLCHAIN = 'GCC_ARM'
nexpaq 1:55a6170b404f 59
nexpaq 1:55a6170b404f 60 TARGETS = [
nexpaq 1:55a6170b404f 61 'EFM32GG_STK3700',
nexpaq 1:55a6170b404f 62 'EFM32ZG_STK3200',
nexpaq 1:55a6170b404f 63 'EFM32LG_STK3600',
nexpaq 1:55a6170b404f 64 'EFM32WG_STK3800',
nexpaq 1:55a6170b404f 65 'EFM32HG_STK3400',
nexpaq 1:55a6170b404f 66 'EFM32PG_STK3401'
nexpaq 1:55a6170b404f 67 ]
nexpaq 1:55a6170b404f 68
nexpaq 1:55a6170b404f 69 PARTS = {
nexpaq 1:55a6170b404f 70 'EFM32GG_STK3700': 'com.silabs.mcu.si32.efm32.efm32gg.efm32gg990f1024',
nexpaq 1:55a6170b404f 71 'EFM32ZG_STK3200': 'com.silabs.mcu.si32.efm32.efm32zg.efm32zg222f32',
nexpaq 1:55a6170b404f 72 'EFM32LG_STK3600': 'com.silabs.mcu.si32.efm32.efm32lg.efm32lg990f256',
nexpaq 1:55a6170b404f 73 'EFM32WG_STK3800': 'com.silabs.mcu.si32.efm32.efm32wg.efm32wg990f256',
nexpaq 1:55a6170b404f 74 'EFM32HG_STK3400': 'com.silabs.mcu.si32.efm32.efm32hg.efm32hg322f64',
nexpaq 1:55a6170b404f 75 'EFM32PG_STK3401': 'com.silabs.mcu.si32.efm32.efm32pg1b.efm32pg1b200f256gm48'
nexpaq 1:55a6170b404f 76 }
nexpaq 1:55a6170b404f 77
nexpaq 1:55a6170b404f 78 KITS = {
nexpaq 1:55a6170b404f 79 'EFM32GG_STK3700': 'com.silabs.kit.si32.efm32.efm32gg.stk3700',
nexpaq 1:55a6170b404f 80 'EFM32ZG_STK3200': 'com.silabs.kit.si32.efm32.efm32zg.stk3200',
nexpaq 1:55a6170b404f 81 'EFM32LG_STK3600': 'com.silabs.kit.si32.efm32.efm32lg.stk3600',
nexpaq 1:55a6170b404f 82 'EFM32WG_STK3800': 'com.silabs.kit.si32.efm32.efm32wg.stk3800',
nexpaq 1:55a6170b404f 83 'EFM32HG_STK3400': 'com.silabs.kit.si32.efm32.efm32hg.slstk3400a',
nexpaq 1:55a6170b404f 84 'EFM32PG_STK3401': 'com.silabs.kit.si32.efm32.efm32pg.slstk3401a'
nexpaq 1:55a6170b404f 85 }
nexpaq 1:55a6170b404f 86
nexpaq 1:55a6170b404f 87 FILE_TYPES = {
nexpaq 1:55a6170b404f 88 'c_sources':'1',
nexpaq 1:55a6170b404f 89 'cpp_sources':'1',
nexpaq 1:55a6170b404f 90 's_sources':'1'
nexpaq 1:55a6170b404f 91 }
nexpaq 1:55a6170b404f 92
nexpaq 1:55a6170b404f 93 EXCLUDED_LIBS = [
nexpaq 1:55a6170b404f 94 'm',
nexpaq 1:55a6170b404f 95 'c',
nexpaq 1:55a6170b404f 96 'gcc',
nexpaq 1:55a6170b404f 97 'nosys',
nexpaq 1:55a6170b404f 98 'supc++',
nexpaq 1:55a6170b404f 99 'stdc++'
nexpaq 1:55a6170b404f 100 ]
nexpaq 1:55a6170b404f 101
nexpaq 1:55a6170b404f 102 DOT_IN_RELATIVE_PATH = False
nexpaq 1:55a6170b404f 103
nexpaq 1:55a6170b404f 104 MBED_CONFIG_HEADER_SUPPORTED = True
nexpaq 1:55a6170b404f 105
nexpaq 1:55a6170b404f 106 orderedPaths = Folder("Root")
nexpaq 1:55a6170b404f 107
nexpaq 1:55a6170b404f 108 def check_and_add_path(self, path):
nexpaq 1:55a6170b404f 109 levels = path.split('/')
nexpaq 1:55a6170b404f 110 base = self.orderedPaths
nexpaq 1:55a6170b404f 111 for level in levels:
nexpaq 1:55a6170b404f 112 if base.contains(level):
nexpaq 1:55a6170b404f 113 base = base.findChild(level)
nexpaq 1:55a6170b404f 114 else:
nexpaq 1:55a6170b404f 115 base.addChild(level)
nexpaq 1:55a6170b404f 116 base = base.findChild(level)
nexpaq 1:55a6170b404f 117
nexpaq 1:55a6170b404f 118
nexpaq 1:55a6170b404f 119 def generate(self):
nexpaq 1:55a6170b404f 120 # "make" wants Unix paths
nexpaq 1:55a6170b404f 121 self.resources.win_to_unix()
nexpaq 1:55a6170b404f 122
nexpaq 1:55a6170b404f 123 main_files = []
nexpaq 1:55a6170b404f 124
nexpaq 1:55a6170b404f 125 EXCLUDED_LIBS = [
nexpaq 1:55a6170b404f 126 'm',
nexpaq 1:55a6170b404f 127 'c',
nexpaq 1:55a6170b404f 128 'gcc',
nexpaq 1:55a6170b404f 129 'nosys',
nexpaq 1:55a6170b404f 130 'supc++',
nexpaq 1:55a6170b404f 131 'stdc++'
nexpaq 1:55a6170b404f 132 ]
nexpaq 1:55a6170b404f 133
nexpaq 1:55a6170b404f 134 for r_type in ['s_sources', 'c_sources', 'cpp_sources']:
nexpaq 1:55a6170b404f 135 r = getattr(self.resources, r_type)
nexpaq 1:55a6170b404f 136 if r:
nexpaq 1:55a6170b404f 137 for source in r:
nexpaq 1:55a6170b404f 138 self.check_and_add_path(split(source)[0])
nexpaq 1:55a6170b404f 139
nexpaq 1:55a6170b404f 140 if not ('/' in source):
nexpaq 1:55a6170b404f 141 main_files.append(source)
nexpaq 1:55a6170b404f 142
nexpaq 1:55a6170b404f 143 libraries = []
nexpaq 1:55a6170b404f 144 for lib in self.resources.libraries:
nexpaq 1:55a6170b404f 145 l, _ = splitext(basename(lib))
nexpaq 1:55a6170b404f 146 if l[3:] not in EXCLUDED_LIBS:
nexpaq 1:55a6170b404f 147 libraries.append(l[3:])
nexpaq 1:55a6170b404f 148
nexpaq 1:55a6170b404f 149 defines = []
nexpaq 1:55a6170b404f 150 for define in self.toolchain.get_symbols():
nexpaq 1:55a6170b404f 151 if '=' in define:
nexpaq 1:55a6170b404f 152 keyval = define.split('=')
nexpaq 1:55a6170b404f 153 defines.append( (keyval[0], keyval[1]) )
nexpaq 1:55a6170b404f 154 else:
nexpaq 1:55a6170b404f 155 defines.append( (define, '') )
nexpaq 1:55a6170b404f 156
nexpaq 1:55a6170b404f 157 self.check_and_add_path(split(self.resources.linker_script)[0])
nexpaq 1:55a6170b404f 158
nexpaq 1:55a6170b404f 159 ctx = {
nexpaq 1:55a6170b404f 160 'name': self.project_name,
nexpaq 1:55a6170b404f 161 'main_files': main_files,
nexpaq 1:55a6170b404f 162 'recursiveFolders': self.orderedPaths,
nexpaq 1:55a6170b404f 163 'object_files': self.resources.objects,
nexpaq 1:55a6170b404f 164 'include_paths': self.resources.inc_dirs,
nexpaq 1:55a6170b404f 165 'library_paths': self.resources.lib_dirs,
nexpaq 1:55a6170b404f 166 'linker_script': self.resources.linker_script,
nexpaq 1:55a6170b404f 167 'libraries': libraries,
nexpaq 1:55a6170b404f 168 'defines': defines,
nexpaq 1:55a6170b404f 169 'part': self.PARTS[self.target],
nexpaq 1:55a6170b404f 170 'kit': self.KITS[self.target],
nexpaq 1:55a6170b404f 171 'loopcount': 0
nexpaq 1:55a6170b404f 172 }
nexpaq 1:55a6170b404f 173 ctx.update(self.flags)
nexpaq 1:55a6170b404f 174
nexpaq 1:55a6170b404f 175 ## Strip main folder from include paths because ssproj is not capable of handling it
nexpaq 1:55a6170b404f 176 if '.' in ctx['include_paths']:
nexpaq 1:55a6170b404f 177 ctx['include_paths'].remove('.')
nexpaq 1:55a6170b404f 178
nexpaq 1:55a6170b404f 179 '''
nexpaq 1:55a6170b404f 180 Suppress print statements
nexpaq 1:55a6170b404f 181 print('\n')
nexpaq 1:55a6170b404f 182 print(self.target)
nexpaq 1:55a6170b404f 183 print('\n')
nexpaq 1:55a6170b404f 184 print(ctx)
nexpaq 1:55a6170b404f 185 print('\n')
nexpaq 1:55a6170b404f 186 print(self.orderedPaths)
nexpaq 1:55a6170b404f 187 for path in self.orderedPaths.children:
nexpaq 1:55a6170b404f 188 print(path.name + "\n")
nexpaq 1:55a6170b404f 189 for bpath in path.children:
nexpaq 1:55a6170b404f 190 print("\t" + bpath.name + "\n")
nexpaq 1:55a6170b404f 191 '''
nexpaq 1:55a6170b404f 192
nexpaq 1:55a6170b404f 193 self.gen_file('simplicityv3_slsproj.tmpl', ctx, '%s.slsproj' % self.project_name)