chiark / gitweb /
ignore PIR3, since we may want to use PIC18F4550
[trains.git] / pic.make
1 # recommended programming order
2 #   one test on PIC#0
3 #       first time:                             erase, write FOO-entire0.hex
4 #       subsequently if only FOO.asm changed:   update FOO.hex
5 #   for all pics
6 #       first time:     for each individually   erase, write perpicNUM.hex
7 #                       then for all            update FOO.hex
8 #       subsequently:   for all                 update FOO.hex
9 #   other possibilities are not ruled out
10 #
11 # filename conventions - contents of hex files
12 #   FOO.hex             FOO.o (only)
13 #   FOO-withcfg.hex     FOO.o                           config.o
14 #   FOO-entire0.hex     FOO.o           idlocs0.o       config.o
15 #   perpicNUMBER.hex                    idlocsNUMBER.o  config.o
16
17 #ASFLAGS=       -Dmclock=20000 -Dsclock=20000
18 CLOCKS=         -Dmclock=32000 -Dsclock=4000
19 ASFLAGS=        $(CLOCKS)
20
21 HEXMERGER=      $(CEBPIC)merge-hex
22 MERGEHEX=       ./$^ $o
23
24 PIC=            18f458
25 LINK=           gplink -m -o $@ $^
26 ASSEMBLE=       gpasm -p$(PIC)  $(ASFLAGS)
27 DOASSEMBLE=     $(ASSEMBLE) -c $< && mv $*.lst $*+asm.lst
28
29 PIC_HEADER=     /usr/share/gputils/header/p$(PIC).inc
30
31 %.o:            %.asm $(INCLUDES)
32                 $(DOASSEMBLE)
33
34 TIA_DIR=        ../iwjpictest
35 TIA_TIA=        $(TIA_DIR)/to-insn-aliases
36 TIA_ALIASES=    $(TIA_DIR)/insn-aliases.inc
37 TIA=            $(TIA_TIA) -A $(TIA_ALIASES) -H $(PIC_HEADER)
38
39 %.disasm:       %.hex %.map $(TIA_TIA) $(TIA_ALIASES)
40                 gpdasm -p$(PIC) $(word 1,$+) >$@.tmp
41                 $(TIA) -M $(word 2,$+) <$@.tmp $o
42                 @rm $@.tmp
43
44 .PRECIOUS:      %.o
45
46 pic-clean:
47                 -rm -f -- *~ *.new *.tmp *.disasm
48                 -rm -f *.hex *.cod *.lst *.o *.map