Minor documentation enhancements.
[pub/USBasp.git] / Demos / Device / ClassDriver / MassStorageKeyboard / makefile
index b9fb9d9..09c4806 100644 (file)
@@ -66,33 +66,26 @@ MCU = at90usb1287
 # Target board (see library "Board Types" documentation, NONE for projects not requiring
 # LUFA board drivers). If USER is selected, put custom board drivers in a directory called 
 # "Board" inside the application directory.
 # Target board (see library "Board Types" documentation, NONE for projects not requiring
 # LUFA board drivers). If USER is selected, put custom board drivers in a directory called 
 # "Board" inside the application directory.
-BOARD  = USBKEY
+BOARD = USBKEY
 
 
 # Processor frequency.
 #     This will define a symbol, F_CPU, in all source code files equal to the 
 
 
 # Processor frequency.
 #     This will define a symbol, F_CPU, in all source code files equal to the 
-#     processor frequency. You can then use this symbol in your source code to 
+#     processor frequency in Hz. You can then use this symbol in your source code to 
 #     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
 #     automatically to create a 32-bit value in your source code.
 #     calculate timings. Do NOT tack on a 'UL' at the end, this will be done
 #     automatically to create a 32-bit value in your source code.
-#     Typical values are:
-#         F_CPU =  1000000
-#         F_CPU =  1843200
-#         F_CPU =  2000000
-#         F_CPU =  3686400
-#         F_CPU =  4000000
-#         F_CPU =  7372800
-#         F_CPU =  8000000
-#         F_CPU = 11059200
-#         F_CPU = 14745600
-#         F_CPU = 16000000
-#         F_CPU = 18432000
-#         F_CPU = 20000000
+#
+#     This will be an integer division of F_CLOCK below, as it is sourced by
+#     F_CLOCK after it has run through any CPU prescalers. Note that this value
+#     does not *change* the processor frequency - it should merely be updated to
+#     reflect the processor speed set externally so that the code can use accurate
+#     software delays.
 F_CPU = 8000000
 
 
 # Input clock frequency.
 #     This will define a symbol, F_CLOCK, in all source code files equal to the 
 F_CPU = 8000000
 
 
 # Input clock frequency.
 #     This will define a symbol, F_CLOCK, in all source code files equal to the 
-#     input clock frequency (before any prescaling is performed). This value may
+#     input clock frequency (before any prescaling is performed) in Hz. This value may
 #     differ from F_CPU if prescaling is used on the latter, and is required as the
 #     raw input clock is fed directly to the PLL sections of the AVR for high speed
 #     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
 #     differ from F_CPU if prescaling is used on the latter, and is required as the
 #     raw input clock is fed directly to the PLL sections of the AVR for high speed
 #     clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
@@ -122,7 +115,7 @@ OBJDIR = .
 LUFA_PATH = ../../../..
 
 
 LUFA_PATH = ../../../..
 
 
-# LUFA library compile-time options
+# LUFA library compile-time options and predefined tokens
 LUFA_OPTS  = -D USB_DEVICE_ONLY
 LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
 LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
 LUFA_OPTS  = -D USB_DEVICE_ONLY
 LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8
 LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1
@@ -131,27 +124,17 @@ LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENAB
 LUFA_OPTS += -D INTERRUPT_CONTROL_ENDPOINT
 
 
 LUFA_OPTS += -D INTERRUPT_CONTROL_ENDPOINT
 
 
+# Create the LUFA source path variables by including the LUFA root makefile
+include $(LUFA_PATH)/LUFA/makefile
+
 
 # List C source files here. (C dependencies are automatically generated.)
 SRC = $(TARGET).c                                                 \
          Descriptors.c                                               \
 
 # List C source files here. (C dependencies are automatically generated.)
 SRC = $(TARGET).c                                                 \
          Descriptors.c                                               \
-         Lib/SCSI.c                                                  \
          Lib/DataflashManager.c                                      \
          Lib/DataflashManager.c                                      \
