firmware/Makefile

changeset 0
bdcf2c76d86e
equal deleted inserted replaced
-1:000000000000 0:bdcf2c76d86e
1 # Name: Makefile
2 # Project: hid-data example
3 # Author: Christian Starkjohann
4 # Creation Date: 2008-04-07
5 # Tabsize: 4
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
9 DEVICE = attiny2313
10 F_CPU = 8000000 # in Hz
11 AVRDUDE = avrdude -c usbasp -p $(DEVICE) -B .5 -P USB -u
12
13 CFLAGS = -I. -DDEBUG_LEVEL=0
14 OBJECTS = main.o
15
16 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
17
18 FUSE_H = 0x9f
19 FUSE_L = 0xe4
20
21 # symbolic targets:
22 help:
23 @echo "This Makefile has no default rule. Use one of the following:"
24 @echo "make hex ....... to build main.hex"
25 @echo "make program ... to flash fuses and firmware"
26 @echo "make fuse ...... to flash the fuses"
27 @echo "make flash ..... to flash the firmware (use this on metaboard)"
28 @echo "make clean ..... to delete objects and hex file"
29
30 hex: main.hex
31
32 program: flash fuse
33
34 # rule for programming fuse bits:
35 fuse:
36 @[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" ] || \
37 { echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
38 $(AVRDUDE) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m
39
40 # rule for uploading firmware:
41 flash: main.hex
42 $(AVRDUDE) -U flash:w:main.hex:i
43
44 # rule for deleting dependent files (those which can be built by Make):
45 clean:
46 rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.elf *.o main.s
47
48 # Generic rule for compiling C files:
49 .c.o:
50 $(COMPILE) -c $< -o $@
51
52 # Generic rule for assembling Assembler source files:
53 .S.o:
54 $(COMPILE) -x assembler-with-cpp -c $< -o $@
55 # "-x assembler-with-cpp" should not be necessary since this is the default
56 # file type for the .S (with capital S) extension. However, upper case
57 # characters are not always preserved on Windows. To ensure WinAVR
58 # compatibility define the file type manually.
59
60 # Generic rule for compiling C to assembler, used for debugging only.
61 .c.s:
62 $(COMPILE) -S $< -o $@
63
64 # file targets:
65
66 main.elf: $(OBJECTS) # usbdrv dependency only needed because we copy it
67 $(COMPILE) -o main.elf $(OBJECTS)
68
69 main.hex: main.elf
70 rm -f main.hex main.eep.hex
71 avr-objcopy -j .text -j .data -O ihex main.elf main.hex
72 avr-size main.hex
73
74 # debugging targets:
75
76 disasm: main.elf
77 avr-objdump -d main.elf
78
79 cpp:
80 $(COMPILE) -E main.c

mercurial