Skip to content

Commit f88fefc

Browse files
committed
templates: semihosting argv[1] loops
1 parent 40e5f20 commit f88fefc

31 files changed

+281
-36
lines changed

ilg.gnuarmeclipse.templates.core/templates/common/src/main/main-100-include.c

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
// ----------------------------------------------------------------------------
77

88
#include <stdio.h>
9+
#include <stdlib.h>
910
#include "diag/Trace.h"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
timer_start();
3+
4+
blink_led_init();
5+
6+
uint32_t seconds = 0;
7+
8+
// Infinite loop
9+
while (1)
10+
{
11+
blink_led_on();
12+
timer_sleep(BLINK_ON_TICKS);
13+
14+
blink_led_off();
15+
timer_sleep(BLINK_OFF_TICKS);
16+
17+
++seconds;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
Timer timer;
3+
timer.start();
4+
5+
BlinkLed blinkLed;
6+
7+
// Perform all necessary initialisations for the LED.
8+
blinkLed.powerUp();
9+
10+
uint32_t seconds = 0;
11+
12+
// Infinite loop
13+
while (1)
14+
{
15+
blinkLed.turnOn();
16+
timer.sleep(BLINK_ON_TICKS);
17+
18+
blinkLed.turnOff();
19+
timer.sleep(BLINK_OFF_TICKS);
20+
21+
++seconds;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
// Infinite loop
3+
while (1)
4+
{
5+
// Add your code here.
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
timer_start();
3+
4+
blink_led_init();
5+
6+
uint32_t seconds = 0;
7+
8+
// Infinite loop
9+
while (1)
10+
{
11+
blink_led_on();
12+
timer_sleep(BLINK_ON_TICKS);
13+
14+
blink_led_off();
15+
timer_sleep(BLINK_OFF_TICKS);
16+
17+
++seconds;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
Timer timer;
3+
timer.start();
4+
5+
BlinkLed blinkLed;
6+
7+
// Perform all necessary initialisations for the LED.
8+
blinkLed.powerUp();
9+
10+
uint32_t seconds = 0;
11+
12+
// Infinite loop
13+
while (1)
14+
{
15+
blinkLed.turnOn();
16+
timer.sleep(BLINK_ON_TICKS);
17+
18+
blinkLed.turnOff();
19+
timer.sleep(BLINK_OFF_TICKS);
20+
21+
++seconds;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
// Infinite loop
3+
while (1)
4+
{
5+
// Add your code here.
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
timer_start();
3+
4+
blink_led_init();
5+
6+
uint32_t seconds = 0;
7+
8+
#define LOOP_COUNT (5)
9+
int loops = LOOP_COUNT;
10+
if (argc > 1)
11+
{
12+
// If defined, get the number of loops from the command line,
13+
// configurable via semihosting.
14+
loops = atoi (argv[1]);
15+
}
16+
17+
// Short loop.
18+
for (int i = 0; i < loops; i++)
19+
{
20+
blink_led_on();
21+
timer_sleep(BLINK_ON_TICKS);
22+
23+
blink_led_off();
24+
timer_sleep(BLINK_OFF_TICKS);
25+
26+
++seconds;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
Timer timer;
3+
timer.start();
4+
5+
BlinkLed blinkLed;
6+
7+
// Perform all necessary initialisations for the LED.
8+
blinkLed.powerUp();
9+
10+
uint32_t seconds = 0;
11+
12+
#define LOOP_COUNT (5)
13+
int loops = LOOP_COUNT;
14+
if (argc > 1)
15+
{
16+
// If defined, get the number of loops from the command line,
17+
// configurable via semihosting.
18+
loops = atoi (argv[1]);
19+
}
20+
21+
// Short loop.
22+
for (int i = 0; i < loops; i++)
23+
{
24+
blinkLed.turnOn();
25+
timer.sleep(BLINK_ON_TICKS);
26+
27+
blinkLed.turnOff();
28+
timer.sleep(BLINK_OFF_TICKS);
29+
30+
++seconds;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
#define LOOP_COUNT (5)
3+
int loops = LOOP_COUNT;
4+
if (argc > 1)
5+
{
6+
// If defined, get the number of loops from the command line,
7+
// configurable via semihosting.
8+
loops = atoi (argv[1]);
9+
}
10+
11+
// Short loop.
12+
for (int i = 0; i < loops; i++)
13+
{
14+
// Add your code here.
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
}
2+
// Infinite loop, never return.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
}
2+
// Infinite loop, never return.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
}
2+
3+
#pragma GCC diagnostic pop
4+
5+
// ----------------------------------------------------------------------------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
}
2+
3+
#pragma GCC diagnostic pop
4+
5+
// ----------------------------------------------------------------------------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
return 0;
2+
}
3+
4+
#pragma GCC diagnostic pop
5+
6+
// ----------------------------------------------------------------------------

ilg.gnuarmeclipse.templates.core/templates/common/src/main/main-include.xcdl.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
//@XCDL @if "$(content)"=="blinky"
1616
//@XCDL @include "$(commonDir)/src/main/main-180-$(syscalls)-hello.c"
1717
//@XCDL @include "$(commonDir)/src/main/main-190-clock-blinky.c"
18-
//@XCDL @include "$(commonDir)/src/main/main-200-loop-blinky.$(fileExtension)"
18+
//@XCDL @include "$(commonDir)/src/main/main-200-$(syscalls)-loop-blinky.$(fileExtension)"
1919
//@XCDL @include "$(commonDir)/src/main/main-210-print.c"
20-
//@XCDL @include "$(commonDir)/src/main/main-220-loopend.c"
20+
//@XCDL @include "$(commonDir)/src/main/main-220-$(syscalls)-loopend.c"
2121
//@XCDL @elif "$(content)"=="empty"
2222
//@XCDL @include "$(commonDir)/src/main/main-190-clock-empty.c"
23-
//@XCDL @include "$(commonDir)/src/main/main-200-loop-empty.c"
23+
//@XCDL @include "$(commonDir)/src/main/main-200-$(syscalls)-loop-empty.c"
2424
//@XCDL @endif
25-
//@XCDL @include "$(commonDir)/src/main/main-230-end.c"
25+
//@XCDL @include "$(commonDir)/src/main/main-230-$(syscalls)-end.c"

ilg.gnuarmeclipse.templates.cortexm/templates/cortexm_project/src/main-10.c

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// ----------------------------------------------------------------------------
77

88
#include <stdio.h>
9+
#include <stdlib.h>
910

1011
#include "diag/Trace.h"
1112
#include "Timer.h"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
int seconds = 0;
3+
4+
// Infinite loop
5+
while (1)
6+
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
int seconds = 0;
3+
4+
// Infinite loop
5+
while (1)
6+
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
int seconds = 0;
3+
4+
#define LOOP_COUNT (5)
5+
int loops = LOOP_COUNT;
6+
if (argc > 1)
7+
{
8+
// If defined, get the number of loops from the command line,
9+
// configurable via semihosting.
10+
loops = atoi (argv[1]);
11+
}
12+
13+
// Short loop.
14+
for (int i = 0; i < loops; i++)
15+
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
++seconds;
3+
4+
// Count seconds on the trace device.
5+
trace_printf ("Second %d\n", seconds);
6+
}
7+
// Infinite loop, never return.
8+
}
9+
10+
#pragma GCC diagnostic pop
11+
12+
// ----------------------------------------------------------------------------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
++seconds;
3+
4+
// Count seconds on the trace device.
5+
trace_printf ("Second %d\n", seconds);
6+
}
7+
// Infinite loop, never return.
8+
}
9+
10+
#pragma GCC diagnostic pop
11+
12+
// ----------------------------------------------------------------------------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
++seconds;
3+
4+
// Count seconds on the trace device.
5+
trace_printf ("Second %d\n", seconds);
6+
}
7+
return 0;
8+
}
9+
10+
#pragma GCC diagnostic pop
11+
12+
// ----------------------------------------------------------------------------