-         $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c        \
-         $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Device.c             \
-         $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Endpoint.c           \
-         $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Host.c               \
-         $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/HostChapter9.c       \
-         $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/LowLevel.c           \
-         $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Pipe.c               \
-         $(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/USBInterrupt.c       \
-         $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c  \
-         $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/Events.c            \
-         $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/USBTask.c           \
-         $(LUFA_PATH)/LUFA/Drivers/USB/Class/Device/MassStorage.c    \
-         $(LUFA_PATH)/LUFA/Drivers/USB/Class/Device/HID.c            \
-
-
+         Lib/SCSI.c                                                  \
+         $(LUFA_SRC_USB)                                             \
+         $(LUFA_SRC_USBCLASS)
 
 
 # List C++ source files here. (C dependencies are automatically generated.)
 
 
 # List C++ source files here. (C dependencies are automatically generated.)
@@ -193,19 +176,27 @@ EXTRAINCDIRS = $(LUFA_PATH)/
 #     gnu89 = c89 plus GCC extensions
 #     c99   = ISO C99 standard (not yet fully implemented)
 #     gnu99 = c99 plus GCC extensions
 #     gnu89 = c89 plus GCC extensions
 #     c99   = ISO C99 standard (not yet fully implemented)
 #     gnu99 = c99 plus GCC extensions
-CSTANDARD = -std=gnu99
+CSTANDARD = -std=c99
 
 
 # Place -D or -U options here for C sources
 
 
 # Place -D or -U options here for C sources
-CDEFS  = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA_OPTS)
+CDEFS  = -DF_CPU=$(F_CPU)UL
+CDEFS += -DF_CLOCK=$(F_CLOCK)UL
+CDEFS += -DBOARD=BOARD_$(BOARD)
+CDEFS += $(LUFA_OPTS)
 
 
 # Place -D or -U options here for ASM sources
 
 
 # Place -D or -U options here for ASM sources
-ADEFS = -DF_CPU=$(F_CPU)
-
+ADEFS  = -DF_CPU=$(F_CPU)
+ADEFS += -DF_CLOCK=$(F_CLOCK)UL
+ADEFS += -DBOARD=BOARD_$(BOARD)
+ADEFS += $(LUFA_OPTS)
 
 # Place -D or -U options here for C++ sources
 
 # Place -D or -U options here for C++ sources
-CPPDEFS = -DF_CPU=$(F_CPU)UL
+CPPDEFS  = -DF_CPU=$(F_CPU)UL
+CPPDEFS += -DF_CLOCK=$(F_CLOCK)UL
+CPPDEFS += -DBOARD=BOARD_$(BOARD)
+CPPDEFS += $(LUFA_OPTS)
 #CPPDEFS += -D__STDC_LIMIT_MACROS
 #CPPDEFS += -D__STDC_CONSTANT_MACROS
 
 #CPPDEFS += -D__STDC_LIMIT_MACROS
 #CPPDEFS += -D__STDC_CONSTANT_MACROS
 
@@ -224,13 +215,15 @@ CFLAGS += -O$(OPT)
 CFLAGS += -funsigned-char
 CFLAGS += -funsigned-bitfields
 CFLAGS += -ffunction-sections
 CFLAGS += -funsigned-char
 CFLAGS += -funsigned-bitfields
 CFLAGS += -ffunction-sections
+CFLAGS += -fno-inline-small-functions
 CFLAGS += -fpack-struct
 CFLAGS += -fshort-enums
 CFLAGS += -fpack-struct
 CFLAGS += -fshort-enums
-CFLAGS += -finline-limit=20
+CFLAGS += -fno-strict-aliasing
 CFLAGS += -Wall
 CFLAGS += -Wstrict-prototypes
 CFLAGS += -Wall
 CFLAGS += -Wstrict-prototypes
-CFLAGS += -Wundef
+#CFLAGS += -mshort-calls
 #CFLAGS += -fno-unit-at-a-time
 #CFLAGS += -fno-unit-at-a-time
+#CFLAGS += -Wundef
 #CFLAGS += -Wunreachable-code
 #CFLAGS += -Wsign-compare
 CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
 #CFLAGS += -Wunreachable-code
 #CFLAGS += -Wsign-compare
 CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst)
@@ -254,7 +247,7 @@ CPPFLAGS += -fpack-struct
 CPPFLAGS += -fshort-enums
 CPPFLAGS += -fno-exceptions
 CPPFLAGS += -Wall
 CPPFLAGS += -fshort-enums
 CPPFLAGS += -fno-exceptions
 CPPFLAGS += -Wall
