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