Project

General

Profile

[Resolved] Modify MCU pin options » stm32f4_getlist.m

Krisada Sangpetchsong (เอม), 24 Nov 2019 08:59

 
1
function setting = stm32f4_getlist ()
2

    
3
setting = [];
4
mcu_list = [];
5
mcu_list.list = [];
6

    
7
setting.devices = [];
8
setting.list = [];
9

    
10
% Define MCU support list
11
DEVICES_LIST = {...
12
	'STM32F401CBU',...
13
	'STM32F401CCU',...
14
	'STM32F401CDU',...
15
	'STM32F401CEU',...
16
	'STM32F401RBT',...
17
	'STM32F401RCT',...
18
	'STM32F401RDT',...
19
	'STM32F401RET',...
20
	'STM32F401VBT',...
21
	'STM32F401VCT',...
22
	'STM32F401VDT',...
23
	'STM32F401VET',...
24
	...
25
	'STM32F405OEY',...
26
	'STM32F405OGY',...
27
	'STM32F405RGT',...
28
	'STM32F405VGT',...
29
	'STM32F405ZGT',...
30
	'STM32F407IET',...
31
	'STM32F407IGT',...
32
	'STM32F407VET',...
33
	'STM32F407VGT',...
34
	'STM32F407ZET',...
35
	'STM32F407ZGT',...
36
	...
37
	'STM32F415OGY',...
38
	'STM32F415RGT',...
39
	'STM32F415VGT',...
40
	'STM32F415ZGT',...
41
	'STM32F417IET',...
42
	'STM32F417IGT',...
43
	'STM32F417VET',...
44
	'STM32F417VGT',...
45
	'STM32F417ZET',...
46
	'STM32F417ZGT',...
47
	...
48
	'STM32F410C8U',...
49
	'STM32F410CBT',...
50
	'STM32F410R8T',...
51
	'STM32F410RBT',...
52
	'STM32F410T8Y',...
53
	'STM32F410TBY',...
54
	'STM32F411CCU',...
55
	'STM32F411CEU',...
56
	'STM32F411RCT',...
57
	'STM32F411RET',...
58
	'STM32F411VCT',...
59
	'STM32F411VET',...
60
	'STM32F412CEU',...
61
	'STM32F412CGU',...
62
	'STM32F412RET',...
63
	'STM32F412RGT',...
64
	'STM32F412VET',...
65
	'STM32F412VGT',...
66
	'STM32F412ZET',...
67
	'STM32F412ZGT',...
68
	...
69
	'STM32F427AGH',...
70
	'STM32F427AIH',...
71
	'STM32F427IGH',...
72
	'STM32F427IIH',...
73
	'STM32F427VGT',...
74
	'STM32F427VIT',...
75
	'STM32F427ZGT',...
76
	'STM32F427ZIT',...
77
	'STM32F429AGH',...
78
	'STM32F429AIH',...
79
	'STM32F429BET',...
80
	'STM32F429BGT',...
81
	'STM32F429BIT',...
82
	'STM32F429IEH',...
83
	'STM32F429IGH',...
84
	'STM32F429IIH',...
85
	'STM32F429NEH',...
86
	'STM32F429NGH',...
87
	'STM32F429NIH',...
88
	'STM32F429VET',...
89
	'STM32F429VGT',...
90
	'STM32F429VIT',...
91
	'STM32F429ZET',...
92
	'STM32F429ZGT',...
93
	'STM32F429ZIT',...
94
	'STM32F437AIH',...
95
	'STM32F437IGH',...
96
	'STM32F437IIH',...
97
	'STM32F437VGT',...
98
	'STM32F437VIT',...
99
	'STM32F437ZGT',...
100
	'STM32F437ZIT',...
101
	'STM32F439AIH',...
102
	'STM32F439BGT',...
103
	'STM32F439BIT',...
104
	'STM32F439IGH',...
105
	'STM32F439IIH',...
106
	'STM32F439NGH',...
107
	'STM32F439NIH',...
108
	'STM32F439VGT',...
109
	'STM32F439VIT',...
110
	'STM32F439ZGT',...
111
	'STM32F439ZIT',...
112
	'STM32F446MCY',...
113
	'STM32F446MEY',...
114
	'STM32F446RCT',...
115
	'STM32F446RET',...
116
	'STM32F446VCT',...
117
	'STM32F446VET',...
118
	'STM32F446ZCT',...
119
	'STM32F446ZET',...
120
	'STM32F469AEH',...
121
	'STM32F469AGH',...
122
	'STM32F469AIH',...
123
	'STM32F469BET',...
124
	'STM32F469BGT',...
125
	'STM32F469BIT',...
126
	'STM32F469IEH',...
127
	'STM32F469IGH',...
128
	'STM32F469IIH',...
129
	'STM32F469NEH',...
130
	'STM32F469NGH',...
131
	'STM32F469NIH',...
132
	'STM32F469VIT',...
133
	'STM32F469ZIT',...
134
	'STM32F479AGH',...
135
	'STM32F479AIH',...
136
	'STM32F479BGT',...
137
	'STM32F479BIT',...
138
	'STM32F479IGH',...
139
	'STM32F479IIT',...
140
	'STM32F479NGH',...
141
	'STM32F479NIH',...
142
	'STM32F479VIT',...
143
	'STM32F479ZIT'...
144
	};
145

    
146
PACKAGE_LIST = {...
147
	'WLCSP36',...
148
	'UFQFPN48',...
149
	'LQFP48',...
150
	'LQFP64',...
151
	'WLCSP81',...
152
	'WLCSP90',...
153
	'LQFP100',...
154
	'LQFP144',...
155
	'BGA169',...
156
	'BGA168',...
157
	'UFBGA169',...
158
	'WLCSP168',...
159
	'BGA176',...
160
	'UFBGA176',...
161
	'LQFP176',...
162
	'LQFP208',...
163
	'BGA216'...
164
	};
165

    
166
% MCU package list
167
setting.pkg = [];
168
setting.pkg.WLCSP36 = [];
169
setting.pkg.UFQFPN48 = [];
170
setting.pkg.LQFP48 = [];
171
setting.pkg.LQFP64 = [];
172
setting.pkg.WLCSP81 = [];
173
setting.pkg.WLCSP90 = [];
174
setting.pkg.LQFP100 = [];
175
setting.pkg.LQFP144 = [];
176
setting.pkg.BGA169 = [];
177
setting.pkg.BGA168 = [];
178
setting.pkg.UFBGA169 = [];
179
setting.pkg.WLCSP168 = [];
180
setting.pkg.BGA176 = [];
181
setting.pkg.UFBGA176 = [];
182
setting.pkg.LQFP176 = [];
183
setting.pkg.LQFP208 = [];
184
setting.pkg.BGA216 = [];
185

    
186
% I/O pin available for each package
187
% = WLCSP36 =
188
setting.pkg.WLCSP36.IO = {...
189
	'C13','C14','C15','H0','H1','A0','A2','A3','A5',...
190
	'C4','B2','B10','B12',...
191
	'A8','A12','A13','A14','A15','B3','B4','B5','B6',...
192
	'B7','B8','B9'};
193
% = UFQFPN48 =
194
setting.pkg.UFQFPN48.IO = {...
195
	'C13','C14','C15','H0','H1','A0','A1','A2','A3','A4','A5','A6',...
196
	'A7','C4','B0','B1','B2','B10','B12','B13','B14','B15',...
197
	'A8','A9','A10','A11','A12','A13','A14','A15','B3','B4','B5','B6',...
198
	'B7','B8','B9'};
199
% = UFQFPN48 =
200
setting.pkg.LQFP48.IO = {...
201
	'C13','C14','C15','H0','H1','A0','A1','A2','A3','A4','A5','A6',...
202
	'A7','C4','B0','B1','B2','B10','B12','B13','B14','B15',...
203
	'A8','A9','A10','A11','A12','A13','A14','A15','B3','B4','B5','B6',...
204
	'B7','B8','B9'};
205
% = LQFP64 =
206
setting.pkg.LQFP64.IO = {...
207
	'C13','C14','C15','H0','H1','C0','C1','C2','C3','A0','A1','A2','A3','A4','A5','A6',...
208
	'A7','C4','C5','B0','B1','B2','B10','B11','B12','B13','B14','B15','C6','C7','C8','C9',...
209
	'A8','A9','A10','A11','A12','A13','A14','A15','C10','C11','C12','D2','B3','B4','B5','B6',...
210
	'B7','B8','B9'};
211
% = WLCSP81 =
212
setting.pkg.WLCSP81.IO = {...
213
	'E2','E3','E4','C13','C14','C15','H0','H1','C0','C2','C3','A0','A1',...
214
	'A2','A3','A4','A5','A6','A7','C4','B0','B1','B2','E7','E8','E9','E10',...
215
	'B10','B12','B13','B14','B15','D11','D12','D13',...
216
	'C6','C7','C8','C9','A8','A9','A10','A11','A12','A13','A14','A15','C10','C11',...
217
	'C12','D0','D1','D2','D4','D6','D7','B3','B4','B5','B6','B7','B8','B9'};
218
% = WLCSP90 =
219
setting.pkg.WLCSP90.IO = {...
220
	'C13','C14','C15','H0','H1','C0','C2','C3','A0','A1','A2','A3','A4','A5','A6','A7',...
221
	'B0','B1','B2','E7','E8','E9','E10','E11','E12','E13','E14','E15','B10','B11','B12','B13',...
222
	'B14','B15','D8','D9','D10','D11','D12','D14','D15','C6','C7','C8','C9','A8','A9','A10',...
223
	'A11','A12','A13','I0','I1','A14','A15','C10','C11','C12','D0','D1','D2','D4','D5','D6',...
224
	'D7','B3','B4','B5','B6','B7','B8','B9'};
