Statistics
| Branch: | Tag: | Revision:

root / analog_exp / Makefile @ 168:bfc84ee2839b

History | View | Annotate | Download (1.9 kB)

1
# Generic AVR Makefile
2
# Brian Mayton <bmayton@media.mit.edu>
3
#
4
# This is a basic Makefile for building programs for the AVR.  I usually start
5
# with this for any new project; it's pretty versatile.
6
#
7
# 'make' builds the .hex file.
8
# 'make install' uses the programmer to load it onto the target chip.
9
# 'make fuses' programs the fuse bits on the target chip.
10
# 'make clean' removes all autogenerated files.
11
12
# OBJECTS should list all of the object files for the program (e.g. for each
13
# .c file, list a corresponding .o file here.)  APPLICATION just specifies the
14
# name of the hex/elf files, and can be whatever you want. 
15
OBJECTS = \
16
	analog_exp.o \
17
	uart.o \
18
	debug.o \
19
	onewire.o \
20
	onewire_hal_bitbang.o \
21
	excitation.o \
22
23
APPLICATION = analog_exp
24
25
# Set up which MCU you're using, and what programmer, and the clock speed
26
# here.
27
MCU = atmega168p
28
PROGRAMMER = jtag2isp
29
F_CPU = 8000000UL
30
31
# Make sure you check these fuse settings before actually using them, using
32
# fuse settings for the wrong clock setup or chip can make it hard to
33
# reprogram.  http://www.engbedded.com/fusecalc/ is very useful!
34
EFUSE=0x01
35
HFUSE=0xD7
36
LFUSE=0xE2
37
38
# Edit these if you want to use different compilers
39
CC = avr-gcc
40
OBJCOPY = avr-objcopy
41
SIZE = avr-size
42
AVRDUDE = avrdude
43
44
# Compiler and linker flags
45
CFLAGS=-mmcu=$(MCU) -Wall -DF_CPU=$(F_CPU) -I. -funsigned-char \
46
	-funsigned-bitfields -fpack-struct -fshort-enums -Os -DDEBUG --std=gnu99
47
LDFLAGS=-mmcu=$(MCU)
48
49
all: $(APPLICATION).hex
50
51
clean:
52
	rm -f *.hex *.elf *.o 
53
54
%.hex: %.elf
55
	$(OBJCOPY) -j .text -j .data -O ihex $< $@
56
57
$(APPLICATION).elf: $(OBJECTS)
58
	$(CC) $(LDFLAGS) -o $@ $^
59
	$(SIZE) -C --mcu=$(MCU) $@
60
61
%.o: %.c
62
	$(CC) $(CFLAGS) -c $< -o $@
63
64
install: all
65
	$(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -P usb -e \
66
		-U flash:w:$(APPLICATION).hex
67
68
fuses:
69
	$(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -P usb -e \
70
		-U lfuse:w:$(LFUSE):m -U hfuse:w:$(HFUSE):m \
71
		-U efuse:w:$(EFUSE):m
72
73
.PHONY: all clean install fuses
74