diff --git a/firmware/Makefile b/firmware/Makefile index ab2d535..17c50d3 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -1,24 +1,44 @@ -SDCC=sdcc -SDLD=sdld -OBJECT=halo.ihx +SOURCEDIR = src +BUILDDIR = build +INCLUDEDIR = include + +LDCC := sdcc +CFLAGS := -lstm8 -mstm8 + +FIRMWARE_IMAGE = $(BUILDDIR)/halo-fw.ihx + +DEBUG_FW_IMAGE = $(patsubst $(BUILDDIR)/%.ihx,$(BUILDDIR)/%.elf,$(FIRMWARE_IMAGE)) +SOURCES = $(wildcard $(SOURCEDIR)/*.c) +OBJECTS = $(patsubst $(SOURCEDIR)/%.c,$(BUILDDIR)/%.rel,$(SOURCES)) .PHONY: all clean flash -all: $(OBJECT) +all: $(FIRMWARE_IMAGE) clean: - rm -f $(OBJECT) *.cdb *.adb *.asm *.li *.lst *.map *.rel *.rst *.sym *.lk + @echo "Cleaning up '$(BUILDDIR)' directory" + rm -r $(BUILDDIR) -flash: $(OBJECT) -ifeq (,$(command -v STVP_CmdLine.exe)) - STVP_CmdLine.exe -Device=STM8L15xG4 -FileProg=$(OBJECT) -verif -no_loop -no_log -else ifeq (,$(command -v stm8flash)) - stm8flash -cstlink -pstm8l151 -w $(OBJECT) +flash: $(FIRMWARE_IMAGE) +ifneq (, $(shell command -v STVP_CmdLine.exe;)) + STVP_CmdLine.exe -Device=STM8L15xG4 -FileProg=$(FIRMWARE_IMAGE) -verif -no_loop -no_log +else ifneq (, $(shell command -v stm8flash;)) + stm8flash -cstlinkv2 -p"stm8l151?4" -w $(FIRMWARE_IMAGE) else @echo "STVP_CmdLine or stm8flash not found" endif - - -%.ihx: %.c - $(SDCC) -lstm8 -mstm8 --out-fmt-ihx --debug $(CFLAGS) $(LDFLAGS) $< +debug: CFLAGS += --debug +debug: $(DEBUG_FW_IMAGE) + +$(BUILDDIR): + @mkdir -p build + +$(OBJECTS): $(BUILDDIR)/%.rel : $(SOURCEDIR)/%.c | $(BUILDDIR) + $(LDCC) $(CFLAGS) -I$(INCLUDEDIR) $(LDFLAGS) -c $< -o $@ + +$(FIRMWARE_IMAGE): $(OBJECTS) | $(BUILDDIR) + $(LDCC) $(CFLAGS) --out-fmt-ihx $^ -o $@ + +$(DEBUG_FW_IMAGE): $(OBJECTS) | $(BUILDDIR) + $(LDCC) $(CFLAGS) --out-fmt-elf $^ -o $@ diff --git a/firmware/halo.ihx b/firmware/halo.ihx deleted file mode 100644 index 7438e7a..0000000 --- a/firmware/halo.ihx +++ /dev/null @@ -1,72 +0,0 @@ -:20800000820080738200000082000000820000008200000082000000820080BD8200000020 -:20802000820000008200000082000000820000008200000082000000820000008200000030 -:20804000820081B08200000082000000820000008200814F8200811A820000008200000074 -:10806000820000008200000082000000820082ABDB -:1D807300AE00002707724F00005A26F9AE002D2709D6808FD700005A26F7CC8070E0 -:03807000CC82FCC3 -:2080BD004F62C60004A1012706A102271C20465FC60001971C000D4B5A4B0089CD88345BCA -:2080DD00049F88CD862484202CCD87B74B0F4B0089CD88345B045D27093B0001CD86F88458 -:2080FD002013CD87B74B5A4B0089CD88345B049F88CD862484AE514DA6FBF4F7804F625247 -:20811D0002C6000297494FA20095C600036B027B02494FA2006B0172FB014B5A4B0089CD05 -:20813D0088345B049FC70002AE5256A6FEF4F75B02804F625206AE5340A6FEF4F7C65345A6 -:20815D0097C653440F040F011A01011A04971F05C6000297494FA200951C102C72FB05906E -:20817D00AE005A65909F88CD862484AE5343A6FEF4F7AE5340F6AA01F7AE534BF6AA40F7F4 -:20819D005FA300302E035C20F8AE5340F6AA02F75B06804F6252115FA3138824049D5C203E -:2081BD00F7AE00261F04FEE6016B03AE00291F01F614036B0D2703CC82A1725D00052703CE -:2081DD00CC825E4BF4CD84DE84CD8524C600046B0C0F0B1E0B5C1F094B034B001E0B89CD4E -:2081FD0088345B041F077B08C70004C60004A100270BA101271AA102272FCC82A1AE7F60DE -:20821D00A6FDF4F7CD84B2CD8587CD83E7CC82A1CD8405CD85ADAE7F60F6AA02F74B024B9E -:20823D0000CD846E5B02CC82A1CD85ADCD8405AE7F60F6AA02F74B644B00CD846E5B022065 -:20825D00435F1F0E5F1F101E10A34E20242F1E04FEE6016B061E01F6140626121E0E5C1F8C -:20827D000E1E0E90AE00C8659F88CD8624841E0EA346502301751E105C1F1020CA3B00013D -:20829D00CD86F884AE50A3F6AA40F75B11804F62883B0001CD86F884AE0026FEE6016B0125 -:2082BD00AE0029F61401262E725D00052628AE7F60F6AA02F7CD8405CD85ADCD8545CD84E6 -:2082DD00B2AE52E5A6FEF4F7350100053B0001CD86F8848E2007AE52E5A6FEF4F784805296 -:2082FD00069B350050C05F1F051E05A3000A2E301E05581C00061F03FE5C5CF66B021605D7 -:20831D0072A9001A90F6431402F71E03FE1C0003F66B0190F6431401F71E055C1F0520C934 -:20833D00CD855B4B884B13CD83A25B02CD85BCCD841BCD84B2CD8587CD83E79A8F20FD5BC5 -:20835D0006815204AE5340F6AA01F7AE534BF6AA40F75FA3000C2E035C20F8AE5340F6AA93 -:20837D0002F7AE5343F6A40127F8AE5340A6FEF4F7C6534597C653440F040F011A01011A6E -:20839D0004975B0481AE50C3F6AA01F7AE5250A6FEF4F7AE7F74A63FF4AA40F7AE525079E9 -:2083BD0099763500525C3500525D35005258AE525EF6AA07F77B03C7525F7B04C75260AE53 -:2083DD005255F6AA01F7CD83E781AE50C3F6AA01F73500525C3500525DAE5255F6AA01F77C -:2083FD00AE5250F6AA01F781AE5255A6FEF4F7AE5250A6FEF4F7AE50C3A6FEF4F781AE5065 -:20841D00C1F6AA04F7AE50C1F6A40126F8AE50C4F6AA04F7AE5159A6CAF7AE5159A653F707 -:20843D00AE5149A6FBF4F7AE514CF64444A40127F63500515435015155AE5148A6F0F4AA8F -:20845D0003F7AE50C2F6AA10F7AE50C4A6FBF4F781AE50C4F6AA04F7AE7F71A6FCF4F7AE99 -:20847D005159A6CAF7AE5159A653F7AE5149A6FBF4F7AE514CF64444A40127F67B03C75191 -:20849D00547B04C75155AE5149F6AA40F7AE5149F6AA04F781AE5159A6CAF7AE5159A653EC -:2084BD00F7AE5149A6FBF4F7AE514CF64444A40127F6AE5149A6BFF4F7AE50C4A6FBF4F763 -:2084DD0081AE50C3F6AA04F7AE7F76F6AA0CF7AE52E0A6FEF4F7350052E7AE52E079997617 -:2084FD00AE52E0F6AA04F7350052E6AE52E8F6AA0FF7AE52E97B03F7AE52E0F6AA08F7AE5E -:20851D0050C3A6FBF4F781AE50C3F6AA04F7350052E7AE52E6F6AA01F7AE52E4F6AA01F75A -:20853D00AE52E0F6AA01F781AE52E4A6FEF4F7AE52E0A6FEF4F7AE50C3A6FBF4F781AE7F48 -:20855D0074A6CFF4AA10F7AE50C4F6AA01F7AE5340A69FF4F7AE5341F6AA07F7AE534A7901 -:20857D009976AE5340A6FBF4F781AE5340F6AA08F7AE5340F6AA01F7AE534BF6AA40F75F46 -:20859D00A3000C2E035C20F8AE5340F6AA02F781AE5340A6F7F4F7AE5340A6FEF4F78152A3 -:2085BD0008CE00245C5CF66B0590AE002890F61A05F7CE00241C0003F66B0490F61A04F773 -:2085DD00CE0024F66B0390F6431403F7AE00261F01FE5C5CF66B08905C90F6431408F71E58 -:2085FD0001FE1C0003F66B0790F61A07F71E01FE1C0004F66B0690F61A06F7AE50A1A6CFE5 -:20861D00F4AA20F75B08813B0001CD86F8847B0388CD8638847B03C700018152145F7B1766 -:20863D0097894B094B0089CD884A5B041F05857B046B127B126B05A60910056B114B094B56 -:20865D000089CD88345B04A609891002856B107B106B020F01AE000972F0017B116B0F0F0B -:20867D000E130E2F020A105F7B1297581C00061F0CFE5C5CF66B0B905F7B12909772A9005B -:20869D001A90F61A0BF71E0CFE1C0003F66B0A90F61A0AF71E0CFEF66B0990F61A09F75F1D -:2086BD007B1097581C00061F07FE5C5CF66B06905F7B10909772A9001A90F61A06F71E0726 -:2086DD00FE1C0003F66B1490F61A14F71E07FEF66B1390F6431413F75B148152135F7B167D -:2086FD0097894B094B0089CD884A5B041F03857B026B077B076B05A60910056B064B094BBB -:20871D000089CD88345B04A609891002856B130F12AE000972F012887B076B12840F1013F5 -:20873D00102F014A5F97581C00061F0EFE88F66B0E84905F909772A9001A90F61A0DF71E6F -:20875D000EFE5C5CF66B0C90F643140CF71E0EFE1C0003F66B0B90F643140BF75F7B0797DF -:20877D00581C00061F09FEF66B08905F7B07909772A9001A90F6431408F71E09FE5C5CF657 -:1A879D006B0490F6431404F71E09FE1C0003F66B0390F6431403F75B13810D -:20809000002D0100005000500050055000500F500F500F50005005500504100820020408FC -:0980B00008802050055005024033 -:2087B7005214CE002C1F03CE002A1F011E027B010F09445644561802889F1805021804950F -:2087D7007B0A18029095841F0E6B0D0F100810090F090E090D180E90979F181002180F9547 -:2087F700909E180D90951F1317115F7B11974F0F0554181290979F1814021813957B0518E1 -:1D881700119095CF002C90CF002A58545B148116035F58995690CF002CCF002A812A -:0480B9008000000142 -:2088340016051E039E2A0150905D2A029050654D2A02905093811E039E16052A03439050DA -:0A8854005D2A0150654D2A01508194 -:00000001FF diff --git a/firmware/STM8L151G6.h b/firmware/include/STM8L151G6.h similarity index 100% rename from firmware/STM8L151G6.h rename to firmware/include/STM8L151G6.h diff --git a/firmware/halo.c b/firmware/src/halo.c similarity index 99% rename from firmware/halo.c rename to firmware/src/halo.c index cc0cd9a..28df939 100644 --- a/firmware/halo.c +++ b/firmware/src/halo.c @@ -397,4 +397,4 @@ void ledLow(uint8_t led) { CPX_PORT[col]->ODR.byte &= ~CPX_PIN[col]; CPX_PORT[col]->DDR.byte &= ~CPX_PIN[col]; CPX_PORT[col]->CR1.byte &= ~CPX_PIN[col]; -} \ No newline at end of file +}