225
% = LQFP100 =
226
setting.pkg.LQFP100.IO = {...
227
	'E2','E3','E4','E5','E6','C13','C14','C15','H0','H1','C0','C1','C2','C3','A0','A1',...
228
	'A2','A3','A4','A5','A6','A7','C4','C5','B0','B1','B2','E7','E8','E9','E10','E11',...
229
	'E12','E13','E14','E15','B10','B11','B12','B13','B14','B15','D8','D9','D10','D11','D12','D13',...
230
	'D14','D15','C6','C7','C8','C9','A8','A9','A10','A11','A12','A13','A14','A15','C10','C11',...
231
	'C12','D0','D1','D2','D3','D4','D5','D6','D7','B3','B4','B5','B6','B7','B8','B9',...
232
	'E0','E1'};
233
% = LQFP144 =
234
setting.pkg.LQFP144.IO = {...
235
	'E2','E3','E4','E5','E6','C13','C14','C15','F0','F1','F2','F3','F4','F5','F6','F7',...
236
	'F8','F9','F10','H0','H1','C0','C1','C2','C3','A0','A1','A2','A3','A4','A5','A6',...
237
	'A7','C4','C5','B0','B1','B2','F11','F12','F13','F14','F15','G0','G1','E7','E8','E9',...
238
	'E10','E11','E12','E13','E14','E15','B10','B11','B12','B13','B14','B15','D8','D9','D10','D11',...
239
	'D12','D13','D14','D15','G2','G3','G4','G5','G6','G7','G8','C6','C7','C8','C9','A8',...
240
	'A9','A10','A11','A12','A13','A14','A15','C10','C11','C12','D0','D1','D2','D3','D4','D5',...
241
	'D6','D7','G9','G10','G11','G12','G13','G14','G15','B3','B4','B5','B6','B7','B8','B9',...
242
	'E0','E1'};
243
% = BGA169 =
244
setting.pkg.BGA169.IO = {...
245
	'E2','E3','E4','E5','E6','C13','C14','C15','I9','I10','F0','F1','F2','F3',...
246
	'F4','F5','F10','H0','H1','C0','C1','C2','C3','A0','A1','A2',...
247
	'H2','H3','H4','H5','A3','A4','A5','A6','A7','C4','C5','B0','B1','B2','F11','F12',...
248
	'F13','F14','F15','G0','G1','E7','E8','E9','E10','E11','E12','E13','E14','E15','B10','B11',...
249
	'H6','H7','H8','H9','H10','H11','H12','B12','B13','B14','B15','D8','D9','D10','D11','D12',...
250
	'D13','D14','D15','G2','G4','G5','G6','G7','G8','C6','C7','C8','C9','A8','A9',...
251
	'A10','A11','A12','A13','H13','H14','H15','I0','I1','I2','I3','A14','A15','C10','C11','C12',...
252
	'D0','D1','D2','D3','D4','D5','D6','D7','G10','G11','G12','G15','B3',...
253
	'B4','B5','B6','B7','B8','B9','E0','E1','I4','I5','I6','I7'};
254
% = BGA168 =
255
setting.pkg.BGA168.IO = setting.pkg.BGA169.IO;
256
% = UFBGA169 =
257
setting.pkg.UFBGA169.IO = setting.pkg.BGA169.IO;
258
% = WLCSP168 =
259
setting.pkg.WLCSP168.IO = setting.pkg.BGA169.IO;
260
% = BGA176 =
261
setting.pkg.BGA176.IO = {...
262
	'E2','E3','E4','E5','E6','I8','C13','C14','C15','I9','I10','I11','F0','F1','F2','F3',...
263
	'F4','F5','F6','F7','F8','F9','F10','H0','H1','C0','C1','C2','C3','A0','A1','A2',...
264
	'H2','H3','H4','H5','A3','A4','A5','A6','A7','C4','C5','B0','B1','B2','F11','F12',...
265
	'F13','F14','F15','G0','G1','E7','E8','E9','E10','E11','E12','E13','E14','E15','B10','B11',...
266
	'H6','H7','H8','H9','H10','H11','H12','B12','B13','B14','B15','D8','D9','D10','D11','D12',...
267
	'D13','D14','D15','G2','G3','G4','G5','G6','G7','G8','C6','C7','C8','C9','A8','A9',...
268
	'A10','A11','A12','A13','H13','H14','H15','I0','I1','I2','I3','A14','A15','C10','C11','C12',...
269
	'D0','D1','D2','D3','D4','D5','D6','D7','G9','G10','G11','G12','G13','G14','G15','B3',...
270
	'B4','B5','B6','B7','B8','B9','E0','E1','I4','I5','I6','I7'};
