Mercurial > templog
annotate Makefile @ 6:9d538f674ff0
- Some basic ADC code
- Turn on -mcall-prologues
- Put strings in program space, saves RAM
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 14 May 2012 00:22:57 +0800 |
parents | 54d369e3d689 |
children | 52cb08a01171 |
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 | |
6 | 20 DEVICE = atmega168 |
2 | 21 CLOCK = 1000000 |
0 | 22 PROGRAMMER = #-c stk500v2 -P avrdoper |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
23 OBJECTS = main.o ff.o mmc.o onewire.o |
6 | 24 LIBS = -lm |
0 | 25 FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x24:m |
26 | |
27 # ATMega8 fuse bits used above (fuse bits for other devices are different!): | |
28 # Example for 8 MHz internal oscillator | |
29 # Fuse high byte: | |
30 # 0xd9 = 1 1 0 1 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) | |
31 # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 | |
32 # | | | | | +-------- BOOTSZ1 | |
33 # | | | | +---------- EESAVE (set to 0 to preserve EEPROM over chip erase) | |
34 # | | | +-------------- CKOPT (clock option, depends on oscillator type) | |
35 # | | +---------------- SPIEN (if set to 1, serial programming is disabled) | |
36 # | +------------------ WDTON (if set to 0, watchdog is always on) | |
37 # +-------------------- RSTDISBL (if set to 0, RESET pin is disabled) | |
38 # Fuse low byte: | |
39 # 0x24 = 0 0 1 0 0 1 0 0 | |
40 # ^ ^ \ / \--+--/ | |
41 # | | | +------- CKSEL 3..0 (8M internal RC) | |
42 # | | +--------------- SUT 1..0 (slowly rising power) | |
43 # | +------------------ BODEN (if 0, brown-out detector is enabled) | |
44 # +-------------------- BODLEVEL (if 0: 4V, if 1: 2.7V) | |
45 # | |
46 # For computing fuse byte values for other devices and options see | |
47 # the fuse bit calculator at http://www.engbedded.com/fusecalc/ | |
48 | |
49 | |
50 # Tune the lines below only if you know what you are doing: | |
51 | |
52 AVRDUDE = avrdude $(PROGRAMMER) -p $(DEVICE) | |
6 | 53 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g -std=c99 -mcall-prologues |
0 | 54 |
55 # symbolic targets: | |
56 all: main.hex | |
57 | |
58 .c.o: | |
59 $(COMPILE) -c $< -o $@ | |
60 | |
61 .S.o: | |
62 $(COMPILE) -x assembler-with-cpp -c $< -o $@ | |
63 # "-x assembler-with-cpp" should not be necessary since this is the default | |
64 # file type for the .S (with capital S) extension. However, upper case | |
65 # characters are not always preserved on Windows. To ensure WinAVR | |
66 # compatibility define the file type manually. | |
67 | |
68 .c.s: | |
69 $(COMPILE) -S $< -o $@ | |
70 | |
71 flash: all | |
72 $(AVRDUDE) -U flash:w:main.hex:i | |
73 | |
74 fuse: | |
75 $(AVRDUDE) $(FUSES) | |
76 | |
77 # Xcode uses the Makefile targets "", "clean" and "install" | |
78 install: flash fuse | |
79 | |
80 # if you use a bootloader, change the command below appropriately: | |
81 load: all | |
82 bootloadHID main.hex | |
83 | |
84 clean: | |
85 rm -f main.hex main.elf $(OBJECTS) | |
86 | |
87 # file targets: | |
88 main.elf: $(OBJECTS) | |
6 | 89 $(COMPILE) -o main.elf $(OBJECTS) $(LIBS) |
0 | 90 |
91 main.hex: main.elf | |
92 rm -f main.hex | |
93 avr-objcopy -j .text -j .data -O ihex main.elf main.hex | |
94 avr-size --format=avr --mcu=$(DEVICE) main.elf | |
95 # If you have an EEPROM section, you must also create a hex file for the | |
96 # EEPROM and add it to the "flash" target. | |
97 | |
98 # Targets for code debugging and analysis: | |
99 disasm: main.elf | |
100 avr-objdump -d main.elf | |
101 | |
102 cpp: | |
103 $(COMPILE) -E main.c |