Mercurial > pihelp
annotate Makefile @ 31:5d6a841eef82
/128 prescaler for adc
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Thu, 27 Jun 2013 00:12:32 +0800 |
parents | 320c8cc7df5a |
children | bd9ce7e581ec |
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 | |
20 | 9 # CLOCK ........ Target AVR CLOCK rate in Hertz |
0 | 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 | |
19
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
20 DEVICE = atmega328p |
0 | 21 PROGDEVICE = atmega328p |
30 | 22 CLOCK = 11059200L |
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 |
19
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
28 SOURCE += $(SOURCE_CRYPTO) $(SOURCE_SD) |
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
29 LIBS = |
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
30 |
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
31 OBJECTS := $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(SOURCE))) |
0 | 32 |
33 # default but 2mhz | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
34 FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x77:m -U efuse:w:0xfd:m |
0 | 35 |
22 | 36 #LOCKBIT |
37 # -U lock:w:0x28:m | |
38 # 0 unused bit7 | |
39 # 0 unused | |
40 # 1 blb12 no writing to bootloader | |
41 # 0 blb11 | |
42 # 1 blb02 no writing to app | |
43 # 0 blb01 | |
44 # 0 lb2 | |
45 # 0 lb1 bit0 | |
46 | |
0 | 47 # ATMega8 fuse bits used above (fuse bits for other devices are different!): |
48 # Example for 8 MHz internal oscillator | |
49 # Fuse high byte: | |
50 # 0xd9 = 1 1 0 1 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) | |
51 # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 | |
52 # | | | | | +-------- BOOTSZ1 | |
53 # | | | | +---------- EESAVE (set to 0 to preserve EEPROM over chip erase) | |
54 # | | | +-------------- WDTON | |
55 # | | +---------------- SPIEN (if set to 1, serial programming is disabled) | |
56 # | +------------------ DWEN | |
57 # +-------------------- RSTDISBL (if set to 0, RESET pin is disabled) | |
58 # Fuse low byte: | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
59 # 0x77 0 1 1 1 0 1 1 1 (low rising, full swing, crystal) |
0 | 60 # 0x62 = 0 1 1 0 0 0 1 0 |
61 # ^ ^ \ / \--+--/ | |
62 # | | | +------- CKSEL 3..0 (8M internal RC) | |
63 # | | +--------------- SUT 1..0 (slowly rising power) | |
64 # | +------------------ CKOUT | |
18
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
65 # +-------------------- CLKDIV8 (initial) |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
66 |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
67 # Extended fuse: |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
68 # 0xfd = 2.7V BOD |
021e6e0006f4
debug printing, 5v adc, fixes
Matt Johnston <matt@ucc.asn.au>
parents:
17
diff
changeset
|
69 # |
0 | 70 # |
71 # For computing fuse byte values for other devices and options see | |
72 # the fuse bit calculator at http://www.engbedded.com/fusecalc/ | |
73 | |
74 | |
75 # Tune the lines below only if you know what you are doing: | |
76 | |
19
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
77 SHELL := /bin/bash |
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
78 export PATH := $(PATH):/usr/local/CrossPack-AVR/bin/ |
5f9a40d6991b
Import SD handling from http://www.roland-riegel.de/sd-reader/index.html
Matt Johnston <matt@ucc.asn.au>
parents:
18
diff
changeset
|
79 |
0 | 80 AVRDUDE = avrdude $(PROGRAMMER) |
81 #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 | |
29 | 82 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g -std=c99 -Wl,-u,vfprintf -lprintf_flt -lm |
0 | 83 |
84 # symbolic targets: | |
85 all: main.hex | |
86 | |
87 .c.o: | |
88 $(COMPILE) -c $< -o $@ | |
89 | |
90 .S.o: | |
91 $(COMPILE) -x assembler-with-cpp -c $< -o $@ | |
92 # "-x assembler-with-cpp" should not be necessary since this is the default | |
93 # file type for the .S (with capital S) extension. However, upper case | |
94 # characters are not always preserved on Windows. To ensure WinAVR | |
95 # compatibility define the file type manually. | |
96 | |
97 .c.s: | |
98 $(COMPILE) -S $< -o $@ | |
99 | |
100 flash: all | |
29 | 101 $(AVRDUDE) -U flash:w:main.hex:i |
0 | 102 |
103 checkprog: | |
104 $(AVRDUDE) -v | |
105 | |
106 fuse: | |
107 $(AVRDUDE) $(FUSES) | |
108 | |
109 # Xcode uses the Makefile targets "", "clean" and "install" | |
110 install: flash | |
111 | |
112 # if you use a bootloader, change the command below appropriately: | |
113 load: all | |
114 bootloadHID main.hex | |
115 | |
116 clean: | |
117 rm -f main.hex main.elf $(OBJECTS) | |
118 | |
119 # file targets: | |
120 main.elf: $(SOURCE) | |
121 $(COMPILE) -o main.elf $(SOURCE) $(LIBS) | |
122 | |
123 main.hex: main.elf | |
124 rm -f main.hex | |
125 avr-objcopy -j .text -j .data -O ihex main.elf main.hex | |
126 avr-size --format=avr --mcu=$(DEVICE) main.elf | |
127 # If you have an EEPROM section, you must also create a hex file for the | |
128 # EEPROM and add it to the "flash" target. | |
129 | |
130 # Targets for code debugging and analysis: | |
131 disasm: main.elf | |
132 avr-objdump -d main.elf | |
133 | |
134 cpp: | |
135 $(COMPILE) -E main.c |