ilg.gnuarmeclipse.templates.cortexm/templates/cortexm_project/template.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ and is available athttp://www.eclipse.org/legal/epl-v10.html"
333333
<simple name="replaceable" value="true" />
334334
</element>
335335
<element>
336-
<simple name="source" value="src/main-30.c" />
336+
<simple name="source" value="src/main-30-$(syscalls).c" />
337337
<simple name="target" value="$(sourceDir)/main.$(fileExtension)" />
338338
<simple name="replaceable" value="true" />
339339
</element>
@@ -343,7 +343,7 @@ and is available athttp://www.eclipse.org/legal/epl-v10.html"
343343
<simple name="replaceable" value="true" />
344344
</element>
345345
<element>
346-
<simple name="source" value="src/main-50.c" />
346+
<simple name="source" value="src/main-50-$(syscalls).c" />
347347
<simple name="target" value="$(sourceDir)/main.$(fileExtension)" />
348348
<simple name="replaceable" value="true" />
349349
</element>

ilg.gnuarmeclipse.templates.freescale/templates/klxx_c_project/template.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ and is available athttp://www.eclipse.org/legal/epl-v10.html"
397397
</element>
398398
<element>
399399
<simple name="source"
400-
value="$(commonDir)/src/main/main-200-loop-blinky.$(fileExtension)" />
400+
value="$(commonDir)/src/main/main-200-$(syscalls)-loop-blinky.$(fileExtension)" />
401401
<simple name="target" value="$(sourceDir)/main.$(fileExtension)" />
402402
<simple name="replaceable" value="true" />
403403
</element>
@@ -407,12 +407,12 @@ and is available athttp://www.eclipse.org/legal/epl-v10.html"
407407
<simple name="replaceable" value="true" />
408408
</element>
409409
<element>
410-
<simple name="source" value="$(commonDir)/src/main/main-220-loopend.c" />
410+
<simple name="source" value="$(commonDir)/src/main/main-220-$(syscalls)-loopend.c" />
411411
<simple name="target" value="$(sourceDir)/main.$(fileExtension)" />
412412
<simple name="replaceable" value="true" />
413413
</element>
414414
<element>
415-
<simple name="source" value="$(commonDir)/src/main/main-230-end.c" />
415+
<simple name="source" value="$(commonDir)/src/main/main-230-$(syscalls)-end.c" />
416416
<simple name="target" value="$(sourceDir)/main.$(fileExtension)" />
417417
<simple name="replaceable" value="true" />
418418
</element>
@@ -532,12 +532,12 @@ and is available athttp://www.eclipse.org/legal/epl-v10.html"
532532
<simple name="replaceable" value="true" />
533533
</element>
534534
<element>
535-
<simple name="source" value="$(commonDir)/src/main/main-200-loop-empty.c" />
535+
<simple name="source" value="$(commonDir)/src/main/main-200-$(syscalls)-loop-empty.c" />
536536
<simple name="target" value="$(sourceDir)/main.$(fileExtension)" />
537537
<simple name="replaceable" value="true" />
538538
</element>
539539
<element>
540-
<simple name="source" value="$(commonDir)/src/main/main-230-end.c" />
540+
<simple name="source" value="$(commonDir)/src/main/main-230-$(syscalls)-end.c" />
541541
<simple name="target" value="$(sourceDir)/main.$(fileExtension)" />
542542
<simple name="replaceable" value="true" />
543543
</element>

