Development mbed library for MAX32630FTHR
Dependents: blinky_max32630fthr
tools/export/sw4stm32.py@3:1198227e6421, 2016-12-16 (annotated)
- Committer:
- switches
- Date:
- Fri Dec 16 16:27:57 2016 +0000
- Revision:
- 3:1198227e6421
- Parent:
- 0:5c4d7b2438d3
Changed ADC scale for MAX32625 platforms to 1.2V full scale to match MAX32630 platforms
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
switches | 0:5c4d7b2438d3 | 1 | """ |
switches | 0:5c4d7b2438d3 | 2 | mbed SDK |
switches | 0:5c4d7b2438d3 | 3 | Copyright (c) 2011-2016 ARM Limited |
switches | 0:5c4d7b2438d3 | 4 | |
switches | 0:5c4d7b2438d3 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); |
switches | 0:5c4d7b2438d3 | 6 | you may not use this file except in compliance with the License. |
switches | 0:5c4d7b2438d3 | 7 | You may obtain a copy of the License at |
switches | 0:5c4d7b2438d3 | 8 | |
switches | 0:5c4d7b2438d3 | 9 | http://www.apache.org/licenses/LICENSE-2.0 |
switches | 0:5c4d7b2438d3 | 10 | |
switches | 0:5c4d7b2438d3 | 11 | Unless required by applicable law or agreed to in writing, software |
switches | 0:5c4d7b2438d3 | 12 | distributed under the License is distributed on an "AS IS" BASIS, |
switches | 0:5c4d7b2438d3 | 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
switches | 0:5c4d7b2438d3 | 14 | See the License for the specific language governing permissions and |
switches | 0:5c4d7b2438d3 | 15 | limitations under the License. |
switches | 0:5c4d7b2438d3 | 16 | """ |
switches | 0:5c4d7b2438d3 | 17 | from exporters import Exporter |
switches | 0:5c4d7b2438d3 | 18 | from os.path import splitext, basename, join |
switches | 0:5c4d7b2438d3 | 19 | from random import randint |
switches | 0:5c4d7b2438d3 | 20 | from tools.utils import mkdir |
switches | 0:5c4d7b2438d3 | 21 | |
switches | 0:5c4d7b2438d3 | 22 | |
switches | 0:5c4d7b2438d3 | 23 | class Sw4STM32(Exporter): |
switches | 0:5c4d7b2438d3 | 24 | NAME = 'Sw4STM32' |
switches | 0:5c4d7b2438d3 | 25 | TOOLCHAIN = 'GCC_ARM' |
switches | 0:5c4d7b2438d3 | 26 | |
switches | 0:5c4d7b2438d3 | 27 | BOARDS = { |
switches | 0:5c4d7b2438d3 | 28 | 'B96B_F446VE': {'name': 'B96B-F446VE', 'mcuId': 'STM32F446VETx'}, |
switches | 0:5c4d7b2438d3 | 29 | 'DISCO_F051R8': {'name': 'STM32F0DISCOVERY', 'mcuId': 'STM32F051R8Tx'}, |
switches | 0:5c4d7b2438d3 | 30 | 'DISCO_F303VC': {'name': 'STM32F3DISCOVERY', 'mcuId': 'STM32F303VCTx'}, |
switches | 0:5c4d7b2438d3 | 31 | 'DISCO_F334C8': {'name': 'STM32F3348DISCOVERY', 'mcuId': 'STM32F334C8Tx'}, |
switches | 0:5c4d7b2438d3 | 32 | 'DISCO_F401VC': {'name': 'STM32F401C-DISCO', 'mcuId': 'STM32F401VCTx'}, |
switches | 0:5c4d7b2438d3 | 33 | 'DISCO_F407VG': {'name': 'STM32F4DISCOVERY', 'mcuId': 'STM32F407VGTx'}, |
switches | 0:5c4d7b2438d3 | 34 | 'DISCO_F429ZI': {'name': 'STM32F429I-DISCO', 'mcuId': 'STM32F429ZITx'}, |
switches | 0:5c4d7b2438d3 | 35 | 'DISCO_F469NI': {'name': 'DISCO-F469NI', 'mcuId': 'STM32F469NIHx'}, |
switches | 0:5c4d7b2438d3 | 36 | 'DISCO_F746NG': {'name': 'STM32F746G-DISCO', 'mcuId': 'STM32F746NGHx'}, |
switches | 0:5c4d7b2438d3 | 37 | 'DISCO_F769NI': {'name': 'DISCO-F769NI', 'mcuId': 'STM32F769NIHx'}, |
switches | 0:5c4d7b2438d3 | 38 | 'DISCO_L053C8': {'name': 'STM32L0538DISCOVERY', 'mcuId': 'STM32L053C8Tx'}, |
switches | 0:5c4d7b2438d3 | 39 | 'DISCO_L476VG': {'name': 'STM32L476G-DISCO', 'mcuId': 'STM32L476VGTx'}, |
switches | 0:5c4d7b2438d3 | 40 | 'NUCLEO_F030R8': {'name': 'NUCLEO-F030R8', 'mcuId': 'STM32F030R8Tx'}, |
switches | 0:5c4d7b2438d3 | 41 | 'NUCLEO_F031K6': {'name': 'NUCLEO-F031K6', 'mcuId': 'STM32F031K6Tx'}, |
switches | 0:5c4d7b2438d3 | 42 | 'NUCLEO_F042K6': {'name': 'NUCLEO-F042K6', 'mcuId': 'STM32F042K6Tx'}, |
switches | 0:5c4d7b2438d3 | 43 | 'NUCLEO_F070RB': {'name': 'NUCLEO-F070RB', 'mcuId': 'STM32F070RBTx'}, |
switches | 0:5c4d7b2438d3 | 44 | 'NUCLEO_F072RB': {'name': 'NUCLEO-F072RB', 'mcuId': 'STM32F072RBTx'}, |
switches | 0:5c4d7b2438d3 | 45 | 'NUCLEO_F091RC': {'name': 'NUCLEO-F091RC', 'mcuId': 'STM32F091RCTx'}, |
switches | 0:5c4d7b2438d3 | 46 | 'NUCLEO_F103RB': {'name': 'NUCLEO-F103RB', 'mcuId': 'STM32F103RBTx'}, |
switches | 0:5c4d7b2438d3 | 47 | 'NUCLEO_F207ZG': {'name': 'NUCLEO-F207ZG', 'mcuId': 'STM32F207ZGTx'}, |
switches | 0:5c4d7b2438d3 | 48 | 'NUCLEO_F302R8': {'name': 'NUCLEO-F302R8', 'mcuId': 'STM32F302R8Tx'}, |
switches | 0:5c4d7b2438d3 | 49 | 'NUCLEO_F303K8': {'name': 'NUCLEO-F303K8', 'mcuId': 'STM32F303K8Tx'}, |
switches | 0:5c4d7b2438d3 | 50 | 'NUCLEO_F303RE': {'name': 'NUCLEO-F303RE', 'mcuId': 'STM32F303RETx'}, |
switches | 0:5c4d7b2438d3 | 51 | 'NUCLEO_F303ZE': {'name': 'NUCLEO-F303ZE', 'mcuId': 'STM32F303ZETx'}, |
switches | 0:5c4d7b2438d3 | 52 | 'NUCLEO_F334R8': {'name': 'NUCLEO-F334R8', 'mcuId': 'STM32F334R8Tx'}, |
switches | 0:5c4d7b2438d3 | 53 | 'NUCLEO_F401RE': {'name': 'NUCLEO-F401RE', 'mcuId': 'STM32F401RETx'}, |
switches | 0:5c4d7b2438d3 | 54 | 'NUCLEO_F410RB': {'name': 'NUCLEO-F410RB', 'mcuId': 'STM32F410RBTx'}, |
switches | 0:5c4d7b2438d3 | 55 | 'NUCLEO_F411RE': {'name': 'NUCLEO-F411RE', 'mcuId': 'STM32F411RETx'}, |
switches | 0:5c4d7b2438d3 | 56 | 'NUCLEO_F429ZI': {'name': 'NUCLEO-F429ZI', 'mcuId': 'STM32F429ZITx'}, |
switches | 0:5c4d7b2438d3 | 57 | 'NUCLEO_F446RE': {'name': 'NUCLEO-F446RE', 'mcuId': 'STM32F446RETx'}, |
switches | 0:5c4d7b2438d3 | 58 | 'NUCLEO_F446ZE': {'name': 'NUCLEO-F446ZE', 'mcuId': 'STM32F446ZETx'}, |
switches | 0:5c4d7b2438d3 | 59 | 'NUCLEO_F746ZG': {'name': 'NUCLEO-F746ZG', 'mcuId': 'STM32F746ZGTx'}, |
switches | 0:5c4d7b2438d3 | 60 | 'NUCLEO_F767ZI': {'name': 'NUCLEO-F767ZI', 'mcuId': 'STM32F767ZITx'}, |
switches | 0:5c4d7b2438d3 | 61 | 'NUCLEO_L011K4': {'name': 'NUCLEO-L011K4', 'mcuId': 'STM32L011K4Tx'}, |
switches | 0:5c4d7b2438d3 | 62 | 'NUCLEO_L031K6': {'name': 'NUCLEO-L031K6', 'mcuId': 'STM32L031K6Tx'}, |
switches | 0:5c4d7b2438d3 | 63 | 'NUCLEO_L053R8': {'name': 'NUCLEO-L053R8', 'mcuId': 'STM32L053R8Tx'}, |
switches | 0:5c4d7b2438d3 | 64 | 'NUCLEO_L073RZ': {'name': 'NUCLEO-L073RZ', 'mcuId': 'STM32L073RZTx'}, |
switches | 0:5c4d7b2438d3 | 65 | 'NUCLEO_L152RE': {'name': 'NUCLEO-L152RE', 'mcuId': 'STM32L152RETx'}, |
switches | 0:5c4d7b2438d3 | 66 | 'NUCLEO_L432KC': {'name': 'NUCLEO-L432KC', 'mcuId': 'STM32L432KCUx'}, |
switches | 0:5c4d7b2438d3 | 67 | 'NUCLEO_L476RG': {'name': 'NUCLEO-L476RG', 'mcuId': 'STM32L476RGTx'}, |
switches | 0:5c4d7b2438d3 | 68 | } |
switches | 0:5c4d7b2438d3 | 69 | |
switches | 0:5c4d7b2438d3 | 70 | TARGETS = BOARDS.keys() |
switches | 0:5c4d7b2438d3 | 71 | |
switches | 0:5c4d7b2438d3 | 72 | def __gen_dir(self, dirname): |
switches | 0:5c4d7b2438d3 | 73 | settings = join(self.export_dir, dirname) |
switches | 0:5c4d7b2438d3 | 74 | mkdir(settings) |
switches | 0:5c4d7b2438d3 | 75 | |
switches | 0:5c4d7b2438d3 | 76 | def __generate_uid(self): |
switches | 0:5c4d7b2438d3 | 77 | return "%0.9u" % randint(0, 999999999) |
switches | 0:5c4d7b2438d3 | 78 | |
switches | 0:5c4d7b2438d3 | 79 | def generate(self): |
switches | 0:5c4d7b2438d3 | 80 | fp_hardware = "no" |
switches | 0:5c4d7b2438d3 | 81 | fp_abi = "soft" |
switches | 0:5c4d7b2438d3 | 82 | core = self.toolchain.target.core |
switches | 0:5c4d7b2438d3 | 83 | if core == "Cortex-M4F" or core == "Cortex-M7F": |
switches | 0:5c4d7b2438d3 | 84 | fp_hardware = "fpv4-sp-d16" |
switches | 0:5c4d7b2438d3 | 85 | fp_abi = "soft-fp" |
switches | 0:5c4d7b2438d3 | 86 | elif core == "Cortex-M7FD": |
switches | 0:5c4d7b2438d3 | 87 | fp_hardware = "fpv5-d16" |
switches | 0:5c4d7b2438d3 | 88 | fp_abi = "soft-fp" |
switches | 0:5c4d7b2438d3 | 89 | |
switches | 0:5c4d7b2438d3 | 90 | libraries = [] |
switches | 0:5c4d7b2438d3 | 91 | for lib in self.resources.libraries: |
switches | 0:5c4d7b2438d3 | 92 | l, _ = splitext(basename(lib)) |
switches | 0:5c4d7b2438d3 | 93 | libraries.append(l[3:]) |
switches | 0:5c4d7b2438d3 | 94 | |
switches | 0:5c4d7b2438d3 | 95 | ctx = { |
switches | 0:5c4d7b2438d3 | 96 | 'name': self.project_name, |
switches | 0:5c4d7b2438d3 | 97 | 'include_paths': self.resources.inc_dirs, |
switches | 0:5c4d7b2438d3 | 98 | 'linker_script': self.resources.linker_script, |
switches | 0:5c4d7b2438d3 | 99 | 'library_paths': self.resources.lib_dirs, |
switches | 0:5c4d7b2438d3 | 100 | 'object_files': self.resources.objects, |
switches | 0:5c4d7b2438d3 | 101 | 'libraries': libraries, |
switches | 0:5c4d7b2438d3 | 102 | 'symbols': self.toolchain.get_symbols(), |
switches | 0:5c4d7b2438d3 | 103 | 'board_name': self.BOARDS[self.target.upper()]['name'], |
switches | 0:5c4d7b2438d3 | 104 | 'mcu_name': self.BOARDS[self.target.upper()]['mcuId'], |
switches | 0:5c4d7b2438d3 | 105 | 'debug_config_uid': self.__generate_uid(), |
switches | 0:5c4d7b2438d3 | 106 | 'debug_tool_compiler_uid': self.__generate_uid(), |
switches | 0:5c4d7b2438d3 | 107 | 'debug_tool_compiler_input_uid': self.__generate_uid(), |
switches | 0:5c4d7b2438d3 | 108 | 'release_config_uid': self.__generate_uid(), |
switches | 0:5c4d7b2438d3 | 109 | 'release_tool_compiler_uid': self.__generate_uid(), |
switches | 0:5c4d7b2438d3 | 110 | 'release_tool_compiler_input_uid': self.__generate_uid(), |
switches | 0:5c4d7b2438d3 | 111 | 'uid': self.__generate_uid(), |
switches | 0:5c4d7b2438d3 | 112 | 'floating_point_hardware': fp_hardware, |
switches | 0:5c4d7b2438d3 | 113 | 'floating_point_abi': fp_abi |
switches | 0:5c4d7b2438d3 | 114 | } |
switches | 0:5c4d7b2438d3 | 115 | |
switches | 0:5c4d7b2438d3 | 116 | self.__gen_dir('.settings') |
switches | 0:5c4d7b2438d3 | 117 | self.gen_file('sw4stm32_language_settings_commom.tmpl', ctx, '.settings/language.settings.xml') |
switches | 0:5c4d7b2438d3 | 118 | self.gen_file('sw4stm32_project_common.tmpl', ctx, '.project') |
switches | 0:5c4d7b2438d3 | 119 | self.gen_file('sw4stm32_cproject_common.tmpl', ctx, '.cproject') |