trackswitch/Makefile

Tue, 29 Nov 2011 15:06:08 +0100

author
Malte Bayer <mbayer@neo-soft.org>
date
Tue, 29 Nov 2011 15:06:08 +0100
changeset 20
e333cf0e4d84
parent 19
40a309c9c135
child 21
8b7cdb655e7b
permissions
-rw-r--r--

finished trackswitch v1.0 - works as original firmware now

19
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
1 PRG=main
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
2
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
3 MCU=atmega8
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
4 FUSES=-U lfuse:w:0xAE:m -U hfuse:w:0xd9:m
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
5 #FUSES=-U lfuse:w:0x83:m -U hfuse:w:0xd9:m
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
6 BOOTFUSES=-U lfuse:w:0xff:m -U hfuse:w:0xce:m
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
7
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
8 #F_CPU=4185600
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
9 #F_CPU = 14318000
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
10
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
11 F_CPU = 8000000
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
12 BAUD=38400
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
13
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
14 ISP_BAUD = 115200
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
15
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
16 #SRC = main.c seriald.c driver/ADC.c driver/clock.c driver/timer.c
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
17 #SRC = main.c driver/rs232.c driver/manchester.c
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
18 SRC = main.c driver/rs232.c
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
19
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
20 ###################################################################
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
21 # You possibly do not need to change settings below this marker
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
22 ###################################################################
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
23
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
24 # Binaries to be used
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
25 # You may add the path to them if they are not in the PATH variable.
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
26 CC = avr-gcc
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
27 OBJCOPY = avr-objcopy
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
28 OBJDUMP = avr-objdump
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
29 AVRDUDE = avrdude
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
30 PERL = perl
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
31
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
32 # Optional library search path
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
33 LIBS =
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
34
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
35 # Compiler options for all c source files
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
36 CFLAGS += -g -Wall -mmcu=$(MCU) -DBAUD=$(BAUD) -DF_CPU=$(F_CPU)UL -std=gnu99
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
37 CFLAGS += -funsigned-char
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
38 CFLAGS += -funsigned-bitfields
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
39 CFLAGS += -fpack-struct
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
40 CFLAGS += -fshort-enums
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
41 CFLAGS += -Wstrict-prototypes
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
42 CFLAGS += -Wundef
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
43 #CFLAGS += -save-temps
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
44
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
45 # optimize for size
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
46 CFLAGS += -Os
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
47 # dont optimize
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
48 #CFLAGS += -O0
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
49
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
50 # Linker options
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
51 LDFLAGS = -Wl,-Map,$(PRG).map
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
52
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
53 # Enable floating-point support in printf
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
54 #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
55
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
56 ###################################################################
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
57 # TARGET DEFINITIONS:
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
58
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
59
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
60 all: code
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
61
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
62 code: $(PRG).hex
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
63
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
64 $(PRG).elf: $(SRC:.c=.o)
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
65 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
66
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
67 %.lst: %.elf
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
68 $(OBJDUMP) -h -S $< > $@
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
69
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
70 %.hex: %.elf
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
71 $(OBJCOPY) -j .text -j .data -O ihex $< $@
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
72 rm $(PRG).elf
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
73 rm $(PRG).map
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
74
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
75 program: code
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
76 $(AVRDUDE) -c stk500v2 -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:w:$(PRG).hex:i
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
77
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
78 fuse:
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
79 $(AVRDUDE) -c stk500 -p $(MCU) -V $(FUSES)
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
80
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
81 clean:
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
82 rm -rf *.o *.elf *.elf.src *.s *.i
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
83 rm -rf driver/*.o
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
84
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
85 upgrade: code
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
86 $(RESETCOMMAND)
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
87 ./bootloader -d $(NETDEV) -b $(UPGRADE_BAUD) -p $(PRG).hex
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
88
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
89 bootloader: bootload.hex
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
90 $(AVRDUDE) -p $(MCU) -c stk500 -V -U flash:w:bootload.hex:i
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
91
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
92 bootfuses:
40a309c9c135 added initial trackswitch code, data rx and car id detect working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff changeset
93 $(AVRDUDE) -p $(MCU) -c stk500 $(BOOTFUSES)

mercurial