2 # Project: hid-custom-rq example
3 # Author: Christian Starkjohann
4 # Creation Date: 2008-04-07
6 # Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
7 # License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
8 # This Revision: $Id: Makefile 692 2008-11-07 15:07:40Z cs $
10 DEVICE = attiny45 #attiny45
12 FUSE_L = 0xe1# 1110.0001
13 FUSE_H = 0x9d# 1001.1101
14 #AVRDUDE = avrdude -c avr910 -P /dev/ttyUSB0 -p $(DEVICE) # edit this line for your programmer
15 AVRDUDE_ISP = avrdude -c jtag2isp -P usb -p $(DEVICE) # edit this line for your programmer
16 AVRDUDE_DW = avrdude -c jtag2dw -P usb -p $(DEVICE) # edit this line for your programmer
18 CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0
19 OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o \
22 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
23 COMPILEPP = avr-g++ -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
27 @echo "This Makefile has no default rule. Use one of the following:"
28 @echo "make hex ....... to build main.hex"
29 @echo "make program ... to flash fuses and firmware"
30 @echo "make fuse ...... to flash the fuses"
31 @echo "make flash ..... to flash the firmware (use this on metaboard)"
32 @echo "make clean ..... to delete objects and hex file"
38 xprog_i: flash_isp fuse
39 xprog_d: fuse flash_dw
41 # rule for programming fuse bits:
43 @[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" ] || \
44 { echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
45 $(AVRDUDE_ISP) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m
47 # rule for uploading firmware:
49 $(AVRDUDE_ISP) -U flash:w:main.hex:i
52 $(AVRDUDE_DW) -U flash:w:main.hex:i
55 # rule for deleting dependent files (those which can be built by Make):
57 rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.elf *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s
60 $(COMPILEPP) -c $< -o $@
63 # Generic rule for compiling C files:
65 $(COMPILE) -c $< -o $@
67 # Generic rule for assembling Assembler source files:
69 $(COMPILE) -x assembler-with-cpp -c $< -o $@
70 # "-x assembler-with-cpp" should not be necessary since this is the default
71 # file type for the .S (with capital S) extension. However, upper case
72 # characters are not always preserved on Windows. To ensure WinAVR
73 # compatibility define the file type manually.
75 # Generic rule for compiling C to assembler, used for debugging only.
77 $(COMPILE) -S $< -o $@
81 # Since we don't want to ship the driver multipe times, we copy it into this project:
83 cp -r ../../../usbdrv .
85 main.elf: usbdrv $(OBJECTS) # usbdrv dependency only needed because we copy it
86 $(COMPILE) -o main.elf $(OBJECTS)
89 rm -f main.hex main.eep.hex
90 avr-objcopy -j .text -j .data -O ihex main.elf main.hex
96 avr-objdump -d main.elf
99 $(COMPILE) -E main.cpp