271
% = UFBGA176 =
272
setting.pkg.UFBGA176.IO = setting.pkg.BGA176.IO;
273
% = LQFP176 =
274
setting.pkg.LQFP176.IO = setting.pkg.BGA176.IO;
275
% = LQFP208 =
276
setting.pkg.LQFP208.IO = {...
277
	'E2','E3','E4','E5','E6','I8','C13','C14','C15','I9','I10','I11','F0','F1','F2','I12','I13','I14','F3',...
278
	'F4','F5','F6','F7','F8','F9','F10','H0','H1','C0','C1','C2','C3','A0','A1','A2','H2','H3','H4','H5',...
279
	'H2','H3','H4','H5','A3','A4','A5','A6','A7','C4','C5','B0','B1','B2','I15','J0','J1','J2','J3','J4','F11','F12',...
280
	'F13','F14','F15','G0','G1','E7','E8','E9','E10','E11','E12','E13','E14','E15','B10','B11',...
281
	'J5','H6','H7','H8','H9','H10','H11','H12','B12','B13','B14','B15','D8','D9','D10','D11','D12',...
282
	'D13','D14','D15','J6','J7','J8','J9','J10','J11','K0','K1','K2','G2','G3','G4','G5','G6','G7','G8','C6','C7','C8','C9','A8','A9',...
283
	'A10','A11','A12','A13','H13','H14','H15','I0','I1','I2','I3','A14','A15','C10','C11','C12',...
284
	'D0','D1','D2','D3','D4','D5','D6','D7','J12','J13','J14','J15','G9','G10','G11','G12','G13','G14','K3','K4','K5','K6','K7','G15','B3',...
285
	'B4','B5','B6','B7','B8','B9','E0','E1','I4','I5','I6','I7'};
286
% = BGA216 =
287
setting.pkg.BGA216.IO = {...
288
	'E2','E3','E4','E5','E6','I8','C13','C14','C15','I9','I10','I11','F0','F1','F2','I12','I13','I14','F3',...
289
	'F4','F5','F6','F7','F8','F9','F10','H0','H1','C0','C1','C2','C3','A0','A1','A2','H2','H3','H4','H5',...
290
	'H2','H3','H4','H5','A3','A4','A5','A6','A7','C4','C5','B0','B1','B2','I15','J0','J1','J2','J3','J4','F11','F12',...
291
	'F13','F14','F15','G0','G1','E7','E8','E9','E10','E11','E12','E13','E14','E15','B10','B11',...
292
	'J5','H6','H7','H8','H9','H10','H11','H12','B12','B13','B14','B15','D8','D9','D10','D11','D12',...
293
	'D13','D14','D15','J6','J7','J8','J9','J10','J11','K0','K1','K2','G2','G3','G4','G5','G6','G7','G8','C6','C7','C8','C9','A8','A9',...
294
	'A10','A11','A12','A13','H13','H14','H15','I0','I1','I2','I3','A14','A15','C10','C11','C12',...
295
	'D0','D1','D2','D3','D4','D5','D6','D7','J12','J13','J14','J15','G9','G10','G11','G12','G13','G14','K3','K4','K5','K6','K7','G15','B3',...
296
	'B4','B5','B6','B7','B8','B9','E0','E1','I4','I5','I6','I7'};
297

    
298
% Update packages, basic Peripheral
299
for pkg_idx=1:size(PACKAGE_LIST,2)
300
	pkg_str = char(PACKAGE_LIST{pkg_idx});
301
	pkg_io_available = eval(['setting.pkg.' pkg_str '.IO;']);
302
	
303
	% GPIO
304
	port_list = {'A','B','C','D','E','F','G','H','I','J','K'};
305
	for port_idx=1:size(port_list,2)
306
		port_str = char(port_list{port_idx});
307
		pin_list = [];
308
		for pin_idx=1:16
309
			pin = [port_str num2str(pin_idx-1)];
310
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
311
				pin_list{end+1} = num2str(pin_idx-1);
312
			end
313
		end
314
		eval(['setting.pkg.' pkg_str '.GPIO' port_str '=pin_list;']);
315
	end
316
	
317
	% ADC
318
	adc = [];
319
	adc{1} = {'A0','A1','A2','A3','A4','A5','A6','A7','B0','B1','C0','C1','C2','C3','C4','C5','Y','Y','Y'};
320
	adc{2} = {'A0','A1','A2','A3','A4','A5','A6','A7','B0','B1','C0','C1','C2','C3','C4','C5'};
321
	adc{3} = {'A0','A1','A2','A3','F6','F7','F8','F9','F10','F3','C0','C1','C2','C3','F4','F5'};
322
	eval(['setting.pkg.' pkg_str '.ADC=[];']);
323
	for adc_idx=1:size(adc,2)
324
		pin_list = [];
325
		for pin_idx=1:size(adc{adc_idx},2)
326
			pin = char(adc{adc_idx}{pin_idx});
327
			if ~isempty(find(strcmp(pkg_io_available,pin),1)) ...
328
					|| strcmp(pin,'Y')
329
				pin_list{end+1} = pin;
330
			else
331
				pin_list{end+1} = [];
332
			end
333
		end
334
		eval(['setting.pkg.' pkg_str '.ADC{' num2str(adc_idx) '}=pin_list;']);
335
	end
336
	
337
	% CAN
338
	can =[];
339
	can{1}.tx = {'A12','B9','D1','H13','dd'};
340
	can{1}.rx = {'A11','B8','D0','I9'};
341
	can{2}.tx = {'B6','B13'};
342
	can{2}.rx = {'B5','B12'};
343
	eval(['setting.pkg.' pkg_str '.CAN=[];']);
344
	for can_idx=1:size(can,2)
345
		% tx
346
		pin_list_tx = [];
347
		for pin_idx=1:size(can{can_idx}.tx,2)
348
			pin = char(can{can_idx}.tx{pin_idx});
