Sat, 21 Dec 2013 16:21:06 +0100
optimized fuses, rx binary crap filter
0
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
1 | PRG=main |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
2 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
3 | MCU=atmega16 |
33 | 4 | #FUSES=-U lfuse:w:0x3f:m -U hfuse:w:0xd8:m |
145
80be5eb283d3
optimized fuses, rx binary crap filter
Malte Bayer <mbayer@neo-soft.org>
parents:
140
diff
changeset
|
5 | #FUSES=-U lfuse:w:0x2f:m -U hfuse:w:0xc8:m |
80be5eb283d3
optimized fuses, rx binary crap filter
Malte Bayer <mbayer@neo-soft.org>
parents:
140
diff
changeset
|
6 | FUSES=-U lfuse:w:0x3c:m -U hfuse:w:0xc9:m |
0
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
7 | BOOTFUSES=-U lfuse:w:0xff:m -U hfuse:w:0xce:m |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
8 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
9 | #F_CPU=4185600 |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
10 | #F_CPU = 14318000 |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
11 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
12 | F_CPU = 8000000 |
139
7127e7082ee0
switched firmware to binary protocol, TODO: client implementation
Malte Bayer <mbayer@neo-soft.org>
parents:
128
diff
changeset
|
13 | #F_CPU = 16000000 |
0
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
14 | |
140
f910ad6ed0b6
client binary protocol implementation
Malte Bayer <mbayer@neo-soft.org>
parents:
139
diff
changeset
|
15 | BAUD=57600 |
f910ad6ed0b6
client binary protocol implementation
Malte Bayer <mbayer@neo-soft.org>
parents:
139
diff
changeset
|
16 | #BAUD=33600 |
80
393b63b8c95f
added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents:
33
diff
changeset
|
17 | ISP_BAUD=115200 |
393b63b8c95f
added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents:
33
diff
changeset
|
18 | ifdef USB |
393b63b8c95f
added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents:
33
diff
changeset
|
19 | PORT=/dev/ttyUSB$(USB) |
393b63b8c95f
added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents:
33
diff
changeset
|
20 | else |
393b63b8c95f
added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents:
33
diff
changeset
|
21 | PORT=/dev/ttyS0 |
393b63b8c95f
added usb programmer option to blackbox makefile
Malte Bayer <mbayer@neo-soft.org>
parents:
33
diff
changeset
|
22 | endif |
0
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
23 | |
114 | 24 | PROGRAMMER=-P $(PORT) -c stk500v2 |
25 | ifdef IF | |
26 | PROGRAMMER=-c $(IF) | |
27 | endif | |
28 | ||
0
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
29 | #SRC = main.c seriald.c driver/ADC.c driver/clock.c driver/timer.c |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
30 | #SRC = main.c driver/rs232.c driver/manchester.c |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
31 | SRC = main.c driver/rs232.c driver/adc.c |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
32 | SRC += lowlevel.c |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
33 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
34 | ################################################################### |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
35 | # You possibly do not need to change settings below this marker |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
36 | ################################################################### |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
37 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
38 | # Binaries to be used |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
39 | # You may add the path to them if they are not in the PATH variable. |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
40 | CC = avr-gcc |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
41 | OBJCOPY = avr-objcopy |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
42 | OBJDUMP = avr-objdump |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
43 | AVRDUDE = avrdude |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
44 | PERL = perl |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
45 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
46 | # Optional library search path |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
47 | LIBS = |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
48 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
49 | # Compiler options for all c source files |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
50 | CFLAGS += -g -Wall -mmcu=$(MCU) -DBAUD=$(BAUD) -DF_CPU=$(F_CPU)UL -std=gnu99 |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
51 | CFLAGS += -funsigned-char |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
52 | CFLAGS += -funsigned-bitfields |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
53 | CFLAGS += -fpack-struct |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
54 | CFLAGS += -fshort-enums |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
55 | CFLAGS += -Wstrict-prototypes |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
56 | CFLAGS += -Wundef |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
57 | #CFLAGS += -save-temps |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
58 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
59 | # optimize for size |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
60 | CFLAGS += -Os |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
61 | # dont optimize |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
62 | #CFLAGS += -O0 |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
63 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
64 | # Linker options |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
65 | LDFLAGS = -Wl,-Map,$(PRG).map |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
66 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
67 | # Enable floating-point support in printf |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
68 | #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt -lm |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
69 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
70 | ################################################################### |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
71 | # TARGET DEFINITIONS: |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
72 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
73 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
74 | all: code |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
75 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
76 | code: $(PRG).hex |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
77 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
78 | $(PRG).elf: $(SRC:.c=.o) |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
79 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
80 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
81 | %.lst: %.elf |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
82 | $(OBJDUMP) -h -S $< > $@ |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
83 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
84 | %.hex: %.elf |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
85 | $(OBJCOPY) -j .text -j .data -O ihex $< $@ |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
86 | rm $(PRG).elf |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
87 | rm $(PRG).map |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
88 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
89 | program: code |
114 | 90 | $(AVRDUDE) $(PROGRAMMER) -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:w:$(PRG).hex:i |
0
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
91 | |
103
52fd4283cd2c
added learn and teach modes for intelligent ghostcars
Malte Bayer <mbayer@neo-soft.org>
parents:
80
diff
changeset
|
92 | backup: |
114 | 93 | $(AVRDUDE) $(PROGRAMMER) -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:r:$(PRG)_backup.hex:i |
103
52fd4283cd2c
added learn and teach modes for intelligent ghostcars
Malte Bayer <mbayer@neo-soft.org>
parents:
80
diff
changeset
|
94 | |
128 | 95 | restore: |
96 | $(AVRDUDE) $(PROGRAMMER) -b $(ISP_BAUD) -i 1 -p $(MCU) -V -U flash:w:$(PRG).hex:i | |
97 | ||
0
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
98 | fuse: |
145
80be5eb283d3
optimized fuses, rx binary crap filter
Malte Bayer <mbayer@neo-soft.org>
parents:
140
diff
changeset
|
99 | $(AVRDUDE) $(PROGRAMMER) -p $(MCU) -V $(FUSES) |
0
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
100 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
101 | clean: |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
102 | rm -rf *.o *.elf *.elf.src *.s *.i |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
103 | rm -rf driver/*.o |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
104 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
105 | upgrade: code |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
106 | $(RESETCOMMAND) |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
107 | ./bootloader -d $(NETDEV) -b $(UPGRADE_BAUD) -p $(PRG).hex |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
108 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
109 | bootloader: bootload.hex |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
110 | $(AVRDUDE) -p $(MCU) -c stk500 -V -U flash:w:bootload.hex:i |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
111 | |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
112 | bootfuses: |
9b7de464f0ea
initial commit - controller1 working
Malte Bayer <mbayer@neo-soft.org>
parents:
diff
changeset
|
113 | $(AVRDUDE) -p $(MCU) -c stk500 $(BOOTFUSES) |