Mon, 23 Dec 2013 10:59:14 +0100
car: finished set_id function
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
1 | PRG=main |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
2 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
3 | MCU=atmega8 |
151 | 4 | #FUSES=-U lfuse:w:0xAE:m -U hfuse:w:0xd9:m |
5 | FUSES=-U lfuse:w:0x83:m -U hfuse:w:0xd8:m | |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
6 | # original fuses: 83 / d8 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
7 | BOOTFUSES=-U lfuse:w:0xff:m -U hfuse:w:0xce:m |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
8 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
9 | #F_CPU=4185600 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
10 | #F_CPU = 14318000 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
11 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
12 | F_CPU = 4000000 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
13 | BAUD=38400 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
14 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
15 | ISP_BAUD = 115200 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
16 | ifdef USB |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
17 | PORT=/dev/ttyUSB$(USB) |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
18 | else |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
19 | PORT=/dev/ttyS0 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
20 | endif |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
21 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
22 | PROGRAMMER=-P $(PORT) -c stk500v2 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
23 | ifdef IF |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
24 | PROGRAMMER=-c $(IF) |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
25 | endif |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
26 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
27 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
28 | #SRC = main.c seriald.c driver/ADC.c driver/clock.c driver/timer.c |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
29 | #SRC = main.c driver/rs232.c driver/manchester.c |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
30 | #SRC = main.c driver/rs232.c |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
31 | SRC = main.c |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
32 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
33 | ################################################################### |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
34 | # You possibly do not need to change settings below this marker |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
35 | ################################################################### |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
36 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
37 | # Binaries to be used |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
38 | # You may add the path to them if they are not in the PATH variable. |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
39 | CC = avr-gcc |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
40 | OBJCOPY = avr-objcopy |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
41 | OBJDUMP = avr-objdump |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
42 | AVRDUDE = avrdude |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
43 | PERL = perl |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
44 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
45 | # Optional library search path |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
46 | LIBS = |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
47 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
48 | # Compiler options for all c source files |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
49 | CFLAGS += -g -Wall -mmcu=$(MCU) -DBAUD=$(BAUD) -DF_CPU=$(F_CPU)UL -std=gnu99 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
50 | CFLAGS += -funsigned-char |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
51 | CFLAGS += -funsigned-bitfields |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
52 | CFLAGS += -fpack-struct |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
53 | CFLAGS += -fshort-enums |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
54 | CFLAGS += -Wstrict-prototypes |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
55 | CFLAGS += -Wundef |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
56 | #CFLAGS += -save-temps |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
57 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
58 | # optimize for size |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
59 | CFLAGS += -Os |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
60 | # dont optimize |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
61 | #CFLAGS += -O0 |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
62 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
63 | # Linker options |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
64 | LDFLAGS = -Wl,-Map,$(PRG).map |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
65 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
66 | # Enable floating-point support in printf |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
67 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
68 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
69 | ################################################################### |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
70 | # TARGET DEFINITIONS: |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
71 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
72 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
73 | all: code |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
74 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
75 | code: $(PRG).hex |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
76 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
77 | $(PRG).elf: $(SRC:.c=.o) |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
78 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
79 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
80 | %.lst: %.elf |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
81 | $(OBJDUMP) -h -S $< > $@ |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
82 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
83 | %.hex: %.elf |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
84 | $(OBJCOPY) -j .text -j .data -O ihex $< $@ |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
85 | rm $(PRG).elf |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
86 | rm $(PRG).map |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
87 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
88 | program: code |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
89 | $(AVRDUDE) $(PROGRAMMER) -i 1 -p $(MCU) -V -U flash:w:$(PRG).hex:i |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
90 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
91 | backup: |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
92 | $(AVRDUDE) -P $(PORT) -c stk500v2 -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:r:$(PRG)_backup.hex:i |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
93 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
94 | fuse: |
149
1c3425af9aa0
car firmware suspended, avr chip not responding after fuse error (note to self, never program an avr when powered via the SCK line :-)
Malte Bayer <mbayer@neo-soft.org>
parents:
147
diff
changeset
|
95 | $(AVRDUDE) $(PROGRAMMER) -p $(MCU) -V $(FUSES) |
147
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
96 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
97 | clean: |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
98 | rm -rf *.o *.elf *.elf.src *.s *.i |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
99 | rm -rf driver/*.o |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
100 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
101 | upgrade: code |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
102 | $(RESETCOMMAND) |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
103 | ./bootloader -d $(NETDEV) -b $(UPGRADE_BAUD) -p $(PRG).hex |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
104 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
105 | bootloader: bootload.hex |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
106 | $(AVRDUDE) -p $(MCU) -c stk500 -V -U flash:w:bootload.hex:i |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
107 | |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
108 | bootfuses: |
f66c5b3b3ed2
started firmware for car004f hardware
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
109 | $(AVRDUDE) -p $(MCU) -c stk500 $(BOOTFUSES) |