349
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
350
				pin_list_tx{end+1} = pin;
351
			end
352
		end
353
		eval(['setting.pkg.' pkg_str '.CAN{' num2str(can_idx) '}.tx=pin_list_tx;']);
354
		% rx
355
		pin_list_rx = [];
356
		for pin_idx=1:size(can{can_idx}.rx,2)
357
			pin = char(can{can_idx}.rx{pin_idx});
358
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
359
				pin_list_rx{end+1} = pin;
360
			end
361
		end
362
		eval(['setting.pkg.' pkg_str '.CAN{' num2str(can_idx) '}.rx=pin_list_rx;']);		
363
	end
364
	
365
	% DAC
366
	dac = [];
367
	dac{1} = {'A4'};
368
	dac{2} = {'A5'};
369
	eval(['setting.pkg.' pkg_str '.DAC=[];']);
370
	for dac_idx=1:size(dac,2)
371
		pin_list = [];
372
		for pin_idx=1:size(dac{dac_idx},2)
373
			pin = char(dac{dac_idx}{pin_idx});
374
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
375
				pin_list{end+1} = pin;
376
			end
377
		end
378
		eval(['setting.pkg.' pkg_str '.DAC{' num2str(dac_idx) '}=pin_list;']);
379
	end
380
	
381
	% UART
382
	uart = [];
383
	uart{1}.tx = {'A9','B6'};
384
	uart{1}.rx = {'A10','B7'};
385
	uart{1}.cts = {'A11'};
386
	uart{1}.rts = {'A12'};
387
	uart{2}.tx = {'A2','D5'};
388
	uart{2}.rx = {'A3','D6'};
389
	uart{2}.cts = {'A0','D3'};
390
	uart{2}.rts = {'A1','D4'};
391
	uart{3}.tx = {'B10','C10','D8'};
392
	uart{3}.rx = {'B11','C11','D9'};
393
	uart{3}.cts = {'B13','D11'};
394
	uart{3}.rts = {'B14','D12'};
395
	uart{4}.tx = {'A0','C10'};
396
	uart{4}.rx = {'A1','C11'};
397
	uart{4}.cts = {};
398
	uart{4}.rts = {};
399
	uart{5}.tx = {'C12'};
400
	uart{5}.rx = {'D2'};
401
	uart{5}.cts = {};
402
	uart{5}.rts = {};
403
	uart{6}.tx = {'C6','G14'};
404
	uart{6}.rx = {'C7','G9'};
405
	uart{6}.cts = {'G13','G15'};
406
	uart{6}.rts = {'G8','G12'};	 %#ok<*AGROW>
407
	eval(['setting.pkg.' pkg_str '.UART=[];']);
408
	for uart_idx=1:size(uart,2)
409
		% tx
410
		pin_list_tx = [];
411
		for pin_idx=1:size(uart{uart_idx}.tx,2)
412
			pin = char(uart{uart_idx}.tx{pin_idx});
413
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
414
				pin_list_tx{end+1} = pin; %#ok<AGROW>
415
			end
416
		end
417
		eval(['setting.pkg.' pkg_str '.UART{' num2str(uart_idx) '}.tx=pin_list_tx;']);
418
		% rx
419
		pin_list_rx = [];
420
		for pin_idx=1:size(uart{uart_idx}.rx,2)
421
			pin = char(uart{uart_idx}.rx{pin_idx});
422
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
423
				pin_list_rx{end+1} = pin;
424
			end
425
		end
426
		eval(['setting.pkg.' pkg_str '.UART{' num2str(uart_idx) '}.rx=pin_list_rx;']);		
427
		% cts
428
		pin_list_cts = [];
429
		for pin_idx=1:size(uart{uart_idx}.cts,2)
430
			pin = char(uart{uart_idx}.cts{pin_idx});
431
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
432
				pin_list_cts{end+1} = pin;
433
			end
434
		end
435
		eval(['setting.pkg.' pkg_str '.UART{' num2str(uart_idx) '}.cts=pin_list_cts;']);
436
		% rts
437
		pin_list_rts = [];
438
		for pin_idx=1:size(uart{uart_idx}.rts,2)
439
			pin = char(uart{uart_idx}.rts{pin_idx});
440
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
441
				pin_list_rts{end+1} = pin;
442
			end
443
		end
444
		eval(['setting.pkg.' pkg_str '.UART{' num2str(uart_idx) '}.rts=pin_list_rts;']);
445
	end	
446
	
447
	% I2C
448
	i2c = [];
449
	i2c{1}.scl = {'B6','B8'};
450
	i2c{1}.sda = {'B7','B9'};
451
	i2c{2}.scl = {'B10','F1','H4'};
452
	i2c{2}.sda = {'B11','F0','H5'};
453
	i2c{3}.scl = {'A8','H7'};
454
	i2c{3}.sda = {'C9','H8'};
455
	eval(['setting.pkg.' pkg_str '.I2C=[];']);
456
	for i2c_idx=1:size(i2c,2)
457
		% scl
458
		pin_list_scl = [];
459
		for pin_idx=1:size(i2c{i2c_idx}.scl,2)
460
			pin = char(i2c{i2c_idx}.scl{pin_idx});
