116 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
			
		
		
	
	
			116 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
| # $Id: Makefile,v 1.1 2007/07/29 17:19:50 rschaten Exp $
 | |
| 
 | |
| # microcontroller settings
 | |
| F_CPU = 20000000UL
 | |
| MCU = attiny2313
 | |
| 
 | |
| # usb programmer:
 | |
| AVRDUDE = avrdude -p $(MCU) -P /dev/tts/USB0 -b 115200 -c avr109
 | |
| # parallel programmer, used to set fuse bits:
 | |
| AVRDUDE2 = avrdude -p $(MCU) -P /dev/parport0 -c stk200 -E noreset,vcc
 | |
| 
 | |
| 
 | |
| COMPILE = avr-gcc -Wall -Os -I../common -I. -mmcu=$(MCU)  -DF_CPU=$(F_CPU) -Wa,-ahlms=$(<:.c=.lst) #-DDEBUG_LEVEL=2
 | |
| 
 | |
| OBJECTS = main.o usiTwiSlave.o
 | |
| 
 | |
| TODAY=`date "+%y%m%d"`
 | |
| DIR=`basename \`pwd\``
 | |
| PACKETNAME=$(DIR)_$(TODAY)
 | |
| 
 | |
| all: usage
 | |
| 
 | |
| usage:
 | |
| 	@echo "Usage of this makefile:"
 | |
| 	@echo "make firmware   create firmware"
 | |
| 	@echo "make program    send firmware to the device"
 | |
| 	@echo "make fuses      set fuses of the device"
 | |
| 	@echo "make docs       create documentation"
 | |
| 	@echo "make tarball    packs a tarball for shipping"
 | |
| 	@echo "make clean      tidy the directory"
 | |
| 	@echo
 | |
| 	@echo "For further information, consult the documentation in Readme.txt."
 | |
| 
 | |
| # symbolic targets:
 | |
| firmware: main.hex
 | |
| 
 | |
| .c.o:
 | |
| 	$(COMPILE) -c $< -o $@
 | |
| 
 | |
| .c.s:
 | |
| 	$(COMPILE) -S $< -o $@
 | |
| 
 | |
| program: firmware
 | |
| 	$(AVRDUDE) -U flash:w:main.hex
 | |
| 
 | |
| # Fuse low byte:
 | |
| # 0xef = 1 1 1 0   1 1 1 1
 | |
| #        ^ ^ \+/   \--+--/
 | |
| #        | |  |       +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz)
 | |
| #        | |  +--------------- SUT 1..0 (BOD enabled, fast rising power)
 | |
| #        | +------------------ CKOUT (clock output on CKOUT pin -> disabled)
 | |
| #        +-------------------- CKDIV8 (divide clock by 8 -> don't divide)
 | |
| #
 | |
| # Fuse high byte:
 | |
| # 0xdb = 1 1 0 1   1 0 1 1
 | |
| #        ^ ^ ^ ^   \-+-/ ^
 | |
| #        | | | |     |   +---- RSTDISBL (disable external reset -> enabled)
 | |
| #        | | | |     +-------- BODLEVEL 2..0 (brownout trigger level -> 2.7V)
 | |
| #        | | | +-------------- WDTON (watchdog timer always on -> disable)
 | |
| #        | | +---------------- SPIEN (enable serial programming -> enabled)
 | |
| #        | +------------------ EESAVE (preserve EEPROM on Chip Erase -> not preserved)
 | |
| #        +-------------------- DWEN (debug wire enable)
 | |
| fuses:
 | |
| 	$(AVRDUDE2) -u -U hfuse:w:0xdb:m -U lfuse:w:0xef:m
 | |
| 
 | |
| clean:
 | |
| 	rm -f main.lst main.obj main.cof main.list main.map main.eep.hex main.bin *.o main.s *.lst
 | |
| 	rm -rf htmldoc latexdoc Readme.txt refman.pdf
 | |
| 	rm -f $(PACKETNAME).tar.gz
 | |
| 
 | |
| # file targets:
 | |
| main.bin: $(OBJECTS)
 | |
| 	$(COMPILE) -o main.bin $(OBJECTS)
 | |
| 
 | |
| main.hex: main.bin
 | |
| 	rm -f main.hex main.eep.hex
 | |
| 	avr-objcopy -j .text -j .data -O ihex main.bin main.hex
 | |
| 	avr-size main.hex
 | |
| 
 | |
| # doc generation
 | |
| docs: readme pdf
 | |
| 	@echo "documentation created"
 | |
| 
 | |
| readme: doxygen
 | |
| 	echo "This file is auto-generated from the content of <main.c>." > Readme.txt
 | |
| 	echo "You'll have more fun if you read the HTML-content in htmldoc or the PDF." >> Readme.txt
 | |
| 	echo >> Readme.txt
 | |
| 	lynx -dump htmldoc/main.html >> Readme.txt
 | |
| 
 | |
| pdf: doxygen
 | |
| 	make -C latexdoc
 | |
| 	mv latexdoc/refman.pdf .
 | |
| 	rm -rf latexdoc
 | |
| 
 | |
| doxygen:
 | |
| 	doxygen i2c-dimmer.doxygen
 | |
| 
 | |
| tarball: firmware clean docs
 | |
| 	@echo
 | |
| 	@echo
 | |
| 	@echo "I assume you updated the Changelog...? Press Enter to continue..."
 | |
| 	@read
 | |
| 	mv -v main.hex main_$(TODAY).hex
 | |
| 	[ -e "main_$(TODAY).hex" ] || exit
 | |
| 	rm --force $(PACKETNAME).tar.gz;            \
 | |
| 	tar --directory=..                          \
 | |
| 	    --exclude=$(DIR)/Makefile               \
 | |
| 	    --exclude=CVS                           \
 | |
| 	    --exclude=*.ps                          \
 | |
| 	    --create                                \
 | |
| 	    --gzip                                  \
 | |
| 	    --verbose                               \
 | |
| 	    --file ../$(PACKETNAME).tar.gz $(DIR)
 | |
| 	rm -f main_$(TODAY).hex
 | |
| 
 |