]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/workspace_tools/export/uvision4.py
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / workspace_tools / export / uvision4.py
1 """
2 mbed SDK
3 Copyright (c) 2011-2013 ARM Limited
4
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
8
9     http://www.apache.org/licenses/LICENSE-2.0
10
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
16 """
17 from exporters import Exporter
18 from os.path import basename
19
20
21 class Uvision4(Exporter):
22     NAME = 'uVision4'
23
24     TARGETS = [
25         'LPC1768',
26         'LPC11U24',
27         'KL05Z',
28         'KL25Z',
29         'KL43Z',
30         'KL46Z',
31         'K64F',
32         'K22F',
33         'K20D50M',
34         'TEENSY3_1',
35         'LPC1347',
36         'LPC1114',
37         'LPC11C24',
38         'LPC4088',
39         'LPC4088_DM',
40         'LPC4330_M4',
41         'LPC4337',
42         'LPC812',
43         'NUCLEO_F030R8',
44         'NUCLEO_F070RB',
45         'NUCLEO_F072RB',
46         'NUCLEO_F091RC',
47         'NUCLEO_F103RB',
48         'NUCLEO_F302R8',
49         'NUCLEO_F303RE',
50         'NUCLEO_F334R8',
51         'NUCLEO_F401RE',
52         'NUCLEO_F411RE',
53         'NUCLEO_L053R8',
54         'NUCLEO_L073RZ',
55         'NUCLEO_L152RE',
56         'UBLOX_C027',
57         'LPC1549',
58         'LPC11U68',
59         # Removed as uvision4_lpc11u35_501.uvproj.tmpl is missing.
60         #'LPC11U35_501',
61         'NRF51822',
62         'HRM1017',
63         'RBLAB_NRF51822',
64         'ARCH_PRO',
65         'ARCH_BLE',
66         'DISCO_F407VG',
67         'DISCO_L053C8',
68         'MTS_GAMBIT',
69         'ARCH_MAX',
70         'MTS_MDOT_F405RG',
71         'NRF51_DK',
72         'NRF51_DONGLE',
73         'SEEED_TINY_BLE',
74         'LPC11U37H_401',
75         'DELTA_DFCM_NNN40',
76         'MAXWSNENV',
77         'MAX32600MBED',
78         'MOTE_L152RC',
79     ]
80
81     USING_MICROLIB = [
82         'LPC11U24',
83         'LPC1114',
84         'LPC11C24',
85         'LPC812',
86         'NUCLEO_F030R8',
87         'NUCLEO_F070RB',
88         'NUCLEO_F072RB',
89         'NUCLEO_F091RC',
90         'NUCLEO_F103RB',
91         'NUCLEO_F302R8',
92         'NUCLEO_F303RE',
93         'NUCLEO_F334R8',
94         'NUCLEO_F401RE',
95         'NUCLEO_F411RE',
96         'NUCLEO_L053R8',
97         'NUCLEO_L073RZ',
98         'NUCLEO_L152RE',
99         'LPC1549',
100         'LPC11U68',
101         'LPC11U35_501',
102         'KL05Z',
103         'LPC11U37H_401',
104         'MOTE_L152RC',
105     ]
106
107     FILE_TYPES = {
108         'c_sources':'1',
109         'cpp_sources':'8',
110         's_sources':'2'
111     }
112
113     FLAGS = [
114         "--gnu", "--no_rtti",
115     ]
116
117     # By convention uVision projects do not show header files in the editor:
118     # 'headers':'5',
119
120     def get_toolchain(self):
121         return 'uARM' if (self.target in self.USING_MICROLIB) else 'ARM'
122
123     def get_flags(self):
124         return self.FLAGS
125
126     def generate(self):
127         source_files = {
128             'mbed': [],
129             'hal': [],
130             'src': []
131         }
132         for r_type, n in Uvision4.FILE_TYPES.iteritems():
133             for file in getattr(self.resources, r_type):
134                 f = {'name': basename(file), 'type': n, 'path': file}
135                 if file.startswith("mbed\\common"):
136                     source_files['mbed'].append(f)
137                 elif file.startswith("mbed\\targets"):
138                     source_files['hal'].append(f)
139                 else:
140                     source_files['src'].append(f)
141         source_files = dict( [(k,v) for k,v in source_files.items() if len(v)>0])
142         ctx = {
143             'name': self.program_name,
144             'include_paths': self.resources.inc_dirs,
145             'scatter_file': self.resources.linker_script,
146             'object_files': self.resources.objects + self.resources.libraries,
147             'source_files': source_files.items(),
148             'symbols': self.get_symbols() + ['__ASSERT_MSG'],
149             'hex_files' : self.resources.hex_files,
150             'flags' : self.get_flags(),
151         }
152         target = self.target.lower()
153         # Project file
154         self.gen_file('uvision4_%s.uvproj.tmpl' % target, ctx, '%s.uvproj' % self.program_name)
155         self.gen_file('uvision4_%s.uvopt.tmpl' % target, ctx, '%s.uvopt' % self.program_name)