Skip to content

Commit 79d7a46

Browse files
committed
first commit
0 parents  commit 79d7a46

29 files changed

+8376
-0
lines changed

Makefile

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Name: Makefile
2+
# Project: custom-class example
3+
# Author: Christian Starkjohann
4+
# Creation Date: 2008-04-07
5+
# Tabsize: 4
6+
# Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
7+
# License: GNU GPL v2 (see License.txt), GNU GPL v3 or proprietary (CommercialLicense.txt)
8+
# This Revision: $Id: Makefile 692 2008-11-07 15:07:40Z cs $
9+
10+
DEVICE = attiny44
11+
F_CPU = 12000000 # in Hz
12+
FUSE_L = 0xFF
13+
FUSE_H = 0xDF
14+
AVRDUDE = avrdude -c avrispmkii -P usb -p $(DEVICE) # edit this line for your programmer
15+
16+
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0
17+
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o
18+
19+
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
20+
21+
##############################################################################
22+
# Fuse values for particular devices
23+
##############################################################################
24+
# If your device is not listed here, go to
25+
# http://palmavr.sourceforge.net/cgi-bin/fc.cgi
26+
# and choose options for external crystal clock and no clock divider
27+
#
28+
################################## ATMega8 ##################################
29+
# ATMega8 FUSE_L (Fuse low byte):
30+
# 0x9f = 1 0 0 1 1 1 1 1
31+
# ^ ^ \ / \--+--/
32+
# | | | +------- CKSEL 3..0 (external >8M crystal)
33+
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
34+
# | +------------------ BODEN (BrownOut Detector enabled)
35+
# +-------------------- BODLEVEL (2.7V)
36+
# ATMega8 FUSE_H (Fuse high byte):
37+
# 0xc9 = 1 1 0 0 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000)
38+
# ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0
39+
# | | | | | +-------- BOOTSZ1
40+
# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase)
41+
# | | | +-------------- CKOPT (full output swing)
42+
# | | +---------------- SPIEN (allow serial programming)
43+
# | +------------------ WDTON (WDT not always on)
44+
# +-------------------- RSTDISBL (reset pin is enabled)
45+
#
46+
############################## ATMega48/88/168 ##############################
47+
# ATMega*8 FUSE_L (Fuse low byte):
48+
# 0xdf = 1 1 0 1 1 1 1 1
49+
# ^ ^ \ / \--+--/
50+
# | | | +------- CKSEL 3..0 (external >8M crystal)
51+
# | | +--------------- SUT 1..0 (crystal osc, BOD enabled)
52+
# | +------------------ CKOUT (if 0: Clock output enabled)
53+
# +-------------------- CKDIV8 (if 0: divide by 8)
54+
# ATMega*8 FUSE_H (Fuse high byte):
55+
# 0xde = 1 1 0 1 1 1 1 0
56+
# ^ ^ ^ ^ ^ \-+-/
57+
# | | | | | +------ BODLEVEL 0..2 (110 = 1.8 V)
58+
# | | | | + --------- EESAVE (preserve EEPROM over chip erase)
59+
# | | | +-------------- WDTON (if 0: watchdog always on)
60+
# | | +---------------- SPIEN (allow serial programming)
61+
# | +------------------ DWEN (debug wire enable)
62+
# +-------------------- RSTDISBL (reset pin is enabled)
63+
#
64+
############################## ATTiny25/45/85 ###############################
65+
# ATMega*5 FUSE_L (Fuse low byte):
66+
# 0xef = 1 1 1 0 1 1 1 1
67+
# ^ ^ \+/ \--+--/
68+
# | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz)
69+
# | | +--------------- SUT 1..0 (BOD enabled, fast rising power)
70+
# | +------------------ CKOUT (clock output on CKOUT pin -> disabled)
71+
# +-------------------- CKDIV8 (divide clock by 8 -> don't divide)
72+
# ATMega*5 FUSE_H (Fuse high byte):
73+
# 0xdd = 1 1 0 1 1 1 0 1
74+
# ^ ^ ^ ^ ^ \-+-/
75+
# | | | | | +------ BODLEVEL 2..0 (brownout trigger level -> 2.7V)
76+
# | | | | +---------- EESAVE (preserve EEPROM on Chip Erase -> not preserved)
77+
# | | | +-------------- WDTON (watchdog timer always on -> disable)
78+
# | | +---------------- SPIEN (enable serial programming -> enabled)
79+
# | +------------------ DWEN (debug wire enable)
80+
# +-------------------- RSTDISBL (disable external reset -> enabled)
81+
#
82+
################################ ATTiny2313 #################################
83+
# ATTiny2313 FUSE_L (Fuse low byte):
84+
# 0xef = 1 1 1 0 1 1 1 1
85+
# ^ ^ \+/ \--+--/
86+
# | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz)
87+
# | | +--------------- SUT 1..0 (BOD enabled, fast rising power)
88+
# | +------------------ CKOUT (clock output on CKOUT pin -> disabled)
89+
# +-------------------- CKDIV8 (divide clock by 8 -> don't divide)
90+
# ATTiny2313 FUSE_H (Fuse high byte):
91+
# 0xdb = 1 1 0 1 1 0 1 1
92+
# ^ ^ ^ ^ \-+-/ ^
93+
# | | | | | +---- RSTDISBL (disable external reset -> enabled)
94+
# | | | | +-------- BODLEVEL 2..0 (brownout trigger level -> 2.7V)
95+
# | | | +-------------- WDTON (watchdog timer always on -> disable)
96+
# | | +---------------- SPIEN (enable serial programming -> enabled)
97+
# | +------------------ EESAVE (preserve EEPROM on Chip Erase -> not preserved)
98+
# +-------------------- DWEN (debug wire enable)
99+
100+
101+
# symbolic targets:
102+
help:
103+
@echo "This Makefile has no default rule. Use one of the following:"
104+
@echo "make hex ....... to build main.hex"
105+
@echo "make program ... to flash fuses and firmware"
106+
@echo "make fuse ...... to flash the fuses"
107+
@echo "make flash ..... to flash the firmware (use this on metaboard)"
108+
@echo "make clean ..... to delete objects and hex file"
109+
110+
hex: main.hex
111+
112+
program: flash fuse
113+
114+
# rule for programming fuse bits:
115+
fuse:
116+
@[ "$(FUSE_H)" != "" -a "$(FUSE_L)" != "" ] || \
117+
{ echo "*** Edit Makefile and choose values for FUSE_L and FUSE_H!"; exit 1; }
118+
$(AVRDUDE) -U hfuse:w:$(FUSE_H):m -U lfuse:w:$(FUSE_L):m
119+
120+
# rule for uploading firmware:
121+
flash: main.hex
122+
$(AVRDUDE) -U flash:w:main.hex:i
123+
124+
# rule for deleting dependent files (those which can be built by Make):
125+
clean:
126+
rm -f main.hex main.lst main.obj main.cof main.list main.map main.eep.hex main.elf *.o usbdrv/*.o main.s usbdrv/oddebug.s usbdrv/usbdrv.s
127+
128+
# Generic rule for compiling C files:
129+
.c.o:
130+
$(COMPILE) -c $< -o $@
131+
132+
# Generic rule for assembling Assembler source files:
133+
.S.o:
134+
$(COMPILE) -x assembler-with-cpp -c $< -o $@
135+
# "-x assembler-with-cpp" should not be necessary since this is the default
136+
# file type for the .S (with capital S) extension. However, upper case
137+
# characters are not always preserved on Windows. To ensure WinAVR
138+
# compatibility define the file type manually.
139+
140+
# Generic rule for compiling C to assembler, used for debugging only.
141+
.c.s:
142+
$(COMPILE) -S $< -o $@
143+
144+
# file targets:
145+
146+
# Since we don't want to ship the driver multipe times, we copy it into this project:
147+
usbdrv:
148+
cp -r ../../../usbdrv .
149+
150+
main.elf: usbdrv $(OBJECTS) # usbdrv dependency only needed because we copy it
151+
$(COMPILE) -o main.elf $(OBJECTS)
152+
153+
main.hex: main.elf
154+
rm -f main.hex main.eep.hex
155+
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
156+
avr-size main.hex
157+
158+
# debugging targets:
159+
160+
disasm: main.elf
161+
avr-objdump -d main.elf
162+
163+
cpp:
164+
$(COMPILE) -E main.c

0 commit comments

Comments
 (0)