mbed os with nrf51 internal bandgap enabled to read battery level

Dependents:   BLE_file_test BLE_Blink ExternalEncoder

Committer:
elessair
Date:
Sun Oct 23 15:10:02 2016 +0000
Revision:
0:f269e3021894
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elessair 0:f269e3021894 1 """
elessair 0:f269e3021894 2 mbed SDK
elessair 0:f269e3021894 3 Copyright (c) 2014-2016 ARM Limited
elessair 0:f269e3021894 4
elessair 0:f269e3021894 5 Licensed under the Apache License, Version 2.0 (the "License");
elessair 0:f269e3021894 6 you may not use this file except in compliance with the License.
elessair 0:f269e3021894 7 You may obtain a copy of the License at
elessair 0:f269e3021894 8
elessair 0:f269e3021894 9 http://www.apache.org/licenses/LICENSE-2.0
elessair 0:f269e3021894 10
elessair 0:f269e3021894 11 Unless required by applicable law or agreed to in writing, software
elessair 0:f269e3021894 12 distributed under the License is distributed on an "AS IS" BASIS,
elessair 0:f269e3021894 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
elessair 0:f269e3021894 14 See the License for the specific language governing permissions and
elessair 0:f269e3021894 15 limitations under the License.
elessair 0:f269e3021894 16 """
elessair 0:f269e3021894 17 from exporters import Exporter
elessair 0:f269e3021894 18 from os.path import splitext, basename
elessair 0:f269e3021894 19 from tools.targets import TARGETS
elessair 0:f269e3021894 20
elessair 0:f269e3021894 21 # filter all the GCC_ARM targets out of the target list
elessair 0:f269e3021894 22 gccTargets = []
elessair 0:f269e3021894 23 for t in TARGETS:
elessair 0:f269e3021894 24 if 'GCC_ARM' in t.supported_toolchains:
elessair 0:f269e3021894 25 gccTargets.append(t.name)
elessair 0:f269e3021894 26
elessair 0:f269e3021894 27 class IntermediateFile(Exporter):
elessair 0:f269e3021894 28 NAME = 'EmBlocks'
elessair 0:f269e3021894 29 TOOLCHAIN = 'GCC_ARM'
elessair 0:f269e3021894 30
elessair 0:f269e3021894 31 # we support all GCC targets (is handled on IDE side)
elessair 0:f269e3021894 32 TARGETS = gccTargets
elessair 0:f269e3021894 33
elessair 0:f269e3021894 34 MBED_CONFIG_HEADER_SUPPORTED = True
elessair 0:f269e3021894 35
elessair 0:f269e3021894 36 FILE_TYPES = {
elessair 0:f269e3021894 37 'headers': 'h',
elessair 0:f269e3021894 38 'c_sources': 'c',
elessair 0:f269e3021894 39 's_sources': 'a',
elessair 0:f269e3021894 40 'cpp_sources': 'cpp'
elessair 0:f269e3021894 41 }
elessair 0:f269e3021894 42
elessair 0:f269e3021894 43
elessair 0:f269e3021894 44 def generate(self):
elessair 0:f269e3021894 45 self.resources.win_to_unix()
elessair 0:f269e3021894 46 source_files = []
elessair 0:f269e3021894 47 for r_type, n in IntermediateFile.FILE_TYPES.iteritems():
elessair 0:f269e3021894 48 for file in getattr(self.resources, r_type):
elessair 0:f269e3021894 49 source_files.append({
elessair 0:f269e3021894 50 'name': file, 'type': n
elessair 0:f269e3021894 51 })
elessair 0:f269e3021894 52
elessair 0:f269e3021894 53 libraries = []
elessair 0:f269e3021894 54 for lib in self.resources.libraries:
elessair 0:f269e3021894 55 l, _ = splitext(basename(lib))
elessair 0:f269e3021894 56 libraries.append(l[3:])
elessair 0:f269e3021894 57
elessair 0:f269e3021894 58
elessair 0:f269e3021894 59 if self.resources.linker_script is None:
elessair 0:f269e3021894 60 self.resources.linker_script = ''
elessair 0:f269e3021894 61
elessair 0:f269e3021894 62 ctx = {
elessair 0:f269e3021894 63 'name': self.project_name,
elessair 0:f269e3021894 64 'target': self.target,
elessair 0:f269e3021894 65 'toolchain': self.toolchain.name,
elessair 0:f269e3021894 66 'source_files': source_files,
elessair 0:f269e3021894 67 'include_paths': self.resources.inc_dirs,
elessair 0:f269e3021894 68 'script_file': self.resources.linker_script,
elessair 0:f269e3021894 69 'library_paths': self.resources.lib_dirs,
elessair 0:f269e3021894 70 'libraries': libraries,
elessair 0:f269e3021894 71 'symbols': self.toolchain.get_symbols(),
elessair 0:f269e3021894 72 'object_files': self.resources.objects,
elessair 0:f269e3021894 73 'sys_libs': self.toolchain.sys_libs,
elessair 0:f269e3021894 74 'cc_org': self.flags['common_flags'] + self.flags['c_flags'],
elessair 0:f269e3021894 75 'ld_org': self.flags['common_flags'] + self.flags['ld_flags'],
elessair 0:f269e3021894 76 'cppc_org': self.flags['common_flags'] + self.flags['cxx_flags']
elessair 0:f269e3021894 77 }
elessair 0:f269e3021894 78
elessair 0:f269e3021894 79 # EmBlocks intermediate file template
elessair 0:f269e3021894 80 self.gen_file('emblocks.eix.tmpl', ctx, '%s.eix' % self.project_name)