Subversion Repositories group.electronics

Rev

Rev 84 | Rev 86 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
79 pfowler 1
# Name: Makefile
2
# Project: EasyLogger
3
# Author: Christian Starkjohann
4
# Creation Date: 2007-06-23
5
# Tabsize: 4
6
# Copyright: (c) 2007 by OBJECTIVE DEVELOPMENT Software GmbH
7
# License: GPLv2.
8
# This Revision: $Id$
9
 
85 pfowler 10
DEVICE=atmega168
79 pfowler 11
AVRDUDE = avrdude -c avrispmkii -P usb -p $(DEVICE)
12
# The two lines above are for "avrdude" and the STK500 programmer connected
13
# to an USB to serial converter to a Mac running Mac OS X.
14
# Choose your favorite programmer and interface.
15
 
85 pfowler 16
COMPILE = avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=$(DEVICE) -DF_CPU=12000000 -DDEBUG_LEVEL=0
79 pfowler 17
# NEVER compile the final product with debugging! Any debug output will
18
# distort timing so that the specs can't be met.
19
 
81 pfowler 20
#OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
21
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o  main.o
79 pfowler 22
 
23
# symbolic targets:
24
all:	main.hex
25
 
26
.c.o:
27
	$(COMPILE) -c $< -o $@
28
 
29
.S.o:
30
	$(COMPILE) -x assembler-with-cpp -c $< -o $@
31
# "-x assembler-with-cpp" should not be necessary since this is the default
32
# file type for the .S (with capital S) extension. However, upper case
33
# characters are not always preserved on Windows. To ensure WinAVR
34
# compatibility define the file type manually.
35
 
36
.c.s:
37
	$(COMPILE) -S $< -o $@
38
 
39
flash:	all
40
	$(AVRDUDE) -U flash:w:main.hex:i
41
 
42
 
43
# Fuse high byte:
44
# 0xdd = 1 1 0 1   1 1 0 1
45
#        ^ ^ ^ ^   ^ \-+-/ 
46
#        | | | |   |   +------ BODLEVEL 2..0 (brownout trigger level -> 2.7V)
47
#        | | | |   +---------- EESAVE (preserve EEPROM on Chip Erase -> not preserved)
48
#        | | | +-------------- WDTON (watchdog timer always on -> disable)
49
#        | | +---------------- SPIEN (enable serial programming -> enabled)
50
#        | +------------------ DWEN (debug wire enable)
51
#        +-------------------- RSTDISBL (disable external reset -> enabled)
52
#
53
# Fuse low byte:
54
# 0xe1 = 1 1 1 0   0 0 0 1
55
#        ^ ^ \+/   \--+--/
56
#        | |  |       +------- CKSEL 3..0 (clock selection -> HF PLL)
57
#        | |  +--------------- SUT 1..0 (BOD enabled, fast rising power)
58
#        | +------------------ CKOUT (clock output on CKOUT pin -> disabled)
59
#        +-------------------- CKDIV8 (divide clock by 8 -> don't divide)
60
fuse:
61
	$(AVRDUDE) -U hfuse:w:0xdd:m -U lfuse:w:0xe1:m
62
 
81 pfowler 63
fusedef:
64
	$(AVRDUDE) -U hfuse:w:0xdf:m -Ulfuse:w:0x64:m
65
 
79 pfowler 66
readcal:
67
	$(AVRDUDE) -U calibration:r:/dev/stdout:i | head -1
68
 
69
 
70
clean:
71
	rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s
72
 
73
# file targets:
74
main.bin:	$(OBJECTS)
75
	$(COMPILE) -o main.bin $(OBJECTS)
76
 
77
main.hex:	main.bin
78
	rm -f main.hex main.eep.hex
79
	avr-objcopy -j .text -j .data -O ihex main.bin main.hex
80
	./checksize main.bin 4096 256
81
# do the checksize script as our last action to allow successful compilation
82
# on Windows with WinAVR where the Unix commands will fail.
83
 
84
disasm:	main.bin
85
	avr-objdump -d main.bin
86
 
87
cpp:
88
	$(COMPILE) -E main.c