chiark / gitweb /
put %! at start but do not break segcmapreq
[trains.git] / pic.make
index 93e62e76bb4b601c9419b198735029acde220196..d445442b7335a2ee17a4b33b84c7d9d2e41cf69f 100644 (file)
--- a/pic.make
+++ b/pic.make
@@ -1,41 +1,48 @@
-
-M4INCS=                parts.i4
-
-E_TRACK=       ArsCLMNo
-LAYOUTOPTS_ALL=        -ep=*Cm
-LAYOUTOPTS=    -E=*$(E_TRACK) $(LAYOUTOPTS_ALL)
-LAYERS_LS=     0 10 20
-LAYERS_PS=     $(addsuffix .ps, $(LAYERS_LS))
-LAYERS_L=      $(addprefix ours-l, $(LAYERS_PS))
-LAYERS_E=      $(addprefix ours-e, $(LAYERS_PS))
-LAYERS=                $(LAYERS_L) $(LAYERS_E)
-
-default:       ours-a.ps ours-al.ps parts.ps
-layers:                $(LAYERS)
-
-all:           default layers
-
-o=>$@.new && mv -f $@.new $@
-
-%.d4:          %.m4 $(M4INCS) Makefile
-               m4 -s <$< $o
-
-%-a.ps:                %.d4 layout
-               ./layout <$< $(LAYOUTOPTS) '-E*l' $o
-
-%-al.ps:       %.d4 layout
-               ./layout <$< $(LAYOUTOPTS) '-e*C' '-ep=rm' $o
-
-ours-l%.ps:    ours.d4 layout
-               ./layout <$< -l$* $(LAYOUTOPTS) \
-                       -e'=5AN' -E'*~=5rsm' -e'p~=5r' -e'*~=9C' -e'*=*l' $o
-
-ours-e%.ps:    ours.d4 layout
-               ./layout <$< -l$* -E'=*aRsclMno' \
-                       -e'p=*rm' -e'=5RN' -E'*~=5rsm' -e'p~=5r' -e'*=*l' $o
-
-parts.ps:      showlib.d4 layout
-               ./layout <$< $(LAYOUTOPTS_ALL) $o
-
-clean:
-               -rm -f -- *.d4 *.ps
+# recommended programming order
+#   one test on PIC#0
+#      first time:                             erase, write FOO-entire0.hex
+#      subsequently if only FOO.asm changed:   update FOO.hex
+#   for all pics
+#      first time:     for each individually   erase, write perpicNUM.hex
+#                      then for all            update FOO.hex
+#      subsequently:   for all                 update FOO.hex
+#   other possibilities are not ruled out
+#
+# filename conventions - contents of hex files
+#   FOO.hex            FOO.o (only)
+#   FOO-withcfg.hex    FOO.o                           config.o
+#   FOO-entire0.hex    FOO.o           idlocs0.o       config.o
+#   perpicNUMBER.hex                   idlocsNUMBER.o  config.o
+
+#ASFLAGS=      -Dmclock=20000 -Dsclock=20000
+CLOCKS=                -Dmclock=32000 -Dsclock=4000
+ASFLAGS=       $(CLOCKS)
+
+HEXMERGER=     $(CEBPIC)merge-hex
+MERGEHEX=      ./$^ $o
+
+PIC=           18f458
+LINK=          gplink -m -o $@ $^
+ASSEMBLE=      gpasm -p$(PIC)  $(ASFLAGS)
+DOASSEMBLE=    $(ASSEMBLE) -c $< && mv $*.lst $*+asm.lst
+
+PIC_HEADER=    /usr/share/gputils/header/p$(PIC).inc
+
+%.o:           %.asm $(INCLUDES)
+               $(DOASSEMBLE)
+
+TIA_DIR=       ../iwjpictest
+TIA_TIA=       $(TIA_DIR)/to-insn-aliases
+TIA_ALIASES=   $(TIA_DIR)/insn-aliases.inc
+TIA=           $(TIA_TIA) -A $(TIA_ALIASES) -H $(PIC_HEADER)
+
+%.disasm:      %.hex %.map $(TIA_TIA) $(TIA_ALIASES)
+               gpdasm -p$(PIC) $(word 1,$+) >$@.tmp
+               $(TIA) -M $(word 2,$+) <$@.tmp $o
+               @rm $@.tmp
+
+.PRECIOUS:     %.o
+
+pic-clean:
+               -rm -f -- *~ *.new *.tmp *.disasm
+               -rm -f *.hex *.cod *.lst *.o *.map