461
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
462
				pin_list_scl{end+1} = pin;
463
			end
464
		end
465
		eval(['setting.pkg.' pkg_str '.I2C{' num2str(i2c_idx) '}.scl=pin_list_scl;']);
466
		% sda
467
		pin_list_sda = [];
468
		for pin_idx=1:size(i2c{i2c_idx}.sda,2)
469
			pin = char(i2c{i2c_idx}.sda{pin_idx});
470
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
471
				pin_list_sda{end+1} = pin;
472
			end
473
		end
474
		eval(['setting.pkg.' pkg_str '.I2C{' num2str(i2c_idx) '}.sda=pin_list_sda;']);
475
	end	
476

    
477
	% SPI
478
	spi = [];
479
	spi{1}.nss = {'A4','A15'};
480
	spi{1}.sck = {'A5','B3'};
481
	spi{1}.miso = {'A6','B4'};
482
	spi{1}.mosi = {'A7','B5'};
483
	spi{2}.nss = {'B9','B12','I0'};
484
	spi{2}.sck = {'B10','B13','I1'};
485
	spi{2}.miso = {'B14','C2','I2'};
486
	spi{2}.mosi = {'B15','C3','I3'};
487
	spi{3}.nss = {'A4','15'};
488
	spi{3}.sck = {'B3','C10'};
489
	spi{3}.miso = {'B4','C11'};
490
	spi{3}.mosi = {'B5','C12'};
491
    spi{4}.nss = {'E4','E11'};
492
	spi{4}.sck = {'E2','E12'};
493
	spi{4}.miso = {'E5','E13'};
494
	spi{4}.mosi = {'E6','E14'};
495
    spi{5}.nss = {'F6','H5'};
496
	spi{5}.sck = {'F7','H6'};
497
	spi{5}.miso = {'F8','H7'};
498
	spi{5}.mosi = {'F9','F11'};
499
	eval(['setting.pkg.' pkg_str '.SPI=[];']);
500
	for spi_idx=1:size(spi,2)
501
		% nss
502
		pin_list_nss = [];
503
		for pin_idx=1:size(spi{spi_idx}.nss,2)
504
			pin = char(spi{spi_idx}.nss{pin_idx});
505
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
506
				pin_list_nss{end+1} = pin;
507
			end
508
		end
509
		eval(['setting.pkg.' pkg_str '.SPI{' num2str(spi_idx) '}.nss=pin_list_nss;']);
510
		% sck
511
		pin_list_sck = [];
512
		for pin_idx=1:size(spi{spi_idx}.sck,2)
513
			pin = char(spi{spi_idx}.sck{pin_idx});
514
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
515
				pin_list_sck{end+1} = pin;
516
			end
517
		end
518
		eval(['setting.pkg.' pkg_str '.SPI{' num2str(spi_idx) '}.sck=pin_list_sck;']);
519
		% miso
520
		pin_list_miso = [];
521
		for pin_idx=1:size(spi{spi_idx}.miso,2)
522
			pin = char(spi{spi_idx}.miso{pin_idx});
523
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
524
				pin_list_miso{end+1} = pin;
525
			end
526
		end
527
		eval(['setting.pkg.' pkg_str '.SPI{' num2str(spi_idx) '}.miso=pin_list_miso;']);
528
		% mosi
529
		pin_list_mosi = [];
530
		for pin_idx=1:size(spi{spi_idx}.mosi,2)
531
			pin = char(spi{spi_idx}.mosi{pin_idx});
532
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
533
				pin_list_mosi{end+1} = pin;
534
			end
535
		end
536
		eval(['setting.pkg.' pkg_str '.SPI{' num2str(spi_idx) '}.mosi=pin_list_mosi;']);
537
	end
538
	
539
	% TIM
540
	timer = [];
541
	% TIM1
542
	timer{1}.ch1 = {'A8','E9'};
543
	timer{1}.ch2 = {'A9','E11'};
544
	timer{1}.ch3 = {'A10','E13'};
545
	timer{1}.ch4 = {'A11','E14'};
546
	% TIM2
547
	timer{2}.ch1 = {'A0','A5','A15'};
548
	timer{2}.ch2 = {'A1','B3'};
549
	timer{2}.ch3 = {'A2','B10'};
550
	timer{2}.ch4 = {'A3','B11'};
551
	% TIM3
552
	timer{3}.ch1 = {'A6','B4','C6'};
553
	timer{3}.ch2 = {'A7','B5','C7'};
554
	timer{3}.ch3 = {'B0','C8'};
555
	timer{3}.ch4 = {'B1','C9'};
556
	% TIM4
557
	timer{4}.ch1 = {'B6','D12'};
558
	timer{4}.ch2 = {'B7','D13'};
559
	timer{4}.ch3 = {'B8','D14'};
560
	timer{4}.ch4 = {'B9','D15'};
561
	% TIM5
562
	timer{5}.ch1 = {'A0','H10'};
563
	timer{5}.ch2 = {'A1','H11'};
564
	timer{5}.ch3 = {'A2','H12'};
565
	timer{5}.ch4 = {'A3','I0'};
