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