Skip to content

Commit c60c6ed

Browse files
committed
converted some tests to use the new sduino.mk (adc1, digitalWrite, print, pwm1)
1 parent 95500e5 commit c60c6ed

10 files changed

Lines changed: 158 additions & 135 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ tags
1717
*.sym
1818
*.lk
1919
*.map
20+
# ignore files generated by the Arduino make system:
21+
build-*

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,12 @@ Wire/I2C
255255
#### not implemented
256256
`yield()`
257257

258+
The compile environment needs to detect which interrupts are actively used
259+
and link only the needed ones into the binary. See test/digitalWrite:
260+
Compiling with the straight Makefile.classic does not add UART interrupt
261+
routines. But when using the sduino.mk Makefile the two UART interrupt
262+
routines are pulled into the binary by the interrupt table in main.c.
263+
258264

259265

260266
## Differences from the original Arduino environment
@@ -302,9 +308,13 @@ Migration guideline within the STM8L familiy
302308

303309

304310

305-
### Anmerkungen zu SDCC
311+
### Notes on SDCC
312+
313+
The linker `sdld` does not automatically link the object file for main.c if it
314+
is part of a library. It must be part of the list of object files. (Important
315+
for the build process with Arduino.mk)
306316

307-
Befehl '_ _ critical{..}' sollte eigentlich den vorherigen Interrupt-Zustand
317+
Befehl `__critical{..}` sollte eigentlich den vorherigen Interrupt-Zustand
308318
wiederherstellen, es wird aber einfach ein festes Paar sim/rim produziert.
309319
Mit "push cc; sim" und "pop cc" klappt es im Simulator, aber nicht in der
310320
Realität.

sduino/pins_arduino.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ static const uint8_t PROGMEM analogInputToDigitalPinMap[5]={6,11,12,14,15};
6969
* This way it does get optimized to a hard constant load when used with a
7070
* const value. It is extremy ineffizient for run time accesses though.
7171
*/
72-
/*
72+
7373
#define analogInputToDigitalPin(p) ( (p<0)?-1:(\
7474
(p<1)?PIN_A0:(\
7575
(p<2)?PIN_A1:(\
7676
(p<3)?PIN_A2:(\
7777
(p<4)?PIN_A3:(\
7878
(p<5)?PIN_A4:(\
7979
-1)))))))
80-
*/
80+
8181

8282

8383
#ifdef SUPPORT_ALTERNATE_MAPPINGS

test/adc1/Makefile

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,5 @@
1-
BASENAME=$(shell basename $$(pwd))
2-
EXECUTABLE=$(BASENAME).ihx
1+
BOARD_TAG = stm8sblue
32

4-
#SDCCBASE=/usr/local
5-
SDCCBASE=/opt/sdcc
6-
BINDIR=$(SDCCBASE)/bin
7-
CC=$(BINDIR)/sdcc
8-
LD=$(BINDIR)/sdld
3+
CFLAGS= --debug -DSUPPORT_ALTERNATE_MAPPINGS
94

10-
LIBBASE=../../STM8S_StdPeriph_Driver
11-
SDUINO=../../sduino
12-
13-
CFLAGS= --debug -mstm8 -DF_CPU=16000000L -DSTM8S103 -DSUPPORT_ALTERNATE_MAPPINGS \
14-
-I. -I$(SDUINO) -I$(LIBBASE)/inc -I/usr/share/sdcc/include/
15-
16-
LDFLAGS=-L$(LIBBASE)/src -L/opt/sdcc/share/sdcc/lib/stm8 -lstm8s103
17-
18-
OBJECTS=$(BASENAME).rel
19-
SDOBJECTS=main.rel wiring.rel wiring_digital.rel wiring_analog.rel \
20-
HardwareSerial.rel Print.rel
21-
22-
.PHONY: all clean flash
23-
24-
#all: $(OBJECTS)
25-
26-
$(EXECUTABLE): $(OBJECTS) $(SDOBJECTS)
27-
#test.rel wiring_digital.rel
28-
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
29-
30-
$(OBJECTS) : %.rel : %.c
31-
$(CC) -c $(CFLAGS) $^ -o $@
32-
33-
$(SDOBJECTS) : %.rel : $(SDUINO)/%.c
34-
$(CC) -c $(CFLAGS) $^ -o $@
35-
36-
flash: $(EXECUTABLE)
37-
stm8flash -cstlinkv2 -pstm8s103?3 -w $^
38-
39-
readopt:
40-
stm8flash -c stlinkv2 -p stm8s103?3 -s opt -r opt.bin
41-
42-
43-
clean:
44-
rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \
45-
*.cdb *.adb *~ *.bak
46-
rm -f $(EXECUTABLE)
5+
include ../../sduino/sduino.mk

