dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
cyberjoey
Date:
Sat Oct 22 01:31:58 2016 +0000
Revision:
9:6bb35cef007d
Parent:
1:55a6170b404f
WORKING

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) 2011-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 splitext, basename, join
nexpaq 1:55a6170b404f 19 from random import randint
nexpaq 1:55a6170b404f 20 from tools.utils import mkdir
nexpaq 1:55a6170b404f 21
nexpaq 1:55a6170b404f 22
nexpaq 1:55a6170b404f 23 class Sw4STM32(Exporter):
nexpaq 1:55a6170b404f 24 NAME = 'Sw4STM32'
nexpaq 1:55a6170b404f 25 TOOLCHAIN = 'GCC_ARM'
nexpaq 1:55a6170b404f 26
nexpaq 1:55a6170b404f 27 BOARDS = {
nexpaq 1:55a6170b404f 28 # 'DISCO_F051R8': {'name': 'STM32F0DISCOVERY', 'mcuId': 'STM32F051R8Tx'},
nexpaq 1:55a6170b404f 29 # 'DISCO_F303VC': {'name': 'STM32F3DISCOVERY', 'mcuId': 'STM32F303VCTx'},
nexpaq 1:55a6170b404f 30 'DISCO_F334C8': {'name': 'STM32F3348DISCOVERY', 'mcuId': 'STM32F334C8Tx'},
nexpaq 1:55a6170b404f 31 # 'DISCO_F401VC': {'name': 'STM32F401C-DISCO', 'mcuId': 'STM32F401VCTx'},
nexpaq 1:55a6170b404f 32 'DISCO_F407VG': {'name': 'STM32F4DISCOVERY', 'mcuId': 'STM32F407VGTx'},
nexpaq 1:55a6170b404f 33 'DISCO_F429ZI': {'name': 'STM32F429I-DISCO', 'mcuId': 'STM32F429ZITx'},
nexpaq 1:55a6170b404f 34 'DISCO_F746NG': {'name': 'STM32F746G-DISCO', 'mcuId': 'STM32F746NGHx'},
nexpaq 1:55a6170b404f 35 'DISCO_L053C8': {'name': 'STM32L0538DISCOVERY', 'mcuId': 'STM32L053C8Tx'},
nexpaq 1:55a6170b404f 36 'DISCO_L476VG': {'name': 'STM32L476G-DISCO', 'mcuId': 'STM32L476VGTx'},
nexpaq 1:55a6170b404f 37 'DISCO_F469NI': {'name': 'DISCO-F469NI', 'mcuId': 'STM32F469NIHx'},
nexpaq 1:55a6170b404f 38 'NUCLEO_F030R8': {'name': 'NUCLEO-F030R8', 'mcuId': 'STM32F030R8Tx'},
nexpaq 1:55a6170b404f 39 'NUCLEO_F070RB': {'name': 'NUCLEO-F070RB', 'mcuId': 'STM32F070RBTx'},
nexpaq 1:55a6170b404f 40 'NUCLEO_F072RB': {'name': 'NUCLEO-F072RB', 'mcuId': 'STM32F072RBTx'},
nexpaq 1:55a6170b404f 41 'NUCLEO_F091RC': {'name': 'NUCLEO-F091RC', 'mcuId': 'STM32F091RCTx'},
nexpaq 1:55a6170b404f 42 'NUCLEO_F103RB': {'name': 'NUCLEO-F103RB', 'mcuId': 'STM32F103RBTx'},
nexpaq 1:55a6170b404f 43 'NUCLEO_F207ZG': {'name': 'NUCLEO-F207ZG', 'mcuId': 'STM32F207ZGTx'},
nexpaq 1:55a6170b404f 44 'NUCLEO_F302R8': {'name': 'NUCLEO-F302R8', 'mcuId': 'STM32F302R8Tx'},
nexpaq 1:55a6170b404f 45 'NUCLEO_F303RE': {'name': 'NUCLEO-F303RE', 'mcuId': 'STM32F303RETx'},
nexpaq 1:55a6170b404f 46 'NUCLEO_F334R8': {'name': 'NUCLEO-F334R8', 'mcuId': 'STM32F334R8Tx'},
nexpaq 1:55a6170b404f 47 'NUCLEO_F303ZE': {'name': 'NUCLEO-F303ZE', 'mcuId': 'STM32F303ZETx'},
nexpaq 1:55a6170b404f 48 'NUCLEO_F401RE': {'name': 'NUCLEO-F401RE', 'mcuId': 'STM32F401RETx'},
nexpaq 1:55a6170b404f 49 'NUCLEO_F429ZI': {'name': 'NUCLEO-F429ZI', 'mcuId': 'STM32F429ZITx'},
nexpaq 1:55a6170b404f 50 'NUCLEO_F411RE': {'name': 'NUCLEO-F411RE', 'mcuId': 'STM32F411RETx'},
nexpaq 1:55a6170b404f 51 'NUCLEO_F446RE': {'name': 'NUCLEO-F446RE', 'mcuId': 'STM32F446RETx'},
nexpaq 1:55a6170b404f 52 'NUCLEO_F446ZE': {'name': 'NUCLEO-F446ZE', 'mcuId': 'STM32F446ZETx'},
nexpaq 1:55a6170b404f 53 'NUCLEO_L011K4': {'name': 'NUCLEO-L011K4', 'mcuId': 'STM32L011K4Tx'},
nexpaq 1:55a6170b404f 54 'NUCLEO_L031K6': {'name': 'NUCLEO-L031K6', 'mcuId': 'STM32L031K6Tx'},
nexpaq 1:55a6170b404f 55 'NUCLEO_L053R8': {'name': 'NUCLEO-L053R8', 'mcuId': 'STM32L053R8Tx'},
nexpaq 1:55a6170b404f 56 'NUCLEO_L073RZ': {'name': 'NUCLEO-L073RZ', 'mcuId': 'STM32L073RZTx'},
nexpaq 1:55a6170b404f 57 'NUCLEO_L152RE': {'name': 'NUCLEO-L152RE', 'mcuId': 'STM32L152RETx'},
nexpaq 1:55a6170b404f 58 'NUCLEO_L432KC': {'name': 'NUCLEO-L432KC', 'mcuId': 'STM32L432KCUx'},
nexpaq 1:55a6170b404f 59 'NUCLEO_L476RG': {'name': 'NUCLEO-L476RG', 'mcuId': 'STM32L476RGTx'},
nexpaq 1:55a6170b404f 60 'NUCLEO_F031K6': {'name': 'NUCLEO-F031K6', 'mcuId': 'STM32F031K6Tx'},
nexpaq 1:55a6170b404f 61 'NUCLEO_F042K6': {'name': 'NUCLEO-F042K6', 'mcuId': 'STM32F042K6Tx'},
nexpaq 1:55a6170b404f 62 'NUCLEO_F303K8': {'name': 'NUCLEO-F303K8', 'mcuId': 'STM32F303K8Tx'},
nexpaq 1:55a6170b404f 63 'NUCLEO_F410RB': {'name': 'NUCLEO-F410RB', 'mcuId': 'STM32F410RBTx'},
nexpaq 1:55a6170b404f 64 }
nexpaq 1:55a6170b404f 65
nexpaq 1:55a6170b404f 66 TARGETS = BOARDS.keys()
nexpaq 1:55a6170b404f 67
nexpaq 1:55a6170b404f 68 def __gen_dir(self, dirname):
nexpaq 1:55a6170b404f 69 settings = join(self.export_dir, dirname)
nexpaq 1:55a6170b404f 70 mkdir(settings)
nexpaq 1:55a6170b404f 71
nexpaq 1:55a6170b404f 72 def __generate_uid(self):
nexpaq 1:55a6170b404f 73 return "%0.9u" % randint(0, 999999999)
nexpaq 1:55a6170b404f 74
nexpaq 1:55a6170b404f 75 def generate(self):
nexpaq 1:55a6170b404f 76 libraries = []
nexpaq 1:55a6170b404f 77 for lib in self.resources.libraries:
nexpaq 1:55a6170b404f 78 l, _ = splitext(basename(lib))
nexpaq 1:55a6170b404f 79 libraries.append(l[3:])
nexpaq 1:55a6170b404f 80
nexpaq 1:55a6170b404f 81 ctx = {
nexpaq 1:55a6170b404f 82 'name': self.project_name,
nexpaq 1:55a6170b404f 83 'include_paths': self.resources.inc_dirs,
nexpaq 1:55a6170b404f 84 'linker_script': self.resources.linker_script,
nexpaq 1:55a6170b404f 85 'library_paths': self.resources.lib_dirs,
nexpaq 1:55a6170b404f 86 'object_files': self.resources.objects,
nexpaq 1:55a6170b404f 87 'libraries': libraries,
nexpaq 1:55a6170b404f 88 'symbols': self.toolchain.get_symbols(),
nexpaq 1:55a6170b404f 89 'board_name': self.BOARDS[self.target.upper()]['name'],
nexpaq 1:55a6170b404f 90 'mcu_name': self.BOARDS[self.target.upper()]['mcuId'],
nexpaq 1:55a6170b404f 91 'debug_config_uid': self.__generate_uid(),
nexpaq 1:55a6170b404f 92 'debug_tool_compiler_uid': self.__generate_uid(),
nexpaq 1:55a6170b404f 93 'debug_tool_compiler_input_uid': self.__generate_uid(),
nexpaq 1:55a6170b404f 94 'release_config_uid': self.__generate_uid(),
nexpaq 1:55a6170b404f 95 'release_tool_compiler_uid': self.__generate_uid(),
nexpaq 1:55a6170b404f 96 'release_tool_compiler_input_uid': self.__generate_uid(),
nexpaq 1:55a6170b404f 97 'uid': self.__generate_uid()
nexpaq 1:55a6170b404f 98 }
nexpaq 1:55a6170b404f 99
nexpaq 1:55a6170b404f 100 self.__gen_dir('.settings')
nexpaq 1:55a6170b404f 101 self.gen_file('sw4stm32_language_settings_commom.tmpl', ctx, '.settings/language.settings.xml')
nexpaq 1:55a6170b404f 102 self.gen_file('sw4stm32_project_common.tmpl', ctx, '.project')
nexpaq 1:55a6170b404f 103 self.gen_file('sw4stm32_cproject_common.tmpl', ctx, '.cproject')