566
	% TIM6
567
	timer{6}.ch1 = [];
568
	timer{6}.ch2 = [];
569
	timer{6}.ch3 = [];
570
	timer{6}.ch4 = [];
571
	% TIM7
572
	timer{7}.ch1 = [];
573
	timer{7}.ch2 = [];
574
	timer{7}.ch3 = [];
575
	timer{7}.ch4 = [];
576
	% TIM8
577
	timer{8}.ch1 = {'C6','I5'};
578
	timer{8}.ch2 = {'C7','I6'};
579
	timer{8}.ch3 = {'C8','I7'};
580
	timer{8}.ch4 = {'C9','I2'};
581
	% TIM9
582
	timer{9}.ch1 = {'A2','E5'};
583
	timer{9}.ch2 = {'A3','E6'};
584
	timer{9}.ch3 = {};
585
	timer{9}.ch4 = {};
586
	% TIM10
587
	timer{10}.ch1 = {'B8'};
588
	timer{10}.ch2 = {};
589
	timer{10}.ch3 = {};
590
	timer{10}.ch4 = {};
591
	% TIM11
592
	timer{11}.ch1 = {'B9','F7'};
593
	timer{11}.ch2 = {};
594
	timer{11}.ch3 = {};
595
	timer{11}.ch4 = {};
596
	% TIM12
597
	timer{12}.ch1 = {'B14','H6'};
598
	timer{12}.ch2 = {'B15','H9'};
599
	timer{12}.ch3 = {};
600
	timer{12}.ch4 = {};
601
	% TIM13
602
	timer{13}.ch1 = {'A6','F8'};
603
	timer{13}.ch2 = {};
604
	timer{13}.ch3 = {};
605
	timer{13}.ch4 = {};
606
	% TIM14
607
	timer{14}.ch1 = {'A7','F9'};
608
	timer{14}.ch2 = {};
609
	timer{14}.ch3 = {};
610
	timer{14}.ch4 = {};
611
	eval(['setting.pkg.' pkg_str '.TIM=[];']);
612
	for timer_idx=1:size(timer,2)
613
		% ch1
614
		pin_list_ch1 = [];
615
		for pin_idx=1:size(timer{timer_idx}.ch1,2)
616
			pin = char(timer{timer_idx}.ch1{pin_idx});
617
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
618
				pin_list_ch1{end+1} = pin;
619
			end
620
		end
621
		eval(['setting.pkg.' pkg_str '.TIM{' num2str(timer_idx) '}.ch1=pin_list_ch1;']);
622
		% ch2
623
		pin_list_ch2 = [];
624
		for pin_idx=1:size(timer{timer_idx}.ch2,2)
625
			pin = char(timer{timer_idx}.ch2{pin_idx});
626
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
627
				pin_list_ch2{end+1} = pin;
628
			end
629
		end
630
		eval(['setting.pkg.' pkg_str '.TIM{' num2str(timer_idx) '}.ch2=pin_list_ch2;']);
631
		% ch3
632
		pin_list_ch3 = [];
633
		for pin_idx=1:size(timer{timer_idx}.ch3,2)
634
			pin = char(timer{timer_idx}.ch3{pin_idx});
635
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
636
				pin_list_ch3{end+1} = pin;
637
			end
638
		end
639
		eval(['setting.pkg.' pkg_str '.TIM{' num2str(timer_idx) '}.ch3=pin_list_ch3;']);
640
		% ch4
641
		pin_list_ch4 = [];
642
		for pin_idx=1:size(timer{timer_idx}.ch4,2)
643
			pin = char(timer{timer_idx}.ch4{pin_idx});
644
			if ~isempty(find(strcmp(pkg_io_available,pin),1))
645
				pin_list_ch4{end+1} = pin;
646
			end
647
		end
648
		eval(['setting.pkg.' pkg_str '.TIM{' num2str(timer_idx) '}.ch4=pin_list_ch4;']);
649
	end
650
end
651

    
652
% === MCU Device list ===
653
for pn_idx = 1:size(DEVICES_LIST,2)
654
	pn = char(DEVICES_LIST{pn_idx});
655
	
656
	device.family = [];
657
	device.pincount = [];
658
	device.package = [];
659
	device.flashsize = [];
660
	device.ramsize = [];
661
	device.mcuname = [];
662
	
663
	mcu = char(pn(1:9));
664
	pcnt = char(pn(10));
665
	flsh = char(pn(11));
666
	pkg = char(pn(12));
667
	
668
	% === Flash size ===
669
	flash_code = {'8','B','C','D','E','G','I'};
670
	flahs_size_kb = [64,128,256,384,512,1024,2048];
671
	idx = find(strcmp (flash_code,flsh));
672
	if isempty(idx)
673
		error('Invalid flash size code.');
674
	else
675
		device.flashsize = flahs_size_kb(idx);
676
	end
677
	
678
	% === Pin count ===
679
	pincount_code = {'T','C','R','M','O','V','Z','I','A','B','N'};
680
	pincount_num = {'36','48','64','81','90','100','144','176','168','208','216'};
681
	idx = find(strcmp (pincount_code,pcnt), 1);
