Subversion Repositories group.electronics

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
75 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
 
10
DEVICE=attiny85
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
 
16
COMPILE = avr-gcc -Wall -Os -Iusbdrv -I. -mmcu=$(DEVICE) -DF_CPU=16500000 -DDEBUG_LEVEL=0
17
# NEVER compile the final product with debugging! Any debug output will
18
# distort timing so that the specs can't be met.
19
 
20
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
21
 
22
# symbolic targets:
23
all:	main.hex
24
 
25
.c.o:
26
	$(COMPILE) -c $< -o $@
27
 
28
.S.o:
29
	$(COMPILE) -x assembler-with-cpp -c $< -o $@
30
# "-x assembler-with-cpp" should not be necessary since this is the default
31
# file type for the .S (with capital S) extension. However, upper case
32
# characters are not always preserved on Windows. To ensure WinAVR
33
# compatibility define the file type manually.
34
 
35
.c.s:
36
	$(COMPILE) -S $< -o $@
37
 
38
flash:	all
39
	$(AVRDUDE) -U flash:w:main.hex:i
40
 
41
 
42
# Fuse high byte:
43
# 0xdd = 1 1 0 1   1 1 0 1
44
#        ^ ^ ^ ^   ^ \-+-/ 
45
#        | | | |   |   +------ BODLEVEL 2..0 (brownout trigger level -> 2.7V)
46
#        | | | |   +---------- EESAVE (preserve EEPROM on Chip Erase -> not preserved)
47
#        | | | +-------------- WDTON (watchdog timer always on -> disable)
48
#        | | +---------------- SPIEN (enable serial programming -> enabled)
49
#        | +------------------ DWEN (debug wire enable)
50
#        +-------------------- RSTDISBL (disable external reset -> enabled)
51
#
52
# Fuse low byte:
53
# 0xe1 = 1 1 1 0   0 0 0 1
54
#        ^ ^ \+/   \--+--/
55
#        | |  |       +------- CKSEL 3..0 (clock selection -> HF PLL)
56
#        | |  +--------------- SUT 1..0 (BOD enabled, fast rising power)
57
#        | +------------------ CKOUT (clock output on CKOUT pin -> disabled)
58
#        +-------------------- CKDIV8 (divide clock by 8 -> don't divide)
59
fuse:
60
	$(AVRDUDE) -U hfuse:w:0xdd:m -U lfuse:w:0xe1:m
61
 
62
readcal:
63
	$(AVRDUDE) -U calibration:r:/dev/stdout:i | head -1
64
 
65
 
66
clean:
67
	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
68
 
69
# file targets:
70
main.bin:	$(OBJECTS)
71
	$(COMPILE) -o main.bin $(OBJECTS)
72
 
73
main.hex:	main.bin
74
	rm -f main.hex main.eep.hex
75
	avr-objcopy -j .text -j .data -O ihex main.bin main.hex
76
	./checksize main.bin 4096 256
77
# do the checksize script as our last action to allow successful compilation
78
# on Windows with WinAVR where the Unix commands will fail.
79
 
80
disasm:	main.bin
81
	avr-objdump -d main.bin
82
 
83
cpp:
84
	$(COMPILE) -E main.c