-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FR] needs build instructions / examples #6
Comments
@ildar CC = gcc -Wall -O2 -I./inc
SDCC = sdcc -mstm8 -DSTM8103 -DSTM8S103 -I./inc
SDAR = sdar
NAME = lib_sdcc
SOURCES = $(wildcard src/*.c)
OBJS = $(SOURCES:.c=.rel)
.SUFFIXES : .rel .c
all: $(NAME).lib
$(NAME).lib: $(OBJS)
$(SDAR) -rc $@ $(OBJS)
.c.rel:
$(SDCC) -c $< -o $@
clean:
rm -f ${OBJS:.rel=.map} ${OBJS:.rel=.rst} ${OBJS:.rel=.cdb} ${OBJS:.rel=.asm} ${OBJS:.rel=.lst} ${OBJS:.rel=.sym} $(OBJS) $(NAME).lib Build make Copy files stm8s_it.c and stm8s_it.h to the project and use it in Makefile of project like that: ## Select one of these
DEVICE=stm8s103f3
## A directory for common include files
COMMONDIR = ..
SDCC_LIBS = ../stm8s-sdcc
PROGRAM = i2c_slave
SOURCES=$(wildcard *.c $(COMMONDIR)/*.c)
OBJECTS=$(SOURCES:.c=.rel)
HEADERS=$(wildcard *.h $(COMMONDIR)/*.h $(SDCC_LIBS)/inc/*.h)
CC = sdcc
PROGRAMMER = stlinkv2
DEFINES=
## Set MCU-type DEFINE
ifeq ($(DEVICE),stm8s003f3)
DEFINES += -DSTM8S003
# stm8_libs define
DEFINES += -DSTM8003
endif
ifeq ($(DEVICE),stm8s103f3)
DEFINES += -DSTM8S103
# stm8_libs define
DEFINES += -DSTM8103
endif
CPPFLAGS = -I$(COMMONDIR)
CFLAGS = --Werror --std-sdcc99 -mstm8 $(DEFINES)
LDFLAGS = -lstm8 -mstm8 --out-fmt-ihx
LDLIBS = -l$(SDCC_LIBS)/lib_sdcc.lib
.PHONY: all clean
$(PROGRAM).ihx: $(OBJECTS)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
%.rel : %.c $(HEADERS)
$(CC) -I$(SDCC_LIBS) $(LDLIBS) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
CCOMPILEDFILES=$(SOURCES:.c=.asm) $(SOURCES:.c=.lst) $(SOURCES:.c=.rel) \
$(SOURCES:.c=.rst) $(SOURCES:.c=.sym)
clean:
rm -f $(PROGRAM).ihx \
$(PROGRAM).cdb \
$(PROGRAM).lk \
$(PROGRAM).map \
$(CCOMPILEDFILES)
flash: $(PROGRAM).ihx
stm8flash -c $(PROGRAMMER) -p $(DEVICE) -w $(PROGRAM).ihx
|
looks great, thanks a lot!
Worth a PR.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just for a developer to start with.
Or maybe links to a HOWTO would be good...
The text was updated successfully, but these errors were encountered: