# $Id: Makefile,v 1.2 2010/03/23 07:55:23 simimeie Exp $ # Makefile for the ds1820-to-usb project CC = avr-gcc OBJDUMP = avr-objdump OBJCOPY = avr-objcopy AVRDUDE = avrdude INCDIR = . # target mcu (at90s8515, atmega16, atmega8515...) MCU = attiny45 # Since avrdude is generally crappy software (I liked uisp a lot better, too # bad the project is dead :-/), it cannot use the MCU name everybody else # uses, it has to invent its own name for it. So this defines the same # MCU as above, but with the name avrdude understands. AVRDMCU = t45 # Some more settings # Clock Frequency of the AVR. Needed for various calculations. CPUFREQ = 15000000UL # Additional defines # Known defines are: # -DKISS enables Keep-It-Simple-Stupid mode, which can only handle one # temperature sensor on the bus. ADDDEFS = SRCS = usbdrv/usbdrv.c ds1820.c main.c time.c ASMS = usbdrv/usbdrvasm.S PROG = ds1820tousb # compiler flags CFLAGS = -g -Os -Wall -fno-strict-aliasing -mmcu=$(MCU) $(ADDDEFS) # linker flags LDFLAGS = -g -mmcu=$(MCU) -Wl,-Map,$(PROG).map CFLAGS += -DCPUFREQ=$(CPUFREQ) -DF_CPU=$(CPUFREQ) OBJS = $(SRCS:.c=.o) $(ASMS:.S=.o) all: compile dump text eeprom compile: $(OBJS) $(CC) $(LDFLAGS) -o $(PROG).elf $(OBJS) dump: compile $(OBJDUMP) -h -S $(PROG).elf > $(PROG).lst hostsoftware: hostsoftware.c gcc -o hostsoftware -O2 -Wall -lusb hostsoftware.c %o : %c $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@ %o : %S $(CC) $(CFLAGS) -I$(INCDIR) -c $< -o $@ # Create the flash contents text: compile $(OBJCOPY) -j .text -j .data -O ihex $(PROG).elf $(PROG).hex $(OBJCOPY) -j .text -j .data -O srec $(PROG).elf $(PROG).srec $(OBJCOPY) -j .text -j .data -O binary $(PROG).elf $(PROG).bin # Rules for building the .eeprom rom images eeprom: compile $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $(PROG).elf $(PROG)_eeprom.hex $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $(PROG).elf $(PROG)_eeprom.srec $(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $(PROG).elf $(PROG)_eeprom.bin clean: rm -f $(PROG) *~ *.elf *.rom *.bin *.eep *.o usbdrv/*.o *.lst *.map *.srec *.hex upload: uploadflash uploadeeprom uploadflash: $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U flash:w:$(PROG).srec:s uploadeeprom: $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U eeprom:w:$(PROG)_eeprom.srec:s uploadfuses: @echo "Sorry, I will not program the fuses for you, since things will" @echo "go horribly wrong if you make a mistake there. It is safest to set" @echo "them with avrstudio." @echo "If you want to use attiny45/85, you will probably want" @echo " lfuse=0xff, hfuse=0xdd, efuse=0xff" @echo "Command line will be something along the lines of" @echo $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U lfuse:w:0xff:m @echo $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U hfuse:w:0xdd:m @echo $(AVRDUDE) -c stk500v2 -p $(AVRDMCU) -P /dev/ttyS0 -U efuse:w:0xff:m