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
elessair 0:f269e3021894 20
elessair 0:f269e3021894 21 class CoIDE(Exporter):
elessair 0:f269e3021894 22 NAME = 'CoIDE'
elessair 0:f269e3021894 23 TOOLCHAIN = 'GCC_ARM'
elessair 0:f269e3021894 24
elessair 0:f269e3021894 25 TARGETS = [
elessair 0:f269e3021894 26 'KL25Z',
elessair 0:f269e3021894 27 'KL05Z',
elessair 0:f269e3021894 28 'LPC1768',
elessair 0:f269e3021894 29 'ARCH_PRO',
elessair 0:f269e3021894 30 'ARCH_MAX',
elessair 0:f269e3021894 31 'UBLOX_C027',
elessair 0:f269e3021894 32 'NUCLEO_L011K4',
elessair 0:f269e3021894 33 'NUCLEO_L053R8',
elessair 0:f269e3021894 34 'NUCLEO_L152RE',
elessair 0:f269e3021894 35 'NUCLEO_F030R8',
elessair 0:f269e3021894 36 'NUCLEO_F042K6',
elessair 0:f269e3021894 37 'NUCLEO_F070RB',
elessair 0:f269e3021894 38 'NUCLEO_F072RB',
elessair 0:f269e3021894 39 'NUCLEO_F091RC',
elessair 0:f269e3021894 40 'NUCLEO_F103RB',
elessair 0:f269e3021894 41 'NUCLEO_F207ZG',
elessair 0:f269e3021894 42 'NUCLEO_F302R8',
elessair 0:f269e3021894 43 'NUCLEO_F303K8',
elessair 0:f269e3021894 44 'NUCLEO_F303RE',
elessair 0:f269e3021894 45 'NUCLEO_F334R8',
elessair 0:f269e3021894 46 'NUCLEO_F303ZE',
elessair 0:f269e3021894 47 'NUCLEO_F401RE',
elessair 0:f269e3021894 48 'NUCLEO_F410RB',
elessair 0:f269e3021894 49 'NUCLEO_F411RE',
elessair 0:f269e3021894 50 'NUCLEO_F429ZI',
elessair 0:f269e3021894 51 'NUCLEO_F446RE',
elessair 0:f269e3021894 52 'NUCLEO_F446ZE',
elessair 0:f269e3021894 53 'DISCO_L053C8',
elessair 0:f269e3021894 54 'DISCO_F051R8',
elessair 0:f269e3021894 55 'DISCO_F100RB',
elessair 0:f269e3021894 56 'DISCO_F303VC',
elessair 0:f269e3021894 57 'DISCO_F334C8',
elessair 0:f269e3021894 58 'DISCO_F401VC',
elessair 0:f269e3021894 59 'DISCO_F407VG',
elessair 0:f269e3021894 60 'DISCO_F429ZI',
elessair 0:f269e3021894 61 'DISCO_F469NI',
elessair 0:f269e3021894 62 'MTS_MDOT_F405RG',
elessair 0:f269e3021894 63 'MTS_MDOT_F411RE',
elessair 0:f269e3021894 64 'MOTE_L152RC',
elessair 0:f269e3021894 65 'NZ32_SC151',
elessair 0:f269e3021894 66 ]
elessair 0:f269e3021894 67
elessair 0:f269e3021894 68 # seems like CoIDE currently supports only one type
elessair 0:f269e3021894 69 FILE_TYPES = {
elessair 0:f269e3021894 70 'c_sources':'1',
elessair 0:f269e3021894 71 'cpp_sources':'1',
elessair 0:f269e3021894 72 's_sources':'1'
elessair 0:f269e3021894 73 }
elessair 0:f269e3021894 74 FILE_TYPES2 = {
elessair 0:f269e3021894 75 'headers':'1'
elessair 0:f269e3021894 76 }
elessair 0:f269e3021894 77
elessair 0:f269e3021894 78 def generate(self):
elessair 0:f269e3021894 79 self.resources.win_to_unix()
elessair 0:f269e3021894 80 source_files = []
elessair 0:f269e3021894 81 for r_type, n in CoIDE.FILE_TYPES.iteritems():
elessair 0:f269e3021894 82 for file in getattr(self.resources, r_type):
elessair 0:f269e3021894 83 source_files.append({
elessair 0:f269e3021894 84 'name': basename(file), 'type': n, 'path': file
elessair 0:f269e3021894 85 })
elessair 0:f269e3021894 86 header_files = []
elessair 0:f269e3021894 87 for r_type, n in CoIDE.FILE_TYPES2.iteritems():
elessair 0:f269e3021894 88 for file in getattr(self.resources, r_type):
elessair 0:f269e3021894 89 header_files.append({
elessair 0:f269e3021894 90 'name': basename(file), 'type': n, 'path': file
elessair 0:f269e3021894 91 })
elessair 0:f269e3021894 92
elessair 0:f269e3021894 93 libraries = []
elessair 0:f269e3021894 94 for lib in self.resources.libraries:
elessair 0:f269e3021894 95 l, _ = splitext(basename(lib))
elessair 0:f269e3021894 96 libraries.append(l[3:])
elessair 0:f269e3021894 97
elessair 0:f269e3021894 98 if self.resources.linker_script is None:
elessair 0:f269e3021894 99 self.resources.linker_script = ''
elessair 0:f269e3021894 100
elessair 0:f269e3021894 101 ctx = {
elessair 0:f269e3021894 102 'name': self.project_name,
elessair 0:f269e3021894 103 'source_files': source_files,
elessair 0:f269e3021894 104 'header_files': header_files,
elessair 0:f269e3021894 105 'include_paths': self.resources.inc_dirs,
elessair 0:f269e3021894 106 'scatter_file': self.resources.linker_script,
elessair 0:f269e3021894 107 'library_paths': self.resources.lib_dirs,
elessair 0:f269e3021894 108 'object_files': self.resources.objects,
elessair 0:f269e3021894 109 'libraries': libraries,
elessair 0:f269e3021894 110 'symbols': self.toolchain.get_symbols()
elessair 0:f269e3021894 111 }
elessair 0:f269e3021894 112 target = self.target.lower()
elessair 0:f269e3021894 113
elessair 0:f269e3021894 114 # Project file
elessair 0:f269e3021894 115 self.gen_file('coide_%s.coproj.tmpl' % target, ctx, '%s.coproj' % self.project_name)