682
	if isempty(idx)
683
		error ('Invlalid pin count code.');
684
	else
685
		device.pincount = char(pincount_num(idx));
686
	end
687
	
688
	% === Package ===
689
	package_code = {'H','I','J','T','U','Y'};
690
	package_str = {'BGA','UFBGA','UFBGA','LQFP','UFQFPN','WLCSP'};
691
	idx = find(strcmp (package_code,pkg), 1);
692
	if isempty(idx)
693
		error ('Invalid package code.');
694
	else
695
		device.package = char(package_str(idx));
696
	end
697
	
698
	% mcu name
699
	device.mcuname = [mcu pcnt flsh ' (' device.package device.pincount ')'];
700
% 	if strcmp(device.mcuname,'STM32F417IG (LQFP176)')
701
% 		device.mcuname = [device.mcuname '; FiO2'];
702
% 	end
703
	device.mcuid = [mcu pcnt flsh device.package device.pincount];
704
	device.package = [device.package device.pincount];
705
	
706
	% Family
707
	switch mcu
708
		% =====================================================================
709
		% === STM32F40_41xxx ===
710
		% =====================================================================
711
		case {'STM32F405', 'STM32F407', 'STM32F415', 'STM32F417'}
712
			device.family = 'STM32F40_41xxx';
713
			device.ramsize = 128;
714
			
715
			% =====================================================================
716
			% === STM32F427_437xx ===
717
			% =====================================================================
718
			% =====================================================================
719
			% === STM32F429_439xx ===
720
			% =====================================================================
721
		case {'STM32F429', 'STM32F439','STM32F427', 'STM32F437'}
722
			if ~isempty(find(strcmp({'STM32F429', 'STM32F439'}, mcu),1))
723
				device.family = 'STM32F429_439xx';
724
			else
725
				device.family = 'STM32F427_437xx';
726
			end
727
			
728
			device.ramsize = 192;
729
			
730
			% =====================================================================
731
			% STM32F401xx
732
			% =====================================================================
733
		case 'STM32F401'
734
			device.family = 'STM32F401xx';
735
			if device.flashsize < 384
736
				device.ramsize = 64;
737
			else
738
				device.ramsize = 96;
739
			end
740
			
741
			% =====================================================================
742
			% STM32F410xx
743
			% =====================================================================
744
		case 'STM32F410'
745
			device.family = 'STM32F410xx';
746
			device.ramsize = 32;
747
			
748
			% =====================================================================
749
			% STM32F411xx
750
			% =====================================================================
751
		case 'STM32F411'
752
			device.family = 'STM32F411xE';
753
			device.ramsize = 128;
754
			
755
			% =====================================================================
756
			% STM32F412xx
757
			% =====================================================================
758
		case 'STM32F412'
759
			device.family = 'STM32F412xG';
760
			device.ramsize = 256;
761
			% =====================================================================
762
			% STM32F446xx
763
			% =====================================================================
764
		case 'STM32F446'
765
			device.family = 'STM32F446xx';
766
			device.ramsize = 128;
767
			
768
			% =====================================================================
769
			% STM32F469_479xx
770
			% =====================================================================
771
		case {'STM32F469', 'STM32F479'}
772
			device.family = 'STM32F469_479xx';
773
			device.ramsize = 384;
774
			
775
			% Invalid
776
		otherwise
777
			error ('Invalid or unsupported device name.');
778
	end
779
	
780
	% Flash size
781
	device.compilers = [];
782
	device.compilers.gnuarm = [];
783
	device.compilers.mdkarm = [];
784
	device.compilers.ewarm = [];
785
	
786
	% FLASH_ORIGIN
787
	device.compilers.gnuarm.FLASH_ORIGIN = '0x8000000';
788
	device.compilers.mdkarm.FLASH_ORIGIN = '0x08000000';
789
	device.compilers.ewarm.FLASH_ORIGIN = '0x08000000';
790
	% FLASH_LENGTH
791
	device.compilers.gnuarm.FLASH_LENGTH = sprintf('%dk',device.flashsize);
792
	device.compilers.mdkarm.FLASH_LENGTH = sprintf('0x%X',(device.flashsize*1024));
793
	device.compilers.ewarm.FLASH_LENGTH = sprintf('0x%X',(device.flashsize*1024));
794
	% RAM_ORIGIN
795
	device.compilers.gnuarm.RAM_ORIGIN = '0x20000000';
796
	device.compilers.mdkarm.RAM_ORIGIN = '0x20000000';
797
	device.compilers.ewarm.RAM_ORIGIN = '0x20000000';
798
	% RAM_LENGTHs
799
	device.compilers.gnuarm.RAM_LENGTH = sprintf('%dk',device.ramsize);
800
	device.compilers.mdkarm.RAM_LENGTH = sprintf('0x%X',(device.ramsize*1024));
801
	device.compilers.ewarm.RAM_LENGTH = sprintf('0x%X',(device.ramsize*1024));
802
	%
803
	eval(['setting.devices.' device.mcuid '=device;']);
804
	eval(['setting.list{end+1}=''' device.mcuname ''';']);
805
end
(1-1/2)