test/adc1/Makefile.classic

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
BASENAME=$(shell basename $$(pwd))
2+
EXECUTABLE=$(BASENAME).ihx
3+
4+
#SDCCBASE=/usr/local
5+
SDCCBASE=/opt/sdcc
6+
BINDIR=$(SDCCBASE)/bin
7+
CC=$(BINDIR)/sdcc
8+
LD=$(BINDIR)/sdld
9+
10+
LIBBASE=../../STM8S_StdPeriph_Driver
11+
SDUINO=../../sduino
12+
13+
CFLAGS= --debug -mstm8 -DF_CPU=16000000L -DSTM8S103 -DSUPPORT_ALTERNATE_MAPPINGS \
14+
-I. -I$(SDUINO) -I$(LIBBASE)/inc -I/usr/share/sdcc/include/
15+
16+
LDFLAGS=-L$(LIBBASE)/src -L/opt/sdcc/share/sdcc/lib/stm8 -lstm8s103
17+
18+
OBJECTS=$(BASENAME).rel
19+
SDOBJECTS=main.rel wiring.rel wiring_digital.rel wiring_analog.rel \
20+
HardwareSerial.rel Print.rel
21+
22+
.PHONY: all clean flash
23+
24+
#all: $(OBJECTS)
25+
26+
$(EXECUTABLE): $(OBJECTS) $(SDOBJECTS)
27+
#test.rel wiring_digital.rel
28+
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
29+
30+
$(OBJECTS) : %.rel : %.c
31+
$(CC) -c $(CFLAGS) $^ -o $@
32+
33+
$(SDOBJECTS) : %.rel : $(SDUINO)/%.c
34+
$(CC) -c $(CFLAGS) $^ -o $@
35+
36+
flash: $(EXECUTABLE)
37+
stm8flash -cstlinkv2 -pstm8s103?3 -w $^
38+
39+
readopt:
40+
stm8flash -c stlinkv2 -p stm8s103?3 -s opt -r opt.bin
41+
42+
43+
clean:
44+
rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \
45+
*.cdb *.adb *~ *.bak
46+
rm -f $(EXECUTABLE)

test/print/Makefile

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,3 @@
1-
BASENAME=$(shell basename $$(pwd))
2-
EXECUTABLE=$(BASENAME).ihx
1+
BOARD_TAG = stm8sblue
32

4-
#SDCCBASE=/usr/local
5-
SDCCBASE=/opt/sdcc
6-
BINDIR=$(SDCCBASE)/bin
7-
CC=$(BINDIR)/sdcc
8-
LD=$(BINDIR)/sdld
9-
10-
LIBBASE=../../STM8S_StdPeriph_Driver
11-
SDUINO=../../sduino
12-
13-
CFLAGS= --debug -mstm8 -DF_CPU=2000000L -DSTM8S103 \
14-
-I. -I$(SDUINO) -I$(LIBBASE)/inc -I$(SDCCBASE)/share/sdcc/include/
15-
16-
LDFLAGS=-L$(LIBBASE)/src -L$(SDCCBASE)/share/sdcc/lib/stm8 -lstm8s
17-
18-
OBJECTS=$(BASENAME).rel
19-
SDOBJECTS=main.rel wiring.rel \
20-
HardwareSerial.rel Print.rel
21-
22-
.PHONY: all clean flash
23-
24-
#all: $(OBJECTS)
25-
26-
$(EXECUTABLE): $(OBJECTS) $(SDOBJECTS)
27-
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
28-
29-
$(OBJECTS) : %.rel : %.c
30-
$(CC) -c $(CFLAGS) $^ -o $@
31-
32-
$(SDOBJECTS) : %.rel : $(SDUINO)/%.c
33-
$(CC) -c $(CFLAGS) $^ -o $@
34-
35-
flash: $(EXECUTABLE)
36-
stm8flash -cstlinkv2 -pstm8s103?3 -w $^
37-
38-
39-
clean:
40-
rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \
41-
*.cdb *.adb *~ *.bak
42-
rm -f $(EXECUTABLE)
3+
include ../../sduino/sduino.mk

test/print/Makefile.classic

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
BASENAME=$(shell basename $$(pwd))
2+
EXECUTABLE=$(BASENAME).ihx
3+
4+
#SDCCBASE=/usr/local
5+
SDCCBASE=/opt/sdcc
6+
BINDIR=$(SDCCBASE)/bin
7+
CC=$(BINDIR)/sdcc
8+
LD=$(BINDIR)/sdld
9+
10+
LIBBASE=../../STM8S_StdPeriph_Driver
11+
SDUINO=../../sduino
12+
13+
CFLAGS= --debug -mstm8 -DF_CPU=2000000L -DSTM8S103 \
14+
-I. -I$(SDUINO) -I$(LIBBASE)/inc -I$(SDCCBASE)/share/sdcc/include/
15+
16+
LDFLAGS=-L$(LIBBASE)/src -L$(SDCCBASE)/share/sdcc/lib/stm8 -lstm8s
17+
18+
OBJECTS=$(BASENAME).rel
19+
SDOBJECTS=main.rel wiring.rel \
20+
HardwareSerial.rel Print.rel
21+
22+
.PHONY: all clean flash
23+
24+
#all: $(OBJECTS)
25+
26+
$(EXECUTABLE): $(OBJECTS) $(SDOBJECTS)
27+
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
28+
29+
$(OBJECTS) : %.rel : %.c
30+
$(CC) -c $(CFLAGS) $^ -o $@
31+
32+
$(SDOBJECTS) : %.rel : $(SDUINO)/%.c
33+
$(CC) -c $(CFLAGS) $^ -o $@
34+
35+
flash: $(EXECUTABLE)
36+
stm8flash -cstlinkv2 -pstm8s103?3 -w $^
37+
38+
39+
clean:
40+
rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \
41+
*.cdb *.adb *~ *.bak
42+
rm -f $(EXECUTABLE)

