comparison old/Makefile @ 203:11a1b59b0624

Move old stuff to its own place
author Matt Johnston <matt@ucc.asn.au>
date Sun, 30 Mar 2014 20:21:56 +0800
parents Makefile@bb0c946460f3
children
comparison
equal deleted inserted replaced
202:6dd157a12035 203:11a1b59b0624
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
22 CLOCK = 2000000
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
26 SOURCE = main.c
27 SOURCE += $(SOURCE_1WIRE)
28 LIBS = -lm
29
30 # default but 2mhz
31 FUSES = -U hfuse:w:0xd9:m -U lfuse:w:0x62:m
32
33 # ATMega8 fuse bits used above (fuse bits for other devices are different!):
34 # Example for 8 MHz internal oscillator
35 # Fuse high byte:
36 # 0xd9 = 1 1 0 1 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000)
37 # ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0
38 # | | | | | +-------- BOOTSZ1
39 # | | | | +---------- EESAVE (set to 0 to preserve EEPROM over chip erase)
40 # | | | +-------------- WDTON
41 # | | +---------------- SPIEN (if set to 1, serial programming is disabled)
42 # | +------------------ DWEN
43 # +-------------------- RSTDISBL (if set to 0, RESET pin is disabled)
44 # Fuse low byte:
45 # 0x62 = 0 1 1 0 0 0 1 0
46 # ^ ^ \ / \--+--/
47 # | | | +------- CKSEL 3..0 (8M internal RC)
48 # | | +--------------- SUT 1..0 (slowly rising power)
49 # | +------------------ CKOUT
50 # +-------------------- CLKDIV8
51 #
52 # For computing fuse byte values for other devices and options see
53 # the fuse bit calculator at http://www.engbedded.com/fusecalc/
54
55
56 # Tune the lines below only if you know what you are doing:
57
58 AVRDUDE = avrdude $(PROGRAMMER)
59 COMPILE = avr-gcc -Wall -Os -DF_CPU=$(CLOCK) -mmcu=$(DEVICE) -g -std=c99 -mcall-prologues -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,--relax --combine -fwhole-program -Wl,-u,vfprintf -lprintf_flt -lm
60
61 # symbolic targets:
62 all: main.hex
63
64 .c.o:
65 $(COMPILE) -c $< -o $@
66
67 .S.o:
68 $(COMPILE) -x assembler-with-cpp -c $< -o $@
69 # "-x assembler-with-cpp" should not be necessary since this is the default
70 # file type for the .S (with capital S) extension. However, upper case
71 # characters are not always preserved on Windows. To ensure WinAVR
72 # compatibility define the file type manually.
73
74 .c.s:
75 $(COMPILE) -S $< -o $@
76
77 flash: all
78 $(AVRDUDE) -U flash:w:main.hex:i
79
80 checkprog:
81 $(AVRDUDE) -v
82
83 fuse:
84 $(AVRDUDE) $(FUSES)
85
86 # Xcode uses the Makefile targets "", "clean" and "install"
87 install: flash
88
89 # if you use a bootloader, change the command below appropriately:
90 load: all
91 bootloadHID main.hex
92
93 clean:
94 rm -f main.hex main.elf $(OBJECTS)
95
96 # file targets:
97 main.elf: $(SOURCE)
98 $(COMPILE) -o main.elf $(SOURCE) $(LIBS)
99
100 main.hex: main.elf
101 rm -f main.hex
102 avr-objcopy -j .text -j .data -O ihex main.elf main.hex
103 avr-size --format=avr --mcu=$(DEVICE) main.elf
104 # If you have an EEPROM section, you must also create a hex file for the
105 # EEPROM and add it to the "flash" target.
106
107 # Targets for code debugging and analysis:
108 disasm: main.elf
109 avr-objdump -d main.elf
110
111 cpp:
112 $(COMPILE) -E main.c