| 3516 | 
        miho | 
        1 | 
        # Name: Makefile | 
      
      
         | 
         | 
        2 | 
        # Project: USB I2C | 
      
      
         | 
         | 
        3 | 
        # Author: Christian Starkjohann, modified for I2C USB by Till Harbaum | 
      
      
         | 
         | 
        4 | 
        # Creation Date: 2005-03-20 | 
      
      
         | 
         | 
        5 | 
        # Tabsize: 4 | 
      
      
         | 
         | 
        6 | 
        # Copyright: (c) 2005 by OBJECTIVE DEVELOPMENT Software GmbH | 
      
      
         | 
         | 
        7 | 
        # License: Proprietary, free under certain conditions. See Documentation. | 
      
      
         | 
         | 
        8 | 
        # This Revision: $Id: Makefile-avrusb.mega8,v 1.1 2006/12/03 21:28:59 harbaum Exp $ | 
      
      
         | 
         | 
        9 | 
          | 
      
      
         | 
         | 
        10 | 
        SERIAL = `echo /dev/tty.[Uu][Ss]*` | 
      
      
         | 
         | 
        11 | 
        UISP = uisp -dprog=stk200 | 
      
      
         | 
         | 
        12 | 
        # UISP = uisp -dprog=avr910 -dserial=$(SERIAL) -dpart=auto | 
      
      
         | 
         | 
        13 | 
        # The two lines above are for "uisp" and the AVR910 serial programmer connected | 
      
      
         | 
         | 
        14 | 
        # to a Keyspan USB to serial converter to a Mac running Mac OS X. | 
      
      
         | 
         | 
        15 | 
        # Choose your favorite programmer and interface. | 
      
      
         | 
         | 
        16 | 
          | 
      
      
         | 
         | 
        17 | 
        DEFINES += -DDEBUG | 
      
      
         | 
         | 
        18 | 
        DEFINES += -DDEBUG_LEVEL=1 | 
      
      
         | 
         | 
        19 | 
        COMPILE = avr-gcc -Wall -O2 -Iusbdrv -I. -mmcu=atmega88 $(DEFINES) | 
      
      
         | 
         | 
        20 | 
          | 
      
      
         | 
         | 
        21 | 
        OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o | 
      
      
         | 
         | 
        22 | 
          | 
      
      
         | 
         | 
        23 | 
          | 
      
      
         | 
         | 
        24 | 
        # symbolic targets: | 
      
      
         | 
         | 
        25 | 
        all:	firmware.hex | 
      
      
         | 
         | 
        26 | 
          | 
      
      
         | 
         | 
        27 | 
        .c.o: | 
      
      
         | 
         | 
        28 | 
        	$(COMPILE) -c $< -o $@ | 
      
      
         | 
         | 
        29 | 
          | 
      
      
         | 
         | 
        30 | 
        .S.o: | 
      
      
         | 
         | 
        31 | 
        	$(COMPILE) -x assembler-with-cpp -c $< -o $@ | 
      
      
         | 
         | 
        32 | 
        # "-x assembler-with-cpp" should not be necessary since this is the default | 
      
      
         | 
         | 
        33 | 
        # file type for the .S (with capital S) extension. However, upper case | 
      
      
         | 
         | 
        34 | 
        # characters are not always preserved on Windows. To ensure WinAVR | 
      
      
         | 
         | 
        35 | 
        # compatibility define the file type manually. | 
      
      
         | 
         | 
        36 | 
          | 
      
      
         | 
         | 
        37 | 
        .c.s: | 
      
      
         | 
         | 
        38 | 
        	$(COMPILE) -S $< -o $@ | 
      
      
         | 
         | 
        39 | 
          | 
      
      
         | 
         | 
        40 | 
        # Fuse extended byte: | 
      
      
         | 
         | 
        41 | 
        # 0xF9 = 1 1 1 1   1 0 0 1 <<<----Default Value (default value is used) | 
      
      
         | 
         | 
        42 | 
        # 0xF9 = 1 1 1 1   1 0 0 1 <-- BOOTRST (select vetor) | 
      
      
         | 
         | 
        43 | 
        #                      \+/ | 
      
      
         | 
         | 
        44 | 
        #                       +----- BOOTSZ1..0 (Select Boot Size) | 
      
      
         | 
         | 
        45 | 
        # Fuse high byte: | 
      
      
         | 
         | 
        46 | 
        # 0xDF   1 1 0 1   1 1 1 1 <<<----Default Value (default value may be used) | 
      
      
         | 
         | 
        47 | 
        # 0xDE = 1 1 0 1   1 1 1 0 | 
      
      
         | 
         | 
        48 | 
        #        ^ ^ ^ ^   ^ \-+-/ | 
      
      
         | 
         | 
        49 | 
        #        | | | |   |   +------ BODLEVEL (1.7-2.0V) | 
      
      
         | 
         | 
        50 | 
        #        | | | |   +---------- EESAVE (don't preserve EEPROM over chip erase) | 
      
      
         | 
         | 
        51 | 
        #        | | | +-------------- WDTON (WDT not always on) | 
      
      
         | 
         | 
        52 | 
        #        | | +---------------- SPIEN (allow serial programming)!!! | 
      
      
         | 
         | 
        53 | 
        #        | +------------------ DWEN (debug wire not enabled) | 
      
      
         | 
         | 
        54 | 
        #        +-------------------- RSTDISBL (reset pin is not disabled) | 
      
      
         | 
         | 
        55 | 
        # Fuse low byte: | 
      
      
         | 
         | 
        56 | 
        # 0x62   0 1 1 0   0 0 1 0 <<<----Default Value (must be programmed to use xosc) | 
      
      
         | 
         | 
        57 | 
        # 0xD7 = 1 1 0 1   0 1 1 1 | 
      
      
         | 
         | 
        58 | 
        #        ^ ^ \ /   \--+--/ | 
      
      
         | 
         | 
        59 | 
        #        | |  |       +------- CKSEL 3..0 (full swing xosc, BOD enabled) | 
      
      
         | 
         | 
        60 | 
        #        | |  +--------------- SUT 1..0 (startup timer - see CKSEL) | 
      
      
         | 
         | 
        61 | 
        #        | +------------------ CKOUT (clock output is not enabled) | 
      
      
         | 
         | 
        62 | 
        #        +-------------------- CLKDIV8 (clock divider is not enabled) | 
      
      
         | 
         | 
        63 | 
        fuse: | 
      
      
         | 
         | 
        64 | 
        	$(UISP) --wr_fuse_h=0xDE --wr_fuse_l=0xD7 | 
      
      
         | 
         | 
        65 | 
          | 
      
      
         | 
         | 
        66 | 
          | 
      
      
         | 
         | 
        67 | 
        clean: | 
      
      
         | 
         | 
        68 | 
        	rm -f firmware.hex firmware.lst firmware.obj firmware.cof firmware.list firmware.map firmware.eep.hex firmware.bin *.o usbdrv/*.o firmware.s usbdrv/oddebug.s usbdrv/usbdrv.s | 
      
      
         | 
         | 
        69 | 
          | 
      
      
         | 
         | 
        70 | 
        # file targets: | 
      
      
         | 
         | 
        71 | 
        firmware.bin:	$(OBJECTS) | 
      
      
         | 
         | 
        72 | 
        	$(COMPILE) -o firmware.bin $(OBJECTS) | 
      
      
         | 
         | 
        73 | 
          | 
      
      
         | 
         | 
        74 | 
        firmware.hex:	firmware.bin | 
      
      
         | 
         | 
        75 | 
        	rm -f firmware.hex firmware.eep.hex | 
      
      
         | 
         | 
        76 | 
        	avr-objcopy -j .text -j .data -O ihex firmware.bin firmware.hex | 
      
      
         | 
         | 
        77 | 
        	./checksize firmware.bin 8192 960 | 
      
      
         | 
         | 
        78 | 
        # do the checksize script as our last action to allow successful compilation | 
      
      
         | 
         | 
        79 | 
        # on Windows with WinAVR where the Unix commands will fail. | 
      
      
         | 
         | 
        80 | 
          | 
      
      
         | 
         | 
        81 | 
        program: firmware.hex | 
      
      
         | 
         | 
        82 | 
        	avrdude -c usbasp -p atmega88 -U lfuse:w:0xD7:m -U hfuse:w:0xDE:m -U flash:w:firmware.hex | 
      
      
         | 
         | 
        83 | 
          | 
      
      
         | 
         | 
        84 | 
        program-nodep: | 
      
      
         | 
         | 
        85 | 
        	avrdude -c usbasp -p atmega88 -U lfuse:w:0xD7:m -U hfuse:w:0xDE:m -U flash:w:firmware.hex | 
      
      
         | 
         | 
        86 | 
          | 
      
      
         | 
         | 
        87 | 
        disasm:	firmware.bin | 
      
      
         | 
         | 
        88 | 
        	avr-objdump -d firmware.bin | 
      
      
         | 
         | 
        89 | 
          | 
      
      
         | 
         | 
        90 | 
        cpp: | 
      
      
         | 
         | 
        91 | 
        	$(COMPILE) -E main.c |