ilg.gnuarmeclipse.templates.stm/templates/stm32f0xx_exe_c_project/template.xml

+5-5
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@
358358
</element>
359359
<element>
360360
<simple name="source"
361-
value="$(commonDir)/src/main/main-200-loop-blinky.$(fileExtension)" />
361+
value="$(commonDir)/src/main/main-200-$(syscalls)-loop-blinky.$(fileExtension)" />
362362
<simple name="target" value="$(sourceDir)/main.$(fileExtension)" />
363363
<simple name="replaceable" value="true" />
364364
</element>
@@ -368,12 +368,12 @@
368368
<simple name="replaceable" value="true" />
369369
</element>
370370
<element>
371-
<simple name="source" value="$(commonDir)/src/main/main-220-loopend.c" />
371+
<simple name="source" value="$(commonDir)/src/main/main-220-$(syscalls)-loopend.c" />
372372
<simple name="target" value="$(sourceDir)/main.$(fileExtension)" />
373373
<simple name="replaceable" value="true" />
374374
</element>
375375
<element>
376-
<simple name="source" value="$(commonDir)/src/main/main-230-end.c" />
376+
<simple name="source" value="$(commonDir)/src/main/main-230-$(syscalls)-end.c" />
377377
<simple name="target" value="$(sourceDir)/main.$(fileExtension)" />
378378
<simple name="replaceable" value="true" />
379379
</element>
@@ -493,12 +493,12 @@
493493
<simple name="replaceable" value="true" />
494494
</element>
495495
<element>
496-
<simple name="source" value="$(commonDir)/src/main/main-200-loop-empty.c" />
496+
<simple name="source" value="$(commonDir)/src/main/main-200-$(syscalls)-loop-empty.c" />
497497
<simple name="target" value="$(sourceDir)/main.$(fileExtension)" />
498498
<simple name="replaceable" value="true" />
499499
</element>
500500
<element>
501-
<simple name="source" value="$(commonDir)/src/main/main-230-end.c" />
501+
<simple name="source" value="$(commonDir)/src/main/main-230-$(syscalls)-end.c" />
502502
<simple name="target" value="$(sourceDir)/main.$(fileExtension)" />
503503
<simple name="replaceable" value="true" />
504504
</element>

0 commit comments

Comments
 (0)