1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
|
//-----------------------------------------------------------------------------
// Copyright 2007 Jonathan Westhues
//
// This file is part of LDmicro.
//
// LDmicro is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// LDmicro is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with LDmicro. If not, see <http://www.gnu.org/licenses/>.
//------
//
// Load/save the circuit from/to a file in a nice ASCII format.
// Jonathan Westhues, Nov 2004
//-----------------------------------------------------------------------------
#include "linuxUI.h"
#include <stdio.h>
#include <stdlib.h>
#include "ldmicro.h"
static ElemSubcktSeries *LoadSeriesFromFile(FILE *f);
//-----------------------------------------------------------------------------
// Check a line of text from a saved project file to determine whether it
// contains a leaf element (coil, contacts, etc.). If so, create an element
// for and save that in *any and *which, and return TRUE, else return FALSE.
//-----------------------------------------------------------------------------
static BOOL LoadLeafFromFile(char *line, void **any, int *which)
{
ElemLeaf *l = AllocLeaf();
int x;
if(memcmp(line, "COMMENT", 7)==0) {
char *s = line + 8;
int i = 0;
while(*s && *s != '\n') {
if(*s == '\\') {
if(s[1] == 'n') {
l->d.comment.str[i++] = '\n';
s++;
} else if(s[1] == 'r') {
l->d.comment.str[i++] = '\r';
s++;
} else if(s[1] == '\\') {
l->d.comment.str[i++] = '\\';
s++;
} else {
// that is odd
}
} else {
l->d.comment.str[i++] = *s;
}
s++;
}
l->d.comment.str[i++] = '\0';
*which = ELEM_COMMENT;
} else if(sscanf(line, "CONTACTS %s %d",
l->d.contacts.name, &l->d.contacts.negated)==2)
{
*which = ELEM_CONTACTS;
} else if(sscanf(line, "COIL %s %d %d %d",
l->d.coil.name, &l->d.coil.negated, &l->d.coil.setOnly,
&l->d.coil.resetOnly)==4)
{
*which = ELEM_COIL;
} else if(memcmp(line, "PLACEHOLDER", 11)==0) {
*which = ELEM_PLACEHOLDER;
} else if(memcmp(line, "SHORT", 5)==0) {
*which = ELEM_SHORT;
} else if(memcmp(line, "OPEN", 4)==0) {
*which = ELEM_OPEN;
} else if(memcmp(line, "MASTER_RELAY", 12)==0) {
*which = ELEM_MASTER_RELAY;
} else if(sscanf(line, "SHIFT_REGISTER %s %d",
l->d.shiftRegister.name, &(l->d.shiftRegister.stages))==2)
{
*which = ELEM_SHIFT_REGISTER;
} else if(memcmp(line, "OSR", 3)==0) {
*which = ELEM_ONE_SHOT_RISING;
} else if(memcmp(line, "OSF", 3)==0) {
*which = ELEM_ONE_SHOT_FALLING;
} else if((sscanf(line, "TON %s %d",
l->d.timer.name, &l->d.timer.delay)==2))
{
*which = ELEM_TON;
} else if((sscanf(line, "TOF %s %d",
l->d.timer.name, &l->d.timer.delay)==2))
{
*which = ELEM_TOF;
} else if((sscanf(line, "RTO %s %d", l->d.timer.name,
&l->d.timer.delay)==2))
{
*which = ELEM_RTO;
} else if((sscanf(line, "CTD %s %d", l->d.counter.name,
&l->d.counter.max)==2))
{
*which = ELEM_CTD;
} else if((sscanf(line, "CTU %s %d", l->d.counter.name,
&l->d.counter.max)==2))
{
*which = ELEM_CTU;
} else if((sscanf(line, "CTC %s %d", l->d.counter.name,
&l->d.counter.max)==2))
{
*which = ELEM_CTC;
} else if(sscanf(line, "RES %s", l->d.reset.name)==1) {
*which = ELEM_RES;
} else if(sscanf(line, "MOVE %s %s", l->d.move.dest, l->d.move.src)==2) {
*which = ELEM_MOVE;
} else if(sscanf(line, "ADD %s %s %s", l->d.math.dest,
l->d.math.op1, l->d.math.op2)==3)
{
*which = ELEM_ADD;
} else if(sscanf(line, "SUB %s %s %s", l->d.math.dest,
l->d.math.op1, l->d.math.op2)==3)
{
*which = ELEM_SUB;
} else if(sscanf(line, "MUL %s %s %s", l->d.math.dest,
l->d.math.op1, l->d.math.op2)==3)
{
*which = ELEM_MUL;
} else if(sscanf(line, "DIV %s %s %s", l->d.math.dest,
l->d.math.op1, l->d.math.op2)==3)
{
*which = ELEM_DIV;
} else if(sscanf(line, "EQU %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) {
*which = ELEM_EQU;
} else if(sscanf(line, "NEQ %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) {
*which = ELEM_NEQ;
} else if(sscanf(line, "GRT %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) {
*which = ELEM_GRT;
} else if(sscanf(line, "GEQ %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) {
*which = ELEM_GEQ;
} else if(sscanf(line, "LEQ %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) {
*which = ELEM_LEQ;
} else if(sscanf(line, "LES %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) {
*which = ELEM_LES;
} else if(sscanf(line, "READ_ADC %s", l->d.readAdc.name)==1) {
*which = ELEM_READ_ADC;
} else if(sscanf(line, "SET_PWM %s %d", l->d.setPwm.name,
&(l->d.setPwm.targetFreq))==2)
{
*which = ELEM_SET_PWM;
} else if(sscanf(line, "UART_RECV %s", l->d.uart.name)==1) {
*which = ELEM_UART_RECV;
} else if(sscanf(line, "UART_SEND %s", l->d.uart.name)==1) {
*which = ELEM_UART_SEND;
} else if(sscanf(line, "PERSIST %s", l->d.persist.var)==1) {
*which = ELEM_PERSIST;
} else if(sscanf(line, "FORMATTED_STRING %s %d", l->d.fmtdStr.var, &x)==2)
{
if(strcmp(l->d.fmtdStr.var, "(none)")==0) {
strcpy(l->d.fmtdStr.var, "");
}
char *p = line;
int i;
for(i = 0; i < 3; i++) {
while(!isspace(*p)) p++;
while( isspace(*p)) p++;
}
for(i = 0; i < x; i++) {
l->d.fmtdStr.string[i] = atoi(p);
if(l->d.fmtdStr.string[i] < 32) {
l->d.fmtdStr.string[i] = 'X';
}
while(!isspace(*p) && *p) p++;
while( isspace(*p) && *p) p++;
}
l->d.fmtdStr.string[i] = '\0';
*which = ELEM_FORMATTED_STRING;
} else if(sscanf(line, "LOOK_UP_TABLE %s %s %d %d", l->d.lookUpTable.dest,
l->d.lookUpTable.index, &(l->d.lookUpTable.count),
&(l->d.lookUpTable.editAsString))==4)
{
char *p = line;
int i;
// First skip over the parts that we already sscanf'd.
for(i = 0; i < 5; i++) {
while((!isspace(*p)) && *p)
p++;
while(isspace(*p) && *p)
p++;
}
// Then copy over the look-up table entries.
for(i = 0; i < l->d.lookUpTable.count; i++) {
l->d.lookUpTable.vals[i] = atoi(p);
while((!isspace(*p)) && *p)
p++;
while(isspace(*p) && *p)
p++;
}
*which = ELEM_LOOK_UP_TABLE;
} else if(sscanf(line, "PIECEWISE_LINEAR %s %s %d",
l->d.piecewiseLinear.dest, l->d.piecewiseLinear.index,
&(l->d.piecewiseLinear.count))==3)
{
char *p = line;
int i;
// First skip over the parts that we already sscanf'd.
for(i = 0; i < 4; i++) {
while((!isspace(*p)) && *p)
p++;
while(isspace(*p) && *p)
p++;
}
// Then copy over the piecewise linear points.
for(i = 0; i < l->d.piecewiseLinear.count*2; i++) {
l->d.piecewiseLinear.vals[i] = atoi(p);
while((!isspace(*p)) && *p)
p++;
while(isspace(*p) && *p)
p++;
}
*which = ELEM_PIECEWISE_LINEAR;
} else {
// that's odd; nothing matched
CheckFree(l);
return FALSE;
}
*any = l;
return TRUE;
}
//-----------------------------------------------------------------------------
// Load a parallel subcircuit from a file. We look for leaf nodes using
// LoadLeafFromFile, which we can put directly into the parallel circuit
// that we're building up, or series subcircuits that we can pass to
// LoadSeriesFromFile. Returns the parallel subcircuit built up, or NULL if
// something goes wrong.
//-----------------------------------------------------------------------------
static ElemSubcktParallel *LoadParallelFromFile(FILE *f)
{
char line[512];
void *any;
int which;
ElemSubcktParallel *ret = AllocSubcktParallel();
int cnt = 0;
for(;;) {
if(!fgets(line, sizeof(line), f)) return NULL;
ManageLineEnding(line);
char *s = line;
while(isspace(*s)) s++;
if(strcmp(s, "SERIES\n")==0) {
which = ELEM_SERIES_SUBCKT;
any = LoadSeriesFromFile(f);
if(!any) return NULL;
} else if(LoadLeafFromFile(s, &any, &which)) {
// got it
} else if(strcmp(s, "END\n")==0) {
ret->count = cnt;
return ret;
} else {
return NULL;
}
ret->contents[cnt].which = which;
ret->contents[cnt].d.any = any;
cnt++;
if(cnt >= MAX_ELEMENTS_IN_SUBCKT) return NULL;
}
}
//-----------------------------------------------------------------------------
// Same as LoadParallelFromFile, but for a series subcircuit. Thus builds
// a series circuit out of parallel circuits and leaf elements.
//-----------------------------------------------------------------------------
static ElemSubcktSeries *LoadSeriesFromFile(FILE *f)
{
char line[512];
void *any;
int which;
ElemSubcktSeries *ret = AllocSubcktSeries();
int cnt = 0;
for(;;) {
if(!fgets(line, sizeof(line), f)) return NULL;
ManageLineEnding(line);
char *s = line;
while(isspace(*s)) s++;
if(strcmp(s, "PARALLEL\n")==0) {
which = ELEM_PARALLEL_SUBCKT;
any = LoadParallelFromFile(f);
if(!any) return NULL;
} else if(LoadLeafFromFile(s, &any, &which)) {
// got it
} else if(strcmp(s, "END\n")==0) {
ret->count = cnt;
return ret;
} else {
return NULL;
}
ret->contents[cnt].which = which;
ret->contents[cnt].d.any = any;
cnt++;
if(cnt >= MAX_ELEMENTS_IN_SUBCKT) return NULL;
}
}
void ManageLineEnding(char* line)
{
int charlen = strlen(line) - 2;
if(line[charlen] == '\r')
{
line[charlen++] = '\n';
line[charlen] = '\0';
}
}
//-----------------------------------------------------------------------------
// Load a project from a saved project description files. This describes the
// program, the target processor, plus certain configuration settings (cycle
// time, processor clock, etc.). Return TRUE for success, FALSE if anything
// went wrong.
//-----------------------------------------------------------------------------
BOOL LoadProjectFromFile(char *filename)
{
FreeEntireProgram();
strcpy(CurrentCompileFile, "");
FILE *f = fopen(filename, "r");
if(!f) return FALSE;
char line[512];
int crystal, cycle, baud;
while(fgets(line, sizeof(line), f)) {
ManageLineEnding(line);
if(strcmp(line, "IO LIST\n")==0) {
if(!LoadIoListFromFile(f)) {
fclose(f);
return FALSE;
}
} else if(sscanf(line, "CRYSTAL=%d", &crystal)) {
Prog.mcuClock = crystal;
} else if(sscanf(line, "CYCLE=%d", &cycle)) {
Prog.cycleTime = cycle;
} else if(sscanf(line, "BAUD=%d", &baud)) {
Prog.baudRate = baud;
} else if(memcmp(line, "COMPILED=", 9)==0) {
line[strlen(line)-1] = '\0';
strcpy(CurrentCompileFile, line+9);
} else if(memcmp(line, "MICRO=", 6)==0) {
line[strlen(line)-1] = '\0';
int i;
for(i = 0; i < NUM_SUPPORTED_MCUS; i++) {
if(strcmp(SupportedMcus[i].mcuName, line+6)==0) {
Prog.mcu = &SupportedMcus[i];
break;
}
}
if(i == NUM_SUPPORTED_MCUS) {
Error(_("Microcontroller '%s' not supported.\r\n\r\n"
"Defaulting to no selected MCU."), line+6);
}
} else if(strcmp(line, "PROGRAM\n")==0) {
break;
}
}
if(strcmp(line, "PROGRAM\n") != 0) goto failed;
int rung;
for(rung = 0;;) {
if(!fgets(line, sizeof(line), f)) break;
ManageLineEnding(line);
if(strcmp(line, "RUNG\n")!=0) goto failed;
Prog.rungs[rung] = LoadSeriesFromFile(f);
if(!Prog.rungs[rung])
goto failed;
rung++;
}
Prog.numRungs = rung;
fclose(f);
return TRUE;
failed:
fclose(f);
NewProgram();
Error(_("File format error; perhaps this program is for a newer version "
"of LDmicro?"));
return FALSE;
}
//-----------------------------------------------------------------------------
// Helper routine for outputting hierarchical representation of the ladder
// logic: indent on file f, by depth*4 spaces.
//-----------------------------------------------------------------------------
static void Indent(FILE *f, int depth)
{
int i;
for(i = 0; i < depth; i++) {
fprintf(f, " ");
}
}
//-----------------------------------------------------------------------------
// Save an element to a file. If it is a leaf, then output a single line
// describing it and return. If it is a subcircuit, call ourselves
// recursively (with depth+1, so that the indentation is right) to handle
// the members of the subcircuit. Special case for depth=0: we do not
// output the SERIES/END delimiters. This is because the root is delimited
// by RUNG/END markers output elsewhere.
//-----------------------------------------------------------------------------
static void SaveElemToFile(FILE *f, int which, void *any, int depth)
{
ElemLeaf *l = (ElemLeaf *)any;
char *s;
Indent(f, depth);
switch(which) {
case ELEM_PLACEHOLDER:
fprintf(f, "PLACEHOLDER\n");
break;
case ELEM_COMMENT: {
fprintf(f, "COMMENT ");
char *s = l->d.comment.str;
for(; *s; s++) {
if(*s == '\\') {
fprintf(f, "\\\\");
} else if(*s == '\n') {
fprintf(f, "\\n");
} else if(*s == '\r') {
fprintf(f, "\\r");
} else {
fprintf(f, "%c", *s);
}
}
fprintf(f, "\n");
break;
}
case ELEM_OPEN:
fprintf(f, "OPEN\n");
break;
case ELEM_SHORT:
fprintf(f, "SHORT\n");
break;
case ELEM_MASTER_RELAY:
fprintf(f, "MASTER_RELAY\n");
break;
case ELEM_SHIFT_REGISTER:
fprintf(f, "SHIFT_REGISTER %s %d\n", l->d.shiftRegister.name,
l->d.shiftRegister.stages);
break;
case ELEM_CONTACTS:
fprintf(f, "CONTACTS %s %d\n", l->d.contacts.name,
l->d.contacts.negated);
break;
case ELEM_COIL:
fprintf(f, "COIL %s %d %d %d\n", l->d.coil.name, l->d.coil.negated,
l->d.coil.setOnly, l->d.coil.resetOnly);
break;
case ELEM_TON:
s = "TON"; goto timer;
case ELEM_TOF:
s = "TOF"; goto timer;
case ELEM_RTO:
s = "RTO"; goto timer;
timer:
fprintf(f, "%s %s %d\n", s, l->d.timer.name, l->d.timer.delay);
break;
case ELEM_CTU:
s = "CTU"; goto counter;
case ELEM_CTD:
s = "CTD"; goto counter;
case ELEM_CTC:
s = "CTC"; goto counter;
counter:
fprintf(f, "%s %s %d\n", s, l->d.counter.name, l->d.counter.max);
break;
case ELEM_RES:
fprintf(f, "RES %s\n", l->d.reset.name);
break;
case ELEM_MOVE:
fprintf(f, "MOVE %s %s\n", l->d.move.dest, l->d.move.src);
break;
case ELEM_ADD: s = "ADD"; goto math;
case ELEM_SUB: s = "SUB"; goto math;
case ELEM_MUL: s = "MUL"; goto math;
case ELEM_DIV: s = "DIV"; goto math;
math:
fprintf(f, "%s %s %s %s\n", s, l->d.math.dest, l->d.math.op1,
l->d.math.op2);
break;
case ELEM_EQU: s = "EQU"; goto cmp;
case ELEM_NEQ: s = "NEQ"; goto cmp;
case ELEM_GRT: s = "GRT"; goto cmp;
case ELEM_GEQ: s = "GEQ"; goto cmp;
case ELEM_LES: s = "LES"; goto cmp;
case ELEM_LEQ: s = "LEQ"; goto cmp;
cmp:
fprintf(f, "%s %s %s\n", s, l->d.cmp.op1, l->d.cmp.op2);
break;
case ELEM_ONE_SHOT_RISING:
fprintf(f, "OSR\n");
break;
case ELEM_ONE_SHOT_FALLING:
fprintf(f, "OSF\n");
break;
case ELEM_READ_ADC:
fprintf(f, "READ_ADC %s\n", l->d.readAdc.name);
break;
case ELEM_SET_PWM:
fprintf(f, "SET_PWM %s %d\n", l->d.setPwm.name,
l->d.setPwm.targetFreq);
break;
case ELEM_UART_RECV:
fprintf(f, "UART_RECV %s\n", l->d.uart.name);
break;
case ELEM_UART_SEND:
fprintf(f, "UART_SEND %s\n", l->d.uart.name);
break;
case ELEM_PERSIST:
fprintf(f, "PERSIST %s\n", l->d.persist.var);
break;
case ELEM_FORMATTED_STRING: {
int i;
fprintf(f, "FORMATTED_STRING ");
if(*(l->d.fmtdStr.var)) {
fprintf(f, "%s", l->d.fmtdStr.var);
} else {
fprintf(f, "(none)");
}
fprintf(f, " %d", strlen(l->d.fmtdStr.string));
for(i = 0; i < (int)strlen(l->d.fmtdStr.string); i++) {
fprintf(f, " %d", l->d.fmtdStr.string[i]);
}
fprintf(f, "\n");
break;
}
case ELEM_LOOK_UP_TABLE: {
int i;
fprintf(f, "LOOK_UP_TABLE %s %s %d %d", l->d.lookUpTable.dest,
l->d.lookUpTable.index, l->d.lookUpTable.count,
l->d.lookUpTable.editAsString);
for(i = 0; i < l->d.lookUpTable.count; i++) {
fprintf(f, " %d", l->d.lookUpTable.vals[i]);
}
fprintf(f, "\n");
break;
}
case ELEM_PIECEWISE_LINEAR: {
int i;
fprintf(f, "PIECEWISE_LINEAR %s %s %d", l->d.piecewiseLinear.dest,
l->d.piecewiseLinear.index, l->d.piecewiseLinear.count);
for(i = 0; i < l->d.piecewiseLinear.count*2; i++) {
fprintf(f, " %d", l->d.piecewiseLinear.vals[i]);
}
fprintf(f, "\n");
break;
}
case ELEM_SERIES_SUBCKT: {
ElemSubcktSeries *s = (ElemSubcktSeries *)any;
int i;
if(depth == 0) {
fprintf(f, "RUNG\n");
} else {
fprintf(f, "SERIES\n");
}
for(i = 0; i < s->count; i++) {
SaveElemToFile(f, s->contents[i].which, s->contents[i].d.any,
depth+1);
}
Indent(f, depth);
fprintf(f, "END\n");
break;
}
case ELEM_PARALLEL_SUBCKT: {
ElemSubcktParallel *s = (ElemSubcktParallel *)any;
int i;
fprintf(f, "PARALLEL\n");
for(i = 0; i < s->count; i++) {
SaveElemToFile(f, s->contents[i].which, s->contents[i].d.any,
depth+1);
}
Indent(f, depth);
fprintf(f, "END\n");
break;
}
default:
oops();
break;
}
}
//-----------------------------------------------------------------------------
// Save the program in memory to the given file. Returns TRUE for success,
// FALSE otherwise.
//-----------------------------------------------------------------------------
BOOL SaveProjectToFile(char *filename)
{
FILE *f = fopen(filename, "w");
if(!f) return FALSE;
fprintf(f, "LDmicro0.1\n");
if(Prog.mcu) {
fprintf(f, "MICRO=%s\n", Prog.mcu->mcuName);
}
fprintf(f, "CYCLE=%d\n", Prog.cycleTime);
fprintf(f, "CRYSTAL=%d\n", Prog.mcuClock);
fprintf(f, "BAUD=%d\n", Prog.baudRate);
if(strlen(CurrentCompileFile) > 0) {
fprintf(f, "COMPILED=%s\n", CurrentCompileFile);
}
fprintf(f, "\n");
// list extracted from schematic, but the pin assignments are not
fprintf(f, "IO LIST\n", Prog.mcuClock);
SaveIoListToFile(f);
fprintf(f, "END\n", Prog.mcuClock);
fprintf(f, "\n", Prog.mcuClock);
fprintf(f, "PROGRAM\n", Prog.mcuClock);
int i;
for(i = 0; i < Prog.numRungs; i++) {
SaveElemToFile(f, ELEM_SERIES_SUBCKT, Prog.rungs[i], 0);
}
fclose(f);
return TRUE;
}
|