-CFLAGS += -Wundef
+CPPFLAGS += -Wundef
 #CPPFLAGS += -mshort-calls
 #CPPFLAGS += -fno-unit-at-a-time
 #CPPFLAGS += -Wstrict-prototypes
 #CPPFLAGS += -mshort-calls
 #CPPFLAGS += -fno-unit-at-a-time
 #CPPFLAGS += -Wstrict-prototypes
@@ -331,8 +324,8 @@ EXTMEMOPTS =
 #  -Wl,...:     tell GCC to pass this to linker.
 #    -Map:      create map file
 #    --cref:    add cross reference to  map file
 #  -Wl,...:     tell GCC to pass this to linker.
 #    -Map:      create map file
 #    --cref:    add cross reference to  map file
-LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
-LDFLAGS += -Wl,--relax
+LDFLAGS  = -Wl,-Map=$(TARGET).map,--cref
+LDFLAGS += -Wl,--relax 
 LDFLAGS += -Wl,--gc-sections
 LDFLAGS += $(EXTMEMOPTS)
 LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
 LDFLAGS += -Wl,--gc-sections
 LDFLAGS += $(EXTMEMOPTS)
 LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
@@ -343,9 +336,7 @@ LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
 
 #---------------- Programming Options (avrdude) ----------------
 
 
 #---------------- Programming Options (avrdude) ----------------
 
-# Programming hardware: alf avr910 avrisp bascom bsd 
-# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500
-#
+# Programming hardware
 # Type: avrdude -c ?
 # to get a full listing.
 #
 # Type: avrdude -c ?
 # to get a full listing.
 #
@@ -425,6 +416,7 @@ REMOVEDIR = rm -rf
 COPY = cp
 WINSHELL = cmd
 
 COPY = cp
 WINSHELL = cmd
 
+
 # Define Messages
 # English
 MSG_ERRORS_NONE = Errors: none
 # Define Messages
 # English
 MSG_ERRORS_NONE = Errors: none
@@ -470,7 +462,7 @@ ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
 
 
 # Default target.
 
 
 # Default target.
-all: begin gccversion sizebefore build showeventhooks showliboptions showtarget sizeafter end
+all: begin gccversion sizebefore build sizeafter end
 
 # Change the build target to build a HEX file or a library.
 build: elf hex eep lss sym
 
 # Change the build target to build a HEX file or a library.
 build: elf hex eep lss sym
@@ -505,6 +497,7 @@ ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf
 MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
 FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
 
 MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )
 FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr )
 
+
 sizebefore:
        @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
        2>/dev/null; echo; fi
 sizebefore:
        @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \
        2>/dev/null; echo; fi
@@ -513,40 +506,38 @@ sizeafter:
        @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
        2>/dev/null; echo; fi
 
        @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \
        2>/dev/null; echo; fi
 
