Commit | Line | Data |
---|---|---|
93ac315e MPM |
1 | # $Id: Makefile,v 1.2 2010/03/23 07:55:23 simimeie Exp $ |
2 | # Makefile for the ds1820-to-usb project | |
3 | ||
4 | CC = avr-gcc | |
5 | OBJDUMP = avr-objdump | |
6 | OBJCOPY = avr-objcopy | |
7 | AVRDUDE = avrdude | |
8 | INCDIR = . | |
9 | ||
10 | # target mcu (at90s8515, atmega16, atmega8515...) | |
11 | MCU = attiny45 | |
12 | # Since avrdude is generally crappy software (I liked uisp a lot better, too | |
13 | # bad the project is dead :-/), it cannot use the MCU name everybody else | |
14 | # uses, it has to invent its own name for it. So this defines the same | |
15 | # MCU as above, but with the name avrdude understands. | |
16 | AVRDMCU = t45 | |
17 | ||
18 | # Some more settings | |
19 | # Clock Frequency of the AVR. Needed for various calculations. | |
20 | CPUFREQ = 15000000UL | |
21 | ||
22 | # Additional defines | |
23 | # Known defines are: | |
24 | # -DKISS enables Keep-It-Simple-Stupid mode, which can only handle one | |
25 | # temperature sensor on the bus. | |
26 | ADDDEFS = | |
27 | ||
28 | SRCS = usbdrv/usbdrv.c ds1820.c main.c time.c | |
29 | ASMS = usbdrv/usbdrvasm.S | |
30 | PROG = ds1820tousb | |
31 | ||
32 | # compiler flags | |
33 | CFLAGS = -g -Os -Wall -fno-strict-aliasing -mmcu=$(MCU) $(ADDDEFS) | |
34 | ||
35 | # linker flags | |
36 | LDFLAGS = -g -mmcu=$(MCU) -Wl,-Map,$(PROG).map | |
37 | ||
38 | CFLAGS += -DCPUFREQ=$(CPUFREQ) -DF_CPU=$(CPUFREQ) | |
39 | ||
40 | OBJS = $(SRCS:.c=.o) $(ASMS:.S=.o) | |
41 | ||
42 | all: compile dump text eeprom | |
43 | ||
44 | compile: $(OBJS) | |
45 | $(CC) $(LDFLAGS) -o $(PROG).elf $(OBJS) | |
46 | ||
47 | dump: compile | |
48 | $(OBJDUMP) -h -S $(PROG).elf > $(PROG).lst | |
49 | ||
50 | hostsoftware: hostsoftware.c | |
51 | gcc -o hostsoftware -O2 -Wall -lusb hostsoftware.c | |
52 | ||
53 | %o : %c | |
54 | $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@ | |
55 | ||
56 | %o : %S | |
57 | $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@ | |
58 | ||
59 | # Create the flash contents | |
60 | text: compile | |
61 | $(OBJCOPY) -j .text -j .data -O ihex $(PROG).elf $(PROG).hex | |
62 | $(OBJCOPY) -j .text -j .data -O srec $(PROG).elf $(PROG).srec | |
63 | $(OBJCOPY) -j .text -j .data -O binary $(PROG).elf $(PROG).bin | |
64 | ||
65 | # Rules for building the .eeprom rom images | |
66 | eeprom: compile | |
67 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $(PROG).elf $(PROG)_eeprom.hex | |
68 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $(PROG).elf $(PROG)_eeprom.srec | |
69 | $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $(PROG).elf $(PROG)_eeprom.bin | |
70 | ||
71 | clean: | |
72 | rm -f $(PROG) *~ *.elf *.rom *.bin *.eep *.o usbdrv/*.o *.lst *.map *.srec *.hex | |
73 | ||
74 | upload: uploadflash uploadeeprom | |
75 | ||
76 | uploadflash: | |
77 | $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U flash:w:$(PROG).srec:s | |
78 | ||
79 | uploadeeprom: | |
80 | $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U eeprom:w:$(PROG)_eeprom.srec:s | |
81 | ||
82 | uploadfuses: | |
83 | @echo "Sorry, I will not program the fuses for you, since things will" | |
84 | @echo "go horribly wrong if you make a mistake there. It is safest to set" | |
85 | @echo "them with avrstudio." | |
86 | @echo "If you want to use attiny45/85, you will probably want" | |
87 | @echo " lfuse=0xff, hfuse=0xdd, efuse=0xff" | |
88 | @echo "Command line will be something along the lines of" | |
89 | @echo $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U lfuse:w:0xff:m | |
90 | @echo $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U hfuse:w:0xdd:m | |
91 | @echo $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U efuse:w:0xff:m |