test/pwm1/Makefile

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,3 @@
1-
BASENAME=$(shell basename $$(pwd))
2-
EXECUTABLE=$(BASENAME).ihx
1+
BOARD_TAG = stm8sblue
32

4-
#SDCCBASE=/usr/local
5-
SDCCBASE=/opt/sdcc
6-
BINDIR=$(SDCCBASE)/bin
7-
CC=$(BINDIR)/sdcc
8-
LD=$(BINDIR)/sdld
9-
10-
LIBBASE=../../STM8S_StdPeriph_Driver
11-
SDUINO=../../sduino
12-
13-
CFLAGS= --debug -mstm8 -DF_CPU=16000000L -DSTM8S103 \
14-
-I. -I$(SDUINO) -I$(LIBBASE)/inc -I/usr/share/sdcc/include/
15-
# -DSUPPORT_ALTERNATE_MAPPINGS
16-
17-
LDFLAGS=-L$(LIBBASE)/src -L/opt/sdcc/share/sdcc/lib/stm8 -lstm8s103
18-
19-
OBJECTS=$(BASENAME).rel
20-
SDOBJECTS=main.rel wiring.rel wiring_digital.rel wiring_analog.rel \
21-
HardwareSerial.rel Print.rel
22-
23-
.PHONY: all clean flash
24-
25-
#all: $(OBJECTS)
26-
27-
$(EXECUTABLE): $(OBJECTS) $(SDOBJECTS)
28-
#test.rel wiring_digital.rel
29-
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
30-
31-
$(OBJECTS) : %.rel : %.c
32-
$(CC) -c $(CFLAGS) $^ -o $@
33-
34-
$(SDOBJECTS) : %.rel : $(SDUINO)/%.c
35-
$(CC) -c $(CFLAGS) $^ -o $@
36-
37-
flash: $(EXECUTABLE)
38-
stm8flash -cstlinkv2 -pstm8s103?3 -w $^
39-
40-
readopt:
41-
stm8flash -c stlinkv2 -p stm8s103?3 -s opt -r opt.bin
42-
43-
44-
clean:
45-
rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \
46-
*.cdb *.adb *~ *.bak
47-
rm -f $(EXECUTABLE)
3+
include ../../sduino/sduino.mk

test/pwm1/Makefile.classic

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
BASENAME=$(shell basename $$(pwd))
2+
EXECUTABLE=$(BASENAME).ihx
3+
4+
#SDCCBASE=/usr/local
5+
SDCCBASE=/opt/sdcc
6+
BINDIR=$(SDCCBASE)/bin
7+
CC=$(BINDIR)/sdcc
8+
LD=$(BINDIR)/sdld
9+
10+
LIBBASE=../../STM8S_StdPeriph_Driver
11+
SDUINO=../../sduino
12+
13+
CFLAGS= --debug -mstm8 -DF_CPU=16000000L -DSTM8S103 \
14+
-I. -I$(SDUINO) -I$(LIBBASE)/inc -I/usr/share/sdcc/include/
15+
# -DSUPPORT_ALTERNATE_MAPPINGS
16+
17+
LDFLAGS=-L$(LIBBASE)/src -L/opt/sdcc/share/sdcc/lib/stm8 -lstm8s103
18+
19+
OBJECTS=$(BASENAME).rel
20+
SDOBJECTS=main.rel wiring.rel wiring_digital.rel wiring_analog.rel \
21+
HardwareSerial.rel Print.rel
22+
23+
.PHONY: all clean flash
24+
25+
#all: $(OBJECTS)
26+
27+
$(EXECUTABLE): $(OBJECTS) $(SDOBJECTS)
28+
#test.rel wiring_digital.rel
29+
$(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@
30+
31+
$(OBJECTS) : %.rel : %.c
32+
$(CC) -c $(CFLAGS) $^ -o $@
33+
34+
$(SDOBJECTS) : %.rel : $(SDUINO)/%.c
35+
$(CC) -c $(CFLAGS) $^ -o $@
36+
37+
flash: $(EXECUTABLE)
38+
stm8flash -cstlinkv2 -pstm8s103?3 -w $^
39+
40+
readopt:
41+
stm8flash -c stlinkv2 -p stm8s103?3 -s opt -r opt.bin
42+
43+
44+
clean:
45+
rm -f *.lib *.rst *.rel *.lst *.ihx *.sym *.asm *.lk *.map \
46+
*.cdb *.adb *~ *.bak
47+
rm -f $(EXECUTABLE)

0 commit comments

Comments
 (0)