-showeventhooks: build
-       @echo
-       @echo -------- Unhooked LUFA Events --------
-       @$(shell) (grep -s '^EVENT_.*LUFA/.*\\.o' $(TARGET).map | \
-                  cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
-                          echo "(None)"
-       @echo --------------------------------------
 
 
-showliboptions:
-       @echo
-       @echo ---- Compile Time Library Options ----
-       @for i in $(LUFA_OPTS:-D%=%); do \
-               echo $$i; \
-       done
-       @echo --------------------------------------
 
 
-showtarget:
-       @echo
-       @echo --------- Target Information ---------
-       @echo AVR Model: $(MCU)
-       @echo Board:     $(BOARD)
-       @echo Clock:     $(F_CPU)Hz CPU, $(F_CLOCK)Hz Master
-       @echo --------------------------------------
-       
 # Display compiler version information.
 gccversion : 
        @$(CC) --version
 
 
 # Display compiler version information.
 gccversion : 
        @$(CC) --version
 
 
-
 # Program the device.  
 program: $(TARGET).hex $(TARGET).eep
        $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
 
 # Program the device.  
 program: $(TARGET).hex $(TARGET).eep
        $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
 
+flip: $(TARGET).hex
+       batchisp -hardware usb -device $(MCU) -operation erase f
+       batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program
+       batchisp -hardware usb -device $(MCU) -operation start reset 0
+
+dfu: $(TARGET).hex
+       dfu-programmer $(MCU) erase
+       dfu-programmer $(MCU) flash $(TARGET).hex
+       dfu-programmer $(MCU) reset
+
+flip-ee: $(TARGET).hex $(TARGET).eep
+       $(COPY) $(TARGET).eep $(TARGET)eep.hex
+       batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase
+       batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program
+       batchisp -hardware usb -device $(MCU) -operation start reset 0
+       $(REMOVE) $(TARGET)eep.hex
+
+dfu-ee: $(TARGET).hex $(TARGET).eep
+       dfu-programmer $(MCU) eeprom-flash $(TARGET).eep
+       dfu-programmer $(MCU) reset
+
 
 # Generate avr-gdb config/init file which does the following:
 #     define the reset signal, load the target file, connect to target, and set 
 
 # Generate avr-gdb config/init file which does the following:
 #     define the reset signal, load the target file, connect to target, and set 
@@ -605,7 +596,7 @@ extcoff: $(TARGET).elf
 %.hex: %.elf
        @echo
        @echo $(MSG_FLASH) $@
 %.hex: %.elf
        @echo
        @echo $(MSG_FLASH) $@
-       $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
+       $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $< $@
 
 %.eep: %.elf
        @echo
 
 %.eep: %.elf
        @echo
@@ -617,7 +608,7 @@ extcoff: $(TARGET).elf
 %.lss: %.elf
        @echo
        @echo $(MSG_EXTENDED_LISTING) $@
 %.lss: %.elf
        @echo
        @echo $(MSG_EXTENDED_LISTING) $@
-       $(OBJDUMP) -h -z -S $< > $@
+       $(OBJDUMP) -h -S -z $< > $@
 
 # Create a symbol table from ELF output file.
 %.sym: %.elf
 
 # Create a symbol table from ELF output file.
 %.sym: %.elf
@@ -679,31 +670,28 @@ $(OBJDIR)/%.o : %.S
 # Create preprocessed source for use in sending a bug report.
 %.i : %.c
        $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ 
 # Create preprocessed source for use in sending a bug report.
 %.i : %.c
        $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ 
-       
+
 
 # Target: clean project.
 
 # Target: clean project.
-clean: begin clean_list clean_binary end
+clean: begin clean_list end
 
 
-clean_binary:
-       $(REMOVE) $(TARGET).hex
-       
-clean_list:
+clean_list :
+       @echo
        @echo $(MSG_CLEANING)
        @echo $(MSG_CLEANING)
+       $(REMOVE) $(TARGET).hex
        $(REMOVE) $(TARGET).eep
        $(REMOVE) $(TARGET).eep
-       $(REMOVE) $(TARGET)eep.hex
        $(REMOVE) $(TARGET).cof
        $(REMOVE) $(TARGET).elf
        $(REMOVE) $(TARGET).map
        $(REMOVE) $(TARGET).sym
        $(REMOVE) $(TARGET).lss
        $(REMOVE) $(TARGET).cof
        $(REMOVE) $(TARGET).elf
        $(REMOVE) $(TARGET).map
        $(REMOVE) $(TARGET).sym
        $(REMOVE) $(TARGET).lss
-       $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)
-       $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)
+       $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
+       $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
        $(REMOVE) $(SRC:.c=.s)
        $(REMOVE) $(SRC:.c=.d)
        $(REMOVE) $(SRC:.c=.i)
        $(REMOVEDIR) .dep
 
        $(REMOVE) $(SRC:.c=.s)
        $(REMOVE) $(SRC:.c=.d)
        $(REMOVE) $(SRC:.c=.i)
        $(REMOVEDIR) .dep
 
-
 doxygen:
        @echo Generating Project Documentation...
        @doxygen Doxygen.conf
 doxygen:
        @echo Generating Project Documentation...
        @doxygen Doxygen.conf
@@ -721,8 +709,7 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
 
 
 # Listing of phony targets.
 
 
 # Listing of phony targets.
-.PHONY : all showeventhooks showliboptions showtarget  \
-begin finish end sizebefore sizeafter gccversion build \
-elf hex eep lss sym coff extcoff program clean debug   \
-clean_list clean_binary gdb-config doxygen dfu flip    \
-flip-ee dfu-ee
+.PHONY : all begin finish end sizebefore sizeafter gccversion \
+build elf hex eep lss sym coff extcoff doxygen clean          \
+clean_list clean_doxygen program dfu flip flip-ee dfu-ee      \
+debug gdb-config