306
|
1 # Name: Makefile |
|
2 # Author: <insert your name here> |
|
3 # Copyright: <insert your copyright message here> |
|
4 # License: <insert your license reference here> |
|
5 |
|
6 # This is a prototype Makefile. Modify it according to your needs. |
|
7 # You should at least check the settings for |
|
8 # DEVICE ....... The AVR device you compile for |
|
9 # CLOCK ........ Target AVR clock rate in Hertz |
|
10 # OBJECTS ...... The object files created from your source files. This list is |
|
11 # usually the same as the list of source files with suffix ".o". |
|
12 # PROGRAMMER ... Options to avrdude which define the hardware you use for |
|
13 # uploading to the AVR and the interface where this hardware |
|
14 # is connected. We recommend that you leave it undefined and |
|
15 # add settings like this to your ~/.avrduderc file: |
|
16 # default_programmer = "stk500v2" |
|
17 # default_serial = "avrdoper" |
|
18 # FUSES ........ Parameters for avrdude to flash the fuses appropriately. |
|
19 |
313
|
20 DEVICE = atmega328 |
|
21 PROGDEVICE = atmega328p |
308
|
22 CLOCK = 1000000 |
306
|
23 PROGRAMMER = #-c stk500v2 -P avrdoper |
313
|
24 PROGRAMMER = -c stk500 -P ~/dev/stk500 -p $(PROGDEVICE) |
|
25 OBJECTS = main.o #ff.o mmc.o onewire.o |
312
|
26 LIBS = -lm |
306
|
27 FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x24:m |
|
28 |
|
29 # ATMega8 fuse bits used above (fuse bits for other devices are different!): |
|
30 # Example for 8 MHz internal oscillator |
|
31 # Fuse high byte: |
|
32 # 0xd9 = 1 1 0 1 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) |
|
33 # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 |
|
34 # | | | | | +-------- BOOTSZ1 |
|
35 # | | | | +---------- EESAVE (set to 0 to preserve EEPROM over chip erase) |
|
36 # | | | +-------------- CKOPT (clock option, depends on oscillator type) |
|
37 # | | +---------------- SPIEN (if set to 1, serial programming is disabled) |
|
38 # | +------------------ WDTON (if set to 0, watchdog is always on) |
|
39 # +-------------------- RSTDISBL (if set to 0, RESET pin is disabled) |
|
40 # Fuse low byte: |
|
41 # 0x24 = 0 0 1 0 0 1 0 0 |
|
42 # ^ ^ \ / \--+--/ |
|
43 # | | | +------- CKSEL 3..0 (8M internal RC) |
|
44 # | | +--------------- SUT 1..0 (slowly rising power) |
|
45 # | +------------------ BODEN (if 0, brown-out detector is enabled) |
|
46 # +-------------------- BODLEVEL (if 0: 4V, if 1: 2.7V) |
|
47 # |
|
48 # For computing fuse byte values for other devices and options see |
|
49 # the fuse bit calculator at http://www.engbedded.com/fusecalc/ |
|
50 |
|
51 |
|
52 # Tune the lines below only if you know what you are doing: |
|
53 |
313
|
54 AVRDUDE = avrdude $(PROGRAMMER) |
312
|
55 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g -std=c99 -mcall-prologues |
306
|
56 |
|
57 # symbolic targets: |
|
58 all: main.hex |
|
59 |
|
60 .c.o: |
|
61 $(COMPILE) -c $< -o $@ |
|
62 |
|
63 .S.o: |
|
64 $(COMPILE) -x assembler-with-cpp -c $< -o $@ |
|
65 # "-x assembler-with-cpp" should not be necessary since this is the default |
|
66 # file type for the .S (with capital S) extension. However, upper case |
|
67 # characters are not always preserved on Windows. To ensure WinAVR |
|
68 # compatibility define the file type manually. |
|
69 |
|
70 .c.s: |
|
71 $(COMPILE) -S $< -o $@ |
|
72 |
|
73 flash: all |
|
74 $(AVRDUDE) -U flash:w:main.hex:i |
|
75 |
|
76 fuse: |
|
77 $(AVRDUDE) $(FUSES) |
|
78 |
|
79 # Xcode uses the Makefile targets "", "clean" and "install" |
|
80 install: flash fuse |
|
81 |
|
82 # if you use a bootloader, change the command below appropriately: |
|
83 load: all |
|
84 bootloadHID main.hex |
|
85 |
|
86 clean: |
|
87 rm -f main.hex main.elf $(OBJECTS) |
|
88 |
|
89 # file targets: |
|
90 main.elf: $(OBJECTS) |
312
|
91 $(COMPILE) -o main.elf $(OBJECTS) $(LIBS) |
306
|
92 |
|
93 main.hex: main.elf |
|
94 rm -f main.hex |
|
95 avr-objcopy -j .text -j .data -O ihex main.elf main.hex |
|
96 avr-size --format=avr --mcu=$(DEVICE) main.elf |
|
97 # If you have an EEPROM section, you must also create a hex file for the |
|
98 # EEPROM and add it to the "flash" target. |
|
99 |
|
100 # Targets for code debugging and analysis: |
|
101 disasm: main.elf |
|
102 avr-objdump -d main.elf |
|
103 |
|
104 cpp: |
|
105 $(COMPILE) -E main.c |