1 |
# Name: Makefile |
1 |
# Name: Makefile |
2 |
# Project: USB I2C |
2 |
# Project: USB I2C |
3 |
# Author: Christian Starkjohann, modified for I2C USB by Till Harbaum |
3 |
# Author: Christian Starkjohann, modified for I2C USB by Till Harbaum |
4 |
# Creation Date: 2005-03-20 |
4 |
# Creation Date: 2005-03-20 |
5 |
# Tabsize: 4 |
5 |
# Tabsize: 4 |
6 |
# Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH |
6 |
# Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH |
7 |
# License: Proprietary, free under certain conditions. See Documentation. |
7 |
# License: Proprietary, free under certain conditions. See Documentation. |
8 |
# This Revision: $Id: Makefile-avrusb.tiny45,v 1.3 2007/06/07 13:53:47 harbaum Exp $ |
8 |
# This Revision: $Id: Makefile-avrusb.tiny45,v 1.3 2007/06/07 13:53:47 harbaum Exp $ |
9 |
|
9 |
|
10 |
# DEFINES += -DDEBUG |
10 |
# DEFINES += -DDEBUG |
11 |
# DEFINES += -DDEBUG_LEVEL=1 |
11 |
# DEFINES += -DDEBUG_LEVEL=1 |
12 |
DEFINES += -DF_CPU=12000000 |
12 |
DEFINES += -DF_CPU=12000000 |
13 |
COMPILE = avr-gcc -Wall -O2 -Iusbdrv -I. -mmcu=attiny45 $(DEFINES) |
13 |
COMPILE = avr-gcc -Wall -O2 -Iusbdrv -I. -mmcu=attiny45 $(DEFINES) |
14 |
|
14 |
|
15 |
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o |
15 |
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o |
16 |
|
16 |
|
17 |
# symbolic targets: |
17 |
# symbolic targets: |
18 |
all: firmware.hex |
18 |
all: firmware.hex |
19 |
|
19 |
|
20 |
.c.o: |
20 |
.c.o: |
21 |
$(COMPILE) -c $< -o $@ |
21 |
$(COMPILE) -c $< -o $@ |
22 |
|
22 |
|
23 |
.S.o: |
23 |
.S.o: |
24 |
$(COMPILE) -x assembler-with-cpp -c $< -o $@ |
24 |
$(COMPILE) -x assembler-with-cpp -c $< -o $@ |
25 |
# "-x assembler-with-cpp" should not be necessary since this is the default |
25 |
# "-x assembler-with-cpp" should not be necessary since this is the default |
26 |
# file type for the .S (with capital S) extension. However, upper case |
26 |
# file type for the .S (with capital S) extension. However, upper case |
27 |
# characters are not always preserved on Windows. To ensure WinAVR |
27 |
# characters are not always preserved on Windows. To ensure WinAVR |
28 |
# compatibility define the file type manually. |
28 |
# compatibility define the file type manually. |
29 |
|
29 |
|
30 |
.c.s: |
30 |
.c.s: |
31 |
$(COMPILE) -S $< -o $@ |
31 |
$(COMPILE) -S $< -o $@ |
32 |
|
32 |
|
33 |
# Fuse high byte: |
33 |
# Fuse high byte: |
34 |
# 0x5f = 0 1 0 1 1 1 1 1 <-- BODLEVEL0 (Brown out trigger level bit 0) |
34 |
# 0x5f = 0 1 0 1 1 1 1 1 <-- BODLEVEL0 (Brown out trigger level bit 0) |
35 |
# ^ ^ ^ ^ ^ ^ ^------ BODLEVEL1 (Brown out trigger level bit 1) |
35 |
# ^ ^ ^ ^ ^ ^ ^------ BODLEVEL1 (Brown out trigger level bit 1) |
36 |
# | | | | | +-------- BODLEVEL2 (Brown out trigger level bit 2) |
36 |
# | | | | | +-------- BODLEVEL2 (Brown out trigger level bit 2) |
37 |
# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) |
37 |
# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) |
38 |
# | | | +-------------- WDTON (WDT not always on) |
38 |
# | | | +-------------- WDTON (WDT not always on) |
39 |
# | | +---------------- SPIEN (allow serial programming) |
39 |
# | | +---------------- SPIEN (allow serial programming) |
40 |
# | +------------------ DWEN (ebug wire is enabled) |
40 |
# | +------------------ DWEN (ebug wire is enabled) |
41 |
# +-------------------- RSTDISBL (reset pin is disabled) |
41 |
# +-------------------- RSTDISBL (reset pin is disabled) |
42 |
# Fuse low byte: |
42 |
# Fuse low byte: |
43 |
# 0xdf = 1 1 0 1 1 1 1 1 |
43 |
# 0xdf = 1 1 0 1 1 1 1 1 |
44 |
# ^ ^ \ / \--+--/ |
44 |
# ^ ^ \ / \--+--/ |
45 |
# | | | +------- CKSEL 3..0 (external >8M crystal) |
45 |
# | | | +------- CKSEL 3..0 (external >8M crystal) |
46 |
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled) |
46 |
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled) |
47 |
# | +------------------ CKOUT (clock output enable) |
47 |
# | +------------------ CKOUT (clock output enable) |
48 |
# +-------------------- CKDIV8 (divide clock by eight disabled) |
48 |
# +-------------------- CKDIV8 (divide clock by eight disabled) |
49 |
|
49 |
|
50 |
clean: |
50 |
clean: |
51 |
rm -f firmware.lst firmware.obj firmware.cof firmware.list firmware.map *.bin *.o */*.o *~ */*~ firmware.s usbdrv/oddebug.s usbdrv/usbdrv.s |
51 |
rm -f firmware.lst firmware.obj firmware.cof firmware.list firmware.map *.bin *.o */*.o *~ */*~ firmware.s usbdrv/oddebug.s usbdrv/usbdrv.s |
52 |
|
52 |
|
53 |
# file targets: |
53 |
# file targets: |
54 |
firmware.bin: $(OBJECTS) |
54 |
firmware.bin: $(OBJECTS) |
55 |
$(COMPILE) -o firmware.bin $(OBJECTS) |
55 |
$(COMPILE) -o firmware.bin $(OBJECTS) |
56 |
|
56 |
|
57 |
firmware.hex: firmware.bin |
57 |
firmware.hex: firmware.bin |
58 |
rm -f firmware.hex firmware.eep.hex |
58 |
rm -f firmware.hex firmware.eep.hex |
59 |
avr-objcopy -j .text -j .data -O ihex firmware.bin firmware.hex |
59 |
avr-objcopy -j .text -j .data -O ihex firmware.bin firmware.hex |
60 |
./checksize firmware.bin 4096 196 |
60 |
./checksize firmware.bin 4096 196 |
61 |
# do the checksize script as our last action to allow successful compilation |
61 |
# do the checksize script as our last action to allow successful compilation |
62 |
# on Windows with WinAVR where the Unix commands will fail. |
62 |
# on Windows with WinAVR where the Unix commands will fail. |
63 |
|
63 |
|
64 |
program: firmware.hex |
64 |
program: firmware.hex |
65 |
avrdude -P/dev/ttyS0 -c stk500hvsp -p attiny45 -U lfuse:w:0xdf:m -U flash:w:firmware.hex -U hfuse:w:0x5f:m |
65 |
avrdude -P/dev/ttyS0 -c stk500hvsp -p attiny45 -U lfuse:w:0xdf:m -U flash:w:firmware.hex -U hfuse:w:0x5f:m |
66 |
|
66 |
|
67 |
program-usb: firmware.hex |
67 |
program-usb: firmware.hex |
68 |
avrdude -P/dev/ttyUSB0 -c stk500hvsp -p attiny45 -U lfuse:w:0xdf:m -U flash:w:firmware.hex -U hfuse:w:0x5f:m |
68 |
avrdude -P/dev/ttyUSB0 -c stk500hvsp -p attiny45 -U lfuse:w:0xdf:m -U flash:w:firmware.hex -U hfuse:w:0x5f:m |
69 |
|
69 |
|
70 |
disasm: firmware.bin |
70 |
disasm: firmware.bin |
71 |
avr-objdump -d firmware.bin |
71 |
avr-objdump -d firmware.bin |
72 |
|
72 |
|
73 |
cpp: |
73 |
cpp: |
74 |
$(COMPILE) -E main.c |
74 |
$(COMPILE) -E main.c |