Mercurial > pihelp
annotate Makefile @ 18:021e6e0006f4
debug printing, 5v adc, fixes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 13 Jun 2013 23:44:59 +0800 |
parents | 21717153e0f1 |
children | 5f9a40d6991b bc48a1d17edf |
rev | line source |
---|---|
0 | 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 | |
20 DEVICE = atmega328 | |
21 PROGDEVICE = atmega328p | |
17 | 22 CLOCK = 4915200 |
0 | 23 PROGRAMMER = #-c stk500v2 -P avrdoper |
24 PROGRAMMER = -c stk500 -P ~/dev/stk500 -p $(PROGDEVICE) -B 2 | |
25 SOURCE_1WIRE = onewire.c simple_ds18b20.c crc8.c | |
5 | 26 SOURCE_CRYPTO = hmac-sha1.c sha1-asm.S aes.c |
0 | 27 SOURCE = main.c |
2 | 28 SOURCE += $(SOURCE_CRYPTO) |
0 | 29 LIBS = -lm |
30 | |
31 # default but 2mhz | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
32 FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x77:m -U efuse:w:0xfd:m |
0 | 33 |
34 # ATMega8 fuse bits used above (fuse bits for other devices are different!): | |
35 # Example for 8 MHz internal oscillator | |
36 # Fuse high byte: | |
37 # 0xd9 = 1 1 0 1 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) | |
38 # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 | |
39 # | | | | | +-------- BOOTSZ1 | |
40 # | | | | +---------- EESAVE (set to 0 to preserve EEPROM over chip erase) | |
41 # | | | +-------------- WDTON | |
42 # | | +---------------- SPIEN (if set to 1, serial programming is disabled) | |
43 # | +------------------ DWEN | |
44 # +-------------------- RSTDISBL (if set to 0, RESET pin is disabled) | |
45 # Fuse low byte: | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
46 # 0x77 0 1 1 1 0 1 1 1 (low rising, full swing, crystal) |
0 | 47 # 0x62 = 0 1 1 0 0 0 1 0 |
48 # ^ ^ \ / \--+--/ | |
49 # | | | +------- CKSEL 3..0 (8M internal RC) | |
50 # | | +--------------- SUT 1..0 (slowly rising power) | |
51 # | +------------------ CKOUT | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
52 # +-------------------- CLKDIV8 (initial) |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
53 |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
54 # Extended fuse: |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
55 # 0xfd = 2.7V BOD |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
56 # |
0 | 57 # |
58 # For computing fuse byte values for other devices and options see | |
59 # the fuse bit calculator at http://www.engbedded.com/fusecalc/ | |
60 | |
61 | |
62 # Tune the lines below only if you know what you are doing: | |
63 | |
64 AVRDUDE = avrdude $(PROGRAMMER) | |
65 #COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g -std=c99 -mcall-prologues -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,--relax -fwhole-program -Wl,-u,vfprintf -lprintf_flt -lm | |
2 | 66 COMPILE = /usr/local/CrossPack-AVR/bin/avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g -std=c99 -Wl,-u,vfprintf -lprintf_flt -lm |
0 | 67 |
68 # symbolic targets: | |
69 all: main.hex | |
70 | |
71 .c.o: | |
72 $(COMPILE) -c $< -o $@ | |
73 | |
74 .S.o: | |
75 $(COMPILE) -x assembler-with-cpp -c $< -o $@ | |
76 # "-x assembler-with-cpp" should not be necessary since this is the default | |
77 # file type for the .S (with capital S) extension. However, upper case | |
78 # characters are not always preserved on Windows. To ensure WinAVR | |
79 # compatibility define the file type manually. | |
80 | |
81 .c.s: | |
82 $(COMPILE) -S $< -o $@ | |
83 | |
84 flash: all | |
85 $(AVRDUDE) -U flash:w:main.hex:i | |
86 | |
87 checkprog: | |
88 $(AVRDUDE) -v | |
89 | |
90 fuse: | |
91 $(AVRDUDE) $(FUSES) | |
92 | |
93 # Xcode uses the Makefile targets "", "clean" and "install" | |
94 install: flash | |
95 | |
96 # if you use a bootloader, change the command below appropriately: | |
97 load: all | |
98 bootloadHID main.hex | |
99 | |
100 clean: | |
101 rm -f main.hex main.elf $(OBJECTS) | |
102 | |
103 # file targets: | |
104 main.elf: $(SOURCE) | |
105 $(COMPILE) -o main.elf $(SOURCE) $(LIBS) | |
106 | |
107 main.hex: main.elf | |
108 rm -f main.hex | |
109 avr-objcopy -j .text -j .data -O ihex main.elf main.hex | |
110 avr-size --format=avr --mcu=$(DEVICE) main.elf | |
111 # If you have an EEPROM section, you must also create a hex file for the | |
112 # EEPROM and add it to the "flash" target. | |
113 | |
114 # Targets for code debugging and analysis: | |
115 disasm: main.elf | |
116 avr-objdump -d main.elf | |
117 | |
118 cpp: | |
119 $(COMPILE) -E main.c |