--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * Special application to extract an EEPROM image stored in FLASH memory, and\r
+ * copy it to the device EEPROM. This application is designed to be used with\r
+ * the HID build system module of LUFA to program the EEPROM of a target device\r
+ * that uses the HID bootloader protocol, which does not have native EEPROM\r
+ * programming support.\r
+ */\r
+\r
+#include <avr/io.h>\r
+#include <avr/eeprom.h>\r
+#include <avr/pgmspace.h>\r
+\r
+/* References to the binary EEPROM data linked in the AVR's FLASH memory space */\r
+extern const char _binary_InputEEData_bin_start[];\r
+extern const char _binary_InputEEData_bin_end[];\r
+extern const char _binary_InputEEData_bin_size[];\r
+\r
+/* Friendly names for the embedded binary data stored in FLASH memory space */\r
+#define InputEEData _binary_InputEEData_bin_start\r
+#define InputEEData_size ((int)_binary_InputEEData_bin_size)\r
+\r
+int main(void)\r
+{\r
+ /* Copy out the embedded EEPROM data from FLASH to EEPROM memory space */\r
+ for (uint16_t i = 0; i < InputEEData_size; i++)\r
+ eeprom_update_byte((uint8_t*)i, pgm_read_byte(&InputEEData[i]));\r
+\r
+ /* Infinite loop once complete */\r
+ for (;;);\r
+}\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2012.\r
+#\r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.lufa-lib.org\r
+#\r
+# --------------------------------------\r
+# LUFA Project Makefile.\r
+# --------------------------------------\r
+\r
+MCU = at90usb1287\r
+ARCH = AVR8\r
+F_CPU = 1000000\r
+F_USB = $(F_CPU)\r
+OPTIMIZATION = s\r
+TARGET = HID_EEPROM_Loader\r
+SRC = $(TARGET).c\r
+LUFA_PATH = ../../../LUFA\r
+CC_FLAGS = \r
+LD_FLAGS =\r
+OBJECT_FILES = InputEEData.o\r
+\r
+# Default target\r
+all:\r
+\r
+# Determine the AVR sub-architecture of the build main application object file\r
+FIND_AVR_SUBARCH = avr$(shell avr-objdump -f $(TARGET).o | grep architecture | cut -d':' -f3 | cut -d',' -f1)\r
+\r
+# Create a linkable object file with the input binary EEPROM data stored in the FLASH section\r
+InputEEData.o: InputEEData.bin $(TARGET).o $(MAKEFILE_LIST)\r
+ @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a object file \"$@\"\r
+ avr-objcopy -I binary -O elf32-avr -B $(call FIND_AVR_SUBARCH) --rename-section .data=.progmem.data,contents,alloc,readonly,data $< $@\r
+\r
+# Include LUFA build script makefiles\r
+include $(LUFA_PATH)/Build/lufa_core.mk\r
+include $(LUFA_PATH)/Build/lufa_build.mk\r
+include $(LUFA_PATH)/Build/lufa_cppcheck.mk\r
+include $(LUFA_PATH)/Build/lufa_doxygen.mk\r
+include $(LUFA_PATH)/Build/lufa_hid.mk\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2012.\r
+#\r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.lufa-lib.org\r
+#\r
+\r
+LUFA_BUILD_MODULES += ATPROGRAM\r
+LUFA_BUILD_TARGETS += atprogram atprogram-ee\r
+LUFA_BUILD_MANDATORY_VARS += MCU TARGET\r
+LUFA_BUILD_OPTIONAL_VARS += ATPROGRAM_PROGRAMMER ATPROGRAM_INTERFACE ATPROGRAM_PORT\r
+LUFA_BUILD_PROVIDED_VARS += \r
+LUFA_BUILD_PROVIDED_MACROS += \r
+\r
+# -----------------------------------------------------------------------------\r
+# LUFA ATPROGRAM Programmer Buildsystem Makefile Module.\r
+# -----------------------------------------------------------------------------\r
+# DESCRIPTION:\r
+# Provides a set of targets to re-program a device using the Atmel atprogram\r
+# utility in AVR Studio 5.x and Atmel Studio 6.0 onwards.\r
+# -----------------------------------------------------------------------------\r
+# TARGETS:\r
+#\r
+# atprogram - Program target FLASH with application using\r
+# atprogram\r
+# atprogram-ee - Program target EEPROM with application data\r
+# using atprogram\r
+#\r
+# MANDATORY PARAMETERS:\r
+#\r
+# MCU - Microcontroller device model name\r
+# TARGET - Application name\r
+#\r
+# OPTIONAL PARAMETERS:\r
+#\r
+# ATPROGRAM_PROGRAMMER - Name of programming hardware to use\r
+# ATPROGRAM_INTERFACE - Name of programming interface to use\r
+# ATPROGRAM_PORT - Name of communication port to use\r
+#\r
+# PROVIDED VARIABLES:\r
+#\r
+# (None)\r
+#\r
+# PROVIDED MACROS:\r
+#\r
+# (None)\r
+#\r
+# -----------------------------------------------------------------------------\r
+\r
+SHELL = /bin/sh\r
+\r
+ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))\r
+ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))\r
+ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))\r
+\r
+# Default values of optionally user-supplied variables\r
+ATPROGRAM_PROGRAMMER ?= jtagice3\r
+ATPROGRAM_INTERFACE ?= jtag\r
+ATPROGRAM_PORT ?= \r
+\r
+# Sanity check user supplied values\r
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))\r
+$(call ERROR_IF_EMPTY, MCU)\r
+$(call ERROR_IF_EMPTY, TARGET)\r
+$(call ERROR_IF_EMPTY, ATPROGRAM_PROGRAMMER)\r
+$(call ERROR_IF_EMPTY, ATPROGRAM_INTERFACE)\r
+\r
+# Output Messages\r
+MSG_ATPROGRAM_CMD := ' [ATPRGRM] :'\r
+\r
+# Construct base atprogram command flags\r
+BASE_ATPROGRAM_FLAGS := --tool $(ATPROGRAM_PROGRAMMER) --interface $(ATPROGRAM_INTERFACE) --device $(MCU)\r
+ifneq ($(ATPROGRAM_PORT),)\r
+ BASE_ATPROGRAM_FLAGS += --port $(ATPROGRAM_PORT)\r
+endif\r
+\r
+# Construct the flags to use for the various memory spaces\r
+ifeq ($(ARCH), AVR8)\r
+ ATPROGRAM_FLASH_FLAGS := --chiperase --flash\r
+ ATPROGRAM_EEPROM_FLAGS := --eeprom\r
+else ifeq ($(ARCH), XMEGA)\r
+ ATPROGRAM_FLASH_FLAGS := --erase --flash\r
+ ATPROGRAM_EEPROM_FLAGS := --eeprom\r
+else ifeq ($(ARCH), UC3)\r
+ ATPROGRAM_FLASH_FLAGS := --erase\r
+ ATPROGRAM_EEPROM_FLAGS := --eeprom\r
+else\r
+ $(error Unsupported architecture "$(ARCH)")\r
+endif\r
+\r
+atprogram: $(TARGET).elf $(MAKEFILE_LIST)\r
+ @echo $(MSG_ATPROGRAM_CMD) Programming device \"$(MCU)\" FLASH using \"$(ATPROGRAM_PROGRAMMER)\"\r
+ atprogram $(BASE_ATPROGRAM_FLAGS) program $(ATPROGRAM_FLASH_FLAGS) --file $<\r
+\r
+atprogram-ee: $(TARGET).elf $(MAKEFILE_LIST)\r
+ @echo $(MSG_ATPROGRAM_CMD) Programming device \"$(MCU)\" EEPROM using \"$(ATPROGRAM_PROGRAMMER)\"\r
+ atprogram $(BASE_ATPROGRAM_FLAGS) program $(ATPROGRAM_EEPROM_FLAGS) --file $<\r
+ \r
+# Phony build targets for this module\r
+.PHONY: atprogram atprogram-ee\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2012.\r
+#\r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.lufa-lib.org\r
+#\r
+\r
+LUFA_BUILD_MODULES += AVRDUDE\r
+LUFA_BUILD_TARGETS += avrdude avrdude-ee\r
+LUFA_BUILD_MANDATORY_VARS += MCU TARGET\r
+LUFA_BUILD_OPTIONAL_VARS += AVRDUDE_PROGRAMMER AVRDUDE_PORT AVRDUDE_FLAGS\r
+LUFA_BUILD_PROVIDED_VARS += \r
+LUFA_BUILD_PROVIDED_MACROS += \r
+\r
+# -----------------------------------------------------------------------------\r
+# LUFA AVRDUDE Programmer Buildsystem Makefile Module.\r
+# -----------------------------------------------------------------------------\r
+# DESCRIPTION:\r
+# Provides a set of targets to re-program a device using the open source\r
+# avr-dude utility.\r
+# -----------------------------------------------------------------------------\r
+# TARGETS:\r
+#\r
+# avrdude - Program target FLASH with application using\r
+# avrdude\r
+# avrdude-ee - Program target EEPROM with application data\r
+# using avrdude\r
+#\r
+# MANDATORY PARAMETERS:\r
+#\r
+# MCU - Microcontroller device model name\r
+# TARGET - Application name\r
+#\r
+# OPTIONAL PARAMETERS:\r
+#\r
+# AVRDUDE_PROGRAMMER - Name of programming hardware to use\r
+# AVRDUDE_PORT - Name of communication port to use\r
+# AVRDUDE_FLAGS - Flags to pass to avr-dude\r
+#\r
+# PROVIDED VARIABLES:\r
+#\r
+# (None)\r
+#\r
+# PROVIDED MACROS:\r
+#\r
+# (None)\r
+#\r
+# -----------------------------------------------------------------------------\r
+\r
+SHELL = /bin/sh\r
+\r
+ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))\r
+ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))\r
+ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))\r
+\r
+# Default values of optionally user-supplied variables\r
+AVRDUDE_PROGRAMMER ?= jtagicemkii\r
+AVRDUDE_PORT ?= usb\r
+AVRDUDE_FLAGS ?= \r
+\r
+# Sanity check user supplied values\r
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))\r
+$(call ERROR_IF_EMPTY, MCU)\r
+$(call ERROR_IF_EMPTY, TARGET)\r
+$(call ERROR_IF_EMPTY, AVRDUDE_PROGRAMMER)\r
+$(call ERROR_IF_EMPTY, AVRDUDE_PORT)\r
+\r
+# Output Messages\r
+MSG_AVRDUDE_CMD := ' [AVRDUDE] :'\r
+\r
+# Construct base avrdude command flags\r
+BASE_AVRDUDE_FLAGS := -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)\r
+\r
+avrdude: $(TARGET).hex $(MAKEFILE_LIST)\r
+ @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" FLASH with settings \"$(AVRDUDE_FLASH_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"\r
+ avrdude $(BASE_AVRDUDE_FLAGS) -U flash:w:$< $(AVRDUDE_FLAGS)\r
+\r
+avrdude-ee: $(TARGET).eep $(MAKEFILE_LIST)\r
+ @echo $(MSG_AVRDUDE_CMD) Programming device \"$(MCU)\" EEPROM with settings \"$(AVRDUDE_EEP_FLAGS)\" using \"$(AVRDUDE_PROGRAMMER)\" on port \"$(AVRDUDE_PORT)\"\r
+ avrdude $(BASE_AVRDUDE_FLAGS) -U eeprom:w:$< $(AVRDUDE_FLAGS)\r
+\r
+# Phony build targets for this module\r
+.PHONY: avrdude avrdude-ee\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2012.\r
+#\r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.lufa-lib.org\r
+#\r
+\r
+LUFA_BUILD_MODULES += BUILD\r
+LUFA_BUILD_TARGETS += size check-source symbol-sizes all lib elf hex lss clean mostlyclean\r
+LUFA_BUILD_MANDATORY_VARS += TARGET ARCH MCU SRC F_USB LUFA_PATH\r
+LUFA_BUILD_OPTIONAL_VARS += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS OBJDIR OBJECT_FILES DEBUG_TYPE DEBUG_LEVEL\r
+LUFA_BUILD_PROVIDED_VARS += \r
+LUFA_BUILD_PROVIDED_MACROS += \r
+\r
+# -----------------------------------------------------------------------------\r
+# LUFA GCC Compiler Buildsystem Makefile Module.\r
+# -----------------------------------------------------------------------------\r
+# DESCRIPTION:\r
+# Provides a set of targets to build a C, C++ and/or Assembly application\r
+# via the AVR-GCC compiler.\r
+# -----------------------------------------------------------------------------\r
+# TARGETS:\r
+#\r
+# size - List built application size\r
+# symbol-sizes - Print application symbols from the binary ELF\r
+# file as a list sorted by size in bytes\r
+# check-source - Print a list of SRC source files that cannot\r
+# be found\r
+# all - Build application and list size\r
+# lib - Build and archive source files into a library\r
+# elf - Build application ELF debug object file\r
+# hex - Build application HEX object files\r
+# lss - Build application LSS assembly listing file\r
+# clean - Remove all project intermediatary and binary\r
+# output files\r
+# mostlyclean - Remove intermediatary output files, but\r
+# preserve binaries\r
+#\r
+# MANDATORY PARAMETERS:\r
+#\r
+# TARGET - Application name\r
+# ARCH - Device architecture name\r
+# MCU - Microcontroller device model name\r
+# SRC - List of input source files (*.c, *.cpp, *.S)\r
+# F_USB - Speed of the input clock of the USB controller\r
+# in Hz\r
+# LUFA_PATH - Path to the LUFA library core\r
+#\r
+# OPTIONAL PARAMETERS:\r
+#\r
+# BOARD - LUFA board hardware\r
+# OPTIMIZATION - Optimization level\r
+# C_STANDARD - C Language Standard to use\r
+# CPP_STANDARD - C++ Language Standard to use\r
+# F_CPU - Speed of the CPU, in Hz\r
+# C_FLAGS - Flags to pass to the C compiler only\r
+# CPP_FLAGS - Flags to pass to the C++ compiler only\r
+# ASM_FLAGS - Flags to pass to the assembler only\r
+# CC_FLAGS - Common flags to pass to the C/C++ compiler and\r
+# assembler\r
+# LD_FLAGS - Flags to pass to the linker\r
+# OBJDIR - Directory for the output object and dependency\r
+# files; if equal to ".", the output files will\r
+# be generated in the same folder as the sources\r
+# OBJECT_FILES - Extra object files to link in to the binaries\r
+# DEBUG_FORMAT - Format of the debugging information to\r
+# generate in the compiled object files\r
+# DEBUG_LEVEL - Level the debugging information to generate in\r
+# the compiled object files\r
+#\r
+# PROVIDED VARIABLES:\r
+#\r
+# (None)\r
+#\r
+# PROVIDED MACROS:\r
+#\r
+# (None)\r
+#\r
+# -----------------------------------------------------------------------------\r
+\r
+SHELL = /bin/sh\r
+\r
+ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))\r
+ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))\r
+ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))\r
+\r
+# Default values of optionally user-supplied variables\r
+BOARD ?= NONE\r
+OPTIMIZATION ?= s\r
+F_CPU ?=\r
+C_STANDARD ?= gnu99\r
+CPP_STANDARD ?= gnu++98\r
+C_FLAGS ?=\r
+CPP_FLAGS ?=\r
+ASM_FLAGS ?=\r
+CC_FLAGS ?=\r
+OBJDIR ?= .\r
+OBJECT_FILES ?=\r
+DEBUG_FORMAT ?= dwarf-2\r
+DEBUG_LEVEL ?= 3\r
+\r
+# Sanity check user supplied values\r
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))\r
+$(call ERROR_IF_EMPTY, MCU)\r
+$(call ERROR_IF_EMPTY, TARGET)\r
+$(call ERROR_IF_EMPTY, ARCH)\r
+$(call ERROR_IF_EMPTY, F_USB)\r
+$(call ERROR_IF_EMPTY, LUFA_PATH)\r
+$(call ERROR_IF_EMPTY, BOARD)\r
+$(call ERROR_IF_EMPTY, OPTIMIZATION)\r
+$(call ERROR_IF_EMPTY, C_STANDARD)\r
+$(call ERROR_IF_EMPTY, CPP_STANDARD)\r
+$(call ERROR_IF_EMPTY, OBJDIR)\r
+$(call ERROR_IF_EMPTY, DEBUG_FORMAT)\r
+$(call ERROR_IF_EMPTY, DEBUG_LEVEL)\r
+\r
+# Determine the utility prefix to use for the selected architecture\r
+ifeq ($(ARCH), AVR8)\r
+ CROSS := avr\r
+else ifeq ($(ARCH), XMEGA)\r
+ CROSS := avr\r
+ $(warning The XMEGA device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.)\r
+else ifeq ($(ARCH), UC3)\r
+ CROSS := avr32\r
+ $(warning The UC3 device support is currently EXPERIMENTAL (incomplete and/or non-functional), and is included for preview purposes only.)\r
+else\r
+ $(error Unsupported architecture "$(ARCH)")\r
+endif\r
+\r
+# Output Messages\r
+MSG_COMPILE_CMD := ' [GCC] :'\r
+MSG_ASSEMBLE_CMD := ' [GAS] :'\r
+MSG_NM_CMD := ' [NM] :'\r
+MSG_REMOVE_CMD := ' [RM] :'\r
+MSG_LINK_CMD := ' [LNK] :'\r
+MSG_ARCHIVE_CMD := ' [AR] :'\r
+MSG_SIZE_CMD := ' [SIZE] :'\r
+MSG_OBJCPY_CMD := ' [OBJCPY] :'\r
+MSG_OBJDMP_CMD := ' [OBJDMP] :'\r
+\r
+# Convert input source file list to differentiate them by type\r
+C_SOURCE := $(filter %.c, $(SRC))\r
+CPP_SOURCE := $(filter %.cpp, $(SRC))\r
+ASM_SOURCE := $(filter %.S, $(SRC))\r
+\r
+# Create a list of unknown source file types, if any are found throw an error\r
+UNKNOWN_SOURCE := $(filter-out $(C_SOURCE) $(CPP_SOURCE) $(ASM_SOURCE), $(SRC))\r
+ifneq ($(UNKNOWN_SOURCE),)\r
+ $(error Unknown input source file formats: $(UNKNOWN_SOURCE))\r
+endif\r
+\r
+# Convert input source filenames into a list of required output object files\r
+OBJECT_FILES += $(addsuffix .o, $(basename $(SRC)))\r
+ifneq ($(OBJDIR),.)\r
+ $(shell mkdir $(OBJDIR) 2> /dev/null) \r
+ VPATH += $(dir $(SRC))\r
+ OBJECT_FILES := $(addprefix $(patsubst %/,%,$(OBJDIR))/, $(notdir $(OBJECT_FILES)))\r
+ \r
+ # Check if any object file (without path) appears more than once in the object file list\r
+ ifneq ($(words $(sort $(OBJECT_FILES))), $(words $(OBJECT_FILES)))\r
+ $(error Cannot build with OBJDIR parameter set - one or more object file name is not unique)\r
+ endif\r
+endif\r
+\r
+# Create a list of dependency files from the list of object files\r
+DEPENDENCY_FILES := $(OBJECT_FILES:%.o=%.d)\r
+\r
+# Create a list of common flags to pass to the compiler/linker/assembler\r
+BASE_CC_FLAGS := -pipe -g$(DEBUG_FORMAT) -g$(DEBUG_LEVEL)\r
+ifeq ($(ARCH), AVR8)\r
+ BASE_CC_FLAGS += -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions -fpack-struct\r
+else ifeq ($(ARCH), XMEGA)\r
+ BASE_CC_FLAGS += -mmcu=$(MCU) -fshort-enums -fno-inline-small-functions -fpack-struct\r
+else ifeq ($(ARCH), UC3)\r
+ BASE_CC_FLAGS += -mpart=$(MCU:at32%=%) -masm-addr-pseudos\r
+endif\r
+BASE_CC_FLAGS += -Wall -fno-strict-aliasing -funsigned-char -funsigned-bitfields -ffunction-sections\r
+BASE_CC_FLAGS += -I. -I$(patsubst %/,%,$(LUFA_PATH))/..\r
+BASE_CC_FLAGS += -DARCH=ARCH_$(ARCH) -DBOARD=BOARD_$(BOARD) -DF_USB=$(F_USB)UL\r
+ifneq ($(F_CPU),)\r
+ BASE_CC_FLAGS += -DF_CPU=$(F_CPU)UL\r
+endif\r
+\r
+# Additional language specific compiler flags\r
+BASE_C_FLAGS := -x c -O$(OPTIMIZATION) -std=$(C_STANDARD) -Wstrict-prototypes\r
+BASE_CPP_FLAGS := -x c++ -O$(OPTIMIZATION) -std=$(CPP_STANDARD)\r
+BASE_ASM_FLAGS := -x assembler-with-cpp\r
+\r
+# Create a list of flags to pass to the linker\r
+BASE_LD_FLAGS := -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections -Wl,--relax \r
+ifeq ($(ARCH), AVR8)\r
+ BASE_LD_FLAGS += -mmcu=$(MCU)\r
+else ifeq ($(ARCH), XMEGA)\r
+ BASE_LD_FLAGS += -mmcu=$(MCU)\r
+else ifeq ($(ARCH), UC3)\r
+ BASE_LD_FLAGS += -mpart=$(MCU:at32%=%) --rodata-writable --direct-data\r
+endif\r
+\r
+# Determine flags to pass to the size utility based on its reported features (only invoke if size target required)\r
+size: SIZE_MCU_FLAG := $(shell $(CROSS)-size --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) )\r
+size: SIZE_FORMAT_FLAG := $(shell $(CROSS)-size --help | grep -- --format=.*avr > /dev/null && echo --format=avr )\r
+\r
+\r
+build_begin:\r
+ @echo ""\r
+ @echo Begin compilation of project \"$(TARGET)\"...\r
+ @echo ""\r
+ \r
+build_end:\r
+ @echo Finished building project \"$(TARGET)\".\r
+ @echo ""\r
+\r
+gcc-version:\r
+ @$(CROSS)-gcc --version\r
+\r
+check-source:\r
+ @for f in $(SRC); do \\r
+ if [ ! -f $$f ]; then \\r
+ echo "Error: Source file not found: $$f"; \\r
+ exit 1; \\r
+ fi; \\r
+ done\r
+\r
+size: $(TARGET).elf\r
+ @echo $(MSG_SIZE_CMD) Determining size of \"$<\"\r
+ @echo ""\r
+ $(CROSS)-size $(SIZE_MCU_FLAG) $(SIZE_FORMAT_FLAG) $< ; 2>/dev/null;\r
+\r
+symbol-sizes: $(TARGET).elf\r
+ @echo $(MSG_NM_CMD) Extracting \"$<\" symbols with decimal byte sizes\r
+ $(CROSS)-nm --size-sort --demangle --radix=d $<\r
+\r
+mostlyclean:\r
+ @echo $(MSG_REMOVE_CMD) Removing object files of \"$(TARGET)\"\r
+ rm -f $(OBJECT_FILES)\r
+ @echo $(MSG_REMOVE_CMD) Removing dependency files of \"$(TARGET)\"\r
+ rm -f $(DEPENDENCY_FILES)\r
+\r
+clean: mostlyclean\r
+ @echo $(MSG_REMOVE_CMD) Removing output files of \"$(TARGET)\"\r
+ rm -f $(TARGET).elf $(TARGET).hex $(TARGET).eep $(TARGET).map $(TARGET).lss $(TARGET).sym $(TARGET).a\r
+\r
+all: build_begin check-source gcc-version elf hex lss sym size build_end\r
+\r
+lib: lib$(TARGET).a\r
+elf: $(TARGET).elf\r
+hex: $(TARGET).hex $(TARGET).eep\r
+lss: $(TARGET).lss\r
+sym: $(TARGET).sym\r
+\r
+$(OBJDIR)/%.o: %.c $(MAKEFILE_LIST)\r
+ @echo $(MSG_COMPILE_CMD) Compiling C file \"$(notdir $<)\"\r
+ $(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_C_FLAGS) $(CC_FLAGS) $(C_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@\r
+\r
+$(OBJDIR)/%.o: %.cpp $(MAKEFILE_LIST)\r
+ @echo $(MSG_COMPILE_CMD) Compiling C++ file \"$(notdir $<)\"\r
+ $(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_CPP_FLAGS) $(CC_FLAGS) $(CPP_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@\r
+ \r
+$(OBJDIR)/%.o: %.S $(MAKEFILE_LIST)\r
+ @echo $(MSG_ASSEMBLE_CMD) Assembling \"$(notdir $<)\"\r
+ $(CROSS)-gcc -c $(BASE_CC_FLAGS) $(BASE_ASM_FLAGS) $(CC_FLAGS) $(ASM_FLAGS) -MMD -MP -MF $(@:%.o=%.d) $< -o $@\r
+\r
+.PRECIOUS : $(OBJECT_FILES)\r
+.SECONDARY : %.a\r
+%.a: $(OBJECT_FILES)\r
+ @echo $(MSG_ARCHIVE_CMD) Archiving object files into \"$@\"\r
+ $(CROSS)-ar rcs $@ $(OBJECT_FILES)\r
+\r
+.PRECIOUS : $(OBJECT_FILES)\r
+.SECONDARY : %.elf\r
+%.elf: $(OBJECT_FILES)\r
+ @echo $(MSG_LINK_CMD) Linking object files into \"$@\"\r
+ $(CROSS)-gcc $(BASE_LD_FLAGS) $(LD_FLAGS) $^ -o $@\r
+\r
+%.hex: %.elf\r
+ @echo $(MSG_OBJCPY_CMD) Extracting HEX file data from \"$<\"\r
+ $(CROSS)-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@\r
+\r
+%.eep: %.elf\r
+ @echo $(MSG_OBJCPY_CMD) Extracting EEP file data from \"$<\"\r
+ $(CROSS)-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ihex $< $@ || exit 0\r
+\r
+%.lss: %.elf\r
+ @echo $(MSG_OBJDMP_CMD) Extracting LSS file data from \"$<\"\r
+ $(CROSS)-objdump -h -S -z $< > $@\r
+\r
+%.sym: %.elf\r
+ @echo $(MSG_NM_CMD) Extracting SYM file data from \"$<\"\r
+ $(CROSS)-nm -n $< > $@\r
+\r
+# Include build dependency files\r
+-include $(DEPENDENCY_FILES)\r
+\r
+# Phony build targets for this module\r
+.PHONY: build_begin build_end gcc-version check-source size symbol-sizes lib elf hex lss clean mostlyclean\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2012.\r
+#\r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.lufa-lib.org\r
+#\r
+\r
+LUFA_BUILD_MODULES += CORE\r
+LUFA_BUILD_TARGETS += help list_targets list_modules list_mandatory list_optional list_provided list_macros\r
+LUFA_BUILD_MANDATORY_VARS += \r
+LUFA_BUILD_OPTIONAL_VARS += \r
+LUFA_BUILD_PROVIDED_VARS += \r
+LUFA_BUILD_PROVIDED_MACROS += \r
+\r
+# -----------------------------------------------------------------------------\r
+# LUFA Core Build System Makefile Module.\r
+# -----------------------------------------------------------------------------\r
+# DESCRIPTION:\r
+# Provides a set of core build targets for the LUFA build system\r
+# -----------------------------------------------------------------------------\r
+# TARGETS:\r
+#\r
+# help - Build system help\r
+# list_targets - List all build targets\r
+# list_modules - List all build modules\r
+# list_mandatory - List all mandatory make variables required by\r
+# the included build modules of the application\r
+# list_optional - List all optional make variables required by\r
+# the included build modules of the application\r
+# list_provided - List all provided make variables from the\r
+# included build modules of the application\r
+# list_macros - List all provided make macros from the\r
+# included build modules of the application\r
+#\r
+# MANDATORY PARAMETERS:\r
+#\r
+# (None)\r
+#\r
+# OPTIONAL PARAMETERS:\r
+#\r
+# (None)\r
+#\r
+# PROVIDED VARIABLES:\r
+#\r
+# (None)\r
+#\r
+# PROVIDED MACROS:\r
+#\r
+# (None)\r
+#\r
+# -----------------------------------------------------------------------------\r
+\r
+SHELL = /bin/sh\r
+\r
+# Build sorted and filtered lists of the included build module data\r
+SORTED_LUFA_BUILD_MODULES = $(sort $(LUFA_BUILD_MODULES))\r
+SORTED_LUFA_BUILD_TARGETS = $(sort $(LUFA_BUILD_TARGETS))\r
+SORTED_LUFA_MANDATORY_VARS = $(sort $(LUFA_BUILD_MANDATORY_VARS))\r
+SORTED_LUFA_OPTIONAL_VARS = $(filter-out $(SORTED_LUFA_MANDATORY_VARS), $(sort $(LUFA_BUILD_OPTIONAL_VARS)))\r
+SORTED_LUFA_PROVIDED_VARS = $(sort $(LUFA_BUILD_PROVIDED_VARS))\r
+SORTED_LUFA_PROVIDED_MACROS = $(sort $(LUFA_BUILD_PROVIDED_MACROS))\r
+\r
+# Create printable versions of the sorted build module data (use "(None)" when no data is available)\r
+PRINTABLE_LUFA_BUILD_MODULES = $(if $(strip $(SORTED_LUFA_BUILD_MODULES)), $(SORTED_LUFA_BUILD_MODULES), (None))\r
+PRINTABLE_LUFA_BUILD_TARGETS = $(if $(strip $(SORTED_LUFA_BUILD_TARGETS)), $(SORTED_LUFA_BUILD_TARGETS), (None))\r
+PRINTABLE_LUFA_MANDATORY_VARS = $(if $(strip $(SORTED_LUFA_MANDATORY_VARS)), $(SORTED_LUFA_MANDATORY_VARS), (None))\r
+PRINTABLE_LUFA_OPTIONAL_VARS = $(if $(strip $(SORTED_LUFA_OPTIONAL_VARS)), $(SORTED_LUFA_OPTIONAL_VARS), (None))\r
+PRINTABLE_LUFA_PROVIDED_VARS = $(if $(strip $(SORTED_LUFA_PROVIDED_VARS)), $(SORTED_LUFA_PROVIDED_VARS), (None))\r
+PRINTABLE_LUFA_PROVIDED_MACROS = $(if $(strip $(SORTED_LUFA_PROVIDED_MACROS)), $(SORTED_LUFA_PROVIDED_MACROS), (None))\r
+\r
+help:\r
+ @echo "==================================================================="\r
+ @echo " LUFA Build System 2.0 "\r
+ @echo " (C) Dean Camera, 2012 { dean @ fourwalledcubicle . com } "\r
+ @echo "==================================================================="\r
+ @echo "DESCRIPTION: "\r
+ @echo " This build system is a set of makefile modules for (GNU) Make, to "\r
+ @echo " provide a simple system for building LUFA powered applications. "\r
+ @echo " Each makefile module can be included from within a user makefile, "\r
+ @echo " to expose the build rules documented in the comments at the top of"\r
+ @echo " each build module. "\r
+ @echo " "\r
+ @echo "USAGE: " \r
+ @echo " To execute a rule, define all variables indicated in the desired "\r
+ @echo " module as a required parameter before including the build module "\r
+ @echo " in your project makefile. Parameters marked as optional will "\r
+ @echo " assume a default value in the modules if not user-assigned. "\r
+ @echo " "\r
+ @echo " By default the target output shows both a friendly summary, as "\r
+ @echo " well as the actual invoked command. To suppress the output of the "\r
+ @echo " invoked commands and show only the friendly command output, run "\r
+ @echo " make with the \"-s\" switch added before the target(s). " \r
+ @echo "==================================================================="\r
+ @echo " "\r
+ @echo " Currently used build system modules in this application: "\r
+ @echo " "\r
+ @printf " %b" "$(PRINTABLE_LUFA_BUILD_MODULES:%= - %\n)"\r
+ @echo " "\r
+ @echo " "\r
+ @echo " Currently available build targets in this application: "\r
+ @echo " "\r
+ @printf " %b" "$(PRINTABLE_LUFA_BUILD_TARGETS:%= - %\n)"\r
+ @echo " "\r
+ @echo " "\r
+ @echo " Mandatory variables required by the selected build Modules: "\r
+ @echo " "\r
+ @printf " %b" "$(PRINTABLE_LUFA_MANDATORY_VARS:%= - %\n)"\r
+ @echo " "\r
+ @echo " "\r
+ @echo " Optional variables required by the selected build Modules: "\r
+ @echo " "\r
+ @printf " %b" "$(PRINTABLE_LUFA_OPTIONAL_VARS:%= - %\n)"\r
+ @echo " "\r
+ @echo " "\r
+ @echo " Variables provided by the selected build Modules: "\r
+ @echo " "\r
+ @printf " %b" "$(PRINTABLE_LUFA_PROVIDED_VARS:%= - %\n)"\r
+ @echo " "\r
+ @echo " "\r
+ @echo " Macros provided by the selected build Modules: "\r
+ @echo " "\r
+ @printf " %b" "$(PRINTABLE_LUFA_PROVIDED_MACROS:%= - %\n)"\r
+ @echo " "\r
+ @echo "==================================================================="\r
+ @echo " The LUFA BuildSystem 2.0 - Powered By Unicorns (tm) "\r
+ @echo "==================================================================="\r
+ \r
+list_modules:\r
+ @echo Currently Used Build System Modules: $(PRINTABLE_LUFA_BUILD_MODULES)\r
+\r
+list_targets:\r
+ @echo Currently Available Build Targets: $(PRINTABLE_LUFA_BUILD_TARGETS) \r
+\r
+list_mandatory:\r
+ @echo Mandatory Variables for Included Modules: $(PRINTABLE_LUFA_MANDATORY_VARS)\r
+ \r
+list_optional:\r
+ @echo Optional Variables for Included Modules: $(PRINTABLE_LUFA_OPTIONAL_VARS)\r
+\r
+list_provided:\r
+ @echo Variables Provided by the Included Modules: $(PRINTABLE_LUFA_PROVIDED_VARS)\r
+\r
+list_macros:\r
+ @echo Macros Provided by the Included Modules: $(PRINTABLE_LUFA_PROVIDED_MACROS)\r
+\r
+# Disable default in-built make rules (those that are needed are explicitly\r
+# defined, and doing so has performance benefits when recursively building)\r
+.SUFFIXES:\r
+\r
+# Phony build targets for this module\r
+.PHONY: help list_modules list_targets list_mandatory list_optional list_provided list_macros\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2012.\r
+#\r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.lufa-lib.org\r
+#\r
+\r
+LUFA_BUILD_MODULES += CPPCHECK\r
+LUFA_BUILD_TARGETS += cppcheck cppcheck-config\r
+LUFA_BUILD_MANDATORY_VARS += SRC\r
+LUFA_BUILD_OPTIONAL_VARS += CPPCHECK_INCLUDES CPPCHECK_EXCLUDES CPPCHECK_MSG_TEMPLATE CPPCHECK_ENABLE \\r
+ CPPCHECK_SUPPRESS CPPCHECK_FAIL_ON_WARNING CPPCHECK_QUIET CPPCHECK_FLAGS\r
+LUFA_BUILD_PROVIDED_VARS += \r
+LUFA_BUILD_PROVIDED_MACROS += \r
+\r
+# -----------------------------------------------------------------------------\r
+# LUFA CPPCheck Buildsystem Makefile Module.\r
+# -----------------------------------------------------------------------------\r
+# DESCRIPTION:\r
+# Provides a set of targets to scan a project with the free "cppcheck" static\r
+# analysis tool, to check for code errors at runtime (see http://cppcheck.sourceforge.net).\r
+# -----------------------------------------------------------------------------\r
+# TARGETS:\r
+#\r
+# cppcheck - Scan the project with CPPCheck\r
+# cppcheck-config - Use CPPCheck to look for missing include files\r
+#\r
+# MANDATORY PARAMETERS:\r
+#\r
+# SRC - List of source files to statically analyze\r
+#\r
+# OPTIONAL PARAMETERS:\r
+#\r
+# CPPCHECK_INCLUDES - Extra include paths to search for missing\r
+# header files\r
+# CPPCHECK_EXCLUDES - Source file paths to exclude checking (can be\r
+# a path fragment if desired)\r
+# CPPCHECK_MSG_TEMPLATE - Template for cppcheck error and warning output\r
+# CPPCHECK_ENABLE - General cppcheck category checks to enable\r
+# CPPCHECK_SUPPRESS - Specific cppcheck warnings to disable by ID\r
+# CPPCHECK_FAIL_ON_WARNING - Set to Y to fail the build on cppcheck\r
+# warnings, N to continue even if warnings occur\r
+# CPPCHECK_QUIET - Enable cppcheck verbose or quiet output mode\r
+# CPPCHECK_FLAGS - Additional flags to pass to cppcheck\r
+#\r
+# PROVIDED VARIABLES:\r
+#\r
+# (None)\r
+#\r
+# PROVIDED MACROS:\r
+#\r
+# (None)\r
+#\r
+# -----------------------------------------------------------------------------\r
+\r
+SHELL = /bin/sh\r
+\r
+ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))\r
+ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))\r
+ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))\r
+\r
+# Default values of optionally user-supplied variables\r
+CPPCHECK_INCLUDES ?=\r
+CPPCHECK_EXCLUDES ?=\r
+CPPCHECK_MSG_TEMPLATE ?= {file}:{line}: {severity} ({id}): {message}\r
+CPPCHECK_ENABLE ?= all\r
+CPPCHECK_SUPPRESS ?= variableScope missingInclude\r
+CPPCHECK_FAIL_ON_WARNING ?= Y\r
+CPPCHECK_QUIET ?= Y\r
+CPPCHECK_FLAGS ?= \r
+\r
+# Sanity check user supplied values\r
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))\r
+$(call ERROR_IF_EMPTY, SRC)\r
+$(call ERROR_IF_EMPTY, CPPCHECK_MSG_TEMPLATE)\r
+$(call ERROR_IF_EMPTY, CPPCHECK_ENABLE)\r
+$(call ERROR_IF_NONBOOL, CPPCHECK_FAIL_ON_WARNING)\r
+$(call ERROR_IF_NONBOOL, CPPCHECK_QUIET)\r
+\r
+# Build a default argument list for cppcheck\r
+BASE_CPPCHECK_FLAGS := --template="$(CPPCHECK_MSG_TEMPLATE)" $(CPPCHECK_INCLUDES:%=-I%) $(CPPCHECK_EXCLUDES:%=-i%) --inline-suppr --force --std=c99\r
+\r
+# Sanity check parameters and construct additional command line arguments to cppcheck\r
+ifeq ($(CPPCHECK_FAIL_ON_WARNING), Y)\r
+ BASE_CPPCHECK_FLAGS += --error-exitcode=1\r
+endif\r
+ifeq ($(CPPCHECK_QUIET), Y)\r
+ BASE_CPPCHECK_FLAGS += --quiet\r
+endif\r
+\r
+# Output Messages\r
+MSG_CPPCHECK_CMD := ' [CPPCHECK]:'\r
+\r
+cppcheck-config:\r
+ @echo $(MSG_CPPCHECK_CMD) Checking cppcheck configuration check on source files\r
+ cppcheck $(BASE_CPPCHECK_FLAGS) --check-config $(CPPCHECK_FLAGS) $(SRC)\r
+\r
+cppcheck:\r
+ @echo $(MSG_CPPCHECK_CMD) Performing static analysis on source files\r
+ cppcheck $(BASE_CPPCHECK_FLAGS) --enable=$(CPPCHECK_ENABLE) $(CPPCHECK_SUPPRESS:%=--suppress=%) $(CPPCHECK_FLAGS) $(SRC)\r
+\r
+# Phony build targets for this module\r
+.PHONY: cppcheck-config cppcheck\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2012.\r
+#\r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.lufa-lib.org\r
+#\r
+\r
+LUFA_BUILD_MODULES += DFU\r
+LUFA_BUILD_TARGETS += flip flip-ee dfu dfu-ee\r
+LUFA_BUILD_MANDATORY_VARS += MCU TARGET\r
+LUFA_BUILD_OPTIONAL_VARS += \r
+LUFA_BUILD_PROVIDED_VARS += \r
+LUFA_BUILD_PROVIDED_MACROS += \r
+\r
+# -----------------------------------------------------------------------------\r
+# LUFA DFU Bootloader Buildsystem Makefile Module.\r
+# -----------------------------------------------------------------------------\r
+# DESCRIPTION:\r
+# Provides a set of targets to re-program a device currently running a DFU\r
+# class bootloader with a project's FLASH and EEPROM files.\r
+# -----------------------------------------------------------------------------\r
+# TARGETS:\r
+#\r
+# flip - Program FLASH into target via Atmel FLIP\r
+# flip-ee - Program EEPROM into target via Atmel FLIP\r
+# dfu - Program FLASH into target via dfu-programmer\r
+# dfu-ee - Program EEPROM into target via dfu-programmer\r
+#\r
+# MANDATORY PARAMETERS:\r
+#\r
+# MCU - Microcontroller device model name\r
+# TARGET - Application name\r
+#\r
+# OPTIONAL PARAMETERS:\r
+#\r
+# (None)\r
+#\r
+# PROVIDED VARIABLES:\r
+#\r
+# (None)\r
+#\r
+# PROVIDED MACROS:\r
+#\r
+# (None)\r
+#\r
+# -----------------------------------------------------------------------------\r
+\r
+SHELL = /bin/sh\r
+\r
+ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))\r
+ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))\r
+ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))\r
+\r
+# Sanity-check values of mandatory user-supplied variables\r
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))\r
+$(call ERROR_IF_EMPTY, MCU)\r
+$(call ERROR_IF_EMPTY, TARGET)\r
+\r
+# Output Messages\r
+MSG_COPY_CMD := ' [CP] :'\r
+MSG_REMOVE_CMD := ' [RM] :'\r
+MSG_DFU_CMD := ' [DFU] :'\r
+\r
+flip: $(TARGET).hex $(MAKEFILE_LIST)\r
+ @echo $(MSG_DFU_CMD) Programming FLASH with batchisp using \"$<\"\r
+ batchisp -hardware usb -device $(MCU) -operation erase f\r
+ batchisp -hardware usb -device $(MCU) -operation loadbuffer $< program\r
+ batchisp -hardware usb -device $(MCU) -operation start reset 0\r
+\r
+flip-ee: $(TARGET).eep $(MAKEFILE_LIST)\r
+ @echo $(MSG_DFU_CMD) Copying EEP file to temporary file \"$<.hex\"\r
+ cp $< $<.hex\r
+ @echo $(MSG_DFU_CMD) Programming EEPROM with batchisp using \"$<.hex\"\r
+ batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase\r
+ batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $<.hex program\r
+ batchisp -hardware usb -device $(MCU) -operation start reset 0\r
+ @echo $(MSG_DFU_CMD) Removing temporary file \"$<.hex\"\r
+ rm $<.hex\r
+ \r
+dfu: $(TARGET).hex $(MAKEFILE_LIST)\r
+ @echo $(MSG_DFU_CMD) Programming FLASH with dfu-programmer using \"$<\"\r
+ dfu-programmer $(MCU) erase\r
+ dfu-programmer $(MCU) flash $<\r
+ dfu-programmer $(MCU) reset\r
+\r
+dfu-ee: $(TARGET).eep $(MAKEFILE_LIST)\r
+ @echo $(MSG_DFU_CMD) Programming EEPROM with dfu-programmer using \"$<\"\r
+ dfu-programmer $(MCU) eeprom-flash $<\r
+ dfu-programmer $(MCU) reset\r
+ \r
+# Phony build targets for this module\r
+.PHONY: flip flip-ee dfu dfu-ee\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2012.\r
+#\r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.lufa-lib.org\r
+#\r
+\r
+LUFA_BUILD_MODULES += DOXYGEN\r
+LUFA_BUILD_TARGETS += doxygen\r
+LUFA_BUILD_MANDATORY_VARS += LUFA_PATH\r
+LUFA_BUILD_OPTIONAL_VARS += DOXYGEN_CONF DOXYGEN_FAIL_ON_WARNING DOXYGEN_OVERRIDE_PARAMS\r
+LUFA_BUILD_PROVIDED_VARS += \r
+LUFA_BUILD_PROVIDED_MACROS += \r
+\r
+# -----------------------------------------------------------------------------\r
+# LUFA Doxygen Buildsystem Makefile Module.\r
+# -----------------------------------------------------------------------------\r
+# DESCRIPTION:\r
+# Provides a set of targets to automatically build Doxygen documentation for\r
+# a project (see www.doxygen.org).\r
+# -----------------------------------------------------------------------------\r
+# TARGETS:\r
+#\r
+# doxygen - Build Doxygen Documentation\r
+#\r
+# MANDATORY PARAMETERS:\r
+#\r
+# LUFA_PATH - Path to the LUFA library core\r
+#\r
+# OPTIONAL PARAMETERS:\r
+#\r
+# DOXYGEN_CONF - Doxygen configuration filename\r
+# DOXYGEN_FAIL_ON_WARNING - Set to Y to fail the build on Doxygen warnings,\r
+# N to continue even if warnings occur\r
+# DOXYGEN_OVERRIDE_PARAMS - Parameters to override in the doxygen\r
+# configuration file\r
+# PROVIDED VARIABLES:\r
+#\r
+# (None)\r
+#\r
+# PROVIDED MACROS:\r
+#\r
+# (None)\r
+#\r
+# -----------------------------------------------------------------------------\r
+\r
+SHELL = /bin/sh\r
+\r
+ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))\r
+ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))\r
+ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))\r
+\r
+# Default values of optionally user-supplied variables\r
+DOXYGEN_CONF ?= Doxygen.conf\r
+DOXYGEN_FAIL_ON_WARNING ?= Y\r
+DOXYGEN_OVERRIDE_PARAMS ?= QUIET=YES HTML_STYLESHEET=$(patsubst %/,%,$(LUFA_PATH))/DoxygenPages/Style/Style.css\r
+\r
+# Sanity check user supplied values\r
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))\r
+$(call ERROR_IF_EMPTY, DOXYGEN_CONF)\r
+$(call ERROR_IF_EMPTY, LUFA_PATH)\r
+$(call ERROR_IF_NONBOOL, DOXYGEN_FAIL_ON_WARNING)\r
+\r
+# Output Messages\r
+MSG_DOXYGEN_CMD := ' [DOXYGEN] :'\r
+\r
+# Determine Doxygen invocation command\r
+BASE_DOXYGEN_CMD := ( cat $(DOXYGEN_CONF) $(DOXYGEN_OVERRIDE_PARAMS:%=; echo "%") ) | doxygen -\r
+ifeq ($(DOXYGEN_FAIL_ON_WARNING), Y)\r
+ DOXYGEN_CMD := if ( $(BASE_DOXYGEN_CMD) 2>&1 | grep -v "warning: ignoring unsupported tag" ;); then exit 1; fi;\r
+else\r
+ DOXYGEN_CMD := $(BASE_DOXYGEN_CMD)\r
+endif\r
+\r
+doxygen:\r
+ @echo $(MSG_DOXYGEN_CMD) Configuration file \"$(DOXYGEN_CONF)\" with parameters \"$(DOXYGEN_OVERRIDE_PARAMS)\"\r
+ $(DOXYGEN_CMD)\r
+\r
+# Phony build targets for this module\r
+.PHONY: doxygen\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2012.\r
+#\r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.lufa-lib.org\r
+#\r
+\r
+LUFA_BUILD_MODULES += HID\r
+LUFA_BUILD_TARGETS += hid hid-ee teensy teensy-ee\r
+LUFA_BUILD_MANDATORY_VARS += MCU TARGET\r
+LUFA_BUILD_OPTIONAL_VARS += \r
+LUFA_BUILD_PROVIDED_VARS += \r
+LUFA_BUILD_PROVIDED_MACROS += \r
+\r
+# -----------------------------------------------------------------------------\r
+# LUFA HID Bootloader Buildsystem Makefile Module.\r
+# -----------------------------------------------------------------------------\r
+# DESCRIPTION:\r
+# Provides a set of targets to re-program a device currently running a HID\r
+# class bootloader with a project's FLASH files.\r
+# -----------------------------------------------------------------------------\r
+# TARGETS:\r
+#\r
+# hid - Program FLASH into target via\r
+# hid_bootloader_cli\r
+# hid-ee - Program EEPROM into target via a temporary\r
+# AVR application and hid_bootloader_cli\r
+# teensy - Program FLASH into target via\r
+# teensy_loader_cli\r
+# teensy-ee - Program EEPROM into target via a temporary\r
+# AVR application and teensy_loader_cli\r
+#\r
+# MANDATORY PARAMETERS:\r
+#\r
+# MCU - Microcontroller device model name\r
+# TARGET - Application name\r
+#\r
+# OPTIONAL PARAMETERS:\r
+#\r
+# (None)\r
+#\r
+# PROVIDED VARIABLES:\r
+#\r
+# (None)\r
+#\r
+# PROVIDED MACROS:\r
+#\r
+# (None)\r
+#\r
+# -----------------------------------------------------------------------------\r
+\r
+ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))\r
+ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))\r
+ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))\r
+\r
+# Sanity-check values of mandatory user-supplied variables\r
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))\r
+$(call ERROR_IF_EMPTY, MCU)\r
+$(call ERROR_IF_EMPTY, TARGET)\r
+\r
+# Output Messages\r
+MSG_HID_BOOTLOADER_CMD := ' [HID] :'\r
+MSG_OBJCPY_CMD := ' [OBJCPY] :'\r
+MSG_MAKE_CMD := ' [MAKE] :'\r
+\r
+hid: $(TARGET).hex $(MAKEFILE_LIST)\r
+ @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with hid_bootloader_cli using \"$<\"\r
+ hid_bootloader_cli -mmcu=$(MCU) -v $<\r
+\r
+hid-ee: $(TARGET).eep $(MAKEFILE_LIST)\r
+ @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"\r
+ avr-objcopy -I ihex -O binary $< $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/InputEEData.bin\r
+ @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"\r
+ make -C $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/ MCU=$(MCU) clean hid\r
+\r
+teensy: $(TARGET).hex $(MAKEFILE_LIST)\r
+ @echo $(MSG_HID_BOOTLOADER_CMD) Programming FLASH with teensy_loader_cli using \"$<\"\r
+ teensy_loader_cli -mmcu=$(MCU) -v $<\r
+\r
+teensy-ee: $(TARGET).hex $(MAKEFILE_LIST)\r
+ @echo $(MSG_OBJCPY_CMD) Converting \"$<\" to a binary file \"InputEEData.bin\"\r
+ avr-objcopy -I ihex -O binary $< $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/InputEEData.bin\r
+ @echo $(MSG_MAKE_CMD) Making EEPROM loader application for \"$<\"\r
+ make -s -C $(patsubst %/,%,$(LUFA_PATH))/Build/HID_EEPROM_Loader/ MCU=$(MCU) clean hid-teensy\r
+ \r
+# Phony build targets for this module\r
+.PHONY: hid hid-ee teensy teensy-ee\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2012.\r
+#\r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.lufa-lib.org\r
+#\r
+\r
+LUFA_BUILD_MODULES += SOURCES\r
+LUFA_BUILD_TARGETS += \r
+LUFA_BUILD_MANDATORY_VARS += LUFA_PATH ARCH\r
+LUFA_BUILD_OPTIONAL_VARS += \r
+LUFA_BUILD_PROVIDED_VARS += LUFA_SRC_USB LUFA_SRC_USBCLASS LUFA_SRC_TEMPERATURE LUFA_SRC_SERIAL LUFA_SRC_TWI LUFA_SRC_PLATFORM\r
+LUFA_BUILD_PROVIDED_MACROS += \r
+\r
+# -----------------------------------------------------------------------------\r
+# LUFA Sources Buildsystem Makefile Module.\r
+# -----------------------------------------------------------------------------\r
+# DESCRIPTION:\r
+# Provides a set of makefile variables for the various LUFA module sources.\r
+# Once included, the sources required to use a given LUFA module will become\r
+# available using the makefile variable names listed in the LUFA project\r
+# documentation.\r
+# -----------------------------------------------------------------------------\r
+# TARGETS:\r
+#\r
+# (None)\r
+#\r
+# MANDATORY PARAMETERS:\r
+#\r
+# LUFA_PATH - Path to the LUFA library core\r
+# ARCH - Device architecture name\r
+#\r
+# OPTIONAL PARAMETERS:\r
+#\r
+# (None)\r
+#\r
+# PROVIDED VARIABLES:\r
+#\r
+# LUFA_SRC_USB - List of LUFA USB driver source files\r
+# LUFA_SRC_USBCLASS - List of LUFA USB Class driver source files\r
+# LUFA_SRC_TEMPERATURE - List of LUFA temperature sensor driver source\r
+# files\r
+# LUFA_SRC_SERIAL - List of LUFA Serial U(S)ART driver source files\r
+# LUFA_SRC_TWI - List of LUFA TWI driver source files\r
+# LUFA_SRC_PLATFORM - List of LUFA architecture specific platform\r
+# management source files\r
+#\r
+# PROVIDED MACROS:\r
+#\r
+# (None)\r
+#\r
+# -----------------------------------------------------------------------------\r
+\r
+SHELL = /bin/sh\r
+\r
+ERROR_IF_UNSET ?= $(if $(filter undefined, $(origin $(strip $(1)))), $(error Makefile $(strip $(1)) value not set))\r
+ERROR_IF_EMPTY ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $(1)) option cannot be blank))\r
+ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))\r
+\r
+# Sanity check user supplied values\r
+$(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))\r
+$(call ERROR_IF_EMPTY, LUFA_PATH)\r
+$(call ERROR_IF_EMPTY, ARCH)\r
+\r
+# Allow LUFA_ROOT_PATH to be overridden elsewhere to support legacy LUFA makefiles\r
+LUFA_ROOT_PATH ?= $(patsubst %/,%,$(LUFA_PATH))\r
+\r
+# Construct LUFA module source variables\r
+LUFA_SRC_USB := $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Device_$(ARCH).c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Endpoint_$(ARCH).c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Host_$(ARCH).c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/Pipe_$(ARCH).c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBController_$(ARCH).c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/USBInterrupt_$(ARCH).c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/EndpointStream_$(ARCH).c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/$(ARCH)/PipeStream_$(ARCH).c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/ConfigDescriptors.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/DeviceStandardReq.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/Events.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/HostStandardReq.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Core/USBTask.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Common/HIDParser.c\r
+LUFA_SRC_USBCLASS := $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/AudioClassDevice.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/CDCClassDevice.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/HIDClassDevice.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MassStorageClassDevice.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/MIDIClassDevice.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Device/RNDISClassDevice.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/AudioClassHost.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/CDCClassHost.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/HIDClassHost.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MassStorageClassHost.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/MIDIClassHost.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/PrinterClassHost.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/RNDISClassHost.c \\r
+ $(LUFA_ROOT_PATH)/Drivers/USB/Class/Host/StillImageClassHost.c\r
+LUFA_SRC_TEMPERATURE := $(LUFA_ROOT_PATH)/Drivers/Board/Temperature.c\r
+LUFA_SRC_SERIAL := $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/Serial_$(ARCH).c\r
+LUFA_SRC_TWI := $(LUFA_ROOT_PATH)/Drivers/Peripheral/$(ARCH)/TWI_$(ARCH).c\r
+\r
+ifeq ($(ARCH), UC3)\r
+ LUFA_SRC_PLATFORM := $(LUFA_ROOT_PATH)/Platform/UC3/Exception.S \\r
+ $(LUFA_ROOT_PATH)/Platform/UC3/InterruptManagement.c\r
+else\r
+ LUFA_SRC_PLATFORM :=\r
+endif\r
+\r
+# Build a list of all available module sources\r
+LUFA_SRC_ALL_FILES := $(LUFA_SRC_USB) \\r
+ $(LUFA_SRC_USBCLASS) \\r
+ $(LUFA_SRC_TEMPERATURE) \\r
+ $(LUFA_SRC_SERIAL) \\r
+ $(LUFA_SRC_TWI) \\r
+ $(LUFA_SRC_PLATFORM)\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief LUFA Custom Board Button Hardware Driver (Template)\r
+ *\r
+ * This is a stub driver header file, for implementing custom board\r
+ * layout hardware with compatible LUFA board specific drivers. If\r
+ * the library is configured to use the BOARD_USER board mode, this\r
+ * driver file should be completed and copied into the "/Board/" folder\r
+ * inside the application's folder.\r
+ *\r
+ * This stub is for the board-specific component of the LUFA Buttons driver,\r
+ * for the control of physical board-mounted GPIO pushbuttons.\r
+ */\r
+\r
+#ifndef __BUTTONS_USER_H__\r
+#define __BUTTONS_USER_H__\r
+\r
+ /* Includes: */\r
+ // TODO: Add any required includes here\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 // TODO: Add mask for first board button here\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ // TODO: Initialize the appropriate port pins as an inputs here, with pull-ups\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ // TODO: Clear the appropriate port pins as high impedance inputs here\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ // TODO: Return current button status here, debounced if required\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief LUFA Custom Board Dataflash Hardware Driver (Template)\r
+ *\r
+ * This is a stub driver header file, for implementing custom board\r
+ * layout hardware with compatible LUFA board specific drivers. If\r
+ * the library is configured to use the BOARD_USER board mode, this\r
+ * driver file should be completed and copied into the "/Board/" folder\r
+ * inside the application's folder.\r
+ *\r
+ * This stub is for the board-specific component of the LUFA Dataflash\r
+ * driver.\r
+*/\r
+\r
+#ifndef __DATAFLASH_USER_H__\r
+#define __DATAFLASH_USER_H__\r
+\r
+ /* Includes: */\r
+ // TODO: Add any required includes here\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_DATAFLASH_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATAFLASH_CHIPCS_MASK // TODO: Replace this with a mask of all the /CS pins of all Dataflashes\r
+ #define DATAFLASH_CHIPCS_DDR // TODO: Replace with the DDR register name for the board's Dataflash ICs\r
+ #define DATAFLASH_CHIPCS_PORT // TODO: Replace with the PORT register name for the board's Dataflash ICs\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */\r
+ #define DATAFLASH_TOTALCHIPS 1 // TODO: Replace with the number of Dataflashes on the board, max 2\r
+\r
+ /** Mask for no dataflash chip selected. */\r
+ #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK\r
+\r
+ /** Mask for the first dataflash chip selected. */\r
+ #define DATAFLASH_CHIP1 // TODO: Replace with mask to hold /CS of first Dataflash low, and all others high\r
+\r
+ /** Mask for the second dataflash chip selected. */\r
+ #define DATAFLASH_CHIP2 // TODO: Replace with mask to hold /CS of second Dataflash low, and all others high\r
+\r
+ /** Internal main memory page size for the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGE_SIZE // TODO: Replace with the page size for the Dataflash ICs\r
+\r
+ /** Total number of pages inside each of the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGES // TODO: Replace with the total number of pages inside one of the Dataflash ICs\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.\r
+ * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.\r
+ */\r
+ static inline void Dataflash_Init(void)\r
+ {\r
+ DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK;\r
+ DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)\r
+ {\r
+ // TODO\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ */\r
+ static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SendByte(const uint8_t Byte)\r
+ {\r
+ // TODO\r
+ }\r
+\r
+ /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_ReceiveByte(void)\r
+ {\r
+ // TODO\r
+ }\r
+\r
+ /** Determines the currently selected dataflash chip.\r
+ *\r
+ * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected\r
+ * or a DATAFLASH_CHIPn mask (where n is the chip number).\r
+ */\r
+ static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_GetSelectedChip(void)\r
+ {\r
+ return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK);\r
+ }\r
+\r
+ /** Selects the given dataflash chip.\r
+ *\r
+ * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is\r
+ * the chip number).\r
+ */\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask)\r
+ {\r
+ DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask);\r
+ }\r
+\r
+ /** Deselects the current dataflash chip, so that no dataflash is selected. */\r
+ static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_DeselectChip(void)\r
+ {\r
+ Dataflash_SelectChip(DATAFLASH_NO_CHIP);\r
+ }\r
+\r
+ /** Selects a dataflash IC from the given page number, which should range from 0 to\r
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one\r
+ * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside\r
+ * the total number of pages contained in the boards dataflash ICs, all dataflash ICs\r
+ * are deselected.\r
+ *\r
+ * \param[in] PageAddress Address of the page to manipulate, ranging from\r
+ * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).\r
+ */\r
+ static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)\r
+ {\r
+ Dataflash_DeselectChip();\r
+\r
+ if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS))\r
+ return;\r
+\r
+ #if (DATAFLASH_TOTALCHIPS == 2)\r
+ if (PageAddress & 0x01)\r
+ Dataflash_SelectChip(DATAFLASH_CHIP2);\r
+ else\r
+ Dataflash_SelectChip(DATAFLASH_CHIP1);\r
+ #else\r
+ Dataflash_SelectChip(DATAFLASH_CHIP1);\r
+ #endif\r
+ }\r
+\r
+ /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive\r
+ * a new command.\r
+ */\r
+ static inline void Dataflash_ToggleSelectedChipCS(void)\r
+ {\r
+ uint8_t SelectedChipMask = Dataflash_GetSelectedChip();\r
+\r
+ Dataflash_DeselectChip();\r
+ Dataflash_SelectChip(SelectedChipMask);\r
+ }\r
+\r
+ /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main\r
+ * memory page program or main memory to buffer transfer.\r
+ */\r
+ static inline void Dataflash_WaitWhileBusy(void)\r
+ {\r
+ Dataflash_ToggleSelectedChipCS();\r
+ Dataflash_SendByte(DF_CMD_GETSTATUS);\r
+ while (!(Dataflash_ReceiveByte() & DF_STATUS_READY));\r
+ Dataflash_ToggleSelectedChipCS();\r
+ }\r
+\r
+ /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with\r
+ * dataflash commands which require a complete 24-bit address.\r
+ *\r
+ * \param[in] PageAddress Page address within the selected dataflash IC\r
+ * \param[in] BufferByte Address within the dataflash's buffer\r
+ */\r
+ static inline void Dataflash_SendAddressBytes(uint16_t PageAddress, const uint16_t BufferByte)\r
+ {\r
+ #if (DATAFLASH_TOTALCHIPS == 2)\r
+ PageAddress >>= 1;\r
+ #endif\r
+\r
+ Dataflash_SendByte(PageAddress >> 5);\r
+ Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8));\r
+ Dataflash_SendByte(BufferByte);\r
+ }\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief LUFA Custom Board Joystick Hardware Driver (Template)\r
+ *\r
+ * This is a stub driver header file, for implementing custom board\r
+ * layout hardware with compatible LUFA board specific drivers. If\r
+ * the library is configured to use the BOARD_USER board mode, this\r
+ * driver file should be completed and copied into the "/Board/" folder\r
+ * inside the application's folder.\r
+ *\r
+ * This stub is for the board-specific component of the LUFA Joystick\r
+ * driver, for a digital four-way (plus button) joystick.\r
+*/\r
+\r
+#ifndef __JOYSTICK_USER_H__\r
+#define __JOYSTICK_USER_H__\r
+\r
+ /* Includes: */\r
+ // TODO: Add any required includes here\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_JOYSTICK_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the joystick being pushed in the left direction. */\r
+ #define JOY_LEFT // TODO: Add mask to indicate joystick left position here\r
+\r
+ /** Mask for the joystick being pushed in the right direction. */\r
+ #define JOY_RIGHT // TODO: Add mask to indicate joystick right position here\r
+\r
+ /** Mask for the joystick being pushed in the upward direction. */\r
+ #define JOY_UP // TODO: Add mask to indicate joystick up position here\r
+\r
+ /** Mask for the joystick being pushed in the downward direction. */\r
+ #define JOY_DOWN // TODO: Add mask to indicate joystick down position here\r
+\r
+ /** Mask for the joystick being pushed inward. */\r
+ #define JOY_PRESS // TODO: Add mask to indicate joystick pressed position here\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Joystick_Init(void)\r
+ {\r
+ // TODO: Initialize joystick port pins as inputs with pull-ups\r
+ }\r
+\r
+ static inline void Joystick_Disable(void)\r
+ {\r
+ // TODO: Clear the joystick pins as high impedance inputs here\r
+ }\r
+\r
+ static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Joystick_GetStatus(void)\r
+ {\r
+ // TODO: Return current joystick position data which can be obtained by masking against the JOY_* macros\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief LUFA Custom Board LED Hardware Driver (Template)\r
+ *\r
+ * This is a stub driver header file, for implementing custom board\r
+ * layout hardware with compatible LUFA board specific drivers. If\r
+ * the library is configured to use the BOARD_USER board mode, this\r
+ * driver file should be completed and copied into the "/Board/" folder\r
+ * inside the application's folder.\r
+ *\r
+ * This stub is for the board-specific component of the LUFA LEDs driver,\r
+ * for the LEDs (up to four) mounted on most development boards.\r
+*/\r
+\r
+#ifndef __LEDS_USER_H__\r
+#define __LEDS_USER_H__\r
+\r
+ /* Includes: */\r
+ // TODO: Add any required includes here\r
+\r
+/* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 // TODO: Add mask for first board LED here\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 // TODO: Add mask for second board LED here\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 // TODO: Add mask for third board LED here\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 // TODO: Add mask for fourth board LED here\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ // TODO: Add code to initialize LED port pins as outputs here\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ // TODO: Clear the LED port pins as high impedance inputs here\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ // TODO: Add code to turn on LEDs given in the LEDMask mask here, leave others as-is\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ // TODO: Add code to turn off LEDs given in the LEDMask mask here, leave others as-is\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ // TODO: Add code to turn on only LEDs given in the LEDMask mask here, all others off\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)\r
+ {\r
+ // TODO: Add code to set the Leds in the given LEDMask to the status given in ActiveMask here\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ // TODO: Add code to toggle the Leds in the given LEDMask, ignoring all others\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ // TODO: Add code to return the current LEDs status' here which can be masked against LED_LED* macros\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief LUFA Library Configuration Header File (Template)\r
+ *\r
+ * This is a header file which can be used to configure LUFA's\r
+ * compile time options, as an alternative to the compile time\r
+ * constants supplied through a makefile. To use this configuration\r
+ * header, copy this into your project's root directory and supply\r
+ * the \c USE_LUFA_CONFIG_HEADER token to the compiler so that it is\r
+ * defined in all compiled source files.\r
+ *\r
+ * For information on what each token does, refer to the LUFA\r
+ * manual section "Summary of Compile Tokens".\r
+ */\r
+\r
+#ifndef __LUFA_CONFIG_H__\r
+#define __LUFA_CONFIG_H__\r
+\r
+ #if (ARCH == ARCH_AVR8)\r
+\r
+ /* Non-USB Related Configuration Tokens: */\r
+// #define DISABLE_TERMINAL_CODES\r
+\r
+ /* USB Class Driver Related Tokens: */\r
+// #define HID_HOST_BOOT_PROTOCOL_ONLY\r
+// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}\r
+// #define HID_USAGE_STACK_DEPTH {Insert Value Here}\r
+// #define HID_MAX_COLLECTIONS {Insert Value Here}\r
+// #define HID_MAX_REPORTITEMS {Insert Value Here}\r
+// #define HID_MAX_REPORT_IDS {Insert Value Here}\r
+// #define NO_CLASS_DRIVER_AUTOFLUSH\r
+\r
+ /* General USB Driver Related Tokens: */\r
+// #define ORDERED_EP_CONFIG\r
+// #define USE_STATIC_OPTIONS {Insert Value Here}\r
+// #define USB_DEVICE_ONLY\r
+// #define USB_HOST_ONLY\r
+// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}\r
+// #define NO_LIMITED_CONTROLLER_CONNECT\r
+// #define NO_SOF_EVENTS\r
+\r
+ /* USB Device Mode Driver Related Tokens: */\r
+// #define USE_RAM_DESCRIPTORS\r
+// #define USE_FLASH_DESCRIPTORS\r
+// #define USE_EEPROM_DESCRIPTORS\r
+// #define NO_INTERNAL_SERIAL\r
+// #define FIXED_CONTROL_ENDPOINT_SIZE {Insert Value Here}\r
+// #define DEVICE_STATE_AS_GPIOR {Insert Value Here}\r
+// #define FIXED_NUM_CONFIGURATIONS {Insert Value Here}\r
+// #define CONTROL_ONLY_DEVICE\r
+// #define INTERRUPT_CONTROL_ENDPOINT\r
+// #define NO_DEVICE_REMOTE_WAKEUP\r
+// #define NO_DEVICE_SELF_POWER\r
+\r
+ /* USB Host Mode Driver Related Tokens: */\r
+// #define HOST_STATE_AS_GPIOR {Insert Value Here}\r
+// #define USB_HOST_TIMEOUT_MS {Insert Value Here}\r
+// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}\r
+// #define NO_AUTO_VBUS_MANAGEMENT\r
+// #define INVERTED_VBUS_ENABLE_LINE\r
+\r
+ #elif (ARCH == ARCH_XMEGA)\r
+\r
+ /* Non-USB Related Configuration Tokens: */\r
+// #define DISABLE_TERMINAL_CODES\r
+\r
+ /* USB Class Driver Related Tokens: */\r
+// #define HID_HOST_BOOT_PROTOCOL_ONLY\r
+// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}\r
+// #define HID_USAGE_STACK_DEPTH {Insert Value Here}\r
+// #define HID_MAX_COLLECTIONS {Insert Value Here}\r
+// #define HID_MAX_REPORTITEMS {Insert Value Here}\r
+// #define HID_MAX_REPORT_IDS {Insert Value Here}\r
+// #define NO_CLASS_DRIVER_AUTOFLUSH\r
+\r
+ /* General USB Driver Related Tokens: */\r
+// #define USE_STATIC_OPTIONS {Insert Value Here}\r
+// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}\r
+// #define NO_LIMITED_CONTROLLER_CONNECT\r
+// #define NO_SOF_EVENTS\r
+\r
+ /* USB Device Mode Driver Related Tokens: */\r
+// #define USE_RAM_DESCRIPTORS\r
+// #define USE_FLASH_DESCRIPTORS\r
+// #define USE_EEPROM_DESCRIPTORS\r
+// #define NO_INTERNAL_SERIAL\r
+// #define FIXED_CONTROL_ENDPOINT_SIZE {Insert Value Here}\r
+// #define DEVICE_STATE_AS_GPIOR {Insert Value Here}\r
+// #define FIXED_NUM_CONFIGURATIONS {Insert Value Here}\r
+// #define CONTROL_ONLY_DEVICE\r
+// #define MAX_ENDPOINT_INDEX {Insert Value Here}\r
+// #define NO_DEVICE_REMOTE_WAKEUP\r
+// #define NO_DEVICE_SELF_POWER\r
+\r
+ #elif (ARCH == ARCH_UC3)\r
+\r
+ /* Non-USB Related Configuration Tokens: */\r
+// #define DISABLE_TERMINAL_CODES\r
+\r
+ /* USB Class Driver Related Tokens: */\r
+// #define HID_HOST_BOOT_PROTOCOL_ONLY\r
+// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}\r
+// #define HID_USAGE_STACK_DEPTH {Insert Value Here}\r
+// #define HID_MAX_COLLECTIONS {Insert Value Here}\r
+// #define HID_MAX_REPORTITEMS {Insert Value Here}\r
+// #define HID_MAX_REPORT_IDS {Insert Value Here}\r
+// #define NO_CLASS_DRIVER_AUTOFLUSH\r
+\r
+ /* General USB Driver Related Tokens: */\r
+// #define ORDERED_EP_CONFIG\r
+// #define USE_STATIC_OPTIONS {Insert Value Here}\r
+// #define USB_DEVICE_ONLY\r
+// #define USB_HOST_ONLY\r
+// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}\r
+// #define NO_SOF_EVENTS\r
+\r
+ /* USB Device Mode Driver Related Tokens: */\r
+// #define NO_INTERNAL_SERIAL\r
+// #define FIXED_CONTROL_ENDPOINT_SIZE {Insert Value Here}\r
+// #define FIXED_NUM_CONFIGURATIONS {Insert Value Here}\r
+// #define CONTROL_ONLY_DEVICE\r
+// #define INTERRUPT_CONTROL_ENDPOINT\r
+// #define NO_DEVICE_REMOTE_WAKEUP\r
+// #define NO_DEVICE_SELF_POWER\r
+\r
+ /* USB Host Mode Driver Related Tokens: */\r
+// #define USB_HOST_TIMEOUT_MS {Insert Value Here}\r
+// #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}\r
+// #define NO_AUTO_VBUS_MANAGEMENT\r
+// #define INVERTED_VBUS_ENABLE_LINE\r
+\r
+ #else\r
+\r
+ #error Unsupported architecture for this LUFA configuration file.\r
+\r
+ #endif\r
+#endif\r
+\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2012.\r
+#\r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.lufa-lib.org\r
+#\r
+# --------------------------------------\r
+# LUFA Project Makefile.\r
+# --------------------------------------\r
+\r
+MCU = at90usb1287\r
+ARCH = AVR8\r
+BOARD = USBKEY\r
+F_CPU = 8000000\r
+F_USB = $(F_CPU)\r
+OPTIMIZATION = s\r
+TARGET = Target\r
+SRC = $(TARGET).c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS) $(LUFA_SRC_PLATFORM)\r
+LUFA_PATH = ../../LUFA\r
+CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig\r
+LD_FLAGS =\r
+\r
+# Default target\r
+all:\r
+\r
+# Include LUFA build script makefiles\r
+include $(LUFA_PATH)/Build/lufa_core.mk\r
+include $(LUFA_PATH)/Build/lufa_sources.mk\r
+include $(LUFA_PATH)/Build/lufa_build.mk\r
+include $(LUFA_PATH)/Build/lufa_cppcheck.mk\r
+include $(LUFA_PATH)/Build/lufa_doxygen.mk\r
+include $(LUFA_PATH)/Build/lufa_dfu.mk\r
+include $(LUFA_PATH)/Build/lufa_hid.mk\r
+include $(LUFA_PATH)/Build/lufa_avrdude.mk\r
+include $(LUFA_PATH)/Build/lufa_atprogram.mk\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Architecture specific definitions relating to specific processor architectures.\r
+ *\r
+ * \copydetails Group_ArchitectureSpecific\r
+ *\r
+ * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's\r
+ * functionality.\r
+ */\r
+\r
+/** \ingroup Group_Common\r
+ * \defgroup Group_ArchitectureSpecific Architecture Specific Definitions\r
+ * \brief Architecture specific definitions relating to specific processor architectures.\r
+ *\r
+ * Architecture specific macros, functions and other definitions, which relate to specific architectures. This\r
+ * definitions may or may not be available in some form on other architectures, and thus should be protected by\r
+ * preprocessor checks in portable code to prevent compile errors.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LUFA_ARCHSPEC_H__\r
+#define __LUFA_ARCHSPEC_H__\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_COMMON_H)\r
+ #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality.\r
+ #endif\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #if (ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA) || defined(__DOXYGEN__)\r
+ #if (ARCH == ARCH_AVR8) || defined(__DOXYGEN__)\r
+ /** Re-enables the AVR's JTAG bus in software, until a system reset. This will re-enable JTAG debugging\r
+ * interface after is has been disabled in software via \ref JTAG_DISABLE().\r
+ *\r
+ * \note This macro is not available for all architectures.\r
+ */\r
+ #define JTAG_ENABLE() MACROS{ \\r
+ __asm__ __volatile__ ( \\r
+ "in __tmp_reg__,__SREG__" "\n\t" \\r
+ "cli" "\n\t" \\r
+ "out %1, %0" "\n\t" \\r
+ "out __SREG__, __tmp_reg__" "\n\t" \\r
+ "out %1, %0" "\n\t" \\r
+ : \\r
+ : "r" (MCUCR & ~(1 << JTD)), \\r
+ "M" (_SFR_IO_ADDR(MCUCR)) \\r
+ : "r0"); \\r
+ }MACROE\r
+\r
+ /** Disables the AVR's JTAG bus in software, until a system reset. This will override the current JTAG\r
+ * status as set by the JTAGEN fuse, disabling JTAG debugging and reverting the JTAG pins back to GPIO\r
+ * mode.\r
+ *\r
+ * \note This macro is not available for all architectures.\r
+ */\r
+ #define JTAG_DISABLE() MACROS{ \\r
+ __asm__ __volatile__ ( \\r
+ "in __tmp_reg__,__SREG__" "\n\t" \\r
+ "cli" "\n\t" \\r
+ "out %1, %0" "\n\t" \\r
+ "out __SREG__, __tmp_reg__" "\n\t" \\r
+ "out %1, %0" "\n\t" \\r
+ : \\r
+ : "r" (MCUCR | (1 << JTD)), \\r
+ "M" (_SFR_IO_ADDR(MCUCR)) \\r
+ : "r0"); \\r
+ }MACROE\r
+ #endif\r
+\r
+ /** Defines a volatile \c NOP statement which cannot be optimized out by the compiler, and thus can always\r
+ * be set as a breakpoint in the resulting code. Useful for debugging purposes, where the optimizer\r
+ * removes/reorders code to the point where break points cannot reliably be set.\r
+ *\r
+ * \note This macro is not available for all architectures.\r
+ */\r
+ #define JTAG_DEBUG_POINT() __asm__ __volatile__ ("nop" ::)\r
+\r
+ /** Defines an explicit JTAG break point in the resulting binary via the assembly \c BREAK statement. When\r
+ * a JTAG is used, this causes the program execution to halt when reached until manually resumed.\r
+ *\r
+ * \note This macro is not available for all architectures.\r
+ */\r
+ #define JTAG_DEBUG_BREAK() __asm__ __volatile__ ("break" ::)\r
+\r
+ /** Macro for testing condition "x" and breaking via \ref JTAG_DEBUG_BREAK() if the condition is false.\r
+ *\r
+ * \note This macro is not available for all architectures.\r
+ *\r
+ * \param[in] Condition Condition that will be evaluated.\r
+ */\r
+ #define JTAG_ASSERT(Condition) MACROS{ if (!(Condition)) { JTAG_DEBUG_BREAK(); } }MACROE\r
+\r
+ /** Macro for testing condition \c "x" and writing debug data to the stdout stream if \c false. The stdout stream\r
+ * must be pre-initialized before this macro is run and linked to an output device, such as the microcontroller's\r
+ * USART peripheral.\r
+ *\r
+ * The output takes the form "{FILENAME}: Function {FUNCTION NAME}, Line {LINE NUMBER}: Assertion {Condition} failed."\r
+ *\r
+ * \note This macro is not available for all architectures.\r
+ *\r
+ * \param[in] Condition Condition that will be evaluated,\r
+ */\r
+ #define STDOUT_ASSERT(Condition) MACROS{ if (!(x)) { \\r
+ printf_P(PSTR("%s: Function \"%s\", Line %d: " \\r
+ "Assertion \"%s\" failed.\r\n"), \\r
+ __FILE__, __func__, __LINE__, #Condition); } }MACROE\r
+\r
+ #if !defined(pgm_read_ptr) || defined(__DOXYGEN__)\r
+ /** Reads a pointer out of PROGMEM space on the AVR8 architecture. This is currently a wrapper for the\r
+ * avr-libc \c pgm_read_ptr() macro with a \c void* cast, so that its value can be assigned directly\r
+ * to a pointer variable or used in pointer arithmetic without further casting in C. In a future\r
+ * avr-libc distribution this will be part of the standard API and will be implemented in a more formal\r
+ * manner.\r
+ *\r
+ * \note This macro is not available for all architectures.\r
+ *\r
+ * \param[in] Address Address of the pointer to read.\r
+ *\r
+ * \return Pointer retrieved from PROGMEM space.\r
+ */\r
+ #define pgm_read_ptr(Address) (void*)pgm_read_word(Address)\r
+ #endif\r
+ #elif (ARCH == ARCH_UC3)\r
+ #define JTAG_DEBUG_POINT() __asm__ __volatile__ ("nop" ::)\r
+ #define JTAG_DEBUG_BREAK() __asm__ __volatile__ ("breakpoint" ::)\r
+ #define JTAG_ASSERT(Condition) MACROS{ if (!(Condition)) { JTAG_DEBUG_BREAK(); } }MACROE\r
+ #define STDOUT_ASSERT(Condition) MACROS{ if (!(x)) { \\r
+ printf("%s: Function \"%s\", Line %d: " \\r
+ "Assertion \"%s\" failed.\r\n"), \\r
+ __FILE__, __func__, __LINE__, #Condition); } }MACROE\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Supported library architecture defines.\r
+ *\r
+ * \copydetails Group_Architectures\r
+ *\r
+ * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's\r
+ * functionality.\r
+ */\r
+\r
+/** \ingroup Group_Common\r
+ * \defgroup Group_Architectures Hardware Architectures\r
+ * \brief Supported library architecture defines.\r
+ *\r
+ * Architecture macros for selecting the desired target microcontroller architecture. One of these values should be\r
+ * defined as the value of \c ARCH in the user project makefile via the \c -D compiler switch to GCC, to select the\r
+ * target architecture.\r
+ *\r
+ * The selected architecture should remain consistent with the makefile \c ARCH value, which is used to select the\r
+ * underlying driver source files for each architecture.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LUFA_ARCHITECTURES_H__\r
+#define __LUFA_ARCHITECTURES_H__\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_COMMON_H)\r
+ #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Selects the Atmel 8-bit AVR (AT90USB* and ATMEGA*U* chips) architecture. */\r
+ #define ARCH_AVR8 0\r
+\r
+ /** Selects the Atmel 32-bit UC3 AVR (AT32UC3* chips) architecture. */\r
+ #define ARCH_UC3 1\r
+\r
+ /** Selects the Atmel XMEGA AVR (ATXMEGA*U chips) architecture. */\r
+ #define ARCH_XMEGA 2\r
+\r
+ #if !defined(__DOXYGEN__)\r
+ #define ARCH_ ARCH_AVR8\r
+\r
+ #if !defined(ARCH)\r
+ #define ARCH ARCH_AVR8\r
+ #endif\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Special function/variable attribute macros.\r
+ *\r
+ * \copydetails Group_FuncVarAttributes\r
+ *\r
+ * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's\r
+ * functionality.\r
+ */\r
+\r
+/** \ingroup Group_Common\r
+ * \defgroup Group_FuncVarAttributes Function/Variable Attributes\r
+ * \brief Special function/variable attribute macros.\r
+ *\r
+ * This module contains macros for applying specific attributes to functions and variables to control various\r
+ * optimizer and code generation features of the compiler. Attributes may be placed in the function prototype\r
+ * or variable declaration in any order, and multiple attributes can be specified for a single item via a space\r
+ * separated list.\r
+ *\r
+ * On incompatible versions of GCC or on other compilers, these macros evaluate to nothing unless they are\r
+ * critical to the code's function and thus must throw a compile error when used.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LUFA_ATTR_H__\r
+#define __LUFA_ATTR_H__\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_COMMON_H)\r
+ #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #if (__GNUC__ >= 3) || defined(__DOXYGEN__)\r
+ /** Indicates to the compiler that the function can not ever return, so that any stack restoring or\r
+ * return code may be omitted by the compiler in the resulting binary.\r
+ */\r
+ #define ATTR_NO_RETURN __attribute__ ((noreturn))\r
+\r
+ /** Indicates that the function returns a value which should not be ignored by the user code. When\r
+ * applied, any ignored return value from calling the function will produce a compiler warning.\r
+ */\r
+ #define ATTR_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result))\r
+\r
+ /** Indicates that the specified parameters of the function are pointers which should never be \c NULL.\r
+ * When applied as a 1-based comma separated list the compiler will emit a warning if the specified\r
+ * parameters are known at compiler time to be \c NULL at the point of calling the function.\r
+ */\r
+ #define ATTR_NON_NULL_PTR_ARG(...) __attribute__ ((nonnull (__VA_ARGS__)))\r
+\r
+ /** Removes any preamble or postamble from the function. When used, the function will not have any\r
+ * register or stack saving code. This should be used with caution, and when used the programmer\r
+ * is responsible for maintaining stack and register integrity.\r
+ */\r
+ #define ATTR_NAKED __attribute__ ((naked))\r
+\r
+ /** Prevents the compiler from considering a specified function for in-lining. When applied, the given\r
+ * function will not be in-lined under any circumstances.\r
+ */\r
+ #define ATTR_NO_INLINE __attribute__ ((noinline))\r
+\r
+ /** Forces the compiler to inline the specified function. When applied, the given function will be\r
+ * in-lined under all circumstances.\r
+ */\r
+ #define ATTR_ALWAYS_INLINE __attribute__ ((always_inline))\r
+\r
+ /** Indicates that the specified function is pure, in that it has no side-effects other than global\r
+ * or parameter variable access.\r
+ */\r
+ #define ATTR_PURE __attribute__ ((pure))\r
+\r
+ /** Indicates that the specified function is constant, in that it has no side effects other than\r
+ * parameter access.\r
+ */\r
+ #define ATTR_CONST __attribute__ ((const))\r
+\r
+ /** Marks a given function as deprecated, which produces a warning if the function is called. */\r
+ #define ATTR_DEPRECATED __attribute__ ((deprecated))\r
+\r
+ /** Marks a function as a weak reference, which can be overridden by other functions with an\r
+ * identical name (in which case the weak reference is discarded at link time).\r
+ */\r
+ #define ATTR_WEAK __attribute__ ((weak))\r
+ #endif\r
+\r
+ /** Forces the compiler to not automatically zero the given global variable on startup, so that the\r
+ * current RAM contents is retained. Under most conditions this value will be random due to the\r
+ * behavior of volatile memory once power is removed, but may be used in some specific circumstances,\r
+ * like the passing of values back after a system watchdog reset.\r
+ */\r
+ #define ATTR_NO_INIT __attribute__ ((section (".noinit")))\r
+\r
+ /** Places the function in one of the initialization sections, which execute before the main function\r
+ * of the application. Refer to the avr-libc manual for more information on the initialization sections.\r
+ *\r
+ * \param[in] SectionIndex Initialization section number where the function should be placed.\r
+ */\r
+ #define ATTR_INIT_SECTION(SectionIndex) __attribute__ ((used, naked, section (".init" #SectionIndex )))\r
+\r
+ /** Marks a function as an alias for another function.\r
+ *\r
+ * \param[in] Func Name of the function which the given function name should alias.\r
+ */\r
+ #define ATTR_ALIAS(Func) __attribute__ ((alias( #Func )))\r
+\r
+ /** Marks a variable or struct element for packing into the smallest space available, omitting any\r
+ * alignment bytes usually added between fields to optimize field accesses.\r
+ */\r
+ #define ATTR_PACKED __attribute__ ((packed))\r
+\r
+ /** Indicates the minimum alignment in bytes for a variable or struct element.\r
+ *\r
+ * \param[in] Bytes Minimum number of bytes the item should be aligned to.\r
+ */\r
+ #define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Supported pre-made board hardware defines.\r
+ *\r
+ * \copydetails Group_BoardTypes\r
+ *\r
+ * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's\r
+ * functionality.\r
+ */\r
+\r
+/** \ingroup Group_Common\r
+ * \defgroup Group_BoardTypes Board Types\r
+ * \brief Supported pre-made board hardware defines.\r
+ *\r
+ * Board macros for indicating the chosen physical board hardware to the library. These macros should be used when\r
+ * defining the \c BOARD token to the chosen hardware via the \c -D switch in the project makefile. If a custom\r
+ * board is used, the \ref BOARD_NONE or \ref BOARD_USER values should be selected.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LUFA_BOARDTYPES_H__\r
+#define __LUFA_BOARDTYPES_H__\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_COMMON_H)\r
+ #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Selects the user-defined board drivers, which should be placed in the user project's folder\r
+ * under a directory named \c /Board/. Each board driver should be named identically to the LUFA\r
+ * master board driver (i.e., driver in the \c LUFA/Drivers/Board directory) so that the library\r
+ * can correctly identify it.\r
+ */\r
+ #define BOARD_USER 0\r
+\r
+ /** Disables board drivers when operation will not be adversely affected (e.g. LEDs) - use of board drivers\r
+ * such as the Joystick driver, where the removal would adversely affect the code's operation is still disallowed. */\r
+ #define BOARD_NONE 1\r
+\r
+ /** Selects the USBKEY specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */\r
+ #define BOARD_USBKEY 2\r
+\r
+ /** Selects the STK525 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */\r
+ #define BOARD_STK525 3\r
+\r
+ /** Selects the STK526 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */\r
+ #define BOARD_STK526 4\r
+\r
+ /** Selects the RZUSBSTICK specific board drivers, including the driver for the boards LEDs. */\r
+ #define BOARD_RZUSBSTICK 5\r
+\r
+ /** Selects the ATAVRUSBRF01 specific board drivers, including the driver for the board LEDs. */\r
+ #define BOARD_ATAVRUSBRF01 6\r
+\r
+ /** Selects the BUMBLEB specific board drivers, using the officially recommended peripheral layout. */\r
+ #define BOARD_BUMBLEB 7\r
+\r
+ /** Selects the XPLAIN (Revision 2 or newer) specific board drivers, including LED and Dataflash drivers. */\r
+ #define BOARD_XPLAIN 8\r
+\r
+ /** Selects the XPLAIN (Revision 1) specific board drivers, including LED and Dataflash drivers. */\r
+ #define BOARD_XPLAIN_REV1 9\r
+\r
+ /** Selects the EVK527 specific board drivers, including Temperature, Button, Dataflash, Joystick and LED drivers. */\r
+ #define BOARD_EVK527 10\r
+\r
+ /** Selects the Teensy version 1.x specific board drivers, including the driver for the board LEDs. */\r
+ #define BOARD_TEENSY 11\r
+\r
+ /** Selects the USBTINY MKII specific board drivers, including the Button and LEDs drivers. */\r
+ #define BOARD_USBTINYMKII 12\r
+\r
+ /** Selects the Benito specific board drivers, including the Button and LEDs drivers. */\r
+ #define BOARD_BENITO 13\r
+\r
+ /** Selects the JM-DB-U2 specific board drivers, including the Button and LEDs drivers. */\r
+ #define BOARD_JMDBU2 14\r
+\r
+ /** Selects the Olimex AVR-USB-162 specific board drivers, including the Button and LEDs drivers. */\r
+ #define BOARD_OLIMEX162 15\r
+\r
+ /** Selects the UDIP specific board drivers, including the Button and LEDs drivers. */\r
+ #define BOARD_UDIP 16\r
+\r
+ /** Selects the BUI specific board drivers, including the driver for the board LEDs. */\r
+ #define BOARD_BUI 17\r
+\r
+ /** Selects the Arduino Uno specific board drivers, including the driver for the board LEDs. */\r
+ #define BOARD_UNO 18\r
+\r
+ /** Selects the Busware CUL V3 specific board drivers, including the Button and LEDs drivers. */\r
+ #define BOARD_CULV3 19\r
+\r
+ /** Selects the Blackcat USB JTAG specific board drivers, including the driver for the board LEDs. */\r
+ #define BOARD_BLACKCAT 20\r
+\r
+ /** Selects the Maximus specific board drivers, including the driver for the board LEDs. */\r
+ #define BOARD_MAXIMUS 21\r
+\r
+ /** Selects the Minimus specific board drivers, including the Button and LEDs drivers. */\r
+ #define BOARD_MINIMUS 22\r
+\r
+ /** Selects the Adafruit U4 specific board drivers, including the Button driver. */\r
+ #define BOARD_ADAFRUITU4 23\r
+\r
+ /** Selects the Microsin AVR-USB162 specific board drivers, including the Button and LEDs drivers. */\r
+ #define BOARD_MICROSIN162 24\r
+\r
+ /** Selects the Kernel Concepts USBFOO specific board drivers, including the Button and LEDs drivers. */\r
+ #define BOARD_USBFOO 25\r
+\r
+ /** Selects the Sparkfun ATMEGA8U2 specific board drivers, including the driver for the board LEDs. */\r
+ #define BOARD_SPARKFUN8U2 26\r
+\r
+ /** Selects the Atmel EVK1101 specific board drivers, including the Button, Joystick and LED drivers. */\r
+ #define BOARD_EVK1101 27\r
+\r
+ /** Selects the Busware TUL specific board drivers, including the Button and LED drivers. */\r
+ #define BOARD_TUL 28\r
+\r
+ /** Selects the Atmel EVK1100 specific board drivers, including the Button, Joystick and LED drivers. */\r
+ #define BOARD_EVK1100 29\r
+\r
+ /** Selects the Atmel EVK1104 specific board drivers, including the Button and LED drivers. */\r
+ #define BOARD_EVK1104 30\r
+\r
+ /** Selects the Atmel XMEGA A3BU Xplained specific board drivers, including Dataflash, Button and LED drivers. */\r
+ #define BOARD_A3BU_XPLAINED 31\r
+\r
+ /** Selects the Teensy version 2.x specific board drivers, including the driver for the board LEDs. */\r
+ #define BOARD_TEENSY2 32\r
+\r
+ /** Selects the USB2AX version 1 and 2 specific board drivers, including the Button and LEDs drivers. */\r
+ #define BOARD_USB2AX 33\r
+\r
+ /** Selects the USB2AX version 3 specific board drivers, including the Button and LEDs drivers. */\r
+ #define BOARD_USB2AX_V3 34\r
+\r
+ /** Selects the Micropendous 32U2 specific board drivers, including the Button and LED drivers. */\r
+ #define BOARD_MICROPENDOUS_32U2 35\r
+\r
+ /** Selects the Micropendous A specific board drivers, including the driver for the board Button. */\r
+ #define BOARD_MICROPENDOUS_A 36\r
+\r
+ /** Selects the Micropendous 1 specific board drivers, including the driver for the board Button. */\r
+ #define BOARD_MICROPENDOUS_1 37\r
+\r
+ /** Selects the Micropendous 2 specific board drivers, including the driver for the board Button. */\r
+ #define BOARD_MICROPENDOUS_2 38\r
+\r
+ /** Selects the Micropendous 3 specific board drivers, including the driver for the board Button. */\r
+ #define BOARD_MICROPENDOUS_3 39\r
+\r
+ /** Selects the Micropendous 4 specific board drivers, including the driver for the board Button. */\r
+ #define BOARD_MICROPENDOUS_4 40\r
+\r
+ /** Selects the Micropendous DIP specific board drivers, including the driver for the board Button. */\r
+ #define BOARD_MICROPENDOUS_DIP 41\r
+\r
+ /** Selects the Micropendous (Arduino-like) revision 1 specific board drivers, including the Button and LED drivers. */\r
+ #define BOARD_MICROPENDOUS_REV1 42\r
+\r
+ /** Selects the Micropendous (Arduino-like) revision 2 specific board drivers, including the Button and LED drivers. */\r
+ #define BOARD_MICROPENDOUS_REV2 43\r
+\r
+ /** Selects the XMEGA B1 Xplained specific board drivers, including the Button and LED drivers. */\r
+ #define BOARD_B1_XPLAINED 44\r
+\r
+ /** Selects the Bitwizard Multio specific board drivers, including the driver for the board LEDs. */\r
+ #define BOARD_MULTIO 45\r
+\r
+ /** Selects the Bitwizard Big-Multio specific board drivers, including the driver for the board LEDs. */\r
+ #define BOARD_BIGMULTIO 46\r
+\r
+ /** Selects the DorkbotPDX Duce specific board drivers, including the driver for the board LEDs. */\r
+ #define BOARD_DUCE 47\r
+ \r
+ /** Selects the Olimex AVR-USB-32U4 specific board drivers, including the Button and LED drivers. */\r
+ #define BOARD_OLIMEX32U4 48\r
+ \r
+ /** Selects the Olimex AVR-USB-T32U4 specific board drivers, including the Button and LED drivers. */\r
+ #define BOARD_OLIMEXT32U4 49\r
+ \r
+ /** Selects the Olimex AVR-ISP-MK2 specific board drivers, including the Button and LED drivers. */\r
+ #define BOARD_OLIMEXISPMK2 50\r
+\r
+\r
+ #if !defined(__DOXYGEN__)\r
+ #define BOARD_ BOARD_NONE\r
+\r
+ #if !defined(BOARD)\r
+ #define BOARD BOARD_NONE\r
+ #endif\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \dir\r
+ * \brief Common library header files.\r
+ *\r
+ * This folder contains header files which are common to all parts of the LUFA library. They may be used freely in\r
+ * user applications.\r
+ */\r
+\r
+/** \file\r
+ * \brief Common library convenience headers, macros and functions.\r
+ *\r
+ * \copydetails Group_Common\r
+ */\r
+\r
+/** \defgroup Group_Common Common Utility Headers - LUFA/Drivers/Common/Common.h\r
+ * \brief Common library convenience headers, macros and functions.\r
+ *\r
+ * Common utility headers containing macros, functions, enums and types which are common to all\r
+ * aspects of the library.\r
+ *\r
+ * @{\r
+ */\r
+\r
+/** \defgroup Group_GlobalInt Global Interrupt Macros\r
+ * \brief Convenience macros for the management of interrupts globally within the device.\r
+ *\r
+ * Macros and functions to create and control global interrupts within the device.\r
+ */\r
+\r
+#ifndef __LUFA_COMMON_H__\r
+#define __LUFA_COMMON_H__\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_COMMON_H\r
+\r
+ /* Includes: */\r
+ #include <stdint.h>\r
+ #include <stdbool.h>\r
+ #include <string.h>\r
+ #include <stddef.h>\r
+\r
+ #include "Architectures.h"\r
+ #include "BoardTypes.h"\r
+ #include "ArchitectureSpecific.h"\r
+ #include "CompilerSpecific.h"\r
+ #include "Attributes.h"\r
+\r
+ #if defined(USE_LUFA_CONFIG_HEADER)\r
+ #include "LUFAConfig.h"\r
+ #endif\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Architecture specific utility includes: */\r
+ #if defined(__DOXYGEN__)\r
+ /** Type define for an unsigned integer the same width as the selected architecture's machine register.\r
+ * This is distinct from the non-specific standard int data type, whose width is machine dependant but\r
+ * which may not reflect the actual machine register width on some targets (e.g. AVR8).\r
+ */\r
+ typedef MACHINE_REG_t uint_reg_t;\r
+ #elif (ARCH == ARCH_AVR8)\r
+ #include <avr/io.h>\r
+ #include <avr/interrupt.h>\r
+ #include <avr/pgmspace.h>\r
+ #include <avr/eeprom.h>\r
+ #include <avr/boot.h>\r
+ #include <math.h>\r
+ #include <util/delay.h>\r
+\r
+ typedef uint8_t uint_reg_t;\r
+\r
+ #define ARCH_HAS_EEPROM_ADDRESS_SPACE\r
+ #define ARCH_HAS_FLASH_ADDRESS_SPACE\r
+ #define ARCH_HAS_MULTI_ADDRESS_SPACE\r
+ #define ARCH_LITTLE_ENDIAN\r
+\r
+ #include "Endianness.h"\r
+ #elif (ARCH == ARCH_UC3)\r
+ #include <avr32/io.h>\r
+ #include <math.h>\r
+\r
+ // === TODO: Find abstracted way to handle these ===\r
+ #define PROGMEM \r
+ #define pgm_read_byte(x) *x\r
+ #define memcmp_P(...) memcmp(__VA_ARGS__)\r
+ #define memcpy_P(...) memcpy(__VA_ARGS__)\r
+ // =================================================\r
+\r
+ typedef uint32_t uint_reg_t;\r
+\r
+ #define ARCH_BIG_ENDIAN\r
+\r
+ #include "Endianness.h"\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ #include <avr/io.h>\r
+ #include <avr/interrupt.h>\r
+ #include <avr/pgmspace.h>\r
+ #include <avr/eeprom.h>\r
+ #include <math.h>\r
+ #include <util/delay.h>\r
+\r
+ typedef uint8_t uint_reg_t;\r
+\r
+ #define ARCH_HAS_EEPROM_ADDRESS_SPACE\r
+ #define ARCH_HAS_FLASH_ADDRESS_SPACE\r
+ #define ARCH_HAS_MULTI_ADDRESS_SPACE\r
+ #define ARCH_LITTLE_ENDIAN\r
+\r
+ #include "Endianness.h"\r
+ #else\r
+ #error Unknown device architecture specified.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Macro for encasing other multi-statement macros. This should be used along with an opening brace\r
+ * before the start of any multi-statement macro, so that the macros contents as a whole are treated\r
+ * as a discrete block and not as a list of separate statements which may cause problems when used as\r
+ * a block (such as inline \c if statements).\r
+ */\r
+ #define MACROS do\r
+\r
+ /** Macro for encasing other multi-statement macros. This should be used along with a preceding closing\r
+ * brace at the end of any multi-statement macro, so that the macros contents as a whole are treated\r
+ * as a discrete block and not as a list of separate statements which may cause problems when used as\r
+ * a block (such as inline \c if statements).\r
+ */\r
+ #define MACROE while (0)\r
+\r
+ /** Convenience macro to determine the larger of two values.\r
+ *\r
+ * \attention This macro should only be used with operands that do not have side effects from being evaluated\r
+ * multiple times.\r
+ *\r
+ * \param[in] x First value to compare\r
+ * \param[in] y First value to compare\r
+ *\r
+ * \return The larger of the two input parameters\r
+ */\r
+ #if !defined(MAX) || defined(__DOXYGEN__)\r
+ #define MAX(x, y) (((x) > (y)) ? (x) : (y))\r
+ #endif\r
+\r
+ /** Convenience macro to determine the smaller of two values.\r
+ *\r
+ * \attention This macro should only be used with operands that do not have side effects from being evaluated\r
+ * multiple times.\r
+ *\r
+ * \param[in] x First value to compare\r
+ * \param[in] y First value to compare\r
+ *\r
+ * \return The smaller of the two input parameters\r
+ */\r
+ #if !defined(MIN) || defined(__DOXYGEN__)\r
+ #define MIN(x, y) (((x) < (y)) ? (x) : (y))\r
+ #endif\r
+\r
+ #if !defined(STRINGIFY) || defined(__DOXYGEN__)\r
+ /** Converts the given input into a string, via the C Preprocessor. This macro puts literal quotation\r
+ * marks around the input, converting the source into a string literal.\r
+ *\r
+ * \param[in] x Input to convert into a string literal.\r
+ *\r
+ * \return String version of the input.\r
+ */\r
+ #define STRINGIFY(x) #x\r
+\r
+ /** Converts the given input into a string after macro expansion, via the C Preprocessor. This macro puts\r
+ * literal quotation marks around the expanded input, converting the source into a string literal.\r
+ *\r
+ * \param[in] x Input to expand and convert into a string literal.\r
+ *\r
+ * \return String version of the expanded input.\r
+ */\r
+ #define STRINGIFY_EXPANDED(x) STRINGIFY(x)\r
+ #endif\r
+\r
+ #if !defined(ISR) || defined(__DOXYGEN__)\r
+ /** Macro for the definition of interrupt service routines, so that the compiler can insert the required\r
+ * prologue and epilogue code to properly manage the interrupt routine without affecting the main thread's\r
+ * state with unintentional side-effects.\r
+ *\r
+ * Interrupt handlers written using this macro may still need to be registered with the microcontroller's\r
+ * Interrupt Controller (if present) before they will properly handle incoming interrupt events.\r
+ *\r
+ * \note This macro is only supplied on some architectures, where the standard library does not include a valid\r
+ * definition. If an existing definition exists, the alternative definition here will be ignored.\r
+ *\r
+ * \ingroup Group_GlobalInt\r
+ *\r
+ * \param[in] Name Unique name of the interrupt service routine.\r
+ */\r
+ #define ISR(Name, ...) void Name (void) __attribute__((__interrupt__)) __VA_ARGS__; void Name (void)\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ /** Function to reverse the individual bits in a byte - i.e. bit 7 is moved to bit 0, bit 6 to bit 1,\r
+ * etc.\r
+ *\r
+ * \param[in] Byte Byte of data whose bits are to be reversed.\r
+ *\r
+ * \return Input data with the individual bits reversed (mirrored).\r
+ */\r
+ static inline uint8_t BitReverse(uint8_t Byte) ATTR_WARN_UNUSED_RESULT ATTR_CONST;\r
+ static inline uint8_t BitReverse(uint8_t Byte)\r
+ {\r
+ Byte = (((Byte & 0xF0) >> 4) | ((Byte & 0x0F) << 4));\r
+ Byte = (((Byte & 0xCC) >> 2) | ((Byte & 0x33) << 2));\r
+ Byte = (((Byte & 0xAA) >> 1) | ((Byte & 0x55) << 1));\r
+\r
+ return Byte;\r
+ }\r
+\r
+ /** Function to perform a blocking delay for a specified number of milliseconds. The actual delay will be\r
+ * at a minimum the specified number of milliseconds, however due to loop overhead and internal calculations\r
+ * may be slightly higher.\r
+ *\r
+ * \param[in] Milliseconds Number of milliseconds to delay\r
+ */\r
+ static inline void Delay_MS(uint16_t Milliseconds) ATTR_ALWAYS_INLINE;\r
+ static inline void Delay_MS(uint16_t Milliseconds)\r
+ {\r
+ #if (ARCH == ARCH_AVR8)\r
+ if (GCC_IS_COMPILE_CONST(Milliseconds))\r
+ {\r
+ _delay_ms(Milliseconds);\r
+ }\r
+ else\r
+ {\r
+ while (Milliseconds--)\r
+ _delay_ms(1);\r
+ }\r
+ #elif (ARCH == ARCH_UC3)\r
+ while (Milliseconds--)\r
+ {\r
+ __builtin_mtsr(AVR32_COUNT, 0);\r
+ while ((uint32_t)__builtin_mfsr(AVR32_COUNT) < (F_CPU / 1000));\r
+ }\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ if (GCC_IS_COMPILE_CONST(Milliseconds))\r
+ {\r
+ _delay_ms(Milliseconds);\r
+ }\r
+ else\r
+ {\r
+ while (Milliseconds--)\r
+ _delay_ms(1);\r
+ }\r
+ #endif\r
+ }\r
+\r
+ /** Retrieves a mask which contains the current state of the global interrupts for the device. This\r
+ * value can be stored before altering the global interrupt enable state, before restoring the\r
+ * flag(s) back to their previous values after a critical section using \ref SetGlobalInterruptMask().\r
+ *\r
+ * \ingroup Group_GlobalInt\r
+ *\r
+ * \return Mask containing the current Global Interrupt Enable Mask bit(s).\r
+ */\r
+ static inline uint_reg_t GetGlobalInterruptMask(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint_reg_t GetGlobalInterruptMask(void)\r
+ {\r
+ GCC_MEMORY_BARRIER();\r
+\r
+ #if (ARCH == ARCH_AVR8)\r
+ return SREG;\r
+ #elif (ARCH == ARCH_UC3)\r
+ return __builtin_mfsr(AVR32_SR);\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ return SREG;\r
+ #endif\r
+ }\r
+\r
+ /** Sets the global interrupt enable state of the microcontroller to the mask passed into the function.\r
+ * This can be combined with \ref GetGlobalInterruptMask() to save and restore the Global Interrupt Enable\r
+ * Mask bit(s) of the device after a critical section has completed.\r
+ *\r
+ * \ingroup Group_GlobalInt\r
+ *\r
+ * \param[in] GlobalIntState Global Interrupt Enable Mask value to use\r
+ */\r
+ static inline void SetGlobalInterruptMask(const uint_reg_t GlobalIntState) ATTR_ALWAYS_INLINE;\r
+ static inline void SetGlobalInterruptMask(const uint_reg_t GlobalIntState)\r
+ {\r
+ GCC_MEMORY_BARRIER();\r
+\r
+ #if (ARCH == ARCH_AVR8)\r
+ SREG = GlobalIntState;\r
+ #elif (ARCH == ARCH_UC3)\r
+ if (GlobalIntState & AVR32_SR_GM)\r
+ __builtin_ssrf(AVR32_SR_GM_OFFSET);\r
+ else\r
+ __builtin_csrf(AVR32_SR_GM_OFFSET);\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ SREG = GlobalIntState;\r
+ #endif\r
+\r
+ GCC_MEMORY_BARRIER();\r
+ }\r
+\r
+ /** Enables global interrupt handling for the device, allowing interrupts to be handled.\r
+ *\r
+ * \ingroup Group_GlobalInt\r
+ */\r
+ static inline void GlobalInterruptEnable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void GlobalInterruptEnable(void)\r
+ {\r
+ GCC_MEMORY_BARRIER();\r
+\r
+ #if (ARCH == ARCH_AVR8)\r
+ sei();\r
+ #elif (ARCH == ARCH_UC3)\r
+ __builtin_csrf(AVR32_SR_GM_OFFSET);\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ sei();\r
+ #endif\r
+\r
+ GCC_MEMORY_BARRIER();\r
+ }\r
+\r
+ /** Disabled global interrupt handling for the device, preventing interrupts from being handled.\r
+ *\r
+ * \ingroup Group_GlobalInt\r
+ */\r
+ static inline void GlobalInterruptDisable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void GlobalInterruptDisable(void)\r
+ {\r
+ GCC_MEMORY_BARRIER();\r
+\r
+ #if (ARCH == ARCH_AVR8)\r
+ cli();\r
+ #elif (ARCH == ARCH_UC3)\r
+ __builtin_ssrf(AVR32_SR_GM_OFFSET);\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ cli();\r
+ #endif\r
+\r
+ GCC_MEMORY_BARRIER();\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Compiler specific definitions for code optimization and correctness.\r
+ *\r
+ * \copydetails Group_CompilerSpecific\r
+ *\r
+ * \note Do not include this file directly, rather include the Common.h header file instead to gain this file's\r
+ * functionality.\r
+ */\r
+\r
+/** \ingroup Group_Common\r
+ * \defgroup Group_CompilerSpecific Compiler Specific Definitions\r
+ * \brief Compiler specific definitions for code optimization and correctness.\r
+ *\r
+ * Compiler specific definitions to expose certain compiler features which may increase the level of code optimization\r
+ * for a specific compiler, or correct certain issues that may be present such as memory barriers for use in conjunction\r
+ * with atomic variable access.\r
+ *\r
+ * Where possible, on alternative compilers, these macros will either have no effect, or default to returning a sane value\r
+ * so that they can be used in existing code without the need for extra compiler checks in the user application code.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LUFA_COMPILERSPEC_H__\r
+#define __LUFA_COMPILERSPEC_H__\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_COMMON_H)\r
+ #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #if defined(__GNUC__) || defined(__DOXYGEN__)\r
+ /** Forces GCC to use pointer indirection (via the device's pointer register pairs) when accessing the given\r
+ * struct pointer. In some cases GCC will emit non-optimal assembly code when accessing a structure through\r
+ * a pointer, resulting in a larger binary. When this macro is used on a (non \c const) structure pointer before\r
+ * use, it will force GCC to use pointer indirection on the elements rather than direct store and load\r
+ * instructions.\r
+ *\r
+ * \param[in, out] StructPtr Pointer to a structure which is to be forced into indirect access mode.\r
+ */\r
+ #define GCC_FORCE_POINTER_ACCESS(StructPtr) __asm__ __volatile__("" : "=b" (StructPtr) : "0" (StructPtr))\r
+\r
+ /** Forces GCC to create a memory barrier, ensuring that memory accesses are not reordered past the barrier point.\r
+ * This can be used before ordering-critical operations, to ensure that the compiler does not re-order the resulting\r
+ * assembly output in an unexpected manner on sections of code that are ordering-specific.\r
+ */\r
+ #define GCC_MEMORY_BARRIER() __asm__ __volatile__("" ::: "memory");\r
+\r
+ /** Determines if the specified value can be determined at compile-time to be a constant value when compiling under GCC.\r
+ *\r
+ * \param[in] x Value to check compile-time constantness of.\r
+ *\r
+ * \return Boolean true if the given value is known to be a compile time constant, false otherwise.\r
+ */\r
+ #define GCC_IS_COMPILE_CONST(x) __builtin_constant_p(x)\r
+ #else\r
+ #define GCC_FORCE_POINTER_ACCESS(StructPtr)\r
+ #define GCC_MEMORY_BARRIER()\r
+ #define GCC_IS_COMPILE_CONST(x) 0\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Endianness and Byte Ordering macros and functions.\r
+ *\r
+ * \copydetails Group_Endianness\r
+ */\r
+\r
+/** \ingroup Group_Endianness\r
+ * \defgroup Group_ByteSwapping Byte Reordering\r
+ * \brief Macros and functions for forced byte reordering.\r
+ */\r
+\r
+/** \ingroup Group_Endianness\r
+ * \defgroup Group_EndianConversion Endianness Conversion\r
+ * \brief Macros and functions for automatic endianness conversion.\r
+ */\r
+\r
+/** \ingroup Group_Common\r
+ * \defgroup Group_Endianness Endianness and Byte Ordering\r
+ * \brief Convenience macros and functions relating to byte (re-)ordering\r
+ *\r
+ * Common library convenience macros and functions relating to byte (re-)ordering.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LUFA_ENDIANNESS_H__\r
+#define __LUFA_ENDIANNESS_H__\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_COMMON_H)\r
+ #error Do not include this file directly. Include LUFA/Common/Common.h instead to gain this functionality.\r
+ #endif\r
+\r
+ #if !(defined(ARCH_BIG_ENDIAN) || defined(ARCH_LITTLE_ENDIAN))\r
+ #error ARCH_BIG_ENDIAN or ARCH_LITTLE_ENDIAN not set for the specified architecture.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Swaps the byte ordering of a 16-bit value at compile-time. Do not use this macro for swapping byte orderings\r
+ * of dynamic values computed at runtime, use \ref SwapEndian_16() instead. The result of this macro can be used\r
+ * inside struct or other variable initializers outside of a function, something that is not possible with the\r
+ * inline function variant.\r
+ *\r
+ * \ingroup Group_ByteSwapping\r
+ *\r
+ * \param[in] x 16-bit value whose byte ordering is to be swapped.\r
+ *\r
+ * \return Input value with the byte ordering reversed.\r
+ */\r
+ #define SWAPENDIAN_16(x) (uint16_t)((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8))\r
+\r
+ /** Swaps the byte ordering of a 32-bit value at compile-time. Do not use this macro for swapping byte orderings\r
+ * of dynamic values computed at runtime- use \ref SwapEndian_32() instead. The result of this macro can be used\r
+ * inside struct or other variable initializers outside of a function, something that is not possible with the\r
+ * inline function variant.\r
+ *\r
+ * \ingroup Group_ByteSwapping\r
+ *\r
+ * \param[in] x 32-bit value whose byte ordering is to be swapped.\r
+ *\r
+ * \return Input value with the byte ordering reversed.\r
+ */\r
+ #define SWAPENDIAN_32(x) (uint32_t)((((x) & 0xFF000000UL) >> 24UL) | (((x) & 0x00FF0000UL) >> 8UL) | \\r
+ (((x) & 0x0000FF00UL) << 8UL) | (((x) & 0x000000FFUL) << 24UL))\r
+\r
+ #if defined(ARCH_BIG_ENDIAN) && !defined(le16_to_cpu)\r
+ #define le16_to_cpu(x) SwapEndian_16(x)\r
+ #define le32_to_cpu(x) SwapEndian_32(x)\r
+ #define be16_to_cpu(x) (x)\r
+ #define be32_to_cpu(x) (x)\r
+ #define cpu_to_le16(x) SwapEndian_16(x)\r
+ #define cpu_to_le32(x) SwapEndian_32(x)\r
+ #define cpu_to_be16(x) (x)\r
+ #define cpu_to_be32(x) (x)\r
+ #define LE16_TO_CPU(x) SWAPENDIAN_16(x)\r
+ #define LE32_TO_CPU(x) SWAPENDIAN_32(x)\r
+ #define BE16_TO_CPU(x) (x)\r
+ #define BE32_TO_CPU(x) (x)\r
+ #define CPU_TO_LE16(x) SWAPENDIAN_16(x)\r
+ #define CPU_TO_LE32(x) SWAPENDIAN_32(x)\r
+ #define CPU_TO_BE16(x) (x)\r
+ #define CPU_TO_BE32(x) (x)\r
+ #elif !defined(le16_to_cpu)\r
+ /** \name Run-time endianness conversion */\r
+ //@{\r
+\r
+ /** Performs a conversion between a Little Endian encoded 16-bit piece of data and the\r
+ * Endianness of the currently selected CPU architecture.\r
+ *\r
+ * On little endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for run-time conversion of data - for compile-time endianness\r
+ * conversion, use \ref LE16_TO_CPU instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define le16_to_cpu(x) (x)\r
+\r
+ /** Performs a conversion between a Little Endian encoded 32-bit piece of data and the\r
+ * Endianness of the currently selected CPU architecture.\r
+ *\r
+ * On little endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for run-time conversion of data - for compile-time endianness\r
+ * conversion, use \ref LE32_TO_CPU instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define le32_to_cpu(x) (x)\r
+\r
+ /** Performs a conversion between a Big Endian encoded 16-bit piece of data and the\r
+ * Endianness of the currently selected CPU architecture.\r
+ *\r
+ * On big endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for run-time conversion of data - for compile-time endianness\r
+ * conversion, use \ref BE16_TO_CPU instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define be16_to_cpu(x) SwapEndian_16(x)\r
+\r
+ /** Performs a conversion between a Big Endian encoded 32-bit piece of data and the\r
+ * Endianness of the currently selected CPU architecture.\r
+ *\r
+ * On big endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for run-time conversion of data - for compile-time endianness\r
+ * conversion, use \ref BE32_TO_CPU instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define be32_to_cpu(x) SwapEndian_32(x)\r
+\r
+ /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it\r
+ * is in Little Endian format regardless of the currently selected CPU architecture.\r
+ *\r
+ * On little endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for run-time conversion of data - for compile-time endianness\r
+ * conversion, use \ref CPU_TO_LE16 instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define cpu_to_le16(x) (x)\r
+\r
+ /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it\r
+ * is in Little Endian format regardless of the currently selected CPU architecture.\r
+ *\r
+ * On little endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for run-time conversion of data - for compile-time endianness\r
+ * conversion, use \ref CPU_TO_LE32 instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define cpu_to_le32(x) (x)\r
+\r
+ /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it\r
+ * is in Big Endian format regardless of the currently selected CPU architecture.\r
+ *\r
+ * On big endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for run-time conversion of data - for compile-time endianness\r
+ * conversion, use \ref CPU_TO_BE16 instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define cpu_to_be16(x) SwapEndian_16(x)\r
+\r
+ /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it\r
+ * is in Big Endian format regardless of the currently selected CPU architecture.\r
+ *\r
+ * On big endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for run-time conversion of data - for compile-time endianness\r
+ * conversion, use \ref CPU_TO_BE32 instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define cpu_to_be32(x) SwapEndian_32(x)\r
+\r
+ //@}\r
+\r
+ /** \name Compile-time endianness conversion */\r
+ //@{\r
+\r
+ /** Performs a conversion between a Little Endian encoded 16-bit piece of data and the\r
+ * Endianness of the currently selected CPU architecture.\r
+ *\r
+ * On little endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for compile-time conversion of data - for run time endianness\r
+ * conversion, use \ref le16_to_cpu instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define LE16_TO_CPU(x) (x)\r
+\r
+ /** Performs a conversion between a Little Endian encoded 32-bit piece of data and the\r
+ * Endianness of the currently selected CPU architecture.\r
+ *\r
+ * On little endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for compile-time conversion of data - for run time endianness\r
+ * conversion, use \ref le32_to_cpu instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define LE32_TO_CPU(x) (x)\r
+\r
+ /** Performs a conversion between a Big Endian encoded 16-bit piece of data and the\r
+ * Endianness of the currently selected CPU architecture.\r
+ *\r
+ * On big endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for compile-time conversion of data - for run-time endianness\r
+ * conversion, use \ref be16_to_cpu instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define BE16_TO_CPU(x) SWAPENDIAN_16(x)\r
+\r
+ /** Performs a conversion between a Big Endian encoded 32-bit piece of data and the\r
+ * Endianness of the currently selected CPU architecture.\r
+ *\r
+ * On big endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for compile-time conversion of data - for run-time endianness\r
+ * conversion, use \ref be32_to_cpu instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define BE32_TO_CPU(x) SWAPENDIAN_32(x)\r
+\r
+ /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it\r
+ * is in Little Endian format regardless of the currently selected CPU architecture.\r
+ *\r
+ * On little endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for compile-time conversion of data - for run-time endianness\r
+ * conversion, use \ref cpu_to_le16 instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define CPU_TO_LE16(x) (x)\r
+\r
+ /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it\r
+ * is in Little Endian format regardless of the currently selected CPU architecture.\r
+ *\r
+ * On little endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for compile-time conversion of data - for run-time endianness\r
+ * conversion, use \ref cpu_to_le32 instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define CPU_TO_LE32(x) (x)\r
+\r
+ /** Performs a conversion on a natively encoded 16-bit piece of data to ensure that it\r
+ * is in Big Endian format regardless of the currently selected CPU architecture.\r
+ *\r
+ * On big endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for compile-time conversion of data - for run-time endianness\r
+ * conversion, use \ref cpu_to_be16 instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define CPU_TO_BE16(x) SWAPENDIAN_16(x)\r
+\r
+ /** Performs a conversion on a natively encoded 32-bit piece of data to ensure that it\r
+ * is in Big Endian format regardless of the currently selected CPU architecture.\r
+ *\r
+ * On big endian architectures, this macro does nothing.\r
+ *\r
+ * \note This macro is designed for compile-time conversion of data - for run-time endianness\r
+ * conversion, use \ref cpu_to_be32 instead.\r
+ *\r
+ * \ingroup Group_EndianConversion\r
+ *\r
+ * \param[in] x Data to perform the endianness conversion on.\r
+ *\r
+ * \return Endian corrected version of the input value.\r
+ */\r
+ #define CPU_TO_BE32(x) SWAPENDIAN_32(x)\r
+\r
+ //! @}\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ /** Function to reverse the byte ordering of the individual bytes in a 16 bit value.\r
+ *\r
+ * \ingroup Group_ByteSwapping\r
+ *\r
+ * \param[in] Word Word of data whose bytes are to be swapped.\r
+ *\r
+ * \return Input data with the individual bytes reversed.\r
+ */\r
+ static inline uint16_t SwapEndian_16(const uint16_t Word) ATTR_WARN_UNUSED_RESULT ATTR_CONST;\r
+ static inline uint16_t SwapEndian_16(const uint16_t Word)\r
+ {\r
+ if (GCC_IS_COMPILE_CONST(Word))\r
+ return SWAPENDIAN_16(Word);\r
+\r
+ uint8_t Temp;\r
+\r
+ union\r
+ {\r
+ uint16_t Word;\r
+ uint8_t Bytes[2];\r
+ } Data;\r
+\r
+ Data.Word = Word;\r
+\r
+ Temp = Data.Bytes[0];\r
+ Data.Bytes[0] = Data.Bytes[1];\r
+ Data.Bytes[1] = Temp;\r
+\r
+ return Data.Word;\r
+ }\r
+\r
+ /** Function to reverse the byte ordering of the individual bytes in a 32 bit value.\r
+ *\r
+ * \ingroup Group_ByteSwapping\r
+ *\r
+ * \param[in] DWord Double word of data whose bytes are to be swapped.\r
+ *\r
+ * \return Input data with the individual bytes reversed.\r
+ */\r
+ static inline uint32_t SwapEndian_32(const uint32_t DWord) ATTR_WARN_UNUSED_RESULT ATTR_CONST;\r
+ static inline uint32_t SwapEndian_32(const uint32_t DWord)\r
+ {\r
+ if (GCC_IS_COMPILE_CONST(DWord))\r
+ return SWAPENDIAN_32(DWord);\r
+\r
+ uint8_t Temp;\r
+\r
+ union\r
+ {\r
+ uint32_t DWord;\r
+ uint8_t Bytes[4];\r
+ } Data;\r
+\r
+ Data.DWord = DWord;\r
+\r
+ Temp = Data.Bytes[0];\r
+ Data.Bytes[0] = Data.Bytes[3];\r
+ Data.Bytes[3] = Temp;\r
+\r
+ Temp = Data.Bytes[1];\r
+ Data.Bytes[1] = Data.Bytes[2];\r
+ Data.Bytes[2] = Temp;\r
+\r
+ return Data.DWord;\r
+ }\r
+\r
+ /** Function to reverse the byte ordering of the individual bytes in a n byte value.\r
+ *\r
+ * \ingroup Group_ByteSwapping\r
+ *\r
+ * \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed.\r
+ * \param[in] Length Length of the data in bytes.\r
+ *\r
+ * \return Input data with the individual bytes reversed.\r
+ */\r
+ static inline void SwapEndian_n(void* const Data,\r
+ uint8_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline void SwapEndian_n(void* const Data,\r
+ uint8_t Length)\r
+ {\r
+ uint8_t* CurrDataPos = (uint8_t*)Data;\r
+\r
+ while (Length > 1)\r
+ {\r
+ uint8_t Temp = *CurrDataPos;\r
+ *CurrDataPos = *(CurrDataPos + Length - 1);\r
+ *(CurrDataPos + Length - 1) = Temp;\r
+\r
+ CurrDataPos++;\r
+ Length -= 2;\r
+ }\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+# Doxyfile 1.8.1.2\r
+\r
+# This file describes the settings to be used by the documentation system\r
+# doxygen (www.doxygen.org) for a project.\r
+#\r
+# All text after a hash (#) is considered a comment and will be ignored.\r
+# The format is:\r
+# TAG = value [value, ...]\r
+# For lists items can also be appended using:\r
+# TAG += value [value, ...]\r
+# Values that contain spaces should be placed between quotes (" ").\r
+\r
+#---------------------------------------------------------------------------\r
+# Project related configuration options\r
+#---------------------------------------------------------------------------\r
+\r
+# This tag specifies the encoding used for all characters in the config file\r
+# that follow. The default is UTF-8 which is also the encoding used for all\r
+# text before the first occurrence of this tag. Doxygen uses libiconv (or the\r
+# iconv built into libc) for the transcoding. See\r
+# http://www.gnu.org/software/libiconv for the list of possible encodings.\r
+\r
+DOXYFILE_ENCODING = UTF-8\r
+\r
+# The PROJECT_NAME tag is a single word (or sequence of words) that should\r
+# identify the project. Note that if you do not use Doxywizard you need\r
+# to put quotes around the project name if it contains spaces.\r
+\r
+PROJECT_NAME = "LUFA Library"\r
+\r
+# The PROJECT_NUMBER tag can be used to enter a project or revision number.\r
+# This could be handy for archiving the generated documentation or\r
+# if some version control system is used.\r
+\r
+PROJECT_NUMBER = 000000\r
+\r
+# Using the PROJECT_BRIEF tag one can provide an optional one line description\r
+# for a project that appears at the top of each page and should give viewer\r
+# a quick idea about the purpose of the project. Keep the description short.\r
+\r
+PROJECT_BRIEF =\r
+\r
+# With the PROJECT_LOGO tag one can specify an logo or icon that is\r
+# included in the documentation. The maximum height of the logo should not\r
+# exceed 55 pixels and the maximum width should not exceed 200 pixels.\r
+# Doxygen will copy the logo to the output directory.\r
+\r
+PROJECT_LOGO = ./DoxygenPages/Images/LUFA_thumb.png\r
+\r
+# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)\r
+# base path where the generated documentation will be put.\r
+# If a relative path is entered, it will be relative to the location\r
+# where doxygen was started. If left blank the current directory will be used.\r
+\r
+OUTPUT_DIRECTORY = ./Documentation/\r
+\r
+# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create\r
+# 4096 sub-directories (in 2 levels) under the output directory of each output\r
+# format and will distribute the generated files over these directories.\r
+# Enabling this option can be useful when feeding doxygen a huge amount of\r
+# source files, where putting all generated files in the same directory would\r
+# otherwise cause performance problems for the file system.\r
+\r
+CREATE_SUBDIRS = NO\r
+\r
+# The OUTPUT_LANGUAGE tag is used to specify the language in which all\r
+# documentation generated by doxygen is written. Doxygen will use this\r
+# information to generate all constant output in the proper language.\r
+# The default language is English, other supported languages are:\r
+# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional,\r
+# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German,\r
+# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English\r
+# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian,\r
+# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak,\r
+# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese.\r
+\r
+OUTPUT_LANGUAGE = English\r
+\r
+# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will\r
+# include brief member descriptions after the members that are listed in\r
+# the file and class documentation (similar to JavaDoc).\r
+# Set to NO to disable this.\r
+\r
+BRIEF_MEMBER_DESC = YES\r
+\r
+# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend\r
+# the brief description of a member or function before the detailed description.\r
+# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the\r
+# brief descriptions will be completely suppressed.\r
+\r
+REPEAT_BRIEF = NO\r
+\r
+# This tag implements a quasi-intelligent brief description abbreviator\r
+# that is used to form the text in various listings. Each string\r
+# in this list, if found as the leading text of the brief description, will be\r
+# stripped from the text and the result after processing the whole list, is\r
+# used as the annotated text. Otherwise, the brief description is used as-is.\r
+# If left blank, the following values are used ("$name" is automatically\r
+# replaced with the name of the entity): "The $name class" "The $name widget"\r
+# "The $name file" "is" "provides" "specifies" "contains"\r
+# "represents" "a" "an" "the"\r
+\r
+ABBREVIATE_BRIEF = "The $name class" \\r
+ "The $name widget" \\r
+ "The $name file" \\r
+ is \\r
+ provides \\r
+ specifies \\r
+ contains \\r
+ represents \\r
+ a \\r
+ an \\r
+ the\r
+\r
+# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then\r
+# Doxygen will generate a detailed section even if there is only a brief\r
+# description.\r
+\r
+ALWAYS_DETAILED_SEC = NO\r
+\r
+# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all\r
+# inherited members of a class in the documentation of that class as if those\r
+# members were ordinary class members. Constructors, destructors and assignment\r
+# operators of the base classes will not be shown.\r
+\r
+INLINE_INHERITED_MEMB = NO\r
+\r
+# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full\r
+# path before files name in the file list and in the header files. If set\r
+# to NO the shortest path that makes the file name unique will be used.\r
+\r
+FULL_PATH_NAMES = YES\r
+\r
+# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag\r
+# can be used to strip a user-defined part of the path. Stripping is\r
+# only done if one of the specified strings matches the left-hand part of\r
+# the path. The tag can be used to show relative paths in the file list.\r
+# If left blank the directory from which doxygen is run is used as the\r
+# path to strip.\r
+\r
+STRIP_FROM_PATH =\r
+\r
+# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of\r
+# the path mentioned in the documentation of a class, which tells\r
+# the reader which header file to include in order to use a class.\r
+# If left blank only the name of the header file containing the class\r
+# definition is used. Otherwise one should specify the include paths that\r
+# are normally passed to the compiler using the -I flag.\r
+\r
+STRIP_FROM_INC_PATH =\r
+\r
+# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter\r
+# (but less readable) file names. This can be useful if your file system\r
+# doesn't support long names like on DOS, Mac, or CD-ROM.\r
+\r
+SHORT_NAMES = NO\r
+\r
+# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen\r
+# will interpret the first line (until the first dot) of a JavaDoc-style\r
+# comment as the brief description. If set to NO, the JavaDoc\r
+# comments will behave just like regular Qt-style comments\r
+# (thus requiring an explicit @brief command for a brief description.)\r
+\r
+JAVADOC_AUTOBRIEF = NO\r
+\r
+# If the QT_AUTOBRIEF tag is set to YES then Doxygen will\r
+# interpret the first line (until the first dot) of a Qt-style\r
+# comment as the brief description. If set to NO, the comments\r
+# will behave just like regular Qt-style comments (thus requiring\r
+# an explicit \brief command for a brief description.)\r
+\r
+QT_AUTOBRIEF = NO\r
+\r
+# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen\r
+# treat a multi-line C++ special comment block (i.e. a block of //! or ///\r
+# comments) as a brief description. This used to be the default behaviour.\r
+# The new default is to treat a multi-line C++ comment block as a detailed\r
+# description. Set this tag to YES if you prefer the old behaviour instead.\r
+\r
+MULTILINE_CPP_IS_BRIEF = NO\r
+\r
+# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented\r
+# member inherits the documentation from any documented member that it\r
+# re-implements.\r
+\r
+INHERIT_DOCS = YES\r
+\r
+# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce\r
+# a new page for each member. If set to NO, the documentation of a member will\r
+# be part of the file/class/namespace that contains it.\r
+\r
+SEPARATE_MEMBER_PAGES = NO\r
+\r
+# The TAB_SIZE tag can be used to set the number of spaces in a tab.\r
+# Doxygen uses this value to replace tabs by spaces in code fragments.\r
+\r
+TAB_SIZE = 4\r
+\r
+# This tag can be used to specify a number of aliases that acts\r
+# as commands in the documentation. An alias has the form "name=value".\r
+# For example adding "sideeffect=\par Side Effects:\n" will allow you to\r
+# put the command \sideeffect (or @sideeffect) in the documentation, which\r
+# will result in a user-defined paragraph with heading "Side Effects:".\r
+# You can put \n's in the value part of an alias to insert newlines.\r
+\r
+ALIASES =\r
+\r
+# This tag can be used to specify a number of word-keyword mappings (TCL only).\r
+# A mapping has the form "name=value". For example adding\r
+# "class=itcl::class" will allow you to use the command class in the\r
+# itcl::class meaning.\r
+\r
+TCL_SUBST =\r
+\r
+# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C\r
+# sources only. Doxygen will then generate output that is more tailored for C.\r
+# For instance, some of the names that are used will be different. The list\r
+# of all members will be omitted, etc.\r
+\r
+OPTIMIZE_OUTPUT_FOR_C = YES\r
+\r
+# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java\r
+# sources only. Doxygen will then generate output that is more tailored for\r
+# Java. For instance, namespaces will be presented as packages, qualified\r
+# scopes will look different, etc.\r
+\r
+OPTIMIZE_OUTPUT_JAVA = NO\r
+\r
+# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran\r
+# sources only. Doxygen will then generate output that is more tailored for\r
+# Fortran.\r
+\r
+OPTIMIZE_FOR_FORTRAN = NO\r
+\r
+# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL\r
+# sources. Doxygen will then generate output that is tailored for\r
+# VHDL.\r
+\r
+OPTIMIZE_OUTPUT_VHDL = NO\r
+\r
+# Doxygen selects the parser to use depending on the extension of the files it\r
+# parses. With this tag you can assign which parser to use for a given extension.\r
+# Doxygen has a built-in mapping, but you can override or extend it using this\r
+# tag. The format is ext=language, where ext is a file extension, and language\r
+# is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C,\r
+# C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make\r
+# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C\r
+# (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions\r
+# you also need to set FILE_PATTERNS otherwise the files are not read by doxygen.\r
+\r
+EXTENSION_MAPPING =\r
+\r
+# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all\r
+# comments according to the Markdown format, which allows for more readable\r
+# documentation. See http://daringfireball.net/projects/markdown/ for details.\r
+# The output of markdown processing is further processed by doxygen, so you\r
+# can mix doxygen, HTML, and XML commands with Markdown formatting.\r
+# Disable only in case of backward compatibilities issues.\r
+\r
+MARKDOWN_SUPPORT = NO\r
+\r
+# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want\r
+# to include (a tag file for) the STL sources as input, then you should\r
+# set this tag to YES in order to let doxygen match functions declarations and\r
+# definitions whose arguments contain STL classes (e.g. func(std::string); v.s.\r
+# func(std::string) {}). This also makes the inheritance and collaboration\r
+# diagrams that involve STL classes more complete and accurate.\r
+\r
+BUILTIN_STL_SUPPORT = NO\r
+\r
+# If you use Microsoft's C++/CLI language, you should set this option to YES to\r
+# enable parsing support.\r
+\r
+CPP_CLI_SUPPORT = NO\r
+\r
+# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only.\r
+# Doxygen will parse them like normal C++ but will assume all classes use public\r
+# instead of private inheritance when no explicit protection keyword is present.\r
+\r
+SIP_SUPPORT = NO\r
+\r
+# For Microsoft's IDL there are propget and propput attributes to indicate getter\r
+# and setter methods for a property. Setting this option to YES (the default)\r
+# will make doxygen replace the get and set methods by a property in the\r
+# documentation. This will only work if the methods are indeed getting or\r
+# setting a simple type. If this is not the case, or you want to show the\r
+# methods anyway, you should set this option to NO.\r
+\r
+IDL_PROPERTY_SUPPORT = YES\r
+\r
+# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC\r
+# tag is set to YES, then doxygen will reuse the documentation of the first\r
+# member in the group (if any) for the other members of the group. By default\r
+# all members of a group must be documented explicitly.\r
+\r
+DISTRIBUTE_GROUP_DOC = NO\r
+\r
+# Set the SUBGROUPING tag to YES (the default) to allow class member groups of\r
+# the same type (for instance a group of public functions) to be put as a\r
+# subgroup of that type (e.g. under the Public Functions section). Set it to\r
+# NO to prevent subgrouping. Alternatively, this can be done per class using\r
+# the \nosubgrouping command.\r
+\r
+SUBGROUPING = YES\r
+\r
+# When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and\r
+# unions are shown inside the group in which they are included (e.g. using\r
+# @ingroup) instead of on a separate page (for HTML and Man pages) or\r
+# section (for LaTeX and RTF).\r
+\r
+INLINE_GROUPED_CLASSES = NO\r
+\r
+# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and\r
+# unions with only public data fields will be shown inline in the documentation\r
+# of the scope in which they are defined (i.e. file, namespace, or group\r
+# documentation), provided this scope is documented. If set to NO (the default),\r
+# structs, classes, and unions are shown on a separate page (for HTML and Man\r
+# pages) or section (for LaTeX and RTF).\r
+\r
+INLINE_SIMPLE_STRUCTS = NO\r
+\r
+# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum\r
+# is documented as struct, union, or enum with the name of the typedef. So\r
+# typedef struct TypeS {} TypeT, will appear in the documentation as a struct\r
+# with name TypeT. When disabled the typedef will appear as a member of a file,\r
+# namespace, or class. And the struct will be named TypeS. This can typically\r
+# be useful for C code in case the coding convention dictates that all compound\r
+# types are typedef'ed and only the typedef is referenced, never the tag name.\r
+\r
+TYPEDEF_HIDES_STRUCT = YES\r
+\r
+# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to\r
+# determine which symbols to keep in memory and which to flush to disk.\r
+# When the cache is full, less often used symbols will be written to disk.\r
+# For small to medium size projects (<1000 input files) the default value is\r
+# probably good enough. For larger projects a too small cache size can cause\r
+# doxygen to be busy swapping symbols to and from disk most of the time\r
+# causing a significant performance penalty.\r
+# If the system has enough physical memory increasing the cache will improve the\r
+# performance by keeping more symbols in memory. Note that the value works on\r
+# a logarithmic scale so increasing the size by one will roughly double the\r
+# memory usage. The cache size is given by this formula:\r
+# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0,\r
+# corresponding to a cache size of 2^16 = 65536 symbols.\r
+\r
+SYMBOL_CACHE_SIZE = 0\r
+\r
+# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be\r
+# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given\r
+# their name and scope. Since this can be an expensive process and often the\r
+# same symbol appear multiple times in the code, doxygen keeps a cache of\r
+# pre-resolved symbols. If the cache is too small doxygen will become slower.\r
+# If the cache is too large, memory is wasted. The cache size is given by this\r
+# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0,\r
+# corresponding to a cache size of 2^16 = 65536 symbols.\r
+\r
+LOOKUP_CACHE_SIZE = 0\r
+\r
+#---------------------------------------------------------------------------\r
+# Build related configuration options\r
+#---------------------------------------------------------------------------\r
+\r
+# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in\r
+# documentation are documented, even if no documentation was available.\r
+# Private class members and static file members will be hidden unless\r
+# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES\r
+\r
+EXTRACT_ALL = YES\r
+\r
+# If the EXTRACT_PRIVATE tag is set to YES all private members of a class\r
+# will be included in the documentation.\r
+\r
+EXTRACT_PRIVATE = YES\r
+\r
+# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation.\r
+\r
+EXTRACT_PACKAGE = NO\r
+\r
+# If the EXTRACT_STATIC tag is set to YES all static members of a file\r
+# will be included in the documentation.\r
+\r
+EXTRACT_STATIC = YES\r
+\r
+# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)\r
+# defined locally in source files will be included in the documentation.\r
+# If set to NO only classes defined in header files are included.\r
+\r
+EXTRACT_LOCAL_CLASSES = YES\r
+\r
+# This flag is only useful for Objective-C code. When set to YES local\r
+# methods, which are defined in the implementation section but not in\r
+# the interface are included in the documentation.\r
+# If set to NO (the default) only methods in the interface are included.\r
+\r
+EXTRACT_LOCAL_METHODS = NO\r
+\r
+# If this flag is set to YES, the members of anonymous namespaces will be\r
+# extracted and appear in the documentation as a namespace called\r
+# 'anonymous_namespace{file}', where file will be replaced with the base\r
+# name of the file that contains the anonymous namespace. By default\r
+# anonymous namespaces are hidden.\r
+\r
+EXTRACT_ANON_NSPACES = NO\r
+\r
+# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all\r
+# undocumented members of documented classes, files or namespaces.\r
+# If set to NO (the default) these members will be included in the\r
+# various overviews, but no documentation section is generated.\r
+# This option has no effect if EXTRACT_ALL is enabled.\r
+\r
+HIDE_UNDOC_MEMBERS = NO\r
+\r
+# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all\r
+# undocumented classes that are normally visible in the class hierarchy.\r
+# If set to NO (the default) these classes will be included in the various\r
+# overviews. This option has no effect if EXTRACT_ALL is enabled.\r
+\r
+HIDE_UNDOC_CLASSES = NO\r
+\r
+# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all\r
+# friend (class|struct|union) declarations.\r
+# If set to NO (the default) these declarations will be included in the\r
+# documentation.\r
+\r
+HIDE_FRIEND_COMPOUNDS = NO\r
+\r
+# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any\r
+# documentation blocks found inside the body of a function.\r
+# If set to NO (the default) these blocks will be appended to the\r
+# function's detailed documentation block.\r
+\r
+HIDE_IN_BODY_DOCS = NO\r
+\r
+# The INTERNAL_DOCS tag determines if documentation\r
+# that is typed after a \internal command is included. If the tag is set\r
+# to NO (the default) then the documentation will be excluded.\r
+# Set it to YES to include the internal documentation.\r
+\r
+INTERNAL_DOCS = NO\r
+\r
+# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate\r
+# file names in lower-case letters. If set to YES upper-case letters are also\r
+# allowed. This is useful if you have classes or files whose names only differ\r
+# in case and if your file system supports case sensitive file names. Windows\r
+# and Mac users are advised to set this option to NO.\r
+\r
+CASE_SENSE_NAMES = NO\r
+\r
+# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen\r
+# will show members with their full class and namespace scopes in the\r
+# documentation. If set to YES the scope will be hidden.\r
+\r
+HIDE_SCOPE_NAMES = NO\r
+\r
+# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen\r
+# will put a list of the files that are included by a file in the documentation\r
+# of that file.\r
+\r
+SHOW_INCLUDE_FILES = YES\r
+\r
+# If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen\r
+# will list include files with double quotes in the documentation\r
+# rather than with sharp brackets.\r
+\r
+FORCE_LOCAL_INCLUDES = NO\r
+\r
+# If the INLINE_INFO tag is set to YES (the default) then a tag [inline]\r
+# is inserted in the documentation for inline members.\r
+\r
+INLINE_INFO = YES\r
+\r
+# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen\r
+# will sort the (detailed) documentation of file and class members\r
+# alphabetically by member name. If set to NO the members will appear in\r
+# declaration order.\r
+\r
+SORT_MEMBER_DOCS = YES\r
+\r
+# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the\r
+# brief documentation of file, namespace and class members alphabetically\r
+# by member name. If set to NO (the default) the members will appear in\r
+# declaration order.\r
+\r
+SORT_BRIEF_DOCS = NO\r
+\r
+# If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen\r
+# will sort the (brief and detailed) documentation of class members so that\r
+# constructors and destructors are listed first. If set to NO (the default)\r
+# the constructors will appear in the respective orders defined by\r
+# SORT_MEMBER_DOCS and SORT_BRIEF_DOCS.\r
+# This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO\r
+# and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO.\r
+\r
+SORT_MEMBERS_CTORS_1ST = NO\r
+\r
+# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the\r
+# hierarchy of group names into alphabetical order. If set to NO (the default)\r
+# the group names will appear in their defined order.\r
+\r
+SORT_GROUP_NAMES = YES\r
+\r
+# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be\r
+# sorted by fully-qualified names, including namespaces. If set to\r
+# NO (the default), the class list will be sorted only by class name,\r
+# not including the namespace part.\r
+# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES.\r
+# Note: This option applies only to the class list, not to the\r
+# alphabetical list.\r
+\r
+SORT_BY_SCOPE_NAME = NO\r
+\r
+# If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to\r
+# do proper type resolution of all parameters of a function it will reject a\r
+# match between the prototype and the implementation of a member function even\r
+# if there is only one candidate or it is obvious which candidate to choose\r
+# by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen\r
+# will still accept a match between prototype and implementation in such cases.\r
+\r
+STRICT_PROTO_MATCHING = NO\r
+\r
+# The GENERATE_TODOLIST tag can be used to enable (YES) or\r
+# disable (NO) the todo list. This list is created by putting \todo\r
+# commands in the documentation.\r
+\r
+GENERATE_TODOLIST = NO\r
+\r
+# The GENERATE_TESTLIST tag can be used to enable (YES) or\r
+# disable (NO) the test list. This list is created by putting \test\r
+# commands in the documentation.\r
+\r
+GENERATE_TESTLIST = NO\r
+\r
+# The GENERATE_BUGLIST tag can be used to enable (YES) or\r
+# disable (NO) the bug list. This list is created by putting \bug\r
+# commands in the documentation.\r
+\r
+GENERATE_BUGLIST = NO\r
+\r
+# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or\r
+# disable (NO) the deprecated list. This list is created by putting\r
+# \deprecated commands in the documentation.\r
+\r
+GENERATE_DEPRECATEDLIST= YES\r
+\r
+# The ENABLED_SECTIONS tag can be used to enable conditional\r
+# documentation sections, marked by \if sectionname ... \endif.\r
+\r
+ENABLED_SECTIONS =\r
+\r
+# The MAX_INITIALIZER_LINES tag determines the maximum number of lines\r
+# the initial value of a variable or macro consists of for it to appear in\r
+# the documentation. If the initializer consists of more lines than specified\r
+# here it will be hidden. Use a value of 0 to hide initializers completely.\r
+# The appearance of the initializer of individual variables and macros in the\r
+# documentation can be controlled using \showinitializer or \hideinitializer\r
+# command in the documentation regardless of this setting.\r
+\r
+MAX_INITIALIZER_LINES = 15\r
+\r
+# Set the SHOW_USED_FILES tag to NO to disable the list of files generated\r
+# at the bottom of the documentation of classes and structs. If set to YES the\r
+# list will mention the files that were used to generate the documentation.\r
+\r
+SHOW_USED_FILES = YES\r
+\r
+# Set the SHOW_FILES tag to NO to disable the generation of the Files page.\r
+# This will remove the Files entry from the Quick Index and from the\r
+# Folder Tree View (if specified). The default is YES.\r
+\r
+SHOW_FILES = YES\r
+\r
+# Set the SHOW_NAMESPACES tag to NO to disable the generation of the\r
+# Namespaces page.\r
+# This will remove the Namespaces entry from the Quick Index\r
+# and from the Folder Tree View (if specified). The default is YES.\r
+\r
+SHOW_NAMESPACES = YES\r
+\r
+# The FILE_VERSION_FILTER tag can be used to specify a program or script that\r
+# doxygen should invoke to get the current version for each file (typically from\r
+# the version control system). Doxygen will invoke the program by executing (via\r
+# popen()) the command <command> <input-file>, where <command> is the value of\r
+# the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file\r
+# provided by doxygen. Whatever the program writes to standard output\r
+# is used as the file version. See the manual for examples.\r
+\r
+FILE_VERSION_FILTER =\r
+\r
+# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed\r
+# by doxygen. The layout file controls the global structure of the generated\r
+# output files in an output format independent way. To create the layout file\r
+# that represents doxygen's defaults, run doxygen with the -l option.\r
+# You can optionally specify a file name after the option, if omitted\r
+# DoxygenLayout.xml will be used as the name of the layout file.\r
+\r
+LAYOUT_FILE =\r
+\r
+# The CITE_BIB_FILES tag can be used to specify one or more bib files\r
+# containing the references data. This must be a list of .bib files. The\r
+# .bib extension is automatically appended if omitted. Using this command\r
+# requires the bibtex tool to be installed. See also\r
+# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style\r
+# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this\r
+# feature you need bibtex and perl available in the search path.\r
+\r
+CITE_BIB_FILES =\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to warning and progress messages\r
+#---------------------------------------------------------------------------\r
+\r
+# The QUIET tag can be used to turn on/off the messages that are generated\r
+# by doxygen. Possible values are YES and NO. If left blank NO is used.\r
+\r
+QUIET = YES\r
+\r
+# The WARNINGS tag can be used to turn on/off the warning messages that are\r
+# generated by doxygen. Possible values are YES and NO. If left blank\r
+# NO is used.\r
+\r
+WARNINGS = YES\r
+\r
+# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings\r
+# for undocumented members. If EXTRACT_ALL is set to YES then this flag will\r
+# automatically be disabled.\r
+\r
+WARN_IF_UNDOCUMENTED = YES\r
+\r
+# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for\r
+# potential errors in the documentation, such as not documenting some\r
+# parameters in a documented function, or documenting parameters that\r
+# don't exist or using markup commands wrongly.\r
+\r
+WARN_IF_DOC_ERROR = YES\r
+\r
+# The WARN_NO_PARAMDOC option can be enabled to get warnings for\r
+# functions that are documented, but have no documentation for their parameters\r
+# or return value. If set to NO (the default) doxygen will only warn about\r
+# wrong or incomplete parameter documentation, but not about the absence of\r
+# documentation.\r
+\r
+WARN_NO_PARAMDOC = YES\r
+\r
+# The WARN_FORMAT tag determines the format of the warning messages that\r
+# doxygen can produce. The string should contain the $file, $line, and $text\r
+# tags, which will be replaced by the file and line number from which the\r
+# warning originated and the warning text. Optionally the format may contain\r
+# $version, which will be replaced by the version of the file (if it could\r
+# be obtained via FILE_VERSION_FILTER)\r
+\r
+WARN_FORMAT = "$file:$line: $text"\r
+\r
+# The WARN_LOGFILE tag can be used to specify a file to which warning\r
+# and error messages should be written. If left blank the output is written\r
+# to stderr.\r
+\r
+WARN_LOGFILE =\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the input files\r
+#---------------------------------------------------------------------------\r
+\r
+# The INPUT tag can be used to specify the files and/or directories that contain\r
+# documented source files. You may enter file names like "myfile.cpp" or\r
+# directories like "/usr/src/myproject". Separate the files or directories\r
+# with spaces.\r
+\r
+INPUT = ./\r
+\r
+# This tag can be used to specify the character encoding of the source files\r
+# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is\r
+# also the default input encoding. Doxygen uses libiconv (or the iconv built\r
+# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for\r
+# the list of possible encodings.\r
+\r
+INPUT_ENCODING = UTF-8\r
+\r
+# If the value of the INPUT tag contains directories, you can use the\r
+# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp\r
+# and *.h) to filter out the source-files in the directories. If left\r
+# blank the following patterns are tested:\r
+# *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh\r
+# *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py\r
+# *.f90 *.f *.for *.vhd *.vhdl\r
+\r
+FILE_PATTERNS = *.h \\r
+ *.txt\r
+\r
+# The RECURSIVE tag can be used to turn specify whether or not subdirectories\r
+# should be searched for input files as well. Possible values are YES and NO.\r
+# If left blank NO is used.\r
+\r
+RECURSIVE = YES\r
+\r
+# The EXCLUDE tag can be used to specify files and/or directories that should be\r
+# excluded from the INPUT source files. This way you can easily exclude a\r
+# subdirectory from a directory tree whose root is specified with the INPUT tag.\r
+# Note that relative paths are relative to the directory from which doxygen is\r
+# run.\r
+\r
+EXCLUDE = Documentation/ \\r
+ License.txt\r
+\r
+# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or\r
+# directories that are symbolic links (a Unix file system feature) are excluded\r
+# from the input.\r
+\r
+EXCLUDE_SYMLINKS = NO\r
+\r
+# If the value of the INPUT tag contains directories, you can use the\r
+# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude\r
+# certain files from those directories. Note that the wildcards are matched\r
+# against the file with absolute path, so to exclude all test directories\r
+# for example use the pattern */test/*\r
+\r
+EXCLUDE_PATTERNS =\r
+\r
+# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names\r
+# (namespaces, classes, functions, etc.) that should be excluded from the\r
+# output. The symbol name can be a fully qualified name, a word, or if the\r
+# wildcard * is used, a substring. Examples: ANamespace, AClass,\r
+# AClass::ANamespace, ANamespace::*Test\r
+\r
+EXCLUDE_SYMBOLS = _* \\r
+ __*\r
+\r
+# The EXAMPLE_PATH tag can be used to specify one or more files or\r
+# directories that contain example code fragments that are included (see\r
+# the \include command).\r
+\r
+EXAMPLE_PATH = ./ \\r
+ CodeTemplates/\r
+\r
+# If the value of the EXAMPLE_PATH tag contains directories, you can use the\r
+# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp\r
+# and *.h) to filter out the source-files in the directories. If left\r
+# blank all files are included.\r
+\r
+EXAMPLE_PATTERNS = *\r
+\r
+# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be\r
+# searched for input files to be used with the \include or \dontinclude\r
+# commands irrespective of the value of the RECURSIVE tag.\r
+# Possible values are YES and NO. If left blank NO is used.\r
+\r
+EXAMPLE_RECURSIVE = NO\r
+\r
+# The IMAGE_PATH tag can be used to specify one or more files or\r
+# directories that contain image that are included in the documentation (see\r
+# the \image command).\r
+\r
+IMAGE_PATH = ./\r
+\r
+# The INPUT_FILTER tag can be used to specify a program that doxygen should\r
+# invoke to filter for each input file. Doxygen will invoke the filter program\r
+# by executing (via popen()) the command <filter> <input-file>, where <filter>\r
+# is the value of the INPUT_FILTER tag, and <input-file> is the name of an\r
+# input file. Doxygen will then use the output that the filter program writes\r
+# to standard output.\r
+# If FILTER_PATTERNS is specified, this tag will be\r
+# ignored.\r
+\r
+INPUT_FILTER =\r
+\r
+# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern\r
+# basis.\r
+# Doxygen will compare the file name with each pattern and apply the\r
+# filter if there is a match.\r
+# The filters are a list of the form:\r
+# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further\r
+# info on how filters are used. If FILTER_PATTERNS is empty or if\r
+# non of the patterns match the file name, INPUT_FILTER is applied.\r
+\r
+FILTER_PATTERNS =\r
+\r
+# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using\r
+# INPUT_FILTER) will be used to filter the input files when producing source\r
+# files to browse (i.e. when SOURCE_BROWSER is set to YES).\r
+\r
+FILTER_SOURCE_FILES = NO\r
+\r
+# The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file\r
+# pattern. A pattern will override the setting for FILTER_PATTERN (if any)\r
+# and it is also possible to disable source filtering for a specific pattern\r
+# using *.ext= (so without naming a filter). This option only has effect when\r
+# FILTER_SOURCE_FILES is enabled.\r
+\r
+FILTER_SOURCE_PATTERNS =\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to source browsing\r
+#---------------------------------------------------------------------------\r
+\r
+# If the SOURCE_BROWSER tag is set to YES then a list of source files will\r
+# be generated. Documented entities will be cross-referenced with these sources.\r
+# Note: To get rid of all source code in the generated output, make sure also\r
+# VERBATIM_HEADERS is set to NO.\r
+\r
+SOURCE_BROWSER = NO\r
+\r
+# Setting the INLINE_SOURCES tag to YES will include the body\r
+# of functions and classes directly in the documentation.\r
+\r
+INLINE_SOURCES = NO\r
+\r
+# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct\r
+# doxygen to hide any special comment blocks from generated source code\r
+# fragments. Normal C, C++ and Fortran comments will always remain visible.\r
+\r
+STRIP_CODE_COMMENTS = YES\r
+\r
+# If the REFERENCED_BY_RELATION tag is set to YES\r
+# then for each documented function all documented\r
+# functions referencing it will be listed.\r
+\r
+REFERENCED_BY_RELATION = NO\r
+\r
+# If the REFERENCES_RELATION tag is set to YES\r
+# then for each documented function all documented entities\r
+# called/used by that function will be listed.\r
+\r
+REFERENCES_RELATION = NO\r
+\r
+# If the REFERENCES_LINK_SOURCE tag is set to YES (the default)\r
+# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from\r
+# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will\r
+# link to the source code.\r
+# Otherwise they will link to the documentation.\r
+\r
+REFERENCES_LINK_SOURCE = NO\r
+\r
+# If the USE_HTAGS tag is set to YES then the references to source code\r
+# will point to the HTML generated by the htags(1) tool instead of doxygen\r
+# built-in source browser. The htags tool is part of GNU's global source\r
+# tagging system (see http://www.gnu.org/software/global/global.html). You\r
+# will need version 4.8.6 or higher.\r
+\r
+USE_HTAGS = NO\r
+\r
+# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen\r
+# will generate a verbatim copy of the header file for each class for\r
+# which an include is specified. Set to NO to disable this.\r
+\r
+VERBATIM_HEADERS = NO\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the alphabetical class index\r
+#---------------------------------------------------------------------------\r
+\r
+# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index\r
+# of all compounds will be generated. Enable this if the project\r
+# contains a lot of classes, structs, unions or interfaces.\r
+\r
+ALPHABETICAL_INDEX = YES\r
+\r
+# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then\r
+# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns\r
+# in which this list will be split (can be a number in the range [1..20])\r
+\r
+COLS_IN_ALPHA_INDEX = 5\r
+\r
+# In case all classes in a project start with a common prefix, all\r
+# classes will be put under the same header in the alphabetical index.\r
+# The IGNORE_PREFIX tag can be used to specify one or more prefixes that\r
+# should be ignored while generating the index headers.\r
+\r
+IGNORE_PREFIX =\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the HTML output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_HTML tag is set to YES (the default) Doxygen will\r
+# generate HTML output.\r
+\r
+GENERATE_HTML = YES\r
+\r
+# The HTML_OUTPUT tag is used to specify where the HTML docs will be put.\r
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be\r
+# put in front of it. If left blank `html' will be used as the default path.\r
+\r
+HTML_OUTPUT = html\r
+\r
+# The HTML_FILE_EXTENSION tag can be used to specify the file extension for\r
+# each generated HTML page (for example: .htm,.php,.asp). If it is left blank\r
+# doxygen will generate files with .html extension.\r
+\r
+HTML_FILE_EXTENSION = .html\r
+\r
+# The HTML_HEADER tag can be used to specify a personal HTML header for\r
+# each generated HTML page. If it is left blank doxygen will generate a\r
+# standard header. Note that when using a custom header you are responsible\r
+# for the proper inclusion of any scripts and style sheets that doxygen\r
+# needs, which is dependent on the configuration options used.\r
+# It is advised to generate a default header using "doxygen -w html\r
+# header.html footer.html stylesheet.css YourConfigFile" and then modify\r
+# that header. Note that the header is subject to change so you typically\r
+# have to redo this when upgrading to a newer version of doxygen or when\r
+# changing the value of configuration settings such as GENERATE_TREEVIEW!\r
+\r
+HTML_HEADER =\r
+\r
+# The HTML_FOOTER tag can be used to specify a personal HTML footer for\r
+# each generated HTML page. If it is left blank doxygen will generate a\r
+# standard footer.\r
+\r
+HTML_FOOTER = ./DoxygenPages/Style/Footer.htm\r
+\r
+# The HTML_STYLESHEET tag can be used to specify a user-defined cascading\r
+# style sheet that is used by each HTML page. It can be used to\r
+# fine-tune the look of the HTML output. If the tag is left blank doxygen\r
+# will generate a default style sheet. Note that doxygen will try to copy\r
+# the style sheet file to the HTML output directory, so don't put your own\r
+# style sheet in the HTML output directory as well, or it will be erased!\r
+\r
+HTML_STYLESHEET = ./DoxygenPages/Style/Style.css\r
+\r
+# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or\r
+# other source files which should be copied to the HTML output directory. Note\r
+# that these files will be copied to the base HTML output directory. Use the\r
+# $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these\r
+# files. In the HTML_STYLESHEET file, use the file name only. Also note that\r
+# the files will be copied as-is; there are no commands or markers available.\r
+\r
+HTML_EXTRA_FILES =\r
+\r
+# The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.\r
+# Doxygen will adjust the colors in the style sheet and background images\r
+# according to this color. Hue is specified as an angle on a colorwheel,\r
+# see http://en.wikipedia.org/wiki/Hue for more information.\r
+# For instance the value 0 represents red, 60 is yellow, 120 is green,\r
+# 180 is cyan, 240 is blue, 300 purple, and 360 is red again.\r
+# The allowed range is 0 to 359.\r
+\r
+HTML_COLORSTYLE_HUE = 220\r
+\r
+# The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of\r
+# the colors in the HTML output. For a value of 0 the output will use\r
+# grayscales only. A value of 255 will produce the most vivid colors.\r
+\r
+HTML_COLORSTYLE_SAT = 120\r
+\r
+# The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to\r
+# the luminance component of the colors in the HTML output. Values below\r
+# 100 gradually make the output lighter, whereas values above 100 make\r
+# the output darker. The value divided by 100 is the actual gamma applied,\r
+# so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2,\r
+# and 100 does not change the gamma.\r
+\r
+HTML_COLORSTYLE_GAMMA = 80\r
+\r
+# If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML\r
+# page will contain the date and time when the page was generated. Setting\r
+# this to NO can help when comparing the output of multiple runs.\r
+\r
+HTML_TIMESTAMP = NO\r
+\r
+# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML\r
+# documentation will contain sections that can be hidden and shown after the\r
+# page has loaded.\r
+\r
+HTML_DYNAMIC_SECTIONS = YES\r
+\r
+# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of\r
+# entries shown in the various tree structured indices initially; the user\r
+# can expand and collapse entries dynamically later on. Doxygen will expand\r
+# the tree to such a level that at most the specified number of entries are\r
+# visible (unless a fully collapsed tree already exceeds this amount).\r
+# So setting the number of entries 1 will produce a full collapsed tree by\r
+# default. 0 is a special value representing an infinite number of entries\r
+# and will result in a full expanded tree by default.\r
+\r
+HTML_INDEX_NUM_ENTRIES = 100\r
+\r
+# If the GENERATE_DOCSET tag is set to YES, additional index files\r
+# will be generated that can be used as input for Apple's Xcode 3\r
+# integrated development environment, introduced with OSX 10.5 (Leopard).\r
+# To create a documentation set, doxygen will generate a Makefile in the\r
+# HTML output directory. Running make will produce the docset in that\r
+# directory and running "make install" will install the docset in\r
+# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find\r
+# it at startup.\r
+# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html\r
+# for more information.\r
+\r
+GENERATE_DOCSET = NO\r
+\r
+# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the\r
+# feed. A documentation feed provides an umbrella under which multiple\r
+# documentation sets from a single provider (such as a company or product suite)\r
+# can be grouped.\r
+\r
+DOCSET_FEEDNAME = "Doxygen generated docs"\r
+\r
+# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that\r
+# should uniquely identify the documentation set bundle. This should be a\r
+# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen\r
+# will append .docset to the name.\r
+\r
+DOCSET_BUNDLE_ID = org.doxygen.Project\r
+\r
+# When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify\r
+# the documentation publisher. This should be a reverse domain-name style\r
+# string, e.g. com.mycompany.MyDocSet.documentation.\r
+\r
+DOCSET_PUBLISHER_ID = com.lufa-lib.library.documentation\r
+\r
+# The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher.\r
+\r
+DOCSET_PUBLISHER_NAME = DeanCamera\r
+\r
+# If the GENERATE_HTMLHELP tag is set to YES, additional index files\r
+# will be generated that can be used as input for tools like the\r
+# Microsoft HTML help workshop to generate a compiled HTML help file (.chm)\r
+# of the generated HTML documentation.\r
+\r
+GENERATE_HTMLHELP = NO\r
+\r
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can\r
+# be used to specify the file name of the resulting .chm file. You\r
+# can add a path in front of the file if the result should not be\r
+# written to the html output directory.\r
+\r
+CHM_FILE = ../LUFA.chm\r
+\r
+# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can\r
+# be used to specify the location (absolute path including file name) of\r
+# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run\r
+# the HTML help compiler on the generated index.hhp.\r
+\r
+HHC_LOCATION =\r
+\r
+# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag\r
+# controls if a separate .chi index file is generated (YES) or that\r
+# it should be included in the master .chm file (NO).\r
+\r
+GENERATE_CHI = NO\r
+\r
+# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING\r
+# is used to encode HtmlHelp index (hhk), content (hhc) and project file\r
+# content.\r
+\r
+CHM_INDEX_ENCODING =\r
+\r
+# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag\r
+# controls whether a binary table of contents is generated (YES) or a\r
+# normal table of contents (NO) in the .chm file.\r
+\r
+BINARY_TOC = NO\r
+\r
+# The TOC_EXPAND flag can be set to YES to add extra items for group members\r
+# to the contents of the HTML help documentation and to the tree view.\r
+\r
+TOC_EXPAND = YES\r
+\r
+# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and\r
+# QHP_VIRTUAL_FOLDER are set, an additional index file will be generated\r
+# that can be used as input for Qt's qhelpgenerator to generate a\r
+# Qt Compressed Help (.qch) of the generated HTML documentation.\r
+\r
+GENERATE_QHP = NO\r
+\r
+# If the QHG_LOCATION tag is specified, the QCH_FILE tag can\r
+# be used to specify the file name of the resulting .qch file.\r
+# The path specified is relative to the HTML output folder.\r
+\r
+QCH_FILE =\r
+\r
+# The QHP_NAMESPACE tag specifies the namespace to use when generating\r
+# Qt Help Project output. For more information please see\r
+# http://doc.trolltech.com/qthelpproject.html#namespace\r
+\r
+QHP_NAMESPACE = org.doxygen.Project\r
+\r
+# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating\r
+# Qt Help Project output. For more information please see\r
+# http://doc.trolltech.com/qthelpproject.html#virtual-folders\r
+\r
+QHP_VIRTUAL_FOLDER = doc\r
+\r
+# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to\r
+# add. For more information please see\r
+# http://doc.trolltech.com/qthelpproject.html#custom-filters\r
+\r
+QHP_CUST_FILTER_NAME =\r
+\r
+# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the\r
+# custom filter to add. For more information please see\r
+# <a href="http://doc.trolltech.com/qthelpproject.html#custom-filters">\r
+# Qt Help Project / Custom Filters</a>.\r
+\r
+QHP_CUST_FILTER_ATTRS =\r
+\r
+# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this\r
+# project's\r
+# filter section matches.\r
+# <a href="http://doc.trolltech.com/qthelpproject.html#filter-attributes">\r
+# Qt Help Project / Filter Attributes</a>.\r
+\r
+QHP_SECT_FILTER_ATTRS =\r
+\r
+# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can\r
+# be used to specify the location of Qt's qhelpgenerator.\r
+# If non-empty doxygen will try to run qhelpgenerator on the generated\r
+# .qhp file.\r
+\r
+QHG_LOCATION =\r
+\r
+# If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files\r
+# will be generated, which together with the HTML files, form an Eclipse help\r
+# plugin. To install this plugin and make it available under the help contents\r
+# menu in Eclipse, the contents of the directory containing the HTML and XML\r
+# files needs to be copied into the plugins directory of eclipse. The name of\r
+# the directory within the plugins directory should be the same as\r
+# the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before\r
+# the help appears.\r
+\r
+GENERATE_ECLIPSEHELP = NO\r
+\r
+# A unique identifier for the eclipse help plugin. When installing the plugin\r
+# the directory name containing the HTML and XML files should also have\r
+# this name.\r
+\r
+ECLIPSE_DOC_ID = org.doxygen.Project\r
+\r
+# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs)\r
+# at top of each HTML page. The value NO (the default) enables the index and\r
+# the value YES disables it. Since the tabs have the same information as the\r
+# navigation tree you can set this option to NO if you already set\r
+# GENERATE_TREEVIEW to YES.\r
+\r
+DISABLE_INDEX = YES\r
+\r
+# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index\r
+# structure should be generated to display hierarchical information.\r
+# If the tag value is set to YES, a side panel will be generated\r
+# containing a tree-like index structure (just like the one that\r
+# is generated for HTML Help). For this to work a browser that supports\r
+# JavaScript, DHTML, CSS and frames is required (i.e. any modern browser).\r
+# Windows users are probably better off using the HTML help feature.\r
+# Since the tree basically has the same information as the tab index you\r
+# could consider to set DISABLE_INDEX to NO when enabling this option.\r
+\r
+GENERATE_TREEVIEW = YES\r
+\r
+# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values\r
+# (range [0,1..20]) that doxygen will group on one line in the generated HTML\r
+# documentation. Note that a value of 0 will completely suppress the enum\r
+# values from appearing in the overview section.\r
+\r
+ENUM_VALUES_PER_LINE = 1\r
+\r
+# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be\r
+# used to set the initial width (in pixels) of the frame in which the tree\r
+# is shown.\r
+\r
+TREEVIEW_WIDTH = 300\r
+\r
+# When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open\r
+# links to external symbols imported via tag files in a separate window.\r
+\r
+EXT_LINKS_IN_WINDOW = NO\r
+\r
+# Use this tag to change the font size of Latex formulas included\r
+# as images in the HTML documentation. The default is 10. Note that\r
+# when you change the font size after a successful doxygen run you need\r
+# to manually remove any form_*.png images from the HTML output directory\r
+# to force them to be regenerated.\r
+\r
+FORMULA_FONTSIZE = 10\r
+\r
+# Use the FORMULA_TRANPARENT tag to determine whether or not the images\r
+# generated for formulas are transparent PNGs. Transparent PNGs are\r
+# not supported properly for IE 6.0, but are supported on all modern browsers.\r
+# Note that when changing this option you need to delete any form_*.png files\r
+# in the HTML output before the changes have effect.\r
+\r
+FORMULA_TRANSPARENT = YES\r
+\r
+# Enable the USE_MATHJAX option to render LaTeX formulas using MathJax\r
+# (see http://www.mathjax.org) which uses client side Javascript for the\r
+# rendering instead of using prerendered bitmaps. Use this if you do not\r
+# have LaTeX installed or if you want to formulas look prettier in the HTML\r
+# output. When enabled you may also need to install MathJax separately and\r
+# configure the path to it using the MATHJAX_RELPATH option.\r
+\r
+USE_MATHJAX = NO\r
+\r
+# When MathJax is enabled you need to specify the location relative to the\r
+# HTML output directory using the MATHJAX_RELPATH option. The destination\r
+# directory should contain the MathJax.js script. For instance, if the mathjax\r
+# directory is located at the same level as the HTML output directory, then\r
+# MATHJAX_RELPATH should be ../mathjax. The default value points to\r
+# the MathJax Content Delivery Network so you can quickly see the result without\r
+# installing MathJax.\r
+# However, it is strongly recommended to install a local\r
+# copy of MathJax from http://www.mathjax.org before deployment.\r
+\r
+MATHJAX_RELPATH = http://www.mathjax.org/mathjax\r
+\r
+# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension\r
+# names that should be enabled during MathJax rendering.\r
+\r
+MATHJAX_EXTENSIONS =\r
+\r
+# When the SEARCHENGINE tag is enabled doxygen will generate a search box\r
+# for the HTML output. The underlying search engine uses javascript\r
+# and DHTML and should work on any modern browser. Note that when using\r
+# HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets\r
+# (GENERATE_DOCSET) there is already a search function so this one should\r
+# typically be disabled. For large projects the javascript based search engine\r
+# can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution.\r
+\r
+SEARCHENGINE = YES\r
+\r
+# When the SERVER_BASED_SEARCH tag is enabled the search engine will be\r
+# implemented using a PHP enabled web server instead of at the web client\r
+# using Javascript. Doxygen will generate the search PHP script and index\r
+# file to put on the web server. The advantage of the server\r
+# based approach is that it scales better to large projects and allows\r
+# full text search. The disadvantages are that it is more difficult to setup\r
+# and does not have live searching capabilities.\r
+\r
+SERVER_BASED_SEARCH = NO\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the LaTeX output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will\r
+# generate Latex output.\r
+\r
+GENERATE_LATEX = NO\r
+\r
+# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put.\r
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be\r
+# put in front of it. If left blank `latex' will be used as the default path.\r
+\r
+LATEX_OUTPUT = latex\r
+\r
+# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be\r
+# invoked. If left blank `latex' will be used as the default command name.\r
+# Note that when enabling USE_PDFLATEX this option is only used for\r
+# generating bitmaps for formulas in the HTML output, but not in the\r
+# Makefile that is written to the output directory.\r
+\r
+LATEX_CMD_NAME = latex\r
+\r
+# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to\r
+# generate index for LaTeX. If left blank `makeindex' will be used as the\r
+# default command name.\r
+\r
+MAKEINDEX_CMD_NAME = makeindex\r
+\r
+# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact\r
+# LaTeX documents. This may be useful for small projects and may help to\r
+# save some trees in general.\r
+\r
+COMPACT_LATEX = NO\r
+\r
+# The PAPER_TYPE tag can be used to set the paper type that is used\r
+# by the printer. Possible values are: a4, letter, legal and\r
+# executive. If left blank a4wide will be used.\r
+\r
+PAPER_TYPE = a4wide\r
+\r
+# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX\r
+# packages that should be included in the LaTeX output.\r
+\r
+EXTRA_PACKAGES =\r
+\r
+# The LATEX_HEADER tag can be used to specify a personal LaTeX header for\r
+# the generated latex document. The header should contain everything until\r
+# the first chapter. If it is left blank doxygen will generate a\r
+# standard header. Notice: only use this tag if you know what you are doing!\r
+\r
+LATEX_HEADER =\r
+\r
+# The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for\r
+# the generated latex document. The footer should contain everything after\r
+# the last chapter. If it is left blank doxygen will generate a\r
+# standard footer. Notice: only use this tag if you know what you are doing!\r
+\r
+LATEX_FOOTER =\r
+\r
+# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated\r
+# is prepared for conversion to pdf (using ps2pdf). The pdf file will\r
+# contain links (just like the HTML output) instead of page references\r
+# This makes the output suitable for online browsing using a pdf viewer.\r
+\r
+PDF_HYPERLINKS = YES\r
+\r
+# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of\r
+# plain latex in the generated Makefile. Set this option to YES to get a\r
+# higher quality PDF documentation.\r
+\r
+USE_PDFLATEX = YES\r
+\r
+# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode.\r
+# command to the generated LaTeX files. This will instruct LaTeX to keep\r
+# running if errors occur, instead of asking the user for help.\r
+# This option is also used when generating formulas in HTML.\r
+\r
+LATEX_BATCHMODE = NO\r
+\r
+# If LATEX_HIDE_INDICES is set to YES then doxygen will not\r
+# include the index chapters (such as File Index, Compound Index, etc.)\r
+# in the output.\r
+\r
+LATEX_HIDE_INDICES = NO\r
+\r
+# If LATEX_SOURCE_CODE is set to YES then doxygen will include\r
+# source code with syntax highlighting in the LaTeX output.\r
+# Note that which sources are shown also depends on other settings\r
+# such as SOURCE_BROWSER.\r
+\r
+LATEX_SOURCE_CODE = NO\r
+\r
+# The LATEX_BIB_STYLE tag can be used to specify the style to use for the\r
+# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See\r
+# http://en.wikipedia.org/wiki/BibTeX for more info.\r
+\r
+LATEX_BIB_STYLE = plain\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the RTF output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output\r
+# The RTF output is optimized for Word 97 and may not look very pretty with\r
+# other RTF readers or editors.\r
+\r
+GENERATE_RTF = NO\r
+\r
+# The RTF_OUTPUT tag is used to specify where the RTF docs will be put.\r
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be\r
+# put in front of it. If left blank `rtf' will be used as the default path.\r
+\r
+RTF_OUTPUT = rtf\r
+\r
+# If the COMPACT_RTF tag is set to YES Doxygen generates more compact\r
+# RTF documents. This may be useful for small projects and may help to\r
+# save some trees in general.\r
+\r
+COMPACT_RTF = NO\r
+\r
+# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated\r
+# will contain hyperlink fields. The RTF file will\r
+# contain links (just like the HTML output) instead of page references.\r
+# This makes the output suitable for online browsing using WORD or other\r
+# programs which support those fields.\r
+# Note: wordpad (write) and others do not support links.\r
+\r
+RTF_HYPERLINKS = NO\r
+\r
+# Load style sheet definitions from file. Syntax is similar to doxygen's\r
+# config file, i.e. a series of assignments. You only have to provide\r
+# replacements, missing definitions are set to their default value.\r
+\r
+RTF_STYLESHEET_FILE =\r
+\r
+# Set optional variables used in the generation of an rtf document.\r
+# Syntax is similar to doxygen's config file.\r
+\r
+RTF_EXTENSIONS_FILE =\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the man page output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_MAN tag is set to YES (the default) Doxygen will\r
+# generate man pages\r
+\r
+GENERATE_MAN = NO\r
+\r
+# The MAN_OUTPUT tag is used to specify where the man pages will be put.\r
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be\r
+# put in front of it. If left blank `man' will be used as the default path.\r
+\r
+MAN_OUTPUT = man\r
+\r
+# The MAN_EXTENSION tag determines the extension that is added to\r
+# the generated man pages (default is the subroutine's section .3)\r
+\r
+MAN_EXTENSION = .3\r
+\r
+# If the MAN_LINKS tag is set to YES and Doxygen generates man output,\r
+# then it will generate one additional man file for each entity\r
+# documented in the real man page(s). These additional files\r
+# only source the real man page, but without them the man command\r
+# would be unable to find the correct page. The default is NO.\r
+\r
+MAN_LINKS = NO\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the XML output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_XML tag is set to YES Doxygen will\r
+# generate an XML file that captures the structure of\r
+# the code including all documentation.\r
+\r
+GENERATE_XML = NO\r
+\r
+# The XML_OUTPUT tag is used to specify where the XML pages will be put.\r
+# If a relative path is entered the value of OUTPUT_DIRECTORY will be\r
+# put in front of it. If left blank `xml' will be used as the default path.\r
+\r
+XML_OUTPUT = xml\r
+\r
+# The XML_SCHEMA tag can be used to specify an XML schema,\r
+# which can be used by a validating XML parser to check the\r
+# syntax of the XML files.\r
+\r
+XML_SCHEMA =\r
+\r
+# The XML_DTD tag can be used to specify an XML DTD,\r
+# which can be used by a validating XML parser to check the\r
+# syntax of the XML files.\r
+\r
+XML_DTD =\r
+\r
+# If the XML_PROGRAMLISTING tag is set to YES Doxygen will\r
+# dump the program listings (including syntax highlighting\r
+# and cross-referencing information) to the XML output. Note that\r
+# enabling this will significantly increase the size of the XML output.\r
+\r
+XML_PROGRAMLISTING = YES\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options for the AutoGen Definitions output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will\r
+# generate an AutoGen Definitions (see autogen.sf.net) file\r
+# that captures the structure of the code including all\r
+# documentation. Note that this feature is still experimental\r
+# and incomplete at the moment.\r
+\r
+GENERATE_AUTOGEN_DEF = NO\r
+\r
+#---------------------------------------------------------------------------\r
+# configuration options related to the Perl module output\r
+#---------------------------------------------------------------------------\r
+\r
+# If the GENERATE_PERLMOD tag is set to YES Doxygen will\r
+# generate a Perl module file that captures the structure of\r
+# the code including all documentation. Note that this\r
+# feature is still experimental and incomplete at the\r
+# moment.\r
+\r
+GENERATE_PERLMOD = NO\r
+\r
+# If the PERLMOD_LATEX tag is set to YES Doxygen will generate\r
+# the necessary Makefile rules, Perl scripts and LaTeX code to be able\r
+# to generate PDF and DVI output from the Perl module output.\r
+\r
+PERLMOD_LATEX = NO\r
+\r
+# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be\r
+# nicely formatted so it can be parsed by a human reader.\r
+# This is useful\r
+# if you want to understand what is going on.\r
+# On the other hand, if this\r
+# tag is set to NO the size of the Perl module output will be much smaller\r
+# and Perl will parse it just the same.\r
+\r
+PERLMOD_PRETTY = YES\r
+\r
+# The names of the make variables in the generated doxyrules.make file\r
+# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX.\r
+# This is useful so different doxyrules.make files included by the same\r
+# Makefile don't overwrite each other's variables.\r
+\r
+PERLMOD_MAKEVAR_PREFIX =\r
+\r
+#---------------------------------------------------------------------------\r
+# Configuration options related to the preprocessor\r
+#---------------------------------------------------------------------------\r
+\r
+# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will\r
+# evaluate all C-preprocessor directives found in the sources and include\r
+# files.\r
+\r
+ENABLE_PREPROCESSING = YES\r
+\r
+# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro\r
+# names in the source code. If set to NO (the default) only conditional\r
+# compilation will be performed. Macro expansion can be done in a controlled\r
+# way by setting EXPAND_ONLY_PREDEF to YES.\r
+\r
+MACRO_EXPANSION = YES\r
+\r
+# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES\r
+# then the macro expansion is limited to the macros specified with the\r
+# PREDEFINED and EXPAND_AS_DEFINED tags.\r
+\r
+EXPAND_ONLY_PREDEF = YES\r
+\r
+# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files\r
+# pointed to by INCLUDE_PATH will be searched when a #include is found.\r
+\r
+SEARCH_INCLUDES = YES\r
+\r
+# The INCLUDE_PATH tag can be used to specify one or more directories that\r
+# contain include files that are not input files but should be processed by\r
+# the preprocessor.\r
+\r
+INCLUDE_PATH =\r
+\r
+# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard\r
+# patterns (like *.h and *.hpp) to filter out the header-files in the\r
+# directories. If left blank, the patterns specified with FILE_PATTERNS will\r
+# be used.\r
+\r
+INCLUDE_FILE_PATTERNS =\r
+\r
+# The PREDEFINED tag can be used to specify one or more macro names that\r
+# are defined before the preprocessor is started (similar to the -D option of\r
+# gcc). The argument of the tag is a list of macros of the form: name\r
+# or name=definition (no spaces). If the definition and the = are\r
+# omitted =1 is assumed. To prevent a macro definition from being\r
+# undefined via #undef or recursively expanded use the := operator\r
+# instead of the = operator.\r
+\r
+PREDEFINED = __DOXYGEN__ \\r
+ PROGMEM \\r
+ EEMEM \\r
+ ATTR_PACKED\r
+\r
+# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then\r
+# this tag can be used to specify a list of macro names that should be expanded.\r
+# The macro definition that is found in the sources will be used.\r
+# Use the PREDEFINED tag if you want to use a different macro definition that\r
+# overrules the definition found in the source code.\r
+\r
+EXPAND_AS_DEFINED =\r
+\r
+# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then\r
+# doxygen's preprocessor will remove all references to function-like macros\r
+# that are alone on a line, have an all uppercase name, and do not end with a\r
+# semicolon, because these will confuse the parser if not removed.\r
+\r
+SKIP_FUNCTION_MACROS = YES\r
+\r
+#---------------------------------------------------------------------------\r
+# Configuration::additions related to external references\r
+#---------------------------------------------------------------------------\r
+\r
+# The TAGFILES option can be used to specify one or more tagfiles. For each\r
+# tag file the location of the external documentation should be added. The\r
+# format of a tag file without this location is as follows:\r
+#\r
+# TAGFILES = file1 file2 ...\r
+# Adding location for the tag files is done as follows:\r
+#\r
+# TAGFILES = file1=loc1 "file2 = loc2" ...\r
+# where "loc1" and "loc2" can be relative or absolute paths\r
+# or URLs. Note that each tag file must have a unique name (where the name does\r
+# NOT include the path). If a tag file is not located in the directory in which\r
+# doxygen is run, you must also specify the path to the tagfile here.\r
+\r
+TAGFILES =\r
+\r
+# When a file name is specified after GENERATE_TAGFILE, doxygen will create\r
+# a tag file that is based on the input files it reads.\r
+\r
+GENERATE_TAGFILE =\r
+\r
+# If the ALLEXTERNALS tag is set to YES all external classes will be listed\r
+# in the class index. If set to NO only the inherited external classes\r
+# will be listed.\r
+\r
+ALLEXTERNALS = NO\r
+\r
+# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed\r
+# in the modules index. If set to NO, only the current project's groups will\r
+# be listed.\r
+\r
+EXTERNAL_GROUPS = YES\r
+\r
+# The PERL_PATH should be the absolute path and name of the perl script\r
+# interpreter (i.e. the result of `which perl').\r
+\r
+PERL_PATH = /usr/bin/perl\r
+\r
+#---------------------------------------------------------------------------\r
+# Configuration options related to the dot tool\r
+#---------------------------------------------------------------------------\r
+\r
+# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will\r
+# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base\r
+# or super classes. Setting the tag to NO turns the diagrams off. Note that\r
+# this option also works with HAVE_DOT disabled, but it is recommended to\r
+# install and use dot, since it yields more powerful graphs.\r
+\r
+CLASS_DIAGRAMS = NO\r
+\r
+# You can define message sequence charts within doxygen comments using the \msc\r
+# command. Doxygen will then run the mscgen tool (see\r
+# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the\r
+# documentation. The MSCGEN_PATH tag allows you to specify the directory where\r
+# the mscgen tool resides. If left empty the tool is assumed to be found in the\r
+# default search path.\r
+\r
+MSCGEN_PATH =\r
+\r
+# If set to YES, the inheritance and collaboration graphs will hide\r
+# inheritance and usage relations if the target is undocumented\r
+# or is not a class.\r
+\r
+HIDE_UNDOC_RELATIONS = YES\r
+\r
+# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is\r
+# available from the path. This tool is part of Graphviz, a graph visualization\r
+# toolkit from AT&T and Lucent Bell Labs. The other options in this section\r
+# have no effect if this option is set to NO (the default)\r
+\r
+HAVE_DOT = NO\r
+\r
+# The DOT_NUM_THREADS specifies the number of dot invocations doxygen is\r
+# allowed to run in parallel. When set to 0 (the default) doxygen will\r
+# base this on the number of processors available in the system. You can set it\r
+# explicitly to a value larger than 0 to get control over the balance\r
+# between CPU load and processing speed.\r
+\r
+DOT_NUM_THREADS = 0\r
+\r
+# By default doxygen will use the Helvetica font for all dot files that\r
+# doxygen generates. When you want a differently looking font you can specify\r
+# the font name using DOT_FONTNAME. You need to make sure dot is able to find\r
+# the font, which can be done by putting it in a standard location or by setting\r
+# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the\r
+# directory containing the font.\r
+\r
+DOT_FONTNAME = FreeSans\r
+\r
+# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs.\r
+# The default size is 10pt.\r
+\r
+DOT_FONTSIZE = 10\r
+\r
+# By default doxygen will tell dot to use the Helvetica font.\r
+# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to\r
+# set the path where dot can find it.\r
+\r
+DOT_FONTPATH =\r
+\r
+# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen\r
+# will generate a graph for each documented class showing the direct and\r
+# indirect inheritance relations. Setting this tag to YES will force the\r
+# CLASS_DIAGRAMS tag to NO.\r
+\r
+CLASS_GRAPH = NO\r
+\r
+# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen\r
+# will generate a graph for each documented class showing the direct and\r
+# indirect implementation dependencies (inheritance, containment, and\r
+# class references variables) of the class with other documented classes.\r
+\r
+COLLABORATION_GRAPH = NO\r
+\r
+# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen\r
+# will generate a graph for groups, showing the direct groups dependencies\r
+\r
+GROUP_GRAPHS = YES\r
+\r
+# If the UML_LOOK tag is set to YES doxygen will generate inheritance and\r
+# collaboration diagrams in a style similar to the OMG's Unified Modeling\r
+# Language.\r
+\r
+UML_LOOK = NO\r
+\r
+# If the UML_LOOK tag is enabled, the fields and methods are shown inside\r
+# the class node. If there are many fields or methods and many nodes the\r
+# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS\r
+# threshold limits the number of items for each type to make the size more\r
+# managable. Set this to 0 for no limit. Note that the threshold may be\r
+# exceeded by 50% before the limit is enforced.\r
+\r
+UML_LIMIT_NUM_FIELDS = 10\r
+\r
+# If set to YES, the inheritance and collaboration graphs will show the\r
+# relations between templates and their instances.\r
+\r
+TEMPLATE_RELATIONS = NO\r
+\r
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT\r
+# tags are set to YES then doxygen will generate a graph for each documented\r
+# file showing the direct and indirect include dependencies of the file with\r
+# other documented files.\r
+\r
+INCLUDE_GRAPH = YES\r
+\r
+# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and\r
+# HAVE_DOT tags are set to YES then doxygen will generate a graph for each\r
+# documented header file showing the documented files that directly or\r
+# indirectly include this file.\r
+\r
+INCLUDED_BY_GRAPH = YES\r
+\r
+# If the CALL_GRAPH and HAVE_DOT options are set to YES then\r
+# doxygen will generate a call dependency graph for every global function\r
+# or class method. Note that enabling this option will significantly increase\r
+# the time of a run. So in most cases it will be better to enable call graphs\r
+# for selected functions only using the \callgraph command.\r
+\r
+CALL_GRAPH = NO\r
+\r
+# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then\r
+# doxygen will generate a caller dependency graph for every global function\r
+# or class method. Note that enabling this option will significantly increase\r
+# the time of a run. So in most cases it will be better to enable caller\r
+# graphs for selected functions only using the \callergraph command.\r
+\r
+CALLER_GRAPH = NO\r
+\r
+# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen\r
+# will generate a graphical hierarchy of all classes instead of a textual one.\r
+\r
+GRAPHICAL_HIERARCHY = NO\r
+\r
+# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES\r
+# then doxygen will show the dependencies a directory has on other directories\r
+# in a graphical way. The dependency relations are determined by the #include\r
+# relations between the files in the directories.\r
+\r
+DIRECTORY_GRAPH = YES\r
+\r
+# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images\r
+# generated by dot. Possible values are svg, png, jpg, or gif.\r
+# If left blank png will be used. If you choose svg you need to set\r
+# HTML_FILE_EXTENSION to xhtml in order to make the SVG files\r
+# visible in IE 9+ (other browsers do not have this requirement).\r
+\r
+DOT_IMAGE_FORMAT = png\r
+\r
+# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to\r
+# enable generation of interactive SVG images that allow zooming and panning.\r
+# Note that this requires a modern browser other than Internet Explorer.\r
+# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you\r
+# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files\r
+# visible. Older versions of IE do not have SVG support.\r
+\r
+INTERACTIVE_SVG = NO\r
+\r
+# The tag DOT_PATH can be used to specify the path where the dot tool can be\r
+# found. If left blank, it is assumed the dot tool can be found in the path.\r
+\r
+DOT_PATH =\r
+\r
+# The DOTFILE_DIRS tag can be used to specify one or more directories that\r
+# contain dot files that are included in the documentation (see the\r
+# \dotfile command).\r
+\r
+DOTFILE_DIRS =\r
+\r
+# The MSCFILE_DIRS tag can be used to specify one or more directories that\r
+# contain msc files that are included in the documentation (see the\r
+# \mscfile command).\r
+\r
+MSCFILE_DIRS =\r
+\r
+# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of\r
+# nodes that will be shown in the graph. If the number of nodes in a graph\r
+# becomes larger than this value, doxygen will truncate the graph, which is\r
+# visualized by representing a node as a red box. Note that doxygen if the\r
+# number of direct children of the root node in a graph is already larger than\r
+# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note\r
+# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH.\r
+\r
+DOT_GRAPH_MAX_NODES = 15\r
+\r
+# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the\r
+# graphs generated by dot. A depth value of 3 means that only nodes reachable\r
+# from the root by following a path via at most 3 edges will be shown. Nodes\r
+# that lay further from the root node will be omitted. Note that setting this\r
+# option to 1 or 2 may greatly reduce the computation time needed for large\r
+# code bases. Also note that the size of a graph can be further restricted by\r
+# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction.\r
+\r
+MAX_DOT_GRAPH_DEPTH = 2\r
+\r
+# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent\r
+# background. This is disabled by default, because dot on Windows does not\r
+# seem to support this out of the box. Warning: Depending on the platform used,\r
+# enabling this option may lead to badly anti-aliased labels on the edges of\r
+# a graph (i.e. they become hard to read).\r
+\r
+DOT_TRANSPARENT = YES\r
+\r
+# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output\r
+# files in one run (i.e. multiple -o and -T options on the command line). This\r
+# makes dot run faster, but since only newer versions of dot (>1.8.10)\r
+# support this, this feature is disabled by default.\r
+\r
+DOT_MULTI_TARGETS = NO\r
+\r
+# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will\r
+# generate a legend page explaining the meaning of the various boxes and\r
+# arrows in the dot generated graphs.\r
+\r
+GENERATE_LEGEND = YES\r
+\r
+# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will\r
+# remove the intermediate dot files that are used to generate\r
+# the various graphs.\r
+\r
+DOT_CLEANUP = YES\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_BuildSystem The LUFA Build System\r
+ *\r
+ * \section Sec_BuildSystemOverview Overview of the LUFA Build System\r
+ * The LUFA build system is an attempt at making a set of re-usable, modular build make files which\r
+ * can be referenced in a LUFA powered project, to minimise the amount of code required in an\r
+ * application makefile. The system is written in GNU Make, and each module is independant of\r
+ * one-another.\r
+ *\r
+ * For details on the prerequisites needed for Linux and Windows machines to be able to use the LUFA\r
+ * build system, see \ref Sec_Prerequisites.\r
+ *\r
+ * To use a LUFA build system module, simply add an include to your project makefile:\r
+ * \code\r
+ * include $(LUFA_PATH)/Build/lufa_core.mk\r
+ * \endcode\r
+ *\r
+ * And the associated build module targets will be added to your project's build makefile automatically.\r
+ * To call a build target, run <tt>make {TARGET_NAME}</tt> from the command line, substituting in\r
+ * the appropriate target name.\r
+ *\r
+ * \see \ref Sec_AppConfigParams for a copy of the sample LUFA project makefile.\r
+ *\r
+ * Each build module may have one or more mandatory parameters (GNU Make variables) which <i>must</i>\r
+ * be supplied in the project makefile for the module to work, and one or more optional parameters which\r
+ * may be defined and which will assume a sensible default if not.\r
+ *\r
+ * \section SSec_BuildSystemModules Available Modules\r
+ *\r
+ * The following modules are included in this LUFA release:\r
+ *\r
+ * \li \subpage Page_BuildModule_ATPROGRAM - Device Programming\r
+ * \li \subpage Page_BuildModule_AVRDUDE - Device Programming\r
+ * \li \subpage Page_BuildModule_BUILD - Compiling/Assembling/Linking\r
+ * \li \subpage Page_BuildModule_CORE - Core Build System Functions\r
+ * \li \subpage Page_BuildModule_CPPCHECK - Static Code Analysis\r
+ * \li \subpage Page_BuildModule_DFU - Device Programming\r
+ * \li \subpage Page_BuildModule_DOXYGEN - Automated Source Code Documentation\r
+ * \li \subpage Page_BuildModule_HID - Device Programming\r
+ * \li \subpage Page_BuildModule_SOURCES - LUFA Module Source Code Variables\r
+ */\r
+ \r
+ /** \page Page_BuildModule_BUILD The BUILD build module\r
+ *\r
+ * The BUILD LUFA build system module, providing targets for the compilation,\r
+ * assembling and linking of an application from source code into binary files\r
+ * suitable for programming into a target device.\r
+ *\r
+ * To use this module in your application makefile, add the following code:\r
+ * \code\r
+ * include $(LUFA_PATH)/Build/lufa_build.mk\r
+ * \endcode\r
+ *\r
+ * \section SSec_BuildModule_BUILD_Requirements Requirements\r
+ * This module requires the the architecture appropriate binaries of the GCC compiler are available in your\r
+ * system's <b>PATH</b> variable. The GCC compiler and associated toolchain is distributed in Atmel AVR Studio\r
+ * 5.x and Atmel Studio 6.x installation directories, as well as in many third party distribution packages.\r
+ *\r
+ * \section SSec_BuildModule_BUILD_Targets Targets\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>size</tt></td>\r
+ * <td>Display size of the compiled application FLASH and SRAM segments.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>symbol-sizes</tt></td>\r
+ * <td>Display a size-sorted list of symbols from the compiled application, in decimal bytes.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>check-source</tt></td>\r
+ * <td>Display a list of input SRC source files which cannot be found (if any).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>lib</tt></td>\r
+ * <td>Build and archive all source files into a library A binary file.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>all</tt></td>\r
+ * <td>Build and link the application into ELF debug and HEX binary files.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>elf</tt></td>\r
+ * <td>Build and link the application into an ELF debug file.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>hex</tt></td>\r
+ * <td>Build and link the application and produce HEX and EEP binary files.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>lss</tt></td>\r
+ * <td>Build and link the application and produce a LSS source code/assembly code mixed listing file.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>clean</tt></td>\r
+ * <td>Remove all intermediatary files and binary output files.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>mostlyclean</tt></td>\r
+ * <td>Remove all intermediatary files but preserve any binary output files.</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_BUILD_MandatoryParams Mandatory Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>TARGET</tt></td>\r
+ * <td>Name of the application output file prefix (e.g. <tt>TestApplication</tt>).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>ARCH</tt></td>\r
+ * <td>Architecture of the target processor (see \ref Page_DeviceSupport).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>MCU</tt></td>\r
+ * <td>Name of the Atmel processor model (e.g. <tt>at90usb1287</tt>).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>SRC</tt></td>\r
+ * <td>List of relative or absolute paths to the application C (.c), C++ (.cpp) and Assembly (.S) source files.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>F_USB</tt></td>\r
+ * <td>Speed in Hz of the input clock frequency to the target's USB controller.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>LUFA_PATH</tt></td>\r
+ * <td>Path to the LUFA library core, either relative or absolute (e.g. <tt>../LUFA-000000/LUFA/</tt>).</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_BUILD_OptionalParams Optional Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>BOARD</tt></td>\r
+ * <td>LUFA board hardware drivers to use (see \ref Page_DeviceSupport).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>OPTIMIZATION</tt></td>\r
+ * <td>Optimization level to use when compiling source files (see GCC manual).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>C_STANDARD</tt></td>\r
+ * <td>Version of the C standard to apply when compiling C++ source files (see GCC manual).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>CPP_STANDARD</tt></td>\r
+ * <td>Version of the C++ standard to apply when compiling C++ source files (see GCC manual).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>DEBUG_FORMAT</tt></td>\r
+ * <td>Format of the debug information to embed in the generated object files (see GCC manual).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>DEBUG_LEVEL</tt></td>\r
+ * <td>Level of the debugging information to embed in the generated object files (see GCC manual).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>F_CPU</tt></td>\r
+ * <td>Speed of the processor CPU clock, in Hz.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>C_FLAGS</tt></td>\r
+ * <td>Flags to pass to the C compiler only, after the automatically generated flags.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>CPP_FLAGS</tt></td>\r
+ * <td>Flags to pass to the C++ compiler only, after the automatically generated flags.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>ASM_FLAGS</tt></td>\r
+ * <td>Flags to pass to the assembler only, after the automatically generated flags.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>CC_FLAGS</tt></td>\r
+ * <td>Common flags to pass to the C/C++ compiler and assembler, after the automatically generated flags.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>LD_FLAGS</tt></td>\r
+ * <td>Flags to pass to the linker, after the automatically generated flags.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>OBJDIR</tt></td>\r
+ * <td>Directory to place the generated object and dependency files. If set to "." the same folder as the source file will be used.\r
+ * \note When this option is enabled, all source filenames <b>must</b> be unique.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>OBJECT_FILES</tt></td>\r
+ * <td>List of additional object files that should be linked into the resulting binary.</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_BUILD_ProvidedVariables Module Provided Variables\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table> \r
+ *\r
+ * \section SSec_BuildModule_BUILD_ProvidedMacros Module Provided Macros\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ */\r
+\r
+/** \page Page_BuildModule_CORE The CORE build module\r
+ *\r
+ * The core LUFA build system module, providing common build system help and information targets.\r
+ *\r
+ * To use this module in your application makefile, add the following code:\r
+ * \code\r
+ * include $(LUFA_PATH)/Build/lufa_core.mk\r
+ * \endcode\r
+ *\r
+ * \section SSec_BuildModule_CORE_Requirements Requirements\r
+ * This module has no requirements outside a standard *nix shell like environment; the <tt>sh</tt>\r
+ * shell, GNU <tt>make</tt> and *nix CoreUtils (<tt>echo</tt>, <tt>printf</tt>, etc.).\r
+ *\r
+ * \section SSec_BuildModule_CORE_Targets Targets\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>help</tt></td>\r
+ * <td>Display build system help and configuration information.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>list_targets</tt></td>\r
+ * <td>List all available build targets from the build system.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>list_modules</tt></td>\r
+ * <td>List all available build modules from the build system.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>list_mandatory</tt></td>\r
+ * <td>List all mandatory parameters required by the included modules.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>list_optional</tt></td>\r
+ * <td>List all optional parameters required by the included modules.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>list_provided</tt></td>\r
+ * <td>List all variables provided by the included modules.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>list_macros</tt></td>\r
+ * <td>List all macros provided by the included modules.</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_CORE_MandatoryParams Mandatory Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_CORE_OptionalParams Optional Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_CORE_ProvidedVariables Module Provided Variables\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table> \r
+ *\r
+ * \section SSec_BuildModule_CORE_ProvidedMacros Module Provided Macros\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ */\r
+\r
+/** \page Page_BuildModule_ATPROGRAM The ATPROGRAM build module\r
+ *\r
+ * The ATPROGRAM programming utility LUFA build system module, providing targets to reprogram an\r
+ * Atmel processor FLASH and EEPROM memories with a project's compiled binary output files.\r
+ *\r
+ * To use this module in your application makefile, add the following code:\r
+ * \code\r
+ * include $(LUFA_PATH)/Build/lufa_atprogram.mk\r
+ * \endcode\r
+ *\r
+ * \section SSec_BuildModule_ATPROGRAM_Requirements Requirements\r
+ * This module requires the <tt>atprogram.exe</tt> utility to be available in your system's <b>PATH</b>\r
+ * variable. The <tt>atprogram.exe</tt> utility is distributed in Atmel AVR Studio 5.x and Atmel Studio 6.x\r
+ * inside the application install folder's "\avrdbg" subdirectory.\r
+ *\r
+ * \section SSec_BuildModule_ATPROGRAM_Targets Targets\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>atprogram</tt></td>\r
+ * <td>Program the device FLASH memory with the application's executable data.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>atprogram-ee</tt></td>\r
+ * <td>Program the device EEPROM memory with the application's EEPROM data.</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_ATPROGRAM_MandatoryParams Mandatory Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>MCU</tt></td>\r
+ * <td>Name of the Atmel processor model (e.g. <tt>at90usb1287</tt>).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>TARGET</tt></td>\r
+ * <td>Name of the application output file prefix (e.g. <tt>TestApplication</tt>).</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_ATPROGRAM_OptionalParams Optional Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>ATPROGRAM_PROGRAMMER</tt></td>\r
+ * <td>Name of the Atmel programmer or debugger tool to communicate with (e.g. <tt>jtagice3</tt>).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>ATPROGRAM_INTERFACE</tt></td>\r
+ * <td>Name of the programming interface to use when programming the target (e.g. <tt>spi</tt>).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>ATPROGRAM_PORT</tt></td>\r
+ * <td>Name of the communication port to use when when programming with a serially connected tool (e.g. <tt>COM2</tt>).</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_ATPROGRAM_ProvidedVariables Module Provided Variables\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table> \r
+ *\r
+ * \section SSec_BuildModule_ATPROGRAM_ProvidedMacros Module Provided Macros\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ */\r
+\r
+/** \page Page_BuildModule_AVRDUDE The AVRDUDE build module\r
+ *\r
+ * The AVRDUDE programming utility LUFA build system module, providing targets to reprogram an\r
+ * Atmel processor FLASH and EEPROM memories with a project's compiled binary output files.\r
+ *\r
+ * To use this module in your application makefile, add the following code:\r
+ * \code\r
+ * include $(LUFA_PATH)/Build/lufa_avrdude.mk\r
+ * \endcode\r
+ *\r
+ * \section SSec_BuildModule_AVRDUDE_Requirements Requirements\r
+ * This module requires the <tt>avrdude</tt> utility to be available in your system's <b>PATH</b>\r
+ * variable. The <tt>avrdude</tt> utility is distributed in the old WinAVR project releases for\r
+ * Windows (<a>winavr.sourceforge.net</a>) or can be installed on *nix systems via the project's\r
+ * source code (<a>https://savannah.nongnu.org/projects/avrdude</a>) or through the package manager.\r
+ *\r
+ * \section SSec_BuildModule_AVRDUDE_Targets Targets\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>avrdude</tt></td>\r
+ * <td>Program the device FLASH memory with the application's executable data.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>avrdude</tt></td>\r
+ * <td>Program the device EEPROM memory with the application's EEPROM data.</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_AVRDUDE_MandatoryParams Mandatory Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>MCU</tt></td>\r
+ * <td>Name of the Atmel processor model (e.g. <tt>at90usb1287</tt>).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>TARGET</tt></td>\r
+ * <td>Name of the application output file prefix (e.g. <tt>TestApplication</tt>).</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_AVRDUDE_OptionalParams Optional Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>AVRDUDE_PROGRAMMER</tt></td>\r
+ * <td>Name of the programmer or debugger tool to communicate with (e.g. <tt>jtagicemkii</tt>).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>ATPROGRAM_PORT</tt></td>\r
+ * <td>Name of the communication port to use when when programming with the connected tool (e.g. <tt>COM2</tt>, <tt>/dev/ttyUSB0</tt> or <tt>usb</tt>).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>ATPROGRAM_FLAGS</tt></td>\r
+ * <td>Additional flags to pass to avrdude when programming, applied after the automatically generated flags.</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_AVRDUDE_ProvidedVariables Module Provided Variables\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table> \r
+ *\r
+ * \section SSec_BuildModule_AVRDUDE_ProvidedMacros Module Provided Macros\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ */\r
+ \r
+ /** \page Page_BuildModule_CPPCHECK The CPPCHECK build module\r
+ *\r
+ * The CPPCHECK programming utility LUFA build system module, providing targets to statically\r
+ * analyze C and C++ source code for errors and performance/style issues.\r
+ *\r
+ * To use this module in your application makefile, add the following code:\r
+ * \code\r
+ * include $(LUFA_PATH)/Build/lufa_cppcheck.mk\r
+ * \endcode\r
+ *\r
+ * \section SSec_BuildModule_CPPCHECK_Requirements Requirements\r
+ * This module requires the <tt>cppcheck</tt> utility to be available in your system's <b>PATH</b>\r
+ * variable. The <tt>cppcheck</tt> utility is distributed through the project's home page\r
+ * (<a>http://cppcheck.sourceforge.net</a>) for Windows, and can be installed on *nix systems via\r
+ * the project's source code or through the package manager.\r
+ *\r
+ * \section SSec_BuildModule_CPPCHECK_Targets Targets\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>cppcheck</tt></td>\r
+ * <td>Statically analyze the project source code for issues.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>cppcheck-config</tt></td>\r
+ * <td>Check the <tt>cppcheck</tt> configuration - scan source code and warn about missing header files and other issues.</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_CPPCHECK_MandatoryParams Mandatory Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>SRC</tt></td>\r
+ * <td>List of source files to statically analyze.</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_CPPCHECK_OptionalParams Optional Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>CPPCHECK_INCLUDES</tt></td>\r
+ * <td>Path of extra directories to check when attemting to resolve C/C++ header file includes.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>CPPCHECK_EXCLUDES</tt></td>\r
+ * <td>Paths or path fragments to exclude when analyzing.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>CPPCHECK_MSG_TEMPLATE</tt></td>\r
+ * <td>Output message template to use when printing errors, warnings and information (see <tt>cppcheck</tt> documentation).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>CPPCHECK_ENABLE</tt></td>\r
+ * <td>Analysis rule categories to enable (see <tt>cppcheck</tt> documentation).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>CPPCHECK_SUPPRESS</tt></td>\r
+ * <td>Specific analysis rules to suppress (see <tt>cppcheck</tt> documentation).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>CPPCHECK_FAIL_ON_WARNING</tt></td>\r
+ * <td>Set to <b>Y</b> to fail the analysis job with an error exit code if warnings are found, <b>N</b> to continue without failing.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>CPPCHECK_QUIET</tt></td>\r
+ * <td>Set to <b>Y</b> to suppress all output except warnings and errors, <b>N</b> to show verbose output information.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>CPPCHECK_FLAGS</tt></td>\r
+ * <td>Extra flags to pass to <tt>cppcheck</tt>, after the automatically generated flags.</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_CPPCHECK_ProvidedVariables Module Provided Variables\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table> \r
+ *\r
+ * \section SSec_BuildModule_CPPCHECK_ProvidedMacros Module Provided Macros\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ */\r
+ \r
+ /** \page Page_BuildModule_DFU The DFU build module\r
+ *\r
+ * The DFU programming utility LUFA build system module, providing targets to reprogram an\r
+ * Atmel processor FLASH and EEPROM memories with a project's compiled binary output files.\r
+ * This module requires a DFU class bootloader to be running in the target, compatible with\r
+ * the DFU bootloader protocol as published by Atmel.\r
+ *\r
+ * To use this module in your application makefile, add the following code:\r
+ * \code\r
+ * include $(LUFA_PATH)/Build/lufa_dfu.mk\r
+ * \endcode\r
+ *\r
+ * \section SSec_BuildModule_DFU_Requirements Requirements\r
+ * This module requires either the <tt>batchisp</tt> utility from Atmel's FLIP utility, or the open\r
+ * source <tt>dfu-programmer</tt> utility (<a>http://dfu-programmer.sourceforge.net/</a>) to be\r
+ * available in your system's <b>PATH</b> variable. On *nix systems the <tt>dfu-programmer</tt> utility\r
+ * can be installed via the project's source code or through the package manager.\r
+ *\r
+ * \section SSec_BuildModule_DFU_Targets Targets\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>dfu</tt></td>\r
+ * <td>Program the device FLASH memory with the application's executable data using <tt>dfu-programmer</tt>.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>dfu-ee</tt></td>\r
+ * <td>Program the device EEPROM memory with the application's EEPROM data using <tt>dfu-programmer</tt>.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>flip</tt></td>\r
+ * <td>Program the device FLASH memory with the application's executable data using <tt>batchisp</tt>.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>flip-ee</tt></td>\r
+ * <td>Program the device EEPROM memory with the application's EEPROM data using <tt>batchisp</tt>.</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_DFU_MandatoryParams Mandatory Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>MCU</tt></td>\r
+ * <td>Name of the Atmel processor model (e.g. <tt>at90usb1287</tt>).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>TARGET</tt></td>\r
+ * <td>Name of the application output file prefix (e.g. <tt>TestApplication</tt>).</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_DFU_OptionalParams Optional Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_DFU_ProvidedVariables Module Provided Variables\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table> \r
+ *\r
+ * \section SSec_BuildModule_DFU_ProvidedMacros Module Provided Macros\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ */\r
+ \r
+ /** \page Page_BuildModule_DOXYGEN The DOXYGEN build module\r
+ *\r
+ * The DOXYGEN code documentation utility LUFA build system module, providing targets to generate\r
+ * project HTML and other format documentation from a set of source files that include special\r
+ * Doxygen comments.\r
+ *\r
+ * To use this module in your application makefile, add the following code:\r
+ * \code\r
+ * include $(LUFA_PATH)/Build/lufa_doxygen.mk\r
+ * \endcode\r
+ *\r
+ * \section SSec_BuildModule_DOXYGEN_Requirements Requirements\r
+ * This module requires the <tt>doxygen</tt> utility from the Doxygen website\r
+ * (<a>http://www.stack.nl/~dimitri/doxygen/</a>) to be available in your system's <b>PATH</b>\r
+ * variable. On *nix systems the <tt>doxygen</tt> utility can be installed via the project's source\r
+ * code or through the package manager.\r
+ *\r
+ * \section SSec_BuildModule_DOXYGEN_Targets Targets\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>doxygen</tt></td>\r
+ * <td>Generate project documentation.</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_DOXYGEN_MandatoryParams Mandatory Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>LUFA_PATH</tt></td>\r
+ * <td>Path to the LUFA library core, either relative or absolute (e.g. <tt>../LUFA-000000/LUFA/</tt>).</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_DOXYGEN_OptionalParams Optional Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>DOXYGEN_CONF</tt></td>\r
+ * <td>Name and path of the base Doxygen configuration file for the project.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>DOXYGEN_FAIL_ON_WARNING</tt></td>\r
+ * <td>Set to <b>Y</b> to fail the generation with an error exit code if warnings are found other than unsupported configuration parameters, <b>N</b> to continue without failing.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>DOXYGEN_OVERRIDE_PARAMS</tt></td>\r
+ * <td>Extra Doxygen configuration parameters to apply, overriding the corresponding config entry in the project's configuration file (e.g. <tt>QUIET=YES</tt>).</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_DOXYGEN_ProvidedVariables Module Provided Variables\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table> \r
+ *\r
+ * \section SSec_BuildModule_DOXYGEN_ProvidedMacros Module Provided Macros\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ */\r
+ \r
+ /** \page Page_BuildModule_HID The HID build module\r
+ *\r
+ * The HID programming utility LUFA build system module, providing targets to reprogram an\r
+ * Atmel processor's FLASH memory with a project's compiled binary output file. This module\r
+ * requires a HID class bootloader to be running in the target, using a protocol compatible\r
+ * with the PJRC "HalfKay" protocol (<a>http://www.pjrc.com/teensy/halfkay_protocol.html</a>).\r
+ *\r
+ * To use this module in your application makefile, add the following code:\r
+ * \code\r
+ * include $(LUFA_PATH)/Build/lufa_hid.mk\r
+ * \endcode\r
+ *\r
+ * \section SSec_BuildModule_HID_Requirements Requirements\r
+ * This module requires either the <tt>hid_bootloader_cli</tt> utility from the included LUFA HID\r
+ * class bootloader API subdirectory, or the <tt>teensy_loader_cli</tt> utility from PJRC\r
+ * (<a>http://www.pjrc.com/teensy/loader_cli.html</a>) to be available in your system's <b>PATH</b>\r
+ * variable.\r
+ *\r
+ * \section SSec_BuildModule_HID_Targets Targets\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>hid</tt></td>\r
+ * <td>Program the device FLASH memory with the application's executable data using <tt>hid_bootloader_cli</tt>.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>hid-ee</tt></td>\r
+ * <td>Program the device EEPROM memory with the application's EEPROM data using <tt>hid_bootloader_cli</tt> and\r
+ * a temporary AVR application programmed into the target's FLASH.\r
+ * \note This will erase the currently loaded application in the target.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>teensy</tt></td>\r
+ * <td>Program the device FLASH memory with the application's executable data using <tt>teensy_loader_cli</tt>.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>teensy-ee</tt></td>\r
+ * <td>Program the device EEPROM memory with the application's EEPROM data using <tt>teensy_loader_cli</tt> and\r
+ * a temporary AVR application programmed into the target's FLASH.\r
+ * \note This will erase the currently loaded application in the target.</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_HID_MandatoryParams Mandatory Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>MCU</tt></td>\r
+ * <td>Name of the Atmel processor model (e.g. <tt>at90usb1287</tt>).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>TARGET</tt></td>\r
+ * <td>Name of the application output file prefix (e.g. <tt>TestApplication</tt>).</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_HID_OptionalParams Optional Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_HID_ProvidedVariables Module Provided Variables\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table> \r
+ *\r
+ * \section SSec_BuildModule_HID_ProvidedMacros Module Provided Macros\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ */\r
+ \r
+ /** \page Page_BuildModule_SOURCES The SOURCES build module\r
+ *\r
+ * The SOURCES LUFA build system module, providing variables listing the various LUFA source files\r
+ * required to be build by a project for a given LUFA module. This module gives a way to reference\r
+ * LUFA source files symbollically, so that changes to the library structure do not break the library\r
+ * makefile.\r
+ *\r
+ * To use this module in your application makefile, add the following code:\r
+ * \code\r
+ * include $(LUFA_PATH)/Build/lufa_sources.mk\r
+ * \endcode\r
+ *\r
+ * \section SSec_BuildModule_SOURCES_Requirements Requirements\r
+ * None.\r
+ *\r
+ * \section SSec_BuildModule_SOURCES_Targets Targets\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_SOURCES_MandatoryParams Mandatory Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>LUFA_PATH</tt></td>\r
+ * <td>Path to the LUFA library core, either relative or absolute (e.g. <tt>../LUFA-000000/LUFA/</tt>).</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>ARCH</tt></td>\r
+ * <td>Architecture of the target processor (see \ref Page_DeviceSupport).</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_SOURCES_OptionalParams Optional Parameters\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section SSec_BuildModule_SOURCES_ProvidedVariables Module Provided Variables\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><tt>LUFA_SRC_USB</tt></td>\r
+ * <td>List of LUFA USB driver source files.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>LUFA_SRC_USBCLASS</tt></td>\r
+ * <td>List of LUFA USB Class driver source files.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>LUFA_SRC_TEMPERATURE</tt></td>\r
+ * <td>List of LUFA temperature sensor driver source files.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>LUFA_SRC_SERIAL</tt></td>\r
+ * <td>List of LUFA Serial U(S)ART driver source files.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>LUFA_SRC_TWI</tt></td>\r
+ * <td>List of LUFA TWI driver source files.</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td><tt>LUFA_SRC_PLATFORM</tt></td>\r
+ * <td>List of LUFA architecture specific platform management source files.</td>\r
+ * </tr> \r
+ * </table> \r
+ *\r
+ * \section SSec_BuildModule_SOURCES_ProvidedMacros Module Provided Macros\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <td><i>None</i></td>\r
+ * </tr>\r
+ * </table>\r
+ */\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_BuildLibrary Building as a Linkable Library\r
+ *\r
+ * The LUFA library can be built as a proper linkable library (with the extention .a) under AVR-GCC, so that\r
+ * the library does not need to be recompiled with each revision of a user project. Instructions for creating\r
+ * a library from a given source tree can be found in the AVR-GCC user manual included in the WinAVR install\r
+ * /Docs/ directory.\r
+ *\r
+ * However, building the library is <b>not recommended</b>, as the static (compile-time) options will be\r
+ * unable to be changed without a recompilation of the LUFA code. Therefore, if the library is to be built\r
+ * from the LUFA source, it should be made to be application-specific and compiled with the static options\r
+ * that are required for each project (which should be recorded along with the library).\r
+ *\r
+ * Normal library use has the library components compiled in at the same point as the application code, as\r
+ * demonstrated in the library demos and applications. This is the preferred method, as the library is recompiled\r
+ * each time to ensure that all static options for a particular application are applied.\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+ /** \page Page_ChangeLog Project Changelog\r
+ *\r
+ * \section Sec_ChangeLog120730 Version 120730\r
+ * <b>New:</b>\r
+ * - Core:\r
+ * - Added new, revamped modular build system with new makefile templates\r
+ * - Added support for the BitWizard Multio and Big-Multio boards\r
+ * - Added support for the DorkbotPDX Duce board\r
+ * - Added support for the Olimex AVR-USB-32U4 board\r
+ * - Added support for the Olimex AVR-USB-T32U4 board\r
+ * - Added support for the Olimex AVR-ISP-MK2 board\r
+ * - Added new Endpoint_ConfigureEndpointTable() function\r
+ * - Added new Pipe_ConfigurePipeTable() function\r
+ * - Added build test to verify correct compilation of all board drivers using all driver APIs\r
+ * - Added build test to verify correct compilation of all bootloaders using all supported devices \r
+ * - Added build test to verify that there are no detectable errors in the codebase via static analysis\r
+ * - Added new JTAG_ENABLE() macro for the AVR8 architecture\r
+ * - Library Applications:\r
+ * - Modified the CDC Host demos to set a default CDC Line Encoding on enumerated devices\r
+ * - Added Dataflash operational checks and aborts to all projects using the Dataflash to ensure it is working correctly before use\r
+ * - Added new SerialToLCD user project contributed by Simon Foster\r
+ * - Added new RESET_TOGGLES_LIBUSB_COMPAT compile time option to the AVRISP-MKII clone programmer project (thanks to Robert Spitzenpfeil)\r
+ *\r
+ * <b>Changed:</b>\r
+ * - Core:\r
+ * - Android Accessory Host property strings changed from a struct of pointer to an array to prevent unaligned access on greater than 8-bit architectures\r
+ * - Audio Device Class driver changed to also require the index of the Audio Control interface within the device, for SET/GET/CUR/MIN/MAX/RES property adjustments\r
+ * - Removed variable axis support from the HID_DESCRIPTOR_JOYSTICK() macro due to OS incompatibilities, replaced with fixed 3-axis joystick report structure\r
+ * - Removed the old pseudo-scheduler from the library as it was unused and deprecated since the 090810 release\r
+ * - Endpoint indexes are now specified as full endpoint addresses within the device in device mode, rather than a logical index\r
+ * - The Endpoint_ConfigureEndpoint() function no longer takes an endpoint direction as a parameter, as this is now deduced from the specified full endpoint\r
+ * address and type\r
+ * - The Endpoint_ConfigureEndpoint() function no longer takes a number of banks as a special mask; the number of banks is now specified as an integer parameter\r
+ * - Endpoints are now configured via instances of a new struct USB_Endpoint_Table_t in all device mode class drivers, rather than a list of endpoint parameters\r
+ * - Pipe indexes are now specified as full pipe addresses within the host in host mode, rather than a logical index\r
+ * - The Pipe_ConfigurePipe() function no longer takes an pipe token as a parameter, as this is now deduced from the specified full pipe address and type\r
+ * - The Pipe_ConfigurePipe() function no longer takes a number of banks as a special mask; the number of banks is now specified as an integer parameter\r
+ * - Pipes are now configured via instances of a new struct USB_Pipe_Table_t in all host mode class drivers, rather than a list of pipe parameters\r
+ * - Added support for various assert and debugging macros for the UC3 devices\r
+ * - Changed MIDI event structure MIDI_EventPacket_t to use a single field for the combined virtual cable index and command ID, to prevent bitfield packing issues\r
+ * on some architectures (thanks to Darren Gibbs)\r
+ * - Changed board LED driver implementations of LEDs_ToggleLEDs() for the AVR8 architecture to use the fast PIN register toggle alternative function for speed\r
+ * - Library Applications:\r
+ * - Raised the guard bits in the AVRISP-MKII clone project when in PDI and TPI to 32, to prevent communication errors on low quality connections to a target\r
+ * - Added additional bootloader API data to expose the bootloader start address and class to the DFU and CDC class bootloaders\r
+ * - Reverted AVRISP-MKII clone project watchdog based command timeout patch in favour of a hardware timer, to allow for use in devices with WDTRST fuse programmed\r
+ * - The library bootloaders will now correctly start the user application after a watchdog-based application start, even if the /HWB line is held low externally\r
+ * during the reset phase\r
+ * - Increased endpoint polling interval for all demos and projects to 5ms, as 1ms was causing some enumeration issues on some machines (thanks to Riku Salminen)\r
+ *\r
+ * <b>Fixed:</b>\r
+ * - Core:\r
+ * - Fixed possible enumeration error if the user application selects a pipe other than the default Control pipe between the Powered and Default states of\r
+ * the host state machine\r
+ * - Fixed incorrect call to the user callback CALLBACK_Audio_Device_GetSetInterfaceProperty() in the Audio Class device driver (thanks to Tiit Ratsep)\r
+ * - Fixed compile error for the UC3 architecture when INTERRUPT_CONTROL_ENDPOINT is specified (thanks to Andrus Aaslaid)\r
+ * - Fixed compile error if LEDs_Disable() is called and BOARD=NONE is set (thanks to Sam Lin)\r
+ * - Fixed inverted LED logic in the OLIMEX162 board LED driver\r
+ * - Fixed incorrect reponse to GET STATUS requests in device mode if NO_DEVICE_SELF_POWER or NO_DEVICE_REMOTE_WAKEUP tokens are defined (thanks to Georg Glock)\r
+ * - Fixed inverted LED logic in the USB2AX board LED driver\r
+ * - Fixed possible deadlock in the CDC device driver if the USB connection is dropped while the CDC_REQ_SetLineEncoding control request is being processed by\r
+ * the stack (thanks to Jonathan Hudgins)\r
+ * - Fixed broken MIDI host driver MIDI_Host_ReceiveEventPacket() function due to not unfreezing the MIDI data IN pipe before use (thanks to Michael Brown)\r
+ * - Fixed swapped Little Endian/Big Endian endpoint and pipe write code for the UC3 devices (thanks to Andrew Chu)\r
+ * - Fixed the JTAG_DISABLE() macro clearing all other bits in MCUSR when called\r
+ * - Fixed incorrect Micropendous board LED driver LEDs_SetAllLEDs() and LEDs_ChangeLEDs() function implementations (thanks to MitchJS)\r
+ * - Fixed endianess issues in the RNDIS host class driver for UC3 devices (thanks to Andrew Chu) \r
+ * - Library Applications:\r
+ * - Fixed error in the AVRISP-MKII programmer when ISP mode is used at 64KHz (thanks to Ben R. Porter)\r
+ * - Fixed AVRISP-MKII programmer project failing to compile for the U4 chips when VTARGET_ADC_CHANNEL is defined to an invalid channel and NO_VTARGET_DETECT is\r
+ * defined (thanks to Steven Morehouse)\r
+ * - Fixed AVRISP-MKII programmer project reset line polarity inverted when the generated EEP file is loaded into the USB AVR's EEPROM and avr-dude is used\r
+ * - Fixed CDC and DFU bootloaders failing to compile when the bootloader section size is 8KB or more (thanks to Georg Glock)\r
+ * - Fixed CDC and DFU bootloaders API function offsets incorrect on some devices (thanks to Rod DeMay)\r
+ * - Fixed incorrect DFU version number reported to the host in the DFU bootloader descriptors (thanks to Georg Glock)\r
+ * - Fixed incorrect version hundredths value encoding in VERSION_BCD() macro (thanks to Georg Glock)\r
+ * - Fixed invalid configuration descriptor in the low level KeyboardMouse device demo (thanks to Jun Wako)\r
+ * - Fixed CDC and DFU bootloaders API page erase and write function failures (thanks to Martin Lambert)\r
+ *\r
+ * \section Sec_ChangeLog120219 Version 120219\r
+ * <b>New:</b>\r
+ * - Core:\r
+ * - Added support for the XMEGA A3BU Xplained board\r
+ * - Added support for the new B series XMEGA devices\r
+ * - Added support for version 2 of the Teensy boards (thanks to Christoph Redecker)\r
+ * - Added support for the USB2AX boards, hardware revision 1-3\r
+ * - Added new Android Accessory Host class driver\r
+ * - Added new USB_Host_GetDescriptor(), USB_Host_GetDeviceConfiguration() and USB_Host_GetInterfaceAltSetting() functions\r
+ * - Added new CALLBACK_Audio_Device_GetSetInterfaceProperty() callback to the Audio Device Class driver\r
+ * - Added new LEDs_Disable(), Buttons_Disable() and Joystick_Disable() functions to the board hardware drivers\r
+ * - Added support for the Micropendous family of boards (Arduino-like revisions 1 and 2, DIP, 32U2, A, 1, 2, 3 and 4)\r
+ * - Added INVERTED_VBUS_ENABLE_LINE and NO_AUTO_VBUS_MANAGEMENT compile time options (thanks to Opendous Inc.)\r
+ * - Added support for the Atmel XMEGA B1 Xplained board\r
+ * - Added Serial USART peripheral driver for the XMEGA architecture\r
+ * - Added Master Mode SPI USART peripheral driver for the XMEGA and AVR8 architectures\r
+ * - Added build test to verify correct compilation of as many modules as possible under as many architectures as possible under the C and C++ languages\r
+ * - Added build test to verify correct compilation of the USB driver when forced into single USB mode under as many architectures as possible\r
+ * - Library Applications:\r
+ * - Added User Application APIs to the CDC and DFU class bootloaders\r
+ * - Added INVERTED_ISP_MISO compile time option to the AVRISP-MKII clone project (thanks to Chuck Rohs)\r
+ * - Added new Android Accessory Host demo (thanks to Opendous Inc.)\r
+ *\r
+ * <b>Changed:</b>\r
+ * - Core:\r
+ * - When automatic PLL management mode is enabled on the U4 series AVR8 chips, the PLL is now configured for 48MHz and not\r
+ * a divided 96MHz, to lower power consumption and to keep the system within the datasheet specs for 3.3V operation (thanks to Scott Vitale)\r
+ * - Added Class, ClassDevice, ClassHost and ClassCommon to the internal class driver source filenames to prevent ambiguities\r
+ * - Altered the Mass Storage Host class driver so that SCSI data STALLs from the attached device can be recovered from automatically without\r
+ * having to reset the Mass Storage interface\r
+ * - USB_CONFIG_ATTR_BUSPOWERED constant renamed to USB_CONFIG_ATTR_RESERVED, as this was misnamed (thanks to NXP Semiconductors)\r
+ * - Reordered board name definition indexes so that a mispelled BOARD compile option will default to BOARD_USER rather than BOARD_USBKEY\r
+ * - Altered the HID class driver to only try to construct at maximum one packet per USB frame, to reduce CPU usage\r
+ * - All USB Class Driver configuration struct values are now non-const, to allow for run-time modifications if required before configuring an instance\r
+ * - Library Applications:\r
+ * - Altered the Mass Storage Host LowLevel demo so that SCSI data STALLs from the attached device can be recovered from automatically without\r
+ * having to reset the Mass Storage interface\r
+ * - Updated the AVRISP-MKII Clone programmer project to be compatible with the latest version of AVR Studio (version 5.1)\r
+ * - Changed the AVRISP-MKII Clone programmer project to report a fixed 3.3V VTARGET voltage on USB AVRs lacking an ADC instead of 5V to prevent\r
+ * warnings in AVR Studio 5.1 when programming XMEGA devices\r
+ * - Allow serial strings to be generated on the older AVR8 devices which do not explicitly state they contain unique values in the datasheet,\r
+ * as this appears to be implemented in hardware\r
+ *\r
+ * <b>Fixed:</b>\r
+ * - Core:\r
+ * - Fixed ring buffer size limited to 255 elements, instead of the intended 65535 elements.\r
+ * - Fixed CDC class drivers not saving and sending all 16-bits of the control line states (thanks to Matthew Swabey)\r
+ * - Fixed race conditions in the CDC, HID and Mass Storage class drivers when processing some control requests\r
+ * - Fixed misspelled HID_KEYBOARD_MODIFIER_* macros in the HID class driver (thanks to Laszlo Monda)\r
+ * - Fixed broken AVR32 endpoint/pipe communications when ORDERED_EP_CONFIG compile time option is not enabled (thanks to Matthias Jahr)\r
+ * - Fixed broken compilation for the AVR32 devices if the NO_SOF_EVENTS compile time option was not enabled (thanks to Matthias Jahr)\r
+ * - Fixed compiler warning on GCC with \c -wundef compile flag is used (thanks to Georg Glock)\r
+ * - Fixed incorrect implementation of LEDs_ToggleLEDs() for the Adafruit-U4 board (thanks to Caroline Saliman)\r
+ * - Fixed broken compilation of LUFA under C++ compilers when the Serial peripheral module header file is included in a C++ source file\r
+ * - Fixed missing semicolon in the UC3 architecture host pipe functions\r
+ * - Fixed failed compilation for the XMEGA architecture if USB_DEVICE_ONLY us not specified\r
+ * - Fixed UC3 architecture ignoring the pipe size when Pipe_ConfigurePipe() is called\r
+ * - Library Applications:\r
+ * - Added reliability patches to the AVRISP-MKII Clone project's PDI/TPI protocols (thanks to Justin Mattair)\r
+ * - Fixed AVRISP-MKII Clone compile warning on AVR8 U4 targets even when NO_VTARGET_DETECT is enabled\r
+ * - Fixed AVRISP-MKII Clone failing to start application firmware once a TPI programming session is exited\r
+ * - Fixed DFU class bootloader not resetting the LED pins as high impedance inputs when a software jump to the user applications is requested\r
+ * - Fixed AVRISP-MKII Clone timing out on long programming commands such as programming the EEPROM on an ATMEGA8 (thanks to Martin Kelling)\r
+ * - Fixed invalid PID value used in the TempDataLogger project host application (thanks to Anupam Pathak)\r
+ *\r
+ * \section Sec_ChangeLog111009 Version 111009\r
+ * <b>New:</b>\r
+ * - Core:\r
+ * - Added USE_LUFA_CONFIG_HEADER compile time option to include a LUFAConfig.h header in the user director for LUFA configuration\r
+ * tokens as an alternative to tokens defined in the project makefile\r
+ * - Added new USB_Host_SetInterfaceAltSetting() convenience function for the selection of an interface's alternative setting\r
+ * - Added Audio class control request definitions\r
+ * - Added new CALLBACK_Audio_Device_GetSetEndpointProperty() callback to the Audio Device Class driver to allow for endpoint control manipulations\r
+ * such as data sample rates\r
+ * - Added support for the Audio class GET STATUS request in the Audio Device Class driver so that it is correctly ACKed when sent by the host\r
+ * - Added new EVENT_Audio_Device_StreamStartStop() event to the Audio Device Class driver to detect stream start/stop events\r
+ * - Added board driver support for the Busware TUL board\r
+ * - Added board hardware driver support for the EVK1100 board\r
+ * - Added board hardware driver support for the EVK1104 board\r
+ * - Added new Host mode Audio Class driver\r
+ * - Added new SPI_GetCurrentMode() function to the SPI peripheral driver\r
+ * - Added RingBuffer_GetFreeCount() function to the Ring Buffer driver\r
+ * - Added new HID_Host_SetIdlePeriod() function to the HID Host Class driver\r
+ * - Added new USB_Host_ConfigurationNumber global variable to indicate the selected configuration in an attached device\r
+ * - Added new USB_Host_GetDeviceStatus() function to the host standard request function set\r
+ * - Added AVR USB XMEGA architecture port (currently incomplete/experimental)\r
+ * - Added new STRINGIFY() and STRINGIFY_EXPANDED() convenience macros\r
+ * - Added new JTAG_DISABLE() macro for the AVR8 architecture\r
+ * - Added Device Qualifier standard descriptor structure definitions USB_StdDescriptor_DeviceQualifier_t and USB_Descriptor_DeviceQualifier_t\r
+ * - Library Applications:\r
+ * - Added RNDIS device mode to the Webserver project\r
+ * - Added new incomplete AndroidAccessoryHost Host LowLevel demo\r
+ * - Added new HIDReportViewer project\r
+ * - Added new MediaControl project\r
+ * - Added new AudioInputHost Host ClassDriver demo\r
+ * - Added new AudioOutputHost Host ClassDriver demo\r
+ * - Added new AudioInputHost Host LowLevel demo\r
+ * - Added new AudioOutputHost Host LowLevel demo\r
+ * - Added new "checksource" target to all library project makefiles\r
+ * - Added new VTARGET_USE_INTERNAL_REF configuration option to the AVRISP-MKII clone project (thanks to Volker Bosch)\r
+ *\r
+ * <b>Changed:</b>\r
+ * - Core:\r
+ * - Altered the definition of the USB_Audio_Descriptor_Format_t descriptor so that the user is now responsible for supplying\r
+ * the supported audio sampling rates, to allow for multiple audio interfaces with different numbers of supported rates and/or\r
+ * continuous sample rates\r
+ * - Pipe_BoundEndpointNumber() has been renamed to Pipe_GetBoundEndpointAddress(), and now returns the correct endpoint direction\r
+ * as part of the endpoint address\r
+ * - Renamed global state variables that are specific to a certain USB mode to clearly indicate which mode the variable relates to,\r
+ * by changing the USB_* prefix to USB_Device_* or USB_Host_*\r
+ * - Removed the HOST_STATE_WaitForDeviceRemoval and HOST_STATE_Suspended host state machine states, as these are no longer required\r
+ * - Altered the USB_Host_SetDeviceConfiguration() function to update the global Host state machine state and the new\r
+ * USB_Host_ConfigurationNumber global as required\r
+ * - Added endian correcting code to the library USB class drivers for multiple architecture support\r
+ * - Removed the ENDPOINT_DESCRIPTOR_DIR_* macros, replaced by ENDPOINT_DIR_* instead\r
+ * - Renamed the JTAG_DEBUG_ASSERT() macro to JTAG_ASSERT()\r
+ * - Added variable number of axis to HID_DESCRIPTOR_JOYSTICK() for multi-axis joysticks above just X and Y\r
+ * - Renamed USB_Host_ClearPipeStall() to USB_Host_ClearEndpointStall() as the function works on an endpoint address within the attached device,\r
+ * and not a Pipe within the host\r
+ * - The MS_Host_ResetMSInterface() now performs a full Mass Storage reset sequence to prevent data corruption in the event of a device\r
+ * lock up or timeout (thanks to David Lyons)\r
+ * - Added endian-correction to the CDC driver's Line Encoding control request handlers.\r
+ * - Library Applications:\r
+ * - Modified the Low Level and Class Driver AudioInput and AudioOutput demos to support multiple audio sample rates\r
+ * - Updated all host mode demos and projects to use the EVENT_USB_Host_DeviceEnumerationComplete() event callback for device configuration\r
+ * instead of manual host state machine manipulations in the main application task\r
+ * - Changed the reports in the GenericHID device demos to control the board LEDs, to reduce user confusion over the callback routines\r
+ * - Added reliability patches to the AVRISP-MKII Clone project's ISP and PDI/TPI protocols (thanks to Justin Mattair)\r
+ *\r
+ * <b>Fixed:</b>\r
+ * - Core:\r
+ * - Large number of documentation and code comment corrections (thanks to Andrey from Microsin.ru)\r
+ * - Fixed possibility of the AVR's SPI interface being pulled out of master mode if the /SS pin is a input and pulled low (thanks\r
+ * to Andrey from Microsin.ru)\r
+ * - Fixed compile error when FIXED_CONTROL_ENDPOINT_SIZE compile time option was disabled, and a USE_*_DESCRIPTORS compile time\r
+ * option was not enabled on the AVR8s\r
+ * - Fixed lack of C++ compatibility in some internal header files causing compile errors when using LUFA in C++ projects\r
+ * - Fixed error in the pipe unordered allocation algorithm for the AVR8 devices breaking compatibility with some devices\r
+ * - Fixed USB_USBTask not being called internally in stream transfers between packets when Partial Stream Transfers are used\r
+ * - Fixed swapped TWI_ADDRESS_READ and TWI_ADDRESS_WRITE values\r
+ * - Fixed TWI_ReadPacket() not releasing the TWI bus on read completion\r
+ * - Fixed optimization error in the HID Parser item value USB_SetHIDReportItemInfo() and USB_GetHIDReportItemInfo() routines if the report item was\r
+ * \c NULL (which should be allowable according to the API)\r
+ * - Fixed HID Parser CALLBACK_HIDParser_FilterHIDReportItem() callback function not being passed a cacheable report item pointer\r
+ * - Fixed HID Parser's largest report size bit count not including the size of the last parsed report item\r
+ * - Fixed HID host driver's largest HID report size count corrupt when the number of report bits exceeds 255\r
+ * - Library Applications:\r
+ * - Fixed incorrect signature in the CDC and DFU class bootloaders for the ATMEGA8U2\r
+ * - Fixed KeyboardHost and KeyboardHostWithParser demos displaying incorrect values when numerical keys were pressed\r
+ * - Fixed compile errors in the incomplete BluetoothHost demo application (thanks to Timo Lindfors)\r
+ * - Fixed incorrect Dataflash buffer use in the DataflashManager_WriteBlocks_RAM() function of several demos/projects (thanks to Jeremy Willden)\r
+ * - Fixed incorrect logging interval (always 500ms longer than requested) in the TempDataLogger project\r
+ * - Fixed incorrect buffer size check in the USBtoSerial project (thanks to Yuri A Nikiforov)\r
+ * - Fixed port state table corruption in the TCP layer of the RNDIS Ethernet device demos\r
+ *\r
+ * \section Sec_ChangeLog110528 Version 110528\r
+ * <b>New:</b>\r
+ * - Core:\r
+ * - Added new ORDERED_EP_CONFIG compile time option to restrict endpoint/pipe configuration to ascending order\r
+ * in exchange for a smaller compiled program binary size\r
+ * - Added a new general RingBuff.h miscellaneous ring buffer library driver header\r
+ * - Added new GCC_FORCE_POINTER_ACCESS() macro to correct GCC's mishandling of struct pointer accesses\r
+ * - Added new GCC_MEMORY_BARRIER() macro to prevent instruction reordering across boundaries\r
+ * - Added basic driver example use code to the library documentation\r
+ * - Added new Endpoint_Null_Stream() and Pipe_Null_Stream() functions\r
+ * - Added new ADC_GET_CHANNEL_MASK() convenience macro\r
+ * - Added new HID report item macros (with HID_RI_ prefix) to allow for easy creation and editing of HID report descriptors\r
+ * - Added new HID_DESCRIPTOR_MOUSE(), HID_DESCRIPTOR_KEYBOARD(), HID_DESCRIPTOR_JOYSTICK() and HID_DESCRIPTOR_VENDOR() macros\r
+ * for easy automatic creation of basic USB HID device reports\r
+ * - Added new MAX() and MIN() convenience macros\r
+ * - Added new Serial_SendData() function to the Serial driver\r
+ * - Added board driver support for the Sparkfun ATMEGA8U2 breakout board\r
+ * - Added TWI baud rate prescaler and bit length parameters to the TWI_Init() function (thanks to Thomas Herlinghaus)\r
+ * - Internal restructuring for eventual multiple architecture ports\r
+ * - Added AVR32 UC3 architecture port (currently incomplete/experimental)\r
+ * - Added new architecture independent functions to enable, disable, save and restore the Global Interrupt Enable flags\r
+ * - Added new RNDIS Device Class Driver packet send and receive functions\r
+ * - Library Applications:\r
+ * - Added ability to write protect Mass Storage disk write operations from the host OS\r
+ * - Added new MIDIToneGenerator project\r
+ * - Added new KeyboardMouseMultiReport Device ClassDriver demo\r
+ * - Added new VirtualSerialMassStorage Device ClassDriver demo\r
+ * - Added HID class bootloader, compatible with a modified version of the command line Teensy loader from PJRC.com\r
+ * - Added LED flashing to the CDC and DFU class bootloaders to indicate when they are running\r
+ *\r
+ * <b>Changed:</b>\r
+ * - Core:\r
+ * - Unordered Endpoint/Pipe configuration is now allowed once again by default via the previous reconfig workaround\r
+ * - Refactored Host mode Class Driver *_Host_ConfigurePipes() routines to be more space efficient when compiled\r
+ * - Added new *_ENUMERROR_PipeConfigurationFailed error codes for the *_Host_ConfigurePipes() routines\r
+ * - The USARTStream global is now public and documented in the SerialStream module, allowing for the serial USART\r
+ * stream to be accessed via its handle rather than via the implicit stdout and stdin streams\r
+ * - The FAST_STREAM_TRANSFERS compile time option has been removed due to lack of use and low cost/benefit ratio\r
+ * - Altered all endpoint/pipe stream transfers so that the new BytesProcessed parameter now points to a location\r
+ * where the number of bytes in the transfer that have been completed can be stored (or NULL if entire transaction\r
+ * should be performed in one chunk)\r
+ * - The NO_STREAM_CALLBACKS compile time option has now been removed due to the new partial stream transfer feature\r
+ * - Changed over all project and demo HID report descriptors to use the new HID report item macros\r
+ * - Moved the HIDParser.c source file to the LUFA/Drivers/USB/Class/Common/ directory from the LUFA/Drivers/USB/Class/Host/\r
+ * - Added support to the HID parser for extended USAGE items that contain the usage page as well as the usage index\r
+ * - Removed the SerialStream driver, rolled functionality into the regular Serial peripheral driver via the new\r
+ * Serial_CreateStream() and Serial_CreateBlockingStream() functions\r
+ * - Renamed the low level Serial byte send/receive functions, to be consistent with the CDC class driver byte functions\r
+ * - Altered the behaviour of the serial byte reception function so that is is non-blocking, and now returns a negative\r
+ * value if no character is received (to remain consistent with the CDC class driver byte reception routines)\r
+ * - Renamed the PRNT_Host_SendString(), CDC_Host_SendString() and CDC_Device_SendString() functions to *_SendData(), and\r
+ * added new versions of the *_SendString() routines that expect a null terminated string instead\r
+ * - Renamed all driver termination *_ShutDown() functions to the more logical name *_Disable()\r
+ * - Reduced latency for executing the Start-Of-Frame events (if enabled in the user application)\r
+ * - Removed Pipe_ClearErrorFlags(), pipe error flags are now automatically cleared when Pipe_ClearError() is called\r
+ * - Endpoint_ResetFIFO() renamed to Endpoint_ResetEndpoint(), to be consistent with the Pipe_ResetPipe() function name\r
+ * - Implemented on-demand PLL clock generation for the U4, U6 and U7 series USB AVRs when automatic PLL mode is specified\r
+ * - F_CLOCK changed to F_USB to be more descriptive, and applicable on future architecture ports\r
+ * - Renamed all low level Endpoint_Read_*, Endpoint_Write_* and Endpoint_Discard_* functions to use the number of bits instead of\r
+ * a symbolic size (Byte, Word, DWord) so that the function names are applicable and correct across all architectures\r
+ * - Renamed all low level Pipe_Read_*, Pipe_Write_* and Pipe_Discard_* functions to use the number of bits instead of\r
+ * a symbolic size (Byte, Word, DWord) so that the function names are applicable and correct across all architectures\r
+ * - Separated out board drivers by architecture in the library internals for better organisation\r
+ * - Library Applications:\r
+ * - Changed the XPLAINBridge software UART to use the regular timer CTC mode instead of the alternative CTC mode\r
+ * via the Input Capture register, to reduce user confusion\r
+ * - Combined page and word ISP programming mode code in the AVRISP-MKII clone project to reduce compiled size and\r
+ * increase maintainability of the code\r
+ * - Changed over library projects to use the new general ring buffer library driver module\r
+ * - Added new high level TWI packet read/write commands, altered behaviour of the TWI_StartTransmission() function\r
+ * - Changed TempDataLogger project's DS1307 driver to simplify the function interface and prevent a possible race condition\r
+ * - Changed AVRISP-MKII project to use the Watchdog interrupt for command timeouts, to reduce CPU usage and free timer 0\r
+ * for other uses\r
+ * - Updated the software USART code in the XPLAIN Bridge application so that the incoming bits are sampled at their mid-point\r
+ * instead of starting point, to give maximum reliability (thanks to Anton Staaf)\r
+ *\r
+ * <b>Fixed:</b>\r
+ * - Core:\r
+ * - Fixed broken USBFOO board drivers due to missing BOARD_USBFOO define\r
+ * - Fixed HID host class driver incorrectly binding to HID devices that do not have an OUT endpoint\r
+ * - Fixed incorrect definition of the HID_KEYBOARD_SC_D constant in the HID class driver (thanks to Opendous Inc.)\r
+ * - Fixed incorrect definition of the HID_KEYBOARD_SC_RIGHT_ARROW constant in the HID class driver (thanks to Joby Taffey)\r
+ * - Fixed incorrect endpoint initialisation order in the several device demos (thanks to Rick Drolet)\r
+ * - Fixed inverted Minimus board LEDs\r
+ * - Fixed incorrect byte ordering in the Audio_Device_WriteSample24 function (thanks to WZab)\r
+ * - Fixed several functions in the Host mode Still Image Class driver returning an error code from the incorrect\r
+ * error code enum (thanks to Daniel Seibert)\r
+ * - Fixed ReportID not being removed from the feature/out report data array in the HID class driver when Report IDs are used\r
+ * - Fixed incorrect BUTTONS_BUTTON1 definition for the Minimus board\r
+ * - Fixed Still Image Host class driver exiting the descriptor search routine prematurely if the data pipes (but not event pipe)\r
+ * is found\r
+ * - Fixed missing call to Pipe_SetInfiniteINRequests() in the Pipe_ConfigurePipe() routine\r
+ * - Fixed Remote Wakeup broken on the AVRs due to the mechanism only operating when the SUSPI bit is set (thanks to Holger Steinhaus)\r
+ * - Fixed possible invalid program execution when in host mode if corrupt descriptor lengths are supplied by the attached device\r
+ * - Library Applications:\r
+ * - Fixed Benito project discarding incoming data from the USB virtual serial port when the USART is busy\r
+ * - Fixed broken DFU bootloader, added XPLAIN support for bootloader start when XCK jumpered to ground\r
+ * - Fixed broken HID_REQ_GetReport request handler in the Low Level GenericHID demo\r
+ * - Fixed possible lost data in the XPLAINBridge, USBtoSerial and Benito projects when the host exceeds the packet\r
+ * timeout period on received packets as set by USB_STREAM_TIMEOUT_MS (thanks to Justin Rajewski)\r
+ * - Fixed possible programming problem in the AVRISP-MKII clone project when programming specific patterns into a target\r
+ * memory space that is only byte (not page) addressable\r
+ * - Fixed errors in the incomplete Test and Measurement device demo preventing proper operation (thanks to Pavel Plotnikov)\r
+ * - Fixed programming errors in the AVRISP-MKII project when the programming packet is a round multiple of the endpoint bank\r
+ * size under avrdude (thanks to Steffan Woltjer)\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog101122 Version 101122\r
+ * <b>New:</b>\r
+ * - Core:\r
+ * - Added new SCSI_ASENSE_NOT_READY_TO_READY_CHANGE constant to the Mass Storage class driver, to indicate when a previously\r
+ * not ready removable medium has now become ready for the host's use (thanks to Martin Degelsegger)\r
+ * - Moved the Pipe and Endpoint stream related code to two new USB library core source files EndpointStream.c and PipeStream.c\r
+ * - Added new USB_Device_GetFrameNumber() and USB_Host_GetFrameNumber() functions to retrieve the current USB frame number\r
+ * - Added new USB_Host_EnableSOFEvents(), USB_Host_DisableSOFEvents() and EVENT_USB_Host_StartOfFrame() for the user application\r
+ * handling of USB Start of Frame events while in USB Host mode\r
+ * - Added new PRNT_Host_BytesReceived(), PRNT_Host_ReceiveByte(), PRNT_Host_SendByte() and PRNT_Host_Flush() functions to the\r
+ * Print Host Class driver\r
+ * - Added class specific descriptor alternative struct type defines with standard USB-IF element naming\r
+ * - Added new project makefile template to the library and moved board driver stub files into in a new "CodeTemplates" directory\r
+ * - Added board hardware driver support for the Adafruit U4 breakout board\r
+ * - Added board hardware driver support for the Arduino Uno development board\r
+ * - Added board hardware driver support for the Blackcat USB JTAG board (thanks to the PSGroove team)\r
+ * - Added board hardware driver support for the Busware BUI development board\r
+ * - Added board hardware driver support for the Busware CUL V3 868MHZ radio board (thanks to Dirk Tostmann)\r
+ * - Added board hardware driver support for the Kernel Concepts USBFOO development board\r
+ * - Added board hardware driver support for the Linnix UDIP development board\r
+ * - Added board hardware driver support for the Olimex AVR-USB-162 development board (thanks to Steve Fawcett)\r
+ * - Added board hardware driver support for the Maximus board (thanks to the PSGroove team)\r
+ * - Added board hardware driver support for the Microsin AVR-USB162 breakout board\r
+ * - Added board hardware driver support for the Minimus board (thanks to the PSGroove team)\r
+ * - Added new NO_CLASS_DRIVER_AUTOFLUSH compile time option to disable automatic flushing of interfaces when the USB management\r
+ * tasks for each driver is called\r
+ * - Added standard keyboard HID report scan-code defines (thanks to Laszlo Monda)\r
+ * - Added new Pipe_GetBusyBanks(), Endpoint_GetBusyBanks() and Endpoint_AbortPendingIN() functions\r
+ * - Library Applications:\r
+ * - Added default test tone generation mode to the Device mode AudioInput demos\r
+ * - Added new NO_BLOCK_SUPPORT, NO_EEPROM_BYTE_SUPPORT, NO_FLASH_BYTE_SUPPORT and NO_LOCK_BYTE_WRITE_SUPPORT compile time options to the\r
+ * CDC class bootloader\r
+ * - Added new XCK_RESCUE_CLOCK_ENABLE compile time option to the AVRISP-MKII clone programmer project (thanks to Tom Light)\r
+ *\r
+ * <b>Changed:</b>\r
+ * - Core:\r
+ * - Removed complicated logic for the Endpoint_ConfigureEndpoint() function to use inlined or function called versions\r
+ * depending of if the given bank size is a compile time constant, as the compiler does a better job of optimizing\r
+ * with basic code\r
+ * - Changed the signature of the CALLBACK_USB_GetDescriptor() callback function so that the descriptor pointer is const, to remove\r
+ * the need for extra casting inside the callback (thanks to Jonathan Kollasch)\r
+ * - Reduced HOST_DEVICE_SETTLE_DELAY_MS to 1000ms down from 1500ms to improve device compatibility while in USB Host mode\r
+ * - Removed the EVENT_USB_InitFailure() event, not specifying a USB mode correctly now defaults to UID selection mode\r
+ * - Renamed and moved class driver common constant definitions to make the naming scheme more uniform\r
+ * - Moved the USB mode specifier constants into a new enum, so that they are semantically related to one another\r
+ * - Renamed ENDPOINT_DOUBLEBANK_SUPPORTED() to ENDPOINT_BANKS_SUPPORTED() and changed it to return the maximum number of supported banks for\r
+ * the given endpoint\r
+ * - Better algorithm to extract and convert the internal device serial number into a string descriptor (if present)\r
+ * - All USB class drivers are now automatically included when LUFA/Drivers/USB.h is included, and no longer need to be separately included\r
+ * - The MIDI class drivers now automatically flushes the MIDI interface when the MIDI class driver's USBTask() function is called\r
+ * - Renamed the EVENT_USB_Device_UnhandledControlRequest() event to EVENT_USB_Device_ControlRequest() as it is now fired before the library\r
+ * request handlers, not afterwards\r
+ * - Library Applications:\r
+ * - Changed over all device demos to use a clearer algorithm for the configuring of the application's endpoints\r
+ * - Added missing DataflashManager_CheckDataflashOperation() function to the MassStorageKeyboard demo, removed redundant\r
+ * SCSI_Codes.h file as these values are part of the MassStorage Class Driver\r
+ * - Added compile time error to the AVRISP-MKII project when built for the U4 chips, as the default VTARGET detection ADC channel\r
+ * does not exist on these chips (thanks to Marco)\r
+ * - Changed all Device mode LowLevel demos and Device Class drivers so that the control request is acknowledged and any data\r
+ * transferred as quickly as possible without any processing in between sections, so that long callbacks or event handlers will\r
+ * not break communications with the host by exceeding the maximum control request stage timeout period\r
+ * - Changed over all demos, drivers and internal functions to use the current frame number over the Start of Frame flag where possible\r
+ * to free up the Start of Frame flag for interrupt use in the user application\r
+ * - All project makefiles now correctly clean intermediate build files from assembly and C++ sources (thanks to Daniel Czigany)\r
+ * - Changed default value for the reset polarity parameter in the AVRISP-MKII project so that it defaults to active low drive\r
+ * - Changed configuration descriptor parser for all host mode projects and class drivers to ensure better compatibility with devices\r
+ * - All LowLevel demos changed to use the constants and types defined in the USB class drivers\r
+ * - Changed AudioInput and AudioOutput demos to reload the next sample via an interrupt rather than polling the sample timer\r
+ * - Rescue clock of the AVRISP-MKII moved to the AVR's OCR1A pin, so that the clock can be generated at all times\r
+ * - Changed ClassDriver MIDI demos to process all incoming events in a loop until the bank becomes empty rather than one at a time\r
+ * - Changed LowLevel MIDI demos to only clear the incoming event bank once it has become empty to support packed event packets\r
+ *\r
+ * <b>Fixed:</b>\r
+ * - Core:\r
+ * - Fixed USB_GetHIDReportItemInfo() function modifying the given report item's data when the report item does not exist\r
+ * within the supplied report of a multiple report HID device\r
+ * - Fixed critical pipe/endpoint memory allocation issue where the bank memory address space could be silently overlapped\r
+ * in the USB controller if the endpoints or pipes were allocated in anything other than ascending order (thanks to Martin Degelsegger)\r
+ * - Added LEDs_ToggleLEDs() function to several board LED drivers which were missing it (thanks to Andrei Krainev)\r
+ * - Fixed SET FEATURE and CLEAR FEATURE control requests directed at an unconfigured endpoint causing request timeouts\r
+ * - Fixed USB_Host_ClearPipeStall() incorrectly determining the endpoint direction from the currently selected pipe\r
+ * - Fixed JTAG_DEBUG_POINT() and JTAG_DEBUG_BREAK() macros not compiling under pure C99 standards mode\r
+ * - Fixed endpoint selection within the CALLBACK_HID_Device_CreateHIDReport() callback function causing broken GET REPORT requests\r
+ * - Fixed incorrect command name for EEPROM memory programming in the makefile dfu-ee target\r
+ * - Fixed incorrect LEDs_ChangeLEDs() function in the Benito board LED driver\r
+ * - Fixed incorrect USB_DeviceState value when unconfiguring the device without an address set\r
+ * - Fixed SPI driver not explicitly setting /SS and MISO pins as inputs when SPI_Init() is called\r
+ * - Fixed random enumeration failure while in device mode due to interrupts causing the Set Address request to exceed maximum timings\r
+ * - Fixed MIDI_Host_Flush() not aborting early when the specified MIDI host interface was not configured\r
+ * - Fixed MIDI class driver send routines silently discarding packets if the endpoint or pipe is busy (thanks to Robin Green)\r
+ * - Library Applications:\r
+ * - Fixed MassStorage based demos and projects resetting the SCSI sense values before the command is executed, leading to\r
+ * missed SCSI sense values when the host retrieves the sense key (thanks to Martin Degelsegger)\r
+ * - Fixed USBtoSerial and Benito project SetLineEncoding calls failing if the USART is busy, due to the RX ISR delaying the control\r
+ * request handler\r
+ * - Fixed LowLevel PrinterHost demo not sending control requests to the attached printer with the correct printer interface wIndex value\r
+ * - Fixed incorrect signature reported in the CDC class bootloader for the ATMEGA32U2\r
+ * - Fixed BootloaderCDC project failing on some operating systems due to removed Line Encoding options (thanks to Alexey Belyaev)\r
+ * - Fixed broken FLASH/EEPROM programming in the AVRISP-MKII clone project when writing in non-paged mode and the polling byte cannot be used\r
+ * - Fixed ISR definition conflict in the XPLAIN bridge between the software UART and the AVRISP-MKII ISP modules\r
+ * - Fixed USBtoSerial and XPLAINBridge demos discarding data from the PC if the send buffer becomes full\r
+ * - Fixed broken input in the MagStripe reader project due to an incorrect HID report descriptor\r
+ * - Fixed incorrect PollingIntervalMS values in the demo/project/bootloader endpoint descriptors (thanks to MCS Electronics)\r
+ * - Fixed AVRISP-MKII clone project not starting the target's program automatically after exiting TPI programming mode\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog100807 Version 100807\r
+ * <b>New:</b>\r
+ * - Added new ADC_DisableChannel() function (thanks to Mich Davis)\r
+ * - Added new VTARGET_REF_VOLTS and VTARGET_SCALE_FACTOR compile time defines to the AVRISP-MKII programmer project to set\r
+ * the VTARGET reference voltage and scale factor\r
+ * - Added new pgm_read_ptr() macro to Common.h for reading of pointers out of flash memory space\r
+ * - Added new SWAPENDIAN_16() and SWAPENDIAN_32() macros to Common.h for statically initialized variables at compile time\r
+ * - Added new Drivers/USB/LowLevel/Device.c file to house Device mode specific functions that are more complicated than simple macros\r
+ * - Added new AVRStudio 4 project files for all library demos, projects and bootloaders\r
+ * - Added ability to set the serial baud rate via the user's terminal in the XPLAINBridge project\r
+ * - Added new LUFA module variables for the different source modules in the core library makefile to simplify project makefiles\r
+ * - Added start of a new Test and Measurement class demo (thanks to Peter Lawrence)\r
+ * - Added new SPI_ORDER_* data order masks to the SPI peripheral driver\r
+ * - Added support to the AVRISP-MKII project for ISP speeds slower than 125KHz via a new software SPI driver\r
+ * - Added support for the new button/LED on the latest model USBTINY-MKII\r
+ *\r
+ * <b>Changed:</b>\r
+ * - The RingBuff library code has been replaced in the XPLAINBridge, Benito and USBtoSerial projects with an ultra lightweight\r
+ * ring buffer to help improve the reliability of the projects\r
+ * - The EEPROM stream read/write functions now use eeprom_update_byte() instead of eeprom_write_byte(), so that only\r
+ * changed bytes are written to EEPROM to preserve its lifespan\r
+ * - Changed over the AVRISP-MKII and TemperatureDataLogger projects to use eeprom_update_byte() when writing non-volatile\r
+ * parameters to EEPROM to preserve its lifespan\r
+ * - Removed unused line encoding data and control requests from the CDC Bootloader code, to save space\r
+ * - Renamed SERIAL_STREAM_ASSERT() macro to STDOUT_ASSERT()\r
+ * - The USB_Device_IsRemoteWakeupSent() and USB_Device_IsUSBSuspended() macros have been deleted, as they are now obsolete\r
+ * - Rewrote the implementation of the SwapEndian_16() and SwapEndian_32() functions so that they compile down in most instances to\r
+ * minimal loads and stores rather than complicated shifts\r
+ * - The software UART in the XPLAINBridge has been largely altered to try to improve upon its performance and reliability\r
+ * - The USBtoSerial and Benito projects now flushes received data via a flush timer, so that several bytes can be transmitted at once\r
+ * - Removed the automated checking of event names in the demo, project and bootloader makefiles due to inconsistencies between the\r
+ * behaviour of the command line tools used to perform the check on each platform\r
+ * - Internal USB driver source files renamed and moved to ease future possible architecture ports\r
+ * - All internal pseudo-function macros have been converted to true inline functions for type-safety and readability\r
+ * - Changed LED indicator masks for the AVRISP-MKII project, so that there are defined roles for each LED\r
+ * - Altered the CDC Device and Host Class drivers' receive byte routines, so that no data is indicated by the function returning a\r
+ * negative value (thanks to Andreas Paulin)\r
+ * - Added auto flushing of OUT data to the CDC Host Class driver's USBTask function to automatically flush the send pipe buffer\r
+ *\r
+ * <b>Fixed:</b>\r
+ * - Fixed AVRISP project sending a LOAD EXTENDED ADDRESS command to 128KB AVRs after programming or reading from\r
+ * the last page of FLASH (thanks to Gerard Sexton)\r
+ * - Fixed AVRISP project not sending a full erase-and-write EEPROM command to XMEGA targets when writing to the EEPROM\r
+ * instead of the split write-only command (thanks to Tim Margush)\r
+ * - Fixed RNDISEthernet demos crashing when calculating checksums for Ethernet/TCP packets of more than ~500 bytes due to\r
+ * an overflow in the checksum calculation loop (thanks to Kevin Malec)\r
+ * - Fixed XPLAINBridge project not correctly reading the XMEGA's supply voltage when reporting back to the host\r
+ * - Fixed incorrect signature for the ATMEGA32U2 in the DFU bootloader (thanks to Axel Rohde)\r
+ * - Fixed internal device serial not being accessible on the ATMEGAXXU2 AVRs (thanks to Axel Rohde)\r
+ * - Fixed void pointer arithmetic in ConfigDescriptor.h breaking C++ compatibility (thanks to Michael Hennebry)\r
+ * - Fixed broken PDI EEPROM Section Erase functionality in the AVRISP-MKII project\r
+ * - Fixed USB_Device_SendRemoteWakeup() not working when the USB clock was frozen during USB bus suspend (thanks to Brian Dickman)\r
+ * - Fixed occasional lockup of the AVRISP project due to the timeout extension code incorrectly extending the timeout in\r
+ * PDI and TPI programming modes infinitely\r
+ * - Fixed HID device class driver still using PrevReportINBuffer for GetReport control requests even when it has been\r
+ * set to NULL by the user application (thanks to Axel Rohde)\r
+ * - Fixed MIDI_Device_SendEventPacket() not correctly waiting for the endpoint to become ready (thanks to Robin Green)\r
+ * - Fixed Benito and USBtoSerial projects not turning off the USART before reconfiguring it, which could cause incorrect\r
+ * operation to occur (thanks to Bob Paddock)\r
+ * - Fixed Serial peripheral driver not turning off the USART before reconfiguring it, which would cause incorrect operation\r
+ * to occur (thanks to Bob Paddock)\r
+ * - Fixed software application start command broken in the DFU class bootloader when dfu-programmer is used due to application\r
+ * start address corruption\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog100513 Version 100513\r
+ * <b>New:</b>\r
+ * - Added incomplete MIDIToneGenerator project\r
+ * - Added new Relay Controller Board project (thanks to OBinou)\r
+ * - Added board hardware driver support for the Teensy, USBTINY MKII, Benito and JM-DB-U2 lines of third party USB AVR boards\r
+ * - Added new ATTR_NO_INIT variable attribute for global variables that should not be automatically cleared on startup\r
+ * - Added new ENDPOINT_*_BusSuspended error code to the Endpoint function, so that the stream functions early-abort if the bus\r
+ * is suspended before or during a transfer\r
+ * - Added new EVENT_CDC_Device_BreakSent() event and CDC_Host_SendBreak() function to the Device and Host CDC Class drivers\r
+ * - Added ReportType parameter to the HID device class driver CALLBACK_HID_Device_ProcessHIDReport() function so that FEATURE\r
+ * reports from the host to the device can be correctly processed\r
+ * - Added ReportType parameter to the HID host class driver HID_Host_SendReportByID() function so that FEATURE reports can be\r
+ * issued to the attached device\r
+ *\r
+ * <b>Changed:</b>\r
+ * - AVRISP programmer project now has a more robust timeout system\r
+ * - Added a timeout value to the TWI_StartTransmission() function, within which the addressed device must respond\r
+ * - Webserver project now uses the board LEDs to indicate the current IP configuration state\r
+ * - Added ENABLE_TELNET_SERVER compile time option to the Webserver project to disable the TELNET server if desired\r
+ * - Increased throughput of the USBtoSerial demo on systems that send multiple bytes per packet (thanks to Opendous Inc.)\r
+ * - Double bank CDC endpoints in the XPLAIN Bridge project, re-enable JTAG once the mode selection pin has been sampled.\r
+ * - Standardized the naming scheme given to configuration descriptor sub-elements in the Device mode demos, bootloaders\r
+ * and projects\r
+ * - All Class Driver Host mode demos now correctly set the board LEDs to READY once the enumeration process has completed\r
+ * - Added LIBUSB_FILTERDRV_COMPAT compile time option to the AVRISP programmer project to make the code compatible with Windows\r
+ * builds of avrdude at the expense of AVRStudio compatibility\r
+ * - Removed two-step endpoint/pipe bank clear and switch sequence for smaller, faster endpoint/pipe code\r
+ * - The USB_Init() function no longer calls sei() - the user is now responsible for enabling interrupts when they are ready\r
+ * for them to be enabled (thanks to Andrei Krainev)\r
+ * - The Audio_Device_IsSampleReceived() and Audio_Device_IsReadyForNextSample() functions are now inline, to reduce overhead\r
+ * - Removed the cast to uint16_t on the set baud rate in the USBtoSerial project, so that the higher >1M baud rates can be\r
+ * selected (thanks to Steffan Woltjer)\r
+ * - Removed software PDI and TPI emulation from the AVRISP-MKII clone project as it was very buggy and slow - PDI and TPI must\r
+ * now be implemented via separate programming headers\r
+ * - The CDC class bootloader now uses a watchdog reset rather than a soft-reset when exited to ensure that all hardware is\r
+ * properly reset to their defaults\r
+ * - Device mode class driver callbacks are now fired before the control request status stage is sent to prevent the host from\r
+ * timing out if another request is immediately fired and the device has a lengthy callback routine\r
+ * - The TeensyHID bootloader has been removed, per request from Paul at PJRC\r
+ * - The LIBUSB_FILTERDRV_COMPAT compile time option in the XPLAINBridge and AVRISP-MKII projects has been renamed\r
+ * LIBUSB_DRIVER_COMPAT, as it applies to all software on all platforms using the libUSB driver\r
+ *\r
+ * <b>Fixed:</b>\r
+ * - Fixed possible device lockup when INTERRUPT_CONTROL_ENDPOINT is enabled and the control endpoint is not properly\r
+ * selected when the ISR completes\r
+ * - Fixed AVRISP-MKII clone project not correctly issuing LOAD EXTENDED ADDRESS commands when the extended address\r
+ * boundary is crossed during programming or read back (thanks to Gerard Sexton)\r
+ * - Fixed warnings when building the AVRISP-MKII clone project with the ENABLE_XPROG_PROTOCOL compile time option disabled\r
+ * - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin\r
+ * - Fixed TWI_StartTransmission() corrupting the contents of the GPIOR0 register\r
+ * - Fixed TWI driver not aborting when faced with no response after attempting to address a device on the bus\r
+ * - Fixed ADC routines not correctly returning the last result when multiple channels were read\r
+ * - Fixed ADC routines failing to read the extended channels (Channels 8 to 13, Internal Temperature Sensor) on the\r
+ * U4 series USB AVR parts\r
+ * - Fixed LowLevel MassStorage demo broken on the U2 series USB AVRs due to unsupported double-banked endpoint modes used\r
+ * - Fixed compilation error in the AudioInput demos when MICROPHONE_BIASED_TO_HALF_RAIL is defined (thanks to C. Scott Ananian)\r
+ * - Fixed incorrect definition of HID_ALIGN_DATA() causing incorrect HID report item data alignment\r
+ * - Fixed Still Image Host class driver not resetting the transaction ID when a new session is opened, fixed driver not sending\r
+ * a valid session ID to the device\r
+ * - Removed invalid dfu and flip related targets from the bootloaders - bootloaders can only be replaced with an external programmer\r
+ * - Fixed Set/Clear Feature requests directed to a non-configured endpoint not returning a stall to the host\r
+ * - Fixed HID Device Class Driver not allocating a temporary buffer when the host requests a report via the control endpoint and the\r
+ * user has set the PrevReportINBuffer driver configuration element to NULL (thanks to Lars Noschinski)\r
+ * - Fixed device state not being reset to DEVICE_STATE_Default if the host sets a 0x00 device address\r
+ * - Fixed device not stalling configuration requests before the device's address has been set\r
+ * - Fixed possibility of internal signature retrieval being corrupted if an interrupt occurs during a signature byte\r
+ * read (thanks to Andrei Krainev)\r
+ * - Fixed device state not being reset back to the default state if the host sets the address to 0\r
+ * - Fixed Set Configuration requests not being stalled until the host has set the device's address\r
+ * - Fixed Host mode HID class driver not sending the correct report type when HID_Host_SendReportByID() was called and the\r
+ * HID_HOST_BOOT_PROTOCOL_ONLY compile time option is set\r
+ * - Fixed INTERRUPT_CONTROL_ENDPOINT compile time option preventing other interrupts from occurring while the control endpoint\r
+ * request is being processed, causing possible lockups if a USB interrupt occurs during a transfer\r
+ * - Remove incorrect Abstract Call Management class specific descriptor from the CDC demos, bootloaders and projects\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog100219 Version 100219\r
+ *\r
+ * <b>New:</b>\r
+ * - Added TPI programming support for 6-pin ATTINY devices to the AVRISP programmer project (thanks to Tom Light)\r
+ * - Added command timeout counter to the AVRISP project so that the device no longer freezes when incorrectly connected\r
+ * to a target\r
+ * - Added new TemperatureDataLogger application, a USB data logger which writes to the device's dataflash and appears to\r
+ * the host as a standard Mass Storage device when inserted\r
+ * - Added MIDI event packing support to the MIDI Device and Host mode Class drivers, allowing for multiple MIDI events to\r
+ * sent or received in packed form in a single USB packet\r
+ * - Added new MIDI send buffer flush routines to the MIDI Device and Host mode Class drivers, to flush packed events\r
+ * - Added master mode hardware TWI driver for easy TWI peripheral control\r
+ * - Added ADC MUX masks for the standard ADC input channels on all AVR models with an ADC, altered demos to use these masks\r
+ * as on some models, the channel number is not identical to its single-ended ADC MUX mask\r
+ * - New Webserver project, a RNDIS host USB webserver using the open source uIP TCP/IP network stack and FatFS library\r
+ * - New BOARD value option BOARD_NONE (equivalent to not specifying BOARD) which will remove all board hardware drivers which\r
+ * do not adversely affect the code operation (currently only the LEDs driver)\r
+ * - Added keyboard modifier masks (HID_KEYBOARD_MODIFER_*) and LED report masks (KEYBOARD_LED_*) to the HID class driver and\r
+ * Keyboard demos\r
+ * - Added .5MHz recovery clock to the AVRISP programmer project when in ISP programming mode to correct mis-set fuses\r
+ *\r
+ * <b>Changed:</b>\r
+ * - Slowed down software USART carried PDI programming in the AVRISP project to prevent transmission errors\r
+ * - Renamed the AVRISP project folder to AVRISP-MKII to reduce confusion\r
+ * - Renamed the RESET_LINE_* makefile tokens in the AVRISP MKII Project to AUX_LINE_*, as they are not always used for target\r
+ * reset\r
+ * - Changed over the MassStorageKeyboard Class driver device demo to use Start of Frame events rather than a timer to keep track\r
+ * of elapsed milliseconds\r
+ * - Inlined currently unused (but standardized) maintenance functions in the Device and Host Class drivers to save space\r
+ * - The XPLAINBridge project now selects between a USB to Serial bridge and a PDI programmer on startup, reading the JTAG port's\r
+ * TDI pin to determine which mode to use\r
+ * - Removed the stream example code from the Low Level VirtualSerial demos, as they were buggy and only served to add clutter\r
+ *\r
+ * <b>Fixed:</b>\r
+ * - Fixed AVRISP project not able to enter programming mode when ISP protocol is used\r
+ * - Fixed AVRISP PDI race condition where the guard time between direction changes could be interpreted as a start bit\r
+ * - Fixed ADC_IsReadingComplete() returning an inverted result\r
+ * - Fixed blocking CDC streams not aborting when the host is disconnected\r
+ * - Fixed XPLAIN board Dataflash driver broken due to incorrect preprocessor commands\r
+ * - Fixed inverted XPLAIN LED driver output (LED turned on when it was supposed to be turned off, and vice-versa)\r
+ * - Fixed Class Driver struct interface numbers in the KeyboardMouse and VirtualSerialMouse demos (thanks to Renaud Cerrato)\r
+ * - Fixed invalid USB controller PLL prescaler values for the ATMEGAxxU2 controllers\r
+ * - Fixed lack of support for the ATMEGA32U2 in the DFU and CDC class bootloaders\r
+ * - Fixed Benito project not resetting the target AVR automatically when programming has completed\r
+ * - Fixed DFU bootloader programming not discarding the correct number of filler bytes from the host when non-aligned programming\r
+ * ranges are specified (thanks to Thomas Bleeker)\r
+ * - Fixed CDC and RNDIS host demos and class drivers - bidirectional endpoints should use two separate pipes, not one half-duplex pipe\r
+ * - Fixed Pipe_IsEndpointBound() not taking the endpoint's direction into account\r
+ * - Fixed EEPROM and FLASH ISP programming in the AVRISP project\r
+ * - Fixed incorrect values of USB_CONFIG_ATTR_SELFPOWERED and USB_CONFIG_ATTR_REMOTEWAKEUP tokens (thanks to Claus Christensen)\r
+ * - Fixed SerialStream driver blocking while waiting for characters to be received instead of returning EOF\r
+ * - Fixed SerialStream driver not setting stdin to the created serial stream (thanks to Mike Alexander)\r
+ * - Fixed USB_GetHIDReportSize() returning the number of bits in the specified report instead of bytes\r
+ * - Fixed AVRISP project not extending the command delay after each successful page/word/byte program\r
+ * - Fixed accuracy of the SERIAL_UBBRVAL() and SERIAL_2X_UBBRVAL() macros for higher baud rates (thanks to Renaud Cerrato)\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog091223 Version 091223\r
+ *\r
+ * <b>New:</b>\r
+ * - Added activity LED indicators to the AVRISP project to indicate when the device is busy processing a command\r
+ * - The USB target family and allowable USB mode tokens are now public and documented (USB_CAN_BE_*, USB_SERIES_*_AVR)\r
+ * - Added new XPLAIN USB to Serial Bridge project (thanks to John Steggall for initial proof-of-concept, David Prentice\r
+ * and Peter Danneger for revised software USART code)\r
+ * - Added new RNDIS Ethernet Host LowLevel demo\r
+ * - Added new RNDIS Ethernet Host Class Driver\r
+ * - Added new RNDIS Ethernet Host ClassDriver demo\r
+ * - Added CDC_Host_Flush() function to the CDC Host Class driver to flush sent data to the attached device\r
+ * - Added PDI programming support for XMEGA devices to the AVRISP programmer project (thanks to Justin Mattair)\r
+ * - Added support for the XPLAIN board Dataflash, with new XPLAIN_REV1 board target for the different dataflash used\r
+ * on the first revision boards compared to the one mounted on later revisions\r
+ * - Added new HID_ALIGN_DATA() macro to return the pre-retrieved value of a HID report item, left-aligned to a given datatype\r
+ * - Added new PreviousValue to the HID Report Parser report item structure, for easy monitoring of previous report item values\r
+ * - Added new EVK527 board target\r
+ * - Added new USB_Host_GetDeviceStringDescriptor() convenience function\r
+ * - Added new LEDNotification project to the library, to give a visual LED notification on new events from the host\r
+ * - Added new NO_DEVICE_REMOTE_WAKEUP and NO_DEVICE_SELF_POWER compile time options\r
+ *\r
+ * <b>Changed:</b>\r
+ * - Removed code in the Keyboard demos to send zeroed reports between two reports with differing numbers of key codes\r
+ * as this relied on non-standard OS driver behaviour to repeat key groups\r
+ * - The SCSI_Request_Sense_Response_t and SCSI_Inquiry_Response_t type defines are now part of the Mass Storage Class\r
+ * driver common defines, rather than being defined in the Host mode Class driver section only\r
+ * - The USB_MODE_HOST token is now defined even when host mode is not available\r
+ * - The CALLBACK_HID_Device_CreateHIDReport() HID Device Class driver callback now has a new ReportType parameter to\r
+ * indicate the report type to generate\r
+ * - All Class Drivers now return false or the "DeviceDisconnected" error code of their respective error enums when a function\r
+ * is called when no host/device is connected where possible\r
+ * - The HOST_SENDCONTROL_DeviceDisconnect enum value has been renamed to HOST_SENDCONTROL_DeviceDisconnected to be in line\r
+ * with the rest of the library error codes\r
+ * - Make MIDI device demos also turn off the on board LEDs if MIDI Note On messages are sent with a velocity of zero,\r
+ * which some devices use instead of Note Off messages (thanks to Robin Green)\r
+ * - The CDC demos are now named "VirtualSerial" instead to indicate the demos' function rather than its implemented USB class,\r
+ * to reduce confusion and to be in line with the rest of the LUFA demos\r
+ * - The SImage_Host_SendBlockHeader() and SImage_Host_ReceiveBlockHeader() Still Image Host Class driver functions are now public\r
+ *\r
+ * <b>Fixed:</b>\r
+ * - Added missing CDC_Host_CreateBlockingStream() function code to the CDC Host Class driver\r
+ * - Fixed incorrect values for REPORT_ITEM_TYPE_* enum values causing corrupt data in the HID Host Parser\r
+ * - Fixed misnamed SI_Host_USBTask() and SI_Host_ConfigurePipes() functions\r
+ * - Fixed broken USB_GetNextDescriptor() function causing the descriptor to jump ahead double the expected amount\r
+ * - Fixed Pipe_IsEndpointBound() not masking the given Endpoint Address against PIPE_EPNUM_MASK\r
+ * - Fixed host state machine not enabling Auto VBUS mode when HOST_DEVICE_SETTLE_DELAY_MS is set to zero\r
+ * - Fixed misnamed Pipe_SetPipeToken() macro for setting a pipe's direction\r
+ * - Fixed CDCHost failing on devices with bidirectional endpoints\r
+ * - Fixed USB driver failing to define the PLL prescaler mask for the ATMEGA8U2 and ATMEGA16U2\r
+ * - Fixed HID Parser not distributing the Usage Min and Usage Max values across an array of report items\r
+ * - Fixed Mass Storage Host Class driver and Low Level demo not clearing the error condition if an attached device returns a\r
+ * STALL to a GET MAX LUN request (thanks to Martin Luxen)\r
+ * - Fixed TeensyHID bootloader not properly shutting down the USB interface to trigger a disconnection on the host before resetting\r
+ * - Fixed MassStorageHost Class driver demo not having USB_STREAM_TIMEOUT_MS compile time option set properly to prevent slow\r
+ * devices from timing out the data pipes\r
+ * - Fixed the definition of the Endpoint_BytesInEndpoint() macro for the U4 series AVR parts\r
+ * - Fixed MIDI host Class driver MIDI_Host_SendEventPacket() routine not properly checking for Pipe ready before writing\r
+ * - Fixed use of deprecated struct initializers, removed library unused parameter warnings when compiled with -Wextra enabled\r
+ * - Fixed Still Image Host Class driver truncating the PIMA response code (thanks to Daniel Seibert)\r
+ * - Fixed USB_CurrentMode not being reset to USB_MODE_NONE when the USB interface is shut down and both Host and Device modes can be\r
+ * used (thanks to Daniel Levy)\r
+ * - Fixed TeensyHID bootloader not enumerating to the host correctly (thanks to Clint Fisher)\r
+ * - Fixed AVRISP project timeouts not checking for the correct timeout period (thanks to Carl Ott)\r
+ * - Fixed STK525 Dataflash driver using incorrect bit-shifting for Dataflash addresses (thanks to Tim Mitchell)\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog091122 Version 091122\r
+ *\r
+ * <b>New:</b>\r
+ * - Added new Dual Role Keyboard/Mouse demo\r
+ * - Added new HID_HOST_BOOT_PROTOCOL_ONLY compile time token to reduce the size of the HID Host Class driver when\r
+ * Report protocol is not needed\r
+ * - Added new MIDI LowLevel and ClassDriver Host demo, add new MIDI Host Class driver\r
+ * - Added new CDC/Mouse ClassDriver device demo\r
+ * - Added new Joystick Host ClassDriver and LowLevel demos\r
+ * - Added new Printer Host mode Class driver\r
+ * - Added new Printer Host mode ClassDriver demo\r
+ * - Added optional support for double banked endpoints and pipes in the Device and Host mode Class drivers\r
+ * - Added new stream creation function to the CDC Class drivers, to easily make standard I/O streams from CDC Class driver instances\r
+ *\r
+ * <b>Changed:</b>\r
+ * - Removed mostly useless "TestApp" demo, as it was mainly useful only for checking for syntax errors in the library\r
+ * - MIDI device demos now receive MIDI events from the host and display note ON messages via the board LEDs\r
+ * - Cleanups to the Device mode Mass Storage demo application SCSI routines\r
+ * - Changed Audio Class driver sample read/write functions to be inline, to reduce the number of cycles needed to transfer\r
+ * samples to and from the device (allowing more time for sample processing and output)\r
+ * - Audio class Device mode demos now work at both 16MHz and 8MHz, rather than just at 8MHz\r
+ * - The previous USBtoSerial demo has been moved into the projects directory, as it was just a modified CDC demo\r
+ * - The Endpoint/Pipe functions now use the const qualifier on the input buffer\r
+ * - Changed the CALLBACK_HIDParser_FilterHIDReportItem() callback to pass a HID_ReportItem_t rather than just the current\r
+ * item's attributes, to expose more information on the item (including it's type, collection path, etc.)\r
+ * - Changed MouseHostWithParser demos to check that the report items have a Mouse usage collection as a parent at some point,\r
+ * to prevent Joysticks from enumerating with the demo\r
+ * - Corrected the name of the misnamed USB_GetDeviceConfigDescriptor() function to USB_Host_GetDeviceConfigDescriptor().\r
+ * - Keyboard LowLevel/ClassDriver demos now support multiple simultaneous key presses (up to 6) per report\r
+ *\r
+ * <b>Fixed:</b>\r
+ * - Fixed PrinterHost demo returning invalid Device ID data when the attached device does not have a\r
+ * device ID (thanks to Andrei Krainev)\r
+ * - Changed LUFA_VERSION_INTEGER define to use BCD values, to make comparisons easier\r
+ * - Fixed issue in the HID Host class driver's HID_Host_SendReportByID() routine using the incorrect mode (control/pipe)\r
+ * to send report to the attached device\r
+ * - Fixed ClassDriver AudioOutput device demo not selecting an audio output mode\r
+ * - Fixed incorrect SampleFrequencyType value in the AudioInput and AudioOutput ClassDriver demos' descriptors\r
+ * - Fixed incorrect event name rule in demo/project/bootloader makefiles\r
+ * - Fixed HID device class driver not reselecting the correct endpoint once the user callback routines have been called\r
+ * - Corrected HID descriptor in the Joystick Device demos - buttons should be placed outside the pointer collection\r
+ * - Fixed HID report parser collection paths invalid due to misplaced semicolon in the free path item search loop\r
+ * - Fixed HID host Class driver report send/receive report broken when issued through the control pipe\r
+ * - Fixed HOST_STATE_AS_GPIOR compile time option being ignored when in host mode (thanks to David Lyons)\r
+ * - Fixed LowLevel Keyboard demo not saving the issues report only after it has been sent to the host\r
+ * - Fixed Endpoint_Write_Control_Stream_* functions not sending a terminating IN when given data Length is zero\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog090924 Version 090924\r
+ *\r
+ * <b>New:</b>\r
+ * - Added new host mode class drivers and matching demos to the library for rapid application development\r
+ * - Added flag to the HID report parser to indicate if a device has multiple reports\r
+ * - Added new EVENT_USB_Device_StartOfFrame() event, controlled by the new USB_Device_EnableSOFEvents() and\r
+ * USB_Device_DisableSOFEvents() macros to give bus-synchronized millisecond interrupts when in USB device mode\r
+ * - Added new Endpoint_SetEndpointDirection() macro for bidirectional endpoints\r
+ * - Added new AVRISP project, a LUFA powered clone of the Atmel AVRISP-MKII programmer\r
+ * - Added ShutDown() functions for all hardware peripheral drivers, so that peripherals can be turned off after use\r
+ * - Added new CDC_Device_Flush() command to the device mode CDC Class driver to flush Device->Host data\r
+ * - Added extra masks to the SPI driver, changed SPI_Init() so that the clock polarity and sample modes can be set\r
+ * - Added new callback to the HID report parser, so that the user application can filter only the items it is interested\r
+ * in to be stored into the HIDReportInfo structure to save RAM\r
+ * - Added support for the officially recommended external peripheral layout for the BUMBLEB board (thanks to Dave Fletcher)\r
+ * - Added new Pipe_IsFrozen() macro to determine if the currently selected pipe is frozen\r
+ * - Added new USB_GetHIDReportSize() function to the HID report parser to retrieve the size of a given report by its ID\r
+ * - Added new combined Mass Storage and Keyboard demo (thanks to Matthias Hullin)\r
+ *\r
+ * <b>Changed:</b>\r
+ * - SetIdle requests to the HID device driver with a 0 idle period (send changes only) now only affect the requested\r
+ * HID interface within the device, not all HID interfaces\r
+ * - Added explicit attribute masks to the device mode demos' descriptors\r
+ * - Added return values to the CDC and MIDI class driver transmit functions\r
+ * - Optimized Endpoint_Read_Word_* and Pipe_Read_Word_* macros to reduce compiled size\r
+ * - Added non-null function parameter pointer restrictions to USB Class drivers to improve user code reliability\r
+ * - Added new "Common" section to the class drivers, to hold all mode-independent definitions for clarity\r
+ * - Moved SCSI command/sense constants into the Mass Storage Class driver, instead of the user-code\r
+ * - Altered the SCSI commands in the LowLevel Mass Storage Host to save on FLASH space by reducing function calls\r
+ * - Changed the parameters and behaviour of the USB_GetDeviceConfigDescriptor() function so that it now performs size checks\r
+ * and data validations internally, to simplify user code\r
+ * - Changed HIDParser to only zero out important values in the Parsed HID Report Item Information structure to save cycles\r
+ * - The HID report parser now always processed FEATURE items - HID_ENABLE_FEATURE_PROCESSING token now has no effect\r
+ * - The HID report parser now always ignores constant-data items, HID_INCLUDE_CONSTANT_DATA_ITEMS token now has no effect\r
+ * - The Benito Programmer project now has its own unique VID/PID pair allocated from the Atmel donated LUFA VID/PID pool\r
+ * - Add in new invalid event hook check targets to project makefiles to produce compilation errors when invalid event names\r
+ * are used in a project\r
+ * - The HID Report Parser now gives information on the total length of each report within a HID interface\r
+ * - The USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token has been removed - there are now separate USB_Descriptor_* and\r
+ * USB_StdDescriptor_* structures for both the LUFA and standardized element naming conventions so both may be used\r
+ *\r
+ * <b>Fixed:</b>\r
+ * - Fixed possible lockup in the CDC device class driver, when the host sends data that is a multiple of the\r
+ * endpoint's bank\r
+ * - Fixed swapped parameters in the HID state memory copy call while processing a HID PUSH item in the HID report parser\r
+ * - Fixed memory corruption HID report parser when too many COLLECTION or PUSH items were processed\r
+ * - Fixed HID report parser not resetting the FEATURE item count when a REPORT ID item is encountered\r
+ * - Fixed USBtoSerial demos not reading in UDR1 when the USART receives data but the USB interface is not enumerated,\r
+ * causing continuous USART receive interrupts\r
+ * - Fixed misspelled event name in the Class driver USBtoSerial demo, preventing correct operation\r
+ * - Fixed invalid data being returned when a GetStatus request is issued in Device mode with an unhandled data recipient\r
+ * - Added hardware USART receive interrupt and software buffering to the Benito project to ensure received data is not\r
+ * missed or corrupted\r
+ * - Fixed Device mode HID Class driver always sending IN packets, even when nothing to report\r
+ * - Fixed Device mode HID Class driver not explicitly initializing the ReportSize parameter to zero before calling callback\r
+ * routine, so that ignored callbacks don't cause incorrect data to be sent\r
+ * - Fixed StillImageHost not correctly freezing and unfreezing data pipes while waiting for a response block header\r
+ * - Fixed error in the PrinterHost demo preventing the full page data from being sent to the attached device (thanks to John Andrews)\r
+ * - Fixed CDC based demos and projects' INF driver files under 64 bit versions of Windows (thanks to Ronny Hanson, Thomas Bleeker)\r
+ * - Re-add in missing flip, flip-ee, dfu and dfu-ee targets to project makefiles (thanks to Opendous Inc.)\r
+ * - Fix allowable F_CPU values comment in project makefiles to more accurately reflect the allowable values on the USB AVRs\r
+ * - Fixed DFU and CDC class bootloaders on the series 2 USB AVRs, corrected invalid signatures, added support for the new\r
+ * ATMEGAxx2 series 2 variant AVRs to the DFU bootloader\r
+ * - Fixed Low Level USBtoSerial demo not storing received characters (thanks to Michael Cooper)\r
+ * - Fixed MIDI Device Class driver not sending/receiving MIDI packets of the correct size (thanks to Thomas Bleeker)\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog090810 Version 090810\r
+ *\r
+ * <b>New:</b>\r
+ * - Added new device class drivers and matching demos to the library for rapid application development\r
+ * - Added new PrinterHost demo (thanks to John Andrews)\r
+ * - Added USB Missile Launcher project, submitted by Dave Fletcher\r
+ * - Added new Benito Arduino Programmer project\r
+ * - Added incomplete device and host mode demos for later enhancement\r
+ * - Updated MassStorage device block write routines to use ping-pong Dataflash buffering to increase throughput by around 30%\r
+ * - Error status LEDs shown when device endpoint configuration fails to complete in all demos and projects\r
+ * - Added new USB_Host_SetDeviceConfiguration() convenience function for easy configuration selection of devices while in USB\r
+ * host mode\r
+ * - Added new USB_Host_ClearPipeStall() convenience function to clear a stall condition on an attached device's endpoint\r
+ * - Added new USB_Host_GetDeviceDescriptor() convenience function to retrieve the attached device's Device descriptor\r
+ * - Added new Endpoint_ClearStatusStage() convenience function to assist with the status stages of control transfers\r
+ * - Added new USE_INTERNAL_SERIAL define for using the unique serial numbers in some AVR models as the USB device's serial number,\r
+ * added NO_INTERNAL_SERIAL compile time option to turn off new serial number reading code\r
+ * - Added new DATAFLASH_CHIP_MASK() macro to the Dataflash driver, which returns the Dataflash select mask for the given chip index\r
+ * - Added new HOST_STATE_WaitForDeviceRemoval host state machine state for non-blocking disabling of device communications until the\r
+ * device has been removed (for use when an error occurs or communications with the device have completed)\r
+ * - Added new FAST_STREAM_TRANSFERS compile time option for faster stream transfers via multiple bytes copied per stream loop\r
+ * - Added stdio stream demo code to the CDC device demos, to show how to create standard streams out of the virtual serial ports\r
+ * - Added new EEPROM and FLASH buffer versions of the Endpoint and Pipe stream functions\r
+ * - Added new USE_FLASH_DESCRIPTORS and FIXED_NUM_CONFIGURATIONS compile time options\r
+ * - Added support for the new ATMEGA32U2, ATMEGA16U2 and ATMEGA8U2 AVR models\r
+ * - Added new USB_DeviceState variable to keep track of the current Device mode USB state\r
+ * - Added new LEDs_ToggleLEDs() function to the LEDs driver\r
+ * - Added new Pipe_BoundEndpointNumber() and Pipe_IsEndpointBound() functions\r
+ * - Added new DEVICE_STATE_AS_GPIOR and HOST_STATE_AS_GPIOR compile time options\r
+ * - Added 404 Not Found errors to the webserver in the RNDIS demos to indicate invalid URLs\r
+ *\r
+ * <b>Changed:</b>\r
+ * - Deprecated pseudo-scheduler and removed dynamic memory allocator from the library (first no longer needed and second unused)\r
+ * - The device-mode CALLBACK_USB_GetDescriptor() function now has an extra parameter so that the memory space in which the requested\r
+ * descriptor is located can be specified. This means that descriptors can now be located in multiple memory spaces within a device.\r
+ * - Removed vague USB_IsConnected global - test USB_DeviceState or USB_HostState explicitly to gain previous functionality\r
+ * - Removed USB_IsSuspended global - test USB_DeviceState against DEVICE_STATE_Suspended instead\r
+ * - Extended USB_GetDeviceConfigDescriptor() routine to require the configuration number within the device to fetch\r
+ * - Dataflash_WaitWhileBusy() now always ensures that the dataflash is ready for the next command immediately after returning,\r
+ * no need to call Dataflash_ToggleSelectedChipCS() afterwards\r
+ * - Low level API MIDI device demo no longer blocks if a note change event is sent while the endpoint is not ready\r
+ * - Pipe_GetErrorFlags() now returns additional error flags for overflow and underflow errors\r
+ * - Pipe stream functions now automatically set the correct pipe token, so that bidirectional pipes can be used\r
+ * - Pipe_ConfigurePipe() now automatically defaults IN pipes to accepting infinite IN requests, this can still be changed by calling\r
+ * the existing Pipe_SetFiniteINRequests() function\r
+ * - Changed F_USB entries in project makefiles to alias to F_CPU by default, as this is the most common case\r
+ * - Host mode demos now use sane terminal escape codes, so that text is always readable and events/program output is visually distinguished\r
+ * from one another using foreground colours\r
+ * - Internal per-device preprocessing conditions changed to per-device series rather than per-controller group for finer-grain\r
+ * internal control\r
+ * - Interrupts are no longer disabled during the processing of Control Requests on the default endpoint while in device mode\r
+ * - AudioOutput demos now always output to board LEDs, regardless of output mode (removed AUDIO_OUT_LEDS project option)\r
+ * - Removed SINGLE_DEVICE_CONFIGURATION compile time option in favor of the new FIXED_NUM_CONFIGURATIONS option so that the exact number\r
+ * of device configurations can be defined statically\r
+ * - Removed VBUS events, as they are already exposed to the user application via the regular device connection and disconnection events\r
+ * - Renamed and altered existing events to properly separate out Host and Device mode events\r
+ * - All demos switched over from GNU99 standards mode to C99 standards mode, to reduce the dependencies on GCC-only language extensions\r
+ *\r
+ * <b>Fixed:</b>\r
+ * - Changed bootloaders to use FLASHEND rather than the existence of RAMPZ to determine if far FLASH pointers are needed to fix\r
+ * bootloaders on some of the USB AVR devices where avr-libc erroneously defines RAMPZ\r
+ * - Fixes to MassStorageHost for better device compatibility (increase command timeout, change MassStore_WaitForDataReceived()\r
+ * to only unfreeze and check one data pipe at a time) to prevent incorrect device enumerations and freezes while transferring data\r
+ * - Make Pipe_ConfigurePipe() mask the given endpoint number against PIPE_EPNUM_MASK to ensure the endpoint IN direction bit is\r
+ * cleared to prevent endpoint type corruption\r
+ * - Fixed issue opening CDC-ACM ports on hosts when the CDC device tries to send data before the host has set the line encoding\r
+ * - Fixed USB_OPT_MANUAL_PLL option being ignored during device disconnects on some models (thanks to Brian Dickman)\r
+ * - Fixed documentation mentioning Pipe_GetCurrentToken() function when correct function name is Pipe_GetPipeToken()\r
+ * - Fixed ADC driver for the ATMEGA32U4 and ATMEGA16U4 (thanks to Opendous Inc.)\r
+ * - Fixed CDCHost demo unfreezing the pipes at the point of configuration, rather than use\r
+ * - Fixed MassStorage demo not clearing the reset flag when a Mass Storage Reset is issued while not processing a command\r
+ * - Fixed USB_Host_SendControlRequest() not re-suspending the USB bus when initial device ready-wait fails\r
+ * - Fixed USB Pad regulator not being disabled on some AVR models when the USB_OPT_REG_DISABLED option is used\r
+ * - Fixed Host mode to Device mode UID change not causing a USB Disconnect event when a device was connected\r
+ * - Fixed Mouse/Keyboard demos not performing the correct arithmetic on the Idle period at the right times (thanks to Brian Dickman)\r
+ * - Fixed GenericHID failing HID class tests due to incorrect Logical Minimum and Logical Maximum values (thanks to Soren Greiner)\r
+ * - Fixed incorrect PIPE_EPNUM_MASK mask causing pipe failures on devices with endpoint addresses of 8 and above (thanks to John Andrews)\r
+ * - Fixed report data alignment issues in the MouseHostWithParser demo when X and Y movement data size is not a multiple of 8 bits\r
+ * - Fixed HID Report Descriptor Parser not correctly resetting internal states when a REPORT ID element is encountered\r
+ * - Fixed incorrect BUTTONS_BUTTON1 for the STK526 target\r
+ * - Fixed RNDIS demos freezing when more than one connection was attempted simultaneously, causing memory corruption\r
+ * - Fixed USBtoSerial demo receiving noise from the USART due to pull-up not being enabled\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog090605 Version 090605\r
+ *\r
+ * - Fixed bug in RNDISEthernet and DualCDC demos not using the correct USB_ControlRequest structure for control request data\r
+ * - Fixed documentation showing incorrect USB mode support on the supported AVRs list\r
+ * - Fixed RNDISEthernet not working under Linux due to Linux requiring an "optional" RNDIS request which was unhandled\r
+ * - Fixed Mouse and Keyboard device demos not acting in accordance with the HID specification for idle periods (thanks to Brian Dickman)\r
+ * - Removed support for endpoint/pipe non-control interrupts; these did not act in the way users expected, and had many subtle issues\r
+ * - Fixed Device Mode not handling Set Feature and Clear Feature Chapter 9 requests that are addressed to the device (thanks to Brian Dickman)\r
+ * - Moved control endpoint interrupt handling into the library itself, enable via the new INTERRUPT_CONTROL_ENDPOINT token\r
+ * - Fixed CDCHost not clearing configured pipes and resetting configured pipes mask when a partially enumerated invalid CDC\r
+ * interface is skipped\r
+ * - Clarified the size of library tokens which accept integer values in the Compile Time Tokens page, values now use the smallest datatype\r
+ * inside the library that is able to hold their defined value to save space\r
+ * - Removed DESCRIPTOR_ADDRESS() macro as it was largely superfluous and only served to obfuscate code\r
+ * - Rewritten event system to remove all macros, to make user code clearer\r
+ * - Fixed incorrect ENDPOINT_EPNUM_MASK mask preventing endpoints above EP3 from being selected (thanks to Jonathan Oakley)\r
+ * - Removed STREAM_CALLBACK() macro - callbacks now use regular function definitions to clarify user code\r
+ * - Removed DESCRIPTOR_COMPARATOR() macro - comparators should now use regular function definitions to clarify user code\r
+ * - USB_IsConnected is now cleared before the USB_Disconnect() event is fired in response to VBUS being removed\r
+ * - Fixed incorrect PID value being used in the USBtoSerial project (thanks to Phill)\r
+ * - Deleted StdDescriptors.c, renamed USB_GetDescriptor() to CALLBACK_USB_GetDescriptor, moved ConfigDescriptor.c/.h from the\r
+ * LUFA/Drivers/USB/Class/ directory to LUFA/Drivers/USB/HighLevel/ in preparation for the new USB class APIs\r
+ * - Moved out each demos' functionality library files (e.g. Ring Buffer library) to /Lib directories for a better directory structure\r
+ * - Removed Tx interrupt from the USBtoSerial demo; now sends characters via polling to ensure more time for the Rx interrupt\r
+ * - Fixed possible enumeration errors from spin-loops which may fail to exit if the USB connection is severed before the exit condition\r
+ * becomes true\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog090510 Version 090510\r
+ *\r
+ * - Added new GenericHIDHost demo\r
+ * - Corrections to the KeyboardHost and MouseHost demos' pipe handling to freeze and unfreeze the data pipes at the point of use\r
+ * - KeyboardHost, MouseHost and GenericHIDHost demos now save and restore the currently selected pipe inside the pipe ISR\r
+ * - Changed GenericHID device demo to use the LUFA scheduler, added INTERRUPT_DATA_ENDPOINT and INTERRUPT_CONTROL_ENDPOINT compile\r
+ * time options\r
+ * - All comments in the library, bootloaders, demos and projects have now been spell-checked and spelling mistakes/typos corrected\r
+ * - Added new PIMA_DATA_SIZE() define to the Still Image Host demo\r
+ * - Add call to MassStore_WaitForDataReceived() in MassStore_GetReturnedStatus() to ensure that the CSW has been received in the\r
+ * extended MSC timeout period before continuing, to prevent long processing delays from causing the MassStore_GetReturnedStatus()\r
+ * to early-abort (thanks to Dmitry Maksimov)\r
+ * - Move StdRequestType.h, StreamCallbacks.h, USBMode.h from the LowLevel USB driver directory to the HighLevel USB driver directory,\r
+ * where they are more suited\r
+ * - Removed all binary constants and replaced with decimal or hexadecimal constants so that unpatched GCC compilers can still build the\r
+ * code without having to be itself patched and recompiled first\r
+ * - Added preprocessor checks and documentation to the bootloaders giving information about missing SIGNATURE_x defines due to\r
+ * outdated avr-libc versions.\r
+ * - Added support to the CDCHost demo for devices with multiple CDC interfaces which are not the correct ACM type preceding the desired\r
+ * ACM CDC interface\r
+ * - Fixed GenericHID demo not starting USB and HID management tasks when not using interrupt driven modes (thanks to Carl Kjeldsen)\r
+ * - Fixed RNDISEthenet demo checking the incorrect message field for packet size constraints (thanks to Jonathan Oakley)\r
+ * - Fixed WriteNextReport code in the GenericHIDHost demo using incorrect parameter types and not selecting the correct endpoint\r
+ * - Adjusted sample CTC timer calculations in the AudioOutput and AudioInput demos to match the CTC calculations in the AVR datasheet,\r
+ * and to fix instances where rounding caused the endpoint to underflow (thanks to Robin Theunis)\r
+ * - The USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0), so that other control type\r
+ * pipes can be used with the function\r
+ * - The USB Host management task now saves and restores the currently selected pipe before and after the task completes\r
+ * - Fixed GenericHIDHost demo report write routine incorrect for control type requests (thanks to Andrei Krainev)\r
+ * - Removed Endpoint_ClearCurrentBank() and Pipe_ClearCurrentBank() in favor of new Endpoint_ClearIN(), Endpoint_ClearOUT(),\r
+ * Pipe_ClearIN() and Pipe_ClearOUT() macros (done to allow for the detection of packets of zero length)\r
+ * - Renamed *_ReadWriteAllowed() macros to *_IsReadWriteAllowed() to remain consistent with the rest of the LUFA API\r
+ * - Endpoint_IsSetupReceived() macro has been renamed to Endpoint_IsSETUPReceived(), Endpoint_ClearSetupReceived() macro has been\r
+ * renamed to Endpoint_ClearSETUP(), the Pipe_IsSetupSent() macro has been renamed to Pipe_IsSETUPSent() and the\r
+ * Pipe_ClearSetupSent() macro is no longer applicable and should be removed - changes made to compliment the new endpoint and pipe\r
+ * bank management API\r
+ * - Updated all demos, bootloaders and projects to use the new endpoint and pipe management APIs (thanks to Roman Thiel from Curetis AG)\r
+ * - Updated library doxygen documentation, added groups, changed documentation macro functions to real functions for clarity\r
+ * - Removed old endpoint and pipe aliased read/write/discard routines which did not have an explicit endian specifier for clarity\r
+ * - Removed the ButtLoadTag.h header file, as no one used for its intended purpose anyway\r
+ * - Renamed the main Drivers/AT90USBXXX directory to Drivers/Peripheral, renamed the Serial_Stream driver to SerialStream\r
+ * - Fixed CDC and USBtoSerial demos freezing where buffers were full while still transmitting or receiving (thanks to Peter Hand)\r
+ * - Removed "Host_" section of the function names in ConfigDescriptor.h, as most of the routines can now be used in device mode on the\r
+ * device descriptor\r
+ * - Renamed functions in the HID parser to have a "USB_" prefix and the acronym "HID" in the name\r
+ * - Fixed incorrect HID interface class and subclass values in the Mouse and KeyboardMouse demos (thanks to Brian Dickman)\r
+ * - Capitalized the "Descriptor_Search" and "Descriptor_Search_Comp" prefixes of the values in the DSearch_Return_ErrorCodes_t and\r
+ * DSearch_Comp_Return_ErrorCodes_t enums\r
+ * - Removed "ERROR" from the enum names in the endpoint and pipe stream error code enums\r
+ * - Renamed the USB_PowerOnErrorCodes_t enum to USB_InitErrorCodes_t, renamed the POWERON_ERROR_NoUSBModeSpecified enum value to\r
+ * USB_INITERROR_NoUSBModeSpecified\r
+ * - Renamed USB_PowerOnFail event to USB_InitFailure\r
+ * - Renamed OTG.h header functions to be more consistent with the rest of the library API\r
+ * - Changed over all deprecated GCC structure tag initializers to the standardized C99 format (thanks to Mike Alexander)\r
+ * - USB_HostRequest renamed to USB_ControlRequest, entire control request header is now read into USB_ControlRequest in Device mode\r
+ * rather than having the library pass only partially read header data to the application\r
+ * - The USB_UnhandledControlPacket event has had its parameters removed, in favor of accessing the new USB_ControlRequest structure\r
+ * - The Endpoint control stream functions now correctly send a ZLP to the host when less data than requested is sent\r
+ * - Fixed USB_RemoteWakeupEnabled flag never being set (the REMOTE WAKEUP Set Feature request was not being handled)\r
+ * - Renamed the FEATURELESS_CONTROL_ONLY_DEVICE compile-time token to CONTROL_ONLY_DEVICE\r
+ * - Endpoint configuration is now refined to give better output when all configurations have static inputs - removed the now useless\r
+ * STATIC_ENDPOINT_CONFIGURATION compile time token\r
+ * - Fixed SPI driver init function not clearing SPI2X bit when not needed\r
+ * - Fixed PREVENT ALLOW MEDIUM REMOVAL command issuing in the MassStorageHost demo using incorrect parameters (thanks to Mike Alex)\r
+ * - Fixed MassStorageHost demo broken due to an incorrect if statement test in MassStore_GetReturnedStatus()\r
+ * - Fixed reversed signature byte ordering in the CDC bootloader (thanks to Johannes Raschke)\r
+ * - Changed PIPE_CONTROLPIPE_DEFAULT_SIZE from 8 to 64 to try to prevent problems with faulty devices which do not respect the given\r
+ * wLength value when reading in the device descriptor\r
+ * - Fixed missing semicolon in the ATAVRUSBRF01 LED board driver code (thanks to Morten Lund)\r
+ * - Changed LED board driver code to define dummy LED masks for the first four board LEDs, so that user code can be compiled for boards\r
+ * with less than four LEDs without code modifications (thanks to Morten Lund)\r
+ * - Changed HWB board driver to Buttons driver, to allow for the support of future boards with more than one mounted GPIO button\r
+ * - Serial driver now correctly calculates the baud register value when in double speed mode\r
+ * - Init function of the Serial driver is now static inline to product smaller code for the common-case of static init values\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog090401 Version 090401\r
+ *\r
+ * - Fixed MagStripe project configuration descriptor containing an unused (blank) endpoint descriptor\r
+ * - Incorporated makefile changes by Denver Gingerich to retain compatibility with stock (non-WinAVR) AVR-GCC installations\r
+ * - Fixed makefile EEPROM programming targets programming FLASH data in addition to EEPROM data\r
+ * - LUFA devices now enumerate correctly with LUFA hosts\r
+ * - Fixed Configuration Descriptor search routine freezing when a comparator returned a failure\r
+ * - Removed HID report item serial dump in the MouseHostWithParser and KeyboardHostWithParser - useful only for debugging, and\r
+ * slowed down the enumeration of HID devices too much\r
+ * - Increased the number of bits per track which can be read in the MagStripe project to 8192 when compiled for the AT90USBXXX6/7\r
+ * - Fixed KeyboardMouse demo discarding the wIndex value in the REQ_GetReport request\r
+ * - USBtoSerial demo now discards all Rx data when not connected to a USB host, rather than buffering characters for transmission\r
+ * next time the device is attached to a host.\r
+ * - Added new F_USB compile time constant to the library and makefiles, to give the raw input clock (used to feed the PLL before any\r
+ * clock prescaling is performed) frequency, so that the PLL prescale mask can be determined\r
+ * - Changed stream wait timeout counter to be 16-bit, so that very long timeout periods can be set for correct communications with\r
+ * badly designed hosts or devices which greatly exceed the USB specification limits\r
+ * - Mass Storage Host demo now uses a USB_STREAM_TIMEOUT_MS of two seconds to maintain compatibility with poorly designed devices\r
+ * - Function attribute ATTR_ALWAYSINLINE renamed to ATTR_ALWAYS_INLINE to match other function attribute macro naming conventions\r
+ * - Added ATTR_ALWAYS_INLINE attribute to several key inlined library components, to ensure they are inlined in all circumstances\r
+ * - Removed SetSystemClockPrescaler() macro, the clock_prescale_set() avr-libc macro has been corrected in recent avr-libc versions\r
+ * - Fixed incorrect/missing control status stage transfers on demos, bootloaders and applications (thanks to Nate Lawson)\r
+ * - The NO_CLEARSET_FEATURE_REQUEST compile time token has been renamed to FEATURELESS_CONTROL_ONLY_DEVICE, and its function expanded\r
+ * to also remove parts of the Get Status chapter 9 request to further reduce code usage\r
+ * - Makefile updated to include output giving the currently selected BOARD parameter value\r
+ * - Board Dataflash driver now allows for dataflash ICs which use different shifts for setting the current page/byte address (thanks\r
+ * to Kenneth Clubb)\r
+ * - Added DataflashManager_WriteBlocks_RAM() and DataflashManager_ReadBlocks_RAM() functions to the MassStorage demo, to allow for easy\r
+ * interfacing with a FAT library for dataflash file level access\r
+ * - Corrected CDC class bootloader to fix a few bugs, changed address counter to store x2 addresses for convenience\r
+ * - Fixed typos in the SPI driver SPI_SPEED_FCPU_DIV_64 and SPI_SPEED_FCPU_DIV_128 masks (thanks to Markus Zocholl)\r
+ * - Keyboard and Mouse device demos (normal, data interrupt and fully interrupt driven) combined into unified keyboard and mouse demos\r
+ * - Keyboard and Mouse host demos (normal and data interrupt driven) combined into unified keyboard and mouse demos\r
+ * - Removed AVRISP_Programmer project due to code quality concerns\r
+ * - Fixed CDC demo not sending an empty packet after each transfer to prevent the host from buffering incoming data\r
+ * - Fixed documentation typos and preprocessor checks relating to misspellings of the USE_RAM_DESCRIPTORS token (thanks to Ian Gregg)\r
+ * - Fixed USBTask.h not conditionally including HostChapter9.h only when USB_CAN_BE_HOST is defined (thanks to Ian Gregg)\r
+ * - Fixed incorrect ADC driver init register manipulation (thanks to Tobias)\r
+ * - Added new GenericHID device demo application\r
+ * - Fixed Still Image Host SImage_SendData() function not clearing the pipe bank after sending data\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog090209 Version 090209\r
+ *\r
+ * - PWM timer mode in AudioOut demo changed to Fast PWM for speed\r
+ * - Updated Magstripe project to work with the latest hardware revision\r
+ * - Fixed library not responding to the BCERRI flag correctly in host mode, leading to device lockups\r
+ * - Fixed library handling Get Descriptor requests when not addressed as standard requests to the device or interface (thanks to\r
+ * Nate Lawson)\r
+ * - Fixed serious data corruption issue in MassStorage demo dataflash write routine\r
+ * - Added new NO_CLEARSET_FEATURE_REQUEST compile time token\r
+ * - USB task now restores previous global interrupt state after execution, rather than forcing global interrupts to be enabled\r
+ * - Fixed USB_DeviceEnumerationComplete event firing after each configuration change, rather than once after the initial configuration\r
+ * - Added ENDPOINT_DOUBLEBANK_SUPPORTED() macros to Endpoint.h, altered ENDPOINT_MAX_SIZE() to allow user to specify endpoint\r
+ * - ENDPOINT_MAX_ENDPOINTS changed to ENDPOINT_TOTAL_ENDPOINTS, PIPE_MAX_PIPES changed to PIPE_TOTAL_PIPES\r
+ * - Endpoint and Pipe non-control stream functions now ensure endpoint or pipe is ready before reading or writing\r
+ * - Changed Teensy bootloader to use a watchdog reset when exiting rather than a software jump\r
+ * - Fixed integer promotion error in MassStorage and MassStorageHost demos, corrupting read/write transfers\r
+ * - SPI_SendByte is now SPI_TransferByte, added new SPI_SendByte and SPI_ReceiveByte functions for fast one-way transfer\r
+ * - MassStorage demo changed to use new fast one-way SPI transfers to increase throughput\r
+ * - MassStorage handling of Mass Storage Reset class request improved\r
+ * - Altered MassStorage demo dataflash block read code for speed\r
+ * - Added USB_IsSuspended global flag\r
+ * - Simplified internal Dual Mode (OTG) USB library code to reduce code size\r
+ * - Extended stream timeout period to 100ms from 50ms\r
+ * - Mass Storage Host demo commands now all return an error code from the Pipe_Stream_RW_ErrorCodes_t enum\r
+ * - Added SubErrorCode parameter to the USB_DeviceEnumerationFailed event\r
+ * - VBUS drop interrupt now disabled during the manual-to-auto VBUS delivery handoff\r
+ * - Simplified low level backend so that device/host mode initialization uses the same code paths\r
+ * - Added workaround for faulty Mass Storage devices which do not implement the required GET_MAX_LUN request\r
+ * - Removed buggy Telnet application from the RNDIS demo\r
+ * - Moved Mass Storage class requests in the Mass Storage Host demo to wrapper functions in MassStoreCommands.c\r
+ * - Fixed incorrect SCSI command size value in the Request Sense command in MassStoreCommands.c\r
+ * - Added SetProtocol request to HID class non-parser Mouse and Keyboard demos to force devices to use the correct Boot Protocol\r
+ * - Added new "dfu" and "flip" programming targets to project makefiles\r
+ * - HID_PARSE_Sucessful enum member typo corrected to HID_PARSE_Successful\r
+ * - Changed COLLECTION item structures in the HID descriptor parser to include the collection's Usage Page value\r
+ * - Serial driver now sets Tx line as output, enables pull-up on Rx line\r
+ * - Fixed smaller USB AVRs raising multiple connection and disconnection events when NO_LIMITED_CONTROLLER_CONNECT is disabled\r
+ * - Added HOST_DEVICE_SETTLE_DELAY_MS to give the host delay after a device is connected before it is enumerated\r
+ * - Fixed KeyboardHostWithParser demo linking against the wrong global variables\r
+ * - Completed doxygen documentation of remaining library bootloaders, demos and projects\r
+ * - Fixed incorrect bootloader start address in the TeensyHID bootloader\r
+ * - Added HWB button whole-disk ASCII dump functionality to MassStoreHost demo\r
+ * - Replaced printf_P(PSTR("%c"), {Variable}) calls with putchar(<Variable>) for speed and size savings\r
+ * - Serial driver now accepts baud rates over 16-bits in size, added double speed flag option\r
+ * - Fixed incorrect callback abort return value in Pipe.c\r
+ * - Added new flip-ee and dfu-ee makefile targets (courtesy of Opendous Inc.)\r
+ * - Removed reboot-on-disconnect code from the TeensyHID bootloader, caused problems on some systems\r
+ * - Fixed AudioOutput and AudioInput demos looping on the endpoint data, rather than processing a sample at a time and returning\r
+ * each time the task runs to allow for other tasks to execute\r
+ * - Added support for the Atmel ATAVRUSBRF01 board\r
+ * - Added AVRISP Programmer Project, courtesy of Opendous Inc.\r
+ * - Fixed CDC Host demo not searching through both CDC interfaces for endpoints\r
+ * - Fixed incorrect Product String descriptor length in the DFU class bootloader\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog081224 Version 081224\r
+ *\r
+ * - MyUSB name changed to LUFA, the Lightweight USB Framework for AVRs\r
+ * - Fixed Mass Storage Host demo's MassStore_SendCommand() delay in the incorrect place\r
+ * - Fixed USBtoSerial demo not calling ReconfigureUSART() after a change in the line encoding\r
+ * - Fixed infinite loop in host mode Host-to-Device control transfers with data stages\r
+ * - HID report parser now supports devices with multiple reports in one interface via Report IDs\r
+ * - Fixed RZUSBSTICK board LED driver header incorrect macro definition order causing compile errors\r
+ * - Calling USB_Init() when the USB interface is already configured now forces a complete interface reset\r
+ * and re-enumeration - fixes MyUSB DFU bootloader not switching to app code correctly when soft reset used\r
+ * - Fixed "No newline at end of file" warning when stream callbacks are enabled\r
+ * - DFU bootloader now uses fixed signature bytes per device, rather than reading them out dynamically for size\r
+ * - Added new FIXED_CONTROL_ENDPOINT_SIZE and USE_SINGLE_DEVICE_CONFIGURATION switches to statically define certain values to\r
+ * reduce compiled binary size\r
+ * - Added new NO_LIMITED_CONTROLLER_CONNECT switch to prevent the library from trying to determine bus connection\r
+ * state from the suspension and wake up events on the smaller USB AVRs\r
+ * - Added summary of all library compile time tokens to the documentation\r
+ * - Added overview of the LUFA scheduler to the documentation\r
+ * - Removed MANUAL_PLL_CONTROL compile time token, replaced with a mask for the USB_Init() Options parameter\r
+ * - CDC bootloader now uses the correct non-far or far versions of the pgm_* functions depending on if RAMPZ is defined\r
+ * - Doxygen documentation now contains documentation on all the projects, bootloaders and most demos included with the library\r
+ * - CDC bootloader now runs user application when USB disconnected rather than waiting for a hard reset\r
+ * - MouseHostWithParser and KeyboardHostWithParser now support multiple-report devices\r
+ * - RNDIS demo can now close connections correctly using the new TCP_APP_CLOSECONNECTION() macro - used in Webserver\r
+ * - Fixed the DFU bootloader, no longer freezes up when certain files are programmed into an AVR, made reading/writing faster\r
+ * - Fixed mouse/joystick up/down movements reversed - HID mouse X/Y coordinates use a left-handed coordinate system, not a normal\r
+ * right-handed system\r
+ * - Added stub code to the CDC and USBtoSerial demos showing how to read and set the RS-232 handshake lines - not currently used in\r
+ * the demos, but the example code and supporting defines are now in place\r
+ * - Interrupts are now disabled when processing a control request in device mode, to avoid exceeding the strict control request\r
+ * timing requirements.\r
+ * - All demos now use a central StatusUpdate() function rather than direct calls to the board LED functions, so that the demos can\r
+ * easily be altered to show different LED combinations (or do something else entirely) as the demo's status changes\r
+ * - Removed LED commands from the CDC bootloader, unused by most AVR910 programming software\r
+ * - Fixed RNDIS demo ICMP ping requests echoing back incorrect data\r
+ * - Added DHCP server code to RNDIS demo, allowing for hands-free auto configuration on any PC\r
+ * - Fixed DFU bootloader PID value for the ATMEGA16U4 AVR\r
+ * - Endpoint and Pipe configuration functions now return an error code indicating success or failure\r
+ * - USB Reset in device mode now resets and disables all device endpoints\r
+ * - Added intermediate states to the host mode state machine, reducing the USB task blocking time to no more than 1ms explicitly per\r
+ * invocation when in host mode\r
+ * - Added support for the ATMEGA32U6 microcontroller\r
+ * - Added STATIC_ENDPOINT_CONFIGURATION compile time option, enabled in the bootloaders to minimize space usage\r
+ * - Removed redundant code from the USB device GetStatus() chapter 9 processing routine\r
+ * - Added new TeensyHID bootloader, compatible with the Teensy HID protocol (http://www.pjrc.com/teensy/)\r
+ * - Versions are now numbered by release dates, rather than arbitrary major/minor revision numbers\r
+ * - USB_RemoteWakeupEnabled is now correctly set and cleared by SetFeature and ClearFeature requests from the host\r
+ * - Changed prototype of GetDescriptor, so that it now returns the descriptor size (or zero if the descriptor doesn't exist)\r
+ * rather than passing the size back to the caller through a parameter and returning a boolean\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog153 Version 1.5.3 (081002)\r
+ *\r
+ * - Fixed CDC bootloader using pgmspace macros for some descriptors inappropriately\r
+ * - Updated all Mouse and Keyboard device demos to include boot protocol support (now works in BIOS)\r
+ * - Renamed bootloader directories to remove spaces, which were causing build problems on several OSes\r
+ * - Removed serial number strings from all but the MassStore demo where it is required - users were not\r
+ * modifying the code to either omit the descriptor or use a unique serial per device causing problems\r
+ * when multiple units of the same device were plugged in at the same time\r
+ * - AudioOutput and AudioInput demos now correctly silence endpoints when not enabled by the host\r
+ * - Added KeyboardMouse demo (Keyboard and Mouse functionality combined into a single demo)\r
+ * - Added DriverStubs directory to house board level driver templates, to make MyUSB compatible custom board\r
+ * driver creation easier\r
+ * - Extended MassStorage demo to support multiple LUNs, 2 by default\r
+ * - Fixed incorrect device address mask, preventing the device from enumerating with addresses larger than 63\r
+ * - Fixed incorrect data direction mask in the GetStatus standard request, preventing it from being handled\r
+ * - Fixed incorrect GetStatus standard request for endpoints, now returns the endpoint STALL status correctly\r
+ * - Added in new USB_RemoteWakeupEnabled and USB_CurrentlySelfPowered flags rather than using fixed values\r
+ * - Added DualCDC demo to demonstrate the use of Interface Association Descriptors\r
+ * - Added pipe NAK detection and clearing API\r
+ * - Added pipe status change (NAK, STALL, etc.) interrupt API\r
+ * - Fixed MassStorageHost demo so that it no longer freezes randomly when issuing several commands in a row\r
+ * - Host demos configuration descriptor routines now return a unique error code when the returned data does\r
+ * not have a valid configuration descriptor header\r
+ * - Added Endpoint_WaitUntilReady() and Pipe_WaitUntilReady() functions\r
+ * - Stream functions now have software timeouts, timeout period can be set by the USB_STREAM_TIMEOUT_MS token\r
+ * - All demos now pass the USB.org automated Chapter 9 device compliance tests\r
+ * - All HID demos now pass the USB.org automated HID compliance tests\r
+ * - Polling interval of the interrupt endpoint in the CDC based demos changed to 0xFF to fix problems on Linux systems\r
+ * - Changed stream functions to accept a new callback function, with NO_STREAM_CALLBACKS used to disable all callbacks\r
+ * - Mass Storage demo dataflash management routines changed to use the endpoint stream functions\r
+ * - Added AVRStudio project files for each demo in addition to the existing Programmer's Notepad master project file\r
+ * - Re-added call to ReconfigureUSART() in USBtoSerial SetLineCoding request, so that baud rate changes\r
+ * are reflected in the hardware (change was previously lost)\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog152 Version 1.5.2 (080731)\r
+ *\r
+ * - Fixed SwapEndian_32() function in Common.h so that it now works correctly (wrong parameter types)\r
+ * - Updated RNDIS demo - notification endpoint is no longer blocking so that it works with faulty Linux RNDIS\r
+ * implementations (where the notification endpoint is ignored in favor of polling the control endpoint)\r
+ * - Fixed incorrect Vendor Description string return size in RNDIS demo for the OID_GEN_VENDOR_DESCRIPTION OID token\r
+ * - Added very basic TCP/IP stack and HTTP/TELNET servers to RNDIS demo\r
+ * - Fixed DFU bootloader exit causing programming software to complain about failed writes\r
+ * - Fixed DFU bootloader EEPROM programming mode wiping first flash page\r
+ * - Fixed Clear/Set Feature device standard request processing code (fixing MassStorage demo in the process)\r
+ * - Added support for the ATMEGA16U4 AVR microcontroller\r
+ * - Library license changed from LGPLv3 to MIT license\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog151 Version 1.5.1 (080707)\r
+ *\r
+ * - Changed host demos to enable the host function task on the firing of the USB_DeviceEnumerationComplete event\r
+ * rather than the USB_DeviceAttached event\r
+ * - HID Usage Stack now forcefully cleared after an IN/OUT/FEATURE item has been completely processed to remove\r
+ * any referenced but not created usages\r
+ * - Changed USB_INT_DisableAllInterrupts() and USB_INT_ClearAllInterrupts(), USB_Host_GetNextDescriptorOfType(),\r
+ * USB_Host_GetNextDescriptorOfTypeBefore(), USB_Host_GetNextDescriptorOfTypeAfter() to normal functions (from inline)\r
+ * - Fixed USBtoSerial demo not sending data, only receiving\r
+ * - Fixed main makefile to make all by default, fixed MagStripe directory case to prevent case-sensitive path problems\r
+ * - ConfigDescriptor functions made normal, instead of static inline\r
+ * - Pipe/Endpoint *_Ignore_* functions changed to *_Discard_*, old names still present as aliases\r
+ * - Fixed ENDPOINT_MAX_SIZE define to be correct on limited USB controller AVRs\r
+ * - Changed endpoint and pipe size translation routines to use previous IF/ELSE IF cascade code, new algorithmic\r
+ * approach was buggy and caused problems\r
+ * - Bootloaders now compile with -fno-inline-small-functions option to reduce code size\r
+ * - Audio demos now use correct endpoint sizes for full and limited controller USB AVRs, double banking in all cases\r
+ * to be in line with the specification (isochronous endpoints MUST be double banked)\r
+ * - Added Interface Association descriptor to StdDescriptors.h, based on the relevant USB2.0 ECN\r
+ * - Fixed MIDI demo, corrected Audio Streaming descriptor to follow the MIDI-specific AS structure\r
+ * - Fixed HID class demo descriptors so that the HID interface's protocol is 0x00 (required for non-boot protocol HID\r
+ * devices) to prevent problems on hosts expecting the boot protocol functions to be supported\r
+ * - Added read/write control stream functions to Endpoint.h\r
+ * - Fixed AudioOut demo not setting port pins to inputs on USB disconnect properly\r
+ * - Added RNDISEthernet demo application\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog150 Version 1.5.0 (080610)\r
+ *\r
+ * - Fixed MIDI demo, now correctly waits for the endpoint to be ready between multiple note messages\r
+ * - Added CDC Host demo application\r
+ * - Added KeyboardFullInt demo application\r
+ * - Endpoint and Pipe creation routines now mask endpoint/pipe size with the size mask, to remove transaction\r
+ * size bits not required for the routines (improves compatibility with devices)\r
+ * - Fixed AudioInput demo - now correctly sends sampled audio to the host PC\r
+ * - Fixed AudioOutput demo once more -- apparently Windows requires endpoint packets to be >=192 bytes\r
+ * - Shrunk round-robbin scheduler code slightly via the use of struct pointers rather than array indexes\r
+ * - Fixed off-by-one error when determining if the Usage Stack is full inside the HID Report parser\r
+ * - Renamed Magstripe.h to MagstripeHW.h and moved driver out of the library and into the MagStripe demo folder\r
+ * - Added preprocessor checks to enable C linkage on the library components when used with a C++ compiler\r
+ * - Added Still Image Host demo application\r
+ * - The USB device task now restores the previously selected endpoint, allowing control requests to be transparently\r
+ * handled via interrupts while other endpoints are serviced through polling\r
+ * - Fixed device signature being sent in reverse order in the CDC bootloader\r
+ * - Host demos now have a separate ConfigDescriptor.c/.h file for configuration descriptor processing\r
+ * - HostWithParser demos now have a separate HIDReport.c/.h file for HID report processing and dumping\r
+ * - Removed non-mandatory commands from MassStorage demo to save space, fixed SENSE ResponseCode value\r
+ * - CDC demos now send empty packets after sending a full one to prevent buffering issues on the host\r
+ * - Updated demo descriptors to use VID/PID values donated by Atmel\r
+ * - Added DoxyGen documentation to the source files\r
+ * - Fixed Serial_IsCharReceived() definition, was previously reversed\r
+ * - Removed separate USB_Descriptor_Language_t descriptor, USB_Descriptor_String_t is used instead\r
+ * - Removed unused Device Qualifier descriptor structure\r
+ * - Renamed the USB_CreateEndpoints event to the more appropriate USB_ConfigurationChanged\r
+ * - Fixed MassStorageHost demo reading in the block data in reverse\r
+ * - Removed outdated typedefs in StdRequestType.h, superseded by the macro masks\r
+ * - Corrected OTG.h is now included when the AVR supports both Host and Device modes, for creating OTG products\r
+ * - USB_DeviceEnumerationComplete event is now also fired when in device mode and the host has finished its enumeration\r
+ * - Interrupt driven demos now properly restore previously selected endpoint when ISR is complete\r
+ * - The value of USB_HOST_TIMEOUT_MS can now be overridden in the user project makefile to a custom fixed timeout value\r
+ * - Renamed USB_Host_SOFGeneration_* macros to more friendly USB_Host_SuspendBus(), USB_Host_ResumeBus()\r
+ * and USB_Host_IsBusSuspended()\r
+ * - Renamed *_*_Is* macros to *_Is* to make all flag checking macros consistent, Pipe_SetInterruptFreq() is now\r
+ * Pipe_SetInterruptPeriod() to use the correct terminology\r
+ * - UnicodeString member of USB_Descriptor_String_t struct changed to an ordinary int array type, so that the GCC\r
+ * Unicode strings (prefixed with an L before the opening quotation mark) can be used instead of explicit arrays\r
+ * of ASCII characters\r
+ * - Fixed Endpoint/Pipes being configured incorrectly if the maximum endpoint/pipe size for the selected USB AVR\r
+ * model was given as the bank size\r
+ * - HID device demos now use a true raw array for the HID report descriptor rather than a struct wrapped array\r
+ * - Added VERSION_BCD() macro, fixed reported HID and USB version numbers in demo descriptors\r
+ * - Cleaned up GetDescriptor device chapter 9 handler function\r
+ * - Added GET_REPORT class specific request to HID demos to make them complaint to the HID class\r
+ * - Cleaned up setting of USB_IsInitialized and USB_IsConnected values to only when needed\r
+ * - Removed Atomic.c and ISRMacro.h; the library was already only compatible with recent avr-lib-c for other reasons\r
+ * - All demos and library functions now use USB standardized names for the USB data (bRequest, wLength, etc.)\r
+ * - Added USE_NONSTANDARD_DESCRIPTOR_NAMES token to switch back to the non-standard descriptor element names\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog141 Version 1.4.1 (090519)\r
+ *\r
+ * - Enhanced KeyboardWithParser demo, now prints out pressed alphanumeric characters like the standard demo\r
+ * - Fixed MassStorage demo, read/writes using non mode-10 commands now work correctly\r
+ * - Corrected version number in Version.h\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog140 Version 1.4.0 (090505)\r
+ *\r
+ * - Added HID Report Parser API to the library\r
+ * - Added Mouse and Keyboard host demo applications, using the new HID report parser engine\r
+ * - Added MouseFullInt demo, which demonstrates a fully interrupt (including control requests) mouse device\r
+ * - Fixed incorrect length value in the audio control descriptor of the AudioOutput and AudioInput demos\r
+ * - Added MIDI device demo application to the library\r
+ * - Fixed problem preventing USB devices from being resumed from a suspended state\r
+ * - Added new CDC class bootloader to the library, based on the AVR109 bootloader protocol\r
+ * - Added header to each demo application indicating the mode, class, subclass, standards used and supported speed\r
+ * - Functions expecting endpoint/pipe numbers are no longer automatically masked against ENDPOINT_EPNUM_MASK or\r
+ * PIPE_PIPENUM_MASK - this should be manually added to code which requires it\r
+ * - Fixed DFU class bootloader - corrected frequency of flash page writes, greatly reducing programming time\r
+ * - Renamed AVR_HOST_GetDeviceConfigDescriptor() to USB_Host_GetDeviceConfigDescriptor() and AVR_HOST_GetNextDescriptor()\r
+ * to USB_Host_GetNextDescriptor()\r
+ * - Added new USB_Host_GetNextDescriptorOfTypeBefore() and USB_Host_GetNextDescriptorOfTypeAfter() routines\r
+ * - Moved configuration descriptor routines to MyUSB/Drivers/USB/Class/, new accompanying ConfigDescriptors.c file\r
+ * - Added new configuration descriptor comparator API for more powerful descriptor parsing, updated host demos to use the\r
+ * new comparator API\r
+ * - Fixed MassStorageHost demo capacity printout, and changed data read/write mode from little-endian to the correct\r
+ * big-endian for SCSI devices\r
+ * - Fixed macro/function naming consistency; USB_HOST is now USB_Host, USB_DEV is now USB_Device\r
+ * - Added better error reporting to host demos\r
+ * - Added 10 microsecond delay after addressing devices in host mode, to prevent control stalls\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog132 Version 1.3.2 (080401)\r
+ *\r
+ * - Added call to ReconfigureUSART() in USBtoSerial SetLineCoding request, so that baud rate changes\r
+ * are reflected in the hardware\r
+ * - Fixed CDC and USBtoSerial demos - Stream commands do not work for control endpoints, and the\r
+ * GetLineCoding request had an incorrect RequestType mask preventing it from being processed\r
+ * - Improved reliability of the USBtoSerial demo, adding a busy wait while the buffer is full\r
+ * - Device control endpoint size is now determined from the device's descriptors rather than being fixed\r
+ * - Separated out SPI code into new SPI driver in AT90USBXXX driver directory\r
+ * - Bootloader now returns correct PID for the selected USB AVR model, not just the AT90USB128X PID\r
+ * - Added support for the RZUSBSTICK board\r
+ * - Bicolour driver removed in favor of generic LEDs driver\r
+ * - Added support for the ATMEGA32U4 AVR\r
+ * - Added MANUAL_PLL_CONTROL compile time option to prevent the USB library from manipulating the PLL\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog131 Version 1.3.1 (080319)\r
+ *\r
+ * - Fixed USB to Serial demo - class value in the descriptors was incorrect\r
+ * - Control endpoint size changed from 64 bytes to 8 bytes to save on USB FIFO RAM and to allow low\r
+ * speed mode devices to enumerate properly\r
+ * - USB to Serial demo data endpoints changed to dual-banked 16 byte to allow the demo to work\r
+ * on USB AVRs with limited USB FIFO RAM\r
+ * - Changed demo endpoint numbers to use endpoints 3 and 4 for double banking, to allow limited\r
+ * USB device controller AVRs (AT90USB162, AT90USB82) to function correctly\r
+ * - Updated Audio Out demo to use timer 1 for AVRs lacking a timer 3 for the PWM output\r
+ * - Fixed incorrect USB_DEV_OPT_HIGHSPEED entry in the Mass Storage device demo makefile\r
+ * - Optimized Mass Storage demo for a little extra transfer speed\r
+ * - Added LED indicators to the Keyboard demo for Caps Lock, Num Lock and Scroll Lock\r
+ * - Added Endpoint_Read_Stream, Endpoint_Write_Stream, Pipe_Read_Stream and Pipe_Write_Stream functions\r
+ * (including Big and Little Endian variants)\r
+ * - Made Dataflash functions inline for speed, removed now empty Dataflash.c driver file\r
+ * - Added new SetSystemClockPrescaler() macro (thanks to Joerg Wunsch)\r
+ * - Fixed Endpoint_ClearStall() to function correctly on full USB controller AVRs (AT90USBXXX6/7)\r
+ * - Endpoint_Setup_In_Clear() and Endpoint_Setup_Out_Clear() no longer set FIFOCON, in line with the\r
+ * directives in the datasheet\r
+ * - Fixed PLL prescaler defines for all AVR models and frequencies\r
+ * - Fixed ENDPOINT_INT_IN and ENDPOINT_INT_OUT definitions\r
+ * - Added interrupt driven keyboard and mouse device demos\r
+ * - Combined USB_Device_ClearFeature and USB_Device_SetFeature requests into a single routine for code\r
+ * size savings\r
+ * - Added missing Pipe_GetCurrentPipe() macro to Pipe.h\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog130 Version 1.3.0 (080307)\r
+ *\r
+ * - Unnecessary control endpoint config removed from device mode\r
+ * - Fixed device standard request interpreter accidentally processing some class-specific requests\r
+ * - Added USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS compile time options to instruct the library\r
+ * to use descriptors stored in RAM or EEPROM rather than flash memory\r
+ * - All demos now disable watchdog on startup, in case it has been enabled by fuses or the bootloader\r
+ * - USB_DEV_OPT_LOWSPEED option now works correctly\r
+ * - Added ability to set the USB options statically for a binary size reduction via the USE_STATIC_OPTIONS\r
+ * compile time define\r
+ * - USB_Init no longer takes a Mode parameter if compiled for a USB device with no host mode option, or\r
+ * if forced to a particular mode via the USB_HOST_ONLY or USB_DEVICE_ONLY compile time options\r
+ * - USB_Init no longer takes an Options parameter if options statically configured by USE_STATIC_OPTIONS\r
+ * - Endpoint_Ignore_* and Pipe_Ignore_* made smaller by making the dummy variable non-volatile so that the\r
+ * compiler can throw away the result more efficiently\r
+ * - Added in an optional GroupID value to each scheduler entry, so that groups of tasks can once again be\r
+ * controlled by the new Scheduler_SetGroupTaskMode() routine\r
+ * - Added support for AT90USB162 and AT90USB82 AVR models\r
+ * - Added support for the STK525 and STK526 boards\r
+ * - Added support for custom board drivers to be supplied by selecting the board type as BOARD_USER, and\r
+ * placing board drivers in {Application Directory}/Board/\r
+ * - PLL is now stopped and USB clock is frozen when detached from host in device mode, to save power\r
+ * - Joystick defines are now in synch with the schematics - orientation will be rotated for the USBKEY\r
+ * - Fixed USB_DEV_IsUSBSuspended() - now checks the correct register\r
+ * - Fixed data transfers to devices when in host mode\r
+ * - Renamed USB_DEV_OPT_HIGHSPEED to USB_DEV_OPT_FULLSPEED and USB_HOST_IsDeviceHighSpeed() to\r
+ * USB_HOST_IsDeviceFullSpeed() to be in line with the official USB speed names (to avoid confusion with\r
+ * the real high speed mode, which is unavailable on the USB AVRs)\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog120 Version 1.2.0 (080204)\r
+ *\r
+ * - Added USB_DeviceEnumerationComplete event for host mode\r
+ * - Added new Scheduler_Init routine to prepare the scheduler, so that tasks can be started and\r
+ * stopped before the scheduler has been started (via Scheduler_Start)\r
+ * - Connection events in both Device and Host mode are now interrupt-driven, allowing the USB management\r
+ * task to be stopped when the USB is not connected to a host or device\r
+ * - All demos updated to stop the USB task when not in use via the appropriate USB events\r
+ * - Mass Storage Host demo application updated to function correctly with all USB flash disks\r
+ * - Mass Storage Host demo application now prints out the capacity and number of LUNs in the attached\r
+ * device, and prints the first block as hexadecimal numbers rather than ASCII characters\r
+ * - Endpoint and Pipe clearing routines now clear the Endpoint/Pipe interrupt and status flags\r
+ * - Shifted error handling code in the host enum state machine to a single block, to reduce code complexity\r
+ * - Added in DESCRIPTOR_TYPE, DESCRIPTOR_SIZE and DESCRIPTOR_CAST macros to make config descriptor processing\r
+ * clearer in USB hosts and DESCRIPTOR_ADDRESS for convenience in USB devices\r
+ * - Added in alloca macro to common.h, in case the user is using an old version of avr-lib-c missing the macro\r
+ *\r
+ *\r
+ * \section Sec_ChangeLog110 Version 1.1.0 (080125)\r
+ *\r
+ * - Fixed DCONNI interrupt being enabled accidentally after a USB reset\r
+ * - Fixed DDISCI interrupt not being disabled when a device is not connected\r
+ * - Added workaround for powerless pull-up devices causing false disconnect interrupts\r
+ * - Added USB_DeviceEnumerationFailed event for Host mode\r
+ * - AVR_HOST_GetDeviceConfigDescriptor routine no longer modifies ConfigSizePtr if a valid buffer\r
+ * pointer is passed\r
+ * - Added ALLOCABLE_BYTES to DynAlloc, and added code to make the size of key storage variables\r
+ * dependant on size of memory parameters passed in via the user project's makefile\r
+ * - Fixed incorrect device reset routine being called in USBTask\r
+ * - Devices which do not connect within the standard 300mS are now supported\r
+ * - Removed incorrect ATTR_PURE from Scheduler_SetTaskMode(), which was preventing tasks from being\r
+ * started/stopped, as well as USB_InitTaskPointer(), which was breaking dual device/host USB projects\r
+ * - Changed scheduler to use the task name rather than IDs for setting the task mode, eliminating the\r
+ * need to have a task ID list\r
+ * - ID transition interrupt now raises the appropriate device/host disconnect event if device attached\r
+ * - Fixed double VBUS change (and VBUS -) event when detaching in device mode\r
+ * - Added ability to disable ANSI terminal codes by the defining of DISABLE_TERMINAL_CODES in makefile\r
+ * - Removed return from ConfigurePipe and ConfigureEndpoint functions - use Pipe_IsConfigured() and\r
+ * Endpoint_IsConfigured() after calling the config functions to determine success\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_TokenSummary Summary of Compile Tokens\r
+ *\r
+ * The following lists all the possible tokens which can be defined in a project makefile, and passed to the\r
+ * compiler via the -D switch, to alter the LUFA library code. These tokens may alter the library behaviour,\r
+ * or remove features unused by a given application in order to save flash space.\r
+ *\r
+ * \note If the \c USE_LUFA_CONFIG_HEADER token is defined, the library will include a header file named \c LUFAConfig.h located\r
+ * in the user directory where the below compile time tokens may be defined. This allows for an alternative to makefile\r
+ * defined tokens for configuring the library.\r
+ *\r
+ * \section Sec_SummaryNonUSBTokens Non USB Related Tokens\r
+ * This section describes compile tokens which affect non-USB sections of the LUFA library.\r
+ *\r
+ * - <b>DISABLE_TERMINAL_CODES</b> - (\ref Group_Terminal) - <i>All Architectures</i> \n\r
+ * If an application contains ANSI terminal control codes listed in TerminalCodes.h, it might be desired to remove them\r
+ * at compile time for use with a terminal which is non-ANSI control code aware, without modifying the source code. If\r
+ * this token is defined, all ANSI control codes in the application code from the TerminalCodes.h header are removed from\r
+ * the source code at compile time.\r
+ *\r
+ *\r
+ * \section Sec_SummaryUSBClassTokens USB Class Driver Related Tokens\r
+ * This section describes compile tokens which affect USB class-specific drivers in the LUFA library.\r
+ *\r
+ * - <b>HID_HOST_BOOT_PROTOCOL_ONLY</b> - (\ref Group_USBClassHIDHost) - <i>All Architectures</i> \n\r
+ * By default, the USB HID Host class driver is designed to work with HID devices using either the Boot or Report HID\r
+ * communication protocols. On devices where the Report protocol is not used (i.e. in applications where only basic\r
+ * Mouse or Keyboard operation is desired, using boot compatible devices), the code responsible for the Report protocol\r
+ * mode can be removed to save space in the compiled application by defining this token. When defined, it is still necessary\r
+ * to explicitly put the attached device into Boot protocol mode via a call to \ref HID_Host_SetBootProtocol().\r
+ *\r
+ * - <b>HID_STATETABLE_STACK_DEPTH</b>=<i>x</i> - (\ref Group_HIDParser) - <i>All Architectures</i> \n\r
+ * HID reports may contain PUSH and POP elements, to store and retrieve the current HID state table onto a stack. This\r
+ * allows for reports to save the state table before modifying it slightly for a data item, and then restore the previous\r
+ * state table in a compact manner. This token may be defined to a non-zero 8-bit value to give the maximum depth of the state\r
+ * table stack. If not defined, this defaults to the value indicated in the HID.h file documentation.\r
+ *\r
+ * - <b>HID_USAGE_STACK_DEPTH</b>=<i>x</i> - (\ref Group_HIDParser) - <i>All Architectures</i> \n\r
+ * HID reports generally contain many USAGE elements, which are assigned to INPUT, OUTPUT and FEATURE items in succession\r
+ * when multiple items are defined at once (via REPORT COUNT elements). This allows for several items to be defined with\r
+ * different usages in a compact manner. This token may be defined to a non-zero 8-bit value to set the maximum depth of the\r
+ * usage stack, indicating the maximum number of USAGE items which can be stored temporarily until the next INPUT, OUTPUT\r
+ * and FEATURE item. If not defined, this defaults to the value indicated in the HID.h file documentation.\r
+ *\r
+ * - <b>HID_MAX_COLLECTIONS</b>=<i>x</i> - (\ref Group_HIDParser) - <i>All Architectures</i> \n\r
+ * HID reports generally contain several COLLECTION elements, used to group related data items together. Collection information\r
+ * is stored separately in the processed usage structure (and referred to by the data elements in the structure) to save space.\r
+ * This token may be defined to a non-zero 8-bit value to set the maximum number of COLLECTION items which can be processed by the\r
+ * parser into the resultant processed report structure. If not defined, this defaults to the value indicated in the HID.h file\r
+ * documentation.\r
+ *\r
+ * - <b>HID_MAX_REPORTITEMS</b>=<i>x</i> - (\ref Group_HIDParser) - <i>All Architectures</i> \n\r
+ * All HID reports contain one or more INPUT, OUTPUT and/or FEATURE items describing the data which can be sent to and from the HID\r
+ * device. Each item has associated usages, bit offsets in the item reports and other associated data indicating the manner in which\r
+ * the report data should be interpreted by the host. This token may be defined to a non-zero 8-bit value to set the maximum number of\r
+ * data elements which can be stored in the processed HID report structure, including INPUT, OUTPUT and (if enabled) FEATURE items.\r
+ * If a item has a multiple count (i.e. a REPORT COUNT of more than 1), each item in the report count is placed separately in the\r
+ * processed HID report table. If not defined, this defaults to the value indicated in the HID.h file documentation.\r
+ *\r
+ * - <b>HID_MAX_REPORT_IDS</b>=<i>x</i> - (\ref Group_HIDParser) - <i>All Architectures</i> \n\r
+ * HID reports may contain several report IDs, to logically distinguish grouped device data from one another - for example, a combination\r
+ * keyboard and mouse might use report IDs to separate the keyboard reports from the mouse reports. In order to determine the size of each\r
+ * report, and thus know how many bytes must be read or written, the size of each report (IN, OUT and FEATURE) must be calculated and\r
+ * stored. This token may be defined to a non-zero 8-bit value to set the maximum number of report IDs in a device which can be processed\r
+ * and their sizes calculated/stored into the resultant processed report structure. If not defined, this defaults to the value indicated in\r
+ * the HID.h file documentation.\r
+ *\r
+ * - <b>NO_CLASS_DRIVER_AUTOFLUSH</b> - (\ref Group_USBClassDrivers) - <i>All Architectures</i> \n\r
+ * Many of the device and host mode class drivers automatically flush any data waiting to be written to an interface, when the corresponding\r
+ * USB management task is executed. This is usually desirable to ensure that any queued data is sent as soon as possible once and new data is\r
+ * constructed in the main program loop. However, if flushing is to be controlled manually by the user application via the *_Flush() commands,\r
+ * the compile time token may be defined in the application's makefile to disable automatic flushing during calls to the class driver USB\r
+ * management tasks.\r
+ *\r
+ *\r
+ * \section Sec_SummaryUSBTokens General USB Driver Related Tokens\r
+ * This section describes compile tokens which affect USB driver stack as a whole in the LUFA library.\r
+ *\r
+ * - <b>ORDERED_EP_CONFIG</b> - (\ref Group_EndpointManagement , \ref Group_PipeManagement) - <i>AVR8, UC3</i> \n\r
+ * The USB AVRs do not allow for Endpoints and Pipes to be configured out of order; they <i>must</i> be configured in an ascending order to\r
+ * prevent data corruption issues. However, by default LUFA employs a workaround to allow for unordered Endpoint/Pipe initialization. This compile\r
+ * time token may be used to restrict the initialization order to ascending indexes only in exchange for a smaller compiled binary size. Use\r
+ * caution when applied to applications using the library USB Class drivers; the user application must ensure that all endpoints and pipes are\r
+ * allocated sequentially.\r
+ *\r
+ * - <b>USE_STATIC_OPTIONS</b>=<i>x</i> - (\ref Group_USBManagement) - <i>All Architectures</i> \n\r
+ * By default, the USB_Init() function accepts dynamic options at runtime to alter the library behaviour, including whether the USB pad\r
+ * voltage regulator is enabled, and the device speed when in device mode. By defining this token to a mask comprised of the USB options\r
+ * mask defines usually passed as the Options parameter to USB_Init(), the resulting compiled binary can be decreased in size by removing\r
+ * the dynamic options code, and replacing it with the statically set options. When defined, the USB_Init() function no longer accepts an\r
+ * Options parameter.\r
+ *\r
+ * - <b>USB_DEVICE_ONLY</b> - (\ref Group_USBManagement) - <i>All Architectures</i> \n\r
+ * For the USB AVR models supporting both device and host USB modes, the USB_Init() function contains a Mode parameter which specifies the\r
+ * mode the library should be initialized to. If only device mode is required, the code for USB host mode can be removed from the binary to\r
+ * save space. When defined, the USB_Init() function no longer accepts a Mode parameter. This define is irrelevant on smaller USB AVRs which\r
+ * do not support host mode.\r
+ *\r
+ * - <b>USB_HOST_ONLY</b> - (\ref Group_USBManagement) - <i>All Architectures</i> \n\r
+ * Same as USB_DEVICE_ONLY, except the library is fixed to USB host mode rather than USB device mode. Not available on some USB AVR models.\r
+ *\r
+ * - <b>USB_STREAM_TIMEOUT_MS</b>=<i>x</i> - (\ref Group_USBManagement) - <i>All Architectures</i> \n\r
+ * When endpoint and/or pipe stream functions are used, by default there is a timeout between each transfer which the connected device or host\r
+ * must satisfy, or the stream function aborts the remaining data transfer. This token may be defined to a non-zero 16-bit value to set the timeout\r
+ * period for stream transfers, specified in milliseconds. If not defined, the default value specified in LowLevel.h is used instead.\r
+ *\r
+ * - <b>NO_LIMITED_CONTROLLER_CONNECT</b> - (\ref Group_Events) - <i>AVR8 Only</i> \n\r
+ * On the smaller USB AVRs, the USB controller lacks VBUS events to determine the physical connection state of the USB bus to a host. In lieu of\r
+ * VBUS events, the library attempts to determine the connection state via the bus suspension and wake up events instead. This however may be\r
+ * slightly inaccurate due to the possibility of the host suspending the bus while the device is still connected. If accurate connection status is\r
+ * required, the VBUS line of the USB connector should be routed to an AVR pin to detect its level, so that the USB_DeviceState global\r
+ * can be accurately set and the \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events manually raised by the RAISE_EVENT macro.\r
+ * When defined, this token disables the library's auto-detection of the connection state by the aforementioned suspension and wake up events.\r
+ *\r
+ * - <b>NO_SOF_EVENTS</b> - (\ref Group_Events) - <i>All Architectures</i> \n\r
+ * By default, there exists a LUFA application event for the start of each USB frame while the USB bus is not suspended in either host or device mode.\r
+ * This event can be selectively enabled or disabled by calling the appropriate device or host mode function. When this compile time token is defined,\r
+ * the ability to receive USB Start of Frame events via the \ref EVENT_USB_Device_StartOfFrame() or \ref EVENT_USB_Host_StartOfFrame() events is removed,\r
+ * reducing the compiled program's binary size.\r
+ *\r
+ *\r
+ * \section Sec_SummaryUSBDeviceTokens USB Device Mode Driver Related Tokens\r
+ * This section describes compile tokens which affect USB driver stack of the LUFA library when used in Device mode.\r
+ *\r
+ * - <b>USE_RAM_DESCRIPTORS</b> - (\ref Group_StdDescriptors) - <i>AVR8 Only</i> \n\r
+ * Define this token to indicate to the USB driver that all device descriptors are stored in RAM, rather than being located in any one\r
+ * of the AVR's memory spaces. RAM descriptors may be desirable in applications where the descriptors need to be modified at runtime.\r
+ *\r
+ * - <b>USE_FLASH_DESCRIPTORS</b> - (\ref Group_StdDescriptors) - <i>AVR8 Only</i> \n\r
+ * Similar to USE_RAM_DESCRIPTORS, but all descriptors are stored in the AVR's FLASH memory rather than RAM.\r
+ *\r
+ * - <b>USE_EEPROM_DESCRIPTORS</b> - (\ref Group_StdDescriptors) - <i>AVR8 Only</i> \n\r
+ * Similar to USE_RAM_DESCRIPTORS, but all descriptors are stored in the AVR's EEPROM memory rather than RAM.\r
+ *\r
+ * - <b>NO_INTERNAL_SERIAL</b> - (\ref Group_StdDescriptors) - <i>All Architectures</i> \n\r
+ * Some AVR models contain a unique serial number which can be used as the device serial number, while in device mode. This allows\r
+ * the host to uniquely identify the device regardless of if it is moved between USB ports on the same computer, allowing allocated\r
+ * resources (such as drivers, COM Port number allocations) to be preserved. This is not needed in many apps, and so the code that\r
+ * performs this task can be disabled by defining this option and passing it to the compiler via the -D switch.\r
+ *\r
+ * - <b>FIXED_CONTROL_ENDPOINT_SIZE</b>=<i>x</i> - (\ref Group_EndpointManagement) - <i>All Architectures</i> \n\r
+ * By default, the library determines the size of the control endpoint (when in device mode) by reading the device descriptor.\r
+ * Normally this reduces the amount of configuration required for the library, allows the value to change dynamically (if\r
+ * descriptors are stored in EEPROM or RAM rather than flash memory) and reduces code maintenance. However, this token can be\r
+ * defined to a non-zero value instead to give the size in bytes of the control endpoint, to reduce the size of the compiled\r
+ * binary.\r
+ *\r
+ * - <b>DEVICE_STATE_AS_GPIOR</b> - (\ref Group_Device) - <i>AVR8 Only</i> \n\r
+ * One of the most frequently used global variables in the stack is the USB_DeviceState global, which indicates the current state of\r
+ * the Device State Machine. To reduce the amount of code and time required to access and modify this global in an application, this token\r
+ * may be defined to a value between 0 and 2 to fix the state variable into one of the three general purpose IO registers inside the AVR\r
+ * reserved for application use. When defined, the corresponding GPIOR register should not be used within the user application except\r
+ * implicitly via the library APIs.\r
+ *\r
+ * - <b>FIXED_NUM_CONFIGURATIONS</b>=<i>x</i> - (\ref Group_Device) - <i>All Architectures</i> \n\r
+ * By default, the library determines the number of configurations a USB device supports by reading the device descriptor. This reduces\r
+ * the amount of configuration required to set up the library, and allows the value to change dynamically (if descriptors are stored in\r
+ * EEPROM or RAM rather than flash memory) and reduces code maintenance. However, this value may be fixed via this token in the project\r
+ * makefile to reduce the compiled size of the binary at the expense of flexibility.\r
+ *\r
+ * - <b>CONTROL_ONLY_DEVICE</b> - (\ref Group_Device) - <i>All Architectures</i> \n\r
+ * In some limited USB device applications, there are no device endpoints other than the control endpoint; i.e. all device communication\r
+ * is through control endpoint requests. Defining this token will remove several features related to the selection and control of device\r
+ * endpoints internally, saving space. Generally, this is usually only useful in (some) bootloaders and is best avoided.\r
+ *\r
+ * - <b>MAX_ENDPOINT_INDEX</b> - (\ref Group_Device) - <i>XMEGA Only</i> \n\r
+ * Defining this value to the highest index (not address - this excludes the direction flag) endpoint within the device will restrict the\r
+ * number of FIFOs created internally for the endpoint buffers, reducing the total RAM usage.\r
+ *\r
+ * - <b>INTERRUPT_CONTROL_ENDPOINT</b> - (\ref Group_USBManagement) - <i>All Architectures</i> \n\r
+ * Some applications prefer to not call the USB_USBTask() management task regularly while in device mode, as it can complicate code significantly.\r
+ * Instead, when device mode is used this token can be passed to the library via the -D switch to allow the library to manage the USB control\r
+ * endpoint entirely via USB controller interrupts asynchronously to the user application. When defined, USB_USBTask() does not need to be called\r
+ * when in USB device mode.\r
+ *\r
+ * - <b>NO_DEVICE_REMOTE_WAKEUP</b> - (\ref Group_Device) - <i>All Architectures</i> \n\r
+ * Many devices do not require the use of the Remote Wakeup features of USB, used to wake up the USB host when suspended. On these devices,\r
+ * the code required to manage device Remote Wakeup can be disabled by defining this token and passing it to the library via the -D switch.\r
+ *\r
+ * - <b>NO_DEVICE_SELF_POWER</b> - (\ref Group_Device) - <i>All Architectures</i> \n\r
+ * USB devices may be bus powered, self powered, or a combination of both. When a device can be both bus powered and self powered, the host may\r
+ * query the device to determine the current power source, via \ref USB_Device_CurrentlySelfPowered. For solely bus powered devices, this global\r
+ * and the code required to manage it may be disabled by passing this token to the library via the -D switch.\r
+ *\r
+ *\r
+ * \section Sec_SummaryUSBHostTokens USB Host Mode Driver Related Tokens\r
+ *\r
+ * This section describes compile tokens which affect USB driver stack of the LUFA library when used in Host mode.\r
+ *\r
+ * - <b>HOST_STATE_AS_GPIOR</b> - (\ref Group_Host) - <i>AVR8 Only</i> \n\r
+ * One of the most frequently used global variables in the stack is the USB_HostState global, which indicates the current state of\r
+ * the Host State Machine. To reduce the amount of code and time required to access and modify this global in an application, this token\r
+ * may be defined to a value between 0 and 2 to fix the state variable into one of the three general purpose IO registers inside the AVR\r
+ * reserved for application use. When defined, the corresponding GPIOR register should not be used within the user application except\r
+ * implicitly via the library APIs.\r
+ *\r
+ * - <b>USB_HOST_TIMEOUT_MS</b>=<i>x</i> - (\ref Group_Host) - <i>All Architectures</i> \n\r
+ * When a control transfer is initiated in host mode to an attached device, a timeout is used to abort the transfer if the attached\r
+ * device fails to respond within the timeout period. This token may be defined to a non-zero 16-bit value to set the timeout period for\r
+ * control transfers, specified in milliseconds. If not defined, the default value specified in Host.h is used instead.\r
+ *\r
+ * - <b>HOST_DEVICE_SETTLE_DELAY_MS</b>=<i>x</i> - (\ref Group_Host) - <i>All Architectures</i> \n\r
+ * Some devices require a delay of up to 5 seconds after they are connected to VBUS before the enumeration process can be started, or\r
+ * they will fail to enumerate correctly. By placing a delay before the enumeration process, it can be ensured that the bus has settled\r
+ * back to a known idle state before communications occur with the device. This token may be defined to a 16-bit value to set the device\r
+ * settle period, specified in milliseconds. If not defined, the default value specified in Host.h is used instead.\r
+ *\r
+ * - <b>INVERTED_VBUS_ENABLE_LINE</b> - (\ref Group_Host) - <i>All Architectures</i> \n\r
+ * If enabled, this will indicate that the USB target VBUS line polarity is inverted; i.e. it should be pulled low to enable VBUS to the\r
+ * target, and pulled high to stop the target VBUS generation.\r
+ *\r
+ * \attention On AVR8 architecture devices, this compile time option requires \c NO_AUTO_VBUS_MANAGEMENT to be set.\r
+ *\r
+ * - <b>NO_AUTO_VBUS_MANAGEMENT</b> - (\ref Group_Host) - <i>All Architectures</i> \n\r
+ * Disables the automatic management of VBUS to the target, i.e. automatic shut down in the even of an overcurrent situation. When enabled, VBUS\r
+ * is enabled while the USB controller is initialized in USB Host mode.\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_CompilingApps Compiling the Demos, Bootloaders and Projects\r
+ *\r
+ * The following details how to compile the included LUFA demos, applications and bootloaders using AVR-GCC.\r
+ *\r
+ * \section Sec_Prerequisites Prerequisites\r
+ * Before you can compile any of the LUFA library code or demos, you will need a recent distribution of avr-libc (1.6.2+)\r
+ * and the AVR-GCC (4.2+) compiler. A standard "coreutils" package for your system is also required for command line\r
+ * compilation of LUFA based applications.\r
+ *\r
+ * \subsection SSec_PreqWindows Windows Prerequisites\r
+ * On Windows, you will need a copy of the latest Atmel Toolchain, either downloaded and installed as a standalone\r
+ * package, or installed as part of Atmel Studio. You will need to ensure that the "bin" directory of the toolchain\r
+ * is available in your system's <b>PATH</b> environment variable.\r
+ *\r
+ * In addition, you will need to install a ported version of the ZSH or BASH *nix shells, and a standard set of *nix\r
+ * utilities such as <i>cut</i>, <i>find</i> and <i>sed</i>. These can be found in the "basic" system package of the\r
+ * of the MinGW installer (<a>http://www.mingw.org</a>). Once installed, add the "msys\1.0\bin" of the MinGW installation\r
+ * folder is added to your system's <b>PATH</b> environment variable.\r
+ *\r
+ * The bootloaders currently also require the "bc" application, which can be installed from\r
+ * <a>http://gnuwin32.sourceforge.net/downlinks/bc.php</a>. Once installed add the "GnuWin32\bin" path of the GnuWin32\r
+ * installation folder to your system's <b>PATH</b> environment variable.\r
+ *\r
+ * \subsection SSec_PreqLinux Linux Prerequisites\r
+ * On Linux systems you will need to install the latest Linux distribution of the standalone Atmel Toolchain from the\r
+ * Atmel website for general development, or use the latest avr-libc and avr-gcc packages for your chosen distribution's\r
+ * package manager. For full device support, the Atmel standalone package is recommended.\r
+ *\r
+ * \section Sec_Compiling Compiling a LUFA Application\r
+ * Compiling the LUFA demos, applications and/or bootloaders is very simple. LUFA comes with makefile scripts for\r
+ * each individual demo, bootloader and project folder, as well as scripts in the Demos/, Bootloaders/, Projects/\r
+ * and the LUFA root directory. Compilation of projects can be started from any of the above directories, with a build\r
+ * started from an upper directory in the directory structure executing build of all child directories under it. This\r
+ * means that while a build inside a particular demo directory will build only that particular demo, a build started from\r
+ * the /Demos/ directory will build all LUFA demo projects sequentially.\r
+ *\r
+ * To build a project from the source via the command line, the command <b>"make all"</b> should be executed from the command\r
+ * line in the directory of interest. To remove compiled files (including the binary output, all intermediately files and all\r
+ * diagnostic output files), execute <b>"make clean"</b>. Once a "make all" has been run and no errors were encountered, the\r
+ * resulting binary will be located in the generated ".HEX" file. If your project makes use of pre-initialized EEPROM\r
+ * variables, the generated ".EEP" file will contain the project's EEPROM data.\r
+ *\r
+ * \see \ref Page_BuildSystem for information on the LUFA build system.\r
+ */\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_ConfiguringApps Configuring the Demos, Bootloaders and Projects\r
+ *\r
+ * If the target microcontroller model, architecture, clock speed, board or other settings are different from the current\r
+ * settings, they must be changed and the project recompiled from the source code before being programmed into the microcontroller.\r
+ * Most project configuration options are located in the <tt>makefile</tt> build script inside each LUFA application's folder,\r
+ * however some demo or application-specific configuration settings are located in one or more of the source files of the project.\r
+ * See each project's individual documentation for application-specific configuration values.\r
+ *\r
+ * Each project "makefile" contains all the script and configuration data required to compile each project. When opened with\r
+ * any regular basic text editor such as Notepad or WordPad (ensure that the save format is a pure ASCII text format) the\r
+ * build configuration settings may be altered.\r
+ *\r
+ * \see \ref Page_BuildSystem for information on the LUFA build system.\r
+ *\r
+ * \section Sec_AppConfigParams The Default Application Template\r
+ *\r
+ * Below is a copy of the default LUFA application makefile, which can be used as a template for each application.\r
+ *\r
+ * \verbinclude makefile_template\r
+ *\r
+ * Inside each makefile, a number of configuration variables are listed with the syntax "<VARIABLE NAME> = <VALUE>". For\r
+ * each application, the important standard variables which should be altered are:\r
+ *\r
+ * - <b>MCU</b>, the target processor model\r
+ * - <b>ARCH</b>, the target microcontroller architecture\r
+ * - <b>BOARD</b>, the target board hardware\r
+ * - <b>F_CPU</b>, the target CPU master clock frequency, after any prescaling\r
+ * - <b>F_USB</b>, the target raw input clock to the USB module of the processor\r
+ * - <b>OPTIMIZATION</b>, the level of optimization to compile with\r
+ * - <b>TARGET</b>, the name of the target output binary and other files\r
+ * - <b>SRC</b>, the list of source files to compile/assemble/link\r
+ * - <b>LUFA_PATH</b>, the path to the LUFA library core source code\r
+ * - <b>CC_FLAGS</b>, the common command line flags to pass to the C/C++ compiler, assembler and linker\r
+ * - <b>LD_FLAGS</b>, the command line flags to pass to the linker\r
+ *\r
+ * These values should be changed to reflect the build hardware.\r
+ *\r
+ * \subsection SSec_MCU The MCU Parameter\r
+ * This parameter indicates the target microcontroller model for the compiled application. This should be set to the model of the target\r
+ * microcontroller (such as the AT90USB1287, or the ATMEGA32U4), in all lower-case (e.g. "at90usb1287"). Note that not all demos support all the\r
+ * microcontroller models and architectures, as they may make use of peripherals or modes only present in some devices.\r
+ *\r
+ * For supported processor models, see \ref Page_DeviceSupport.\r
+ *\r
+ * \subsection SSec_ARCH The ARCH Parameter\r
+ * This parameter indicates the target microcontroller architecture the library is to be compiled for. Different microcontroller\r
+ * architectures require different source files to be compiled into the final binary, and so this option must be set to the correct\r
+ * architecture for the selected platform.\r
+ *\r
+ * For supported processor architectures, see \ref Page_DeviceSupport.\r
+ *\r
+ * \subsection SSec_BOARD The BOARD Parameter\r
+ * This parameter indicates the target board hardware for the compiled application. Some LUFA library drivers are board-specific,\r
+ * such as the LED driver, and the library needs to know the layout of the target board. If you are using one of the board models listed\r
+ * on the main library page, change this parameter to the board name in all UPPER-case.\r
+ *\r
+ * If you are not using any board-specific drivers in the LUFA library, or you are using a custom board layout, change this to read\r
+ * "USER" (no quotes) instead of a standard board name. If the USER board type is selected and the application makes use of one or more\r
+ * board-specific hardware drivers inside the LUFA library, then the appropriate stub drives files should be copied from the \c /CodeTemplates/DriverStubs/\r
+ * directory into a /Board/ folder inside the application directory, and the stub driver completed with the appropriate code to drive the\r
+ * custom board's hardware.\r
+ *\r
+ * For boards with built in hardware driver support within the LUFA library, see \ref Page_DeviceSupport.\r
+ *\r
+ * \subsection SSec_F_CPU The F_CPU Parameter\r
+ * This parameter indicates the target microcontroller's main CPU clock frequency, in Hz. This is used by many libraries (and applications) for\r
+ * timing related purposes, and should reflect the actual CPU speed after any prescaling or adjustments are performed.\r
+ *\r
+ * \subsection SSec_F_USB The F_USB Parameter\r
+ * This parameter indicates the raw input clock frequency to the USB module within the microcontroller in Hz. This may be very different on some platforms\r
+ * to the main CPU clock or other peripheral/bus clocks.\r
+ *\r
+ * \subsection SSec_OPTIMIZATION The OPTIMIZATION Parameter\r
+ * This parameter indicates the level of optimization to use when compiling the application. This will allow you to compile with an optimization level\r
+ * supported by GCC, from <tt>0</tt> (no optimization) to <tt>3</tt> (fastest runtime optimization) or <tt>s</tt> (smallest size).\r
+ *\r
+ * \subsection SSec_TARGET The TARGET Parameter\r
+ * This parameter indicates the application target name, which is used as the base filename for the build binary and debugging files. This will be the\r
+ * name of the output files once linked together into the final application, ready to load into the target.\r
+ *\r
+ * \subsection SSec_SRC The SRC Parameter\r
+ * This parameter indicates the source files used to compile the application, as a list of C (<tt>*.c</tt>), C++ (<tt>*.cpp</tt>) and Assembly (<tt>*.S</tt>) files. Note that\r
+ * all assembly files must end in a <b>capital</b> .S extension, as lowercase .s files are reserved for GCC intermediate files.\r
+ *\r
+ * \subsection SSec_LUFA_PATH The LUFA_PATH Parameter\r
+ * As each LUFA program requires the LUFA library source code to compile correctly, the application must know where the LUFA library is located. This\r
+ * value specifies the path to the LUFA library core. This path may be relative or absolute, however note than even under Windows based systems the\r
+ * forward-slash (/) path seperator must be used.\r
+ *\r
+ * \subsection SSec_CC_FLAGS The CC_FLAGS Parameter\r
+ * This parameter lists the compiler flags passed to the C/C++ compiler, the assembler and the linker. These are used as-is directly to GCC and thus\r
+ * must match GCC's command line options as given in the GCC manual. This variable may be used to define tokens directly on the command line, enable or\r
+ * disable warnings, adjust the target-specific tuning parameters or other options.\r
+ *\r
+ * \subsection SSec_LD_FLAGS The LD_FLAGS Parameter\r
+ * This parameter lists the linker flags passed exclusively to the linker. These are used as-is directly to GCC and thus must match GCC's command line\r
+ * linker options as given in the GCC manual. This variable may be used to create or relocate custom data sections, or enable linker specific behaviors.\r
+ */\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/**\r
+ * \page Page_DevelopingWithLUFA Developing With LUFA\r
+ *\r
+ * This section of the manual contains information on LUFA development, such as Getting Started information,\r
+ * information on compile-time tuning of the library and other developer-related sections.\r
+ *\r
+ * <b>Subsections:</b>\r
+ * \li \subpage Page_BuildSystem - The LUFA Buildsystem\r
+ * \li \subpage Page_TokenSummary - Summary of Compile Time Tokens\r
+ * \li \subpage Page_Migration - Migrating from an Older LUFA Version\r
+ * \li \subpage Page_VIDPID - Allocated USB VID and PID Values\r
+ * \li \subpage Page_BuildLibrary - Building as a Linkable Library\r
+ * \li \subpage Page_ExportingLibrary - Exporting LUFA for IDE Use\r
+ * \li \subpage Page_WritingBoardDrivers - How to Write Custom Board Drivers\r
+ * \li \subpage Page_SoftwareBootloaderStart - How to jump to the bootloader in software\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/**\r
+ * \page Page_DeviceSupport Device and Hardware Support\r
+ *\r
+ * <b>Atmel Microcontrollers:</b>\r
+ * \li \subpage Page_AVR8Support - Atmel AVR8 Support\r
+ * \li \subpage Page_UC3Support - Atmel AVR32 UC3 Support\r
+ * \li \subpage Page_XMEGASupport - Atmel XMEGA Support\r
+ */\r
+ \r
+/**\r
+ * \page Page_AVR8Support Atmel 8-Bit AVR (AVR8) Support\r
+ *\r
+ * \section Sec_AVR8Support_Devices Supported Microcontroller Models\r
+ *\r
+ * Currently supported AVR8 models:\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <th width="150px">Part</th>\r
+ * <th width="150px">USB Device Mode</th>\r
+ * <th width="150px">USB Host Mode</th>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT90USB82</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATMEGA8U2</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT90USB162</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATMEGA16U2</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATMEGA16U4</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATMEGA32U2</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATMEGA32U4</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATMEGA32U6</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT90USB646</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT90USB647</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT90USB1286</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT90USB1287</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section Sec_AVR8Support_Boards Supported Atmel Boards\r
+ * Currently supported Atmel AVR8 boards (see \ref Group_BoardTypes):\r
+ * - AT90USBKEY\r
+ * - ATAVRUSBRF01\r
+ * - EVK527\r
+ * - RZUSBSTICK\r
+ * - STK525\r
+ * - STK526\r
+ * - XPLAIN (Original green board, <i>not</i> the newer blue XPLAINED family boards)\r
+ *\r
+ * \section Sec_AVR8Support_ThirdParty Supported Third Party Models\r
+ * Currently supported third-party boards (see \ref Group_BoardTypes for makefile \c BOARD constant names):\r
+ * - Adafruit U4 Breakout Board\r
+ * - Arduino Uno\r
+ * - Bitwizard Multio and Big-Multio\r
+ * - Busware BUI\r
+ * - Busware CUL V3\r
+ * - Busware TUL\r
+ * - DorkbotPDX Duce\r
+ * - Fletchtronics Bumble-B (using manufacturer recommended peripheral layout)\r
+ * - Kernel Concepts USBFOO\r
+ * - Linnix UDIP\r
+ * - MattairTech JM-DB-U2\r
+ * - Maximus USB\r
+ * - Micropendous Boards (Micropendous-32U2, Micropendous-1, Micropendous-2)\r
+ * - Microsin AVR-USB162\r
+ * - Minimus USB\r
+ * - Olimex AVR-USB-162\r
+ * - Olimex AVR-USB-32U4\r
+ * - Olimex AVR-USB-T32U4\r
+ * - Olimex AVR-ISP-MK2\r
+ * - Paranoid Studio's US2AX (V1, V2 and V3 hardware revisions)\r
+ * - PJRC Teensy (1.x and 2.x versions)\r
+ * - Sparkfun U2 Breakout Board\r
+ * - TCNISO Blackcat USB JTAG\r
+ * - Tempusdictum Benito\r
+ * - Tom's USBTINY-MKII (all revisions and versions)\r
+ * - Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers)\r
+ */\r
+ \r
+/**\r
+ * \page Page_UC3Support Atmel 32-Bit UC3 AVR (UC3)\r
+ *\r
+ * \warning The AVR32 UC3 device support is currently <b>experimental</b>, and is included for preview purposes only.\r
+ *\r
+ * \section Sec_UC3Support_Devices Supported Microcontroller Models\r
+ *\r
+ * Currently supported UC3 models:\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <th width="150px">Part</th>\r
+ * <th width="150px">USB Device Mode</th>\r
+ * <th width="150px">USB Host Mode</th>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A064</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A164</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A364</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A364S</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A464</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A464S</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3B064</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3B164</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A0128</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A1128</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A3128</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A3128S</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A4128</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A4128S</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3B0128</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3B1128</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A0256</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A1256</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A3256</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A3256S</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A4256</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A4256S</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3B0256</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3B1256</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A0512</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3A1512</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3B0512</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>AT32UC3B1512</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section Sec_UC3Support_Boards Supported Atmel Boards\r
+ *\r
+ * Currently supported Atmel UC3 boards (see \ref Group_BoardTypes):\r
+ * - EVK1100\r
+ * - EVK1101\r
+ * - EVK1104\r
+ *\r
+ * \section Sec_UC3Support_ThirdParty Supported Third Party Models\r
+ *\r
+ * Currently supported third-party boards (see \ref Group_BoardTypes for makefile \c BOARD constant names):\r
+ * - Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers)\r
+ */\r
+ \r
+/**\r
+ * \page Page_XMEGASupport Atmel USB XMEGA AVR (XMEGA)\r
+ *\r
+ * \warning The XMEGA device support is currently <b>experimental</b> (incomplete and/or non-functional), and is included for preview purposes only.\r
+ *\r
+ * \section Sec_XMEGASupport_Devices Supported Microcontroller Models\r
+ *\r
+ * Currently supported XMEGA models:\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <th width="150px">Part</th>\r
+ * <th width="150px">USB Device Mode</th>\r
+ * <th width="150px">USB Host Mode</th>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA16A4U</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA32A4U</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA64A4U</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA128A4U</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA64A3U</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA128A3U</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA192A3U</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA256A3U</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA256A3BU</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA128A1U</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA64B3</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA128B3</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA64B1</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA128B1</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA64C3</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA128C3</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA192C3</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA256C3</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA384C3</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA16C4</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>ATXMEGA32C4</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ * \section Sec_XMEGASupport_Boards Supported Atmel Boards\r
+ * Currently supported Atmel XMEGA boards (see \ref Group_BoardTypes):\r
+ * - XMEGA A3BU Xplained\r
+ * - XMEGA B1 Xplained\r
+ *\r
+ * \section Sec_XMEGASupport_ThirdParty Supported Third Party Models\r
+ * Currently supported third-party boards (see \ref Group_BoardTypes for makefile \c BOARD constant names):\r
+ * - Custom User Boards (with Board Drivers if desired, see \ref Page_WritingBoardDrivers)\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \dir Platform\r
+ * \brief Platform specific drivers.\r
+ *\r
+ * This folder contains platform specific drivers and defines for various supported architectures. These may or may\r
+ * not be used in a LUFA application, and are provided for convenience purposes.\r
+ *\r
+ * \dir Drivers\r
+ * \brief Library hardware and software drivers.\r
+ *\r
+ * This folder contains all the library hardware and software drivers for each supported board, architecture and\r
+ * microcontroller model.\r
+ *\r
+ * \dir Drivers/Misc\r
+ * \brief Miscellaneous driver files.\r
+ *\r
+ * This folder contains drivers for aspects other than the USB interface, board hardware or microcontroller peripherals.\r
+ *\r
+ * \dir Drivers/Peripheral\r
+ * \brief Microcontroller peripheral driver files.\r
+ *\r
+ * This folder contains drivers for various low level microcontroller peripherals, usually located on the microcontroller\r
+ * die within the same physical chip.\r
+ *\r
+ * \dir Drivers/USB\r
+ * \brief USB controller peripheral driver files.\r
+ *\r
+ * This folder contains the complete LUFA USB stack and controller files, including the core driver and stack, as well\r
+ * as the USB class driver implementations.\r
+ *\r
+ * \dir Drivers/USB/Core\r
+ * \brief Core USB driver files.\r
+ *\r
+ * This folder contains the core USB stack and controller driver files, to correctly implement USB functionality on the\r
+ * target architecture and microcontroller model. This\r
+ *\r
+ * \dir Drivers/USB/Class\r
+ * \brief USB Class helper driver files.\r
+ *\r
+ * This folder contains drivers for implementing functionality of standardized USB classes. These are not used directly by the library,\r
+ * but provide a standard and library-maintained way of implementing functionality from some of the defined USB classes without extensive\r
+ * development effort. Is is recommended that these drivers be used where possible to reduce maintenance of user applications.\r
+ *\r
+ * \dir Drivers/USB/Class/Device\r
+ * \brief USB Device Class helper driver files.\r
+ *\r
+ * Device mode drivers for the standard USB classes.\r
+ *\r
+ * \dir Drivers/USB/Class/Host\r
+ * \brief USB Host Class helper driver files.\r
+ *\r
+ * Host mode drivers for the standard USB classes.\r
+ *\r
+ * \dir Drivers/Board\r
+ * \brief Board hardware driver files.\r
+ *\r
+ * This folder contains drivers for interfacing with the physical hardware on supported commercial boards, primarily from\r
+ * the Atmel corporation. Header files in this folder should be included in user applications requiring the functionality of\r
+ * hardware placed on supported boards.\r
+ *\r
+ * \dir CodeTemplates\r
+ * \brief Code templates for use in LUFA powered applications.\r
+ *\r
+ * This contains code templates for board drivers, sample LUFA project makefiles and other similar templates that can be copied into\r
+ * a LUFA powered application and modified to speed up development.\r
+ *\r
+ * \dir CodeTemplates/DriverStubs\r
+ * \brief Driver stub header files for custom boards, to allow the LUFA board drivers to operate.\r
+ *\r
+ * This contains stub files for the LUFA board drivers. If the LUFA board drivers are used with board hardware other than those\r
+ * directly supported by the library, the BOARD parameter of the application's makefile can be set to "USER", and these stub files\r
+ * copied to the "/Board/" directory of the application's folder. When fleshed out with working driver code for the custom board,\r
+ * the corresponding LUFA board APIs will work correctly with the non-standard board hardware.\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/**\r
+ * \page Page_Donating Donating to Support This Project\r
+ *\r
+ * \image html Images/Author.jpg "Dean Camera, LUFA Developer"\r
+ *\r
+ * I am a 23 year old Atmel Applications Engineer, living in Trondheim, Norway and working on LUFA in my spare time.\r
+ * The development and support of this library requires much effort from myself, as I am the sole developer, maintainer\r
+ * and supporter. Please consider donating a small amount to support this and my future Open Source projects - All\r
+ * donations are <i>greatly</i> appreciated.\r
+ *\r
+ * Note that commercial entities can remove the attribution portion of the LUFA license by a one-time fee - see\r
+ * \ref Page_LicenseInfo for more details (<b>Note: Please do NOT pay this in advance through the donation link below -\r
+ * contact author for payment details.</b>).\r
+ *\r
+ * \image html "http://www.pledgie.com/campaigns/6927.png?skin_name=chrome"\r
+ * <a href='http://www.lufa-lib.org/donate'>Donate to this project via PayPal</a> - Thanks in Advance!\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_ExportingLibrary Exporting the Library for IDE Use\r
+ *\r
+ * While LUFA was designed to allow for easy compilation in a makefile driven environment,\r
+ * it is possible to export the library into a form suitable for drop-in use inside of an\r
+ * IDE.\r
+ *\r
+ * \section Sec_LibraryExport Exporting the Library\r
+ * An export of the library is at its most basic, a direct copy of the main "LUFA" source folder from the\r
+ * root download folder; this contains the library core which can be re-used within external projects.\r
+ * However, as many IDEs attempt to automatically compile all included source files, it is neccesary to\r
+ * exclude some directories and files from the library core export to allow for easier integration into\r
+ * an IDE project.\r
+ *\r
+ * \subsection SSec_ManualExport Manual Export\r
+ * To manually export the library core, copy over the main LUFA library folder from the LUFA root directory,\r
+ * renaming as desired. Within the library core folder, the following directories should be removed or\r
+ * excluded from your IDE import:\r
+ * - Documentation/\r
+ * - DoxygenPages/\r
+ * - CodeTemplates/\r
+ *\r
+ * If required, files from the CodeTemplates/ subdirectory may be copied to your IDE project as needed.\r
+ *\r
+ * The resulting copy of the library may then be imported into your chosen IDE according to the instructions\r
+ * shown in \ref Sec_LibraryImport.\r
+ *\r
+ * \subsection SSec_AutomaticExport Automatic Export\r
+ * If desired, the steps indicated in \ref SSec_ManualExport may be automatically performed, by running the\r
+ * command <b><code>make export_tar</code></b> from the command line. This will generate two .tar files in the\r
+ * current directory, named <code>LUFA_YYMMDD.tar</code> and <code>LUFA_YYMMDD_Code_Templates.tar</code> (where\r
+ * "YYMMDD" is the version of the library being exported). The first archive contains the exported LUFA core\r
+ * with the non-required files removed, while the second contains an archived copy of the code template files \r
+ * for the current LUFA version.\r
+ *\r
+ * The resulting archived copy of the library may then be extracted to your chosen IDE project source directory\r
+ * and imported according to the instructions shown in \ref Sec_LibraryImport.\r
+ *\r
+ * \section Sec_LibraryImport Importing the Library\r
+ * An exported copy of the library may be imported wholesale into an IDE project, if the instructions detailed\r
+ * in \ref Sec_LibraryExport are followed.\r
+ *\r
+ * Specific instructions for importing an exported version of LUFA into various IDEs are listed below.\r
+ *\r
+ * \subsection SSec_AS56_Import Importing into AVRStudio 5/Atmel Studio 6\r
+ * To import LUFA into a new or existing project, the following steps must be followed.\r
+ *\r
+ * \subsubsection SSSec_AS56_Import_Step1 Copy over the exported library\r
+ * Copy over the exported library archive created via the steps listed in \ref Sec_LibraryExport to your AS5/AS6\r
+ * project directory.\r
+ *\r
+ * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step1.png\r
+ *\r
+ * \subsubsection SSSec_AS56_Import_Step2 Extract exported library\r
+ * Extract out the contents of the archive to a new folder. This may be any name you wish, however keep in mind\r
+ * that this name will need to be referenced within your user application under most circumstances. It is\r
+ * suggested that this folder be named "LUFA", or "LUFA" followed by the version string for easy reference.\r
+ *\r
+ * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step2.png\r
+ *\r
+ * \subsubsection SSSec_AS56_Import_Step3 Add the library files\r
+ * Open your AVRStudio 5/Atmel Studio 6 project. From the "Solution Explorer" pane, click the "Show All Files"\r
+ * button on the toolbar to display ghosted icons of files and folders located in the project source directory\r
+ * that are not currently added to the project.\r
+ *\r
+ * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step3.png\r
+ *\r
+ * Right-click the ghosted version of the extracted LUFA export folder in the Solution Explorer pane, and\r
+ * choose the "Add to Project" option from the context menu. This will add the entire LUFA source tree to the\r
+ * current project.\r
+ *\r
+ * \subsubsection SSSec_AS56_Import_Step4 Open Project Toolchain Properties\r
+ * In the Solution Explorer pane, click the project node, and press the "Properties" button in the toolbar to\r
+ * open the Project Properties window. This window allows you to configure the various project global compiler,\r
+ * assembler and linker options.\r
+ *\r
+ * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step4.png\r
+ * \r
+ * Click the "Toolchain" tab on the left side of the Project Properties window.\r
+ *\r
+ * \subsubsection SSSec_AS56_Import_Step5 Configure Project Toolchain Properties\r
+ *\r
+ * In the GNU C Compiler section, open the "Symbols" page. Click the "Add Item" button to the top-right of the\r
+ * "Defined Symbols" section to add new symbols.\r
+ *\r
+ * At a minimum, you will need to define the following symbols (for more information on these symbols, see\r
+ * \ref Page_ConfiguringApps):\r
+ * - ARCH\r
+ * - F_CPU\r
+ * - F_USB\r
+ * - BOARD\r
+ * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step5_1.png\r
+ *\r
+ * Next, open the GNU C Compiler section's "Optimization" page. Ensure that the option to prepare functions for\r
+ * garbage collection is enabled.\r
+ * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step5_2.png\r
+ *\r
+ * Finally, in the GNU C Linker section, open the "Optimization" page. Ensure that the option to garbage collect\r
+ * unused sections is selected.\r
+ * \image html Images/AS5_AS6_Import/AS5_AS6_Import_Step5_3.png\r
+ */\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+ /** \page Page_FutureChanges Future Changes\r
+ *\r
+ * Below is a list of future changes which are proposed for the LUFA library, but not yet started/complete.\r
+ * This gives an unordered list of future changes which may be available in future releases of the library.\r
+ * If you have an item to add to this list, please contact the library author via email, the LUFA mailing list,\r
+ * or post your suggestion as an enhancement request to the project bug tracker.\r
+ *\r
+ * <b>Targeted for Future Releases:</b>\r
+ * - Code Features\r
+ * -# Add hub support when in Host mode for multiple devices\r
+ * -# Investigate virtual hubs when in device mode instead of composite devices\r
+ * -# Re-add interrupt Pipe/Endpoint support\r
+ * -# Update stream APIs to use DMA transfers on supported architectures\r
+ * -# Pull out third party libraries into a separate folder and reference them as required\r
+ * -# Add a LUFA_YIELD macro for integration into a third-party RTOS\r
+ * -# Abstract out Mass Storage byte send/receive to prevent low level API use in projects\r
+ * -# Fix HID report parser usage support for array types\r
+ * -# Make HOST_DEVICE_SETTLE_DELAY_MS a global variable that can be changed\r
+ * -# Add MANDATORY_EVENT_FUNCTIONS compile time option\r
+ * -# Add watchdog support to the library and apps/bootloaders\r
+ * - Testing/Verification\r
+ * -# Re-run USBIF test suite on all classes to formally verify operation\r
+ * -# Implement automated functional testing of all demos\r
+ * - Documentation/Support\r
+ * -# Add detailed overviews of how each demo works\r
+ * -# Add board overviews\r
+ * -# Write LUFA tutorials\r
+ * - Demos/Projects\r
+ * -# Device/Host USB bridge\r
+ * -# Finish incomplete demos and projects\r
+ * -# Add class driver support for Test and Measurement class\r
+ * -# Add class driver support for EEM class\r
+ * -# Add class driver support for ECM class\r
+ * -# Add class driver generic HID report host demo\r
+ * -# Implement flow control for USB to Serial project\r
+ * - Ports\r
+ * -# Port all demos to multiple architectures\r
+ * -# Finish USB XMEGA port\r
+ * -# Add AVR32 UC3C, UC3D and UC3L support\r
+ * -# Atmel ARM7 series microcontrollers\r
+ * -# Other (commercial) C compilers\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_GettingStarted Getting Started\r
+ *\r
+ * Out of the box, LUFA contains a large number of pre-made class demos for you to test, experiment with and\r
+ * ultimately build upon for your own projects. All the demos (where possible) come pre-configured to build and\r
+ * run correctly on the AT90USB1287 AVR microcontroller, mounted on the Atmel USBKEY board and running at an 8MHz\r
+ * master clock. This is due to two reasons; one, it is the hardware the author possesses, and two, it is the most\r
+ * popular Atmel USB demonstration board to date. To learn how to reconfigure, recompile and program the included\r
+ * LUFA applications using different settings, see the subsections below.\r
+ *\r
+ * Most of the included demos in the /Demos/ folder come in both ClassDriver and LowLevel varieties. If you are new\r
+ * to LUFA, it is highly recommended that you look at the ClassDriver versions first, which use the pre-made USB\r
+ * Class Drivers (\ref Group_USBClassDrivers) to simplify the use of the standard USB classes in user applications.\r
+ *\r
+ * <b>Subsections:</b>\r
+ * \li \subpage Page_ConfiguringApps - How to Configure the Included Demos, Projects and Bootloaders\r
+ * \li \subpage Page_CompilingApps - How to Compile the Included Demos, Projects and Bootloaders\r
+ * \li \subpage Page_ProgrammingApps - How to Program an AVR with the Included Demos, Projects and Bootloaders\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \defgroup Group_BoardDrivers Board Drivers\r
+ *\r
+ * Functions, macros, variables, enums and types related to the control of physical board hardware.\r
+ */\r
+\r
+/** \defgroup Group_PeripheralDrivers On-chip Peripheral Drivers\r
+ *\r
+ * Functions, macros, variables, enums and types related to the control of AVR subsystems.\r
+ */\r
+\r
+/** \defgroup Group_MiscDrivers Miscellaneous Drivers\r
+ *\r
+ * Miscellaneous driver Functions, macros, variables, enums and types.\r
+ */\r
+\r
+/** \defgroup Group_PlatformDrivers_AVR8 AVR8\r
+ * \ingroup Group_PlatformDrivers\r
+ *\r
+ * Drivers relating to the AVR8 architecture platform, such as clock setup and interrupt management.\r
+ */\r
+\r
+/** \defgroup Group_PlatformDrivers_XMEGA XMEGA\r
+ * \ingroup Group_PlatformDrivers\r
+ *\r
+ * Drivers relating to the XMEGA architecture platform, such as clock setup and interrupt management.\r
+ */\r
+\r
+/** \defgroup Group_PlatformDrivers_UC3 UC3\r
+ * \ingroup Group_PlatformDrivers\r
+ *\r
+ * Drivers relating to the UC3 architecture platform, such as clock setup and interrupt management.\r
+ */\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+ /** \page Page_KnownIssues Known Issues\r
+ * The following are known issues present in each official LUFA release. This list should contain all known\r
+ * issues in the library. Most of these issues should be corrected in the future release - see\r
+ * \ref Page_FutureChanges for a list of planned changes in future releases.\r
+ *\r
+ * \section Sec_KnownIssues120730 Version 120730\r
+ * - AVR8 Architecture\r
+ * - No known issues.\r
+ * - UC3 Architecture\r
+ * \warning The UC3 device support is currently <b>experimental</b> (incomplete and/or non-functional), and is included for preview purposes only. \n\r
+ *\r
+ * - No demos, bootloaders or projects have been ported for the UC3 devices in the current release,\r
+ * although the architecture is supported in the LUFA core library.\r
+ * - DMA transfers to and from the USB controller are not yet implemented for this release.\r
+ * - The UC3C, UC3D and UC3L sub-families of UC3 are not currently supported by the library due to their\r
+ * altered USB controller design.\r
+ * - The various \c CreateStream() functions for creating standard \c <stdio.h> compatible virtual file\r
+ * streams are not available on the UC3 architecture, due to a lack of suitable library support.\r
+ * - XMEGA Architecture\r
+ * \warning The XMEGA device support is currently <b>experimental</b> (incomplete and/or non-functional), and is included for preview purposes only.\r
+ *\r
+ * - No demos, bootloaders or projects have been ported for the XMEGA devices in the current release,\r
+ * although the architecture is supported in the LUFA core library.\r
+ * - Endpoints of more than 64 bytes are not currently supported in this release.\r
+ * - Isochronous endpoints are not currently supported in this release. As a result, the audio class\r
+ * cannot be used on XMEGA devices.\r
+ * - Multiple-bank endpoints are not currently supported in this release.\r
+ * - Early revisions of the ATXMEGA128A1U are incompatible with LUFA, due to their various errata\r
+ * relating to the USB controller.\r
+ * - Architecture Independent\r
+ * - The HID parser fails for array type elements that have a MIN and MAX usage applied; each element\r
+ * in the array will receive a unique incrementing usage from the MIN value, up to MAX.\r
+ * - The LUFA library is not watchdog aware, and thus timeouts are possible if short periods are used\r
+ * and a lengthy USB operation is initiated.\r
+ * - Build System\r
+ * - No known issues.\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_LUFAPoweredProjects User Projects Powered by LUFA\r
+ *\r
+ * LUFA is currently in use all around the world, in many applications both commercial and non-commercial. Below is a\r
+ * list of known public LUFA powered projects, which all use the LUFA library in some way. Feel free to visit each project's\r
+ * home page for more information on each project.\r
+ *\r
+ * If you have a project that you would like to add to this list, please contact me via the details on the main page of this\r
+ * documentation.\r
+ *\r
+ * \section Sec_BoardsUsingLUFA AVR-USB Development Boards Using LUFA\r
+ *\r
+ * The following is a list of known AVR USB development boards, which recommend using LUFA for the USB stack. Some of these\r
+ * are open design, and all are available for purchase as completed development boards suitable for project development.\r
+ *\r
+ * \li AVR-USB-162, a USBKEY-like development board for the AT90USB162: http://olimex.com/dev/avr-usb-162.html\r
+ * \li Benito #7, a no-frills USB board: http://www.dorkbotpdx.org/wiki/benito\r
+ * \li Duce, the sucessor to the Benito #7: http://dorkbotpdx.org/wiki/duce\r
+ * \li JM-DB-U2, an ATMEGA32U2 development board: http://u2.mattair.net/index.html\r
+ * \li Micropendous, an open design/source set of AVR USB development boards: http://micropendous.org/\r
+ * \li Microsin AVR-USB162 breakout board, a DIY AT90USB162 development board: http://microsin.ru/content/view/685/44/\r
+ * \li Minimus USB, a board specially designed for PSGroove: http://www.minimususb.com/\r
+ * \li Nanduino, a do-it-yourself AT90USB162 board: http://www.makestuff.eu/wordpress/?page_id=569\r
+ * \li Sparkfun ATMEGA8U2 breakout board: http://www.sparkfun.com/products/10277\r
+ * \li Teensy and Teensy++, two other AVR USB development boards: http://www.pjrc.com/teensy/index.html\r
+ * \li U2DIL/U4DIL, a set of DIP layout USB AVR boards: http://www.reworld.eu/re/en/products/u2dil/\r
+ * \li USB2AX, a tiny USB to serial converter board: http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX\r
+ * \li USBFOO 2, AT90USB162 based development board: http://shop.kernelconcepts.de/product_info.php?products_id=102\r
+ *\r
+ * \section Sec_LUFAProjects Projects Using LUFA (Hobbyist)\r
+ *\r
+ * The following are known hobbyist projects using LUFA. Most are open source, and show off interesting ways that the LUFA library\r
+ * can be incorporated into many different applications.\r
+ *\r
+ * \li Accelerometer Game Joystick: http://www.crictor.co.il/he/episodes/joystick/\r
+ * \li Arcade Controller: http://fletchtronics.net/arcade-controller-made-petunia\r
+ * \li Arcade Joystick: http://jamie.lentin.co.uk/embedded/arcade-joystick/\r
+ * \li AttoBasic AVR BASIC interpreter: http://www.cappels.org/dproj/AttoBasic2_1/AttoBasic_2.1_with_USB_and_Arduino_support.html\r
+ * \li AVR USB Modem, a 3G Wireless Modem host: http://code.google.com/p/avrusbmodem/\r
+ * \li Bicycle POV: http://www.code.google.com/p/bicycleledpov/\r
+ * \li Bluetooth Explorerbot: http://code.google.com/p/bluetooth-explorerbot/\r
+ * \li Bus Ninja, an AVR clone of the popular BusPirate project: http://blog.hodgepig.org/busninja/\r
+ * \li CAMTRIG, a remote Camera Trigger device: http://code.astraw.com/projects/motmot/camtrig\r
+ * \li CD Driver Emulator Dongle for ISO Files: http://cdemu.blogspot.com/\r
+ * \li ClockTamer, a configurable clock generator: http://code.google.com/p/clock-tamer/\r
+ * \li Collection of alternative Arduino Uno firmwares: http://hunt.net.nz/users/darran/\r
+ * \li Computer controlled LED matrix (Russian): http://we.easyelectronics.ru/AVR/nebolshoy-primer-s-lufa-hidapi.html\r
+ * \li CULFW, a 868MHz RF packet encoder/decoder: http://www.koeniglich.de/culfw/culfw.html\r
+ * \li Dashkey, a custom PC keyboard controller: http://geekhack.org/showwiki.php?title=Island:19096\r
+ * \li DIY PS3 controller emulator: https://code.google.com/p/diyps3controller/\r
+ * \li EMuSer, a USB-RS422 adapter for E-Mu samplers: http://www.emxp.net/EMuSer.htm\r
+ * \li Estick JTAG, an ARM JTAG debugger: http://code.google.com/p/estick-jtag/\r
+ * \li "Fingerlicking Wingdinger" (WARNING: Bad language if no Javascript), a MIDI controller: http://noisybox.net/electronics/wingdinger/\r
+ * \li Flyatar, a real-time fly tracking system: https://github.com/peterpolidoro/Flyatar\r
+ * \li FootJoy, a 22 button, 6-axis josystick with keyboard and mouse modes: https://bitbucket.org/sirbrialliance/foot-joy/\r
+ * \li Gamecube controller to USB adapter: https://www.facebook.com/media/set/?set=a.10150202447076304.310536.688776303&l=df53851c50 \r
+ * \li Garmin GPS USB to NMEA standard serial sentence translator: http://github.com/nall/garmin-transmogrifier/tree/master\r
+ * \li Generic HID Device Creator: http://generichid.sourceforge.net/\r
+ * \li Generic HID Open Source Framework: http://www.waitingforfriday.com/index.php/USB_Generic_HID_Open_Source_Framework_for_Atmel_AVR_and_Windows\r
+ * \li Ghetto Drum, a MIDI drum controller: http://noisybox.net/art/gdrum/\r
+ * \li GPS enabled lap timer for vehicles: http://www.assembla.com/code/ironlung/subversion/nodes/trunk/LapTimer\r
+ * \li Hardware Volume Control: https://github.com/davidk/hw-volume-control\r
+ * \li Hiduino, a USB-MIDI replacement firmware for the Arduino Uno: http://code.google.com/p/hiduino/\r
+ * \li Ikea RGB LED USB modification: http://slashhome.se/p/projects/id/ikea_dioder_usb/#project\r
+ * \li IR Remote to Keyboard decoder: http://netzhansa.blogspot.com/2010/04/our-living-room-hi-fi-setup-needs-mp3.html\r
+ * \li Jukebox panic button: http://thinkl33t.co.uk/the-panic-button\r
+ * \li LED Panel controller: http://projects.peterpolidoro.net/caltech/panelscontroller/panelscontroller.htm\r
+ * \li Linux Secure Storage Dongle: http://github.com/TomMD/teensy\r
+ * \li LUFA powered DDR dance mat (French): http://logicien-parfait.fr/dokuwiki/doku.php?id=projet:ddr_repair\r
+ * \li MakeTV Episode Dispenser: http://www.youtube.com/watch?v=BkWUi18hl3g\r
+ * \li MidiMonster, a USB-to-MIDI gateway board: http://www.dorkbotpdx.org/wiki/midimonster\r
+ * \li MIDI Theremin: http://baldwisdom.com/usb-midi-controller-theremin-style-on-arduino-uno/\r
+ * \li MIDI interface hack of a toy Guitar: http://blog.x37v.info/2011/06/26/toy-guitar-hacked-midi-conroller\r
+ * \li MiniBloq, a graphical Ardunio programming environment : http://minibloq.org/\r
+ * \li MiXley, a port of the Teacup 3D printer firmware for the USB AVRs: http://codaset.com/michielh/mixley\r
+ * \li Mobo 4.3, a USB controlled all band (160-10m) HF SDR transceiver: http://sites.google.com/site/lofturj/mobo4_3\r
+ * \li Moco, a native Arduino Uno MIDI replacement firmware: http://web.mac.com/kuwatay/morecat_lab./MocoLUFA.html\r
+ * \li Motherboard BIOS flasher: http://www.coreboot.org/InSystemFlasher\r
+ * \li Multi-button Joystick (French): http://logicien-parfait.fr/dokuwiki/doku.php?id=projet:joystick\r
+ * \li Music Playing Alarm Clock (Tutorial): http://www.instructables.com/id/Music-Playing-Alarm-Clock/\r
+ * \li Nehebkau, Laptop Controlled Keyboard and Mouse: http://www.frank-zhao.com/cache/nehebkau.php\r
+ * \li NeroJTAG, a JTAG dongle: https://github.com/makestuff/neroJtag\r
+ * \li NES Controller USB modification: http://projects.peterpolidoro.net/video/NESUSB.htm\r
+ * \li Nikon wireless camera remote control (Norwegian): http://hekta.org/~hpe1119/\r
+ * \li Opendous-JTAG, an open source ARM JTAG debugger: http://code.google.com/p/opendous-jtag/\r
+ * \li Openkubus, an open source hardware-based authentication dongle: http://code.google.com/p/openkubus/\r
+ * \li Orbee, a USB connected RGB Orb for notifications: http://www.franksworkshop.com.au/Electronics/Orbee/Orbee.htm\r
+ * \li PPM signal generator over USB: https://github.com/G33KatWork/USBPPM\r
+ * \li Programmable keyboard controller: http://41j.com/blog/2011/10/a-programmable-keyboard-controller/\r
+ * \li Programmable XBOX controller: http://richard-burke.dyndns.org/wordpress/pan-galactic-gargantuan-gargle-brain-aka-xbox-360-usb-controller/\r
+ * \li PSGroove, a Playstation 3 Homebrew dongle: http://github.com/psgroove\r
+ * \li PS/2 to USB adapter: https://github.com/makestuff/p2ukbd\r
+ * \li Reprap with LUFA, a LUFA powered 3D printer: http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse/\r
+ * \li RFPirate, a RF experimentation platform: https://github.com/ebuller/RF-Pirate\r
+ * \li RF Transciever using the MRF49XA: http://alternet.us.com/?page_id=1494\r
+ * \li SD Card reader: http://elasticsheep.com/2010/04/teensy2-usb-mass-storage-with-an-sd-card/\r
+ * \li SDR1, a Software Defined Radio firmware: https://code.google.com/p/sdr-mk1/\r
+ * \li SEGA Megadrive/Genesis Development Cartridge: http://www.makestuff.eu/wordpress/?page_id=398\r
+ * \li Serial Line bus analyser: http://www.pjrc.com/teensy/projects/SerialAnalyzer.html\r
+ * \li SNES custom FLASH ROM: http://electrifiedfoolingmachine.co/?page_id=633\r
+ * \li Smartcard Detective: https://code.google.com/p/smartcarddetective/\r
+ * \li SmartportVHD Apple II Mass Storage adapter: http://pcedric3.free.fr/SmartportVHD/\r
+ * \li Single LED Matrix Display: http://guysoft.wordpress.com/2009/10/08/bumble-b/\r
+ * \li Simple USB LED Controller: https://github.com/scottbez1/sulc\r
+ * \li Stripe Snoop, a Magnetic Card reader: http://www.ossguy.com/ss_usb/\r
+ * \li Stylophone, with USB MIDI connectivity: http://www.waitingforfriday.com/index.php/Stylophone_Studio_5\r
+ * \li Teensy SD Card .WAV file player: http://elasticsheep.com/2010/04/teensy2-usb-wav-player-part-1/\r
+ * \li Touchscreen Input Device: http://capnstech.blogspot.com/2010/07/touchscreen-update.html\r
+ * \li UDFS, a BBC Micro USB disk filing system: https://github.com/makestuff/udfs\r
+ * \li Universal USB AVR Module: http://usbavr.bplaced.net/\r
+ * \li USB2AX, a USB to Dynamixel network adapter: http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX\r
+ * \li USB Infrared Receiver/Transmitter: http://vaton4.web2001.cz/\r
+ * \li USB Interface for Playstation Portable Devices: http://forums.ps2dev.org/viewtopic.php?t=11001\r
+ * \li USB MIDI to DMX controller: http://github.com/hanshuebner/miDiMX\r
+ * \li USB powered Geiger Counter: http://uhrheber.wordpress.com/2011/04/28/a-usb-powered-geiger-counter-for-the-z2-and-other-computers/\r
+ * \li Userial, a USB to Serial converter with SPI, I2C and other protocols: http://www.tty1.net/userial/\r
+ * \li Wireless MIDI Guitar system: http://www.ise.pw.edu.pl/~wzab/wireless_guitar_system/\r
+ * \li Xnormidi, a C MIDI library: http://x37v.info/projects/xnormidi\r
+ * \li XUM1541, a Commodore 64 floppy drive to USB adapter: http://www.root.org/~nate/c64/xum1541/\r
+ * \li Zeus, a touch screen computer for music manipulation: http://www.benbengler.com/developments_zeus.html\r
+ *\r
+ * \section Sec_LUFACommercialProjects Projects Using LUFA (Commercial)\r
+ *\r
+ * The following is a list of known commercial products using LUFA. Some of these are open source, although many are "black-box"\r
+ * solutions with no source code given. Those companies which have purchased a Commercial License to LUFA (see \ref Page_LicenseInfo)\r
+ * are not listed here unless specifically requested.\r
+ *\r
+ * \li Arduino Uno, the official Arduino board: http://www.arduino.cc\r
+ * \li ARPS Locator: http://la3t.hamradio.no/lab//?id=tracker_en\r
+ * \li AsTeRICS assistive technologies project, HID actuator: http://www.asterics.eu\r
+ * \li Ceberus, a MadCatz Xbox 360 arcade stick modifier: http://www.phreakmods.com/products/cerberus\r
+ * \li CFFA3000, a CompactFlash interface for the Apple II: http://www.dreher.net/CFforAppleII\r
+ * \li Digital Survey Instruments Magnetometer and Pointer: http://www.digitalsurveyinstruments.com/\r
+ * \li FinchRobot, a robot designed for educational use: http://www.finchrobot.com/\r
+ * \li HummingBird Kit, a robotics learning platform: http://www.hummingbirdkit.com/\r
+ * \li Penguino, an Arduino Board With On-Board LUFA Powered Debugger/Programmer: http://wiki.icy.com.au/PenguinoAVR\r
+ * \li PIR-1, an IR control interface for consumer electronics: http://www.promixis.com/pir-1.php\r
+ * \li PIR-4, a USB Connected 4 port IR transmitter: http://promixis.com/pir-4.php\r
+ * \li KeyGlove, an alternative input system: http://www.keyglove.net/\r
+ * \li Many of Busware's Products: http://www.busware.de/\r
+ * \li MIDIFighter, a USB-MIDI controller: http://www.midifighter.com/\r
+ * \li Norduino, a wireless Arduino: http://norduino.robomotic.com/norduino-is-now-usb-hid/\r
+ * \li Olimex AVR-ISP-MK2, an AVRISP-MKII Clone AVR Programmer: https://www.olimex.com/dev/avr-isp-mk2.html\r
+ * \li Retrode, a USB Games Console Cartridge Reader: http://www.retrode.org\r
+ * \li RFI21.1EU UHF RFID reader: http://www.metra.cz/rfid/uhf-rfid-ctecky/rfi21-1eu-uhf-rfid-ctecka.htm\r
+ * \li SmartCardDetective, a Smart Card analysis tool: http://www.smartcarddetective.com/\r
+ * \li USBTINY-MKII, an AVRISP-MKII Clone AVR Programmer: http://tom-itx.dyndns.org:81/~webpage/boards/USBTiny_Mkii/USBTiny_Mkii_index.php\r
+ * \li UDS18B20 USB Temperature sensor: http://toughlog.org/uds18b20/\r
+ * \li VMeter, a USB MIDI touch strip controller: http://www.vmeter.net/\r
+ * \li XMEGA Development Board, using LUFA as an On-Board Programmer: http://xmega.mattair.net/\r
+ * \li Zeptoprog, a multifunction AVR programmer: http://www.mattairtech.com/index.php/featured/zeptoprog.html\r
+ *\r
+ * \section Sec_LUFAPublications Publications Mentioning LUFA\r
+ * The following are published magazines which have either mentioned or featured the LUFA library.\r
+ *\r
+ * \li Elektor Magazine, "My First AVR-USB" by Antoine Authier (feature), January 2010 Issue\r
+ * \li Elektor Magazine, "USB is Cool/Sucks" by Jerry Jacobs and Chris Vossen (minor mention), January 2010 Issue\r
+ * \li Elektor Magazine, "20 x Open Source" by Jens Nickel, March 2010 Issue\r
+ * \li Circuit Cellar Magazine, "Advanced USB Design Debugging" by Collin O'Flynn, August 2010 Issue\r
+ *\r
+ * \section Sec_LUFANotableMentions Other Notable Mentions of LUFA\r
+ * The following are non-magazine but notable mentions of the LUFA library.\r
+ *\r
+ * \li Adafruit "Ask an Engineer", 7th November 2010\r
+ * \li Arduino 2010 Keynote speech\r
+ * \li The Amp Hour podcast blog #11\r
+ * \li Blackhat 2011 conference, "Exploiting USB Devices with Arduino"\r
+ *\r
+ * \section Sec_PortsAndForks Non-Official LUFA Ports and Forks\r
+ * The following are unofficial forks of the LUFA codebase, which implement different features such as support for\r
+ * additional architectures.\r
+ *\r
+ * \li NXP's official "nxpusblib" LUFA fork, for LPC devices: http://www.lpcware.com/content/project/nxpusblib\r
+ * \li Kevin Mehall's LUFA port to the NXP LPC13xx: https://github.com/kevinmehall/LUFA-LPC13xx\r
+ *\r
+ */\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/**\r
+ * \page Page_Resources Library Resources\r
+ *\r
+ * \section Sec_UnofficialResources Unofficial Resources\r
+ * Unofficial Russian LUFA documentation translation: http://microsin.ru/Download.cnt/doc/LUFA/ \n\r
+ * Tutorial for LUFA USB Control Transfers: http://www.avrbeginners.net/new/tutorials/usb-control-transfers-with-lufa/\r
+ *\r
+ * \section Sec_ProjectPages LUFA Related Webpages\r
+ * Project Homepage: http://www.lufa-lib.org \n\r
+ * Commercial Licenses: http://www.lufa-lib.org/license \n\r
+ * Author's Website: http://www.fourwalledcubicle.com \n\r
+ * Development Blog: http://www.fourwalledcubicle.com/blog \n\r
+ *\r
+ * \section Sec_ProjectHelp Assistance With LUFA\r
+ * Support Mailing List: http://www.lufa-lib.org/support \n\r
+ * Author's Email: dean [at] fourwalledcubicle [dot] com \n\r
+ *\r
+ * \section Sec_InDevelopment Latest In-Development Source Code\r
+ * Issue Tracker: http://www.lufa-lib.org/tracker \n\r
+ * Public SVN Repository: http://www.lufa-lib.org/svn \n\r
+ * Public GIT Repository: http://www.lufa-lib.org/git \n\r
+ * Latest Repository Source Archive: http://www.lufa-lib.org/latest-archive \n\r
+ * Commit RSS Feed: http://www.lufa-lib.org/rss \n\r
+ *\r
+ * \section Sec_USBResources USB Resources\r
+ * USB-IF Website: http://www.usb.org \n\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/**\r
+ * \page Page_LicenseInfo Source Code License\r
+ *\r
+ * The LUFA library is currently released under the MIT license, included below.\r
+ *\r
+ * Commercial entities can opt out of the public disclosure clause in this license\r
+ * for a one-time US$1500 payment. This provides a non-exclusive modified MIT licensed which\r
+ * allows for the free use of the LUFA library, bootloaders and (where the sole copyright\r
+ * is attributed to Dean Camera) demos without public disclosure within an organization, in\r
+ * addition to three free hours of consultation with the library author, and priority support.\r
+ * Please visit the Commercial License link on \ref Page_Resources for more information on\r
+ * ordering a commercial license for your company.\r
+ *\r
+ * \verbinclude License.txt\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/**\r
+ * \mainpage\r
+ *\r
+ * \image html Images/LUFA.png\r
+ * <div align="center"><small><i>Logo design by <a href="http://www.studiomonsoon.com">Studio Monsoon Photography</a></i></small></div>\r
+ * \n\r
+ * <div align="center"><a href="http://www.lufa-lib.org">http://www.lufa-lib.org</a></div>\r
+ * \n\r
+ *\r
+ * <b>LUFA is donationware. For author and donation information, see \ref Page_Donating.</b>\r
+ *\r
+ * LUFA is an open-source USB library for the USB-enabled AVR microcontrollers, released under the MIT license (see \ref Page_LicenseInfo).\r
+ * It supports a large number of USB AVR models and boards (see \ref Page_DeviceSupport). It is designed to provide an easy to use,\r
+ * feature rich framework for the development of USB peripherals and hosts.\r
+ *\r
+ * LUFA focuses on the microcontroller side of USB development only; it includes no PC host USB driver development facilities - other projects\r
+ * such as the Windows Driver Development Kit, Windows USB Device Mode Framework and libusb may be of interest for developing custom OS drivers.\r
+ * While custom USB devices can be made with LUFA using such tools, the included demos all use the inbuilt OS drivers for each USB class for\r
+ * simplicity.\r
+ *\r
+ * The library is currently in a stable release, suitable for download and incorporation into user projects for\r
+ * both host and device modes. For information about the project progression, see the blog link at \ref Page_Resources.\r
+ *\r
+ * LUFA is written specifically for the free AVR-GCC compiler, and uses several GCC-only extensions to make the\r
+ * library API more streamlined and robust. You can download AVR-GCC for free in a convenient windows package,\r
+ * from the the WinAVR website (see \ref Page_Resources).\r
+ *\r
+ * The only required AVR peripherals for LUFA is the USB controller itself and interrupts - LUFA does not require the use of the\r
+ * microcontroller's timers or other hardware, leaving more hardware to the application developer.\r
+ *\r
+ * Accompanying LUFA in the download package is a set of example demo applications, plus several Bootloaders of different classes\r
+ * and open source LUFA powered projects.\r
+ *\r
+ * <b>Subsections:</b>\r
+ * \li \subpage Page_LicenseInfo - Project source license and commercial use information\r
+ * \li \subpage Page_Donating - Donating to support this project\r
+ * \li \subpage Page_DeviceSupport - Current Device and Hardware Support\r
+ * \li \subpage Page_ChangeLog - Project Changelog\r
+ * \li \subpage Page_KnownIssues - Known Issues\r
+ * \li \subpage Page_FutureChanges - Planned Changes to the Library\r
+ * \li \subpage Page_GettingStarted - Getting started with LUFA\r
+ * \li \subpage Page_DevelopingWithLUFA - Developing with LUFA\r
+ * \li \subpage Page_LUFAPoweredProjects - Other Projects Using LUFA\r
+ * \li \subpage Page_Resources - LUFA and USB Related Resources\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_Migration Migrating from Older Versions\r
+ *\r
+ * Below is migration information for updating existing projects based on previous versions of the LUFA library\r
+ * to the next version released. It does not indicate all new additions to the library in each version change, only\r
+ * areas relevant to making older projects compatible with the API changes of each new release.\r
+ *\r
+ * \section Sec_Migration120730 Migrating from 120219 to 120730\r
+ * <b>Device Mode</b>\r
+ * - The device mode Audio Class driver now requires an additional configuration parameter, the Audio Control interface index. Existing applications should\r
+ * be adjusted to specify the additional configuration parameter.\r
+ * - The HID_DESCRIPTOR_JOYSTICK() macro no longer takes a variable number of axis as a parameter, due to OS incompatibilities; this macro now uses a fixed\r
+ * 3 axis of data. User applications should update their calls to this macro and their report structures to suit a fixed 3-axis joystick report. If a user\r
+ * application requires more than 3 axis' of data, a custom report descriptor will need to be constructed by hand.\r
+ * - The \ref Endpoint_ConfigureEndpoint() function no longer takes in masks for the banks and direction; the number of banks is now an integer argument, and\r
+ * the direction is obtained from the full endpoint address within the device. Applications calling Endpoint_ConfigureEndpoint() should update their API\r
+ * call to use a full endpoint address (including ENDPOINT_DIR_IN or ENDPOINT_DIR_OUT direction in the MSB of the endpoint address) and an integer number\r
+ * of banks.\r
+ * - All endpoint functions now operate on full endpoint addresses within the device, rather than a directionless endpoint index. Applications should update\r
+ * their API calls to use full endpoint addresses when required within the device.\r
+ * - All device mode class drivers have been updated to use a new unified endpoint description structure for all endpoints; existing applications will need\r
+ * to update their class driver struct instantiation to match the new scheme (see \ref USB_Endpoint_Table_t).\r
+ * - The \c ENDPOINT_BANKS_SUPPORTED() and \c ENDPOINT_MAX_ENDPOINT_SIZE() macros have been removed, as these do not function correctly with the new addressing\r
+ * scheme for the endpoint APIs. Please refer to the target device's datasheet for the maximum bank size of each endpoint.\r
+ * - The MIDI class driver \ref MIDI_EventPacket_t event packet no longer contains seperate \c CableIndex and \c Command entries; these have been combined\r
+ * into a single \c Event element which can be contructed using the new macro \ref MIDI_EVENT(). Existing applications should use the new macro and structure\r
+ * element name.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The Android Accessory Host class driver property strings are now a array of \c char* rather than a struct of named pointers. Existing applications\r
+ * should use C99 Designated Initializers with the property string indexes located in \ref AOA_Strings_t instead.\r
+ * - The \ref Pipe_ConfigurePipe() function no longer takes in masks for the banks and token; the number of banks is now an integer argument, and the token\r
+ * is now inferred from the full pipe address within the device, and the pipe type. Applications calling Pipe_ConfigurePipe() should update their API\r
+ * call to use a full pipe address (including PIPE_DIR_IN or PIPE_DIR_OUT direction in the MSB of the pipe address) and an integer number of banks.\r
+ * - All pipe functions now operate on full pipe addresses within the device, rather than a directionless pipe index. Applications should update their API\r
+ * calls to use full pipe addresses when required within the device.\r
+ * - All host mode class drivers have been updated to use a new unified pipe description structure for all pipes; existing applications will need to update\r
+ * their class driver struct instantiation to match the new scheme (see \ref USB_Pipe_Table_t).\r
+ * - The MIDI class driver \ref MIDI_EventPacket_t event packet no longer contains seperate \c CableIndex and \c Command entries; these have been combined\r
+ * into a single \c Event element which can be contructed using the new macro \ref MIDI_EVENT(). Existing applications should use the new macro and structure\r
+ * element name.\r
+ * - The library "LUFA/Drivers/USB/Core/ConfigDescriptor.c" source file has been renamed "LUFA/Drivers/USB/Core/ConfigDescriptors.c" as this was clashing with\r
+ * files in some low level host mode demo applications, preventing parallel project builds. If you are referencing the project source files directly instead\r
+ * of using the makefile module names, you will need to adjust your project makefile.\r
+ *\r
+ * \section Sec_Migration120219 Migrating from 111009 to 120219\r
+ * <b>USB Core</b>\r
+ * - The HID_KEYBOARD_MODIFER_* macros in the HID class driver have been corrected to HID_KEYBOARD_MODIFIER_* (note the spelling of "modifier").\r
+ * Existing applications should switch over to the correctly spelled macro names.\r
+ * - The names of the USB Device and USB Host class driver files have changed; a new "ClassDevice" and "ClassHost" postfix has been added to the\r
+ * respective class driver files. Projects referencing the class driver source files by filename rather than the LUFA_SRC_USBCLASS makefile\r
+ * variable should append these postfixes to the source file names. Projects including the USB class driver dispatch headers directly should either\r
+ * switch to including the main USB driver header instead, or use the updated header filenames.\r
+ * - The USB_CONFIG_ATTR_BUSPOWERED constant has been renamed to USB_CONFIG_ATTR_RESERVED, as this was misnamed. All devices must set this bit in\r
+ * the Configuration descriptor's attributes field. As all devices are assumed to be bus-powered unless stated otherwise with the\r
+ * USB_CONFIG_ATTR_SELFPOWERED flag a replacement constant for bus powered devices is not provided.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The device mode Audio class driver now requires a new user application callback, \ref CALLBACK_Audio_Device_GetSetInterfaceProperty().\r
+ * Existing applications must implement this new callback, however if no audio entities are defined in the audio device's descriptors,\r
+ * this function may be hard-coded to always return false for previous behaviour to be retained.\r
+ *\r
+ * \section Sec_Migration111009 Migrating from 110528 to 111009\r
+ * <b>Non-USB Library Components</b>\r
+ * - The \c JTAG_DEBUG_ASSERT() macro has been renamed \ref JTAG_ASSERT() to be consistent with \ref STDOUT_ASSERT().\r
+ *\r
+ * <b>USB Core</b>\r
+ * - By default, unordered Endpoint and Pipe configuration is now allowed once again, via the previous workaround of\r
+ * reconfiguring all Endpoints/Pipes in order each time a new Endpoint/Pipe is created. To minimize the compiled program\r
+ * size, the new \c ORDERED_EP_CONFIG compile time option may be defined in the project makefile to restrict the ordering\r
+ * in exchange for a smaller compiled binary size.\r
+ * - The previous \c F_CLOCK symbol, required in the project makefile, has been renamed to \c F_USB. This is due to the previous name\r
+ * being far too generic for use in future architecture ports, where multiple clock domains are used.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The Endpoint stream functions now all require a \c BytesProcessed parameter instead of the previous callback parameter.\r
+ * This should be set to \c NULL to retain previous behaviour of the functions, or point to a location where the number of bytes\r
+ * processed in the current transaction can be stored. If the \c BytesProcessed parameter is non \c NULL, each time the endpoint\r
+ * bank becomes full and the packet is sent, the routine will exit with the new \ref ENDPOINT_RWSTREAM_IncompleteTransfer\r
+ * error code to allow the user application to determine when to send the next chunk of data.\r
+ * - The \ref CDC_Device_SendString() function now expects a null terminated string instead of an explicit length. Existing code\r
+ * should use the new \ref CDC_Device_SendData() function, or remove the length parameter from the function call.\r
+ * - The \c Endpoint_ResetFIFO() function has been renamed to \ref Endpoint_ResetEndpoint(), to make the API function names more\r
+ * consistent. Existing applications using the old function name should simply replace it with a call to the new function name.\r
+ * - The \c Endpoint_*_Byte() functions have been renamed Endpoint_*_8() to ensure they are correct across all architectures. Existing\r
+ * code using these functions should replace the previous function names with the new function names.\r
+ * - The \c Endpoint_*_Word() functions have been renamed Endpoint_*_16() to ensure they are correct across all architectures. Existing\r
+ * code using these functions should replace the previous function names with the new function names.\r
+ * - The \c Endpoint_*_DWord() functions have been renamed Endpoint_*_32() to ensure they are correct across all architectures. Existing\r
+ * code using these functions should replace the previous function names with the new function names.\r
+ * - The Device mode RNDIS class driver no longer stores the incoming and outgoing packets in the class driver instance; the user is\r
+ * now expected to manually define a storage location for the packet data. Packets must now be sent and received manually via a call\r
+ * to \ref RNDIS_Device_ReadPacket() and/or \ref RNDIS_Device_SendPacket().\r
+ * - The definition of the Audio class \ref USB_Audio_Descriptor_Format_t has been altered, to remove the fixed singular\r
+ * audio sample rate in the descriptor definition, and to rename the \c SampleFrequencyType to the more appropriate\r
+ * \c TotalDiscreteSampleRates. Existing applications will need to add an array of \ref USB_Audio_SampleFreq_t elements\r
+ * immediately following any \ref USB_Audio_Descriptor_Format_t descriptors, and insert the appropriate sampling rates\r
+ * supported by the device, as well as rename the descriptor elements to match the updated element names.\r
+ * - The device mode Audio class driver now requires a new user application callback, \ref CALLBACK_Audio_Device_GetSetEndpointProperty().\r
+ * Existing applications must implement this new callback, however if multiple sample rates or pitch control is not used,\r
+ * this function may be hard-coded to always return false for previous behaviour to be retained.\r
+ * - The \c USB_ConfigurationNumber, \c USB_RemoteWakeupEnabled and \c USB_CurrentlySelfPowered globals have been renamed to\r
+ * \ref USB_Device_ConfigurationNumber, \ref USB_Device_RemoteWakeupEnabled and \ref USB_Device_CurrentlySelfPowered to clearly indicate\r
+ * the USB mode they relate to. Existing applications using these variables should rename all references to the previous names.\r
+ * - The \c ENDPOINT_DESCRIPTOR_DIR_IN and \c ENDPOINT_DESCRIPTOR_DIR_OUT macros have now been replaced by \ref ENDPOINT_DIR_IN and\r
+ * \ref ENDPOINT_DIR_OUT to improve code clarity.\r
+ * - The \ref HID_DESCRIPTOR_JOYSTICK() macro now takes an additional (first) parameter indicating the number of axis in the joystick.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The Pipe stream functions now all require a \c BytesProcessed parameter instead of the previous callback parameter.\r
+ * This should be set to \c NULL to retain previous behaviour of the functions, or point to a location where the number of bytes\r
+ * processed in the current transaction can be stored. If the BytesProcessed parameter is non \c NULL, each time the pipe\r
+ * bank becomes full and the packet is sent, the routine will exit with the new \ref PIPE_RWSTREAM_IncompleteTransfer\r
+ * error code to allow the user application to determine when to send the next chunk of data.\r
+ * - The \ref PRNT_Host_SendString() and \ref CDC_Host_SendString() functions now expect a null terminated string instead of an explicit\r
+ * length. Existing code should use the new \ref PRNT_Host_SendData() and \ref CDC_Host_SendData() functions, or remove the\r
+ * length parameter from the function call.\r
+ * - The \c Pipe_ClearErrorFlags() function has been removed, as the pipe error flags are now automatically cleared when the\r
+ * \ref Pipe_ClearError() function is called.\r
+ * - The \c Pipe_*_Byte() functions have been renamed Pipe_*_8() to ensure they are correct across all architectures. Existing code using\r
+ * these functions should replace the previous function names with the new function names.\r
+ * - The \c Pipe_*_Word() functions have been renamed Pipe_*_16() to ensure they are correct across all architectures. Existing code using\r
+ * these functions should replace the previous function names with the new function names.\r
+ * - The \c Pipe_*_DWord() functions have been renamed Pipe_*_32() to ensure they are correct across all architectures. Existing code using\r
+ * these functions should replace the previous function names with the new function names.\r
+ * - The \c USB_Host_ClearPipeStall() function has been renamed to USB_Host_ClearEndpointStall(), as it operates on a full endpoing address\r
+ * within the attached device and not a pipe within the host. Existing code using the old function name should update the function calls and\r
+ * check for correct usage.\r
+ *\r
+ * \section Sec_Migration101122 Migrating from 100807 to 101122\r
+ * <b>USB Core</b>\r
+ * - A new USB driver source file, \c Drivers/USB/HighLevel/EndpointStream.c now exists. This source file should be added\r
+ * to all project makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source\r
+ * variables.\r
+ * - A new USB driver source file, \c Drivers/USB/HighLevel/PipeStream.c now exists. This source file should be added to all\r
+ * project makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source variables.\r
+ * - The \c EVENT_USB_InitFailure() event has been removed, as the \ref USB_Init() function will no longer fail; if not USB mode is\r
+ * specified, the controller will default to UID selection mode.\r
+ * - The USB mode specifier constants have been moved into a new enum and renamed. Existing projects should use the equivalent\r
+ * value in the new \ref USB_Modes_t enum.\r
+ * - All class driver headers are now included as part of the standard \c LUFA/Drivers/USB/USB.h master dispatch header, and should\r
+ * no longer be included separately. Class driver module source files must still be added as a separate module in the project's\r
+ * makefile if used.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - Endpoints MUST be allocated in ascending order to ensure that bank corruption does not occur. Ensure that your user application\r
+ * allocated endpoints in ascending order - or if your application uses the USB device mode class drivers, ensure that each instance's\r
+ * endpoint indexes are not overlapped with other interface's endpoints.\r
+ * - The signature for the \ref CALLBACK_USB_GetDescriptor() callback has changed, the \c void** \c const \c DescriptorAddress parameter is\r
+ * now \c const \c void** \c const \c DescriptorAddress. Existing applications should update their callback signatures to match this, and\r
+ * eliminate any casting of descriptor pointers to a non \c const pointer.\r
+ * - The names of the class specific descriptor type defines in the USB Class drivers have changed - refer to the driver documentation\r
+ * for each class driver for the new class specific descriptor type names.\r
+ * - The \c ENDPOINT_DOUBLEBANK_SUPPORTED() macro is has been renamed \c ENDPOINT_BANKS_SUPPORTED() and now returns the total number of\r
+ * banks supported by the given endpoint. Existing code should switch to the new naming scheme, and test that the return value of the\r
+ * macro is equal to or greater than 2 to regain the previous functionality.\r
+ * - The \c EVENT_USB_Device_UnhandledControlRequest() event is now named \ref EVENT_USB_Device_ControlRequest() and fires before (not after)\r
+ * the internal library event handlers. Existing code should rename the event handlers in the user application to match the new event\r
+ * name, and should ensure that the new execution order does not affect the application's operation.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - Pipes MUST be allocated in ascending order to ensure that bank corruption does not occur. Ensure that your user application\r
+ * allocated pipes in ascending order - or if your application uses the USB host mode class drivers, ensure that each instance's\r
+ * pipe indexes are not overlapped with other interface's pipes.\r
+ * - The \c PRNT_Host_SendData() function has been renamed to \ref PRNT_Host_SendString(). Existing applications should simply\r
+ * replace all references to the obsolete function name with the new function name.\r
+ * - The names of the class specific descriptor type defines in the USB Class drivers have changed - refer to the driver documentation\r
+ * for each class driver for the new class specific descriptor type names.\r
+ * - The Still Image Host class' function prefix has been changed from \c SImage_ to \c SI_, to remain consistent with the rest of the\r
+ * driver's enums, type defines and constants.\r
+ *\r
+ * \section Sec_Migration100807 Migrating from 100513 to 100807\r
+ *\r
+ * <b>Non-USB Library Components</b>\r
+ * - The Dataflash board driver stub file has changed, as dataflash functions previously located in the internal\r
+ * Dataflash driver of the library have now been moved to the individual board files. Existing drivers can\r
+ * copy-paste the new functions from the board Dataflash stub driver.\r
+ *\r
+ * <b>USB Core</b>\r
+ * - A new USB driver source file, \c Drivers/USB/LowLevel/Device.c now exists. This source file should be added to all project\r
+ * makefiles using the USB driver of LUFA, or the makefile should be updated to use the new module source variables.\r
+ * - The \c Drivers/USB/LowLevel/DevChapter9.c source file has moved to \c Drivers/USB/HighLevel/DeviceStandardReq.c - this should\r
+ * be updated in all project makefiles, or the makefile should be updated to use the new module source variables.\r
+ * - The \c Drivers/USB/LowLevel/HostChapter9.h source file has moved to \c Drivers/USB/HighLevel/HostStandardReq.c - this should\r
+ * be updated in all project makefiles, or the makefile should be updated to use the new module source variables.\r
+ * - The \c Drivers/USB/LowLevel/LowLevel.c source file has moved to \c Drivers/LowLevel/USBController.c - this should be updated\r
+ * in all project makefiles, or the makefile should be updated to use the new module source variables.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The \c USB_Device_IsRemoteWakeupSent() macro has been removed, as the remote wakeup request is now fully handled by the\r
+ * enhanced \ref USB_Device_SendRemoteWakeup() function. Existing code may now discard any checks to \c USB_Device_IsRemoteWakeupSent().\r
+ * - The \c USB_Device_IsUSBSuspended() macro has been removed, as it is obsolete. Existing code should compare \ref USB_DeviceState\r
+ * to see if it the device is in the \ref DEVICE_STATE_Suspended state instead.\r
+ * - The \ref CDC_Device_ReceiveByte() function has changed, and now returns a signed 16-bit integer, with -1 indicating no data was\r
+ * received. This allows for more efficient coding, as a call to \ref CDC_Device_BytesReceived() is no longer needed if the exact\r
+ * number of queued bytes received is not needed.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The \ref CDC_Host_ReceiveByte() function has changed, and now returns a signed 16-bit integer, with -1 indicating no data was\r
+ * received. This allows for more efficient coding, as a call to \ref CDC_Host_BytesReceived() is no longer needed if the exact\r
+ * number of queued bytes received is not needed.\r
+ * - The \ref CDC_Host_USBTask() now calls \ref CDC_Host_Flush() automatically, flushing any queued data to the attached device. Manual\r
+ * flushing of the interface is no longer needed if the flushes should be in sync with calls to \ref CDC_Host_USBTask().\r
+ *\r
+ * \section Sec_Migration100513 Migrating from 100219 to 100513\r
+ *\r
+ * <b>Non-USB Library Components</b>\r
+ * - The \ref TWI_StartTransmission() function now takes in a timeout period, expressed in milliseconds, within which the addressed\r
+ * device must respond or the function will abort.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The \ref USB_Init() function no longer calls \c sei() to enable global interrupts, as the user application may need\r
+ * to perform other initialization before it is ready to handle global interrupts. The user application is now responsible\r
+ * for enabling global interrupts before or shortly after calling \ref USB_Init() to ensure that the enumeration process\r
+ * functions correctly.\r
+ * - The \c USBInterrupt.c USB driver source file has been relocated from \c LUFA/Drivers/USB/HighLevel/ to \c LUFA/Drivers/USB/LowLevel.\r
+ * Projects must update their makefile SRC values accordingly.\r
+ * - The HID Device Class driver's function signature for the \ref CALLBACK_HID_Device_ProcessHIDReport() function has been changed, to\r
+ * allow for a new \c ReportType parameter. This new parameter must be added in all user applications using the Device mode HID Class\r
+ * Driver, but may be ignored unless Host-to-Device FEATURE HID reports are used.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The \ref USB_Init() function no longer calls \c sei() to enable global interrupts, as the user application may need\r
+ * to perform other initialization before it is ready to handle global interrupts. The user application is now responsible\r
+ * for enabling global interrupts before or shortly after calling \ref USB_Init() to ensure that the enumeration process\r
+ * functions correctly.\r
+ * - The \c USBInterrupt.c USB driver source file has been relocated from \c LUFA/Drivers/USB/HighLevel/ to \c LUFA/Drivers/USB/LowLevel.\r
+ * Projects must update their makefile \c SRC values accordingly.\r
+ * - The HID Host Class driver's function signature for the \ref HID_Host_SendReportByID() function has been changed, to allow for a new\r
+ * ReportType parameter. Existing calls to this function should substitute \c REPORT_ITEM_TYPE_Out as this parameter's value.\r
+ *\r
+ * \section Sec_Migration100219 Migrating from 091223 to 100219\r
+ *\r
+ * <b>Non-USB Library Components</b>\r
+ * - Due to some ADC channels not being identical to their ADC MUX selection masks for single-ended conversions on some AVR models,\r
+ * the ADC driver now has explicit masks for each of the standard ADC channels (see \ref Group_ADC). These masks should be used\r
+ * when calling the ADC functions to ensure proper operation across all AVR models. Note that the \ref ADC_SetupChannel() function\r
+ * is an exception, and should always be called with a channel number rather than a channel mask.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The MIDI Host Class driver send and receive routines now operate on packed events, where multiple MIDI events may be\r
+ * packed into a single USB packet. This means that the sending of MIDI events will now be delayed until the MIDI send\r
+ * pipe bank is full. To override this new behaviour and revert to the previous behaviour, the user application may manually\r
+ * flush the queued event(s) to the device by calling \ref MIDI_Host_Flush().\r
+ * - The \ref Pipe_IsEndpointBound() function now takes the endpoint's direction into account, by checking if the MSB of the endpoint's address\r
+ * is set to denote IN endpoints. If the previous functionality where the direction is to be discounted is required, mask the endpoint\r
+ * address against the \ref PIPE_EPNUM_MASK token before calling \ref Pipe_IsEndpointBound().\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The MIDI Device Class driver send and receive routines now operate on packed events, where multiple MIDI events may be\r
+ * packed into a single USB packet. This means that the sending of MIDI events will now be delayed until the MIDI send\r
+ * endpoint bank is full. To override this new behaviour and revert to the previous behaviour, the user application may manually\r
+ * flush the queued event(s) to the host by calling \ref MIDI_Device_Flush().\r
+ *\r
+ * \section Sec_Migration091223 Migrating from 091122 to 091223\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The Still Image Host Class driver \ref SI_Host_USBTask() and \ref SI_Host_ConfigurePipes() functions were misnamed, and are\r
+ * now named \c SImage_Host_USBTask() and \c SImage_Host_ConfigurePipes() respectively.\r
+ * - The \c HOST_SENDCONTROL_DeviceDisconnect enum value has been renamed to \ref HOST_SENDCONTROL_DeviceDisconnected to be in\r
+ * line with the rest of the library error codes.\r
+ * - The HID Parser item usages no longer contain separate minimum and maximum values, as this was a violation of the HID\r
+ * specification. Instead, the values are distributed evenly across each item as its usage value, to ensure that all items\r
+ * can be distinguished from one-another.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The \ref CALLBACK_HID_Device_CreateHIDReport() HID Device Class driver callback now has a new \c ReportType parameter to\r
+ * indicate the report type to generate. Existing applications may simply add and ignore this additional parameter.\r
+ *\r
+ * \section Sec_Migration091122 Migrating from 090924 to 091122\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The \c HID_PARSE_UsageStackOverflow HID parser error constant is now named \ref HID_PARSE_UsageListOverflow\r
+ * - The \ref CALLBACK_HIDParser_FilterHIDReportItem() HID Parser callback now passes a complete \ref HID_ReportItem_t to the\r
+ * user application, instead of just its attributes.\r
+ * - The \c USB_GetDeviceConfigDescriptor() function was incorrectly named and is now called \ref USB_Host_GetDeviceConfigDescriptor().\r
+ *\r
+ * \section Sec_Migration090924 Migrating from 090810 to 090924\r
+ *\r
+ * <b>Non-USB Library Components</b>\r
+ * - The \c ADC_Off() function has been renamed to \c ADC_ShutDown() to be consistent with the rest of the library.\r
+ * - The \ref SPI_Init() routine's parameters have changed, so that the clock polarity and data sampling modes can be set. See\r
+ * the \ref SPI_Init() function documentation for more details\r
+ * - The \ref Dataflash_Init() routine no longer initializes the SPI bus - the SPI bus should be initialized manually via a\r
+ * call to \ref SPI_Init() before using the Dataflash driver\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The \c USB_GetDeviceConfigDescriptor() function's parameters and behaviour has changed; the user is required to\r
+ * preallocate the largest allowable buffer, and pass the size of the buffer to the function. This allows for a single\r
+ * call to the function to retrieve, size check and validate the Configuration Descriptor rather than having the user\r
+ * application perform these intermediary steps.\r
+ * - The HID report parser now requires a mandatory callback in the user code, to filter only the items the application\r
+ * is interested in into the processed HID report item structure to save RAM. See \ref CALLBACK_HIDParser_FilterHIDReportItem().\r
+ * - The HID report parser now always parses FEATURE and always ignores constant-data items - the \c HID_ENABLE_FEATURE_PROCESSING\r
+ * and \c HID_INCLUDE_CONSTANT_DATA_ITEMS compile time tokens now have no effect.\r
+ * - The \c USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token has been removed - there are now separate \c USB_Descriptor_*\r
+ * and \c USB_StdDescriptor_* structures for both the LUFA and standardized element naming conventions so that both may be used in\r
+ * the one project. For existing projects using the standardized names, change all code to use the \c USB_StdDescriptor_* variants.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The \c USE_NONSTANDARD_DESCRIPTOR_NAMES compile time token has been removed - there are now separate \c USB_Descriptor_*\r
+ * and \c USB_StdDescriptor_* structures for both the LUFA and standardized element naming conventions so that both may be used in\r
+ * the one project. For existing projects using the standardized names, change all code to use the \c USB_StdDescriptor_* variants.\r
+ *\r
+ * \section Sec_Migration090810 Migrating from 090605 to 090810\r
+ *\r
+ * <b>All</b>\r
+ * - The "Simple Scheduler" has been <i>deprecated</i>, as it was little more than an abstracted loop and caused much confusion.\r
+ * User applications using the scheduler should switch to regular loops instead. The scheduler code will be removed in a future\r
+ * release.\r
+ * - The "Dynamic Memory Block Allocator" has been removed, as it was unused in (and unrelated to) the LUFA library and never\r
+ * used in user applications.\r
+ *\r
+ * <b>Non-USB Library Components</b>\r
+ * - The \c ATTR_NOINLINE function attribute macro has been renamed to \ref ATTR_NO_INLINE to be in line with the rest of the function attribute\r
+ * macro names.\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - Most demos now have a corresponding Class Driver implementation, which uses the new internal library class drivers for the standard\r
+ * USB classes. This allows for more rapid device and host development, and so should be used in preference to the low level APIs where\r
+ * possible so that fixes to the class drivers propagate to all applications which use them automatically with each new LUFA release.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The \c HIDParser.c module has moved from \c LUFA/Drivers/USB/Class/ to \c LUFA/Drivers/USB/Class/Host/.\r
+ * - The \c USB_GetDeviceConfigDescriptor() function now requires the desired configuration index within the device as its first\r
+ * parameter, to add support for multi-configuration devices. Existing code should use a configuration index of 1 to indicate the\r
+ * first configuration descriptor within the device.\r
+ * - The non-standard "Ready" host state has been removed. Existing \ref HOST_STATE_Configured code should be moved to the end of\r
+ * the existing \ref HOST_STATE_Addressed state, and the existing HOST_STATE_Ready state code should be moved to the \ref HOST_STATE_Configured\r
+ * state.\r
+ * - The \c USB_IsConnected global has been removed, as it is too vague for general use. Test \ref USB_HostState explicitly to ensure the host is\r
+ * in the desired state instead.\r
+ * - The USB event names have been changed and their firing conditions changed to properly separate out Host mode events from Device mode\r
+ * events. See the \ref Group_Events page for details on the new event names and firing conditions.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The \ref CALLBACK_USB_GetDescriptor() function now takes an extra parameter to specify the descriptor's memory space so that\r
+ * descriptors in mixed memory spaces can be used. The previous functionality can be returned by defining the \c USE_FLASH_DESCRIPTORS\r
+ * token in the project makefile to fix all descriptors into FLASH space and remove the extra function parameter.\r
+ * - The \c USB_IsSuspended global has been removed - test \ref USB_DeviceState against \ref DEVICE_STATE_Suspended instead.\r
+ * - The \c USB_IsConnected global has been removed, as it is too vague for general use. Test \ref USB_DeviceState explicitly to ensure the device\r
+ * is in the desired state instead.\r
+ * - The VBUS events have been removed, as they are already exposed to the user via the \c USB_Connect and \c USB_Disconnect events.\r
+ * - The USB event names have been changed and their firing conditions changed to properly separate out Host mode events from Device mode\r
+ * events. See the \ref Group_Events page for details on the new event names and firing conditions.\r
+ *\r
+ * \section Sec_Migration090605 Migrating from 090510 to 090605\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - Support for non-control data endpoint interrupts has been dropped due to many issues in the implementation. All existing\r
+ * projects using interrupts on non-control endpoints should switch to polling. For control interrupts, the library can\r
+ * manage the control endpoint via interrupts automatically by compiling with the \c INTERRUPT_CONTROL_ENDPOINT token defined.\r
+ * - The \c DESCRIPTOR_ADDRESS() macro has been removed. User applications should use normal casts to obtain a descriptor's memory\r
+ * address.\r
+ * - The library events system has been rewritten, so that all macros have been removed to allow for clearer user code. See\r
+ * \ref Group_Events for new API details.\r
+ * - The \c STREAM_CALLBACK() macro has been removed. User applications should replace all instances of the macro with regular\r
+ * function signatures of a function accepting no arguments and returning a \c uint8_t value.\r
+ * - The \c Event_DeviceError() event no longer exists, as its sole caller (unlinked \c USB_GetDescriptor() function) now produces a\r
+ * compilation error rather than a runtime error. The \c StdDescriptors.c file no longer exists as a result, and should be removed\r
+ * from project makefiles.\r
+ * - The \c USB_GetDescriptor() function has been renamed to \ref CALLBACK_USB_GetDescriptor() to be in line with the new \c CALLBACK_\r
+ * function prefixes for functions which <i>must</i> be implemented in the user application.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - Support for non-control data pipe interrupts has been dropped due to many issues in the implementation. All existing\r
+ * projects using interrupts on non-control pipes should switch to polling.\r
+ * - The library events system has been rewritten, so that all macros have been removed to allow for clearer user code. See\r
+ * \ref Group_Events for new API details.\r
+ * - The \c STREAM_CALLBACK() macro has been removed. User applications should replace all instances of the macro with regular\r
+ * function signatures of a function accepting no arguments and returning a \c uint8_t value.\r
+ * - The \c DESCRIPTOR_COMPARATOR() macro has been removed. User applications should replace all instances of the macro with\r
+ * regular function signatures of a function accepting a void pointer to the descriptor to test, and returning a \c uint8_t value.\r
+ *\r
+ * \section Sec_Migration090510 Migrating from 090401 to 090510\r
+ *\r
+ * <b>All</b>\r
+ * - The \c ButtLoadTag.h header has been removed, as it was never used for its intended purpose. Projects should either remove all\r
+ * \c BUTTLOADTAG() elements, or download and extract \c ButtLoadTag.h header from the ButtLoad project.\r
+ * - The \c Drivers/AT90USBXXX/ directory has been renamed to \c Drivers/Peripheral/.\r
+ * - The \c Serial_Stream driver has been renamed to \c SerialStream to remain consistent with the rest of the library naming scheme.\r
+ * - The HWB driver has changed to the \c Buttons driver. See the board Buttons driver documentation for the new API.\r
+ *\r
+ * <b>Dual Role Mode</b>\r
+ * - The \c USB_PowerOnFail event has been renamed to \c USB_InitFailure.\r
+ * - The functions in \c OTG.h have been renamed to remain more consistent with the library API. See the functions in \c OTG.h for more\r
+ * details.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The \c Endpoint_ClearCurrentBank() macro has been removed, and is now replaced with the \ref Endpoint_ClearIN(), \ref Endpoint_ClearOUT()\r
+ * macros. See \c Endpoint.h documentation for more details on the new endpoint management macros.\r
+ * - The \c Endpoint_ReadWriteAllowed() macro has been renamed to \ref Endpoint_IsReadWriteAllowed() to be more consistent with the rest of\r
+ * the API naming scheme.\r
+ * - The \c Endpoint_IsSetupINReady() and \c Endpoint_IsSetupOUTReceived() macros have been renamed to \ref Endpoint_IsINReady() and\r
+ * \ref Endpoint_IsOUTReceived() respectively.\r
+ * - The \c Endpoint_IsSetupReceived() macro has been renamed to \ref Endpoint_IsSETUPReceived().\r
+ * - The \c Endpoint_ClearSetupReceived() macro has been renamed to \ref Endpoint_ClearSETUP().\r
+ * - All endpoint read/write/discard aliases which did not have an explicitly endianness specifier (such as \c Endpoint_Read_Word()) have\r
+ * been removed for clarity. Existing projects should use the \c _LE suffix on such calls to use the explicit Little Endian versions.\r
+ * - The \c USB_UnhandledControlPacket event no longer has any parameters. User code should no longer attempt to read in the remainder of\r
+ * the Control Request header as all Control Request header data is now preloaded by the library and made available in the\r
+ * USB_ControlRequest structure.\r
+ * - The \c FEATURELESS_CONTROL_ONLY_DEVICE token has been renamed to \c CONTROL_ONLY_DEVICE.\r
+ * - The \c STATIC_ENDPOINT_CONFIGURATION is no longer applicable as the library will apply this optimization when appropriate automatically.\r
+ * - The values of the \ref Endpoint_Stream_RW_ErrorCodes_t and \ref Endpoint_ControlStream_RW_ErrorCodes_t enums have had the \c ERROR_ portion\r
+ * of their names removed.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The \ref USB_Host_SendControlRequest() function no longer automatically selects the Control pipe (pipe 0) to allow it to be used on\r
+ * other control type pipes. Care should be taken to ensure that the Control pipe is always selected before the function is called\r
+ * in existing projects where the Control pipe is to be operated on.\r
+ * - The USB Host management task now saves and restores the currently selected pipe before and after the task runs. Projects no longer\r
+ * need to manage this manually when calling the USB management task.\r
+ * - The \c Pipe_ClearCurrentBank() macro has been removed, and is now replaced with the Pipe_ClearIN(), Pipe_ClearOUT() macros. See\r
+ * Pipe.h documentation for more details on the new pipe management macros.\r
+ * - The \c Pipe_ReadWriteAllowed() macro has been renamed to \ref Pipe_IsReadWriteAllowed() to be more consistent with the rest of the API\r
+ * naming scheme.\r
+ * - The \c Pipe_IsSetupINReceived() and \c Pipe_IsOutReady() macros have been renamed to \ref Pipe_IsINReceived() and \ref Pipe_IsOUTReady()\r
+ * respectively.\r
+ * - The new \ref Pipe_ClearSETUP() macro should be used to send SETUP transactions, rather than the previous \c Pipe_ClearSetupOUT() macro.\r
+ * - The \c Pipe_IsSetupSent() macro has been renamed to \ref Pipe_IsSETUPSent().\r
+ * - The \c Pipe_ClearSetupSent() macro is no longer applicable and should be removed.\r
+ * - All pipe read/write/discard aliases which did not have an explicitly endianness specifier (such as \c Pipe_Read_Word()) have\r
+ * been removed for clarity. Existing projects should use the \c _LE suffix on such calls to use the explicit Little Endian versions.\r
+ * - The \c Host_IsResetBusDone() macro has been renamed to \c Host_IsBusResetComplete().\r
+ * - The \c Pipe_Ignore_Word() and \c Pipe_Ignore_DWord() functions have been renamed to \c Pipe_Discard_Word() and \c Pipe_Discard_DWord()\r
+ * to remain consistent with the rest of the pipe API.\r
+ * - It is no longer needed to manually include the headers from \c LUFA/Drivers/USB/Class, as they are now included along with the rest\r
+ * of the USB headers when \c LUFA/Drivers/USB/USB.h is included.\r
+ * - Functions in the \c ConfigDescriptor.h header file no longer have \c Host_ as part of their names.\r
+ * - The \c ProcessHIDReport() has been renamed to \ref USB_ProcessHIDReport(), \c GetReportItemInfo() has been renamed to \ref USB_GetHIDReportItemInfo()\r
+ * and \c SetReportItemInfo() has been renamed to \ref USB_GetHIDReportItemInfo().\r
+ * - The values of the \ref DSearch_Return_ErrorCodes_t and \ref DSearch_Comp_Return_ErrorCodes_t enums have had their respective \c Descriptor_Search\r
+ * and \c Descriptor_Search_Comp prefixes changed to all caps.\r
+ * - The \c USB_HostRequest global has been renamed to \ref USB_ControlRequest, and is used in Device mode also. The \c USB_Host_Request_Header_t\r
+ * structure type has been renamed to \ref USB_Request_Header_t.\r
+ * - The values of the \ref Pipe_Stream_RW_ErrorCodes_t enum have had the \c ERROR_ portion of their names removed.\r
+ *\r
+ * \section Sec_Migration090401 Migrating from 090209 to 090401\r
+ *\r
+ * <b>All</b>\r
+ * - LUFA projects must now give the raw input clock frequency (before any prescaling) as a compile time constant \c F_USB,\r
+ * defined in the project makefile and passed to the compiler via the -D switch.\r
+ * - The makefile EEPROM programming targets for FLIP and dfu-programmer no longer program in the FLASH data in addition to the\r
+ * EEPROM data into the device. If both are to be programmed, both the EEPROM and FLASH programming targets must be called.\r
+ * - As the avr-libc macro has been corrected in recent avr-libc distributions, the \c SetSystemClockPrescaler() macro has been removed.\r
+ * Include \c <avr/power.h> and call \c clock_prescale_set(clock_div_1); instead on recent avr-libc distributions.\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - The USBtoSerial demo now discards all data when not connected to a host, rather than buffering it for later transmission.\r
+ *\r
+ * <b>Non-USB Library Components</b>\r
+ * - The \c ATTR_ALWAYSINLINE function attribute macro has been renamed to \ref ATTR_ALWAYS_INLINE.\r
+ * - Custom board Dataflash drivers now require the implementation of \ref Dataflash_SelectChipFromPage() and \ref Dataflash_SendAddressBytes().\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The \c NO_CLEARSET_FEATURE_REQUEST compile time token has been renamed to \c FEATURELESS_CONTROL_ONLY_DEVICE, and its function expanded\r
+ * to also remove parts of the Get Status chapter 9 request to further reduce code usage. On all applications currently using the\r
+ * \c NO_CLEARSET_FEATURE_REQUEST compile time token, it can be replaced with the \c FEATURELESS_CONTROL_ONLY_DEVICE token with no further\r
+ * modifications required.\r
+ *\r
+ * \section Sec_Migration090209 Migrating from 081217 to 090209\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The \c ENDPOINT_MAX_ENDPOINTS constant has been renamed to the more appropriate name of \c ENDPOINT_TOTAL_ENDPOINTS.\r
+ * - The \c USB_STREAM_TIMEOUT_MS stream timeout default period has been extended to 100ms. This can be overridden in the user\r
+ * makefile if desired to restore the previous 50ms timeout.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The \c PIPE_MAX_ENDPOINTS constant has been renamed to the more appropriate name of \c PIPE_TOTAL_ENDPOINTS.\r
+ * - The \c USB_STREAM_TIMEOUT_MS stream timeout default period has been extended to 100ms. This can be overridden in the user\r
+ * makefile if desired to restore the previous 50ms timeout.\r
+ * - The \c USB_DeviceEnumerationFailed event now contains a second \c SubErrorCode parameter, giving the error code of the function\r
+ * which failed.\r
+ * - The \c HID_PARSE_Sucessful enum member constant name has been corrected to \ref HID_PARSE_Successful.\r
+ *\r
+ * <b>Non-USB Library Components</b>\r
+ * - The previous \c SPI_SendByte() functionality is now located in \ref SPI_TransferByte(). \ref SPI_SendByte() now discards the return byte\r
+ * for speed, to compliment the new \ref SPI_ReceiveByte() function. If bidirectional SPI transfers are required, calls to \ref SPI_SendByte()\r
+ * should be changed to \ref SPI_TransferByte().\r
+ * - The serial driver now sets the Tx line as an output explicitly, and enables the pull-up of the Rx line.\r
+ * - The \ref Serial_Init() and \c SerialStream_Init() functions now take a second \c DoubleSpeed parameter, which indicates if the USART\r
+ * should be initialized in double speed mode - useful in some circumstances for attaining baud rates not usually possible at the given AVR\r
+ * clock speed.\r
+ *\r
+ * \section Sec_Migration171208 Migrating from V1.5.3 to 081217\r
+ *\r
+ * <b>All</b>\r
+ * - The MyUSB project name has been changed to LUFA (Lightweight Framework for USB AVRs). All references to MyUSB, including macro names,\r
+ * have been changed to LUFA.\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - The ReconfigureUSART() routine in the USBtoSerial demo was not being called after new line encoding\r
+ * parameters were set by the host. Projects built on the USBtoSerial code should update to the latest version.\r
+ * - The HID Parser now supports multiple report (on a single endpoint) HID devices. The MouseHostWithParser and\r
+ * KeyboardHostWithPaser demos use the updated API functions to function correctly on such devices. Projects\r
+ * built on either "WithParser" demo should update to the latest code.\r
+ * - The RNDIS demo TCP stack has been modified so that connections can be properly closed. It is still not\r
+ * recommended that the MyUSB RNDIS demo TCP/IP stack be used for anything other than demonstration purposes,\r
+ * as it is neither a full nor a standards compliant implementation.\r
+ *\r
+ * <b>Non-USB Library Components</b>\r
+ * - The Serial_IsCharReceived() macro has been changed to the correct spelling of Serial_IsCharReceived() in Serial.h.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The MANUAL_PLL_CONTROL compile time token has been removed, and replaced with a USB_OPT_MANUAL_PLL mask\r
+ * to be used in the Options parameter of the USB_Init() function.\r
+ * - Calling USB_Init() now forces a complete USB interface reset and enumeration, even if the USB interface is\r
+ * currently initialized.\r
+ * - Interrupts are now disabled when processing control requests, to avoid problems with interrupts causing the library\r
+ * or user request processing code to exceed the strict USB timing requirements on control transfers.\r
+ * - The USB Reset event now resets and disables all device endpoints. If user code depends on endpoints remaining configured\r
+ * after a Reset event, it should be altered to explicitly re-initialize all user endpoints.\r
+ * - The prototype for the GetDescriptor function has been changed, as the return value was redundant. The function now\r
+ * returns the size of the descriptor, rather than passing it back via a parameter, or returns NO_DESCRIPTOR if the specified\r
+ * descriptor does not exist.\r
+ * - The NO_DESCRIPTOR_STRING macro has been renamed NO_DESCRIPTOR, and is now also used as a possible return value for the\r
+ * GetDescriptor function.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The MANUAL_PLL_CONTROL compile time token has been removed, and replaced with a USB_OPT_MANUAL_PLL mask\r
+ * to be used in the Options parameter of the USB_Init() function.\r
+ * - The HID report parser now supports multiple Report IDs. The HID report parser GetReportItemInfo() and\r
+ * SetReportItemInfo() routines now return a boolean, set if the requested report item was located in the\r
+ * current report. If sending a report to a multi-report device, the first byte of the report is automatically\r
+ * set to the report ID of the given report item.\r
+ * - Calling USB_Init() now forces a complete USB interface reset and enumeration, even if the USB interface is\r
+ * currently initialized.\r
+ *\r
+ * \section Sec_Migration152 Migrating from V1.5.2 to V1.5.3\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - Previously, all demos contained a serial number string descriptor, filled with all zeros. A serial number\r
+ * string is required in Mass Storage devices, or devices which are to retain settings when moved between\r
+ * ports on a machine. As people were not changing the serial number value, this was causing conflicts and so\r
+ * the serial number descriptor has been removed from all but the Mass Storage demo, which requires it.\r
+ * - The AudioOut and AudioIn demos did not previously silence their endpoints when the host has deactivated\r
+ * them. Projects built upon either demo should upgrade to the latest code.\r
+ * - The FEATURE_ENDPOINT macro has been renamed FEATURE_ENDPOINT_HALT, and is now correctly documented.\r
+ * - The MassStoreHost demo contained errors which caused it to lock up randomly on certain devices. Projects built\r
+ * on the MassStoreDemo code should update to the latest version.\r
+ * - The Interrupt type endpoint in the CDC based demos previously had a polling interval of 0x02, which caused\r
+ * problems on some Linux systems. This has been changed to 0xFF, projects built on the CDC demos should upgrade\r
+ * to the latest code.\r
+ * - The HID keyboard and mouse demos were not previously boot mode compatible. To enable boot mode support, projects\r
+ * built on the keyboard or mouse demos (or derivatives) should upgrade to the latest code.\r
+ * - The Mass Storage demo was not previously standards compliant. Projects built on the Mass Storage demo should\r
+ * upgrade to the latest code.\r
+ * - The USART was not being reconfigured after the host sent new encoding settings in the USBtoSerial demo. This was\r
+ * previously discovered and fixed, but the change was lost. Projects built on the USBtoSerial demo should update\r
+ * to the latest code.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The endpoint non-control stream functions now have a default timeout of 50ms between packets in the stream.\r
+ * If this timeout is exceeded, the function returns the new ENDPOINT_RWSTREAM_ERROR_Timeout error value. The\r
+ * timeout value can be overridden by defining the USB_STREAM_TIMEOUT_MS in the project makefile to the desired\r
+ * timeout duration in ms.\r
+ * - Rather than returning fixed values, the flags indicating if the device has Remote Wakeup currently enabled\r
+ * and/or is self-powered are now accessed and set through the new USB_RemoteWakeupEnabled and\r
+ * USB_CurrentlySelfPowered macros. See the DevChapter9.h documentation for more details.\r
+ * - All endpoint stream functions now require an extra Callback function parameter. Existing code may be updated\r
+ * to either supply NO_STREAM_CALLBACK as the extra parameter, or disable stream callbacks altogether by passing\r
+ * the token NO_STREAM_CALLBACKS to the compiler using the -D switch.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The pipe non-control stream functions now have a default timeout of 50ms between packets in the stream.\r
+ * If this timeout is exceeded, the function returns the new PIPE_RWSTREAM_ERROR_Timeout error value. The\r
+ * timeout value can be overridden by defining the USB_STREAM_TIMEOUT_MS in the project makefile to the desired\r
+ * timeout duration in ms.\r
+ * - CollectionPath_t has been renamed to HID_CollectionPath_t to be more in line with the other HID parser structures.\r
+ * - All pipe stream functions now require an extra Callback function parameter. Existing code may be updated\r
+ * to either supply NO_STREAM_CALLBACK as the extra parameter, or disable stream callbacks altogether by passing\r
+ * the token NO_STREAM_CALLBACKS to the compiler using the -D switch.\r
+ *\r
+ * \section Sec_Migration151 Migrating from V1.5.1 to V1.5.2\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - The RNDIS demo application has been updated so that it is functional on Linux under earlier implementations\r
+ * of the RNDIS specification, which had non-standard behaviour. Projects built upon the demo should upgrade\r
+ * to the latest code.\r
+ * - The DFU class bootloader has had several bugs corrected in this release. It is recommended that where\r
+ * possible any existing devices upgrade to the latest bootloader code.\r
+ *\r
+ * \section Sec_Migration150 Migrating from V1.5.0 to V1.5.1\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - The USBtoSerial demo was broken in the 1.5.0 release, due to incorrect register polling in place of the\r
+ * global "Transmitting" flag. The change has been reverted in this release. Projects built upon the demo\r
+ * should upgrade to the latest code.\r
+ * - The HID class demos did not implement the mandatory GetReport HID class request. Projects built upon the HID\r
+ * demos should upgrade to the latest code.\r
+ * - The HID class demos incorrectly reported themselves as boot-protocol enabled HID devices in their descriptors.\r
+ * Projects built upon the HID demos should upgrade to the latest code.\r
+ * - The MIDI device demo had incorrect AudioStreaming interface descriptors. Projects built upon the MIDI demo\r
+ * should upgrade to the latest code.\r
+ * - The AudioOut demo did not correctly tristate the speaker pins when USB was disconnected, wasting power.\r
+ * Projects built upon the AudioOut demo should upgrade to the latest code.\r
+ *\r
+ * \section Sec_Migration141 Migrating from V1.4.1 to V1.5.0\r
+ *\r
+ * <b>Library Demos</b>\r
+ * - Previous versions of the library demos had incorrectly encoded BCD version numbers in the descriptors. To\r
+ * avoid such mistakes in the future, the VERSION_BCD macro has been added to StdDescriptors.h. Existing\r
+ * projects should at least manually correct the BCD version numbers, or preferably update the descriptors to\r
+ * encode the version number in BCD format using the new macro.\r
+ * - The mandatory GetReport class-specific request was accidentally omitted from previous versions of the demos\r
+ * based on the Human Interface Device (HID) class. This has been corrected, and any user projects based on the\r
+ * HID demos should also be updated accordingly.\r
+ * - The CDC demos now correctly send an empty packet directly after a full packet, to end the transmission.\r
+ * Failure to do this on projects which always or frequently send full packets will cause buffering issues on\r
+ * the host OS. All CDC user projects are advised to update their transmission routines in the same manner as\r
+ * the library CDC demos.\r
+ * - The previous interrupt-driven Endpoint/Pipe demos did not properly save and restore the currently selected\r
+ * Endpoint/Pipe when the ISR fired. This has been corrected - user projects based on the interrupt driven\r
+ * demos should also update to properly save and restore the selected Endpoint/Pipe.\r
+ *\r
+ * <b>Non-USB Library Components</b>\r
+ * - The Atomic.h and ISRMacro.h header files in MyUSB/Common have been removed, as the library is now only\r
+ * compatible with avr-libc library versions newer than the time before the functionality of the deleted\r
+ * headers was available.\r
+ *\r
+ * <b>Device Mode</b>\r
+ * - The GetDescriptor function (see StdDescriptors.h) now has a new prototype, with altered parameter names and\r
+ * functions. Existing projects will need to update the GetDescriptor implementation to reflect the new API.\r
+ * The previously split Type and Index parameters are now passed as the original wValue parameter to the\r
+ * function, to make way for the USB specification wIndex parameter which is <i>not</i> the same as the\r
+ * previous Index parameter.\r
+ * - The USB_UnhandledControlPacket event (see Events.h) now has new parameter names, to be in line with the\r
+ * official USB specification. Existing code will need to be altered to use the new parameter names.\r
+ * - The USB_CreateEndpoints event (see Events.h) has been renamed to USB_ConfigurationChanged, which is more\r
+ * appropriate. It fires in an identical manner to the previously named event, thus the only change to be made\r
+ * is the event name itself in the user project.\r
+ * - The USB_Descriptor_Language_t structure no longer exists in StdDescriptors.h, as this was a\r
+ * pseudo-descriptor modeled on the string descriptor. It is replaced by the true USB_Descriptor_String_t type\r
+ * descriptor as indicated in the USB specification, thus all device code must be updated accordingly.\r
+ * - The names of several Endpoint macros have been changed to be more consistent with the rest of the library,\r
+ * with no implementation changes. This means that existing code can be altered to use the new macro names\r
+ * with no other considerations required. See Endpoint.h for the new macro names.\r
+ * - The previous version of the MassStorage demo had an incorrect value in the SCSI_Request_Sense_Response_t\r
+ * structure named SenseData in SCSI.c which caused some problems with some hosts. User projects based on this\r
+ * demo should correct the structure value to maintain compatibility across multiple OS platforms.\r
+ * - By default, the descriptor structures use the official USB specification names for the elements. Previous\r
+ * versions of the library used non-standard (but more verbose) names, which are still usable in the current\r
+ * and future releases when the correct compile time option is enabled. See the StdDescriptors.h file\r
+ * documentation for more details.\r
+ *\r
+ * <b>Host Mode</b>\r
+ * - The USB_Host_Request_Header_t structure in HostChapter9.h (used for issuing control requests) has had its\r
+ * members renamed to the official USB specification names for requests. Existing code will need to be updated\r
+ * to use the new names.\r
+ * - The names of several Pipe macros have been changed to be more consistent with the rest of the library,\r
+ * with no implementation changes. This means that existing code can be altered to use the new macro names\r
+ * with no other considerations required. See Pipe.h for the new macro names.\r
+ * - By default, the descriptor structures use the official USB specification names for the elements. Previous\r
+ * versions of the library used non-standard (but more verbose) names, which are still usable in the current\r
+ * and future releases when the correct compile time option is enabled. See the StdDescriptors.h file\r
+ * documentation for more details.\r
+ * - The names of the macros in Host.h for controlling the SOF generation have been renamed, see the Host.h\r
+ * module documentation for the new macro names.\r
+ *\r
+ * <b>Dual Role Mode</b>\r
+ * - The OTG.h header file has been corrected so that the macros now perform their stated functions. Any existing\r
+ * projects using custom headers to fix the broken OTG header should now be altered to once again use the OTG\r
+ * header inside the library.\r
+ * - The USB_DeviceEnumerationComplete event (see Events.h) now also fires in Device mode, when the host has\r
+ * finished enumerating the device. Projects relying on the event only firing in Host mode should be updated\r
+ * so that the event action only occurs when the USB_Mode global is set to USB_MODE_HOST.\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_ProgrammingApps Programming an Application into a USB AVR\r
+ *\r
+ * Once you have built an application, you will need a way to program in the resulting ".HEX" file (and, if your\r
+ * application uses EEPROM variables with initial values, also a ".EEP" file) into your USB AVR. Normally, the\r
+ * reprogramming of an AVR device must be performed using a special piece of programming hardware, through one of the\r
+ * supported AVR programming protocols - ISP, HVSP, HVPP, JTAG, dW or PDI. This can be done through a custom programmer,\r
+ * a third party programmer, or an official Atmel AVR tool - for more information, see the <a>atmel.com</a> website.\r
+ *\r
+ * Alternatively, you can use the bootloader. From the Atmel factory, each USB AVR comes preloaded with the Atmel\r
+ * DFU (Device Firmware Update) class bootloader, a small piece of AVR firmware which allows the remainder of the\r
+ * AVR to be programmed through a non-standard interface such as the serial USART port, SPI, or (in this case) USB.\r
+ * Bootloaders have the advantage of not requiring any special hardware for programming, and cannot usually be erased\r
+ * or broken without an external programming device. They have disadvantages however; they cannot change the fuses of\r
+ * the AVR (special configuration settings that control the operation of the chip itself) and a small portion of the\r
+ * AVR's FLASH program memory must be reserved to contain the bootloader firmware, and thus cannot be used by the\r
+ * loaded application.\r
+ *\r
+ * If you wish to use the DFU bootloader to program in your application, refer to your DFU programmer's documentation.\r
+ * Atmel provides a free utility called FLIP which is USB AVR compatible, and an open source (Linux compatible)\r
+ * alternative exists called "dfu-programmer".\r
+ *\r
+ * \see \ref Page_BuildModule_DFU for information on the LUFA build system DFU module, for automatic DFU bootloader\r
+ * programming makefile targets.\r
+ */\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/**\r
+ * \page Page_SoftwareBootloaderStart Entering the Bootloader via Software\r
+ *\r
+ * A common requirement of many applications is the ability to jump to the programmed bootloader of a chip\r
+ * on demand, via the code's firmware (i.e. not as a result of any physical user interaction with the\r
+ * hardware). This might be required because the device does not have any physical user input, or simply\r
+ * just to streamline the device upgrade process on the host PC.\r
+ *\r
+ * The following C code snippets may be used to enter the bootloader upon request by the user application.\r
+ * By using the watchdog to physically reset the controller, it is ensured that all system hardware is\r
+ * completely reset to their defaults before the bootloader is run. This is important; since bootloaders\r
+ * are written to occupy a very limited space, they usually make assumptions about the register states based\r
+ * on the default values after a hard-reset of the chip.\r
+ *\r
+ * \section Sec_SoftareBootAVR8 AVR8 Architecture\r
+ * The following software bootloader jump code is written for the AVR8 architecture.\r
+ *\r
+ * \code\r
+ * #include <avr/wdt.h>\r
+ * #include <avr/io.h>\r
+ * #include <util/delay.h>\r
+ * \r
+ * #include <LUFA/Common/Common.h>\r
+ * #include <LUFA/Drivers/USB/USB.h>\r
+ * \r
+ * uint32_t Boot_Key ATTR_NO_INIT;\r
+ * \r
+ * #define MAGIC_BOOT_KEY 0xDC42ACCA\r
+ * #define BOOTLOADER_START_ADDRESS (FLASH_SIZE_BYTES - BOOTLOADER_SEC_SIZE_BYTES)\r
+ * \r
+ * void Bootloader_Jump_Check(void) ATTR_INIT_SECTION(3);\r
+ * void Bootloader_Jump_Check(void)\r
+ * {\r
+ * // If the reset source was the bootloader and the key is correct, clear it and jump to the bootloader\r
+ * if ((MCUSR & (1 << WDRF)) && (Boot_Key == MAGIC_BOOT_KEY))\r
+ * {\r
+ * Boot_Key = 0;\r
+ * ((void (*)(void))BOOTLOADER_START_ADDRESS)();\r
+ * }\r
+ * }\r
+ * \r
+ * void Jump_To_Bootloader(void)\r
+ * {\r
+ * // If USB is used, detach from the bus and reset it\r
+ * USB_Disable();\r
+ * \r
+ * // Disable all interrupts\r
+ * cli();\r
+ * \r
+ * // Wait two seconds for the USB detachment to register on the host\r
+ * Delay_MS(2000);\r
+ * \r
+ * // Set the bootloader key to the magic value and force a reset\r
+ * Boot_Key = MAGIC_BOOT_KEY;\r
+ * wdt_enable(WDTO_250MS);\r
+ * for (;;);\r
+ * }\r
+ * \endcode\r
+ *\r
+ * Note that the bootloader magic key can be any arbitrary value. The <em>FLASH_SIZE_BYTES</em> and\r
+ * <em>BOOTLOADER_SEC_SIZE_BYTES</em> tokens should be replaced with the total flash size of the AVR\r
+ * in bytes, and the allocated size of the bootloader section for the target AVR.\r
+ *\r
+ */\r
+\r
--- /dev/null
+<!--BEGIN GENERATE_TREEVIEW-->\r
+ <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->\r
+ <ul>\r
+ <li class="footer" style="float:left !important;">\r
+ $generatedby\r
+ <a href="http://www.doxygen.org/index.html">\r
+ <img class="footer" src="$relpath$doxygen.png" alt="doxygen"/>\r
+ </a>\r
+ $doxygenversion\r
+ </li>\r
+\r
+ <li class="footer">\r
+ <a href="http://www.lufa-lib.org" title="LUFA Project Page">LUFA Project Page</a> | <a href="http://www.lufa-lib.org/support" title="LUFA Support List">Support Mailing List</a> | <a href="http://www.lufa-lib.org/donate" title="Donate to Support LUFA">Donate</a> | <a href="http://www.fourwalledcubicle.com" title="Four Walled Cubicle Website">Four Walled Cubicle</a> - LUFA, the Lightweight USB Framework for AVRs\r
+ </li>\r
+ </ul>\r
+ </div>\r
+<!--END GENERATE_TREEVIEW-->\r
+<!--BEGIN !GENERATE_TREEVIEW-->\r
+ <hr class="footer"/>\r
+ <div class="footer">\r
+ <span style="float: left;">\r
+ $generatedby\r
+ <a href="http://www.doxygen.org/index.html">\r
+ <img class="footer" src="$relpath$doxygen.png" alt="doxygen"/>\r
+ </a>\r
+ $doxygenversion\r
+ </span>\r
+\r
+ <span style="margin-right: 20px; float: right;">\r
+ <a href="http://www.lufa-lib.org" title="LUFA Project Page">LUFA Project Page</a> | <a href="http://www.lufa-lib.org/support" title="LUFA Support List">Support Mailing List</a> | <a href="http://www.lufa-lib.org/donate" title="Donate to Support LUFA">Donate</a> | <a href="http://www.fourwalledcubicle.com" title="Four Walled Cubicle Website">Four Walled Cubicle</a> - LUFA, the Lightweight USB Framework for AVRs\r
+ </span>\r
+ </div>\r
+<!--END !GENERATE_TREEVIEW-->\r
+ </body>\r
+</html>
\ No newline at end of file
--- /dev/null
+@media print\r
+ {\r
+ #top\r
+ {\r
+ display:none;\r
+ }\r
+\r
+ #side-nav\r
+ {\r
+ display:none;\r
+ }\r
+\r
+ #nav-path\r
+ {\r
+ display:none;\r
+ }\r
+\r
+ body\r
+ {\r
+ overflow:visible;\r
+ }\r
+\r
+ h1,h2,h3,h4,h5,h6\r
+ {\r
+ page-break-after:avoid;\r
+ }\r
+\r
+ .summary\r
+ {\r
+ display:none;\r
+ }\r
+\r
+ .memitem\r
+ {\r
+ page-break-inside:avoid;\r
+ }\r
+\r
+ #doc-content\r
+ {\r
+ display:inline;\r
+ height:auto !important;\r
+ margin-left:0 !important;\r
+ overflow:inherit;\r
+ width:auto !important;\r
+ }\r
+ \r
+ .fragment\r
+ {\r
+ background-color: #FFFFFF !important;\r
+ } \r
+}\r
+\r
+body,table,div,p,dl\r
+{\r
+ font-family:Lucida Grande, Verdana, Geneva, Arial, sans-serif;\r
+ font-size:13px;\r
+ line-height:1.3;\r
+}\r
+\r
+div.contents p\r
+{\r
+ padding-left:12px;\r
+}\r
+\r
+div.contents table.memberdecls,.paramname\r
+{\r
+ font-family:Consolas, Monaco, courier, sans-serif;\r
+ font-size:105%;\r
+ padding-right:20px;\r
+}\r
+\r
+.title\r
+{\r
+ font-size:150%;\r
+ font-weight:bold;\r
+ margin:10px 2px;\r
+}\r
+\r
+h1\r
+{\r
+ font-size:25px;\r
+ margin-bottom:10px;\r
+}\r
+\r
+h2\r
+{\r
+ color:#42657B;\r
+ font-family:Lucida Grande, Verdana, Geneva, Arial, sans-serif;\r
+ font-size:17px;\r
+}\r
+\r
+h3\r
+{\r
+ font-family:Lucida Grande, Verdana, Geneva, Arial, sans-serif;\r
+ font-size:15px;\r
+}\r
+\r
+h4\r
+{\r
+ font-family:Lucida Grande, Verdana, Geneva, Arial, sans-serif;\r
+ font-size:13px;\r
+}\r
+\r
+dt\r
+{\r
+ font-weight:bold;\r
+}\r
+\r
+div.multicol\r
+{\r
+ -moz-column-count:3px;\r
+ -moz-column-gap:1em;\r
+ -webkit-column-count:3px;\r
+ -webkit-column-gap:1em;\r
+}\r
+\r
+p.startli,p.startdd,p.starttd\r
+{\r
+ margin-top:2px;\r
+}\r
+\r
+p.endli\r
+{\r
+ margin-bottom:0;\r
+}\r
+\r
+p.enddd\r
+{\r
+ margin-bottom:4px;\r
+}\r
+\r
+p.endtd\r
+{\r
+ margin-bottom:2px;\r
+}\r
+\r
+caption\r
+{\r
+ font-weight:bold;\r
+}\r
+\r
+span.legend\r
+{\r
+ font-size:70%;\r
+ text-align:center;\r
+}\r
+\r
+h3.version\r
+{\r
+ font-size:90%;\r
+ text-align:center;\r
+}\r
+\r
+div.qindex,div.navtab\r
+{\r
+ background-color:#EAEFF7;\r
+ border:1px solid #9EB3DC;\r
+ text-align:center;\r
+}\r
+\r
+div.qindex,div.navpath\r
+{\r
+ line-height:140%;\r
+ width:100%;\r
+}\r
+\r
+div.navtab\r
+{\r
+ margin-right:15px;\r
+}\r
+\r
+a\r
+{\r
+ color:#355594;\r
+ font-weight:normal;\r
+ text-decoration:none;\r
+}\r
+\r
+.contents a:visited\r
+{\r
+ color:#3D62AB;\r
+}\r
+\r
+a:hover\r
+{\r
+ text-decoration:underline;\r
+}\r
+\r
+a.qindex\r
+{\r
+ font-weight:bold;\r
+}\r
+\r
+a.qindexHL\r
+{\r
+ background-color:#97ADD9;\r
+ border:1px double #7F9BD1;\r
+ color:#ffffff;\r
+ font-weight:bold;\r
+}\r
+\r
+.contents a.qindexHL:visited\r
+{\r
+ color:#ffffff;\r
+}\r
+\r
+a.el\r
+{\r
+ font-weight:bold;\r
+}\r
+\r
+a.code,a.code:visited\r
+{\r
+ color:#4665A2;\r
+}\r
+\r
+a.codeRef,a.codeRef:visited\r
+{\r
+ color:#4665A2;\r
+}\r
+\r
+dl.el\r
+{\r
+ margin-left:-1cm;\r
+}\r
+\r
+pre.fragment {\r
+ border: 1px solid #C4CFE5;\r
+ background-color: #FBFCFD;\r
+ padding: 4px 6px;\r
+ margin: 4px 8px 4px 2px;\r
+ overflow: auto;\r
+ word-wrap: break-word;\r
+ font-size: 9pt;\r
+ line-height: 125%;\r
+ font-family: monospace, fixed;\r
+ font-size: 105%;\r
+}\r
+\r
+div.fragment {\r
+ padding: 4px;\r
+ margin: 4px;\r
+ background-color: #FBFCFD;\r
+ border: 1px solid #C4CFE5;\r
+}\r
+\r
+div.line {\r
+ font-family: monospace, fixed;\r
+ font-size: 13px;\r
+ min-height: 13px;\r
+ line-height: 1.0;\r
+ text-wrap: unrestricted;\r
+ white-space: -moz-pre-wrap; /* Moz */\r
+ white-space: -pre-wrap; /* Opera 4-6 */\r
+ white-space: -o-pre-wrap; /* Opera 7 */\r
+ white-space: pre-wrap; /* CSS3 */\r
+ word-wrap: break-word; /* IE 5.5+ */\r
+ text-indent: -53px;\r
+ padding-left: 53px;\r
+ padding-bottom: 0px;\r
+ margin: 0px;\r
+}\r
+\r
+span.lineno {\r
+ padding-right: 4px;\r
+ text-align: right;\r
+ border-right: 2px solid #0F0;\r
+ background-color: #E8E8E8;\r
+ white-space: pre;\r
+}\r
+span.lineno a {\r
+ background-color: #D8D8D8;\r
+}\r
+\r
+span.lineno a:hover {\r
+ background-color: #C8C8C8;\r
+}\r
+\r
+div.ah\r
+{\r
+ -moz-border-radius:.5em;\r
+ -moz-box-shadow:rgba(0, 0, 0, 0.15) 2px 2px 2px;\r
+ -webkit-border-radius:.5em;\r
+ -webkit-box-shadow:2px 2px 3px #999;\r
+ background-color:black;\r
+ background-image:0;\r
+ border:solid thin #333;\r
+ border-radius:0.5em;\r
+ box-shadow:2px 2px 3px #999;\r
+ color:#ffffff;\r
+ font-weight:bold;\r
+ margin-bottom:3px;\r
+ margin-top:3px;\r
+ padding:0.2em;\r
+}\r
+\r
+div.groupHeader\r
+{\r
+ font-weight:bold;\r
+ margin-left:16px;\r
+ margin-top:12px;\r
+}\r
+\r
+div.groupText\r
+{\r
+ font-style:italic;\r
+ margin-left:16px;\r
+}\r
+\r
+body\r
+{\r
+ background-color:white;\r
+ color:black;\r
+ margin:0;\r
+}\r
+\r
+div.contents\r
+{\r
+ margin-left:8px;\r
+ margin-right:8px;\r
+ margin-top:10px;\r
+}\r
+\r
+td.indexkey\r
+{\r
+ background-color:#EAEFF7;\r
+ border:1px solid #C1CEE8;\r
+ font-weight:bold;\r
+ margin:2px 0;\r
+ padding:2px 10px;\r
+ vertical-align:top;\r
+ white-space:nowrap;\r
+}\r
+\r
+td.indexvalue\r
+{\r
+ background-color:#EAEFF7;\r
+ border:1px solid #C1CEE8;\r
+ margin:2px 0;\r
+ padding:2px 10px;\r
+}\r
+\r
+tr.memlist\r
+{\r
+ background-color:#EDF1F8;\r
+}\r
+\r
+p.formulaDsp\r
+{\r
+ text-align:center;\r
+}\r
+\r
+img.formulaInl\r
+{\r
+ vertical-align:middle;\r
+}\r
+\r
+div.center\r
+{\r
+ margin-bottom:0;\r
+ margin-top:0;\r
+ padding:0;\r
+ text-align:center;\r
+}\r
+\r
+div.center img\r
+{\r
+ border:0;\r
+}\r
+\r
+address.footer\r
+{\r
+ padding-right:12px;\r
+ text-align:right;\r
+}\r
+\r
+img.footer\r
+{\r
+ border:0;\r
+ vertical-align:middle;\r
+}\r
+\r
+span.keyword\r
+{\r
+ color:#008000;\r
+}\r
+\r
+span.keywordtype\r
+{\r
+ color:#604020;\r
+}\r
+\r
+span.keywordflow\r
+{\r
+ color:#e08000;\r
+}\r
+\r
+span.comment\r
+{\r
+ color:#008000;\r
+}\r
+\r
+span.preprocessor\r
+{\r
+ color:#806020;\r
+}\r
+\r
+span.stringliteral\r
+{\r
+ color:#002080;\r
+}\r
+\r
+span.charliteral\r
+{\r
+ color:#008080;\r
+}\r
+\r
+span.vhdldigit\r
+{\r
+ color:#ff00ff;\r
+}\r
+\r
+span.vhdlchar\r
+{\r
+ color:#000000;\r
+}\r
+\r
+span.vhdlkeyword\r
+{\r
+ color:#700070;\r
+}\r
+\r
+span.vhdllogic\r
+{\r
+ color:#ff0000;\r
+}\r
+\r
+blockquote\r
+{\r
+ background-color:#F6F8FC;\r
+ border-left:2px solid #97ADD9;\r
+ margin:0 24px 0 4px;\r
+ padding:0 12px 0 16px;\r
+}\r
+\r
+td.tiny\r
+{\r
+ font-size:75%;\r
+}\r
+\r
+.dirtab\r
+{\r
+ border:1px solid #9EB3DC;\r
+ border-collapse:collapse;\r
+ padding:4px;\r
+}\r
+\r
+th.dirtab\r
+{\r
+ background:#EAEFF7;\r
+ font-weight:bold;\r
+}\r
+\r
+hr\r
+{\r
+ border:none;\r
+ border-top:1px solid #4067B4;\r
+ height:0;\r
+}\r
+\r
+hr.footer\r
+{\r
+ height:1px;\r
+}\r
+\r
+table.memberdecls\r
+{\r
+ border-spacing:0;\r
+ padding:0;\r
+}\r
+\r
+.mdescLeft,.mdescRight,.memItemLeft,.memItemRight,.memTemplItemLeft,.memTemplItemRight,.memTemplParams\r
+{\r
+ background-color:#F9FAFC;\r
+ border:none;\r
+ margin:4px;\r
+ padding:1px 0 0 8px;\r
+}\r
+\r
+.mdescLeft,.mdescRight\r
+{\r
+ color:#555;\r
+ padding:0 8px 4px;\r
+}\r
+\r
+.memItemLeft,.memItemRight,.memTemplParams\r
+{\r
+ border-top:1px solid #C1CEE8;\r
+}\r
+\r
+.memItemLeft,.memTemplItemLeft\r
+{\r
+ white-space:nowrap;\r
+}\r
+\r
+.memItemRight\r
+{\r
+ width:100%;\r
+}\r
+\r
+.memTemplParams\r
+{\r
+ color:#3D62AB;\r
+ white-space:nowrap;\r
+}\r
+\r
+.memtemplate\r
+{\r
+ color:#3D62AB;\r
+ font-size:80%;\r
+ font-weight:normal;\r
+ margin-left:9px;\r
+}\r
+\r
+.memnav\r
+{\r
+ background-color:#EAEFF7;\r
+ border:1px solid #9EB3DC;\r
+ margin:2px 15px 2px 2px;\r
+ padding:2px;\r
+ text-align:center;\r
+}\r
+\r
+.mempage\r
+{\r
+ width:100%;\r
+}\r
+\r
+.memitem\r
+{\r
+ margin-bottom:10px;\r
+ margin-right:5px;\r
+ padding:0;\r
+}\r
+\r
+.memname\r
+{\r
+ font-weight:bold;\r
+ margin-left:6px;\r
+ white-space:nowrap;\r
+}\r
+\r
+.memproto,dl.reflist dt\r
+{\r
+ -moz-border-radius-topleft:8px;\r
+ -moz-border-radius-topright:8px;\r
+ -moz-box-shadow:rgba(0, 0, 0, 0.15) 5px 5px 5px;\r
+ -webkit-border-top-left-radius:8px;\r
+ -webkit-border-top-right-radius:8px;\r
+ -webkit-box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15);\r
+ background-color:#E1E7F4;\r
+ background-image:url('nav_f.png');\r
+ background-repeat:repeat-x;\r
+ border-left:1px solid #A3B7DE;\r
+ border-right:1px solid #A3B7DE;\r
+ border-top:1px solid #A3B7DE;\r
+ border-top-left-radius:8px;\r
+ border-top-right-radius:8px;\r
+ box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15);\r
+ color:#20335A;\r
+ font-weight:bold;\r
+ padding:6px 0;\r
+ text-shadow:0 1px 1px rgba(255, 255, 255, 0.9);\r
+}\r
+\r
+.memdoc,dl.reflist dd\r
+{\r
+ -moz-border-radius-bottomleft:8px;\r
+ -moz-border-radius-bottomright:8px;\r
+ -moz-box-shadow:rgba(0, 0, 0, 0.15) 5px 5px 5px;\r
+ -webkit-border-bottom-left-radius:8px;\r
+ -webkit-border-bottom-right-radius:8px;\r
+ -webkit-box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15);\r
+ background-color:#FBFCFD;\r
+ background-image:0 color-stop(0.6,#FFFFFF), color-stop(0.60,#FFFFFF), color-stop(0.95,#F6F8FC), to(#EDF1F8));\r
+ border-bottom:1px solid #A3B7DE;\r
+ border-bottom-left-radius:8px;\r
+ border-bottom-right-radius:8px;\r
+ border-left:1px solid #A3B7DE;\r
+ border-right:1px solid #A3B7DE;\r
+ border-top-width:0;\r
+ box-shadow:5px 5px 5px rgba(0, 0, 0, 0.15);\r
+ padding:2px 5px;\r
+}\r
+\r
+dl.reflist dt\r
+{\r
+ padding:5px;\r
+}\r
+\r
+dl.reflist dd\r
+{\r
+ margin:0 0 10px;\r
+ padding:5px;\r
+}\r
+\r
+.paramkey\r
+{\r
+ text-align:right;\r
+}\r
+\r
+.paramtype\r
+{\r
+ white-space:nowrap;\r
+}\r
+\r
+.paramname\r
+{\r
+ color:#602020;\r
+ white-space:nowrap;\r
+}\r
+\r
+.paramname em\r
+{\r
+ font-style:normal;\r
+}\r
+\r
+.params,.retval,.exception,.tparams\r
+{\r
+ border-spacing:6px 2px;\r
+}\r
+\r
+.params .paramname,.retval .paramname\r
+{\r
+ font-weight:bold;\r
+ vertical-align:top;\r
+}\r
+\r
+.params .paramtype\r
+{\r
+ font-style:italic;\r
+ vertical-align:top;\r
+}\r
+\r
+.params .paramdir\r
+{\r
+ font-family:"courier new",courier,monospace;\r
+ vertical-align:top;\r
+}\r
+\r
+.ftvtree\r
+{\r
+ font-family:sans-serif;\r
+ margin:0;\r
+}\r
+\r
+.directory\r
+{\r
+ font-size:9pt;\r
+ font-weight:bold;\r
+ margin:5px;\r
+}\r
+\r
+.directory h3\r
+{\r
+ font-size:11pt;\r
+ margin:1em 0 0;\r
+}\r
+\r
+.directory > h3\r
+{\r
+ margin-top:0;\r
+}\r
+\r
+.directory p\r
+{\r
+ margin:0;\r
+ white-space:nowrap;\r
+}\r
+\r
+.directory div\r
+{\r
+ display:none;\r
+ margin:0;\r
+}\r
+\r
+.directory img\r
+{\r
+ vertical-align:-30%;\r
+}\r
+\r
+.directory-alt\r
+{\r
+ font-size:100%;\r
+ font-weight:bold;\r
+}\r
+\r
+.directory-alt h3\r
+{\r
+ font-size:11pt;\r
+ margin:1em 0 0;\r
+}\r
+\r
+.directory-alt > h3\r
+{\r
+ margin-top:0;\r
+}\r
+\r
+.directory-alt p\r
+{\r
+ margin:0;\r
+ white-space:nowrap;\r
+}\r
+\r
+.directory-alt div\r
+{\r
+ display:none;\r
+ margin:0;\r
+}\r
+\r
+.directory-alt img\r
+{\r
+ vertical-align:-30%;\r
+}\r
+\r
+div.dynheader\r
+{\r
+ margin-top:8px;\r
+}\r
+\r
+address\r
+{\r
+ color:#253B67;\r
+ font-style:normal;\r
+}\r
+\r
+table.doxtable\r
+{\r
+ border-collapse:collapse;\r
+ margin-bottom:4px;\r
+ margin-top:4px;\r
+}\r
+\r
+table.doxtable td,table.doxtable th\r
+{\r
+ border:1px solid #273F6D;\r
+ padding:3px 7px 2px;\r
+}\r
+\r
+table.doxtable th\r
+{\r
+ background-color:#304D86;\r
+ color:#FFFFFF;\r
+ font-size:110%;\r
+ padding-bottom:4px;\r
+ padding-top:5px;\r
+}\r
+\r
+table.fieldtable\r
+{\r
+ -moz-border-radius:4px;\r
+ -moz-box-shadow:rgba(0, 0, 0, 0.15) 2px 2px 2px;\r
+ -webkit-border-radius:4px;\r
+ -webkit-box-shadow:2px 2px 2px rgba(0, 0, 0, 0.15);\r
+ border:1px solid #A3B7DE;\r
+ border-radius:4px;\r
+ border-spacing:0;\r
+ box-shadow:2px 2px 2px rgba(0, 0, 0, 0.15);\r
+ margin-bottom:10px;\r
+ width:100%;\r
+}\r
+\r
+.fieldtable td,.fieldtable th\r
+{\r
+ padding:3px 7px 2px;\r
+}\r
+\r
+.fieldtable td.fieldtype,.fieldtable td.fieldname\r
+{\r
+ border-bottom:1px solid #A3B7DE;\r
+ border-right:1px solid #A3B7DE;\r
+ vertical-align:top;\r
+ white-space:nowrap;\r
+}\r
+\r
+.fieldtable td.fielddoc\r
+{\r
+ border-bottom:1px solid #A3B7DE;\r
+ width:100%;\r
+}\r
+\r
+.fieldtable tr:last-child td\r
+{\r
+ border-bottom:none;\r
+}\r
+\r
+.fieldtable th\r
+{\r
+ -moz-border-radius-topleft:4px;\r
+ -moz-border-radius-topright:4px;\r
+ -webkit-border-top-left-radius:4px;\r
+ -webkit-border-top-right-radius:4px;\r
+ background-color:#E1E7F4;\r
+ background-image:url('nav_f.png');\r
+ background-repeat:repeat-x;\r
+ border-bottom:1px solid #A3B7DE;\r
+ border-top-left-radius:4px;\r
+ border-top-right-radius:4px;\r
+ color:#20335A;\r
+ font-size:90%;\r
+ padding-bottom:4px;\r
+ padding-top:5px;\r
+ text-align:left;\r
+}\r
+\r
+.tabsearch\r
+{\r
+ background-image:url('tab_b.png');\r
+ font-size:13px;\r
+ height:36px;\r
+ left:10px;\r
+ overflow:hidden;\r
+ top:0;\r
+ z-index:101;\r
+}\r
+\r
+.navpath ul\r
+{\r
+ background-image:url('tab_b.png');\r
+ background-repeat:repeat-x;\r
+ border:solid 1px #BFCCE8;\r
+ color:#839ED2;\r
+ font-size:11px;\r
+ height:30px;\r
+ line-height:30px;\r
+ margin:0;\r
+ overflow:hidden;\r
+ padding:0;\r
+}\r
+\r
+.navpath li\r
+{\r
+ background-image:url('bc_s.png');\r
+ background-position:right;\r
+ background-repeat:no-repeat;\r
+ color:#2F4B83;\r
+ float:left;\r
+ list-style-type:none;\r
+ padding-left:10px;\r
+ padding-right:15px;\r
+}\r
+\r
+.navpath li.navelem a\r
+{\r
+ display:block;\r
+ height:32px;\r
+ outline:none;\r
+ text-decoration:none;\r
+}\r
+\r
+.navpath li.navelem a:hover\r
+{\r
+ color:#6081C5;\r
+}\r
+\r
+.navpath li.footer\r
+{\r
+ background-image:none;\r
+ background-position:right;\r
+ background-repeat:no-repeat;\r
+ color:#2F4B83;\r
+ float:right;\r
+ font-size:8pt;\r
+ list-style-type:none;\r
+ padding-left:10px;\r
+ padding-right:15px;\r
+}\r
+\r
+div.summary\r
+{\r
+ float:right;\r
+ font-size:8pt;\r
+ padding-right:5px;\r
+ text-align:right;\r
+ width:50%;\r
+}\r
+\r
+div.summary a\r
+{\r
+ white-space:nowrap;\r
+}\r
+\r
+div.ingroups\r
+{\r
+ font-size:8pt;\r
+ margin-left:5px;\r
+ padding-left:5px;\r
+ text-align:left;\r
+ width:50%;\r
+}\r
+\r
+div.ingroups a\r
+{\r
+ white-space:nowrap;\r
+}\r
+\r
+div.header\r
+{\r
+ background-color:#F9FAFC;\r
+ background-image:url('nav_h.png');\r
+ background-repeat:repeat-x;\r
+ border-bottom:1px solid #C1CEE8;\r
+ margin:0;\r
+}\r
+\r
+div.headertitle\r
+{\r
+ padding:5px 5px 5px 7px;\r
+}\r
+\r
+dl\r
+{\r
+ padding:0 0 0 10px;\r
+}\r
+\r
+dl.section\r
+{\r
+ border-left:4px solid;\r
+ padding:0 0 0 6px;\r
+}\r
+\r
+dl.note\r
+{\r
+ border-color:#D0C000;\r
+}\r
+\r
+dl.warning,dl.attention\r
+{\r
+ border-color:#FF0000;\r
+}\r
+\r
+dl.pre,dl.post,dl.invariant\r
+{\r
+ border-color:#00D000;\r
+}\r
+\r
+dl.deprecated\r
+{\r
+ border-color:#505050;\r
+}\r
+\r
+dl.todo\r
+{\r
+ border-color:#00C0E0;\r
+}\r
+\r
+dl.test\r
+{\r
+ border-color:#3030E0;\r
+}\r
+\r
+dl.bug\r
+{\r
+ border-color:#C08050;\r
+}\r
+\r
+dl.section dd\r
+{\r
+ margin-bottom:6px;\r
+}\r
+\r
+#projectlogo\r
+{\r
+ border-collapse:separate;\r
+ text-align:center;\r
+ vertical-align:bottom;\r
+ padding-left: 20px;\r
+}\r
+\r
+#projectlogo img\r
+{\r
+ border:0 none;\r
+}\r
+\r
+#projectname\r
+{\r
+ font:280% Arial, sans-serif;\r
+ margin:0;\r
+ padding-left:20px;\r
+}\r
+\r
+#projectbrief\r
+{\r
+ font:120% Tahoma, Arial, sans-serif;\r
+ margin:0;\r
+ padding:0;\r
+}\r
+\r
+#projectnumber:before\r
+{\r
+ content:"Version ";\r
+}\r
+\r
+#projectnumber\r
+{\r
+ font:50% Tahoma, Arial, sans-serif;\r
+ margin:0;\r
+ padding:0;\r
+}\r
+\r
+#titlearea\r
+{\r
+ margin:0;\r
+ padding:0;\r
+ width:100%;\r
+ background-color:#E1E7F4;\r
+ background-image:url('nav_f.png');\r
+ background-repeat:repeat-x;\r
+ color:#20335A;\r
+ font-weight:bold;\r
+ text-shadow:0 1px 1px rgba(255, 255, 255, 0.9);\r
+}\r
+\r
+.image\r
+{\r
+ text-align:center;\r
+}\r
+\r
+.dotgraph\r
+{\r
+ text-align:center;\r
+}\r
+\r
+.mscgraph\r
+{\r
+ text-align:center;\r
+}\r
+\r
+.caption\r
+{\r
+ font-weight:bold;\r
+}\r
+\r
+div.zoom\r
+{\r
+ border:1px solid #8AA3D4;\r
+}\r
+\r
+dl.citelist\r
+{\r
+ margin-bottom:50px;\r
+}\r
+\r
+dl.citelist dt\r
+{\r
+ color:#2C477C;\r
+ float:left;\r
+ font-weight:bold;\r
+ margin-right:10px;\r
+ padding:5px;\r
+}\r
+\r
+dl.citelist dd\r
+{\r
+ margin:2px 0;\r
+ padding:5px 0;\r
+}\r
+\r
+div.toc\r
+{\r
+ background-color:#F4F6FB;\r
+ border:1px solid #D6DFF0;\r
+ border-radius:7px 7px 7px 7px;\r
+ float:right;\r
+ height:auto;\r
+ margin:0 20px 10px 10px;\r
+ padding:14px 25px;\r
+ width:200px;\r
+}\r
+\r
+div.toc li\r
+{\r
+ background:url("bdwn.png") no-repeat scroll 0 5px transparent;\r
+ font:10px/1.2 Verdana,DejaVu Sans,Geneva,sans-serif;\r
+ margin-top:5px;\r
+ padding-left:10px;\r
+ padding-top:2px;\r
+}\r
+\r
+div.toc h3\r
+{\r
+ border-bottom:0 none;\r
+ color:#3D62AB;\r
+ font:bold 12px/1.2 Arial,FreeSans,sans-serif;\r
+ margin:0;\r
+}\r
+\r
+div.toc ul\r
+{\r
+ border:medium none;\r
+ list-style:none outside none;\r
+ padding:0;\r
+}\r
+\r
+div.toc li.level1\r
+{\r
+ margin-left:0;\r
+}\r
+\r
+div.toc li.level2\r
+{\r
+ margin-left:15px;\r
+}\r
+\r
+div.toc li.level3\r
+{\r
+ margin-left:30px;\r
+}\r
+\r
+div.toc li.level4\r
+{\r
+ margin-left:45px;\r
+}\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_VIDPID VID and PID values\r
+ *\r
+ * \section Sec_VIDPID_Allocations VID and PID Allocations\r
+ * The LUFA library uses VID/PID combinations generously donated by Atmel. The following VID/PID combinations\r
+ * are used within the LUFA demos, and thus may be re-used by derivations of each demo. Free PID values may be\r
+ * used by future LUFA demo projects.\r
+ *\r
+ * <b>These VID/PID values should not be used in commercial designs under any circumstances.</b> Private projects\r
+ * may use the following values freely, but must accept any collisions due to other LUFA derived private projects\r
+ * sharing identical values. It is suggested that private projects using interfaces compatible with existing\r
+ * demos share the same VID/PID value.\r
+ *\r
+ * <table>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * <b>VID</b>\r
+ * </td>\r
+ * <td>\r
+ * <b>PID</b>\r
+ * </td>\r
+ * <td>\r
+ * <b>Usage</b>\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2040\r
+ * </td>\r
+ * <td>\r
+ * Test VID/PID (See below)\r
+ * </td>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2041\r
+ * </td>\r
+ * <td>\r
+ * Mouse Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2042\r
+ * </td>\r
+ * <td>\r
+ * Keyboard Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2043\r
+ * </td>\r
+ * <td>\r
+ * Joystick Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2044\r
+ * </td>\r
+ * <td>\r
+ * CDC Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2045\r
+ * </td>\r
+ * <td>\r
+ * Mass Storage Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2046\r
+ * </td>\r
+ * <td>\r
+ * Audio Output Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2047\r
+ * </td>\r
+ * <td>\r
+ * Audio Input Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2048\r
+ * </td>\r
+ * <td>\r
+ * MIDI Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2049\r
+ * </td>\r
+ * <td>\r
+ * MagStripe Project\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x204A\r
+ * </td>\r
+ * <td>\r
+ * CDC Bootloader\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x204B\r
+ * </td>\r
+ * <td>\r
+ * USB to Serial Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x204C\r
+ * </td>\r
+ * <td>\r
+ * RNDIS Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x204D\r
+ * </td>\r
+ * <td>\r
+ * Combined Keyboard and Mouse Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x204E\r
+ * </td>\r
+ * <td>\r
+ * Dual CDC Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x204F\r
+ * </td>\r
+ * <td>\r
+ * Generic HID Demo Application\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2060\r
+ * </td>\r
+ * <td>\r
+ * Benito Programmer Project\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2061\r
+ * </td>\r
+ * <td>\r
+ * Combined Mass Storage and Keyboard Demo\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2062\r
+ * </td>\r
+ * <td>\r
+ * Combined CDC and Mouse Demo\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2063\r
+ * </td>\r
+ * <td>\r
+ * Mass Storage/HID Interface Datalogger Project\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2064\r
+ * </td>\r
+ * <td>\r
+ * Interfaceless Control-Only LUFA Devices\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2065\r
+ * </td>\r
+ * <td>\r
+ * Test and Measurement Demo\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2066\r
+ * </td>\r
+ * <td>\r
+ * Multiple Report Keyboard/Mouse HID Demo\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2067\r
+ * </td>\r
+ * <td>\r
+ * HID Class Bootloader\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2068\r
+ * </td>\r
+ * <td>\r
+ * Virtual Serial/Mass Storage Demo\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x2069\r
+ * </td>\r
+ * <td>\r
+ * Webserver Project\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x206A\r
+ * </td>\r
+ * <td>\r
+ * Media Control Project\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x206B\r
+ * </td>\r
+ * <td>\r
+ * <i>Currently Unallocated</i>\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x206C\r
+ * </td>\r
+ * <td>\r
+ * <i>Currently Unallocated</i>\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x206D\r
+ * </td>\r
+ * <td>\r
+ * <i>Currently Unallocated</i>\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x206E\r
+ * </td>\r
+ * <td>\r
+ * <i>Currently Unallocated</i>\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * <tr>\r
+ * <td>\r
+ * 0x03EB\r
+ * </td>\r
+ * <td>\r
+ * 0x206F\r
+ * </td>\r
+ * <td>\r
+ * <i>Currently Unallocated</i>\r
+ * </td>\r
+ * </tr>\r
+ *\r
+ * </table>\r
+ *\r
+ * \section Sec_Test_VIDPID The Test VID/PID Combination\r
+ * For use in testing of LUFA powered devices during development only, by non-commercial entities.\r
+ * All devices must accept collisions on this VID/PID range (from other in-development LUFA devices)\r
+ * to be resolved by using a unique release number in the Device Descriptor. No devices using this\r
+ * VID/PID combination may be released to the general public.\r
+ */\r
+\r
--- /dev/null
+/** \file\r
+ *\r
+ * This file contains special DoxyGen information for the generation of the main page and other special\r
+ * documentation pages. It is not a project source file.\r
+ */\r
+\r
+/** \page Page_WritingBoardDrivers Writing LUFA Board Drivers\r
+ *\r
+ * LUFA ships with several basic pre-made board drivers, to control hardware present on the supported board\r
+ * hardware - such as Dataflash ICs, LEDs, Joysticks, or other hardware peripherals. When compiling an application\r
+ * which makes use of one or more board drivers located in LUFA/Drivers/Board, you must also indicate what board\r
+ * hardware you are using in your project makefile. This is done by defining the BOARD macro using the -D switch\r
+ * passed to the compiler, with a constant of BOARD_{Name}. For example <b>-DBOARD=BOARD_USBKEY</b> instructs the\r
+ * compiler to use the USBKEY board hardware drivers.\r
+ *\r
+ * If your application does not use *any* board level drivers, you can omit the definition of the BOARD macro.\r
+ * However, some users may wish to write their own custom board hardware drivers which are to remain compatible\r
+ * with the LUFA hardware API. To do this, the BOARD macro should be defined to the value BOARD_USER. This indicates\r
+ * that the board level drivers should be located in a folder named "Board" located inside the application's folder.\r
+ *\r
+ * When used, the driver stub files located in the LUFA/CodeTemplates/DriverStubs folder should be copied to the user\r
+ * Board/ directory, and fleshed out to include the values and code needed to control the custom board hardware. Once\r
+ * done, the existing LUFA board level APIs (accessed in the regular LUFA/Drivers/Board/ folder) will redirect to the\r
+ * user board drivers, maintaining code compatibility and allowing for a different board to be selected through the\r
+ * project makefile with no code changes.\r
+ */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Adafruit U4 Breakout board.\r
+ * \copydetails Group_LEDs_ADAFRUITU4\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_ADAFRUITU4 ADAFRUITU4\r
+ * \brief Board specific LED driver header for the Adafruit U4 Breakout board.\r
+ *\r
+ * Board specific LED driver header for the Adafruit U4 Breakout board (http://ladyada.net/products/atmega32u4breakout).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTE.6</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_ADAFRUITU4_H__\r
+#define __LEDS_ADAFRUITU4_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 6)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS LEDS_LED1\r
+\r
+ /** LED mask for the none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRE |= LEDS_ALL_LEDS;\r
+ PORTE &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRE &= ~LEDS_ALL_LEDS;\r
+ PORTE &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTE |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTE &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTE = ((PORTE & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTE = ((PORTE & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINE = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTE & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Atmel ATAVRUSBRF01.\r
+ * \copydetails Group_Buttons_ATAVRUSBRF01\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_ATAVRUSBRF01 ATAVRUSBRF01\r
+ * \brief Board specific Buttons driver header for the Atmel ATAVRUSBRF01.\r
+ *\r
+ * Board specific Buttons driver header for the Atmel ATAVRUSBRF01.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_ATAVRUSBRF01_H__\r
+#define __BUTTONS_ATAVRUSBRF01_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Atmel ATAVRUSBRF01.\r
+ * \copydetails Group_LEDs_ATAVRUSBRF01\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_ATAVRUSBRF01 ATAVRUSBRF01\r
+ * \brief Board specific LED driver header for the Atmel ATAVRUSBRF01.\r
+ *\r
+ * Board specific LED driver header for the Atmel ATAVRUSBRF01.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>RX LED</td><td>High</td><td>PORTD.0</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Red</td><td>TX LED</td><td>High</td><td>PORTD.1</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_ATAVRUSBRF01_H__\r
+#define __LEDS_ATAVRUSBRF01_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 0)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 1)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= (LEDMask & LEDS_ALL_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~(LEDMask & LEDS_ALL_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = (PORTD & ~LEDS_ALL_LEDS) | (LEDMask & LEDS_ALL_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Tempusdictum Benito.\r
+ * \copydetails Group_Buttons_BENITO\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_BENITO BENITO\r
+ * \brief Board specific Buttons driver header for the Tempusdictum Benito.\r
+ *\r
+ * Board specific Buttons driver header for the Tempusdictum Benito (http://dorkbotpdx.org/wiki/benito).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_BENITO_H__\r
+#define __BUTTONS_BENITO_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Tempusdictum Benito.\r
+ * \copydetails Group_LEDs_BENITO\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_BENITO BENITO\r
+ * \brief Board specific LED driver header for the Tempusdictum Benito.\r
+ *\r
+ * Board specific LED driver header for the Tempusdictum Benito (http://dorkbotpdx.org/wiki/benito).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>TX LED</td><td>Low</td><td>PORTC.7</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Red</td><td>RX LED</td><td>Low</td><td>PORTC.6</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_BENITO_H__\r
+#define __LEDS_BENITO_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 7)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 6)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRC |= LEDS_ALL_LEDS;\r
+ PORTC |= LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRC &= ~LEDS_ALL_LEDS;\r
+ PORTC &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTC &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTC |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTC = ((PORTC | LEDS_ALL_LEDS) & ~LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTC = ((PORTC | LEDMask) & ~ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINC = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTC & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Bitwizard Big-Multio.\r
+ * \copydetails Group_LEDs_BIGMULTIO\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_BIGMULTIO BIGMULTIO\r
+ * \brief Board specific LED driver header for the Bitwizard Big-Multio.\r
+ *\r
+ * Board specific LED driver header for the Bitwizard Big-Multio (http://www.bitwizard.nl/wiki/index.php/Usbbigmultio).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Unknown</td><td>LED0</td><td>High</td><td>PORTF.6</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Unknown</td><td>LED1</td><td>High</td><td>PORTF.7</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Unknown</td><td>LED2</td><td>High</td><td>PORTE.2</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_BIGMULTIO_H__\r
+#define __LEDS_BIGMULTIO_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define LEDS_PORTF_LEDS (LEDS_LED1 | LEDS_LED2)\r
+ #define LEDS_PORTE_LEDS LEDS_LED3\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 6)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 7)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED3 (1 << 2)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRF |= LEDS_PORTF_LEDS;\r
+ DDRE |= LEDS_PORTE_LEDS;\r
+ \r
+ PORTF &= ~LEDS_PORTF_LEDS;\r
+ PORTE &= ~LEDS_PORTE_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRF &= ~LEDS_PORTF_LEDS;\r
+ DDRE &= ~LEDS_PORTE_LEDS;\r
+ \r
+ PORTF &= ~LEDS_PORTF_LEDS;\r
+ PORTE &= ~LEDS_PORTE_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTF |= (LEDMask & LEDS_PORTF_LEDS);\r
+ PORTE |= (LEDMask & LEDS_PORTE_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTF &= ~(LEDMask & LEDS_PORTF_LEDS);\r
+ PORTE &= ~(LEDMask & LEDS_PORTE_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTF = (PORTF & ~LEDS_PORTF_LEDS) | (LEDMask & LEDS_PORTF_LEDS);\r
+ PORTE = (PORTE & ~LEDS_PORTE_LEDS) | (LEDMask & LEDS_PORTE_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTF = (PORTF & ~(LEDMask & LEDS_PORTF_LEDS)) | (ActiveMask & LEDS_PORTF_LEDS);\r
+ PORTE = (PORTE & ~(LEDMask & LEDS_PORTE_LEDS)) | (ActiveMask & LEDS_PORTE_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINF = (LEDMask & LEDS_PORTF_LEDS);\r
+ PINE = (LEDMask & LEDS_PORTE_LEDS);\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return ((PORTF & LEDS_PORTF_LEDS) | (PORTE & LEDS_PORTE_LEDS));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the BLACKCAT USB JTAG.\r
+ * \copydetails Group_LEDs_BLACKCAT\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_BLACKCAT BLACKCAT\r
+ * \brief Board specific LED driver header for the BLACKCAT USB JTAG.\r
+ *\r
+ * Board specific LED driver header for the TCNISO Blackcat USB JTAG (http://www.embeddedcomputers.net/products/BlackcatUSB).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Unknown</td><td>LED0</td><td>High</td><td>PORTD.6</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Unknown</td><td>LED1</td><td>High</td><td>PORTD.3</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_BLACKCAT_H__\r
+#define __LEDS_BLACKCAT_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 6)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 3)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Busware BUI.\r
+ * \copydetails Group_LEDs_BUI\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_BUI BUI\r
+ * \brief Board specific LED driver header for the Busware BUI.\r
+ *\r
+ * Board specific LED driver header for the Busware BUI (http://www.busware.de/tiki-index.php?page=BUI).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Red</td><td>RGB LED</td><td>High</td><td>PORTC.2</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Green</td><td>RGB LED</td><td>High</td><td>PORTC.3</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Blue</td><td>RGB LED</td><td>High</td><td>PORTC.4</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_BUI_H__\r
+#define __LEDS_BUI_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+/* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 2)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 3)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 4)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRC |= LEDS_ALL_LEDS;\r
+ PORTC &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRC &= ~LEDS_ALL_LEDS;\r
+ PORTC &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTC |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTC &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTC = (PORTC & ~LEDS_ALL_LEDS) | LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTC = (PORTC & ~LEDMask) | ActiveMask;\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINC = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTC & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Fletchtronics BUMBLEB.\r
+ * \copydetails Group_Buttons_BUMBLEB\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_BUMBLEB BUMBLEB\r
+ * \brief Board specific Buttons driver header for the Fletchtronics BUMBLEB.\r
+ *\r
+ * Board specific buttons driver header for the Fletchtronics BUMBLEB (http://fletchtronics.net/bumble-b). The BUMBLEB\r
+ * third-party board does not include any on-board peripherals, but does have an officially recommended external peripheral\r
+ * layout for buttons, LEDs and a Joystick.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_BUMBLEB_H__\r
+#define __BUTTONS_BUMBLEB_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific joystick driver header for the Fletchtronics BUMBLEB.\r
+ * \copydetails Group_Joystick_BUMBLEB\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the joystick driver\r
+ * dispatch header located in LUFA/Drivers/Board/Joystick.h.\r
+ */\r
+\r
+/** \ingroup Group_Joystick\r
+ * \defgroup Group_Joystick_BUMBLEB BUMBLEB\r
+ * \brief Board specific joystick driver header for the Fletchtronics BUMBLEB.\r
+ *\r
+ * Board specific joystick driver header for the Fletchtronics BUMBLEB (http://fletchtronics.net/bumble-b). The BUMBLEB\r
+ * third-party board does not include any on-board peripherals, but does have an officially recommended external peripheral\r
+ * layout for buttons, LEDs and a Joystick.\r
+ *\r
+ * <table>\r
+ * <tr><th>Left Port Pin</th><th>Up Port Pin</th><th>Right Port Pin</th><th>Down Port Pin</th><th>Press Port Pin</th></tr>\r
+ * <tr><td>PORTD.2</td><td>PORTD.3</td><td>PORTD.0</td><td>PORTD.1</td><td>PORTD.4</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __JOYSTICK_BUMBLEB_H__\r
+#define __JOYSTICK_BUMBLEB_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_JOYSTICK_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define JOY_MASK ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 4))\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the joystick being pushed in the left direction. */\r
+ #define JOY_LEFT (1 << 2)\r
+\r
+ /** Mask for the joystick being pushed in the upward direction. */\r
+ #define JOY_UP (1 << 3)\r
+\r
+ /** Mask for the joystick being pushed in the right direction. */\r
+ #define JOY_RIGHT (1 << 0)\r
+\r
+ /** Mask for the joystick being pushed in the downward direction. */\r
+ #define JOY_DOWN (1 << 1)\r
+\r
+ /** Mask for the joystick being pushed inward. */\r
+ #define JOY_PRESS (1 << 4)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Joystick_Init(void)\r
+ {\r
+ DDRD &= ~JOY_MASK;\r
+ PORTD |= JOY_MASK;\r
+ }\r
+\r
+ static inline void Joystick_Disable(void)\r
+ {\r
+ DDRD &= ~JOY_MASK;\r
+ PORTD &= ~JOY_MASK;\r
+ }\r
+\r
+ static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Joystick_GetStatus(void)\r
+ {\r
+ return (uint8_t)(~PIND & JOY_MASK);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Fletchtronics BUMBLEB.\r
+ * \copydetails Group_LEDs_BUMBLEB\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_BUMBLEB BUMBLEB\r
+ * \brief Board specific LED driver header for the Fletchtronics BUMBLEB.\r
+ *\r
+ * Board specific LED driver header for the Fletchtronics BUMBLEB (http://fletchtronics.net/bumble-b). The BUMBLEB\r
+ * third-party board does not include any on-board peripherals, but does have an officially recommended external\r
+ * peripheral layout for buttons, LEDs and a Joystick.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>N/A</td><td>User Supplied</td><td>High</td><td>PORTB.4</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>N/A</td><td>User Supplied</td><td>High</td><td>PORTB.5</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>N/A</td><td>User Supplied</td><td>High</td><td>PORTB.6</td></tr>\r
+ * <tr><td>LEDS_LED4</td><td>N/A</td><td>User Supplied</td><td>High</td><td>PORTB.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_BUMBLEB_H__\r
+#define __LEDS_BUMBLEB_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 5)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 6)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1 << 7)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRB |= LEDS_ALL_LEDS;\r
+ PORTB &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRB &= ~LEDS_ALL_LEDS;\r
+ PORTB &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTB |= LedMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTB &= ~LedMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTB = ((PORTB & ~LEDS_ALL_LEDS) | LedMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LedMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTB = ((PORTB & ~LedMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINB = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTB & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Busware CULV3.\r
+ * \copydetails Group_LEDs_CULV3\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_CULV3 CULV3\r
+ * \brief Board specific Buttons driver header for the Busware CULV3.\r
+ *\r
+ * Board specific Buttons driver header for the Busware CUL V3 (http://busware.de/tiki-index.php?page=CUL).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTE.2</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_CULV3_H__\r
+#define __BUTTONS_CULV3_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 2)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Busware CUL V3.\r
+ * \copydetails Group_LEDs_CULV3\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_CULV3 CULV3\r
+ * \brief Board specific LED driver header for the Busware CUL V3.\r
+ *\r
+ * Board specific LED driver header for the Busware CUL V3 (http://busware.de/tiki-index.php?page=CUL).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Yellow</td><td>General Indicator</td><td>High</td><td>PORTE.6</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_CULV3_H__\r
+#define __LEDS_CULV3_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 6)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS LEDS_LED1\r
+\r
+ /** LED mask for the none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRE |= LEDS_ALL_LEDS;\r
+ PORTE &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRE &= ~LEDS_ALL_LEDS;\r
+ PORTE &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTE |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTE &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTE = ((PORTE & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTE = ((PORTE & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINE = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTE & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the DorkbotPDX Duce.\r
+ * \copydetails Group_LEDs_DUCE\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_DUCE DUCE\r
+ * \brief Board specific LED driver header for the DorkbotPDX Duce.\r
+ *\r
+ * Board specific LED driver header for the DorkbotPDX Duce (http://dorkbotpdx.org/wiki/duce).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Red</td><td>Bicolor Indicator 1</td><td>High</td><td>PORTC.4</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Green</td><td>Bicolor Indicator 1</td><td>High</td><td>PORTC.5</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Red</td><td>Bicolor Indicator 2</td><td>High</td><td>PORTC.6</td></tr>\r
+ * <tr><td>LEDS_LED4</td><td>Green</td><td>Bicolor Indicator 2</td><td>High</td><td>PORTC.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_DUCE_H__\r
+#define __LEDS_DUCE_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 5)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 6)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1 << 7)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRC |= LEDS_ALL_LEDS;\r
+ PORTC &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRC &= ~LEDS_ALL_LEDS;\r
+ PORTC &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTC |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTC &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTC = ((PORTC & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTC = ((PORTC & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINC = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTC & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Atmel EVK527.\r
+ * \copydetails Group_Buttons_EVK527\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_EVK527 EVK527\r
+ * \brief Board specific Buttons driver header for the Atmel EVK527.\r
+ *\r
+ * Board specific Buttons driver header for the Atmel EVK527.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTE.2</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_EVK527_H__\r
+#define __BUTTONS_EVK527_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 2)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Dataflash driver header for the Atmel EVK527.\r
+ * \copydetails Group_Dataflash_EVK527\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+/** \ingroup Group_Dataflash\r
+ * \defgroup Group_Dataflash_EVK527 EVK527\r
+ * \brief Board specific Dataflash driver header for the Atmel EVK527.\r
+ *\r
+ * Board specific Dataflash driver header for the Atmel EVK527.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Select Pin</th><th>SPI Port</th></tr>\r
+ * <tr><td>DATAFLASH_CHIP1</td><td>AT45DB321C (4MB)</td><td>PORTE.6</td><td>SPI0</td></tr>\r
+ * </table> \r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __DATAFLASH_EVK527_H__\r
+#define __DATAFLASH_EVK527_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../../../Misc/AT45DB321C.h"\r
+ #include "../../../Peripheral/SPI.h"\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_DATAFLASH_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATAFLASH_CHIPCS_MASK (1 << 6)\r
+ #define DATAFLASH_CHIPCS_DDR DDRE\r
+ #define DATAFLASH_CHIPCS_PORT PORTE\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */\r
+ #define DATAFLASH_TOTALCHIPS 1\r
+\r
+ /** Mask for no dataflash chip selected. */\r
+ #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK\r
+\r
+ /** Mask for the first dataflash chip selected. */\r
+ #define DATAFLASH_CHIP1 0\r
+\r
+ /** Internal main memory page size for the board's dataflash IC. */\r
+ #define DATAFLASH_PAGE_SIZE 512\r
+\r
+ /** Total number of pages inside the board's dataflash IC. */\r
+ #define DATAFLASH_PAGES 8192\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.\r
+ * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.\r
+ */\r
+ static inline void Dataflash_Init(void)\r
+ {\r
+ DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK;\r
+ DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)\r
+ {\r
+ return SPI_TransferByte(Byte);\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ */\r
+ static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SendByte(const uint8_t Byte)\r
+ {\r
+ SPI_SendByte(Byte);\r
+ }\r
+\r
+ /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_ReceiveByte(void)\r
+ {\r
+ return SPI_ReceiveByte();\r
+ }\r
+\r
+ /** Determines the currently selected dataflash chip.\r
+ *\r
+ * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected\r
+ * or a DATAFLASH_CHIPn mask (where n is the chip number).\r
+ */\r
+ static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_GetSelectedChip(void)\r
+ {\r
+ return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK);\r
+ }\r
+\r
+ /** Selects the given dataflash chip.\r
+ *\r
+ * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is\r
+ * the chip number).\r
+ */\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask)\r
+ {\r
+ DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask);\r
+ }\r
+\r
+ /** Deselects the current dataflash chip, so that no dataflash is selected. */\r
+ static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_DeselectChip(void)\r
+ {\r
+ Dataflash_SelectChip(DATAFLASH_NO_CHIP);\r
+ }\r
+\r
+ /** Selects a dataflash IC from the given page number, which should range from 0 to\r
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one\r
+ * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside\r
+ * the total number of pages contained in the boards dataflash ICs, all dataflash ICs\r
+ * are deselected.\r
+ *\r
+ * \param[in] PageAddress Address of the page to manipulate, ranging from\r
+ * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).\r
+ */\r
+ static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)\r
+ {\r
+ Dataflash_DeselectChip();\r
+\r
+ if (PageAddress >= DATAFLASH_PAGES)\r
+ return;\r
+\r
+ Dataflash_SelectChip(DATAFLASH_CHIP1);\r
+ }\r
+\r
+ /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive\r
+ * a new command.\r
+ */\r
+ static inline void Dataflash_ToggleSelectedChipCS(void)\r
+ {\r
+ uint8_t SelectedChipMask = Dataflash_GetSelectedChip();\r
+\r
+ Dataflash_DeselectChip();\r
+ Dataflash_SelectChip(SelectedChipMask);\r
+ }\r
+\r
+ /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main\r
+ * memory page program or main memory to buffer transfer.\r
+ */\r
+ static inline void Dataflash_WaitWhileBusy(void)\r
+ {\r
+ Dataflash_ToggleSelectedChipCS();\r
+ Dataflash_SendByte(DF_CMD_GETSTATUS);\r
+ while (!(Dataflash_ReceiveByte() & DF_STATUS_READY));\r
+ Dataflash_ToggleSelectedChipCS();\r
+ }\r
+\r
+ /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with\r
+ * dataflash commands which require a complete 24-bit address.\r
+ *\r
+ * \param[in] PageAddress Page address within the selected dataflash IC\r
+ * \param[in] BufferByte Address within the dataflash's buffer\r
+ */\r
+ static inline void Dataflash_SendAddressBytes(uint16_t PageAddress,\r
+ const uint16_t BufferByte)\r
+ {\r
+ Dataflash_SendByte(PageAddress >> 5);\r
+ Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8));\r
+ Dataflash_SendByte(BufferByte);\r
+ }\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific joystick driver header for the Atmel EVK527.\r
+ * \copydetails Group_Joystick_EVK527\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the joystick driver\r
+ * dispatch header located in LUFA/Drivers/Board/Joystick.h.\r
+ */\r
+\r
+/** \ingroup Group_Joystick\r
+ * \defgroup Group_Joystick_EVK527 EVK527\r
+ * \brief Board specific joystick driver header for the Atmel EVK527.\r
+ *\r
+ * Board specific joystick driver header for the Atmel EVK527.\r
+ *\r
+ * <table>\r
+ * <tr><th>Left Port Pin</th><th>Up Port Pin</th><th>Right Port Pin</th><th>Down Port Pin</th><th>Press Port Pin</th></tr>\r
+ * <tr><td>PORTF.4</td><td>PORTF.5</td><td>PORTF.7</td><td>PORTC.6</td><td>PORTF.6</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __JOYSTICK_EVK527_H__\r
+#define __JOYSTICK_EVK527_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_JOYSTICK_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define JOY_FMASK ((1 << 4) | (1 << 5) | (1 << 6) | (1 << 7))\r
+ #define JOY_CMASK (1 << 6)\r
+\r
+ #define JOY_PORTC_MASK_SHIFT 3\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the joystick being pushed in the left direction. */\r
+ #define JOY_LEFT (1 << 4)\r
+\r
+ /** Mask for the joystick being pushed in the right direction. */\r
+ #define JOY_RIGHT (1 << 7)\r
+\r
+ /** Mask for the joystick being pushed in the upward direction. */\r
+ #define JOY_UP (1 << 5)\r
+\r
+ /** Mask for the joystick being pushed in the downward direction. */\r
+ #define JOY_DOWN ((1 << 6) >> JOY_PORTC_MASK_SHIFT)\r
+\r
+ /** Mask for the joystick being pushed inward. */\r
+ #define JOY_PRESS (1 << 6)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Joystick_Init(void)\r
+ {\r
+ DDRF &= ~JOY_FMASK;\r
+ DDRC &= ~JOY_CMASK;\r
+\r
+ PORTF |= JOY_FMASK;\r
+ PORTC |= JOY_CMASK;\r
+ }\r
+\r
+ static inline void Joystick_Disable(void)\r
+ {\r
+ DDRF &= ~JOY_FMASK;\r
+ DDRC &= ~JOY_CMASK;\r
+\r
+ PORTF &= ~JOY_FMASK;\r
+ PORTC &= ~JOY_CMASK;\r
+ }\r
+\r
+ static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Joystick_GetStatus(void)\r
+ {\r
+ return (((uint8_t)~PINF & JOY_FMASK) | (((uint8_t)~PINC & JOY_CMASK) >> JOY_PORTC_MASK_SHIFT));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Atmel EVK527.\r
+ * \copydetails Group_LEDs_EVK527\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_EVK527 EVK527\r
+ * \brief Board specific LED driver header for the Atmel EVK527.\r
+ *\r
+ * Board specific LED driver header for the Atmel EVK527.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.5</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.6</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_EVK527_H__\r
+#define __LEDS_EVK527_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 5)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 6)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 7)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Mattairtech JM-DB-U2.\r
+ * \copydetails Group_Buttons_JMDBU2\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_JMDBU2 JMDBU2\r
+ * \brief Board specific Buttons driver header for the Mattairtech JM-DB-U2.\r
+ *\r
+ * Board specific Buttons driver header for the Mattairtech JM-DB-U2 (http://u2.mattair.net/index.html).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_JMDBU2_H__\r
+#define __BUTTONS_JMDBU2_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Mattairtech JM-DB-U2.\r
+ * \copydetails Group_LEDs_JMDBU2\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_JMDBU2 JMDBU2\r
+ * \brief Board specific LED driver header for the Mattairtech JM-DB-U2.\r
+ *\r
+ * Board specific LED driver header for the Mattairtech JM-DB-U2 (http://u2.mattair.net/index.html).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.4</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_JMDBU2_H__\r
+#define __LEDS_JMDBU2_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS LEDS_LED1\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Maximus.\r
+ * \copydetails Group_LEDs_MAXIMUS\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_MAXIMUS MAXIMUS\r
+ * \brief Board specific LED driver header for the Maximus.\r
+ *\r
+ * Board specific LED driver header for the Maximus (http://www.avrusb.com/).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>LG</td><td>High</td><td>PORTB.6</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Red</td><td>LR</td><td>High</td><td>PORTB.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_MAXIMUS_H__\r
+#define __LEDS_MAXIMUS_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 6)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 7)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2)\r
+\r
+ /** LED mask for the none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRB |= LEDS_ALL_LEDS;\r
+ PORTB &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRB &= ~LEDS_ALL_LEDS;\r
+ PORTB &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB = ((PORTB & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTB = ((PORTB & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINB = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTB & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Micropendous series boards.\r
+ * \copydetails Group_Buttons_MICROPENDOUS_32U2\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_MICROPENDOUS_A MICROPENDOUS_A\r
+ * \brief Board specific Button driver header for the Micropendous A (https://code.google.com/p/micropendous/wiki/MicropendousA).\r
+ *\r
+ * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_MICROPENDOUS_1 MICROPENDOUS_1\r
+ * \brief Board specific Button driver header for the Micropendous 1 (https://code.google.com/p/micropendous/wiki/Micropendous1).\r
+ *\r
+ * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_MICROPENDOUS_2 MICROPENDOUS_2\r
+ * \brief Board specific Button driver header for the Micropendous 2 (https://code.google.com/p/micropendous/wiki/Micropendous2).\r
+ *\r
+ * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.\r
+ */\r
+ \r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_MICROPENDOUS_3 MICROPENDOUS_3\r
+ * \brief Board specific Button driver header for the Micropendous 3 (https://code.google.com/p/micropendous/wiki/Micropendous3).\r
+ *\r
+ * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.\r
+ */\r
+ \r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_MICROPENDOUS_4 MICROPENDOUS_4\r
+ * \brief Board specific Button driver header for the Micropendous 4 (https://code.google.com/p/micropendous/wiki/Micropendous4).\r
+ *\r
+ * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_MICROPENDOUS_DIP MICROPENDOUS_DIP\r
+ * \brief Board specific Button driver header for the Micropendous DIP (https://code.google.com/p/micropendous/wiki/MicropendousDIP).\r
+ *\r
+ * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_MICROPENDOUS_REV1 MICROPENDOUS_REV1\r
+ * \brief Board specific Button driver header for the Micropendous Arduino-like Revision 1 (https://code.google.com/p/micropendous/wiki/Micropendous).\r
+ *\r
+ * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_MICROPENDOUS_REV2 MICROPENDOUS_REV2\r
+ * \brief Board specific Button driver header for the Micropendous Arduino-like Revision 2 (https://code.google.com/p/micropendous/wiki/Micropendous).\r
+ *\r
+ * See \ref Group_Buttons_MICROPENDOUS_32U2 for more details.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_MICROPENDOUS_32U2 MICROPENDOUS_32U2\r
+ * \brief Board specific Buttons driver header for the Micropendous 32U2.\r
+ *\r
+ * \note There are multiple supported Micropendous boards, compile with <code>BOARD = MICROPENDOUS_{VERSION}</code>.\r
+ *\r
+ * Board specific Buttons driver header for the Micropendous 32U2 (https://code.google.com/p/micropendous/wiki/Micropendous_32U2).\r
+ *\r
+ * <b>BOARD_MICROPENDOUS_1 and BOARD_MICROPENDOUS_32U2</b>:\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * <b>Other Revisions</b>:\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTE.2</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_MICROPENDOUS_H__\r
+#define __BUTTONS_MICROPENDOUS_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ #if (BOARD == BOARD_MICROPENDOUS_32U2)\r
+ #define _BOARD_BUTTON1_MASK (1 << 7)\r
+ #define _BOARD_BUTTON_PORTLETTER D\r
+ #elif (BOARD == BOARD_MICROPENDOUS_A)\r
+ #define _BOARD_BUTTON1_MASK (1 << 2)\r
+ #define _BOARD_BUTTON_PORTLETTER E\r
+ #elif (BOARD == BOARD_MICROPENDOUS_1)\r
+ #define _BOARD_BUTTON1_MASK (1 << 7)\r
+ #define _BOARD_BUTTON_PORTLETTER D\r
+ #elif (BOARD == BOARD_MICROPENDOUS_2)\r
+ #define _BOARD_BUTTON1_MASK (1 << 2)\r
+ #define _BOARD_BUTTON_PORTLETTER E\r
+ #elif (BOARD == BOARD_MICROPENDOUS_3)\r
+ #define _BOARD_BUTTON1_MASK (1 << 2)\r
+ #define _BOARD_BUTTON_PORTLETTER E\r
+ #elif (BOARD == BOARD_MICROPENDOUS_4)\r
+ #define _BOARD_BUTTON1_MASK (1 << 2)\r
+ #define _BOARD_BUTTON_PORTLETTER E\r
+ #elif (BOARD == BOARD_MICROPENDOUS_DIP)\r
+ #define _BOARD_BUTTON1_MASK (1 << 2)\r
+ #define _BOARD_BUTTON_PORTLETTER E\r
+ #elif (BOARD == BOARD_MICROPENDOUS_REV1)\r
+ #define _BOARD_BUTTON1_MASK (1 << 2)\r
+ #define _BOARD_BUTTON_PORTLETTER E\r
+ #elif (BOARD == BOARD_MICROPENDOUS_REV2)\r
+ #define _BOARD_BUTTON1_MASK (1 << 2)\r
+ #define _BOARD_BUTTON_PORTLETTER E\r
+ #endif\r
+ \r
+ #define _BOARD_BUTTON_CONCAT2(Reg, Letter) Reg ## Letter\r
+ #define _BOARD_BUTTON_CONCAT(Reg, Letter) _BOARD_BUTTON_CONCAT2(Reg, Letter)\r
+\r
+ #define _BOARD_BUTTON_PORT _BOARD_BUTTON_CONCAT(PORT, _BOARD_BUTTON_PORTLETTER)\r
+ #define _BOARD_BUTTON_PIN _BOARD_BUTTON_CONCAT(PIN, _BOARD_BUTTON_PORTLETTER)\r
+ #define _BOARD_BUTTON_DDR _BOARD_BUTTON_CONCAT(DDR, _BOARD_BUTTON_PORTLETTER)\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 _BOARD_BUTTON1_MASK\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ _BOARD_BUTTON_DDR &= ~BUTTONS_BUTTON1;\r
+ _BOARD_BUTTON_PORT |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ _BOARD_BUTTON_DDR &= ~BUTTONS_BUTTON1;\r
+ _BOARD_BUTTON_PORT &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((_BOARD_BUTTON_PIN & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Micropendous-32U2.\r
+ * \copydetails Group_LEDs_MICROPENDOUS_32U2\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_MICROPENDOUS_REV1 MICROPENDOUS_REV1\r
+ * \brief Board specific LED driver header for the Micropendous Arduino-like Revision 1 (https://code.google.com/p/micropendous/wiki/Micropendous).\r
+ *\r
+ * See \ref Group_LEDs_MICROPENDOUS_32U2 for more details.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_MICROPENDOUS_REV2 MICROPENDOUS_REV2\r
+ * \brief Board specific LED driver header for the Micropendous Arduino-like Revision 2 (https://code.google.com/p/micropendous/wiki/Micropendous).\r
+ *\r
+ * See \ref Group_LEDs_MICROPENDOUS_32U2 for more details.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_MICROPENDOUS_32U2 MICROPENDOUS_32U2\r
+ * \brief Board specific LED driver header for the Micropendous-32U2.\r
+ *\r
+ * Board specific LED driver header for the Micropendous 32U2 (https://code.google.com/p/micropendous/wiki/Micropendous_32U2).\r
+ *\r
+ * <b>BOARD_MICROPENDOUS_32U2</b>:\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.6</td></tr>\r
+ * </table>\r
+ *\r
+ * <b>Other Revisions</b>:\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTB.1</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_MICROPENDOUS_H__\r
+#define __LEDS_MICROPENDOUS_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ #if (BOARD == BOARD_MICROPENDOUS_32U2)\r
+ #define _BOARD_LED1_MASK (1 << 6)\r
+ #define _BOARD_LED_PORTLETTER D\r
+ #elif (BOARD == BOARD_MICROPENDOUS_REV1)\r
+ #define _BOARD_LED1_MASK (1 << 1)\r
+ #define _BOARD_LED_PORTLETTER B\r
+ #elif (BOARD == BOARD_MICROPENDOUS_REV2)\r
+ #define _BOARD_LED1_MASK (1 << 1)\r
+ #define _BOARD_LED_PORTLETTER B\r
+ #endif\r
+ \r
+ #define _BOARD_LED_CONCAT2(Reg, Letter) Reg ## Letter\r
+ #define _BOARD_LED_CONCAT(Reg, Letter) _BOARD_LED_CONCAT2(Reg, Letter)\r
+\r
+ #define _BOARD_LED_PORT _BOARD_LED_CONCAT(PORT, _BOARD_LED_PORTLETTER)\r
+ #define _BOARD_LED_PIN _BOARD_LED_CONCAT(PIN, _BOARD_LED_PORTLETTER)\r
+ #define _BOARD_LED_DDR _BOARD_LED_CONCAT(DDR, _BOARD_LED_PORTLETTER)\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 _BOARD_LED1_MASK\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS LEDS_LED1\r
+\r
+ /** LED mask for the none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ _BOARD_LED_DDR |= LEDS_ALL_LEDS;\r
+ _BOARD_LED_PORT &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ _BOARD_LED_DDR &= ~LEDS_ALL_LEDS;\r
+ _BOARD_LED_PORT &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ _BOARD_LED_PORT |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ _BOARD_LED_PORT &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ _BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ _BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ _BOARD_LED_PIN = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (_BOARD_LED_PORT & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Microsin AVR-USB162 board.\r
+ * \copydetails Group_Buttons_MICROSIN162\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_MICROSIN162 MICROSIN162\r
+ * \brief Board specific Buttons driver header for the Microsin AVR-USB162 board.\r
+ *\r
+ * Board specific Buttons driver header for the Microsin AVR-USB162 board (http://microsin.ru/content/view/685/44/).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_MICROSIN162_H__\r
+#define __BUTTONS_MICROSIN162_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Microsin AVR-USB162 board.\r
+ * \copydetails Group_LEDs_MICROSIN162\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_MICROSIN162 MICROSIN162\r
+ * \brief Board specific LED driver header for the Microsin AVR-USB162 board.\r
+ *\r
+ * Board specific LED driver header for the Microsin AVR-USB162 board (http://microsin.ru/content/view/685/44/).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>Low</td><td>PORTD.4</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_MICROSIN162_H__\r
+#define __LEDS_MICROSIN162_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS LEDS_LED1\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD |= LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD | LEDMask) & ~ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (~PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the MINIMUS.\r
+ * \copydetails Group_Buttons_MINIMUS\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_MINIMUS MINIMUS\r
+ * \brief Board specific Buttons driver header for the MINIMUS.\r
+ *\r
+ * Board specific Buttons driver header for the MINIMUS.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_MINIMUS_H__\r
+#define __BUTTONS_MINIMUS_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the MINIMUS.\r
+ * \copydetails Group_LEDs_MINIMUS\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_MINIMUS MINIMUS\r
+ * \brief Board specific LED driver header for the MINIMUS.\r
+ *\r
+ * Board specific LED driver header for the Minimus USB (http://www.minimususb.com/).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Red</td><td>General Indicator</td><td>Low</td><td>PORTD.5</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Green</td><td>General Indicator</td><td>Low</td><td>PORTD.6</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Blue</td><td>General Indicator</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_MINIMUS_H__\r
+#define __LEDS_MINIMUS_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 5)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 6)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 7)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for the none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD |= LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Bitwizard Multio.\r
+ * \copydetails Group_LEDs_MULTIO\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_MULTIO MULTIO\r
+ * \brief Board specific LED driver header for the Bitwizard Multio.\r
+ *\r
+ * Board specific LED driver header for the Bitwizard Multio (http://www.bitwizard.nl/wiki/index.php/USB-multio).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.0</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTC.2</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_MULTIO_H__\r
+#define __LEDS_MULTIO_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define LEDS_PORTD_LEDS (LEDS_LED1 | LEDS_LED3)\r
+ #define LEDS_PORTC_LEDS LEDS_LED2\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 0)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 2)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED3 (1 << 7)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_PORTD_LEDS;\r
+ DDRC |= LEDS_PORTC_LEDS;\r
+ \r
+ PORTD &= ~LEDS_PORTD_LEDS;\r
+ PORTC &= ~LEDS_PORTC_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_PORTD_LEDS;\r
+ DDRC &= ~LEDS_PORTC_LEDS;\r
+ \r
+ PORTD &= ~LEDS_PORTD_LEDS;\r
+ PORTC &= ~LEDS_PORTC_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= (LEDMask & LEDS_PORTD_LEDS);\r
+ PORTC |= (LEDMask & LEDS_PORTC_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~(LEDMask & LEDS_PORTD_LEDS);\r
+ PORTC &= ~(LEDMask & LEDS_PORTC_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = (PORTD & ~LEDS_PORTD_LEDS) | (LEDMask & LEDS_PORTD_LEDS);\r
+ PORTC = (PORTC & ~LEDS_PORTC_LEDS) | (LEDMask & LEDS_PORTC_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = (PORTD & ~(LEDMask & LEDS_PORTD_LEDS)) | (ActiveMask & LEDS_PORTD_LEDS);\r
+ PORTC = (PORTC & ~(LEDMask & LEDS_PORTC_LEDS)) | (ActiveMask & LEDS_PORTC_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = (LEDMask & LEDS_PORTD_LEDS);\r
+ PINC = (LEDMask & LEDS_PORTC_LEDS);\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return ((PORTD & LEDS_PORTD_LEDS) | (PORTC & LEDS_PORTC_LEDS));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Olimex AVR-USB-162 Development Board.\r
+ * \copydetails Group_Buttons_OLIMEX162\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_OLIMEX162 OLIMEX162\r
+ * \brief Board specific Buttons driver header for the Olimex AVR-USB-162 Development Board.\r
+ *\r
+ * Board specific Buttons driver header for the Olimex AVR-USB-162 Development Board (http://www.olimex.com/dev/avr-usb-162.html).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_OLIMEX162_H__\r
+#define __BUTTONS_OLIMEX162_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Olimex AVR-USB-162.\r
+ * \copydetails Group_LEDs_OLIMEX162\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_OLIMEX162 OLIMEX162\r
+ * \brief Board specific LED driver header for the Olimex AVR-USB-162.\r
+ *\r
+ * Board specific LED driver header for the Olimex AVR-USB-162 (http://www.olimex.com/dev/avr-usb-162.html).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Yellow</td><td>General Indicator</td><td>High</td><td>PORTD.4</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_OLIMEX162_H__\r
+#define __LEDS_OLIMEX162_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS LEDS_LED1\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Olimex AVR-USB-32U4 Development Board.\r
+ * \copydetails Group_Buttons_OLIMEX32U4\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_OLIMEX32U4 OLIMEX32U4\r
+ * \brief Board specific Buttons driver header for the Olimex AVR-USB-32U4 Development Board.\r
+ *\r
+ * Board specific Buttons driver header for the Olimex AVR-USB-32U4 Development Board (http://www.olimex.com/dev/olimexino-32u4.html).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTE.2</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_OLIMEX32U4_H__\r
+#define __BUTTONS_OLIMEX32U4_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 2)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Olimex AVR-USB-32U4.\r
+ * \copydetails Group_LEDs_OLIMEX32U4\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_OLIMEX32U4 OLIMEX32U4\r
+ * \brief Board specific LED driver header for the Olimex AVR-USB-32U4.\r
+ *\r
+ * Board specific LED driver header for the Olimex AVR-USB-32U4 (http://www.olimex.com/dev/olimexino-32u4.html).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>TX</td><td>High</td><td>PORTD.5</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Yellow</td><td>RX</td><td>High</td><td>PORTB.0</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Green</td><td>General Indicator (Default Unconnected)</td><td>High</td><td>PORTE.6</td></tr>\r
+ * <tr><td>LEDS_LED4</td><td>Yellow</td><td>General Indicator (Default Unconnected)</td><td>High</td><td>PORTB.5</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_OLIMEX32U4_H__\r
+#define __LEDS_OLIMEX32U4_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define LEDS_PORTB_LEDS (LEDS_LED2 | LEDS_LED4)\r
+ #define LEDS_PORTD_LEDS (LEDS_LED1)\r
+ #define LEDS_PORTE_LEDS (LEDS_LED3)\r
+\r
+ #define LEDS_PORTD_MASK_SHIFT 1\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 ((1 << 5) >> LEDS_PORTD_MASK_SHIFT)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 0)\r
+ \r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 5)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1 << 6)\r
+ \r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRB |= LEDS_PORTB_LEDS;\r
+ PORTB &= ~LEDS_PORTB_LEDS;\r
+ DDRD |= (LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT);\r
+ PORTD &= ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT);\r
+ DDRE |= LEDS_PORTE_LEDS;\r
+ PORTE &= ~LEDS_PORTE_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRB &= ~LEDS_PORTB_LEDS;\r
+ PORTB &= ~LEDS_PORTB_LEDS;\r
+ DDRD &= ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT);\r
+ PORTD &= ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT);\r
+ DDRE &= ~LEDS_PORTE_LEDS;\r
+ PORTE &= ~LEDS_PORTE_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB |= (LEDMask & LEDS_PORTB_LEDS);\r
+ PORTD |= ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT);\r
+ PORTE |= (LEDMask & LEDS_PORTE_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB &= ~(LEDMask & LEDS_PORTB_LEDS);\r
+ PORTD &= ~((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT);\r
+ PORTE &= ~(LEDMask & LEDS_PORTE_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB = ((PORTB & ~LEDS_PORTB_LEDS) | (LEDMask & LEDS_PORTB_LEDS));\r
+ PORTD = ((PORTD & ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT)) |\r
+ ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT));\r
+ PORTE = ((PORTE & ~LEDS_PORTE_LEDS) | (LEDMask & LEDS_PORTE_LEDS));\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTB = ((PORTB & ~(LEDMask & LEDS_PORTB_LEDS)) | (ActiveMask & LEDS_PORTB_LEDS));\r
+ PORTD = ((PORTD & ~((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT)) |\r
+ ((ActiveMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT));\r
+ PORTE = ((PORTE & ~(LEDMask & LEDS_PORTE_LEDS)) | (ActiveMask & LEDS_PORTE_LEDS));\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINB = (LEDMask & LEDS_PORTB_LEDS);\r
+ PIND = ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT);\r
+ PINE = (LEDMask & LEDS_PORTE_LEDS);\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return ((PORTB & LEDS_PORTB_LEDS) | \r
+ ((PORTD & (LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT)) >> LEDS_PORTD_MASK_SHIFT) |\r
+ (PORTE & LEDS_PORTE_LEDS));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Olimex AVR-ISP-MK2 Development Board.\r
+ * \copydetails Group_Buttons_OLIMEXISPMK2\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_OLIMEXISPMK2 OLIMEXISPMK2\r
+ * \brief Board specific Buttons driver header for the Olimex AVR-ISP-MK2.\r
+ *\r
+ * Board specific Buttons driver header for the Olimex AVR-ISP-MK2 Development Board (https://www.olimex.com/dev/avr-isp-mk2.html).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_OLIMEXISPMK2_H__\r
+#define __BUTTONS_OLIMEXISPMK2_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Olimex AVR-ISP-MK2 Development Board.\r
+ * \copydetails Group_LEDs_OLIMEXISPMK2\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_OLIMEXISPMK2 OLIMEXISPMK2\r
+ * \brief Board specific LED driver header for the Olimex AVR-ISP-MK2.\r
+ *\r
+ * Board specific LED driver header for the Olimex AVR-ISP-MK2 Development Board (https://www.olimex.com/dev/avr-isp-mk2.html).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Yellow</td><td>Target Power</td><td>High</td><td>PORTB.5</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Red</td><td>Activity</td><td>High</td><td>PORTB.6</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Green</td><td>Ready</td><td>High</td><td>PORTB.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_OLIMEXISPMK2_H__\r
+#define __LEDS_OLIMEXISPMK2_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 5)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 6)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 7)\r
+ \r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRB |= LEDS_ALL_LEDS;\r
+ PORTB &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRB &= ~LEDS_ALL_LEDS;\r
+ PORTB &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB = ((PORTB & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTB = ((PORTB & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINB = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTB & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Olimex AVR-USB-T32U4 Development Board.\r
+ * \copydetails Group_Buttons_OLIMEXT32U4\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_OLIMEXT32U4 OLIMEXT32U4\r
+ * \brief Board specific Buttons driver header for the Olimex AVR-USB-32U4 Development Board.\r
+ *\r
+ * Board specific Buttons driver header for the Olimex AVR-USB-T32U4 Development Board (http://www.olimex.com/dev/avr-t32u4.html).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTE.2</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_OLIMEXT32U4_H__\r
+#define __BUTTONS_OLIMEXT32U4_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 2)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Olimex AVR-USB-T32U4.\r
+ * \copydetails Group_LEDs_OLIMEXT32U4\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_OLIMEXT32U4 OLIMEXT32U4\r
+ * \brief Board specific LED driver header for the Olimex AVR-USB-T32U4.\r
+ *\r
+ * Board specific LED driver header for the Olimex AVR-USB-T32U4 (http://www.olimex.com/dev/avr-t32u4.html).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>TX</td><td>High</td><td>PORTD.5</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Yellow</td><td>RX</td><td>High</td><td>PORTB.0</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>N/A</td><td>General Indicator (Not Mounted)</td><td>High</td><td>PORTE.6</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_OLIMEXT32U4_H__\r
+#define __LEDS_OLIMEXT32U4_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define LEDS_PORTB_LEDS (LEDS_LED2)\r
+ #define LEDS_PORTD_LEDS (LEDS_LED1)\r
+ #define LEDS_PORTE_LEDS (LEDS_LED3)\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 5)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 0)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 6)\r
+ \r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRB |= LEDS_PORTB_LEDS;\r
+ PORTB &= ~LEDS_PORTB_LEDS;\r
+ DDRD |= LEDS_PORTD_LEDS;\r
+ PORTD &= ~LEDS_PORTD_LEDS;\r
+ DDRE |= LEDS_PORTE_LEDS;\r
+ PORTE &= ~LEDS_PORTE_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRB &= ~LEDS_PORTB_LEDS;\r
+ PORTB &= ~LEDS_PORTB_LEDS;\r
+ DDRD &= ~LEDS_PORTD_LEDS;\r
+ PORTD &= ~LEDS_PORTD_LEDS;\r
+ DDRE &= ~LEDS_PORTE_LEDS;\r
+ PORTE &= ~LEDS_PORTE_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB |= (LEDMask & LEDS_PORTB_LEDS);\r
+ PORTD |= (LEDMask & LEDS_PORTD_LEDS);\r
+ PORTE |= (LEDMask & LEDS_PORTE_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB &= ~(LEDMask & LEDS_PORTB_LEDS);\r
+ PORTD &= ~(LEDMask & LEDS_PORTD_LEDS);\r
+ PORTE &= ~(LEDMask & LEDS_PORTE_LEDS);\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB = ((PORTB & ~LEDS_PORTB_LEDS) | (LEDMask & LEDS_PORTB_LEDS));\r
+ PORTD = ((PORTD & ~LEDS_PORTD_LEDS) | (LEDMask & LEDS_PORTD_LEDS));\r
+ PORTE = ((PORTE & ~LEDS_PORTE_LEDS) | (LEDMask & LEDS_PORTE_LEDS));\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTB = ((PORTB & ~(LEDMask & LEDS_PORTB_LEDS)) | (ActiveMask & LEDS_PORTB_LEDS));\r
+ PORTD = ((PORTD & ~(LEDMask & LEDS_PORTD_LEDS)) | (ActiveMask & LEDS_PORTD_LEDS));\r
+ PORTE = ((PORTE & ~(LEDMask & LEDS_PORTE_LEDS)) | (ActiveMask & LEDS_PORTE_LEDS));\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINB = (LEDMask & LEDS_PORTB_LEDS);\r
+ PIND = (LEDMask & LEDS_PORTD_LEDS);\r
+ PINE = (LEDMask & LEDS_PORTE_LEDS);\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return ((PORTB & LEDS_PORTB_LEDS) | (PORTD & LEDS_PORTD_LEDS) | (PORTE & LEDS_PORTE_LEDS));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Atmel RZUSBSTICK.\r
+ * \copydetails Group_LEDs_RZUSBSTICK\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_RZUSBSTICK RZUSBSTICK\r
+ * \brief Board specific LED driver header for the Atmel RZUSBSTICK.\r
+ *\r
+ * Board specific LED driver header for the Atmel RZUSBSTICK.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Blue</td><td>General Indicator</td><td>High</td><td>PORTD.7</td></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Red</td><td>General Indicator</td><td>Low</td><td>PORTD.5</td></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>Low</td><td>PORTE.6</td></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Yellow</td><td>General Indicator</td><td>Low</td><td>PORTE.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_RZUSBSTICK_H__\r
+#define __LEDS_RZUSBSTICK_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define LEDS_PORTD_LEDS (LEDS_LED1 | LEDS_LED2)\r
+ #define LEDS_PORTE_LEDS (LEDS_LED3 | LEDS_LED4)\r
+\r
+ #define LEDS_PORTE_MASK_SHIFT 4\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 7)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 5)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 ((1 << 6) >> LEDS_PORTE_MASK_SHIFT)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 ((1 << 7) >> LEDS_PORTE_MASK_SHIFT)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_PORTD_LEDS;\r
+ PORTD &= ~LEDS_LED1;\r
+ PORTD |= LEDS_LED2;\r
+\r
+ DDRE |= (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+ PORTE |= (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_PORTD_LEDS;\r
+ PORTD &= ~LEDS_PORTD_LEDS;\r
+\r
+ DDRE &= ~(LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+ PORTE &= ~(LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= (LEDMask & LEDS_LED1);\r
+ PORTD &= ~(LEDMask & LEDS_LED2);\r
+ PORTE &= ~((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~(LEDMask & LEDS_LED1);\r
+ PORTD |= (LEDMask & LEDS_LED2);\r
+ PORTE |= ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = (((PORTD & ~LEDS_LED1) | (LEDMask & LEDS_LED1)) |\r
+ ((PORTD | LEDS_LED2) & ~(LEDMask & LEDS_LED2)));\r
+ PORTE = ((PORTE | (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT)) &\r
+ ~((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT));\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = (((PORTD & ~(LEDMask & LEDS_LED1)) | (ActiveMask & LEDS_LED1)) |\r
+ ((PORTD | (LEDMask & LEDS_LED2)) & ~(ActiveMask & LEDS_LED2)));\r
+ PORTE = ((PORTE | ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT)) &\r
+ ~((ActiveMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT));\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = (LEDMask & LEDS_PORTD_LEDS);\r
+ PINE = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (((PORTD & LEDS_LED1) | (~PORTD & LEDS_LED2)) |\r
+ ((~PORTE & (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT)) >> LEDS_PORTE_MASK_SHIFT));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Sparkfun ATMEGA8U2 breakout board.\r
+ * \copydetails Group_LEDs_SPARKFUN8U2\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_SPARKFUN8U2 SPARKFUN8U2\r
+ * \brief Board specific LED driver header for the Sparkfun ATMEGA8U2 breakout board.\r
+ *\r
+ * Board specific LED driver header for the Sparkfun ATMEGA8U2 breakout board (http://www.sparkfun.com/products/10277).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>Low</td><td>PORTB.4</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_SPARKFUN8U2_H__\r
+#define __LEDS_SPARKFUN8U2_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS LEDS_LED1\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRB |= LEDS_ALL_LEDS;\r
+ PORTB |= LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRB &= ~LEDS_ALL_LEDS;\r
+ PORTB &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB = ((PORTB | LEDS_ALL_LEDS) & ~LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTB = ((PORTB | LEDMask) & ~ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINB = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (~PORTB & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Atmel STK525.\r
+ * \copydetails Group_Buttons_STK525\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_STK525 STK525\r
+ * \brief Board specific Buttons driver header for the Atmel STK525.\r
+ *\r
+ * Board specific Buttons driver header for the Atmel STK525.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTE.2</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_STK525_H__\r
+#define __BUTTONS_STK525_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 2)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Dataflash driver header for the Atmel STK525.\r
+ * \copydetails Group_Dataflash_STK525\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+/** \ingroup Group_Dataflash\r
+ * \defgroup Group_Dataflash_STK525 STK525\r
+ * \brief Board specific Dataflash driver header for the Atmel STK525.\r
+ *\r
+ * Board specific Dataflash driver header for the Atmel STK525.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Select Pin</th><th>SPI Port</th></tr>\r
+ * <tr><td>DATAFLASH_CHIP1</td><td>AT45DB321C (4MB)</td><td>PORTB.4</td><td>SPI0</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __DATAFLASH_STK525_H__\r
+#define __DATAFLASH_STK525_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../../../Misc/AT45DB321C.h"\r
+ #include "../../../Peripheral/SPI.h"\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_DATAFLASH_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATAFLASH_CHIPCS_MASK (1 << 4)\r
+ #define DATAFLASH_CHIPCS_DDR DDRB\r
+ #define DATAFLASH_CHIPCS_PORT PORTB\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */\r
+ #define DATAFLASH_TOTALCHIPS 1\r
+\r
+ /** Mask for no dataflash chip selected. */\r
+ #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK\r
+\r
+ /** Mask for the first dataflash chip selected. */\r
+ #define DATAFLASH_CHIP1 0\r
+\r
+ /** Internal main memory page size for the board's dataflash IC. */\r
+ #define DATAFLASH_PAGE_SIZE 512\r
+\r
+ /** Total number of pages inside the board's dataflash IC. */\r
+ #define DATAFLASH_PAGES 8192\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.\r
+ * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.\r
+ */\r
+ static inline void Dataflash_Init(void)\r
+ {\r
+ DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK;\r
+ DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)\r
+ {\r
+ return SPI_TransferByte(Byte);\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ */\r
+ static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SendByte(const uint8_t Byte)\r
+ {\r
+ SPI_SendByte(Byte);\r
+ }\r
+\r
+ /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_ReceiveByte(void)\r
+ {\r
+ return SPI_ReceiveByte();\r
+ }\r
+\r
+ /** Determines the currently selected dataflash chip.\r
+ *\r
+ * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected\r
+ * or a DATAFLASH_CHIPn mask (where n is the chip number).\r
+ */\r
+ static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_GetSelectedChip(void)\r
+ {\r
+ return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK);\r
+ }\r
+\r
+ /** Selects the given dataflash chip.\r
+ *\r
+ * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is\r
+ * the chip number).\r
+ */\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask)\r
+ {\r
+ DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask);\r
+ }\r
+\r
+ /** Deselects the current dataflash chip, so that no dataflash is selected. */\r
+ static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_DeselectChip(void)\r
+ {\r
+ Dataflash_SelectChip(DATAFLASH_NO_CHIP);\r
+ }\r
+\r
+ /** Selects a dataflash IC from the given page number, which should range from 0 to\r
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one\r
+ * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside\r
+ * the total number of pages contained in the boards dataflash ICs, all dataflash ICs\r
+ * are deselected.\r
+ *\r
+ * \param[in] PageAddress Address of the page to manipulate, ranging from\r
+ * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).\r
+ */\r
+ static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)\r
+ {\r
+ Dataflash_DeselectChip();\r
+\r
+ if (PageAddress >= DATAFLASH_PAGES)\r
+ return;\r
+\r
+ Dataflash_SelectChip(DATAFLASH_CHIP1);\r
+ }\r
+\r
+ /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive\r
+ * a new command.\r
+ */\r
+ static inline void Dataflash_ToggleSelectedChipCS(void)\r
+ {\r
+ uint8_t SelectedChipMask = Dataflash_GetSelectedChip();\r
+\r
+ Dataflash_DeselectChip();\r
+ Dataflash_SelectChip(SelectedChipMask);\r
+ }\r
+\r
+ /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main\r
+ * memory page program or main memory to buffer transfer.\r
+ */\r
+ static inline void Dataflash_WaitWhileBusy(void)\r
+ {\r
+ Dataflash_ToggleSelectedChipCS();\r
+ Dataflash_SendByte(DF_CMD_GETSTATUS);\r
+ while (!(Dataflash_ReceiveByte() & DF_STATUS_READY));\r
+ Dataflash_ToggleSelectedChipCS();\r
+ }\r
+\r
+ /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with\r
+ * dataflash commands which require a complete 24-bit address.\r
+ *\r
+ * \param[in] PageAddress Page address within the selected dataflash IC\r
+ * \param[in] BufferByte Address within the dataflash's buffer\r
+ */\r
+ static inline void Dataflash_SendAddressBytes(uint16_t PageAddress,\r
+ const uint16_t BufferByte)\r
+ {\r
+ Dataflash_SendByte(PageAddress >> 6);\r
+ Dataflash_SendByte((PageAddress << 2) | (BufferByte >> 8));\r
+ Dataflash_SendByte(BufferByte);\r
+ }\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific joystick driver header for the Atmel STK525.\r
+ * \copydetails Group_Joystick_STK525\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the joystick driver\r
+ * dispatch header located in LUFA/Drivers/Board/Joystick.h.\r
+ */\r
+\r
+/** \ingroup Group_Joystick\r
+ * \defgroup Group_Joystick_STK525 STK525\r
+ * \brief Board specific joystick driver header for the Atmel STK525.\r
+ *\r
+ * Board specific joystick driver header for the Atmel STK525.\r
+ *\r
+ * <table>\r
+ * <tr><th>Left Port Pin</th><th>Up Port Pin</th><th>Right Port Pin</th><th>Down Port Pin</th><th>Press Port Pin</th></tr>\r
+ * <tr><td>PORTB.6</td><td>PORTB.7</td><td>PORTE.4</td><td>PORTE.5</td><td>PORTB.5</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __JOYSTICK_STK525_H__\r
+#define __JOYSTICK_STK525_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_JOYSTICK_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define JOY_BMASK ((1 << 5) | (1 << 6) | (1 << 7))\r
+ #define JOY_EMASK ((1 << 4) | (1 << 5))\r
+\r
+ #define JOY_PORTE_MASK_SHIFT 1\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the joystick being pushed in the left direction. */\r
+ #define JOY_LEFT (1 << 6)\r
+\r
+ /** Mask for the joystick being pushed in the right direction. */\r
+ #define JOY_RIGHT ((1 << 4) >> JOY_PORTE_MASK_SHIFT)\r
+\r
+ /** Mask for the joystick being pushed in the upward direction. */\r
+ #define JOY_UP (1 << 7)\r
+\r
+ /** Mask for the joystick being pushed in the downward direction. */\r
+ #define JOY_DOWN ((1 << 5) >> JOY_PORTE_MASK_SHIFT)\r
+\r
+ /** Mask for the joystick being pushed inward. */\r
+ #define JOY_PRESS (1 << 5)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Joystick_Init(void)\r
+ {\r
+ DDRB &= ~JOY_BMASK;\r
+ DDRE &= ~JOY_EMASK;\r
+\r
+ PORTB |= JOY_BMASK;\r
+ PORTE |= JOY_EMASK;\r
+ }\r
+\r
+ static inline void Joystick_Disable(void)\r
+ {\r
+ DDRB &= ~JOY_BMASK;\r
+ DDRE &= ~JOY_EMASK;\r
+\r
+ PORTB &= ~JOY_BMASK;\r
+ PORTE &= ~JOY_EMASK;\r
+ }\r
+\r
+ static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Joystick_GetStatus(void)\r
+ {\r
+ return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> JOY_PORTE_MASK_SHIFT));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Atmel STK525.\r
+ * \copydetails Group_LEDs_STK525\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_STK525 STK525\r
+ * \brief Board specific LED driver header for the Atmel STK525.\r
+ *\r
+ * Board specific LED driver header for the Atmel STK525.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.4</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.5</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.6</td></tr>\r
+ * <tr><td>LEDS_LED4</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_STK525_H__\r
+#define __LEDS_STK525_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 5)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 7)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1 << 6)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Atmel STK526.\r
+ * \copydetails Group_Buttons_STK526\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_STK526 STK526\r
+ * \brief Board specific Buttons driver header for the Atmel STK526.\r
+ *\r
+ * Board specific Buttons driver header for the Atmel STK526.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_STK526_H__\r
+#define __BUTTONS_STK526_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Dataflash driver header for the Atmel STK525.\r
+ * \copydetails Group_Dataflash_STK526\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+/** \ingroup Group_Dataflash\r
+ * \defgroup Group_Dataflash_STK526 STK526\r
+ * \brief Board specific Dataflash driver header for the Atmel STK525.\r
+ *\r
+ * Board specific Dataflash driver header for the Atmel STK525.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Select Pin</th><th>SPI Port</th></tr>\r
+ * <tr><td>DATAFLASH_CHIP1</td><td>AT45DB642D (8MB)</td><td>PORTC.2</td><td>SPI0</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __DATAFLASH_STK526_H__\r
+#define __DATAFLASH_STK526_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../../../Misc/AT45DB642D.h"\r
+ #include "../../../Peripheral/SPI.h"\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_DATAFLASH_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATAFLASH_CHIPCS_MASK (1 << 2)\r
+ #define DATAFLASH_CHIPCS_DDR DDRC\r
+ #define DATAFLASH_CHIPCS_PORT PORTC\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */\r
+ #define DATAFLASH_TOTALCHIPS 1\r
+\r
+ /** Mask for no dataflash chip selected. */\r
+ #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK\r
+\r
+ /** Mask for the first dataflash chip selected. */\r
+ #define DATAFLASH_CHIP1 0\r
+\r
+ /** Internal main memory page size for the board's dataflash IC. */\r
+ #define DATAFLASH_PAGE_SIZE 1024\r
+\r
+ /** Total number of pages inside the board's dataflash IC. */\r
+ #define DATAFLASH_PAGES 8192\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.\r
+ * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.\r
+ */\r
+ static inline void Dataflash_Init(void)\r
+ {\r
+ DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK;\r
+ DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)\r
+ {\r
+ return SPI_TransferByte(Byte);\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ */\r
+ static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SendByte(const uint8_t Byte)\r
+ {\r
+ SPI_SendByte(Byte);\r
+ }\r
+\r
+ /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_ReceiveByte(void)\r
+ {\r
+ return SPI_ReceiveByte();\r
+ }\r
+\r
+ /** Determines the currently selected dataflash chip.\r
+ *\r
+ * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected\r
+ * or a DATAFLASH_CHIPn mask (where n is the chip number).\r
+ */\r
+ static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_GetSelectedChip(void)\r
+ {\r
+ return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK);\r
+ }\r
+\r
+ /** Selects the given dataflash chip.\r
+ *\r
+ * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is\r
+ * the chip number).\r
+ */\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask)\r
+ {\r
+ DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask);\r
+ }\r
+\r
+ /** Deselects the current dataflash chip, so that no dataflash is selected. */\r
+ static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_DeselectChip(void)\r
+ {\r
+ Dataflash_SelectChip(DATAFLASH_NO_CHIP);\r
+ }\r
+\r
+ /** Selects a dataflash IC from the given page number, which should range from 0 to\r
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one\r
+ * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside\r
+ * the total number of pages contained in the boards dataflash ICs, all dataflash ICs\r
+ * are deselected.\r
+ *\r
+ * \param[in] PageAddress Address of the page to manipulate, ranging from\r
+ * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).\r
+ */\r
+ static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)\r
+ {\r
+ Dataflash_DeselectChip();\r
+\r
+ if (PageAddress >= DATAFLASH_PAGES)\r
+ return;\r
+\r
+ Dataflash_SelectChip(DATAFLASH_CHIP1);\r
+ }\r
+\r
+ /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive\r
+ * a new command.\r
+ */\r
+ static inline void Dataflash_ToggleSelectedChipCS(void)\r
+ {\r
+ uint8_t SelectedChipMask = Dataflash_GetSelectedChip();\r
+\r
+ Dataflash_DeselectChip();\r
+ Dataflash_SelectChip(SelectedChipMask);\r
+ }\r
+\r
+ /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main\r
+ * memory page program or main memory to buffer transfer.\r
+ */\r
+ static inline void Dataflash_WaitWhileBusy(void)\r
+ {\r
+ Dataflash_ToggleSelectedChipCS();\r
+ Dataflash_SendByte(DF_CMD_GETSTATUS);\r
+ while (!(Dataflash_ReceiveByte() & DF_STATUS_READY));\r
+ Dataflash_ToggleSelectedChipCS();\r
+ }\r
+\r
+ /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with\r
+ * dataflash commands which require a complete 24-bit address.\r
+ *\r
+ * \param[in] PageAddress Page address within the selected dataflash IC\r
+ * \param[in] BufferByte Address within the dataflash's buffer\r
+ */\r
+ static inline void Dataflash_SendAddressBytes(uint16_t PageAddress,\r
+ const uint16_t BufferByte)\r
+ {\r
+ Dataflash_SendByte(PageAddress >> 5);\r
+ Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8));\r
+ Dataflash_SendByte(BufferByte);\r
+ }\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific joystick driver header for the Atmel STK526.\r
+ * \copydetails Group_Joystick_STK526\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the joystick driver\r
+ * dispatch header located in LUFA/Drivers/Board/Joystick.h.\r
+ */\r
+\r
+/** \ingroup Group_Joystick\r
+ * \defgroup Group_Joystick_STK526 STK526\r
+ * \brief Board specific joystick driver header for the Atmel STK526.\r
+ *\r
+ * Board specific joystick driver header for the Atmel STK526.\r
+ *\r
+ * <table>\r
+ * <tr><th>Left Port Pin</th><th>Up Port Pin</th><th>Right Port Pin</th><th>Down Port Pin</th><th>Press Port Pin</th></tr>\r
+ * <tr><td>PORTB.4</td><td>PORTB.5</td><td>PORTB.6</td><td>PORTB.7</td><td>PORTB.0</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __JOYSTICK_STK526_H__\r
+#define __JOYSTICK_STK526_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_JOYSTICK_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define JOY_BMASK ((1 << 0) | (1 << 4) | (1 << 5) | (1 << 6) | (1 << 7))\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the joystick being pushed in the left direction. */\r
+ #define JOY_LEFT (1 << 4)\r
+\r
+ /** Mask for the joystick being pushed in the right direction. */\r
+ #define JOY_RIGHT (1 << 6)\r
+\r
+ /** Mask for the joystick being pushed in the upward direction. */\r
+ #define JOY_UP (1 << 5)\r
+\r
+ /** Mask for the joystick being pushed in the downward direction. */\r
+ #define JOY_DOWN (1 << 7)\r
+\r
+ /** Mask for the joystick being pushed inward. */\r
+ #define JOY_PRESS (1 << 0)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Joystick_Init(void)\r
+ {\r
+ DDRB &= ~JOY_BMASK;\r
+\r
+ PORTB |= JOY_BMASK;\r
+ }\r
+\r
+ static inline void Joystick_Disable(void)\r
+ {\r
+ DDRB &= ~JOY_BMASK;\r
+\r
+ PORTB &= ~JOY_BMASK;\r
+ }\r
+\r
+ static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Joystick_GetStatus(void)\r
+ {\r
+ return ((uint8_t)~PINB & JOY_BMASK);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Atmel STK526.\r
+ * \copydetails Group_LEDs_STK526\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_STK526 STK526\r
+ * \brief Board specific LED driver header for the Atmel STK526.\r
+ *\r
+ * Board specific LED driver header for the Atmel STK526.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.1</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.0</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.5</td></tr>\r
+ * <tr><td>LEDS_LED4</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.4</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_STK526_H__\r
+#define __LEDS_STK526_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 1)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 0)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 5)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1 << 4)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the PJRC Teensy 1.x/2.x boards.\r
+ * \copydetails Group_LEDs_TEENSY\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_TEENSY2 TEENSY2\r
+ * \brief Board specific LED driver header for the PJRC Teensy 2 boards.\r
+ *\r
+ * See \ref Group_LEDs_TEENSY for more details.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_TEENSY TEENSY\r
+ * \brief Board specific LED driver header for the PJRC Teensy 1.x/2.x boards.\r
+ *\r
+ * \note For version 2 Teensy boards, compile with <code>BOARD = TEENSY2</code>.\r
+ *\r
+ * Board specific LED driver header for the PJRC Teensy boards (http://www.pjrc.com/teensy/index.html).\r
+ *\r
+ * <b>TEENSY</b>:\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.6</td></tr>\r
+ * </table>\r
+ *\r
+ * <b>TEENSY2</b>:\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>Low</td><td>PORTD.6</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_TEENSY_H__\r
+#define __LEDS_TEENSY_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 6)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS LEDS_LED1\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+\r
+ #if (BOARD == BOARD_TEENSY2)\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ #else\r
+ PORTD |= LEDS_ALL_LEDS;\r
+ #endif\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ #if (BOARD == BOARD_TEENSY2)\r
+ PORTD |= LEDMask;\r
+ #else\r
+ PORTD &= ~LEDMask;\r
+ #endif\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ #if (BOARD == BOARD_TEENSY2)\r
+ PORTD &= ~LEDMask;\r
+ #else\r
+ PORTD |= LEDMask;\r
+ #endif\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ #if (BOARD == BOARD_TEENSY2)\r
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);\r
+ #else\r
+ PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask);\r
+ #endif\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ #if (BOARD == BOARD_TEENSY2)\r
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
+ #else\r
+ PORTD = ((PORTD | LEDMask) & ~ActiveMask);\r
+ #endif\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ #if (BOARD == BOARD_TEENSY2)\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ #else\r
+ return (~PORTD & LEDS_ALL_LEDS);\r
+ #endif\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the TUL.\r
+ * \copydetails Group_Buttons_TUL\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_TUL TUL\r
+ * \brief Board specific Buttons driver header for the TUL.\r
+ *\r
+ * Board specific Buttons driver header for the Busware TUL (http://www.busware.de/tiki-index.php?page=TUL).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTE.2</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_TUL_H__\r
+#define __BUTTONS_TUL_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 2)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Busware TUL.\r
+ * \copydetails Group_LEDs_TUL\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_TUL TUL\r
+ * \brief Board specific LED driver header for the Busware TUL.\r
+ *\r
+ * Board specific LED driver header for the Busware TUL (http://www.busware.de/tiki-index.php?page=TUL).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTF.0</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_TUL_H__\r
+#define __LEDS_TUL_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 0)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS LEDS_LED1\r
+\r
+ /** LED mask for the none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRF |= LEDS_ALL_LEDS;\r
+ PORTF &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRF &= ~LEDS_ALL_LEDS;\r
+ PORTF &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTF |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTF &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTF = ((PORTF & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTF = ((PORTF & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINF = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTF & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the UDIP.\r
+ * \copydetails Group_Buttons_UDIP\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_UDIP UDIP\r
+ * \brief Board specific Buttons driver header for the UDIP.\r
+ *\r
+ * Board specific Buttons driver header for the Linnix UDIP (http://linnix.com/udip/).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_UDIP_H__\r
+#define __BUTTONS_UDIP_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Linnix UDIP.\r
+ * \copydetails Group_LEDs_UDIP\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_UDIP UDIP\r
+ * \brief Board specific LED driver header for the Linnix UDIP.\r
+ *\r
+ * Board specific LED driver header for the Linnix UDIP (http://linnix.com/udip/).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>Bicolor Indicator 1</td><td>High</td><td>PORTB.6</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Red</td><td>Bicolor Indicator 1</td><td>High</td><td>PORTB.5</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Green</td><td>Bicolor Indicator 2</td><td>High</td><td>PORTD.5</td></tr>\r
+ * <tr><td>LEDS_LED4</td><td>Red</td><td>Bicolor Indicator 2</td><td>High</td><td>PORTD.4</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_UDIP_H__\r
+#define __LEDS_UDIP_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define LEDS_PORTB_LEDS (LEDS_LED1 | LEDS_LED2)\r
+ #define LEDS_PORTD_LEDS (LEDS_LED3 | LEDS_LED4)\r
+\r
+ #define LEDS_PORTD_MASK_SHIFT 1\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 6)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 5)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 ((1 << 5) >> LEDS_PORTD_MASK_SHIFT)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 ((1 << 4) >> LEDS_PORTD_MASK_SHIFT)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRB |= LEDS_PORTB_LEDS;\r
+ DDRD |= (LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRB &= ~LEDS_PORTB_LEDS;\r
+ DDRD &= ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB |= (LEDMask & LEDS_PORTB_LEDS);\r
+ PORTD |= ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB &= ~(LEDMask & LEDS_PORTB_LEDS);\r
+ PORTD &= ~((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB = (PORTB & ~LEDS_PORTB_LEDS) | (LEDMask & LEDS_PORTB_LEDS);\r
+ PORTD = (PORTD & ~(LEDS_PORTD_LEDS << LEDS_PORTD_MASK_SHIFT)) |\r
+ ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTB = (PORTB & ~(LEDMask & LEDS_PORTB_LEDS)) | (ActiveMask & LEDS_PORTB_LEDS);\r
+ PORTD = (PORTD & ~((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT)) |\r
+ ((ActiveMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINB = (LEDMask & LEDS_PORTB_LEDS);\r
+ PIND = ((LEDMask & LEDS_PORTD_LEDS) << LEDS_PORTD_MASK_SHIFT);\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return ((PORTB & LEDS_PORTB_LEDS) | ((PORTD & LEDS_PORTD_LEDS) >> LEDS_PORTD_MASK_SHIFT));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Arduino Uno.\r
+ * \copydetails Group_LEDs_UNO\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_UNO UNO\r
+ * \brief Board specific LED driver header for the Arduino Uno.\r
+ *\r
+ * Board specific LED driver header for the Arduino Uno (http://arduino.cc/en/Main/ArduinoBoardUno).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Yellow</td><td>RX</td><td>Low</td><td>PORTD.4</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Yellow</td><td>TX</td><td>Low</td><td>PORTD.5</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_UNO_H__\r
+#define __LEDS_UNO_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 5)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD |= LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD | LEDMask) & ~ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Paranoid Studio USB2AX.\r
+ * \copydetails Group_Buttons_USB2AX\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_USB2AX_V3 USB2AX_V3\r
+ * \brief Board specific Button driver header for the Paranoid Studio USB2AX revision 3.\r
+ *\r
+ * See \ref Group_Buttons_USB2AX for more details.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_USB2AX USB2AX\r
+ * \brief Board specific Buttons driver header for the Paranoid Studio USB2AX.\r
+ *\r
+ * \note For version 3 USB2AX boards, compile with <code>BOARD = USB2AX_V3</code>.\r
+ *\r
+ * Board specific Buttons driver header for the Paranoid Studio USB2AX (http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_USB2AX_H__\r
+#define __BUTTONS_USB2AX_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Paranoid Studio USB2AX.\r
+ * \copydetails Group_LEDs_USB2AX\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+ \r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_USB2AX_V3 USB2AX_V3\r
+ * \brief Board specific LED driver header for the Paranoid Studio USB2AX revision 3.\r
+ *\r
+ * See \ref Group_LEDs_USB2AX for more details.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_USB2AX USB2AX\r
+ * \brief Board specific LED driver header for the Paranoid Studio USB2AX.\r
+ *\r
+ * \note For version 3 USB2AX boards, compile with <code>BOARD = USB2AX_V3</code>.\r
+ *\r
+ * Board specific LED driver header for the Paranoid Studio USB2AX (http://paranoidstudio.assembla.com/wiki/show/paranoidstudio/USB2AX).\r
+ *\r
+ * <b>USB2AX</b>:\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTC.6</td></tr>\r
+ * </table>\r
+ *\r
+ * <b>USB2AX_V3</b>:\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>High</td><td>PORTD.1</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_USB2AX_H__\r
+#define __LEDS_USB2AX_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #if (BOARD == BOARD_USB2AX)\r
+ #define USB2AX_LEDS_LED1 (1 << 6)\r
+ #else\r
+ #define USB2AX_LEDS_LED1 (1 << 1) \r
+ #endif\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 USB2AX_LEDS_LED1\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS LEDS_LED1\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ #if (BOARD == BOARD_USB2AX)\r
+ DDRC |= LEDS_ALL_LEDS;\r
+ PORTC &= ~LEDS_ALL_LEDS; \r
+ #else\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS; \r
+ #endif \r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ #if (BOARD == BOARD_USB2AX)\r
+ DDRC &= ~LEDS_ALL_LEDS;\r
+ PORTC &= ~LEDS_ALL_LEDS; \r
+ #else\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS; \r
+ #endif \r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ #if (BOARD == BOARD_USB2AX)\r
+ PORTC |= LEDMask; \r
+ #else\r
+ PORTD |= LEDMask;\r
+ #endif\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ #if (BOARD == BOARD_USB2AX)\r
+ PORTC &= ~LEDMask;\r
+ #else\r
+ PORTD &= ~LEDMask;\r
+ #endif\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ #if (BOARD == BOARD_USB2AX)\r
+ PORTC = ((PORTC & ~LEDS_ALL_LEDS) | LEDMask); \r
+ #else\r
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);\r
+ #endif\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ #if (BOARD == BOARD_USB2AX)\r
+ PORTC = ((PORTC & ~LEDMask) | ActiveMask); \r
+ #else\r
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
+ #endif\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ #if (BOARD == BOARD_USB2AX)\r
+ PINC = LEDMask; \r
+ #else\r
+ PIND = LEDMask;\r
+ #endif\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ #if (BOARD == BOARD_USB2AX)\r
+ return (PORTC & LEDS_ALL_LEDS); \r
+ #else\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ #endif\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Kernel Concepts USBFOO.\r
+ * \copydetails Group_Buttons_USBFOO\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_USBFOO USBFOO\r
+ * \brief Board specific Buttons driver header for the Kernel Concepts USBFOO.\r
+ *\r
+ * Board specific Buttons driver header for the Kernel Concepts USBFOO (http://shop.kernelconcepts.de/product_info.php?products_id=102).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_USBFOO_H__\r
+#define __BUTTONS_USBFOO_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Kernel Concepts USBFOO.\r
+ * \copydetails Group_LEDs_USBFOO\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_USBFOO USBFOO\r
+ * \brief Board specific LED driver header for the Kernel Concepts USBFOO.\r
+ *\r
+ * Board specific LED driver header for the Kernel Concepts USBFOO (http://shop.kernelconcepts.de/product_info.php?products_id=102).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>Low</td><td>PORTD.4</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_USBFOO_H__\r
+#define __LEDS_USBFOO_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS LEDS_LED1\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD |= LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD | LEDMask) & ~ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (~PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Atmel USBKEY.\r
+ * \copydetails Group_Buttons_USBKEY\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_USBKEY USBKEY\r
+ * \brief Board specific Buttons driver header for the Atmel USBKEY.\r
+ *\r
+ * Board specific Buttons driver header for the Atmel USBKEY.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTE.2</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_USBKEY_H__\r
+#define __BUTTONS_USBKEY_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 2)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRE &= ~BUTTONS_BUTTON1;\r
+ PORTE &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Dataflash driver header for the Atmel USBKEY.\r
+ * \copydetails Group_Dataflash_USBKEY\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+/** \ingroup Group_Dataflash\r
+ * \defgroup Group_Dataflash_USBKEY USBKEY\r
+ * \brief Board specific Dataflash driver header for the Atmel USBKEY.\r
+ *\r
+ * Board specific Dataflash driver header for the Atmel USBKEY board.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Select Pin</th><th>SPI Port</th></tr>\r
+ * <tr><td>DATAFLASH_CHIP1</td><td>AT45DB642D (8MB)</td><td>PORTE.0</td><td>SPI0</td></tr>\r
+ * <tr><td>DATAFLASH_CHIP2</td><td>AT45DB642D (8MB)</td><td>PORTE.1</td><td>SPI0</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __DATAFLASH_USBKEY_H__\r
+#define __DATAFLASH_USBKEY_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../../../Misc/AT45DB642D.h"\r
+ #include "../../../Peripheral/SPI.h"\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_DATAFLASH_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATAFLASH_CHIPCS_MASK ((1 << 1) | (1 << 0))\r
+ #define DATAFLASH_CHIPCS_DDR DDRE\r
+ #define DATAFLASH_CHIPCS_PORT PORTE\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */\r
+ #define DATAFLASH_TOTALCHIPS 2\r
+\r
+ /** Mask for no dataflash chip selected. */\r
+ #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK\r
+\r
+ /** Mask for the first dataflash chip selected. */\r
+ #define DATAFLASH_CHIP1 (1 << 1)\r
+\r
+ /** Mask for the second dataflash chip selected. */\r
+ #define DATAFLASH_CHIP2 (1 << 0)\r
+\r
+ /** Internal main memory page size for the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGE_SIZE 1024\r
+\r
+ /** Total number of pages inside each of the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGES 8192\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.\r
+ * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.\r
+ */\r
+ static inline void Dataflash_Init(void)\r
+ {\r
+ DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK;\r
+ DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)\r
+ {\r
+ return SPI_TransferByte(Byte);\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ */\r
+ static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SendByte(const uint8_t Byte)\r
+ {\r
+ SPI_SendByte(Byte);\r
+ }\r
+\r
+ /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_ReceiveByte(void)\r
+ {\r
+ return SPI_ReceiveByte();\r
+ }\r
+\r
+ /** Determines the currently selected dataflash chip.\r
+ *\r
+ * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected\r
+ * or a DATAFLASH_CHIPn mask (where n is the chip number).\r
+ */\r
+ static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_GetSelectedChip(void)\r
+ {\r
+ return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK);\r
+ }\r
+\r
+ /** Selects the given dataflash chip.\r
+ *\r
+ * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is\r
+ * the chip number).\r
+ */\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask)\r
+ {\r
+ DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask);\r
+ }\r
+\r
+ /** Deselects the current dataflash chip, so that no dataflash is selected. */\r
+ static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_DeselectChip(void)\r
+ {\r
+ Dataflash_SelectChip(DATAFLASH_NO_CHIP);\r
+ }\r
+\r
+ /** Selects a dataflash IC from the given page number, which should range from 0 to\r
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one\r
+ * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside\r
+ * the total number of pages contained in the boards dataflash ICs, all dataflash ICs\r
+ * are deselected.\r
+ *\r
+ * \param[in] PageAddress Address of the page to manipulate, ranging from\r
+ * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).\r
+ */\r
+ static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)\r
+ {\r
+ Dataflash_DeselectChip();\r
+\r
+ if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS))\r
+ return;\r
+\r
+ if (PageAddress & 0x01)\r
+ Dataflash_SelectChip(DATAFLASH_CHIP2);\r
+ else\r
+ Dataflash_SelectChip(DATAFLASH_CHIP1);\r
+ }\r
+\r
+ /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive\r
+ * a new command.\r
+ */\r
+ static inline void Dataflash_ToggleSelectedChipCS(void)\r
+ {\r
+ uint8_t SelectedChipMask = Dataflash_GetSelectedChip();\r
+\r
+ Dataflash_DeselectChip();\r
+ Dataflash_SelectChip(SelectedChipMask);\r
+ }\r
+\r
+ /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main\r
+ * memory page program or main memory to buffer transfer.\r
+ */\r
+ static inline void Dataflash_WaitWhileBusy(void)\r
+ {\r
+ Dataflash_ToggleSelectedChipCS();\r
+ Dataflash_SendByte(DF_CMD_GETSTATUS);\r
+ while (!(Dataflash_ReceiveByte() & DF_STATUS_READY));\r
+ Dataflash_ToggleSelectedChipCS();\r
+ }\r
+\r
+ /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with\r
+ * dataflash commands which require a complete 24-bit address.\r
+ *\r
+ * \param[in] PageAddress Page address within the selected dataflash IC\r
+ * \param[in] BufferByte Address within the dataflash's buffer\r
+ */\r
+ static inline void Dataflash_SendAddressBytes(uint16_t PageAddress,\r
+ const uint16_t BufferByte)\r
+ {\r
+ PageAddress >>= 1;\r
+\r
+ Dataflash_SendByte(PageAddress >> 5);\r
+ Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8));\r
+ Dataflash_SendByte(BufferByte);\r
+ }\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific joystick driver header for the Atmel USBKEY.\r
+ * \copydetails Group_Joystick_USBKEY\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the joystick driver\r
+ * dispatch header located in LUFA/Drivers/Board/Joystick.h.\r
+ */\r
+\r
+/** \ingroup Group_Joystick\r
+ * \defgroup Group_Joystick_USBKEY USBKEY\r
+ * \brief Board specific joystick driver header for the Atmel USBKEY.\r
+ *\r
+ * Board specific joystick driver header for the Atmel USBKEY.\r
+ *\r
+ * <table>\r
+ * <tr><th>Left Port Pin</th><th>Up Port Pin</th><th>Right Port Pin</th><th>Down Port Pin</th><th>Press Port Pin</th></tr>\r
+ * <tr><td>PORTB.6</td><td>PORTB.7</td><td>PORTE.4</td><td>PORTE.5</td><td>PORTB.5</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __JOYSTICK_USBKEY_H__\r
+#define __JOYSTICK_USBKEY_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_JOYSTICK_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define JOY_BMASK ((1 << 5) | (1 << 6) | (1 << 7))\r
+ #define JOY_EMASK ((1 << 4) | (1 << 5))\r
+\r
+ #define JOY_PORTE_MASK_SHIFT 1\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the joystick being pushed in the left direction. */\r
+ #define JOY_LEFT (1 << 6)\r
+\r
+ /** Mask for the joystick being pushed in the right direction. */\r
+ #define JOY_RIGHT ((1 << 4) >> JOY_PORTE_MASK_SHIFT)\r
+\r
+ /** Mask for the joystick being pushed in the upward direction. */\r
+ #define JOY_UP (1 << 7)\r
+\r
+ /** Mask for the joystick being pushed in the downward direction. */\r
+ #define JOY_DOWN ((1 << 5) >> JOY_PORTE_MASK_SHIFT)\r
+\r
+ /** Mask for the joystick being pushed inward. */\r
+ #define JOY_PRESS (1 << 5)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Joystick_Init(void)\r
+ {\r
+ DDRB &= ~JOY_BMASK;\r
+ DDRE &= ~JOY_EMASK;\r
+\r
+ PORTB |= JOY_BMASK;\r
+ PORTE |= JOY_EMASK;\r
+ }\r
+\r
+ static inline void Joystick_Disable(void)\r
+ {\r
+ DDRB &= ~JOY_BMASK;\r
+ DDRE &= ~JOY_EMASK;\r
+\r
+ PORTB &= ~JOY_BMASK;\r
+ PORTE &= ~JOY_EMASK;\r
+ }\r
+\r
+ static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Joystick_GetStatus(void)\r
+ {\r
+ return (((uint8_t)~PINB & JOY_BMASK) | (((uint8_t)~PINE & JOY_EMASK) >> JOY_PORTE_MASK_SHIFT));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Atmel USBKEY.\r
+ * \copydetails Group_LEDs_USBKEY\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_USBKEY USBKEY\r
+ * \brief Board specific LED driver header for the Atmel USBKEY.\r
+ *\r
+ * Board specific LED driver header for the Atmel USBKEY.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Red</td><td>Bicolor Indicator 1</td><td>Low</td><td>PORTD.4</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Green</td><td>Bicolor Indicator 1</td><td>Low</td><td>PORTD.5</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Red</td><td>Bicolor Indicator 2</td><td>Low</td><td>PORTD.6</td></tr>\r
+ * <tr><td>LEDS_LED4</td><td>Green</td><td>Bicolor Indicator 2</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_USBKEY_H__\r
+#define __LEDS_USBKEY_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 5)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 7)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1 << 6)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRD |= LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRD &= ~LEDS_ALL_LEDS;\r
+ PORTD &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDS_ALL_LEDS) | LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTD = ((PORTD & ~LEDMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PIND = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTD & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for Tom's USBTINY MKII.\r
+ * \copydetails Group_Buttons_USBTINYMKII\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_USBTINYMKII USBTINYMKII\r
+ * \brief Board specific Buttons driver header for Tom's USBTINY MKII.\r
+ *\r
+ * Board specific Buttons driver header for Tom's USBTINY MKII (http://tom-itx.dyndns.org:81/~webpage/).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>HWB Button</td><td>Low</td><td>PORTD.7</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_USBTINYMKII_H__\r
+#define __BUTTONS_USBTINYMKII_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 7)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD |= BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ DDRD &= ~BUTTONS_BUTTON1;\r
+ PORTD &= ~BUTTONS_BUTTON1;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for Tom's USBTINY MKII.\r
+ * \copydetails Group_LEDs_USBTINYMKII\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_USBTINYMKII USBTINYMKII\r
+ * \brief Board specific LED driver header for Tom's USBTINY MKII.\r
+ *\r
+ * Board specific LED driver header for Tom's USBTINY MKII (http://tom-itx.dyndns.org:81/~webpage/).\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Red</td><td>Bicolor Indicator 1</td><td>High</td><td>PORTB.6</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Green</td><td>Bicolor Indicator 1</td><td>High</td><td>PORTB.7</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Red</td><td>Target Power</td><td>High</td><td>PORTB.5</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_USBTINYMKII_H__\r
+#define __LEDS_USBTINYMKII_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 6)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 7)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 5)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRB |= LEDS_ALL_LEDS;\r
+ PORTB &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRB &= ~LEDS_ALL_LEDS;\r
+ PORTB &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTB |= LedMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTB &= ~LedMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LedMask)\r
+ {\r
+ PORTB = ((PORTB & ~LEDS_ALL_LEDS) | LedMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LedMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTB = ((PORTB & ~LedMask) | ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINB = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTB & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Dataflash driver header for the original Atmel XPLAIN.\r
+ * \copydetails Group_Dataflash_XPLAIN\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+/** \ingroup Group_Dataflash\r
+ * \defgroup Group_Dataflash_XPLAIN_REV1 XPLAIN_REV1\r
+ * \brief Board specific Dataflash driver header for the original Atmel XPLAIN, revision 1.\r
+ *\r
+ * See \ref Group_Dataflash_XPLAIN for more details.\r
+ */\r
+\r
+/** \ingroup Group_Dataflash\r
+ * \defgroup Group_Dataflash_XPLAIN XPLAIN\r
+ * \brief Board specific Dataflash driver header for the original Atmel XPLAIN.\r
+ *\r
+ * \note For the first revision XPLAIN board, compile with <code>BOARD = BOARD_XPLAIN_REV1</code>.\r
+ *\r
+ * Board specific Dataflash driver header for the Atmel XPLAIN.\r
+ *\r
+ * <b>Revision 1 Boards</b>:\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Select Pin</th><th>SPI Port</th></tr>\r
+ * <tr><td>DATAFLASH_CHIP1</td><td>AT45DB041D (512KB)</td><td>PORTB.5</td><td>SPI0</td></tr>\r
+ * </table>\r
+ *\r
+ * <b>Other Board Revisions</b>:\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Select Pin</th><th>SPI Port</th></tr>\r
+ * <tr><td>DATAFLASH_CHIP1</td><td>AT45DB642D (8MB)</td><td>PORTB.5</td><td>SPI0</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __DATAFLASH_XPLAIN_H__\r
+#define __DATAFLASH_XPLAIN_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ \r
+ #include "../../../Misc/AT45DB642D.h"\r
+ #include "../../../Peripheral/SPI.h"\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_DATAFLASH_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATAFLASH_CHIPCS_MASK (1 << 5)\r
+ #define DATAFLASH_CHIPCS_DDR DDRB\r
+ #define DATAFLASH_CHIPCS_PORT PORTB\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */\r
+ #define DATAFLASH_TOTALCHIPS 1\r
+\r
+ /** Mask for no dataflash chip selected. */\r
+ #define DATAFLASH_NO_CHIP DATAFLASH_CHIPCS_MASK\r
+\r
+ /** Mask for the first dataflash chip selected. */\r
+ #define DATAFLASH_CHIP1 0\r
+\r
+ #if ((BOARD != BOARD_XPLAIN_REV1) || defined(__DOXYGEN__))\r
+ /** Internal main memory page size for the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGE_SIZE 1024\r
+\r
+ /** Total number of pages inside each of the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGES 8192\r
+ #else\r
+ #define DATAFLASH_PAGE_SIZE 256\r
+\r
+ #define DATAFLASH_PAGES 2048\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.\r
+ * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.\r
+ */\r
+ static inline void Dataflash_Init(void)\r
+ {\r
+ DATAFLASH_CHIPCS_DDR |= DATAFLASH_CHIPCS_MASK;\r
+ DATAFLASH_CHIPCS_PORT |= DATAFLASH_CHIPCS_MASK;\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)\r
+ {\r
+ return SPI_TransferByte(Byte);\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ */\r
+ static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SendByte(const uint8_t Byte)\r
+ {\r
+ SPI_SendByte(Byte);\r
+ }\r
+\r
+ /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_ReceiveByte(void)\r
+ {\r
+ return SPI_ReceiveByte();\r
+ }\r
+\r
+ /** Determines the currently selected dataflash chip.\r
+ *\r
+ * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected\r
+ * or a DATAFLASH_CHIPn mask (where n is the chip number).\r
+ */\r
+ static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_GetSelectedChip(void)\r
+ {\r
+ return (DATAFLASH_CHIPCS_PORT & DATAFLASH_CHIPCS_MASK);\r
+ }\r
+\r
+ /** Selects the given dataflash chip.\r
+ *\r
+ * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is\r
+ * the chip number).\r
+ */\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask)\r
+ {\r
+ DATAFLASH_CHIPCS_PORT = ((DATAFLASH_CHIPCS_PORT & ~DATAFLASH_CHIPCS_MASK) | ChipMask);\r
+ }\r
+\r
+ /** Deselects the current dataflash chip, so that no dataflash is selected. */\r
+ static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_DeselectChip(void)\r
+ {\r
+ Dataflash_SelectChip(DATAFLASH_NO_CHIP);\r
+ }\r
+\r
+ /** Selects a dataflash IC from the given page number, which should range from 0 to\r
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one\r
+ * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside\r
+ * the total number of pages contained in the boards dataflash ICs, all dataflash ICs\r
+ * are deselected.\r
+ *\r
+ * \param[in] PageAddress Address of the page to manipulate, ranging from\r
+ * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).\r
+ */\r
+ static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)\r
+ {\r
+ Dataflash_DeselectChip();\r
+\r
+ if (PageAddress >= DATAFLASH_PAGES)\r
+ return;\r
+\r
+ Dataflash_SelectChip(DATAFLASH_CHIP1);\r
+ }\r
+\r
+ /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive\r
+ * a new command.\r
+ */\r
+ static inline void Dataflash_ToggleSelectedChipCS(void)\r
+ {\r
+ uint8_t SelectedChipMask = Dataflash_GetSelectedChip();\r
+\r
+ Dataflash_DeselectChip();\r
+ Dataflash_SelectChip(SelectedChipMask);\r
+ }\r
+\r
+ /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main\r
+ * memory page program or main memory to buffer transfer.\r
+ */\r
+ static inline void Dataflash_WaitWhileBusy(void)\r
+ {\r
+ Dataflash_ToggleSelectedChipCS();\r
+ Dataflash_SendByte(DF_CMD_GETSTATUS);\r
+ while (!(Dataflash_ReceiveByte() & DF_STATUS_READY));\r
+ Dataflash_ToggleSelectedChipCS();\r
+ }\r
+\r
+ /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with\r
+ * dataflash commands which require a complete 24-bit address.\r
+ *\r
+ * \param[in] PageAddress Page address within the selected dataflash IC\r
+ * \param[in] BufferByte Address within the dataflash's buffer\r
+ */\r
+ static inline void Dataflash_SendAddressBytes(uint16_t PageAddress,\r
+ const uint16_t BufferByte)\r
+ {\r
+ Dataflash_SendByte(PageAddress >> 5);\r
+ Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8));\r
+ Dataflash_SendByte(BufferByte);\r
+ }\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the original Atmel XPLAIN.\r
+ * \copydetails Group_LEDs_XPLAIN\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_XPLAIN_REV1 XPLAIN_REV1\r
+ * \brief Board specific LED driver header for the original Atmel XPLAIN, revision 1.\r
+ *\r
+ * See \ref Group_LEDs_XPLAIN for more details.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_XPLAIN XPLAIN\r
+ * \brief Board specific LED driver header for the original Atmel XPLAIN.\r
+ *\r
+ * Board specific LED driver header for the Atmel XPLAIN.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>General Indicator</td><td>Low</td><td>PORTB.6</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_XPLAIN_H__\r
+#define __LEDS_XPLAIN_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 6)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS LEDS_LED1\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ DDRB |= LEDS_ALL_LEDS;\r
+ PORTB |= LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ DDRB &= ~LEDS_ALL_LEDS;\r
+ PORTB &= ~LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB &= ~LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB |= LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB = ((PORTB | LEDS_ALL_LEDS) & ~LEDMask);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask,\r
+ const uint8_t ActiveMask)\r
+ {\r
+ PORTB = ((PORTB | LEDMask) & ~ActiveMask);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PINB = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (~PORTB & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Digital button board hardware driver.\r
+ *\r
+ * This file is the master dispatch header file for the board-specific Buttons driver, for boards containing\r
+ * physical pushbuttons connected to the microcontroller's GPIO pins.\r
+ *\r
+ * User code should include this file, which will in turn include the correct Button driver header file for the\r
+ * currently selected board.\r
+ *\r
+ * If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Buttons.h file in the user project\r
+ * directory.\r
+ *\r
+ * For possible \c BOARD makefile values, see \ref Group_BoardTypes.\r
+ */\r
+\r
+/** \ingroup Group_BoardDrivers\r
+ * \defgroup Group_Buttons Buttons Driver - LUFA/Drivers/Board/Buttons.h\r
+ * \brief Digital button board hardware driver.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Hardware buttons driver. This provides an easy to use driver for the hardware buttons present on many boards.\r
+ * It provides a way to easily configure and check the status of all the buttons on the board so that appropriate\r
+ * actions can be taken.\r
+ *\r
+ * If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Buttons.h file in the user project\r
+ * directory. Otherwise, it will include the appropriate built in board driver header file.\r
+ *\r
+ * For possible \c BOARD makefile values, see \ref Group_BoardTypes.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * // Initialize the button driver before first use\r
+ * Buttons_Init();\r
+ * \r
+ * printf("Waiting for button press...\r\n");\r
+ * \r
+ * // Loop until a board button has been pressed\r
+ * uint8_t ButtonPress;\r
+ * while (!(ButtonPress = Buttons_GetStatus())) {};\r
+ * \r
+ * // Display which button was pressed (assuming two board buttons)\r
+ * printf("Button pressed: %s\r\n", (ButtonPress == BUTTONS_BUTTON1) ? "Button 1" : "Button 2");\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_H__\r
+#define __BUTTONS_H__\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_BUTTONS_H\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ #if (BOARD == BOARD_NONE)\r
+ #error The Board Buttons driver cannot be used if the makefile BOARD option is not set.\r
+ #elif (BOARD == BOARD_USBKEY)\r
+ #include "AVR8/USBKEY/Buttons.h"\r
+ #elif (BOARD == BOARD_STK525)\r
+ #include "AVR8/STK525/Buttons.h"\r
+ #elif (BOARD == BOARD_STK526)\r
+ #include "AVR8/STK526/Buttons.h"\r
+ #elif (BOARD == BOARD_ATAVRUSBRF01)\r
+ #include "AVR8/ATAVRUSBRF01/Buttons.h"\r
+ #elif (BOARD == BOARD_BUMBLEB)\r
+ #include "AVR8/BUMBLEB/Buttons.h"\r
+ #elif (BOARD == BOARD_EVK527)\r
+ #include "AVR8/EVK527/Buttons.h"\r
+ #elif (BOARD == BOARD_USBTINYMKII)\r
+ #include "AVR8/USBTINYMKII/Buttons.h"\r
+ #elif (BOARD == BOARD_BENITO)\r
+ #include "AVR8/BENITO/Buttons.h"\r
+ #elif (BOARD == BOARD_JMDBU2)\r
+ #include "AVR8/JMDBU2/Buttons.h"\r
+ #elif (BOARD == BOARD_OLIMEX162)\r
+ #include "AVR8/OLIMEX162/Buttons.h"\r
+ #elif (BOARD == BOARD_USBFOO)\r
+ #include "AVR8/USBFOO/Buttons.h"\r
+ #elif (BOARD == BOARD_UDIP)\r
+ #include "AVR8/UDIP/Buttons.h"\r
+ #elif (BOARD == BOARD_CULV3)\r
+ #include "AVR8/CULV3/Buttons.h"\r
+ #elif (BOARD == BOARD_MINIMUS)\r
+ #include "AVR8/MINIMUS/Buttons.h"\r
+ #elif (BOARD == BOARD_MICROSIN162)\r
+ #include "AVR8/MICROSIN162/Buttons.h"\r
+ #elif (BOARD == BOARD_EVK1101)\r
+ #include "UC3/EVK1101/Buttons.h"\r
+ #elif (BOARD == BOARD_TUL)\r
+ #include "AVR8/TUL/Buttons.h"\r
+ #elif (BOARD == BOARD_EVK1100)\r
+ #include "UC3/EVK1100/Buttons.h"\r
+ #elif (BOARD == BOARD_EVK1104)\r
+ #include "UC3/EVK1104/Buttons.h"\r
+ #elif (BOARD == BOARD_A3BU_XPLAINED)\r
+ #include "XMEGA/A3BU_XPLAINED/Buttons.h"\r
+ #elif ((BOARD == BOARD_USB2AX) || (BOARD == BOARD_USB2AX_V3))\r
+ #include "AVR8/USB2AX/Buttons.h"\r
+ #elif ((BOARD == BOARD_MICROPENDOUS_32U2) || (BOARD == BOARD_MICROPENDOUS_A) || \\r
+ (BOARD == BOARD_MICROPENDOUS_1) || (BOARD == BOARD_MICROPENDOUS_2) || \\r
+ (BOARD == BOARD_MICROPENDOUS_3) || (BOARD == BOARD_MICROPENDOUS_4) || \\r
+ (BOARD == BOARD_MICROPENDOUS_REV1) || (BOARD == BOARD_MICROPENDOUS_REV2) || \\r
+ (BOARD == BOARD_MICROPENDOUS_DIP))\r
+ #include "AVR8/MICROPENDOUS/Buttons.h"\r
+ #elif (BOARD == BOARD_B1_XPLAINED)\r
+ #include "XMEGA/B1_XPLAINED/Buttons.h"\r
+ #elif (BOARD == BOARD_OLIMEX32U4)\r
+ #include "AVR8/OLIMEX32U4/Buttons.h" \r
+ #elif (BOARD == BOARD_OLIMEXT32U4)\r
+ #include "AVR8/OLIMEXT32U4/Buttons.h" \r
+ #elif (BOARD == BOARD_OLIMEXISPMK2)\r
+ #include "AVR8/OLIMEXISPMK2/Buttons.h" \r
+ #else\r
+ #include "Board/Buttons.h"\r
+ #endif\r
+\r
+ /* Pseudo-Functions for Doxygen: */\r
+ #if defined(__DOXYGEN__)\r
+ /** Initializes the buttons driver, so that the current button position can be read. This sets the appropriate\r
+ * I/O pins to an inputs with pull-ups enabled.\r
+ *\r
+ * This must be called before any Button driver functions are used.\r
+ */\r
+ static inline void Buttons_Init(void);\r
+\r
+ /** Disables the buttons driver, releasing the I/O pins back to their default high-impedance input mode. */\r
+ static inline void Buttons_Disable(void);\r
+\r
+ /** Returns a mask indicating which board buttons are currently pressed.\r
+ *\r
+ * \return Mask indicating which board buttons are currently pressed.\r
+ */\r
+ static inline uint_reg_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master include file for the board dataflash IC driver.\r
+ * \brief Atmel Dataflash storage IC board hardware driver.\r
+ *\r
+ * This file is the master dispatch header file for the board-specific Atmel dataflash driver, for boards containing\r
+ * Atmel Dataflash ICs for external non-volatile storage.\r
+ *\r
+ * User code should include this file, which will in turn include the correct dataflash driver header file for\r
+ * the currently selected board.\r
+ *\r
+ * If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Dataflash.h file in the user project\r
+ * directory.\r
+ *\r
+ * For possible \c BOARD makefile values, see \ref Group_BoardTypes.\r
+ */\r
+\r
+/** \ingroup Group_BoardDrivers\r
+ * \defgroup Group_Dataflash Dataflash Driver - LUFA/Drivers/Board/Dataflash.h\r
+ * \brief Atmel Dataflash storage IC board hardware driver.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Dataflash driver. This module provides an easy to use interface for the Dataflash ICs located on many boards,\r
+ * for the storage of large amounts of data into the Dataflash's non-volatile memory.\r
+ *\r
+ * If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Dataflash.h file in the user project\r
+ * directory. Otherwise, it will include the appropriate built in board driver header file.\r
+ *\r
+ * For possible \c BOARD makefile values, see \ref Group_BoardTypes.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * // Initialize the SPI and board Dataflash drivers before first use\r
+ * SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING |\r
+ * SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);\r
+ * Dataflash_Init();\r
+ * \r
+ * uint8_t WriteBuffer[DATAFLASH_PAGE_SIZE];\r
+ * uint8_t ReadBuffer[DATAFLASH_PAGE_SIZE];\r
+ * \r
+ * // Fill page write buffer with a repeating pattern\r
+ * for (uint16_t i = 0; i < DATAFLASH_PAGE_SIZE; i++)\r
+ * WriteBuffer[i] = (i & 0xFF);\r
+ * \r
+ * // Must select the chip of interest first before operating on it\r
+ * Dataflash_SelectChip(DATAFLASH_CHIP1);\r
+ * \r
+ * // Write to the Dataflash's first internal memory buffer\r
+ * printf("Writing data to first dataflash buffer:\r\n");\r
+ * Dataflash_SendByte(DF_CMD_BUFF1WRITE);\r
+ * Dataflash_SendAddressBytes(0, 0);\r
+ * \r
+ * for (uint16_t i = 0; i < DATAFLASH_PAGE_SIZE; i++)\r
+ * Dataflash_SendByte(WriteBuffer[i]);\r
+ * \r
+ * // Commit the Dataflash's first memory buffer to the non-volatile FLASH memory\r
+ * printf("Committing page to non-volatile memory page index 5:\r\n");\r
+ * Dataflash_SendByte(DF_CMD_BUFF1TOMAINMEMWITHERASE);\r
+ * Dataflash_SendAddressBytes(5, 0);\r
+ * Dataflash_WaitWhileBusy();\r
+ * \r
+ * // Read the page from non-volatile FLASH memory into the Dataflash's second memory buffer\r
+ * printf("Reading data into second dataflash buffer:\r\n");\r
+ * Dataflash_SendByte(DF_CMD_MAINMEMTOBUFF2);\r
+ * Dataflash_SendAddressBytes(5, 0);\r
+ * Dataflash_WaitWhileBusy();\r
+ * \r
+ * // Read the Dataflash's second internal memory buffer\r
+ * Dataflash_SendByte(DF_CMD_BUFF2READ);\r
+ * Dataflash_SendAddressBytes(0, 0);\r
+ * \r
+ * for (uint16_t i = 0; i < DATAFLASH_PAGE_SIZE; i++)\r
+ * ReadBuffer[i] = Dataflash_ReceiveByte();\r
+ * \r
+ * // Deselect the chip after use\r
+ * Dataflash_DeselectChip();\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __DATAFLASH_H__\r
+#define __DATAFLASH_H__\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_DATAFLASH_H\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #if !defined(__DOXYGEN__)\r
+ #define __GET_DATAFLASH_MASK2(x, y) x ## y\r
+ #define __GET_DATAFLASH_MASK(x) __GET_DATAFLASH_MASK2(DATAFLASH_CHIP,x)\r
+ #endif\r
+\r
+ /** Retrieves the Dataflash chip select mask for the given Dataflash chip index.\r
+ *\r
+ * \param[in] index Index of the dataflash chip mask to retrieve\r
+ *\r
+ * \return Mask for the given Dataflash chip's /CS pin\r
+ */\r
+ #define DATAFLASH_CHIP_MASK(index) __GET_DATAFLASH_MASK(index)\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.\r
+ *\r
+ * \note The microcontroller's physical interface driver connected to the Dataflash IC must be initialized before\r
+ * any of the dataflash commands are used. This is usually a SPI hardware port, but on some devices/boards may\r
+ * be a USART operating in SPI Master mode.\r
+ */\r
+ static inline void Dataflash_Init(void);\r
+\r
+ /** Determines the currently selected dataflash chip.\r
+ *\r
+ * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected\r
+ * or a \c DATAFLASH_CHIPn mask (where n is the chip number).\r
+ */\r
+ static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+\r
+ /** Selects the given dataflash chip.\r
+ *\r
+ * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of \c DATAFLASH_CHIPn mask (where n is\r
+ * the chip number).\r
+ */\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;\r
+\r
+ /** Deselects the current dataflash chip, so that no dataflash is selected. */\r
+ static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE;\r
+\r
+ /** Selects a dataflash IC from the given page number, which should range from 0 to\r
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one\r
+ * dataflash IC, this will select \ref DATAFLASH_CHIP1. If the given page number is outside\r
+ * the total number of pages contained in the boards dataflash ICs, all dataflash ICs\r
+ * are deselected.\r
+ *\r
+ * \param[in] PageAddress Address of the page to manipulate, ranging from\r
+ * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).\r
+ */\r
+ static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress);\r
+\r
+ /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive\r
+ * a new command.\r
+ */\r
+ static inline void Dataflash_ToggleSelectedChipCS(void);\r
+\r
+ /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main\r
+ * memory page program or main memory to buffer transfer.\r
+ */\r
+ static inline void Dataflash_WaitWhileBusy(void);\r
+\r
+ /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with\r
+ * dataflash commands which require a complete 24-bit address.\r
+ *\r
+ * \param[in] PageAddress Page address within the selected dataflash IC\r
+ * \param[in] BufferByte Address within the dataflash's buffer\r
+ */\r
+ static inline void Dataflash_SendAddressBytes(uint16_t PageAddress,\r
+ const uint16_t BufferByte);\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ */\r
+ static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+\r
+ /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+\r
+ /* Includes: */\r
+ #if (BOARD == BOARD_NONE)\r
+ #error The Board Dataflash driver cannot be used if the makefile BOARD option is not set.\r
+ #elif (BOARD == BOARD_USBKEY)\r
+ #include "AVR8/USBKEY/Dataflash.h"\r
+ #elif (BOARD == BOARD_STK525)\r
+ #include "AVR8/STK525/Dataflash.h"\r
+ #elif (BOARD == BOARD_STK526)\r
+ #include "AVR8/STK526/Dataflash.h"\r
+ #elif ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))\r
+ #include "AVR8/XPLAIN/Dataflash.h"\r
+ #elif (BOARD == BOARD_EVK527)\r
+ #include "AVR8/EVK527/Dataflash.h"\r
+ #elif (BOARD == BOARD_A3BU_XPLAINED)\r
+ #include "XMEGA/A3BU_XPLAINED/Dataflash.h"\r
+ #elif (BOARD == BOARD_B1_XPLAINED)\r
+ #include "XMEGA/B1_XPLAINED/Dataflash.h"\r
+ #else\r
+ #include "Board/Dataflash.h"\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Digital joystick board hardware driver.\r
+ *\r
+ * This file is the master dispatch header file for the board-specific Joystick driver, for boards containing a\r
+ * digital joystick.\r
+ *\r
+ * User code should include this file, which will in turn include the correct joystick driver header file for the\r
+ * currently selected board.\r
+ *\r
+ * If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Joystick.h file in the user project\r
+ * directory.\r
+ *\r
+ * For possible \c BOARD makefile values, see \ref Group_BoardTypes.\r
+ */\r
+\r
+/** \ingroup Group_BoardDrivers\r
+ * \defgroup Group_Joystick Joystick Driver - LUFA/Drivers/Board/Joystick.h\r
+ * \brief Digital joystick board hardware driver.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Hardware Joystick driver. This module provides an easy to use interface to control the hardware digital Joystick\r
+ * located on many boards.\r
+ *\r
+ * If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/Joystick.h file in the user project\r
+ * directory. Otherwise, it will include the appropriate built in board driver header file.\r
+ *\r
+ * For possible \c BOARD makefile values, see \ref Group_BoardTypes.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * // Initialize the board Joystick driver before first use\r
+ * Joystick_Init();\r
+ * \r
+ * printf("Waiting for joystick movement...\r\n");\r
+ * \r
+ * // Loop until a the joystick has been moved\r
+ * uint8_t JoystickMovement;\r
+ * while (!(JoystickMovement = Joystick_GetStatus())) {};\r
+ * \r
+ * // Display which direction the joystick was moved in\r
+ * printf("Joystick moved:\r\n");\r
+ * \r
+ * if (JoystickMovement & (JOY_UP | JOY_DOWN))\r
+ * printf("%s ", (JoystickMovement & JOY_UP) ? "Up" : "Down");\r
+ * \r
+ * if (JoystickMovement & (JOY_LEFT | JOY_RIGHT))\r
+ * printf("%s ", (JoystickMovement & JOY_LEFT) ? "Left" : "Right");\r
+ * \r
+ * if (JoystickMovement & JOY_PRESS)\r
+ * printf("Pressed");\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __JOYSTICK_H__\r
+#define __JOYSTICK_H__\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_JOYSTICK_H\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ #if (BOARD == BOARD_NONE)\r
+ #error The Board Joystick driver cannot be used if the makefile BOARD option is not set.\r
+ #elif (BOARD == BOARD_USBKEY)\r
+ #include "AVR8/USBKEY/Joystick.h"\r
+ #elif (BOARD == BOARD_STK525)\r
+ #include "AVR8/STK525/Joystick.h"\r
+ #elif (BOARD == BOARD_STK526)\r
+ #include "AVR8/STK526/Joystick.h"\r
+ #elif (BOARD == BOARD_BUMBLEB)\r
+ #include "AVR8/BUMBLEB/Joystick.h"\r
+ #elif (BOARD == BOARD_EVK527)\r
+ #include "AVR8/EVK527/Joystick.h"\r
+ #elif (BOARD == BOARD_EVK1101)\r
+ #include "UC3/EVK1101/Joystick.h"\r
+ #elif (BOARD == BOARD_EVK1100)\r
+ #include "UC3/EVK1100/Joystick.h"\r
+ #else\r
+ #include "Board/Joystick.h"\r
+ #endif\r
+\r
+ /* Pseudo-Functions for Doxygen: */\r
+ #if defined(__DOXYGEN__)\r
+ /** Initializes the joystick driver so that the joystick position can be read. This sets the appropriate\r
+ * I/O pins to inputs with their pull-ups enabled.\r
+ */\r
+ static inline void Joystick_Init(void);\r
+\r
+ /** Disables the joystick driver, releasing the I/O pins back to their default high-impedance input mode. */\r
+ static inline void Joystick_Disable(void);\r
+\r
+ /** Returns the current status of the joystick, as a mask indicating the direction the joystick is\r
+ * currently facing in (multiple bits can be set).\r
+ *\r
+ * \return Mask indicating the joystick direction - see corresponding board specific Joystick.h file\r
+ * for direction masks.\r
+ */\r
+ static inline uint_reg_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief LED board hardware driver.\r
+ *\r
+ * This file is the master dispatch header file for the board-specific LED driver, for boards containing user\r
+ * controllable LEDs.\r
+ *\r
+ * User code should include this file, which will in turn include the correct LED driver header file for the\r
+ * currently selected board.\r
+ *\r
+ * If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/LEDs.h file in the user project\r
+ * directory.\r
+ *\r
+ * For possible \c BOARD makefile values, see \ref Group_BoardTypes.\r
+ */\r
+\r
+/** \ingroup Group_BoardDrivers\r
+ * \defgroup Group_LEDs LEDs Driver - LUFA/Drivers/Board/LEDs.h\r
+ * \brief LED board hardware driver.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Hardware LEDs driver. This provides an easy to use driver for the hardware LEDs present on many boards. It\r
+ * provides an interface to configure, test and change the status of all the board LEDs.\r
+ *\r
+ * If the \c BOARD value is set to \c BOARD_USER, this will include the \c /Board/LEDs.h file in the user project\r
+ * directory. Otherwise, it will include the appropriate built in board driver header file. If the BOARD value\r
+ * is set to \c BOARD_NONE, this driver is silently disabled.\r
+ *\r
+ * For possible \c BOARD makefile values, see \ref Group_BoardTypes.\r
+ *\r
+ * \note To make code as compatible as possible, it is assumed that all boards carry a minimum of four LEDs. If\r
+ * a board contains less than four LEDs, the remaining LED masks are defined to 0 so as to have no effect.\r
+ * If other behavior is desired, either alias the remaining LED masks to existing LED masks via the -D\r
+ * switch in the project makefile, or alias them to nothing in the makefile to cause compilation errors when\r
+ * a non-existing LED is referenced in application code. Note that this means that it is possible to make\r
+ * compatible code for a board with no LEDs by making a board LED driver (see \ref Page_WritingBoardDrivers)\r
+ * which contains only stub functions and defines no LEDs.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * // Initialize the board LED driver before first use\r
+ * LEDs_Init();\r
+ * \r
+ * // Turn on each of the four LEDs in turn\r
+ * LEDs_SetAllLEDs(LEDS_LED1);\r
+ * Delay_MS(500);\r
+ * LEDs_SetAllLEDs(LEDS_LED2);\r
+ * Delay_MS(500);\r
+ * LEDs_SetAllLEDs(LEDS_LED3);\r
+ * Delay_MS(500);\r
+ * LEDs_SetAllLEDs(LEDS_LED4);\r
+ * Delay_MS(500);\r
+ * \r
+ * // Turn on all LEDs\r
+ * LEDs_SetAllLEDs(LEDS_ALL_LEDS);\r
+ * Delay_MS(1000);\r
+ * \r
+ * // Turn on LED 1, turn off LED 2, leaving LEDs 3 and 4 in their current state\r
+ * LEDs_ChangeLEDs((LEDS_LED1 | LEDS_LED2), LEDS_LED1);\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_H__\r
+#define __LEDS_H__\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_LEDS_H\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ #if (BOARD == BOARD_NONE)\r
+ static inline void LEDs_Init(void) {};\r
+ static inline void LEDs_Disable(void) {};\r
+ static inline void LEDs_TurnOnLEDs(const uint_reg_t LEDMask) {};\r
+ static inline void LEDs_TurnOffLEDs(const uint_reg_t LEDMask) {};\r
+ static inline void LEDs_SetAllLEDs(const uint_reg_t LEDMask) {};\r
+ static inline void LEDs_ChangeLEDs(const uint_reg_t LEDMask, const uint_reg_t ActiveMask) {};\r
+ static inline void LEDs_ToggleLEDs(const uint_reg_t LEDMask) {};\r
+ static inline uint_reg_t LEDs_GetLEDs(void) { return 0; }\r
+ #elif (BOARD == BOARD_USBKEY)\r
+ #include "AVR8/USBKEY/LEDs.h"\r
+ #elif (BOARD == BOARD_STK525)\r
+ #include "AVR8/STK525/LEDs.h"\r
+ #elif (BOARD == BOARD_STK526)\r
+ #include "AVR8/STK526/LEDs.h"\r
+ #elif (BOARD == BOARD_RZUSBSTICK)\r
+ #include "AVR8/RZUSBSTICK/LEDs.h"\r
+ #elif (BOARD == BOARD_ATAVRUSBRF01)\r
+ #include "AVR8/ATAVRUSBRF01/LEDs.h"\r
+ #elif ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))\r
+ #include "AVR8/XPLAIN/LEDs.h"\r
+ #elif (BOARD == BOARD_BUMBLEB)\r
+ #include "AVR8/BUMBLEB/LEDs.h"\r
+ #elif (BOARD == BOARD_EVK527)\r
+ #include "AVR8/EVK527/LEDs.h"\r
+ #elif ((BOARD == BOARD_TEENSY) || (BOARD == BOARD_TEENSY2))\r
+ #include "AVR8/TEENSY/LEDs.h"\r
+ #elif (BOARD == BOARD_USBTINYMKII)\r
+ #include "AVR8/USBTINYMKII/LEDs.h"\r
+ #elif (BOARD == BOARD_BENITO)\r
+ #include "AVR8/BENITO/LEDs.h"\r
+ #elif (BOARD == BOARD_JMDBU2)\r
+ #include "AVR8/JMDBU2/LEDs.h"\r
+ #elif (BOARD == BOARD_OLIMEX162)\r
+ #include "AVR8/OLIMEX162/LEDs.h"\r
+ #elif (BOARD == BOARD_USBFOO)\r
+ #include "AVR8/USBFOO/LEDs.h"\r
+ #elif (BOARD == BOARD_UDIP)\r
+ #include "AVR8/UDIP/LEDs.h"\r
+ #elif (BOARD == BOARD_BUI)\r
+ #include "AVR8/BUI/LEDs.h"\r
+ #elif (BOARD == BOARD_UNO)\r
+ #include "AVR8/UNO/LEDs.h"\r
+ #elif (BOARD == BOARD_CULV3)\r
+ #include "AVR8/CULV3/LEDs.h"\r
+ #elif (BOARD == BOARD_BLACKCAT)\r
+ #include "AVR8/BLACKCAT/LEDs.h"\r
+ #elif (BOARD == BOARD_MAXIMUS)\r
+ #include "AVR8/MAXIMUS/LEDs.h"\r
+ #elif (BOARD == BOARD_MINIMUS)\r
+ #include "AVR8/MINIMUS/LEDs.h"\r
+ #elif (BOARD == BOARD_ADAFRUITU4)\r
+ #include "AVR8/ADAFRUITU4/LEDs.h"\r
+ #elif (BOARD == BOARD_MICROSIN162)\r
+ #include "AVR8/MICROSIN162/LEDs.h"\r
+ #elif (BOARD == BOARD_SPARKFUN8U2)\r
+ #include "AVR8/SPARKFUN8U2/LEDs.h"\r
+ #elif (BOARD == BOARD_EVK1101)\r
+ #include "UC3/EVK1101/LEDs.h"\r
+ #elif (BOARD == BOARD_TUL)\r
+ #include "AVR8/TUL/LEDs.h"\r
+ #elif (BOARD == BOARD_EVK1100)\r
+ #include "UC3/EVK1100/LEDs.h"\r
+ #elif (BOARD == BOARD_EVK1104)\r
+ #include "UC3/EVK1104/LEDs.h"\r
+ #elif (BOARD == BOARD_A3BU_XPLAINED)\r
+ #include "XMEGA/A3BU_XPLAINED/LEDs.h"\r
+ #elif ((BOARD == BOARD_USB2AX) || (BOARD == BOARD_USB2AX_V3))\r
+ #include "AVR8/USB2AX/LEDs.h"\r
+ #elif ((BOARD == BOARD_MICROPENDOUS_REV1) || (BOARD == BOARD_MICROPENDOUS_REV2) || \\r
+ (BOARD == BOARD_MICROPENDOUS_32U2))\r
+ #include "AVR8/MICROPENDOUS/LEDs.h"\r
+ #elif (BOARD == BOARD_B1_XPLAINED)\r
+ #include "XMEGA/B1_XPLAINED/LEDs.h"\r
+ #elif (BOARD == BOARD_MULTIO)\r
+ #include "AVR8/MULTIO/LEDs.h"\r
+ #elif (BOARD == BOARD_BIGMULTIO)\r
+ #include "AVR8/BIGMULTIO/LEDs.h"\r
+ #elif (BOARD == BOARD_DUCE)\r
+ #include "AVR8/DUCE/LEDs.h"\r
+ #elif (BOARD == BOARD_OLIMEX32U4)\r
+ #include "AVR8/OLIMEX32U4/LEDs.h" \r
+ #elif (BOARD == BOARD_OLIMEXT32U4)\r
+ #include "AVR8/OLIMEXT32U4/LEDs.h" \r
+ #elif (BOARD == BOARD_OLIMEXISPMK2)\r
+ #include "AVR8/OLIMEXISPMK2/LEDs.h" \r
+ #else\r
+ #include "Board/LEDs.h"\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__DOXYGEN__)\r
+ #if !defined(LEDS_LED1)\r
+ #define LEDS_LED1 0\r
+ #endif\r
+\r
+ #if !defined(LEDS_LED2)\r
+ #define LEDS_LED2 0\r
+ #endif\r
+\r
+ #if !defined(LEDS_LED3)\r
+ #define LEDS_LED3 0\r
+ #endif\r
+\r
+ #if !defined(LEDS_LED4)\r
+ #define LEDS_LED4 0\r
+ #endif\r
+ #endif\r
+\r
+ /* Pseudo-Functions for Doxygen: */\r
+ #if defined(__DOXYGEN__)\r
+ /** Initializes the board LED driver so that the LEDs can be controlled. This sets the appropriate port\r
+ * I/O pins as outputs, and sets the LEDs to default to off.\r
+ */\r
+ static inline void LEDs_Init(void);\r
+\r
+ /** Disables the board LED driver, releasing the I/O pins back to their default high-impedance input mode. */\r
+ static inline void LEDs_Disable(void);\r
+\r
+ /** Turns on the LEDs specified in the given LED mask.\r
+ *\r
+ * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).\r
+ */\r
+ static inline void LEDs_TurnOnLEDs(const uint_reg_t LEDMask);\r
+\r
+ /** Turns off the LEDs specified in the given LED mask.\r
+ *\r
+ * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).\r
+ */\r
+ static inline void LEDs_TurnOffLEDs(const uint_reg_t LEDMask);\r
+\r
+ /** Turns off all LEDs not specified in the given LED mask, and turns on all the LEDs in the given LED\r
+ * mask.\r
+ *\r
+ * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).\r
+ */\r
+ static inline void LEDs_SetAllLEDs(const uint_reg_t LEDMask);\r
+\r
+ /** Turns off all LEDs in the LED mask that are not set in the active mask, and turns on all the LEDs\r
+ * specified in both the LED and active masks.\r
+ *\r
+ * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).\r
+ * \param[in] ActiveMask Mask of whether the LEDs in the LED mask should be turned on or off.\r
+ */\r
+ static inline void LEDs_ChangeLEDs(const uint_reg_t LEDMask,\r
+ const uint_reg_t ActiveMask);\r
+\r
+ /** Toggles all LEDs in the LED mask, leaving all others in their current states.\r
+ *\r
+ * \param[in] LEDMask Mask of the board LEDs to manipulate (see board-specific LEDs.h driver file).\r
+ */\r
+ static inline void LEDs_ToggleLEDs(const uint_reg_t LEDMask);\r
+\r
+ /** Returns the status of all the board LEDs; set LED masks in the return value indicate that the\r
+ * corresponding LED is on.\r
+ *\r
+ * \return Mask of the board LEDs which are currently turned on.\r
+ */\r
+ static inline uint_reg_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_TEMPERATURE_C\r
+#include "Temperature.h"\r
+\r
+#if defined(TEMPERATURE_SENSOR_DRIVER_COMPATIBLE)\r
+\r
+static const uint16_t PROGMEM Temperature_Lookup[TEMP_TABLE_SIZE] =\r
+{\r
+ 0x3B4, 0x3B0, 0x3AB, 0x3A6, 0x3A0, 0x39A, 0x394, 0x38E, 0x388, 0x381, 0x37A, 0x373,\r
+ 0x36B, 0x363, 0x35B, 0x353, 0x34A, 0x341, 0x338, 0x32F, 0x325, 0x31B, 0x311, 0x307,\r
+ 0x2FC, 0x2F1, 0x2E6, 0x2DB, 0x2D0, 0x2C4, 0x2B8, 0x2AC, 0x2A0, 0x294, 0x288, 0x27C,\r
+ 0x26F, 0x263, 0x256, 0x24A, 0x23D, 0x231, 0x225, 0x218, 0x20C, 0x200, 0x1F3, 0x1E7,\r
+ 0x1DB, 0x1CF, 0x1C4, 0x1B8, 0x1AC, 0x1A1, 0x196, 0x18B, 0x180, 0x176, 0x16B, 0x161,\r
+ 0x157, 0x14D, 0x144, 0x13A, 0x131, 0x128, 0x11F, 0x117, 0x10F, 0x106, 0x0FE, 0x0F7,\r
+ 0x0EF, 0x0E8, 0x0E1, 0x0DA, 0x0D3, 0x0CD, 0x0C7, 0x0C0, 0x0BA, 0x0B5, 0x0AF, 0x0AA,\r
+ 0x0A4, 0x09F, 0x09A, 0x096, 0x091, 0x08C, 0x088, 0x084, 0x080, 0x07C, 0x078, 0x074,\r
+ 0x071, 0x06D, 0x06A, 0x067, 0x064, 0x061, 0x05E, 0x05B, 0x058, 0x055, 0x053, 0x050,\r
+ 0x04E, 0x04C, 0x049, 0x047, 0x045, 0x043, 0x041, 0x03F, 0x03D, 0x03C, 0x03A, 0x038\r
+};\r
+\r
+int8_t Temperature_GetTemperature(void)\r
+{\r
+ uint16_t Temp_ADC = ADC_GetChannelReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | TEMP_ADC_CHANNEL_MASK);\r
+\r
+ if (Temp_ADC > pgm_read_word(&Temperature_Lookup[0]))\r
+ return TEMP_MIN_TEMP;\r
+\r
+ for (uint16_t Index = 0; Index < TEMP_TABLE_SIZE; Index++)\r
+ {\r
+ if (Temp_ADC > pgm_read_word(&Temperature_Lookup[Index]))\r
+ return (Index + TEMP_TABLE_OFFSET_DEGREES);\r
+ }\r
+\r
+ return TEMP_MAX_TEMP;\r
+}\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief NTC Temperature Sensor board hardware driver.\r
+ *\r
+ * Master include file for the board temperature sensor driver, for the USB boards which contain a temperature sensor.\r
+ */\r
+\r
+/** \ingroup Group_BoardDrivers\r
+ * \defgroup Group_Temperature Temperature Sensor Driver - LUFA/Drivers/Board/Temperature.h\r
+ * \brief NTC Temperature Sensor board hardware driver.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/Board/Temperature.c <i>(Makefile source module name: LUFA_SRC_TEMPERATURE)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Temperature sensor driver. This provides an easy to use interface for the hardware temperature sensor located\r
+ * on many boards. It provides an interface to configure the sensor and appropriate ADC channel, plus read out the\r
+ * current temperature in degrees C. It is designed for and will only work with the temperature sensor located on the\r
+ * official Atmel USB AVR boards, as each sensor has different characteristics.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * // Initialize the ADC and board temperature sensor drivers before first use\r
+ * ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128);\r
+ * Temperature_Init();\r
+ * \r
+ * // Display converted temperature in degrees Celsius\r
+ * printf("Current Temperature: %d Degrees\r\n", Temperature_GetTemperature());\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __TEMPERATURE_H__\r
+#define __TEMPERATURE_H__\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ /* Preprocessor Checks: */\r
+ #if ((BOARD == BOARD_USBKEY) || (BOARD == BOARD_STK525) || \\r
+ (BOARD == BOARD_STK526) || (BOARD == BOARD_EVK527))\r
+ #define TEMPERATURE_SENSOR_DRIVER_COMPATIBLE\r
+ #endif\r
+ \r
+ #if !defined(__INCLUDE_FROM_TEMPERATURE_C) && !defined(TEMPERATURE_SENSOR_DRIVER_COMPATIBLE)\r
+ #error The selected board does not contain a compatible temperature sensor.\r
+ #endif\r
+\r
+ #if defined(TEMPERATURE_SENSOR_DRIVER_COMPATIBLE)\r
+\r
+ /* Includes: */\r
+ #include "../Peripheral/ADC.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** ADC channel number for the temperature sensor. */\r
+ #define TEMP_ADC_CHANNEL 0\r
+\r
+ /** ADC channel MUX mask for the temperature sensor. */\r
+ #define TEMP_ADC_CHANNEL_MASK ADC_CHANNEL0\r
+\r
+ /** Size of the temperature sensor lookup table, in lookup values */\r
+ #define TEMP_TABLE_SIZE 120\r
+\r
+ /** Minimum returnable temperature from the \ref Temperature_GetTemperature() function. */\r
+ #define TEMP_MIN_TEMP TEMP_TABLE_OFFSET_DEGREES\r
+\r
+ /** Maximum returnable temperature from the \ref Temperature_GetTemperature() function. */\r
+ #define TEMP_MAX_TEMP ((TEMP_TABLE_SIZE - 1) + TEMP_TABLE_OFFSET_DEGREES)\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the temperature sensor driver, including setting up the appropriate ADC channel.\r
+ * This must be called before any other temperature sensor routines.\r
+ *\r
+ * \pre The ADC itself (not the ADC channel) must be configured separately before calling the\r
+ * temperature sensor functions.\r
+ */\r
+ static inline void Temperature_Init(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Temperature_Init(void)\r
+ {\r
+ ADC_SetupChannel(TEMP_ADC_CHANNEL);\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ /** Performs a complete ADC on the temperature sensor channel, and converts the result into a\r
+ * valid temperature between \ref TEMP_MIN_TEMP and \ref TEMP_MAX_TEMP in degrees Celsius.\r
+ *\r
+ * \return Signed temperature value in degrees Celsius.\r
+ */\r
+ int8_t Temperature_GetTemperature(void) ATTR_WARN_UNUSED_RESULT;\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define TEMP_TABLE_OFFSET_DEGREES -21\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+ #endif\r
+ \r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Atmel EVK1100.\r
+ * \copydetails Group_Buttons_EVK1100\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_EVK1100 EVK1100\r
+ * \brief Board specific Buttons driver header for the Atmel EVK1100.\r
+ *\r
+ * Board specific Buttons driver header for the Atmel EVK1100.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>SW0 Button</td><td>Low</td><td>GPIO88</td></tr>\r
+ * <tr><td>BUTTONS_BUTTON2</td><td>SW1 Button</td><td>Low</td><td>GPIO85</td></tr>\r
+ * <tr><td>BUTTONS_BUTTON3</td><td>SW2 Button</td><td>Low</td><td>GPIO82</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_EVK1100_H__\r
+#define __BUTTONS_EVK1100_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define BUTTONS_PORT 2\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask of the first button on the board */\r
+ #define BUTTONS_BUTTON1 (1UL << 24)\r
+\r
+ /** Mask of the second button on the board */\r
+ #define BUTTONS_BUTTON2 (1UL << 21)\r
+\r
+ /** Mask of the third button on the board */\r
+ #define BUTTONS_BUTTON3 (1UL << 18)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ AVR32_GPIO.port[BUTTONS_PORT].gpers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+ AVR32_GPIO.port[BUTTONS_PORT].puers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ AVR32_GPIO.port[BUTTONS_PORT].gperc = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+ AVR32_GPIO.port[BUTTONS_PORT].puerc = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+ }\r
+\r
+ static inline uint32_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint32_t Buttons_GetStatus(void)\r
+ {\r
+ return (~(AVR32_GPIO.port[JOY_MOVE_PORT].pvr & (BUTTONS_BUTTON1 | BUTTONS_BUTTON2)));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific joystick driver header for the Atmel EVK1100.\r
+ * \copydetails Group_Joystick_EVK1100\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the joystick driver\r
+ * dispatch header located in LUFA/Drivers/Board/Joystick.h.\r
+ */\r
+\r
+/** \ingroup Group_Joystick\r
+ * \defgroup Group_Joystick_EVK1100 EVK1100\r
+ * \brief Board specific joystick driver header for the Atmel EVK1100.\r
+ *\r
+ * Board specific joystick driver header for the Atmel EVK1100.\r
+ *\r
+ * <table>\r
+ * <tr><th>Left Port Pin</th><th>Up Port Pin</th><th>Right Port Pin</th><th>Down Port Pin</th><th>Press Port Pin</th></tr>\r
+ * <tr><td>GPIO25</td><td>GPIO26</td><td>GPIO28</td><td>GPIO27</td><td>GPIO20</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __JOYSTICK_EVK1100_H__\r
+#define __JOYSTICK_EVK1100_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_JOYSTICK_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define JOY_PORT 0\r
+ #define JOY_MASK ((1UL << 28) | (1UL << 27) | (1UL << 26) | (1UL << 25) | (1UL << 20))\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the joystick being pushed in the left direction. */\r
+ #define JOY_LEFT (1UL << 25)\r
+\r
+ /** Mask for the joystick being pushed in the upward direction. */\r
+ #define JOY_UP (1UL << 26)\r
+\r
+ /** Mask for the joystick being pushed in the right direction. */\r
+ #define JOY_RIGHT (1UL << 28)\r
+\r
+ /** Mask for the joystick being pushed in the downward direction. */\r
+ #define JOY_DOWN (1UL << 27)\r
+\r
+ /** Mask for the joystick being pushed inward. */\r
+ #define JOY_PRESS (1UL << 20)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Joystick_Init(void)\r
+ {\r
+ AVR32_GPIO.port[JOY_PORT].gpers = JOY_MASK;\r
+ AVR32_GPIO.port[JOY_PORT].gpers = JOY_MASK;\r
+ };\r
+\r
+ static inline void Joystick_Disable(void)\r
+ {\r
+ AVR32_GPIO.port[JOY_PORT].gperc = JOY_MASK;\r
+ AVR32_GPIO.port[JOY_PORT].gperc = JOY_MASK;\r
+ };\r
+\r
+ static inline uint32_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint32_t Joystick_GetStatus(void)\r
+ {\r
+ return (uint32_t)(~(AVR32_GPIO.port[JOY_PORT].pvr & JOY_MASK));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Atmel EVK1100.\r
+ * \copydetails Group_LEDs_EVK1100\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_EVK1100 EVK1100\r
+ * \brief Board specific LED driver header for the Atmel EVK1100.\r
+ *\r
+ * Board specific LED driver header for the Atmel EVK1100.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>LED0 LED</td><td>Low</td><td>GPIO51</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Green</td><td>LED1 LED</td><td>Low</td><td>GPIO52</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Green</td><td>LED2 LED</td><td>Low</td><td>GPIO53</td></tr>\r
+ * <tr><td>LEDS_LED4</td><td>Green</td><td>LED3 LED</td><td>Low</td><td>GPIO54</td></tr>\r
+ * <tr><td>LEDS_LED5</td><td>Green</td><td>LED4 LED</td><td>Low</td><td>GPIO59</td></tr>\r
+ * <tr><td>LEDS_LED6</td><td>Green</td><td>LED5 LED</td><td>Low</td><td>GPIO60</td></tr>\r
+ * <tr><td>LEDS_LED7</td><td>Green</td><td>LED6 LED</td><td>Low</td><td>GPIO61</td></tr>\r
+ * <tr><td>LEDS_LED8</td><td>Green</td><td>LED7 LED</td><td>Low</td><td>GPIO62</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_EVK1100_H__\r
+#define __LEDS_EVK1100_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define LEDS_PORT 1\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1UL << 19)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1UL << 20)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1UL << 21)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1UL << 22)\r
+\r
+ /** LED mask for the fifth LED on the board. */\r
+ #define LEDS_LED5 (1UL << 27)\r
+\r
+ /** LED mask for the sixth LED on the board. */\r
+ #define LEDS_LED6 (1UL << 28)\r
+\r
+ /** LED mask for the seventh LED on the board. */\r
+ #define LEDS_LED7 (1UL << 29)\r
+\r
+ /** LED mask for the eighth LED on the board. */\r
+ #define LEDS_LED8 (1UL << 30)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4 \\r
+ LEDS_LED5 | LEDS_LED6 | LEDS_LED7 | LEDS_LED8)\r
+\r
+ /** LED mask for the none of the board LEDs */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].gpers = LEDS_ALL_LEDS;\r
+ AVR32_GPIO.port[LEDS_PORT].oders = LEDS_ALL_LEDS;\r
+ AVR32_GPIO.port[LEDS_PORT].ovrs = LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].gperc = LEDS_ALL_LEDS;\r
+ AVR32_GPIO.port[LEDS_PORT].oderc = LEDS_ALL_LEDS;\r
+ AVR32_GPIO.port[LEDS_PORT].ovrc = LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint32_t LEDMask)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].ovrc = LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint32_t LEDMask)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].ovrs = LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint32_t LEDMask)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].ovrs = LEDS_ALL_LEDS;\r
+ AVR32_GPIO.port[LEDS_PORT].ovrc = LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint32_t LEDMask, const uint32_t ActiveMask)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].ovrs = LEDMask;\r
+ AVR32_GPIO.port[LEDS_PORT].ovrc = ActiveMask;\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint32_t LEDMask)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].ovrt = LEDMask;\r
+ }\r
+\r
+ static inline uint32_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint32_t LEDs_GetLEDs(void)\r
+ {\r
+ return (~AVR32_GPIO.port[LEDS_PORT].ovr & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Atmel EVK1101.\r
+ * \copydetails Group_Buttons_EVK1101\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_EVK1101 EVK1101\r
+ * \brief Board specific Buttons driver header for the Atmel EVK1101.\r
+ *\r
+ * Board specific Buttons driver header for the Atmel EVK1101.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>SW0 Button</td><td>Low</td><td>GPIO34</td></tr>\r
+ * <tr><td>BUTTONS_BUTTON2</td><td>SW1 Button</td><td>Low</td><td>GPIO35</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_EVK1101_H__\r
+#define __BUTTONS_EVK1101_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define BUTTONS_PORT 1\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask of the first button on the board */\r
+ #define BUTTONS_BUTTON1 (1UL << 2)\r
+\r
+ /** Mask of the second button on the board */\r
+ #define BUTTONS_BUTTON2 (1UL << 3)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ AVR32_GPIO.port[BUTTONS_PORT].gpers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+ AVR32_GPIO.port[BUTTONS_PORT].puers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ AVR32_GPIO.port[BUTTONS_PORT].gperc = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+ AVR32_GPIO.port[BUTTONS_PORT].puerc = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+ }\r
+\r
+ static inline uint32_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint32_t Buttons_GetStatus(void)\r
+ {\r
+ return (~(AVR32_GPIO.port[BUTTONS_PORT].pvr & (BUTTONS_BUTTON1 | BUTTONS_BUTTON2)));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific joystick driver header for the Atmel EVK1101.\r
+ * \copydetails Group_Joystick_EVK1101\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the joystick driver\r
+ * dispatch header located in LUFA/Drivers/Board/Joystick.h.\r
+ */\r
+\r
+/** \ingroup Group_Joystick\r
+ * \defgroup Group_Joystick_EVK1101 EVK1101\r
+ * \brief Board specific joystick driver header for the Atmel EVK1101.\r
+ *\r
+ * Board specific joystick driver header for the Atmel EVK1101.\r
+ *\r
+ * <table>\r
+ * <tr><th>Left Port Pin</th><th>Up Port Pin</th><th>Right Port Pin</th><th>Down Port Pin</th><th>Press Port Pin</th></tr>\r
+ * <tr><td>GPIO38</td><td>GPIO39</td><td>GPIO41</td><td>GPIO40</td><td>GPIO13</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __JOYSTICK_EVK1101_H__\r
+#define __JOYSTICK_EVK1101_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_JOYSTICK_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Joystick.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define JOY_MOVE_PORT 1\r
+ #define JOY_MOVE_MASK ((1UL << 6) | (1UL << 7) | (1UL << 8) | (1UL << 9))\r
+ #define JOY_PRESS_PORT 0\r
+ #define JOY_PRESS_MASK (1UL << 13)\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the joystick being pushed in the left direction. */\r
+ #define JOY_LEFT (1UL << 6)\r
+\r
+ /** Mask for the joystick being pushed in the upward direction. */\r
+ #define JOY_UP (1UL << 7)\r
+\r
+ /** Mask for the joystick being pushed in the right direction. */\r
+ #define JOY_RIGHT (1UL << 9)\r
+\r
+ /** Mask for the joystick being pushed in the downward direction. */\r
+ #define JOY_DOWN (1UL << 8)\r
+\r
+ /** Mask for the joystick being pushed inward. */\r
+ #define JOY_PRESS (1UL << 13)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Joystick_Init(void)\r
+ {\r
+ AVR32_GPIO.port[JOY_MOVE_PORT].gpers = JOY_MOVE_MASK;\r
+ AVR32_GPIO.port[JOY_PRESS_PORT].gpers = JOY_PRESS_MASK;\r
+\r
+ AVR32_GPIO.port[JOY_MOVE_PORT].puers = JOY_MOVE_MASK;\r
+ AVR32_GPIO.port[JOY_PRESS_PORT].puers = JOY_PRESS_MASK;\r
+ };\r
+\r
+ static inline void Joystick_Disable(void)\r
+ {\r
+ AVR32_GPIO.port[JOY_MOVE_PORT].gperc = JOY_MOVE_MASK;\r
+ AVR32_GPIO.port[JOY_PRESS_PORT].gperc = JOY_PRESS_MASK;\r
+\r
+ AVR32_GPIO.port[JOY_MOVE_PORT].puerc = JOY_MOVE_MASK;\r
+ AVR32_GPIO.port[JOY_PRESS_PORT].puerc = JOY_PRESS_MASK;\r
+ };\r
+\r
+ static inline uint32_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint32_t Joystick_GetStatus(void)\r
+ {\r
+ return (uint32_t)(~((AVR32_GPIO.port[JOY_MOVE_PORT].pvr & JOY_MOVE_MASK) |\r
+ (AVR32_GPIO.port[JOY_PRESS_PORT].pvr & JOY_PRESS_MASK)));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Atmel EVK1101.\r
+ * \copydetails Group_LEDs_EVK1101\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_EVK1101 EVK1101\r
+ * \brief Board specific LED driver header for the Atmel EVK1101.\r
+ *\r
+ * Board specific LED driver header for the Atmel EVK1101.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>LED0 LED</td><td>Low</td><td>GPIO7</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Green</td><td>LED1 LED</td><td>Low</td><td>GPIO8</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Green</td><td>LED2 LED</td><td>Low</td><td>GPIO21</td></tr>\r
+ * <tr><td>LEDS_LED4</td><td>Green</td><td>LED3 LED</td><td>Low</td><td>GPIO22</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_EVK1101_H__\r
+#define __LEDS_EVK1101_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define LEDS_PORT 0\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1UL << 7)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1UL << 8)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1UL << 21)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1UL << 22)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for the none of the board LEDs */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].gpers = LEDS_ALL_LEDS;\r
+ AVR32_GPIO.port[LEDS_PORT].oders = LEDS_ALL_LEDS;\r
+ AVR32_GPIO.port[LEDS_PORT].ovrs = LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].gperc = LEDS_ALL_LEDS;\r
+ AVR32_GPIO.port[LEDS_PORT].oderc = LEDS_ALL_LEDS;\r
+ AVR32_GPIO.port[LEDS_PORT].ovrc = LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint32_t LEDMask)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].ovrc = LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint32_t LEDMask)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].ovrs = LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint32_t LEDMask)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].ovrs = LEDS_ALL_LEDS;\r
+ AVR32_GPIO.port[LEDS_PORT].ovrc = LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint32_t LEDMask, const uint32_t ActiveMask)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].ovrs = LEDMask;\r
+ AVR32_GPIO.port[LEDS_PORT].ovrc = ActiveMask;\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint32_t LEDMask)\r
+ {\r
+ AVR32_GPIO.port[LEDS_PORT].ovrt = LEDMask;\r
+ }\r
+\r
+ static inline uint32_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint32_t LEDs_GetLEDs(void)\r
+ {\r
+ return (~AVR32_GPIO.port[LEDS_PORT].ovr & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Atmel EVK1104.\r
+ * \copydetails Group_Buttons_EVK1104\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_EVK1104 EVK1104\r
+ * \brief Board specific Buttons driver header for the Atmel EVK1104.\r
+ *\r
+ * Board specific Buttons driver header for the Atmel EVK1104.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>SW0 Button</td><td>Low</td><td>GPIO42</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_EVK1104_H__\r
+#define __BUTTONS_EVK1104_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define BUTTONS_PORT 1\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask of the first button on the board */\r
+ #define BUTTONS_BUTTON1 (1UL << 10)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ AVR32_GPIO.port[BUTTONS_PORT].gpers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+ AVR32_GPIO.port[BUTTONS_PORT].puers = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ AVR32_GPIO.port[BUTTONS_PORT].gperc = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+ AVR32_GPIO.port[BUTTONS_PORT].puerc = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2);\r
+ }\r
+\r
+ static inline uint32_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint32_t Buttons_GetStatus(void)\r
+ {\r
+ return (~(AVR32_GPIO.port[JOY_MOVE_PORT].pvr & (BUTTONS_BUTTON1 | BUTTONS_BUTTON2)));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Atmel EVK1104.\r
+ * \copydetails Group_LEDs_EVK1104\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_EVK1104 EVK1104\r
+ * \brief Board specific LED driver header for the Atmel EVK1104.\r
+ *\r
+ * Board specific LED driver header for the Atmel EVK1104.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Green</td><td>LED0 LED</td><td>Low</td><td>GPIO67</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Green</td><td>LED1 LED</td><td>Low</td><td>GPIO101</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Green</td><td>LED2 LED</td><td>Low</td><td>GPIO102</td></tr>\r
+ * <tr><td>LEDS_LED4</td><td>Green</td><td>LED3 LED</td><td>Low</td><td>GPIO105</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_EVK1104_H__\r
+#define __LEDS_EVK1104_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define LEDS_LEDMASK2 (1UL << 3)\r
+ #define LEDS_LEDMASK3 ((1UL << 9) | (1UL << 6) | (1UL << 5))\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1UL << 3)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1UL << 5)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1UL << 9)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1UL << 6)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+\r
+ /** LED mask for the none of the board LEDs */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ AVR32_GPIO.port[2].gpers = LEDS_LEDMASK2;\r
+ AVR32_GPIO.port[2].oders = LEDS_LEDMASK2;\r
+ AVR32_GPIO.port[2].ovrs = LEDS_LEDMASK2;\r
+\r
+ AVR32_GPIO.port[3].gpers = LEDS_LEDMASK3;\r
+ AVR32_GPIO.port[3].oders = LEDS_LEDMASK3;\r
+ AVR32_GPIO.port[3].ovrs = LEDS_LEDMASK3;\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ AVR32_GPIO.port[2].gperc = LEDS_LEDMASK2;\r
+ AVR32_GPIO.port[2].oderc = LEDS_LEDMASK2;\r
+ AVR32_GPIO.port[2].ovrc = LEDS_LEDMASK2;\r
+\r
+ AVR32_GPIO.port[3].gperc = LEDS_LEDMASK3;\r
+ AVR32_GPIO.port[3].oderc = LEDS_LEDMASK3;\r
+ AVR32_GPIO.port[3].ovrc = LEDS_LEDMASK3;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint32_t LEDMask)\r
+ {\r
+ AVR32_GPIO.port[2].ovrc = (LEDMask & LEDS_LEDMASK2);\r
+ AVR32_GPIO.port[3].ovrc = (LEDMask & LEDS_LEDMASK3);\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint32_t LEDMask)\r
+ {\r
+ AVR32_GPIO.port[2].ovrs = (LEDMask & LEDS_LEDMASK2);\r
+ AVR32_GPIO.port[3].ovrs = (LEDMask & LEDS_LEDMASK3);\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint32_t LEDMask)\r
+ {\r
+ AVR32_GPIO.port[2].ovrs = LEDS_LEDMASK2;\r
+ AVR32_GPIO.port[2].ovrc = (LEDMask & LEDS_LEDMASK2);\r
+\r
+ AVR32_GPIO.port[3].ovrs = LEDS_LEDMASK3;\r
+ AVR32_GPIO.port[3].ovrc = (LEDMask & LEDS_LEDMASK3);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint32_t LEDMask, const uint32_t ActiveMask)\r
+ {\r
+ AVR32_GPIO.port[2].ovrs = (LEDMask & LEDS_LEDMASK2);\r
+ AVR32_GPIO.port[2].ovrc = (ActiveMask & LEDS_LEDMASK2);\r
+\r
+ AVR32_GPIO.port[3].ovrs = (LEDMask & LEDS_LEDMASK3);\r
+ AVR32_GPIO.port[3].ovrc = (ActiveMask & LEDS_LEDMASK3);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint32_t LEDMask)\r
+ {\r
+ AVR32_GPIO.port[2].ovrt = (LEDMask & LEDS_LEDMASK2);\r
+ AVR32_GPIO.port[3].ovrt = (LEDMask & LEDS_LEDMASK3);\r
+ }\r
+\r
+ static inline uint32_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint32_t LEDs_GetLEDs(void)\r
+ {\r
+ return ((~AVR32_GPIO.port[2].ovr & LEDS_LEDMASK2) | (~AVR32_GPIO.port[3].ovr & LEDS_LEDMASK3));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Atmel XMEGA A3BU Xplained.\r
+ * \copydetails Group_Buttons_A3BU_XPLAINED\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_A3BU_XPLAINED A3BU_XPLAINED\r
+ * \brief Board specific Buttons driver header for the Atmel XMEGA A3BU Xplained.\r
+ *\r
+ * Board specific Buttons driver header for the Atmel XMEGA A3BU Xplained.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>SW0 Button</td><td>Low</td><td>PORTE.5</td></tr>\r
+ * <tr><td>BUTTONS_BUTTON2</td><td>SW1 Button</td><td>Low</td><td>PORTF.1</td></tr>\r
+ * <tr><td>BUTTONS_BUTTON3</td><td>SW2 Button</td><td>Low</td><td>PORTF.2</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_A3BU_XPLAINED_H__\r
+#define __BUTTONS_A3BU_XPLAINED_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 5)\r
+\r
+ /** Button mask for the second button on the board. */\r
+ #define BUTTONS_BUTTON2 (1 << 1)\r
+\r
+ /** Button mask for the third button on the board. */\r
+ #define BUTTONS_BUTTON3 (1 << 2)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ PORTE.OUTCLR = BUTTONS_BUTTON1;\r
+ PORTE.PIN5CTRL = (PORT_OPC_PULLUP_gc | PORT_INVEN_bm);\r
+\r
+ PORTF.OUTCLR = (BUTTONS_BUTTON2 | BUTTONS_BUTTON3);\r
+ PORTF.PIN1CTRL = (PORT_OPC_PULLUP_gc | PORT_INVEN_bm);\r
+ PORTF.PIN2CTRL = (PORT_OPC_PULLUP_gc | PORT_INVEN_bm);\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ PORTE.OUTCLR = BUTTONS_BUTTON1;\r
+ PORTE.PIN5CTRL = 0;\r
+ \r
+ PORTF.OUTCLR = (BUTTONS_BUTTON2 | BUTTONS_BUTTON3);\r
+ PORTF.PIN1CTRL = 0;\r
+ PORTF.PIN2CTRL = 0;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return ((PORTE_IN & BUTTONS_BUTTON1) | (PORTF_IN & (BUTTONS_BUTTON2 | BUTTONS_BUTTON3)));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Dataflash driver header for the Atmel XMEGA B1 Xplained.\r
+ * \copydetails Group_Dataflash_B1_XPLAINED\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+/** \ingroup Group_Dataflash\r
+ * \defgroup Group_Dataflash_B1_XPLAINED B1_XPLAINED\r
+ * \brief Board specific Dataflash driver header for the Atmel XMEGA B1 Xplained.\r
+ *\r
+ * Board specific Dataflash driver header for the Atmel XMEGA B1 Xplained board.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Select Pin</th><th>SPI Port</th></tr>\r
+ * <tr><td>DATAFLASH_CHIP1</td><td>AT45DB642D (8MB)</td><td>PORTF.4</td><td>USARTD0 (In SPI Mode)</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __DATAFLASH_B1_XPLAINED_H__\r
+#define __DATAFLASH_B1_XPLAINED_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../../../Misc/AT45DB642D.h"\r
+ #include "../../../Peripheral/SerialSPI.h"\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_DATAFLASH_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATAFLASH_CHIPCS_MASK (1 << 4)\r
+ #define DATAFLASH_CHIPCS_PORT PORTF\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */\r
+ #define DATAFLASH_TOTALCHIPS 1\r
+\r
+ /** Mask for no dataflash chip selected. */\r
+ #define DATAFLASH_NO_CHIP 0\r
+\r
+ /** Mask for the first dataflash chip selected. */\r
+ #define DATAFLASH_CHIP1 (1 << 4)\r
+\r
+ /** Internal main memory page size for the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGE_SIZE 1024\r
+\r
+ /** Total number of pages inside each of the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGES 8192\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.\r
+ * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.\r
+ */\r
+ static inline void Dataflash_Init(void)\r
+ {\r
+ DATAFLASH_CHIPCS_PORT.DIRSET = DATAFLASH_CHIPCS_MASK;\r
+ \r
+ PORTCFG.MPCMASK = DATAFLASH_CHIPCS_MASK;\r
+ DATAFLASH_CHIPCS_PORT.PIN0CTRL = PORT_INVEN_bm; \r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)\r
+ {\r
+ return SerialSPI_TransferByte(&USARTD0, Byte);\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ */\r
+ static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SendByte(const uint8_t Byte)\r
+ {\r
+ SerialSPI_SendByte(&USARTD0, Byte);\r
+ }\r
+\r
+ /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_ReceiveByte(void)\r
+ {\r
+ return SerialSPI_ReceiveByte(&USARTD0);\r
+ }\r
+\r
+ /** Determines the currently selected dataflash chip.\r
+ *\r
+ * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected\r
+ * or a DATAFLASH_CHIPn mask (where n is the chip number).\r
+ */\r
+ static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_GetSelectedChip(void)\r
+ {\r
+ return (DATAFLASH_CHIPCS_PORT.OUT & DATAFLASH_CHIPCS_MASK);\r
+ }\r
+\r
+ /** Selects the given dataflash chip.\r
+ *\r
+ * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is\r
+ * the chip number).\r
+ */\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask)\r
+ {\r
+ DATAFLASH_CHIPCS_PORT.OUTCLR = DATAFLASH_CHIPCS_MASK;\r
+ DATAFLASH_CHIPCS_PORT.OUTSET = ChipMask;\r
+ }\r
+\r
+ /** Deselects the current dataflash chip, so that no dataflash is selected. */\r
+ static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_DeselectChip(void)\r
+ {\r
+ Dataflash_SelectChip(DATAFLASH_NO_CHIP);\r
+ }\r
+\r
+ /** Selects a dataflash IC from the given page number, which should range from 0 to\r
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one\r
+ * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside\r
+ * the total number of pages contained in the boards dataflash ICs, all dataflash ICs\r
+ * are deselected.\r
+ *\r
+ * \param[in] PageAddress Address of the page to manipulate, ranging from\r
+ * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).\r
+ */\r
+ static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)\r
+ {\r
+ Dataflash_DeselectChip();\r
+\r
+ if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS))\r
+ return;\r
+\r
+ Dataflash_SelectChip(DATAFLASH_CHIP1);\r
+ }\r
+\r
+ /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive\r
+ * a new command.\r
+ */\r
+ static inline void Dataflash_ToggleSelectedChipCS(void)\r
+ {\r
+ uint8_t SelectedChipMask = Dataflash_GetSelectedChip();\r
+\r
+ Dataflash_DeselectChip();\r
+ Dataflash_SelectChip(SelectedChipMask);\r
+ }\r
+\r
+ /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main\r
+ * memory page program or main memory to buffer transfer.\r
+ */\r
+ static inline void Dataflash_WaitWhileBusy(void)\r
+ {\r
+ Dataflash_ToggleSelectedChipCS();\r
+ Dataflash_SendByte(DF_CMD_GETSTATUS);\r
+ while (!(Dataflash_ReceiveByte() & DF_STATUS_READY));\r
+ Dataflash_ToggleSelectedChipCS();\r
+ }\r
+\r
+ /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with\r
+ * dataflash commands which require a complete 24-bit address.\r
+ *\r
+ * \param[in] PageAddress Page address within the selected dataflash IC\r
+ * \param[in] BufferByte Address within the dataflash's buffer\r
+ */\r
+ static inline void Dataflash_SendAddressBytes(uint16_t PageAddress,\r
+ const uint16_t BufferByte)\r
+ {\r
+ Dataflash_SendByte(PageAddress >> 5);\r
+ Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8));\r
+ Dataflash_SendByte(BufferByte);\r
+ }\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Atmel XMEGA A3BU Xplained.\r
+ * \copydetails Group_LEDs_A3BU_XPLAINED\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_A3BU_XPLAINED A3BU_XPLAINED\r
+ * \brief Board specific LED driver header for the Atmel XMEGA A3BU Xplained.\r
+ *\r
+ * Board specific LED driver header for the Atmel XMEGA A3BU Xplained.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Yellow</td><td>LED0 LED</td><td>Low</td><td>PORTR.0</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Yellow</td><td>LED1 LED</td><td>Low</td><td>PORTR.1</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_A3BU_XPLAINED_H__\r
+#define __LEDS_A3BU_XPLAINED_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 0)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 1)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ PORTR.DIRSET = LEDS_ALL_LEDS;\r
+ PORTR.OUTCLR = LEDS_ALL_LEDS;\r
+ \r
+ PORTCFG.MPCMASK = LEDS_ALL_LEDS;\r
+ PORTR.PIN0CTRL = PORT_INVEN_bm; \r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ PORTR.DIRCLR = LEDS_ALL_LEDS;\r
+ PORTR.OUTCLR = LEDS_ALL_LEDS;\r
+\r
+ PORTCFG.MPCMASK = 0;\r
+ PORTR.PIN0CTRL = LEDS_ALL_LEDS;\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTR_OUTSET = LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTR_OUTCLR = LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTR_OUT = (PORTR.OUT & ~LEDS_ALL_LEDS) | LEDMask;\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)\r
+ {\r
+ PORTR_OUT = (PORTR.OUT & ~LEDMask) | ActiveMask;\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTR_OUTTGL = LEDMask;\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return (PORTR_OUT & LEDS_ALL_LEDS);\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Buttons driver header for the Atmel XMEGA B1 Xplained.\r
+ * \copydetails Group_Buttons_B1_XPLAINED\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the Buttons driver\r
+ * dispatch header located in LUFA/Drivers/Board/Buttons.h.\r
+ */\r
+\r
+/** \ingroup Group_Buttons\r
+ * \defgroup Group_Buttons_B1_XPLAINED B1_XPLAINED\r
+ * \brief Board specific Buttons driver header for the Atmel XMEGA B1 Xplained.\r
+ *\r
+ * Board specific Buttons driver header for the Atmel XMEGA B1 Xplained.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>BUTTONS_BUTTON1</td><td>Touch CS0 Button</td><td>Low</td><td>PORTE.0</td></tr>\r
+ * <tr><td>BUTTONS_BUTTON2</td><td>Touch CS1 Button</td><td>Low</td><td>PORTE.1</td></tr>\r
+ * <tr><td>BUTTONS_BUTTON3</td><td>Touch CS2 Button</td><td>Low</td><td>PORTE.2</td></tr>\r
+ * <tr><td>BUTTONS_BUTTON4</td><td>Touch CS3 Button</td><td>Low</td><td>PORTE.3</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __BUTTONS_B1_XPLAINED_H__\r
+#define __BUTTONS_B1_XPLAINED_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_BUTTONS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Button mask for the first button on the board. */\r
+ #define BUTTONS_BUTTON1 (1 << 0)\r
+\r
+ /** Button mask for the second button on the board. */\r
+ #define BUTTONS_BUTTON2 (1 << 1)\r
+\r
+ /** Button mask for the third button on the board. */\r
+ #define BUTTONS_BUTTON3 (1 << 2)\r
+\r
+ /** Button mask for the fourth button on the board. */\r
+ #define BUTTONS_BUTTON4 (1 << 3)\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void Buttons_Init(void)\r
+ {\r
+ PORTE.OUTSET = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2 | BUTTONS_BUTTON3 | BUTTONS_BUTTON4);\r
+\r
+ PORTCFG.MPCMASK = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2 | BUTTONS_BUTTON3 | BUTTONS_BUTTON4);\r
+ PORTE.PIN0CTRL = (PORT_INVEN_bm | PORT_OPC_PULLUP_gc);\r
+ }\r
+\r
+ static inline void Buttons_Disable(void)\r
+ {\r
+ PORTE.OUTCLR = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2 | BUTTONS_BUTTON3 | BUTTONS_BUTTON4);\r
+\r
+ PORTCFG.MPCMASK = (BUTTONS_BUTTON1 | BUTTONS_BUTTON2 | BUTTONS_BUTTON3 | BUTTONS_BUTTON4);\r
+ PORTE.PIN0CTRL = 0;\r
+ }\r
+\r
+ static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Buttons_GetStatus(void)\r
+ {\r
+ return (PORTE_IN & (BUTTONS_BUTTON1 | BUTTONS_BUTTON2 | BUTTONS_BUTTON3 | BUTTONS_BUTTON4));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific Dataflash driver header for the Atmel XMEGA A3BU Xplained.\r
+ * \copydetails Group_Dataflash_A3BU_XPLAINED\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the dataflash driver\r
+ * dispatch header located in LUFA/Drivers/Board/Dataflash.h.\r
+ */\r
+\r
+/** \ingroup Group_Dataflash\r
+ * \defgroup Group_Dataflash_A3BU_XPLAINED A3BU_XPLAINED\r
+ * \brief Board specific Dataflash driver header for the Atmel XMEGA A3BU Xplained.\r
+ *\r
+ * Board specific Dataflash driver header for the Atmel XMEGA A3BU Xplained board.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Info</th><th>Select Pin</th><th>SPI Port</th></tr>\r
+ * <tr><td>DATAFLASH_CHIP1</td><td>AT45DB642D (8MB)</td><td>PORTD.2</td><td>USARTC0 (In SPI Mode, Remapped)</td></tr>\r
+ * </table> \r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __DATAFLASH_A3BU_XPLAINED_H__\r
+#define __DATAFLASH_A3BU_XPLAINED_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../../../Misc/AT45DB642D.h"\r
+ #include "../../../Peripheral/SerialSPI.h"\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_DATAFLASH_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/Dataflash.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define DATAFLASH_CHIPCS_MASK (1 << 2)\r
+ #define DATAFLASH_CHIPCS_PORT PORTD\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Constant indicating the total number of dataflash ICs mounted on the selected board. */\r
+ #define DATAFLASH_TOTALCHIPS 1\r
+\r
+ /** Mask for no dataflash chip selected. */\r
+ #define DATAFLASH_NO_CHIP 0\r
+\r
+ /** Mask for the first dataflash chip selected. */\r
+ #define DATAFLASH_CHIP1 (1 << 2)\r
+\r
+ /** Internal main memory page size for the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGE_SIZE 1024\r
+\r
+ /** Total number of pages inside each of the board's dataflash ICs. */\r
+ #define DATAFLASH_PAGES 8192\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the dataflash driver so that commands and data may be sent to an attached dataflash IC.\r
+ * The microcontroller's SPI driver MUST be initialized before any of the dataflash commands are used.\r
+ */\r
+ static inline void Dataflash_Init(void)\r
+ {\r
+ DATAFLASH_CHIPCS_PORT.DIRSET = DATAFLASH_CHIPCS_MASK;\r
+ \r
+ PORTCFG.MPCMASK = DATAFLASH_CHIPCS_MASK;\r
+ DATAFLASH_CHIPCS_PORT.PIN0CTRL = PORT_INVEN_bm; \r
+ \r
+ PORTC.REMAP |= PORT_USART0_bm;\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and returns a byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Dataflash_TransferByte(const uint8_t Byte)\r
+ {\r
+ return SerialSPI_TransferByte(&USARTC0, Byte);\r
+ }\r
+\r
+ /** Sends a byte to the currently selected dataflash IC, and ignores the next byte from the dataflash.\r
+ *\r
+ * \param[in] Byte Byte of data to send to the dataflash\r
+ */\r
+ static inline void Dataflash_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SendByte(const uint8_t Byte)\r
+ {\r
+ SerialSPI_SendByte(&USARTC0, Byte);\r
+ }\r
+\r
+ /** Sends a dummy byte to the currently selected dataflash IC, and returns the next byte from the dataflash.\r
+ *\r
+ * \return Last response byte from the dataflash\r
+ */\r
+ static inline uint8_t Dataflash_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_ReceiveByte(void)\r
+ {\r
+ return SerialSPI_ReceiveByte(&USARTC0);\r
+ }\r
+\r
+ /** Determines the currently selected dataflash chip.\r
+ *\r
+ * \return Mask of the currently selected Dataflash chip, either \ref DATAFLASH_NO_CHIP if no chip is selected\r
+ * or a DATAFLASH_CHIPn mask (where n is the chip number).\r
+ */\r
+ static inline uint8_t Dataflash_GetSelectedChip(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Dataflash_GetSelectedChip(void)\r
+ {\r
+ return (DATAFLASH_CHIPCS_PORT.OUT & DATAFLASH_CHIPCS_MASK);\r
+ }\r
+\r
+ /** Selects the given dataflash chip.\r
+ *\r
+ * \param[in] ChipMask Mask of the Dataflash IC to select, in the form of DATAFLASH_CHIPn mask (where n is\r
+ * the chip number).\r
+ */\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_SelectChip(const uint8_t ChipMask)\r
+ {\r
+ DATAFLASH_CHIPCS_PORT.OUTCLR = DATAFLASH_CHIPCS_MASK;\r
+ DATAFLASH_CHIPCS_PORT.OUTSET = (ChipMask & DATAFLASH_CHIPCS_MASK);\r
+ }\r
+\r
+ /** Deselects the current dataflash chip, so that no dataflash is selected. */\r
+ static inline void Dataflash_DeselectChip(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Dataflash_DeselectChip(void)\r
+ {\r
+ Dataflash_SelectChip(DATAFLASH_NO_CHIP);\r
+ }\r
+\r
+ /** Selects a dataflash IC from the given page number, which should range from 0 to\r
+ * ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1). For boards containing only one\r
+ * dataflash IC, this will select DATAFLASH_CHIP1. If the given page number is outside\r
+ * the total number of pages contained in the boards dataflash ICs, all dataflash ICs\r
+ * are deselected.\r
+ *\r
+ * \param[in] PageAddress Address of the page to manipulate, ranging from\r
+ * 0 to ((DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS) - 1).\r
+ */\r
+ static inline void Dataflash_SelectChipFromPage(const uint16_t PageAddress)\r
+ {\r
+ Dataflash_DeselectChip();\r
+\r
+ if (PageAddress >= (DATAFLASH_PAGES * DATAFLASH_TOTALCHIPS))\r
+ return;\r
+\r
+ Dataflash_SelectChip(DATAFLASH_CHIP1);\r
+ }\r
+\r
+ /** Toggles the select line of the currently selected dataflash IC, so that it is ready to receive\r
+ * a new command.\r
+ */\r
+ static inline void Dataflash_ToggleSelectedChipCS(void)\r
+ {\r
+ uint8_t SelectedChipMask = Dataflash_GetSelectedChip();\r
+\r
+ Dataflash_DeselectChip();\r
+ Dataflash_SelectChip(SelectedChipMask);\r
+ }\r
+\r
+ /** Spin-loops while the currently selected dataflash is busy executing a command, such as a main\r
+ * memory page program or main memory to buffer transfer.\r
+ */\r
+ static inline void Dataflash_WaitWhileBusy(void)\r
+ {\r
+ Dataflash_ToggleSelectedChipCS();\r
+ Dataflash_SendByte(DF_CMD_GETSTATUS);\r
+ while (!(Dataflash_ReceiveByte() & DF_STATUS_READY));\r
+ Dataflash_ToggleSelectedChipCS();\r
+ }\r
+\r
+ /** Sends a set of page and buffer address bytes to the currently selected dataflash IC, for use with\r
+ * dataflash commands which require a complete 24-bit address.\r
+ *\r
+ * \param[in] PageAddress Page address within the selected dataflash IC\r
+ * \param[in] BufferByte Address within the dataflash's buffer\r
+ */\r
+ static inline void Dataflash_SendAddressBytes(uint16_t PageAddress,\r
+ const uint16_t BufferByte)\r
+ {\r
+ Dataflash_SendByte(PageAddress >> 5);\r
+ Dataflash_SendByte((PageAddress << 3) | (BufferByte >> 8));\r
+ Dataflash_SendByte(BufferByte);\r
+ }\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Board specific LED driver header for the Atmel XMEGA B1 Xplained.\r
+ * \copydetails Group_LEDs_B1_XPLAINED\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the LEDs driver\r
+ * dispatch header located in LUFA/Drivers/Board/LEDs.h.\r
+ */\r
+\r
+/** \ingroup Group_LEDs\r
+ * \defgroup Group_LEDs_B1_XPLAINED B1_XPLAINED\r
+ * \brief Board specific LED driver header for the Atmel XMEGA B1 Xplained.\r
+ *\r
+ * Board specific LED driver header for the Atmel XMEGA B1 Xplained.\r
+ *\r
+ * <table>\r
+ * <tr><th>Name</th><th>Color</th><th>Info</th><th>Active Level</th><th>Port Pin</th></tr>\r
+ * <tr><td>LEDS_LED1</td><td>Yellow</td><td>LED0 LED</td><td>High</td><td>PORTB.4</td></tr>\r
+ * <tr><td>LEDS_LED2</td><td>Yellow</td><td>LED1 LED</td><td>High</td><td>PORTB.5</td></tr>\r
+ * <tr><td>LEDS_LED3</td><td>Yellow</td><td>LED2 LED</td><td>High</td><td>PORTB.6</td></tr>\r
+ * <tr><td>LEDS_LED4</td><td>Yellow</td><td>LED3 LED</td><td>High</td><td>PORTB.7</td></tr>\r
+ * <tr><td>LEDS_LED5</td><td>Green</td><td>USB LED</td><td>Low</td><td>PORTE.4</td></tr>\r
+ * </table>\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __LEDS_B1_XPLAINED_H__\r
+#define __LEDS_B1_XPLAINED_H__\r
+\r
+ /* Includes: */\r
+ #include <avr/io.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_LEDS_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define LEDS_PORTB_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4)\r
+ #define LEDS_PORTE_LEDS LEDS_LED5\r
+\r
+ #define LEDS_PORTE_MASK_SHIFT 1\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** LED mask for the first LED on the board. */\r
+ #define LEDS_LED1 (1 << 4)\r
+\r
+ /** LED mask for the second LED on the board. */\r
+ #define LEDS_LED2 (1 << 5)\r
+\r
+ /** LED mask for the third LED on the board. */\r
+ #define LEDS_LED3 (1 << 6)\r
+\r
+ /** LED mask for the fourth LED on the board. */\r
+ #define LEDS_LED4 (1 << 7)\r
+\r
+ /** LED mask for the fifth LED on the board. */\r
+ #define LEDS_LED5 ((1 << 4) >> LEDS_PORTE_MASK_SHIFT)\r
+\r
+ /** LED mask for all the LEDs on the board. */\r
+ #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2 | LEDS_LED3 | LEDS_LED4 | LEDS_LED5)\r
+\r
+ /** LED mask for none of the board LEDs. */\r
+ #define LEDS_NO_LEDS 0\r
+\r
+ /* Inline Functions: */\r
+ #if !defined(__DOXYGEN__)\r
+ static inline void LEDs_Init(void)\r
+ {\r
+ PORTB.DIRSET = LEDS_PORTB_LEDS;\r
+ PORTB.OUTCLR = LEDS_PORTB_LEDS;\r
+\r
+ PORTCFG.MPCMASK = LEDS_PORTB_LEDS;\r
+ PORTB.PIN0CTRL = PORT_INVEN_bm;\r
+\r
+ PORTE.DIRSET = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+ PORTE.OUTCLR = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_Disable(void)\r
+ {\r
+ PORTB.DIRCLR = LEDS_PORTB_LEDS;\r
+ PORTB.OUTCLR = LEDS_PORTB_LEDS;\r
+ \r
+ PORTCFG.MPCMASK = 0;\r
+ PORTB.PIN0CTRL = LEDS_PORTB_LEDS;\r
+\r
+ PORTE.DIRCLR = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+ PORTE.OUTCLR = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB_OUTSET = (LEDMask & LEDS_PORTB_LEDS);\r
+ PORTE_OUTSET = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB_OUTCLR = (LEDMask & LEDS_PORTB_LEDS);\r
+ PORTE_OUTCLR = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_SetAllLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB_OUTCLR = LEDS_PORTB_LEDS;\r
+ PORTE_OUTCLR = (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT);\r
+\r
+ PORTB_OUTSET = (LEDMask & LEDS_PORTB_LEDS);\r
+ PORTE_OUTSET = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask)\r
+ {\r
+ PORTB_OUTCLR = (LEDMask & LEDS_PORTB_LEDS);\r
+ PORTE_OUTCLR = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
+ \r
+ PORTB_OUTSET = (ActiveMask & LEDS_PORTB_LEDS);\r
+ PORTE_OUTSET = ((ActiveMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline void LEDs_ToggleLEDs(const uint8_t LEDMask)\r
+ {\r
+ PORTB_OUTTGL = (LEDMask & LEDS_PORTB_LEDS);\r
+ PORTE_OUTTGL = ((LEDMask & LEDS_PORTE_LEDS) << LEDS_PORTE_MASK_SHIFT);\r
+ }\r
+\r
+ static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t LEDs_GetLEDs(void)\r
+ {\r
+ return ((PORTB_OUT & LEDS_PORTB_LEDS) | (PORTE_OUT & (LEDS_PORTE_LEDS << LEDS_PORTE_MASK_SHIFT)));\r
+ }\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Command constants for the Atmel AT45DB321C Dataflash.\r
+ * \copydetails Group_AT45DB321C\r
+ */\r
+\r
+/** \ingroup Group_MiscDrivers\r
+ * \defgroup Group_AT45DB321C Atmel AT45DB321C Dataflash Commands\r
+ * \brief Command constants for the Atmel AT45DB321C Dataflash.\r
+ *\r
+ * Dataflash command constants for the Atmel AT45DB321C Dataflash IC.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __AT45DB321C_CMDS_H__\r
+#define __AT45DB321C_CMDS_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name Dataflash Status Values */\r
+ //@{\r
+ #define DF_STATUS_READY (1 << 7)\r
+ #define DF_STATUS_COMPMISMATCH (1 << 6)\r
+ #define DF_STATUS_SECTORPROTECTION_ON (1 << 1)\r
+ //@}\r
+\r
+ /** \name Dataflash Commands */\r
+ //@{\r
+ #define DF_CMD_GETSTATUS 0xD7\r
+\r
+ #define DF_CMD_MAINMEMTOBUFF1 0x53\r
+ #define DF_CMD_MAINMEMTOBUFF2 0x55\r
+ #define DF_CMD_MAINMEMTOBUFF1COMP 0x60\r
+ #define DF_CMD_MAINMEMTOBUFF2COMP 0x61\r
+ #define DF_CMD_AUTOREWRITEBUFF1 0x58\r
+ #define DF_CMD_AUTOREWRITEBUFF2 0x59\r
+\r
+ #define DF_CMD_MAINMEMPAGEREAD 0xD2\r
+ #define DF_CMD_CONTARRAYREAD_LF 0xE8\r
+ #define DF_CMD_BUFF1READ_LF 0xD4\r
+ #define DF_CMD_BUFF2READ_LF 0xD6\r
+\r
+ #define DF_CMD_BUFF1WRITE 0x84\r
+ #define DF_CMD_BUFF2WRITE 0x87\r
+ #define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83\r
+ #define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86\r
+ #define DF_CMD_BUFF1TOMAINMEM 0x88\r
+ #define DF_CMD_BUFF2TOMAINMEM 0x89\r
+ #define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82\r
+ #define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85\r
+\r
+ #define DF_CMD_PAGEERASE 0x81\r
+ #define DF_CMD_BLOCKERASE 0x50\r
+\r
+ #define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0xCF})\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0xCF\r
+\r
+ #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F\r
+ //@}\r
+\r
+ /** Manufacturer code for Atmel Corporation, returned by Atmel Dataflash ICs in response to the \c DF_CMD_READMANUFACTURERDEVICEINFO command. */\r
+ #define DF_MANUFACTURER_ATMEL 0x1F\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Command constants for the Atmel AT45DB642D Dataflash.\r
+ * \copydetails Group_AT45DB642D\r
+ */\r
+\r
+/** \ingroup Group_MiscDrivers\r
+ * \defgroup Group_AT45DB642D Atmel AT45DB642D Dataflash Commands\r
+ * \brief Command constants for the Atmel AT45DB642D Dataflash.\r
+ *\r
+ * Dataflash command constants for the Atmel AT45DB642D Dataflash IC.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __AT45DB642D_CMDS_H__\r
+#define __AT45DB642D_CMDS_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name Dataflash Status Values */\r
+ //@{\r
+ #define DF_STATUS_READY (1 << 7)\r
+ #define DF_STATUS_COMPMISMATCH (1 << 6)\r
+ #define DF_STATUS_SECTORPROTECTION_ON (1 << 1)\r
+ #define DF_STATUS_BINARYPAGESIZE_ON (1 << 0)\r
+ //@}\r
+\r
+ /** \name Dataflash Commands */\r
+ //@{\r
+ #define DF_CMD_GETSTATUS 0xD7\r
+ #define DF_CMD_POWERDOWN 0xB9\r
+ #define DF_CMD_WAKEUP 0xAB\r
+\r
+ #define DF_CMD_MAINMEMTOBUFF1 0x53\r
+ #define DF_CMD_MAINMEMTOBUFF2 0x55\r
+ #define DF_CMD_MAINMEMTOBUFF1COMP 0x60\r
+ #define DF_CMD_MAINMEMTOBUFF2COMP 0x61\r
+ #define DF_CMD_AUTOREWRITEBUFF1 0x58\r
+ #define DF_CMD_AUTOREWRITEBUFF2 0x59\r
+\r
+ #define DF_CMD_MAINMEMPAGEREAD 0xD2\r
+ #define DF_CMD_CONTARRAYREAD_LF 0x03\r
+ #define DF_CMD_BUFF1READ_LF 0xD1\r
+ #define DF_CMD_BUFF2READ_LF 0xD3\r
+\r
+ #define DF_CMD_BUFF1WRITE 0x84\r
+ #define DF_CMD_BUFF2WRITE 0x87\r
+ #define DF_CMD_BUFF1TOMAINMEMWITHERASE 0x83\r
+ #define DF_CMD_BUFF2TOMAINMEMWITHERASE 0x86\r
+ #define DF_CMD_BUFF1TOMAINMEM 0x88\r
+ #define DF_CMD_BUFF2TOMAINMEM 0x89\r
+ #define DF_CMD_MAINMEMPAGETHROUGHBUFF1 0x82\r
+ #define DF_CMD_MAINMEMPAGETHROUGHBUFF2 0x85\r
+\r
+ #define DF_CMD_PAGEERASE 0x81\r
+ #define DF_CMD_BLOCKERASE 0x50\r
+ #define DF_CMD_SECTORERASE 0x7C\r
+\r
+ #define DF_CMD_CHIPERASE ((char[]){0xC7, 0x94, 0x80, 0x9A})\r
+ #define DF_CMD_CHIPERASE_BYTE1 0xC7\r
+ #define DF_CMD_CHIPERASE_BYTE2 0x94\r
+ #define DF_CMD_CHIPERASE_BYTE3 0x80\r
+ #define DF_CMD_CHIPERASE_BYTE4 0x9A\r
+\r
+ #define DF_CMD_SECTORPROTECTIONOFF ((char[]){0x3D, 0x2A, 0x7F, 0x9A})\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE1 0x3D\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE2 0x2A\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE3 0x7F\r
+ #define DF_CMD_SECTORPROTECTIONOFF_BYTE4 0x9A\r
+\r
+ #define DF_CMD_BINARYPAGESIZEMODEON ((char[]){0x3D, 0x2A, 0x80, 0xA6})\r
+ #define DF_CMD_BINARYPAGESIZEMODEON_BYTE1 0x3D\r
+ #define DF_CMD_BINARYPAGESIZEMODEON_BYTE2 0x2A\r
+ #define DF_CMD_BINARYPAGESIZEMODEON_BYTE3 0x80\r
+ #define DF_CMD_BINARYPAGESIZEMODEON_BYTE4 0xA6\r
+\r
+ #define DF_CMD_READMANUFACTURERDEVICEINFO 0x9F\r
+ //@}\r
+\r
+ /** Manufacturer code for Atmel Corporation, returned by Atmel Dataflash ICs in response to the \c DF_CMD_READMANUFACTURERDEVICEINFO command. */\r
+ #define DF_MANUFACTURER_ATMEL 0x1F\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Lightweight ring (circular) buffer, for fast insertion/deletion of bytes.\r
+ *\r
+ * Lightweight ring buffer, for fast insertion/deletion. Multiple buffers can be created of\r
+ * different sizes to suit different needs.\r
+ *\r
+ * Note that for each buffer, insertion and removal operations may occur at the same time (via\r
+ * a multi-threaded ISR based system) however the same kind of operation (two or more insertions\r
+ * or deletions) must not overlap. If there is possibility of two or more of the same kind of\r
+ * operating occurring at the same point in time, atomic (mutex) locking should be used.\r
+ */\r
+\r
+/** \ingroup Group_MiscDrivers\r
+ * \defgroup Group_RingBuff Generic Byte Ring Buffer - LUFA/Drivers/Misc/RingBuffer.h\r
+ * \brief Lightweight ring buffer, for fast insertion/deletion of bytes.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Lightweight ring buffer, for fast insertion/deletion. Multiple buffers can be created of\r
+ * different sizes to suit different needs.\r
+ *\r
+ * Note that for each buffer, insertion and removal operations may occur at the same time (via\r
+ * a multi-threaded ISR based system) however the same kind of operation (two or more insertions\r
+ * or deletions) must not overlap. If there is possibility of two or more of the same kind of\r
+ * operating occurring at the same point in time, atomic (mutex) locking should be used.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * // Create the buffer structure and its underlying storage array\r
+ * RingBuffer_t Buffer;\r
+ * uint8_t BufferData[128];\r
+ * \r
+ * // Initialize the buffer with the created storage array\r
+ * RingBuffer_InitBuffer(&Buffer, BufferData, sizeof(BufferData));\r
+ * \r
+ * // Insert some data into the buffer\r
+ * RingBuffer_Insert(Buffer, 'H');\r
+ * RingBuffer_Insert(Buffer, 'E');\r
+ * RingBuffer_Insert(Buffer, 'L');\r
+ * RingBuffer_Insert(Buffer, 'L');\r
+ * RingBuffer_Insert(Buffer, 'O');\r
+ * \r
+ * // Cache the number of stored bytes in the buffer\r
+ * uint16_t BufferCount = RingBuffer_GetCount(&Buffer);\r
+ * \r
+ * // Printer stored data length\r
+ * printf("Buffer Length: %d, Buffer Data: \r\n", BufferCount);\r
+ * \r
+ * // Print contents of the buffer one character at a time\r
+ * while (BufferCount--)\r
+ * putc(RingBuffer_Remove(&Buffer));\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __RING_BUFFER_H__\r
+#define __RING_BUFFER_H__\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Type Defines: */\r
+ /** \brief Ring Buffer Management Structure.\r
+ *\r
+ * Type define for a new ring buffer object. Buffers should be initialized via a call to\r
+ * \ref RingBuffer_InitBuffer() before use.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t* In; /**< Current storage location in the circular buffer. */\r
+ uint8_t* Out; /**< Current retrieval location in the circular buffer. */\r
+ uint8_t* Start; /**< Pointer to the start of the buffer's underlying storage array. */\r
+ uint8_t* End; /**< Pointer to the end of the buffer's underlying storage array. */\r
+ uint16_t Size; /**< Size of the buffer's underlying storage array. */\r
+ uint16_t Count; /**< Number of bytes currently stored in the buffer. */\r
+ } RingBuffer_t;\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes a ring buffer ready for use. Buffers must be initialized via this function\r
+ * before any operations are called upon them. Already initialized buffers may be reset\r
+ * by re-initializing them using this function.\r
+ *\r
+ * \param[out] Buffer Pointer to a ring buffer structure to initialize.\r
+ * \param[out] DataPtr Pointer to a global array that will hold the data stored into the ring buffer.\r
+ * \param[out] Size Maximum number of bytes that can be stored in the underlying data array.\r
+ */\r
+ static inline void RingBuffer_InitBuffer(RingBuffer_t* Buffer, uint8_t* const DataPtr, const uint16_t Size)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+ static inline void RingBuffer_InitBuffer(RingBuffer_t* Buffer, uint8_t* const DataPtr, const uint16_t Size)\r
+ {\r
+ GCC_FORCE_POINTER_ACCESS(Buffer);\r
+\r
+ uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+ GlobalInterruptDisable();\r
+\r
+ Buffer->In = DataPtr;\r
+ Buffer->Out = DataPtr;\r
+ Buffer->Start = &DataPtr[0];\r
+ Buffer->End = &DataPtr[Size];\r
+ Buffer->Size = Size;\r
+ Buffer->Count = 0;\r
+\r
+ SetGlobalInterruptMask(CurrentGlobalInt);\r
+ }\r
+\r
+ /** Retrieves the current number of bytes stored in a particular buffer. This value is computed\r
+ * by entering an atomic lock on the buffer, so that the buffer cannot be modified while the\r
+ * computation takes place. This value should be cached when reading out the contents of the buffer,\r
+ * so that as small a time as possible is spent in an atomic lock.\r
+ *\r
+ * \note The value returned by this function is guaranteed to only be the minimum number of bytes\r
+ * stored in the given buffer; this value may change as other threads write new data, thus\r
+ * the returned number should be used only to determine how many successive reads may safely\r
+ * be performed on the buffer.\r
+ *\r
+ * \param[in] Buffer Pointer to a ring buffer structure whose count is to be computed.\r
+ *\r
+ * \return Number of bytes currently stored in the buffer.\r
+ */\r
+ static inline uint16_t RingBuffer_GetCount(RingBuffer_t* const Buffer) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline uint16_t RingBuffer_GetCount(RingBuffer_t* const Buffer)\r
+ {\r
+ uint16_t Count;\r
+\r
+ uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+ GlobalInterruptDisable();\r
+\r
+ Count = Buffer->Count;\r
+\r
+ SetGlobalInterruptMask(CurrentGlobalInt);\r
+ return Count;\r
+ }\r
+\r
+ /** Retrieves the free space in a particular buffer. This value is computed by entering an atomic lock\r
+ * on the buffer, so that the buffer cannot be modified while the computation takes place.\r
+ *\r
+ * \note The value returned by this function is guaranteed to only be the maximum number of bytes\r
+ * free in the given buffer; this value may change as other threads write new data, thus\r
+ * the returned number should be used only to determine how many successive writes may safely\r
+ * be performed on the buffer when there is a single writer thread.\r
+ *\r
+ * \param[in] Buffer Pointer to a ring buffer structure whose free count is to be computed.\r
+ *\r
+ * \return Number of free bytes in the buffer.\r
+ */\r
+ static inline uint16_t RingBuffer_GetFreeCount(RingBuffer_t* const Buffer) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline uint16_t RingBuffer_GetFreeCount(RingBuffer_t* const Buffer)\r
+ {\r
+ return (Buffer->Size - RingBuffer_GetCount(Buffer));\r
+ }\r
+\r
+ /** Atomically determines if the specified ring buffer contains any data. This should\r
+ * be tested before removing data from the buffer, to ensure that the buffer does not\r
+ * underflow.\r
+ *\r
+ * If the data is to be removed in a loop, store the total number of bytes stored in the\r
+ * buffer (via a call to the \ref RingBuffer_GetCount() function) in a temporary variable\r
+ * to reduce the time spent in atomicity locks.\r
+ *\r
+ * \param[in,out] Buffer Pointer to a ring buffer structure to insert into.\r
+ *\r
+ * \return Boolean \c true if the buffer contains no free space, false otherwise.\r
+ */\r
+ static inline bool RingBuffer_IsEmpty(RingBuffer_t* const Buffer) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline bool RingBuffer_IsEmpty(RingBuffer_t* const Buffer)\r
+ {\r
+ return (RingBuffer_GetCount(Buffer) == 0);\r
+ }\r
+\r
+ /** Atomically determines if the specified ring buffer contains any free space. This should\r
+ * be tested before storing data to the buffer, to ensure that no data is lost due to a\r
+ * buffer overrun.\r
+ *\r
+ * \param[in,out] Buffer Pointer to a ring buffer structure to insert into.\r
+ *\r
+ * \return Boolean \c true if the buffer contains no free space, false otherwise.\r
+ */\r
+ static inline bool RingBuffer_IsFull(RingBuffer_t* const Buffer) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline bool RingBuffer_IsFull(RingBuffer_t* const Buffer)\r
+ {\r
+ return (RingBuffer_GetCount(Buffer) == Buffer->Size);\r
+ }\r
+\r
+ /** Inserts an element into the ring buffer.\r
+ *\r
+ * \warning Only one execution thread (main program thread or an ISR) may insert into a single buffer\r
+ * otherwise data corruption may occur. Insertion and removal may occur from different execution\r
+ * threads.\r
+ *\r
+ * \param[in,out] Buffer Pointer to a ring buffer structure to insert into.\r
+ * \param[in] Data Data element to insert into the buffer.\r
+ */\r
+ static inline void RingBuffer_Insert(RingBuffer_t* Buffer, const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline void RingBuffer_Insert(RingBuffer_t* Buffer, const uint8_t Data)\r
+ {\r
+ GCC_FORCE_POINTER_ACCESS(Buffer);\r
+\r
+ *Buffer->In = Data;\r
+\r
+ if (++Buffer->In == Buffer->End)\r
+ Buffer->In = Buffer->Start;\r
+\r
+ uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+ GlobalInterruptDisable();\r
+\r
+ Buffer->Count++;\r
+\r
+ SetGlobalInterruptMask(CurrentGlobalInt);\r
+ }\r
+\r
+ /** Removes an element from the ring buffer.\r
+ *\r
+ * \warning Only one execution thread (main program thread or an ISR) may remove from a single buffer\r
+ * otherwise data corruption may occur. Insertion and removal may occur from different execution\r
+ * threads.\r
+ *\r
+ * \param[in,out] Buffer Pointer to a ring buffer structure to retrieve from.\r
+ *\r
+ * \return Next data element stored in the buffer.\r
+ */\r
+ static inline uint8_t RingBuffer_Remove(RingBuffer_t* Buffer) ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline uint8_t RingBuffer_Remove(RingBuffer_t* Buffer)\r
+ {\r
+ GCC_FORCE_POINTER_ACCESS(Buffer);\r
+\r
+ uint8_t Data = *Buffer->Out;\r
+\r
+ if (++Buffer->Out == Buffer->End)\r
+ Buffer->Out = Buffer->Start;\r
+\r
+ uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+ GlobalInterruptDisable();\r
+\r
+ Buffer->Count--;\r
+\r
+ SetGlobalInterruptMask(CurrentGlobalInt);\r
+\r
+ return Data;\r
+ }\r
+\r
+ /** Returns the next element stored in the ring buffer, without removing it.\r
+ *\r
+ * \param[in,out] Buffer Pointer to a ring buffer structure to retrieve from.\r
+ *\r
+ * \return Next data element stored in the buffer.\r
+ */\r
+ static inline uint8_t RingBuffer_Peek(RingBuffer_t* const Buffer) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline uint8_t RingBuffer_Peek(RingBuffer_t* const Buffer)\r
+ {\r
+ return *Buffer->Out;\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief ANSI terminal special escape code macros.\r
+ *\r
+ * ANSI terminal compatible escape sequences. These escape sequences are designed to be concatenated with existing\r
+ * strings to modify their display on a compatible terminal application.\r
+ */\r
+\r
+/** \ingroup Group_MiscDrivers\r
+ * \defgroup Group_Terminal ANSI Terminal Escape Codes - LUFA/Drivers/Misc/TerminalCodes.h\r
+ * \brief ANSI terminal special escape code macros.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Escape code macros for ANSI compliant text terminals.\r
+ *\r
+ * \note If desired, the macro \c DISABLE_TERMINAL_CODES can be defined in the project makefile and passed to the GCC\r
+ * compiler via the -D switch to disable the terminal codes without modifying the source, for use with non\r
+ * compatible terminals (any terminal codes then equate to empty strings).\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * printf("Normal String, "\r
+ * ESC_BOLD_ON "Bold String, "\r
+ * ESC_UNDERLINE_ON "Bold and Underlined String"\r
+ * ESC_RESET ESC_FG_BLUE ESC_BG_YELLOW "Normal Blue-on-Yellow String");\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __TERMINALCODES_H__\r
+#define __TERMINALCODES_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #if !defined(DISABLE_TERMINAL_CODES)\r
+ /** Creates an ANSI escape sequence with the specified payload.\r
+ *\r
+ * \param[in] EscapeSeq Payload to encode as an ANSI escape sequence, a \c ESC_* mask.\r
+ */\r
+ #define ANSI_ESCAPE_SEQUENCE(EscapeSeq) "\33[" EscapeSeq\r
+ #else\r
+ #define ANSI_ESCAPE_SEQUENCE(EscapeSeq)\r
+ #endif\r
+\r
+ /** \name Text Display Modifier Control Sequences */\r
+ //@{\r
+ /** Turns on bold so that any following text is printed to the terminal in bold. */\r
+ #define ESC_BOLD_ON ANSI_ESCAPE_SEQUENCE("1m")\r
+\r
+ /** Turns on italics so that any following text is printed to the terminal in italics. */\r
+ #define ESC_ITALICS_ON ANSI_ESCAPE_SEQUENCE("3m")\r
+\r
+ /** Turns on underline so that any following text is printed to the terminal underlined. */\r
+ #define ESC_UNDERLINE_ON ANSI_ESCAPE_SEQUENCE("4m")\r
+\r
+ /** Turns on inverse so that any following text is printed to the terminal in inverted colours. */\r
+ #define ESC_INVERSE_ON ANSI_ESCAPE_SEQUENCE("7m")\r
+\r
+ /** Turns on strikethrough so that any following text is printed to the terminal with a line through the\r
+ * center.\r
+ */\r
+ #define ESC_STRIKETHROUGH_ON ANSI_ESCAPE_SEQUENCE("9m")\r
+\r
+ /** Turns off bold so that any following text is printed to the terminal in non bold. */\r
+ #define ESC_BOLD_OFF ANSI_ESCAPE_SEQUENCE("22m")\r
+\r
+ /** Turns off italics so that any following text is printed to the terminal in non italics. */\r
+ #define ESC_ITALICS_OFF ANSI_ESCAPE_SEQUENCE("23m")\r
+\r
+ /** Turns off underline so that any following text is printed to the terminal non underlined. */\r
+ #define ESC_UNDERLINE_OFF ANSI_ESCAPE_SEQUENCE("24m")\r
+\r
+ /** Turns off inverse so that any following text is printed to the terminal in non inverted colours. */\r
+ #define ESC_INVERSE_OFF ANSI_ESCAPE_SEQUENCE("27m")\r
+\r
+ /** Turns off strikethrough so that any following text is printed to the terminal without a line through\r
+ * the center.\r
+ */\r
+ #define ESC_STRIKETHROUGH_OFF ANSI_ESCAPE_SEQUENCE("29m")\r
+ //@}\r
+\r
+ /** \name Text Colour Control Sequences */\r
+ //@{\r
+ /** Sets the foreground (text) colour to black. */\r
+ #define ESC_FG_BLACK ANSI_ESCAPE_SEQUENCE("30m")\r
+\r
+ /** Sets the foreground (text) colour to red. */\r
+ #define ESC_FG_RED ANSI_ESCAPE_SEQUENCE("31m")\r
+\r
+ /** Sets the foreground (text) colour to green. */\r
+ #define ESC_FG_GREEN ANSI_ESCAPE_SEQUENCE("32m")\r
+\r
+ /** Sets the foreground (text) colour to yellow. */\r
+ #define ESC_FG_YELLOW ANSI_ESCAPE_SEQUENCE("33m")\r
+\r
+ /** Sets the foreground (text) colour to blue. */\r
+ #define ESC_FG_BLUE ANSI_ESCAPE_SEQUENCE("34m")\r
+\r
+ /** Sets the foreground (text) colour to magenta. */\r
+ #define ESC_FG_MAGENTA ANSI_ESCAPE_SEQUENCE("35m")\r
+\r
+ /** Sets the foreground (text) colour to cyan. */\r
+ #define ESC_FG_CYAN ANSI_ESCAPE_SEQUENCE("36m")\r
+\r
+ /** Sets the foreground (text) colour to white. */\r
+ #define ESC_FG_WHITE ANSI_ESCAPE_SEQUENCE("37m")\r
+\r
+ /** Sets the foreground (text) colour to the terminal's default. */\r
+ #define ESC_FG_DEFAULT ANSI_ESCAPE_SEQUENCE("39m")\r
+\r
+ /** Sets the text background colour to black. */\r
+ #define ESC_BG_BLACK ANSI_ESCAPE_SEQUENCE("40m")\r
+\r
+ /** Sets the text background colour to red. */\r
+ #define ESC_BG_RED ANSI_ESCAPE_SEQUENCE("41m")\r
+\r
+ /** Sets the text background colour to green. */\r
+ #define ESC_BG_GREEN ANSI_ESCAPE_SEQUENCE("42m")\r
+\r
+ /** Sets the text background colour to yellow. */\r
+ #define ESC_BG_YELLOW ANSI_ESCAPE_SEQUENCE("43m")\r
+\r
+ /** Sets the text background colour to blue. */\r
+ #define ESC_BG_BLUE ANSI_ESCAPE_SEQUENCE("44m")\r
+\r
+ /** Sets the text background colour to magenta. */\r
+ #define ESC_BG_MAGENTA ANSI_ESCAPE_SEQUENCE("45m")\r
+\r
+ /** Sets the text background colour to cyan. */\r
+ #define ESC_BG_CYAN ANSI_ESCAPE_SEQUENCE("46m")\r
+\r
+ /** Sets the text background colour to white. */\r
+ #define ESC_BG_WHITE ANSI_ESCAPE_SEQUENCE("47m")\r
+\r
+ /** Sets the text background colour to the terminal's default. */\r
+ #define ESC_BG_DEFAULT ANSI_ESCAPE_SEQUENCE("49m")\r
+ //@}\r
+\r
+ /** \name Cursor Positioning Control Sequences */\r
+ //@{\r
+ /** Saves the current cursor position so that it may be restored with \ref ESC_CURSOR_POS_RESTORE. */\r
+ #define ESC_CURSOR_POS_SAVE ANSI_ESCAPE_SEQUENCE("s")\r
+\r
+ /** Restores the cursor position to the last position saved with \ref ESC_CURSOR_POS_SAVE. */\r
+ #define ESC_CURSOR_POS_RESTORE ANSI_ESCAPE_SEQUENCE("u")\r
+\r
+ /** Sets the cursor position to the given line and column.\r
+ *\r
+ * \param[in] Line Line number to position the cursor at.\r
+ * \param[in] Column Column number to position the cursor at.\r
+ */\r
+ #define ESC_CURSOR_POS(Line, Column) ANSI_ESCAPE_SEQUENCE(#Line ";" #Column "H")\r
+\r
+ /** Moves the cursor up the given number of lines.\r
+ *\r
+ * \param[in] Lines Number of lines to move the cursor position\r
+ */\r
+ #define ESC_CURSOR_UP(Lines) ANSI_ESCAPE_SEQUENCE(#Lines "A")\r
+\r
+ /** Moves the cursor down the given number of lines.\r
+ *\r
+ * \param[in] Lines Number of lines to move the cursor position\r
+ */\r
+ #define ESC_CURSOR_DOWN(Lines) ANSI_ESCAPE_SEQUENCE(#Lines "B")\r
+\r
+ /** Moves the cursor to the right the given number of columns.\r
+ *\r
+ * \param[in] Columns Number of columns to move the cursor position\r
+ */\r
+ #define ESC_CURSOR_FORWARD(Columns) ANSI_ESCAPE_SEQUENCE(#Columns "C")\r
+\r
+ /** Moves the cursor to the left the given number of columns.\r
+ *\r
+ * \param[in] Columns Number of columns to move the cursor position\r
+ */\r
+ #define ESC_CURSOR_BACKWARD(Columns) ANSI_ESCAPE_SEQUENCE(#Columns "D")\r
+ //@}\r
+\r
+ /** \name Miscellaneous Control Sequences */\r
+ //@{\r
+ /** Resets any escape sequence modifiers back to their defaults. */\r
+ #define ESC_RESET ANSI_ESCAPE_SEQUENCE("0m")\r
+\r
+ /** Erases the entire display, returning the cursor to the top left. */\r
+ #define ESC_ERASE_DISPLAY ANSI_ESCAPE_SEQUENCE("2J")\r
+\r
+ /** Erases the current line, returning the cursor to the far left. */\r
+ #define ESC_ERASE_LINE ANSI_ESCAPE_SEQUENCE("K")\r
+ //@}\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Hardware Analogue-to-Digital converter driver.\r
+ *\r
+ * This file is the master dispatch header file for the device-specific ADC driver, for microcontrollers\r
+ * containing an ADC.\r
+ *\r
+ * User code should include this file, which will in turn include the correct ADC driver header file for the\r
+ * currently selected architecture and microcontroller model.\r
+ */\r
+\r
+/** \ingroup Group_PeripheralDrivers\r
+ * \defgroup Group_ADC ADC Driver - LUFA/Drivers/Peripheral/ADC.h\r
+ * \brief Hardware Analogue-to-Digital converter driver.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Hardware ADC driver. This module provides an easy to use driver for the hardware ADC\r
+ * present on many microcontrollers, for the conversion of analogue signals into the\r
+ * digital domain.\r
+ *\r
+ * \note The exact API for this driver may vary depending on the target used - see\r
+ * individual target module documentation for the API specific to your target processor.\r
+ */\r
+\r
+#ifndef __ADC_H__\r
+#define __ADC_H__\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_ADC_H\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ /* Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/ADC_AVR8.h"\r
+ #else\r
+ #error The ADC peripheral driver is not currently available for your selected architecture.\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief ADC Peripheral Driver (AVR8)\r
+ *\r
+ * On-chip Analogue-to-Digital converter (ADC) driver for supported U4, U6 and U7 model AVRs that contain an ADC\r
+ * peripheral internally.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the ADC driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/ADC.h.\r
+ */\r
+\r
+/** \ingroup Group_ADC\r
+ * \defgroup Group_ADC_AVR8 ADC Peripheral Driver (AVR8)\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * On-chip Analogue-to-Digital converter (ADC) driver for supported U4, U6 and U7 model AVRs that contain an ADC\r
+ * peripheral internally.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the ADC driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/ADC.h.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * // Initialize the ADC driver before first use\r
+ * ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_32);\r
+ * \r
+ * // Must setup the ADC channel to read beforehand\r
+ * ADC_SetupChannel(1);\r
+ * \r
+ * // Perform a single conversion of the ADC channel 1\r
+ * ADC_GetChannelReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_CHANNEL1);\r
+ * printf("Conversion Result: %d\r\n", ADC_GetResult());\r
+ * \r
+ * // Start reading ADC channel 1 in free running (continuous conversion) mode\r
+ * ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | ADC_CHANNEL1);\r
+ * for (;;)\r
+ * {\r
+ * while (!(ADC_IsReadingComplete())) {};\r
+ * printf("Conversion Result: %d\r\n", ADC_GetResult());\r
+ * }\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __ADC_AVR8_H__\r
+#define __ADC_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_ADC_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Peripheral/ADC.h instead.\r
+ #endif\r
+\r
+ #if !(defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \\r
+ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \\r
+ defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \\r
+ defined(__AVR_ATmega32U6__))\r
+ #error The ADC peripheral driver is not currently available for your selected microcontroller model.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define _ADC_GET_MUX_MASK2(y) ADC_CHANNEL ## y\r
+ #define _ADC_GET_MUX_MASK(y) _ADC_GET_MUX_MASK2(y)\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name ADC Reference Configuration Masks */\r
+ //@{\r
+ /** Reference mask, for using the voltage present at the AVR's AREF pin for the ADC reference. */\r
+ #define ADC_REFERENCE_AREF 0\r
+\r
+ /** Reference mask, for using the voltage present at the AVR's AVCC pin for the ADC reference. */\r
+ #define ADC_REFERENCE_AVCC (1 << REFS0)\r
+\r
+ /** Reference mask, for using the internally generated 2.56V reference voltage as the ADC reference. */\r
+ #define ADC_REFERENCE_INT2560MV ((1 << REFS1) | (1 << REFS0))\r
+ //@}\r
+\r
+ /** \name ADC Result Adjustment Configuration Masks */\r
+ //@{\r
+ /** Left-adjusts the 10-bit ADC result, so that the upper 8 bits of the value returned by the\r
+ * \ref ADC_GetResult() macro contain the 8 most significant bits of the result.\r
+ */\r
+ #define ADC_LEFT_ADJUSTED (1 << ADLAR)\r
+\r
+ /** Right-adjusts the 10-bit ADC result, so that the lower 8 bits of the value returned by the\r
+ * \ref ADC_GetResult() macro contain the 8 least significant bits of the result.\r
+ */\r
+ #define ADC_RIGHT_ADJUSTED (0 << ADLAR)\r
+ //@}\r
+\r
+ /** \name ADC Mode Configuration Masks */\r
+ //@{\r
+ /** Sets the ADC mode to free running, so that conversions take place continuously as fast as the ADC\r
+ * is capable of at the given input clock speed.\r
+ */\r
+ #define ADC_FREE_RUNNING (1 << ADATE)\r
+\r
+ /** Sets the ADC mode to single conversion, so that only a single conversion will take place before\r
+ * the ADC returns to idle.\r
+ */\r
+ #define ADC_SINGLE_CONVERSION (0 << ADATE)\r
+ //@}\r
+\r
+ /** \name ADC Prescaler Configuration Masks */\r
+ //@{\r
+ /** Sets the ADC input clock to prescale by a factor of 2 the AVR's system clock. */\r
+ #define ADC_PRESCALE_2 (1 << ADPS0)\r
+\r
+ /** Sets the ADC input clock to prescale by a factor of 4 the AVR's system clock. */\r
+ #define ADC_PRESCALE_4 (1 << ADPS1)\r
+\r
+ /** Sets the ADC input clock to prescale by a factor of 8 the AVR's system clock. */\r
+ #define ADC_PRESCALE_8 ((1 << ADPS0) | (1 << ADPS1))\r
+\r
+ /** Sets the ADC input clock to prescale by a factor of 16 the AVR's system clock. */\r
+ #define ADC_PRESCALE_16 (1 << ADPS2)\r
+\r
+ /** Sets the ADC input clock to prescale by a factor of 32 the AVR's system clock. */\r
+ #define ADC_PRESCALE_32 ((1 << ADPS2) | (1 << ADPS0))\r
+\r
+ /** Sets the ADC input clock to prescale by a factor of 64 the AVR's system clock. */\r
+ #define ADC_PRESCALE_64 ((1 << ADPS2) | (1 << ADPS1))\r
+\r
+ /** Sets the ADC input clock to prescale by a factor of 128 the AVR's system clock. */\r
+ #define ADC_PRESCALE_128 ((1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0))\r
+ //@}\r
+\r
+ /** \name ADC MUX Masks */\r
+ //@{\r
+ /** MUX mask define for the ADC0 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */\r
+ #define ADC_CHANNEL0 (0x00 << MUX0)\r
+\r
+ /** MUX mask define for the ADC1 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */\r
+ #define ADC_CHANNEL1 (0x01 << MUX0)\r
+\r
+ #if (!(defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__)) || defined(__DOXYGEN__))\r
+ /** MUX mask define for the ADC2 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().\r
+ *\r
+ * \note Not available on all AVR models.\r
+ */\r
+ #define ADC_CHANNEL2 (0x02 << MUX0)\r
+\r
+ /** MUX mask define for the ADC3 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().\r
+ *\r
+ * \note Not available on all AVR models.\r
+ */\r
+ #define ADC_CHANNEL3 (0x03 << MUX0)\r
+ #endif\r
+\r
+ /** MUX mask define for the ADC4 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */\r
+ #define ADC_CHANNEL4 (0x04 << MUX0)\r
+\r
+ /** MUX mask define for the ADC5 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */\r
+ #define ADC_CHANNEL5 (0x05 << MUX0)\r
+\r
+ /** MUX mask define for the ADC6 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */\r
+ #define ADC_CHANNEL6 (0x06 << MUX0)\r
+\r
+ /** MUX mask define for the ADC7 channel of the ADC. See \ref ADC_StartReading and \ref ADC_GetChannelReading. */\r
+ #define ADC_CHANNEL7 (0x07 << MUX0)\r
+\r
+ #if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))\r
+ /** MUX mask define for the ADC8 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().\r
+ *\r
+ * \note Not available on all AVR models.\r
+ */\r
+ #define ADC_CHANNEL8 ((1 << 8) | (0x00 << MUX0))\r
+\r
+ /** MUX mask define for the ADC9 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().\r
+ *\r
+ * \note Not available on all AVR models.\r
+ */\r
+ #define ADC_CHANNEL9 ((1 << 8) | (0x01 << MUX0))\r
+\r
+ /** MUX mask define for the ADC10 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().\r
+ *\r
+ * \note Not available on all AVR models.\r
+ */\r
+ #define ADC_CHANNEL10 ((1 << 8) | (0x02 << MUX0))\r
+\r
+ /** MUX mask define for the ADC11 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().\r
+ *\r
+ * \note Not available on all AVR models.\r
+ */\r
+ #define ADC_CHANNEL11 ((1 << 8) | (0x03 << MUX0))\r
+\r
+ /** MUX mask define for the ADC12 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().\r
+ *\r
+ * \note Not available on all AVR models.\r
+ */\r
+ #define ADC_CHANNEL12 ((1 << 8) | (0x04 << MUX0))\r
+\r
+ /** MUX mask define for the ADC13 channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading().\r
+ *\r
+ * \note Not available on all AVR models.\r
+ */\r
+ #define ADC_CHANNEL13 ((1 << 8) | (0x05 << MUX0))\r
+\r
+ /** MUX mask define for the internal temperature sensor channel of the ADC. See \ref ADC_StartReading() and\r
+ * \ref ADC_GetChannelReading().\r
+ *\r
+ * \note Not available on all AVR models.\r
+ */\r
+ #define ADC_INT_TEMP_SENS ((1 << 8) | (0x07 << MUX0))\r
+ #endif\r
+\r
+ /** MUX mask define for the internal 1.1V band-gap channel of the ADC. See \ref ADC_StartReading() and \ref ADC_GetChannelReading(). */\r
+ #define ADC_1100MV_BANDGAP (0x1E << MUX0)\r
+\r
+ /** Retrieves the ADC MUX mask for the given ADC channel number.\r
+ *\r
+ * \attention This macro will only work correctly on channel numbers that are compile-time\r
+ * constants defined by the preprocessor.\r
+ *\r
+ * \param[in] Channel Index of the ADC channel whose MUX mask is to be retrieved.\r
+ */\r
+ #define ADC_GET_CHANNEL_MASK(Channel) _ADC_GET_MUX_MASK(Channel)\r
+ //@}\r
+\r
+ /* Inline Functions: */\r
+ /** Configures the given ADC channel, ready for ADC conversions. This function sets the\r
+ * associated port pin as an input and disables the digital portion of the I/O to reduce\r
+ * power consumption.\r
+ *\r
+ * \note This must only be called for ADC channels with are connected to a physical port\r
+ * pin of the AVR, denoted by its special alternative function ADCx.\r
+ *\r
+ * \warning The channel number must be specified as an integer, and <b>not</b> a \c ADC_CHANNEL* mask.\r
+ *\r
+ * \param[in] ChannelIndex ADC channel number to set up for conversions.\r
+ */\r
+ static inline void ADC_SetupChannel(const uint8_t ChannelIndex)\r
+ {\r
+ #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \\r
+ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \\r
+ defined(__AVR_ATmega32U6__))\r
+ DDRF &= ~(1 << ChannelIndex);\r
+ DIDR0 |= (1 << ChannelIndex);\r
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))\r
+ if (ChannelIndex < 8)\r
+ {\r
+ DDRF &= ~(1 << ChannelIndex);\r
+ DIDR0 |= (1 << ChannelIndex);\r
+ }\r
+ else if (ChannelIndex == 8)\r
+ {\r
+ DDRD &= ~(1 << 4);\r
+ DIDR2 |= (1 << 0);\r
+ }\r
+ else if (ChannelIndex < 11)\r
+ {\r
+ DDRD &= ~(1 << (ChannelIndex - 3));\r
+ DIDR2 |= (1 << (ChannelIndex - 8));\r
+ }\r
+ else\r
+ {\r
+ DDRB &= ~(1 << (ChannelIndex - 7));\r
+ DIDR2 |= (1 << (ChannelIndex - 8));\r
+ }\r
+ #endif\r
+ }\r
+\r
+ /** De-configures the given ADC channel, re-enabling digital I/O mode instead of analog. This\r
+ * function sets the associated port pin as an input and re-enabled the digital portion of\r
+ * the I/O.\r
+ *\r
+ * \note This must only be called for ADC channels with are connected to a physical port\r
+ * pin of the AVR, denoted by its special alternative function ADCx.\r
+ *\r
+ * \warning The channel number must be specified as an integer, and <b>not</b> a \c ADC_CHANNEL* mask.\r
+ *\r
+ * \param[in] ChannelIndex ADC channel number to set up for conversions.\r
+ */\r
+ static inline void ADC_DisableChannel(const uint8_t ChannelIndex)\r
+ {\r
+ #if (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \\r
+ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \\r
+ defined(__AVR_ATmega32U6__))\r
+ DDRF &= ~(1 << ChannelIndex);\r
+ DIDR0 &= ~(1 << ChannelIndex);\r
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))\r
+ if (ChannelIndex < 8)\r
+ {\r
+ DDRF &= ~(1 << ChannelIndex);\r
+ DIDR0 &= ~(1 << ChannelIndex);\r
+ }\r
+ else if (ChannelIndex == 8)\r
+ {\r
+ DDRD &= ~(1 << 4);\r
+ DIDR2 &= ~(1 << 0);\r
+ }\r
+ else if (ChannelIndex < 11)\r
+ {\r
+ DDRD &= ~(1 << (ChannelIndex - 3));\r
+ DIDR2 &= ~(1 << (ChannelIndex - 8));\r
+ }\r
+ else\r
+ {\r
+ DDRB &= ~(1 << (ChannelIndex - 7));\r
+ DIDR2 &= ~(1 << (ChannelIndex - 8));\r
+ }\r
+ #endif\r
+ }\r
+\r
+ /** Starts the reading of the given channel, but does not wait until the conversion has completed.\r
+ * Once executed, the conversion status can be determined via the \ref ADC_IsReadingComplete() macro and\r
+ * the result read via the \ref ADC_GetResult() macro.\r
+ *\r
+ * If the ADC has been initialized in free running mode, calling this function once will begin the repeated\r
+ * conversions. If the ADC is in single conversion mode (or the channel to convert from is to be changed),\r
+ * this function must be called each time a conversion is to take place.\r
+ *\r
+ * \param[in] MUXMask ADC channel mask, reference mask and adjustment mask.\r
+ */\r
+ static inline void ADC_StartReading(const uint16_t MUXMask)\r
+ {\r
+ ADMUX = MUXMask;\r
+\r
+ #if (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || defined(__DOXYGEN__))\r
+ if (MUXMask & (1 << 8))\r
+ ADCSRB |= (1 << MUX5);\r
+ else\r
+ ADCSRB &= ~(1 << MUX5);\r
+ #endif\r
+\r
+ ADCSRA |= (1 << ADSC);\r
+ }\r
+\r
+ /** Indicates if the current ADC conversion is completed, or still in progress.\r
+ *\r
+ * \return Boolean false if the reading is still taking place, or true if the conversion is\r
+ * complete and ready to be read out with \ref ADC_GetResult().\r
+ */\r
+ static inline bool ADC_IsReadingComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool ADC_IsReadingComplete(void)\r
+ {\r
+ return ((ADCSRA & (1 << ADIF)) ? true : false);\r
+ }\r
+\r
+ /** Retrieves the conversion value of the last completed ADC conversion and clears the reading\r
+ * completion flag.\r
+ *\r
+ * \return The result of the last ADC conversion as an unsigned value.\r
+ */\r
+ static inline uint16_t ADC_GetResult(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t ADC_GetResult(void)\r
+ {\r
+ ADCSRA |= (1 << ADIF);\r
+ return ADC;\r
+ }\r
+\r
+ /** Performs a complete single reading from channel, including a polling spin-loop to wait for the\r
+ * conversion to complete, and the returning of the converted value.\r
+ *\r
+ * \note For free running mode, the automated conversions should be initialized with a single call\r
+ * to \ref ADC_StartReading() to select the channel and begin the automated conversions, and\r
+ * the results read directly from the \ref ADC_GetResult() instead to reduce overhead.\r
+ *\r
+ * \param[in] MUXMask Mask comprising of an ADC channel mask, reference mask and adjustment mask.\r
+ *\r
+ * \return Converted ADC result for the given ADC channel.\r
+ */\r
+ static inline uint16_t ADC_GetChannelReading(const uint16_t MUXMask) ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint16_t ADC_GetChannelReading(const uint16_t MUXMask)\r
+ {\r
+ ADC_StartReading(MUXMask);\r
+\r
+ while (!(ADC_IsReadingComplete()));\r
+\r
+ return ADC_GetResult();\r
+ }\r
+\r
+ /** Initializes the ADC, ready for conversions. This must be called before any other ADC operations.\r
+ * The "mode" parameter should be a mask comprised of a conversion mode (free running or single) and\r
+ * prescaler masks.\r
+ *\r
+ * \param[in] Mode Mask of ADC prescale and mode settings.\r
+ */\r
+ static inline void ADC_Init(const uint8_t Mode) ATTR_ALWAYS_INLINE;\r
+ static inline void ADC_Init(const uint8_t Mode)\r
+ {\r
+ ADCSRA = ((1 << ADEN) | Mode);\r
+ }\r
+\r
+ /** Turns off the ADC. If this is called, any further ADC operations will require a call to\r
+ * \ref ADC_Init() before the ADC can be used again.\r
+ */\r
+ static inline void ADC_Disable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void ADC_Disable(void)\r
+ {\r
+ ADCSRA = 0;\r
+ }\r
+\r
+ /** Indicates if the ADC is currently enabled.\r
+ *\r
+ * \return Boolean \c true if the ADC subsystem is currently enabled, \c false otherwise.\r
+ */\r
+ static inline bool ADC_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool ADC_GetStatus(void)\r
+ {\r
+ return ((ADCSRA & (1 << ADEN)) ? true : false);\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief SPI Peripheral Driver (AVR8)\r
+ *\r
+ * On-chip SPI driver for the 8-bit AVR microcontrollers.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the SPI driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/SPI.h.\r
+ */\r
+\r
+/** \ingroup Group_SPI\r
+ * \defgroup Group_SPI_AVR8 SPI Peripheral Driver (AVR8)\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Driver for the hardware SPI port available on most 8-bit AVR microcontroller models. This\r
+ * module provides an easy to use driver for the setup and transfer of data over the\r
+ * AVR's SPI port.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the SPI driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/SPI.h.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * // Initialize the SPI driver before first use\r
+ * SPI_Init(SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING |\r
+ * SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);\r
+ * \r
+ * // Send several bytes, ignoring the returned data\r
+ * SPI_SendByte(0x01);\r
+ * SPI_SendByte(0x02);\r
+ * SPI_SendByte(0x03);\r
+ * \r
+ * // Receive several bytes, sending a dummy 0x00 byte each time\r
+ * uint8_t Byte1 = SPI_ReceiveByte();\r
+ * uint8_t Byte2 = SPI_ReceiveByte();\r
+ * uint8_t Byte3 = SPI_ReceiveByte();\r
+ * \r
+ * // Send a byte, and store the received byte from the same transaction\r
+ * uint8_t ResponseByte = SPI_TransferByte(0xDC);\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __SPI_AVR8_H__\r
+#define __SPI_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_SPI_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Peripheral/SPI.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define SPI_USE_DOUBLESPEED (1 << SPE)\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name SPI Prescaler Configuration Masks */\r
+ //@{\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 2. */\r
+ #define SPI_SPEED_FCPU_DIV_2 SPI_USE_DOUBLESPEED\r
+\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 4. */\r
+ #define SPI_SPEED_FCPU_DIV_4 0\r
+\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 8. */\r
+ #define SPI_SPEED_FCPU_DIV_8 (SPI_USE_DOUBLESPEED | (1 << SPR0))\r
+\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 16. */\r
+ #define SPI_SPEED_FCPU_DIV_16 (1 << SPR0)\r
+\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 32. */\r
+ #define SPI_SPEED_FCPU_DIV_32 (SPI_USE_DOUBLESPEED | (1 << SPR1))\r
+\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 64. */\r
+ #define SPI_SPEED_FCPU_DIV_64 (SPI_USE_DOUBLESPEED | (1 << SPR1) | (1 << SPR0))\r
+\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 128. */\r
+ #define SPI_SPEED_FCPU_DIV_128 ((1 << SPR1) | (1 << SPR0))\r
+ //@}\r
+\r
+ /** \name SPI SCK Polarity Configuration Masks */\r
+ //@{\r
+ /** SPI clock polarity mask for \ref SPI_Init(). Indicates that the SCK should lead on the rising edge. */\r
+ #define SPI_SCK_LEAD_RISING (0 << CPOL)\r
+\r
+ /** SPI clock polarity mask for \ref SPI_Init(). Indicates that the SCK should lead on the falling edge. */\r
+ #define SPI_SCK_LEAD_FALLING (1 << CPOL)\r
+ //@}\r
+\r
+ /** \name SPI Sample Edge Configuration Masks */\r
+ //@{\r
+ /** SPI data sample mode mask for \ref SPI_Init(). Indicates that the data should sampled on the leading edge. */\r
+ #define SPI_SAMPLE_LEADING (0 << CPHA)\r
+\r
+ /** SPI data sample mode mask for \ref SPI_Init(). Indicates that the data should be sampled on the trailing edge. */\r
+ #define SPI_SAMPLE_TRAILING (1 << CPHA)\r
+ //@}\r
+\r
+ /** \name SPI Data Ordering Configuration Masks */\r
+ //@{\r
+ /** SPI data order mask for \ref SPI_Init(). Indicates that data should be shifted out MSB first. */\r
+ #define SPI_ORDER_MSB_FIRST (0 << DORD)\r
+\r
+ /** SPI data order mask for \ref SPI_Init(). Indicates that data should be shifted out LSB first. */\r
+ #define SPI_ORDER_LSB_FIRST (1 << DORD)\r
+ //@}\r
+\r
+ /** \name SPI Mode Configuration Masks */\r
+ //@{\r
+ /** SPI mode mask for \ref SPI_Init(). Indicates that the SPI interface should be initialized into slave mode. */\r
+ #define SPI_MODE_SLAVE (0 << MSTR)\r
+\r
+ /** SPI mode mask for \ref SPI_Init(). Indicates that the SPI interface should be initialized into master mode. */\r
+ #define SPI_MODE_MASTER (1 << MSTR)\r
+ //@}\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the SPI subsystem, ready for transfers. Must be called before calling any other\r
+ * SPI routines.\r
+ *\r
+ * \param[in] SPIOptions SPI Options, a mask consisting of one of each of the \c SPI_SPEED_*,\r
+ * \c SPI_SCK_*, \c SPI_SAMPLE_*, \c SPI_ORDER_* and \c SPI_MODE_* masks.\r
+ */\r
+ static inline void SPI_Init(const uint8_t SPIOptions)\r
+ {\r
+ /* Prevent high rise times on PB.0 (/SS) from forcing a change to SPI slave mode */\r
+ DDRB |= (1 << 0);\r
+ PORTB |= (1 << 0);\r
+\r
+ DDRB |= ((1 << 1) | (1 << 2));\r
+ DDRB &= ~(1 << 3);\r
+ PORTB |= (1 << 3);\r
+\r
+ if (SPIOptions & SPI_USE_DOUBLESPEED)\r
+ SPSR |= (1 << SPI2X);\r
+ else\r
+ SPSR &= ~(1 << SPI2X);\r
+\r
+ /* Switch /SS to input mode after configuration to allow for forced mode changes */\r
+ DDRB &= ~(1 << 0);\r
+\r
+ SPCR = ((1 << SPE) | SPIOptions);\r
+ }\r
+\r
+ /** Turns off the SPI driver, disabling and returning used hardware to their default configuration. */\r
+ static inline void SPI_Disable(void)\r
+ {\r
+ DDRB &= ~((1 << 1) | (1 << 2));\r
+ PORTB &= ~((1 << 0) | (1 << 3));\r
+\r
+ SPCR = 0;\r
+ SPSR = 0;\r
+ }\r
+\r
+ /** Retrieves the currently selected SPI mode, once the SPI interface has been configured.\r
+ *\r
+ * \return \ref SPI_MODE_MASTER if the interface is currently in SPI Master mode, \ref SPI_MODE_SLAVE otherwise\r
+ */\r
+ static inline uint8_t SPI_GetCurrentMode(void) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t SPI_GetCurrentMode(void)\r
+ {\r
+ return (SPCR & SPI_MODE_MASTER);\r
+ }\r
+\r
+ /** Sends and receives a byte through the SPI interface, blocking until the transfer is complete.\r
+ *\r
+ * \param[in] Byte Byte to send through the SPI interface.\r
+ *\r
+ * \return Response byte from the attached SPI device.\r
+ */\r
+ static inline uint8_t SPI_TransferByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t SPI_TransferByte(const uint8_t Byte)\r
+ {\r
+ SPDR = Byte;\r
+ while (!(SPSR & (1 << SPIF)));\r
+ return SPDR;\r
+ }\r
+\r
+ /** Sends a byte through the SPI interface, blocking until the transfer is complete. The response\r
+ * byte sent to from the attached SPI device is ignored.\r
+ *\r
+ * \param[in] Byte Byte to send through the SPI interface.\r
+ */\r
+ static inline void SPI_SendByte(const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline void SPI_SendByte(const uint8_t Byte)\r
+ {\r
+ SPDR = Byte;\r
+ while (!(SPSR & (1 << SPIF)));\r
+ }\r
+\r
+ /** Sends a dummy byte through the SPI interface, blocking until the transfer is complete. The response\r
+ * byte from the attached SPI device is returned.\r
+ *\r
+ * \return The response byte from the attached SPI device.\r
+ */\r
+ static inline uint8_t SPI_ReceiveByte(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t SPI_ReceiveByte(void)\r
+ {\r
+ SPDR = 0x00;\r
+ while (!(SPSR & (1 << SPIF)));\r
+ return SPDR;\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master SPI Mode Serial USART Peripheral Driver (XMEGA)\r
+ *\r
+ * On-chip Master SPI mode USART driver for the XMEGA AVR microcontrollers.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the SPI Master\r
+ * Mode USART driver dispatch header located in LUFA/Drivers/Peripheral/Serial.h.\r
+ */\r
+\r
+/** \ingroup Group_SerialSPI\r
+ * \defgroup Group_SerialSPI_AVR8 Master SPI Mode Serial USART Peripheral Driver (AVR8)\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * On-chip serial USART driver for the 8-bit AVR8 microcontrollers.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the SPI Master\r
+ * driver dispatch header located in LUFA/Drivers/Peripheral/SerialSPI.h.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * // Initialize the Master SPI mode USART driver before first use, with 1Mbit baud\r
+ * SerialSPI_Init((USART_SPI_SCK_LEAD_RISING | SPI_SAMPLE_LEADING | SPI_ORDER_MSB_FIRST), 1000000);\r
+ * \r
+ * // Send several bytes, ignoring the returned data\r
+ * SerialSPI_SendByte(0x01);\r
+ * SerialSPI_SendByte(0x02);\r
+ * SerialSPI_SendByte(0x03);\r
+ * \r
+ * // Receive several bytes, sending a dummy 0x00 byte each time\r
+ * uint8_t Byte1 = SerialSPI_ReceiveByte();\r
+ * uint8_t Byte2 = SerialSPI_ReceiveByte();\r
+ * uint8_t Byte3 = SerialSPI_ReceiveByte();\r
+ * \r
+ * // Send a byte, and store the received byte from the same transaction\r
+ * uint8_t ResponseByte = SerialSPI_TransferByte(0xDC);\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __SERIAL_SPI_AVR8_H__\r
+#define __SERIAL_SPI_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+\r
+ #include <stdio.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_SERIAL_SPI_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Peripheral/Serial.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ #define SERIAL_SPI_UBBRVAL(Baud) ((Baud < (F_CPU / 2)) ? ((F_CPU / (2 * Baud)) - 1) : 0)\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name SPI SCK Polarity Configuration Masks */\r
+ //@{\r
+ /** SPI clock polarity mask for \ref SPI_Init(). Indicates that the SCK should lead on the rising edge. */\r
+ #define USART_SPI_SCK_LEAD_RISING (0 << UCPOL)\r
+\r
+ /** SPI clock polarity mask for \ref SPI_Init(). Indicates that the SCK should lead on the falling edge. */\r
+ #define USART_SPI_SCK_LEAD_FALLING (1 << UCPOL)\r
+ //@}\r
+\r
+ /** \name SPI Sample Edge Configuration Masks */\r
+ //@{\r
+ /** SPI data sample mode mask for \ref SerialSPI_Init(). Indicates that the data should sampled on the leading edge. */\r
+ #define USART_SPI_SAMPLE_LEADING (0 << UPCHA)\r
+\r
+ /** SPI data sample mode mask for \ref SerialSPI_Init(). Indicates that the data should be sampled on the trailing edge. */\r
+ #define USART_SPI_SAMPLE_TRAILING (1 << UPCHA)\r
+ //@}\r
+\r
+ /** \name SPI Data Ordering Configuration Masks */\r
+ //@{\r
+ /** SPI data order mask for \ref SerialSPI_Init(). Indicates that data should be shifted out MSB first. */\r
+ #define USART_SPI_ORDER_MSB_FIRST (0 << UDORD)\r
+\r
+ /** SPI data order mask for \ref SerialSPI_Init(). Indicates that data should be shifted out LSB first. */\r
+ #define USART_SPI_ORDER_LSB_FIRST (1 << UDORD)\r
+ //@} \r
+\r
+ /* Inline Functions: */\r
+ /** Initialize the USART module in Master SPI mode. \r
+ *\r
+ * \param[in] SPIOptions USART SPI Options, a mask consisting of one of each of the \c USART_SPI_SCK_*,\r
+ * \c USART_SPI_SAMPLE_* and \c USART_SPI_ORDER_* masks.\r
+ * \param[in] BaudRate SPI baud rate, in bits per second.\r
+ */\r
+ static inline void SerialSPI_Init(const uint8_t SPIOptions,\r
+ const uint32_t BaudRate)\r
+ {\r
+ UBRR1 = SERIAL_SPI_UBBRVAL(BaudRate);\r
+\r
+ UCSR1C = ((1 << UMSEL11) | (1 << UMSEL10) | SPIOptions);\r
+ UCSR1B = ((1 << TXEN1) | (1 << RXEN1));\r
+\r
+ DDRD |= (1 << 3);\r
+ PORTD |= (1 << 2); \r
+ }\r
+\r
+ /** Turns off the USART driver, disabling and returning used hardware to their default configuration. */\r
+ static inline void SerialSPI_Disable(void)\r
+ {\r
+ UCSR1B = 0;\r
+ UCSR1A = 0;\r
+ UCSR1C = 0;\r
+\r
+ UBRR1 = 0;\r
+\r
+ DDRD &= ~(1 << 3);\r
+ PORTD &= ~(1 << 2);\r
+ }\r
+ \r
+ /** Sends and receives a byte through the USART SPI interface, blocking until the transfer is complete.\r
+ *\r
+ * \param[in] DataByte Byte to send through the USART SPI interface.\r
+ *\r
+ * \return Response byte from the attached SPI device.\r
+ */\r
+ static inline uint8_t SerialSPI_TransferByte(const uint8_t DataByte)\r
+ {\r
+ UDR1 = DataByte;\r
+ while (!(UCSR1A & (1 << TXC1)));\r
+ UCSR1A = (1 << TXC1);\r
+ return UDR1;\r
+ }\r
+\r
+ /** Sends a byte through the USART SPI interface, blocking until the transfer is complete. The response\r
+ * byte sent to from the attached SPI device is ignored.\r
+ *\r
+ * \param[in] DataByte Byte to send through the USART SPI interface.\r
+ */\r
+ static inline void SerialSPI_SendByte(const uint8_t DataByte)\r
+ {\r
+ SerialSPI_TransferByte(DataByte);\r
+ }\r
+\r
+ /** Sends a dummy byte through the USART SPI interface, blocking until the transfer is complete. The response\r
+ * byte from the attached SPI device is returned.\r
+ *\r
+ * \return The response byte from the attached SPI device.\r
+ */\r
+ static inline uint8_t SerialSPI_ReceiveByte(void)\r
+ {\r
+ return SerialSPI_TransferByte(0);\r
+ }\r
+ \r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../Common/Common.h"\r
+#if (ARCH == ARCH_AVR8)\r
+\r
+#define __INCLUDE_FROM_SERIAL_C\r
+#include "../Serial.h"\r
+\r
+FILE USARTSerialStream;\r
+\r
+int Serial_putchar(char DataByte,\r
+ FILE *Stream)\r
+{\r
+ (void)Stream;\r
+\r
+ Serial_SendByte(DataByte);\r
+ return 0;\r
+}\r
+\r
+int Serial_getchar(FILE *Stream)\r
+{\r
+ (void)Stream;\r
+\r
+ if (!(Serial_IsCharReceived()))\r
+ return _FDEV_EOF;\r
+\r
+ return Serial_ReceiveByte();\r
+}\r
+\r
+int Serial_getchar_Blocking(FILE *Stream)\r
+{\r
+ (void)Stream;\r
+\r
+ while (!(Serial_IsCharReceived()));\r
+ return Serial_ReceiveByte();\r
+}\r
+\r
+void Serial_SendString_P(const char* FlashStringPtr)\r
+{\r
+ uint8_t CurrByte;\r
+\r
+ while ((CurrByte = pgm_read_byte(FlashStringPtr)) != 0x00)\r
+ {\r
+ Serial_SendByte(CurrByte);\r
+ FlashStringPtr++;\r
+ }\r
+}\r
+\r
+void Serial_SendString(const char* StringPtr)\r
+{\r
+ uint8_t CurrByte;\r
+\r
+ while ((CurrByte = *StringPtr) != 0x00)\r
+ {\r
+ Serial_SendByte(CurrByte);\r
+ StringPtr++;\r
+ }\r
+}\r
+\r
+void Serial_SendData(const uint8_t* Buffer,\r
+ uint16_t Length)\r
+{\r
+ while (Length--)\r
+ Serial_SendByte(*(Buffer++));\r
+}\r
+\r
+void Serial_CreateStream(FILE* Stream)\r
+{\r
+ if (!(Stream))\r
+ {\r
+ Stream = &USARTSerialStream;\r
+ stdin = Stream;\r
+ stdout = Stream;\r
+ }\r
+\r
+ *Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar, _FDEV_SETUP_RW);\r
+}\r
+\r
+void Serial_CreateBlockingStream(FILE* Stream)\r
+{\r
+ if (!(Stream))\r
+ {\r
+ Stream = &USARTSerialStream;\r
+ stdin = Stream;\r
+ stdout = Stream;\r
+ }\r
+\r
+ *Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar_Blocking, _FDEV_SETUP_RW);\r
+}\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Serial USART Peripheral Driver (AVR8)\r
+ *\r
+ * On-chip serial USART driver for the 8-bit AVR microcontrollers.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USART driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/Serial.h.\r
+ */\r
+\r
+/** \ingroup Group_Serial\r
+ * \defgroup Group_Serial_AVR8 Serial USART Peripheral Driver (AVR8)\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * On-chip serial USART driver for the 8-bit AVR microcontrollers.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USART driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/Serial.h.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * // Initialize the serial USART driver before first use, with 9600 baud (and no double-speed mode)\r
+ * Serial_Init(9600, false);\r
+ * \r
+ * // Send a string through the USART\r
+ * Serial_TxString("Test String\r\n");\r
+ * \r
+ * // Receive a byte through the USART\r
+ * uint8_t DataByte = Serial_RxByte();\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __SERIAL_AVR8_H__\r
+#define __SERIAL_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "../../Misc/TerminalCodes.h"\r
+\r
+ #include <stdio.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_SERIAL_H) && !defined(__INCLUDE_FROM_SERIAL_C)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Peripheral/Serial.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* External Variables: */\r
+ extern FILE USARTSerialStream;\r
+\r
+ /* Function Prototypes: */\r
+ int Serial_putchar(char DataByte,\r
+ FILE *Stream);\r
+ int Serial_getchar(FILE *Stream);\r
+ int Serial_getchar_Blocking(FILE *Stream);\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Macro for calculating the baud value from a given baud rate when the \c U2X (double speed) bit is\r
+ * not set.\r
+ *\r
+ * \param[in] Baud Target serial UART baud rate.\r
+ *\r
+ * \return Closest UBRR register value for the given UART frequency.\r
+ */\r
+ #define SERIAL_UBBRVAL(Baud) ((((F_CPU / 16) + (Baud / 2)) / (Baud)) - 1)\r
+\r
+ /** Macro for calculating the baud value from a given baud rate when the \c U2X (double speed) bit is\r
+ * set.\r
+ *\r
+ * \param[in] Baud Target serial UART baud rate.\r
+ *\r
+ * \return Closest UBRR register value for the given UART frequency.\r
+ */\r
+ #define SERIAL_2X_UBBRVAL(Baud) ((((F_CPU / 8) + (Baud / 2)) / (Baud)) - 1)\r
+\r
+ /* Function Prototypes: */\r
+ /** Transmits a given string located in program space (FLASH) through the USART.\r
+ *\r
+ * \param[in] FlashStringPtr Pointer to a string located in program space.\r
+ */\r
+ void Serial_SendString_P(const char* FlashStringPtr) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Transmits a given string located in SRAM memory through the USART.\r
+ *\r
+ * \param[in] StringPtr Pointer to a string located in SRAM space.\r
+ */\r
+ void Serial_SendString(const char* StringPtr) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Transmits a given buffer located in SRAM memory through the USART.\r
+ *\r
+ * \param[in] Buffer Pointer to a buffer containing the data to send.\r
+ * \param[in] Length Length of the data to send, in bytes.\r
+ */\r
+ void Serial_SendData(const uint8_t* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Creates a standard character stream from the USART so that it can be used with all the regular functions\r
+ * in the avr-libc \c <stdio.h> library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created\r
+ * stream is bidirectional and can be used for both input and output functions.\r
+ *\r
+ * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single\r
+ * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may\r
+ * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own\r
+ * line buffering.\r
+ *\r
+ * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL, \c stdout\r
+ * and \c stdin will be configured to use the USART.\r
+ *\r
+ * \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used.\r
+ */\r
+ void Serial_CreateStream(FILE* Stream);\r
+ \r
+ /** Identical to \ref Serial_CreateStream(), except that reads are blocking until the calling stream function terminates\r
+ * the transfer.\r
+ *\r
+ * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL, \c stdout\r
+ * and \c stdin will be configured to use the USART.\r
+ *\r
+ * \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used.\r
+ */\r
+ void Serial_CreateBlockingStream(FILE* Stream);\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the USART, ready for serial data transmission and reception. This initializes the interface to\r
+ * standard 8-bit, no parity, 1 stop bit settings suitable for most applications.\r
+ *\r
+ * \param[in] BaudRate Serial baud rate, in bits per second.\r
+ * \param[in] DoubleSpeed Enables double speed mode when set, halving the sample time to double the baud rate.\r
+ */\r
+ static inline void Serial_Init(const uint32_t BaudRate,\r
+ const bool DoubleSpeed)\r
+ {\r
+ UBRR1 = (DoubleSpeed ? SERIAL_2X_UBBRVAL(BaudRate) : SERIAL_UBBRVAL(BaudRate));\r
+\r
+ UCSR1C = ((1 << UCSZ11) | (1 << UCSZ10));\r
+ UCSR1A = (DoubleSpeed ? (1 << U2X1) : 0);\r
+ UCSR1B = ((1 << TXEN1) | (1 << RXEN1));\r
+\r
+ DDRD |= (1 << 3);\r
+ PORTD |= (1 << 2);\r
+ }\r
+\r
+ /** Turns off the USART driver, disabling and returning used hardware to their default configuration. */\r
+ static inline void Serial_Disable(void)\r
+ {\r
+ UCSR1B = 0;\r
+ UCSR1A = 0;\r
+ UCSR1C = 0;\r
+\r
+ UBRR1 = 0;\r
+\r
+ DDRD &= ~(1 << 3);\r
+ PORTD &= ~(1 << 2);\r
+ }\r
+\r
+ /** Indicates whether a character has been received through the USART.\r
+ *\r
+ * \return Boolean \c true if a character has been received, \c false otherwise.\r
+ */\r
+ static inline bool Serial_IsCharReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Serial_IsCharReceived(void)\r
+ {\r
+ return ((UCSR1A & (1 << RXC1)) ? true : false);\r
+ }\r
+\r
+ /** Transmits a given byte through the USART.\r
+ *\r
+ * \param[in] DataByte Byte to transmit through the USART.\r
+ */\r
+ static inline void Serial_SendByte(const char DataByte) ATTR_ALWAYS_INLINE;\r
+ static inline void Serial_SendByte(const char DataByte)\r
+ {\r
+ while (!(UCSR1A & (1 << UDRE1)));\r
+ UDR1 = DataByte;\r
+ }\r
+\r
+ /** Receives the next byte from the USART.\r
+ *\r
+ * \return Next byte received from the USART, or a negative value if no byte has been received.\r
+ */\r
+ static inline int16_t Serial_ReceiveByte(void) ATTR_ALWAYS_INLINE;\r
+ static inline int16_t Serial_ReceiveByte(void)\r
+ {\r
+ if (!(Serial_IsCharReceived()))\r
+ return -1;\r
+\r
+ return UDR1;\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../Common/Common.h"\r
+#if (ARCH == ARCH_AVR8) && defined(TWCR)\r
+\r
+#define __INCLUDE_FROM_TWI_C\r
+#include "../TWI.h"\r
+\r
+uint8_t TWI_StartTransmission(const uint8_t SlaveAddress,\r
+ const uint8_t TimeoutMS)\r
+{\r
+ for (;;)\r
+ {\r
+ bool BusCaptured = false;\r
+ uint16_t TimeoutRemaining;\r
+\r
+ TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN));\r
+\r
+ TimeoutRemaining = (TimeoutMS * 100);\r
+ while (TimeoutRemaining-- && !(BusCaptured))\r
+ {\r
+ if (TWCR & (1 << TWINT))\r
+ {\r
+ switch (TWSR & TW_STATUS_MASK)\r
+ {\r
+ case TW_START:\r
+ case TW_REP_START:\r
+ BusCaptured = true;\r
+ break;\r
+ case TW_MT_ARB_LOST:\r
+ TWCR = ((1 << TWINT) | (1 << TWSTA) | (1 << TWEN));\r
+ continue;\r
+ default:\r
+ TWCR = (1 << TWEN);\r
+ return TWI_ERROR_BusFault;\r
+ }\r
+ }\r
+\r
+ _delay_us(10);\r
+ }\r
+\r
+ if (!(TimeoutRemaining))\r
+ {\r
+ TWCR = (1 << TWEN);\r
+ return TWI_ERROR_BusCaptureTimeout;\r
+ }\r
+\r
+ TWDR = SlaveAddress;\r
+ TWCR = ((1 << TWINT) | (1 << TWEN));\r
+\r
+ TimeoutRemaining = (TimeoutMS * 100);\r
+ while (TimeoutRemaining--)\r
+ {\r
+ if (TWCR & (1 << TWINT))\r
+ break;\r
+\r
+ _delay_us(10);\r
+ }\r
+\r
+ if (!(TimeoutRemaining))\r
+ return TWI_ERROR_SlaveResponseTimeout;\r
+\r
+ switch (TWSR & TW_STATUS_MASK)\r
+ {\r
+ case TW_MT_SLA_ACK:\r
+ case TW_MR_SLA_ACK:\r
+ return TWI_ERROR_NoError;\r
+ default:\r
+ TWCR = ((1 << TWINT) | (1 << TWSTO) | (1 << TWEN));\r
+ return TWI_ERROR_SlaveNotReady;\r
+ }\r
+ }\r
+}\r
+\r
+bool TWI_SendByte(const uint8_t Byte)\r
+{\r
+ TWDR = Byte;\r
+ TWCR = ((1 << TWINT) | (1 << TWEN));\r
+ while (!(TWCR & (1 << TWINT)));\r
+\r
+ return ((TWSR & TW_STATUS_MASK) == TW_MT_DATA_ACK);\r
+}\r
+\r
+bool TWI_ReceiveByte(uint8_t* const Byte,\r
+ const bool LastByte)\r
+{\r
+ uint8_t TWCRMask;\r
+\r
+ if (LastByte)\r
+ TWCRMask = ((1 << TWINT) | (1 << TWEN));\r
+ else\r
+ TWCRMask = ((1 << TWINT) | (1 << TWEN) | (1 << TWEA));\r
+\r
+ TWCR = TWCRMask;\r
+ while (!(TWCR & (1 << TWINT)));\r
+ *Byte = TWDR;\r
+\r
+ uint8_t Status = (TWSR & TW_STATUS_MASK);\r
+\r
+ return ((LastByte) ? (Status == TW_MR_DATA_NACK) : (Status == TW_MR_DATA_ACK));\r
+}\r
+\r
+uint8_t TWI_ReadPacket(const uint8_t SlaveAddress,\r
+ const uint8_t TimeoutMS,\r
+ const uint8_t* InternalAddress,\r
+ uint8_t InternalAddressLen,\r
+ uint8_t* Buffer,\r
+ uint8_t Length)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ if ((ErrorCode = TWI_StartTransmission((SlaveAddress & TWI_DEVICE_ADDRESS_MASK) | TWI_ADDRESS_WRITE,\r
+ TimeoutMS)) == TWI_ERROR_NoError)\r
+ {\r
+ while (InternalAddressLen--)\r
+ {\r
+ if (!(TWI_SendByte(*(InternalAddress++))))\r
+ {\r
+ ErrorCode = TWI_ERROR_SlaveNAK;\r
+ break;\r
+ }\r
+ }\r
+\r
+ if ((ErrorCode = TWI_StartTransmission((SlaveAddress & TWI_DEVICE_ADDRESS_MASK) | TWI_ADDRESS_READ,\r
+ TimeoutMS)) == TWI_ERROR_NoError)\r
+ {\r
+ while (Length--)\r
+ {\r
+ if (!(TWI_ReceiveByte(Buffer++, (Length == 0))))\r
+ {\r
+ ErrorCode = TWI_ERROR_SlaveNAK;\r
+ break;\r
+ }\r
+ }\r
+\r
+ TWI_StopTransmission();\r
+ }\r
+ }\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+uint8_t TWI_WritePacket(const uint8_t SlaveAddress,\r
+ const uint8_t TimeoutMS,\r
+ const uint8_t* InternalAddress,\r
+ uint8_t InternalAddressLen,\r
+ const uint8_t* Buffer,\r
+ uint8_t Length)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ if ((ErrorCode = TWI_StartTransmission((SlaveAddress & TWI_DEVICE_ADDRESS_MASK) | TWI_ADDRESS_WRITE,\r
+ TimeoutMS)) == TWI_ERROR_NoError)\r
+ {\r
+ while (InternalAddressLen--)\r
+ {\r
+ if (!(TWI_SendByte(*(InternalAddress++))))\r
+ {\r
+ ErrorCode = TWI_ERROR_SlaveNAK;\r
+ break;\r
+ }\r
+ }\r
+\r
+ while (Length--)\r
+ {\r
+ if (!(TWI_SendByte(*(Buffer++))))\r
+ {\r
+ ErrorCode = TWI_ERROR_SlaveNAK;\r
+ break;\r
+ }\r
+ }\r
+\r
+ TWI_StopTransmission();\r
+ }\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief TWI Peripheral Driver (AVR8)\r
+ *\r
+ * On-chip TWI driver for the 8-bit AVR microcontrollers.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the TWI driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/TWI.h.\r
+ */\r
+\r
+/** \ingroup Group_TWI\r
+ * \defgroup Group_TWI_AVR8 TWI Peripheral Driver (AVR8)\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Master mode TWI driver for the 8-bit AVR microcontrollers which contain a hardware TWI module.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the TWI driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/TWI.h.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * <b>Low Level API Example:</b>\r
+ * \code\r
+ * // Initialize the TWI driver before first use at 200KHz\r
+ * TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 200000));\r
+ * \r
+ * // Start a write session to device at device address 0xA0, internal address 0xDC with a 10ms timeout\r
+ * if (TWI_StartTransmission(0xA0 | TWI_ADDRESS_WRITE, 10) == TWI_ERROR_NoError)\r
+ * {\r
+ * TWI_SendByte(0xDC);\r
+ * \r
+ * TWI_SendByte(0x01);\r
+ * TWI_SendByte(0x02);\r
+ * TWI_SendByte(0x03);\r
+ * \r
+ * // Must stop transmission afterwards to release the bus\r
+ * TWI_StopTransmission();\r
+ * }\r
+ * \r
+ * // Start a read session to device at address 0xA0, internal address 0xDC with a 10ms timeout\r
+ * if (TWI_StartTransmission(0xA0 | TWI_ADDRESS_WRITE, 10) == TWI_ERROR_NoError)\r
+ * {\r
+ * TWI_SendByte(0xDC);\r
+ * TWI_StopTransmission();\r
+ * \r
+ * if (TWI_StartTransmission(0xA0 | TWI_ADDRESS_READ, 10) == TWI_ERROR_NoError)\r
+ * {\r
+ * uint8_t Byte1, Byte2, Byte3;\r
+ * \r
+ * // Read three bytes, acknowledge after the third byte is received\r
+ * TWI_ReceiveByte(&Byte1, false);\r
+ * TWI_ReceiveByte(&Byte2, false);\r
+ * TWI_ReceiveByte(&Byte3, true);\r
+ * \r
+ * // Must stop transmission afterwards to release the bus\r
+ * TWI_StopTransmission();\r
+ * }\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>High Level API Example:</b>\r
+ * \code\r
+ * // Initialize the TWI driver before first use at 200KHz\r
+ * TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 200000));\r
+ * \r
+ * // Start a write session to device at device address 0xA0, internal address 0xDC with a 10ms timeout\r
+ * uint8_t InternalWriteAddress = 0xDC;\r
+ * uint8_t WritePacket[3] = {0x01, 0x02, 0x03};\r
+ * \r
+ * TWI_WritePacket(0xA0, 10, &InternalWriteAddress, sizeof(InternalWriteAddress),\r
+ * &WritePacket, sizeof(WritePacket);\r
+ * \r
+ * // Start a read session to device at address 0xA0, internal address 0xDC with a 10ms timeout\r
+ * uint8_t InternalReadAddress = 0xDC;\r
+ * uint8_t ReadPacket[3];\r
+ * \r
+ * TWI_ReadPacket(0xA0, 10, &InternalReadAddress, sizeof(InternalReadAddress),\r
+ * &ReadPacket, sizeof(ReadPacket);\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __TWI_AVR8_H__\r
+#define __TWI_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+\r
+ #include <stdio.h>\r
+ #include <util/twi.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_TWI_H) && !defined(__INCLUDE_FROM_TWI_C)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Peripheral/TWI.h instead.\r
+ #endif\r
+\r
+ #if !(defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \\r
+ defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \\r
+ defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \\r
+ defined(__AVR_ATmega32U6__))\r
+ #error The TWI peripheral driver is not currently available for your selected microcontroller model.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** TWI slave device address mask for a read session. Mask with a slave device base address to obtain\r
+ * the correct TWI bus address for the slave device when reading data from it.\r
+ */\r
+ #define TWI_ADDRESS_READ 0x01\r
+\r
+ /** TWI slave device address mask for a write session. Mask with a slave device base address to obtain\r
+ * the correct TWI bus address for the slave device when writing data to it.\r
+ */\r
+ #define TWI_ADDRESS_WRITE 0x00\r
+\r
+ /** Mask to retrieve the base address for a TWI device, which can then be ORed with \ref TWI_ADDRESS_READ\r
+ * or \ref TWI_ADDRESS_WRITE to obtain the device's read and write address respectively.\r
+ */\r
+ #define TWI_DEVICE_ADDRESS_MASK 0xFE\r
+\r
+ /** Bit length prescaler for \ref TWI_Init(). This mask multiplies the TWI bit length prescaler by 1. */\r
+ #define TWI_BIT_PRESCALE_1 ((0 << TWPS1) | (0 << TWPS0))\r
+\r
+ /** Bit length prescaler for \ref TWI_Init(). This mask multiplies the TWI bit length prescaler by 4. */\r
+ #define TWI_BIT_PRESCALE_4 ((0 << TWPS1) | (1 << TWPS0))\r
+\r
+ /** Bit length prescaler for \ref TWI_Init(). This mask multiplies the TWI bit length prescaler by 16. */\r
+ #define TWI_BIT_PRESCALE_16 ((1 << TWPS1) | (0 << TWPS0))\r
+\r
+ /** Bit length prescaler for \ref TWI_Init(). This mask multiplies the TWI bit length prescaler by 64. */\r
+ #define TWI_BIT_PRESCALE_64 ((1 << TWPS1) | (1 << TWPS0))\r
+\r
+ /** Calculates the length of each bit on the TWI bus for a given target frequency. This may be used with\r
+ * the \ref TWI_Init() function to convert a bus frequency to a number of clocks for the \c BitLength\r
+ * parameter.\r
+ *\r
+ * \param[in] Prescale Prescaler set on the TWI bus.\r
+ * \param[in] Frequency Desired TWI bus frequency in Hz.\r
+ *\r
+ * \return Bit length in clocks for the given TWI bus frequency at the given prescaler value.\r
+ */\r
+ #define TWI_BITLENGTH_FROM_FREQ(Prescale, Frequency) ((((F_CPU / (Prescale)) / (Frequency)) - 16) / 2)\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible return codes of the TWI transfer start routine and other dependant TWI functions. */\r
+ enum TWI_ErrorCodes_t\r
+ {\r
+ TWI_ERROR_NoError = 0, /**< Indicates that the command completed successfully. */\r
+ TWI_ERROR_BusFault = 1, /**< A TWI bus fault occurred while attempting to capture the bus. */\r
+ TWI_ERROR_BusCaptureTimeout = 2, /**< A timeout occurred whilst waiting for the bus to be ready. */\r
+ TWI_ERROR_SlaveResponseTimeout = 3, /**< No ACK received at the nominated slave address within the timeout period. */\r
+ TWI_ERROR_SlaveNotReady = 4, /**< Slave NAKed the TWI bus START condition. */\r
+ TWI_ERROR_SlaveNAK = 5, /**< Slave NAKed whilst attempting to send data to the device. */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the TWI hardware into master mode, ready for data transmission and reception. This must be\r
+ * before any other TWI operations.\r
+ *\r
+ * The generated SCL frequency will be according to the formula <pre>F_CPU / (16 + 2 * BitLength + 4 ^ Prescale)</pre>.\r
+ *\r
+ * \attention The value of the \c BitLength parameter should not be set below 10 or invalid bus conditions may\r
+ * occur, as indicated in the AVR8 microcontroller datasheet.\r
+ *\r
+ * \param[in] Prescale Prescaler to use when determining the bus frequency, a \c TWI_BIT_PRESCALE_* value.\r
+ * \param[in] BitLength Length of the bits sent on the bus.\r
+ */\r
+ static inline void TWI_Init(const uint8_t Prescale, const uint8_t BitLength) ATTR_ALWAYS_INLINE;\r
+ static inline void TWI_Init(const uint8_t Prescale, const uint8_t BitLength)\r
+ {\r
+ TWCR |= (1 << TWEN);\r
+ TWSR = Prescale;\r
+ TWBR = BitLength;\r
+ }\r
+\r
+ /** Turns off the TWI driver hardware. If this is called, any further TWI operations will require a call to\r
+ * \ref TWI_Init() before the TWI can be used again.\r
+ */\r
+ static inline void TWI_Disable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void TWI_Disable(void)\r
+ {\r
+ TWCR &= ~(1 << TWEN);\r
+ }\r
+\r
+ /** Sends a TWI STOP onto the TWI bus, terminating communication with the currently addressed device. */\r
+ static inline void TWI_StopTransmission(void) ATTR_ALWAYS_INLINE;\r
+ static inline void TWI_StopTransmission(void)\r
+ {\r
+ TWCR = ((1 << TWINT) | (1 << TWSTO) | (1 << TWEN));\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ /** Begins a master mode TWI bus communication with the given slave device address.\r
+ *\r
+ * \param[in] SlaveAddress Address of the slave TWI device to communicate with.\r
+ * \param[in] TimeoutMS Timeout period within which the slave must respond, in milliseconds.\r
+ *\r
+ * \return A value from the \ref TWI_ErrorCodes_t enum.\r
+ */\r
+ uint8_t TWI_StartTransmission(const uint8_t SlaveAddress,\r
+ const uint8_t TimeoutMS);\r
+\r
+ /** Sends a byte to the currently addressed device on the TWI bus.\r
+ *\r
+ * \param[in] Byte Byte to send to the currently addressed device\r
+ *\r
+ * \return Boolean \c true if the recipient ACKed the byte, \c false otherwise\r
+ */\r
+ bool TWI_SendByte(const uint8_t Byte);\r
+\r
+ /** Receives a byte from the currently addressed device on the TWI bus.\r
+ *\r
+ * \param[in] Byte Location where the read byte is to be stored.\r
+ * \param[in] LastByte Indicates if the byte should be ACKed if false, NAKed if true.\r
+ *\r
+ * \return Boolean \c true if the byte reception successfully completed, \c false otherwise.\r
+ */\r
+ bool TWI_ReceiveByte(uint8_t* const Byte,\r
+ const bool LastByte) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** High level function to perform a complete packet transfer over the TWI bus to the specified\r
+ * device.\r
+ *\r
+ * \param[in] SlaveAddress Base address of the TWI slave device to communicate with.\r
+ * \param[in] TimeoutMS Timeout for bus capture and slave START ACK, in milliseconds.\r
+ * \param[in] InternalAddress Pointer to a location where the internal slave read start address is stored.\r
+ * \param[in] InternalAddressLen Size of the internal device address, in bytes.\r
+ * \param[in] Buffer Pointer to a buffer where the read packet data is to be stored.\r
+ * \param[in] Length Size of the packet to read, in bytes.\r
+ *\r
+ * \return A value from the \ref TWI_ErrorCodes_t enum.\r
+ */\r
+ uint8_t TWI_ReadPacket(const uint8_t SlaveAddress,\r
+ const uint8_t TimeoutMS,\r
+ const uint8_t* InternalAddress,\r
+ uint8_t InternalAddressLen,\r
+ uint8_t* Buffer,\r
+ uint8_t Length) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** High level function to perform a complete packet transfer over the TWI bus from the specified\r
+ * device.\r
+ *\r
+ * \param[in] SlaveAddress Base address of the TWI slave device to communicate with\r
+ * \param[in] TimeoutMS Timeout for bus capture and slave START ACK, in milliseconds\r
+ * \param[in] InternalAddress Pointer to a location where the internal slave write start address is stored\r
+ * \param[in] InternalAddressLen Size of the internal device address, in bytes\r
+ * \param[in] Buffer Pointer to a buffer where the packet data to send is stored\r
+ * \param[in] Length Size of the packet to send, in bytes\r
+ *\r
+ * \return A value from the \ref TWI_ErrorCodes_t enum.\r
+ */\r
+ uint8_t TWI_WritePacket(const uint8_t SlaveAddress,\r
+ const uint8_t TimeoutMS,\r
+ const uint8_t* InternalAddress,\r
+ uint8_t InternalAddressLen,\r
+ const uint8_t* Buffer,\r
+ uint8_t Length) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Hardware Serial Peripheral Interface driver.\r
+ *\r
+ * This file is the master dispatch header file for the device-specific SPI driver, for microcontrollers\r
+ * containing a hardware SPI.\r
+ *\r
+ * User code should include this file, which will in turn include the correct SPI driver header file for the\r
+ * currently selected architecture and microcontroller model.\r
+ */\r
+\r
+/** \ingroup Group_PeripheralDrivers\r
+ * \defgroup Group_SPI SPI Driver - LUFA/Drivers/Peripheral/SPI.h\r
+ * \brief Hardware Serial Peripheral Interface driver.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Hardware SPI driver. This module provides an easy to use driver for the setup and transfer of data over\r
+ * the selected architecture and microcontroller model's SPI port.\r
+ *\r
+ * \note The exact API for this driver may vary depending on the target used - see\r
+ * individual target module documentation for the API specific to your target processor.\r
+ */\r
+\r
+#ifndef __SPI_H__\r
+#define __SPI_H__\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_SPI_H\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ /* Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/SPI_AVR8.h"\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ #include "XMEGA/SPI_XMEGA.h"\r
+ #else\r
+ #error The SPI peripheral driver is not currently available for your selected architecture.\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Hardware Serial USART driver.\r
+ *\r
+ * This file is the master dispatch header file for the device-specific USART driver, for microcontrollers\r
+ * containing a hardware USART.\r
+ *\r
+ * User code should include this file, which will in turn include the correct ADC driver header file for the\r
+ * currently selected architecture and microcontroller model.\r
+ */\r
+\r
+/** \ingroup Group_PeripheralDrivers\r
+ * \defgroup Group_Serial Serial USART Driver - LUFA/Drivers/Peripheral/Serial.h\r
+ * \brief Hardware Serial USART driver.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/Peripheral/<i>ARCH</i>/Serial_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_SERIAL)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Hardware serial USART driver. This module provides an easy to use driver for the setup and transfer\r
+ * of data over the selected architecture and microcontroller model's USART port.\r
+ *\r
+ * \note The exact API for this driver may vary depending on the target used - see\r
+ * individual target module documentation for the API specific to your target processor.\r
+ */\r
+\r
+#ifndef __SERIAL_H__\r
+#define __SERIAL_H__\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_SERIAL_H\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ /* Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/Serial_AVR8.h"\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ #include "XMEGA/Serial_XMEGA.h"\r
+ #else\r
+ #error The Serial peripheral driver is not currently available for your selected architecture.\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Hardware SPI Master Mode Serial USART driver.\r
+ *\r
+ * This file is the master dispatch header file for the device-specific SPI Master Mode USART driver, for\r
+ * microcontrollers containing a hardware USART capable of operating in a Master SPI mode.\r
+ *\r
+ * User code should include this file, which will in turn include the correct ADC driver header file for the\r
+ * currently selected architecture and microcontroller model.\r
+ */\r
+\r
+/** \ingroup Group_PeripheralDrivers\r
+ * \defgroup Group_SerialSPI Master SPI Mode Serial USART Driver - LUFA/Drivers/Peripheral/SerialSPI.h\r
+ * \brief Hardware SPI Master Mode Serial USART driver.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Hardware SPI Master Mode serial USART driver. This module provides an easy to use driver for the setup and transfer\r
+ * of data over the selected architecture and microcontroller model's USART port, using a SPI framing format.\r
+ *\r
+ * \note The exact API for this driver may vary depending on the target used - see\r
+ * individual target module documentation for the API specific to your target processor.\r
+ */\r
+\r
+#ifndef __SERIAL_SPI_H__\r
+#define __SERIAL_SPI_H__\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_SERIAL_SPI_H\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ /* Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/SerialSPI_AVR8.h"\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ #include "XMEGA/SerialSPI_XMEGA.h"\r
+ #else\r
+ #error The Serial SPI Master Mode peripheral driver is not currently available for your selected architecture.\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Hardware Two Wire Interface (I2C) driver.\r
+ *\r
+ * This file is the master dispatch header file for the device-specific SPI driver, for microcontrollers\r
+ * containing a hardware TWI.\r
+ *\r
+ * User code should include this file, which will in turn include the correct TWI driver header file for the\r
+ * currently selected architecture and microcontroller model.\r
+ */\r
+\r
+/** \ingroup Group_PeripheralDrivers\r
+ * \defgroup Group_TWI TWI Driver - LUFA/Drivers/Peripheral/TWI.h\r
+ * \brief Hardware Two Wire Interface (I2C) driver.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/Peripheral/<i>ARCH</i>/TWI_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_TWI)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Hardware TWI driver. This module provides an easy to use driver for the setup and transfer of data over\r
+ * the selected architecture and microcontroller model's TWI bus port.\r
+ *\r
+ * \note The exact API for this driver may vary depending on the target used - see\r
+ * individual target module documentation for the API specific to your target processor.\r
+ */\r
+\r
+#ifndef __TWI_H__\r
+#define __TWI_H__\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_TWI_H\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ /* Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/TWI_AVR8.h"\r
+ #else\r
+ #error The TWI peripheral driver is not currently available for your selected architecture.\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief SPI Peripheral Driver (XMEGA)\r
+ *\r
+ * On-chip SPI driver for the XMEGA microcontrollers.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the SPI driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/SPI.h.\r
+ */\r
+\r
+/** \ingroup Group_SPI\r
+ * \defgroup Group_SPI_XMEGA SPI Peripheral Driver (XMEGA)\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Driver for the hardware SPI port(s) available on XMEGA AVR microcontroller models. This\r
+ * module provides an easy to use driver for the setup and transfer of data over the AVR's\r
+ * SPI ports.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the SPI driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/SPI.h.\r
+ *\r
+ * \code\r
+ * // Initialize the SPI driver before first use\r
+ * SPI_Init(&SPIC,\r
+ * SPI_SPEED_FCPU_DIV_2 | SPI_ORDER_MSB_FIRST | SPI_SCK_LEAD_FALLING |\r
+ * SPI_SAMPLE_TRAILING | SPI_MODE_MASTER);\r
+ * \r
+ * // Send several bytes, ignoring the returned data\r
+ * SPI_SendByte(&SPIC, 0x01);\r
+ * SPI_SendByte(&SPIC, 0x02);\r
+ * SPI_SendByte(&SPIC, 0x03);\r
+ * \r
+ * // Receive several bytes, sending a dummy 0x00 byte each time\r
+ * uint8_t Byte1 = SPI_ReceiveByte(&SPIC);\r
+ * uint8_t Byte2 = SPI_ReceiveByte(&SPIC);\r
+ * uint8_t Byte3 = SPI_ReceiveByte(&SPIC);\r
+ * \r
+ * // Send a byte, and store the received byte from the same transaction\r
+ * uint8_t ResponseByte = SPI_TransferByte(&SPIC, 0xDC);\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __SPI_XMEGA_H__\r
+#define __SPI_XMEGA_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_SPI_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Peripheral/SPI.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define SPI_USE_DOUBLESPEED SPI_CLK2X_bm\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name SPI Prescaler Configuration Masks */\r
+ //@{\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 2. */\r
+ #define SPI_SPEED_FCPU_DIV_2 SPI_USE_DOUBLESPEED\r
+\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 4. */\r
+ #define SPI_SPEED_FCPU_DIV_4 0\r
+\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 8. */\r
+ #define SPI_SPEED_FCPU_DIV_8 (SPI_USE_DOUBLESPEED | (1 << SPI_PRESCALER_gp))\r
+\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 16. */\r
+ #define SPI_SPEED_FCPU_DIV_16 (1 << SPI_PRESCALER_gp)\r
+\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 32. */\r
+ #define SPI_SPEED_FCPU_DIV_32 (SPI_USE_DOUBLESPEED | (2 << SPI_PRESCALER_gp))\r
+\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 64. */\r
+ #define SPI_SPEED_FCPU_DIV_64 (2 << SPI_PRESCALER_gp)\r
+\r
+ /** SPI prescaler mask for \ref SPI_Init(). Divides the system clock by a factor of 128. */\r
+ #define SPI_SPEED_FCPU_DIV_128 (3 << SPI_PRESCALER_gp)\r
+ //@}\r
+\r
+ /** \name SPI SCK Polarity Configuration Masks */\r
+ //@{\r
+ /** SPI clock polarity mask for \ref SPI_Init(). Indicates that the SCK should lead on the rising edge. */\r
+ #define SPI_SCK_LEAD_RISING 0\r
+\r
+ /** SPI clock polarity mask for \ref SPI_Init(). Indicates that the SCK should lead on the falling edge. */\r
+ #define SPI_SCK_LEAD_FALLING SPI_MODE1_bm\r
+ //@}\r
+\r
+ /** \name SPI Sample Edge Configuration Masks */\r
+ //@{\r
+ /** SPI data sample mode mask for \ref SPI_Init(). Indicates that the data should sampled on the leading edge. */\r
+ #define SPI_SAMPLE_LEADING 0\r
+\r
+ /** SPI data sample mode mask for \ref SPI_Init(). Indicates that the data should be sampled on the trailing edge. */\r
+ #define SPI_SAMPLE_TRAILING SPI_MODE0_bm\r
+ //@}\r
+\r
+ /** \name SPI Data Ordering Configuration Masks */\r
+ //@{\r
+ /** SPI data order mask for \ref SPI_Init(). Indicates that data should be shifted out MSB first. */\r
+ #define SPI_ORDER_MSB_FIRST 0\r
+\r
+ /** SPI data order mask for \ref SPI_Init(). Indicates that data should be shifted out LSB first. */\r
+ #define SPI_ORDER_LSB_FIRST SPI_DORD_bm\r
+ //@}\r
+\r
+ /** \name SPI Mode Configuration Masks */\r
+ //@{\r
+ /** SPI mode mask for \ref SPI_Init(). Indicates that the SPI interface should be initialized into slave mode. */\r
+ #define SPI_MODE_SLAVE 0\r
+\r
+ /** SPI mode mask for \ref SPI_Init(). Indicates that the SPI interface should be initialized into master mode. */\r
+ #define SPI_MODE_MASTER SPI_MASTER_bm\r
+ //@}\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the SPI subsystem, ready for transfers. Must be called before calling any other\r
+ * SPI routines.\r
+ *\r
+ * \param[in,out] SPI Pointer to the base of the SPI peripheral within the device.\r
+ * \param[in] SPIOptions SPI Options, a mask consisting of one of each of the \c SPI_SPEED_*,\r
+ * \c SPI_SCK_*, \c SPI_SAMPLE_*, \c SPI_ORDER_* and \c SPI_MODE_* masks.\r
+ */\r
+ static inline void SPI_Init(SPI_t* const SPI,\r
+ const uint8_t SPIOptions)\r
+ {\r
+ SPI->CTRL = (SPIOptions | SPI_ENABLE_bm);\r
+ }\r
+\r
+ /** Turns off the SPI driver, disabling and returning used hardware to their default configuration.\r
+ *\r
+ * \param[in,out] SPI Pointer to the base of the SPI peripheral within the device.\r
+ */\r
+ static inline void SPI_Disable(SPI_t* const SPI)\r
+ {\r
+ SPI->CTRL &= ~SPI_ENABLE_bm;\r
+ }\r
+\r
+ /** Retrieves the currently selected SPI mode, once the SPI interface has been configured.\r
+ *\r
+ * \param[in,out] SPI Pointer to the base of the SPI peripheral within the device.\r
+ *\r
+ * \return \ref SPI_MODE_MASTER if the interface is currently in SPI Master mode, \ref SPI_MODE_SLAVE otherwise\r
+ */\r
+ static inline uint8_t SPI_GetCurrentMode(SPI_t* const SPI) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t SPI_GetCurrentMode(SPI_t* const SPI)\r
+ {\r
+ return (SPI->CTRL & SPI_MASTER_bm);\r
+ }\r
+\r
+ /** Sends and receives a byte through the SPI interface, blocking until the transfer is complete.\r
+ *\r
+ * \param[in,out] SPI Pointer to the base of the SPI peripheral within the device.\r
+ * \param[in] Byte Byte to send through the SPI interface.\r
+ *\r
+ * \return Response byte from the attached SPI device.\r
+ */\r
+ static inline uint8_t SPI_TransferByte(SPI_t* const SPI,\r
+ const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t SPI_TransferByte(SPI_t* const SPI,\r
+ const uint8_t Byte)\r
+ {\r
+ SPI->DATA = Byte;\r
+ while (!(SPI->STATUS & SPI_IF_bm));\r
+ return SPI->DATA;\r
+ }\r
+\r
+ /** Sends a byte through the SPI interface, blocking until the transfer is complete. The response\r
+ * byte sent to from the attached SPI device is ignored.\r
+ *\r
+ * \param[in,out] SPI Pointer to the base of the SPI peripheral within the device.\r
+ * \param[in] Byte Byte to send through the SPI interface.\r
+ */\r
+ static inline void SPI_SendByte(SPI_t* const SPI,\r
+ const uint8_t Byte) ATTR_ALWAYS_INLINE;\r
+ static inline void SPI_SendByte(SPI_t* const SPI,\r
+ const uint8_t Byte)\r
+ {\r
+ SPI->DATA = Byte;\r
+ while (!(SPI->STATUS & SPI_IF_bm));\r
+ }\r
+\r
+ /** Sends a dummy byte through the SPI interface, blocking until the transfer is complete. The response\r
+ * byte from the attached SPI device is returned.\r
+ *\r
+ * \param[in,out] SPI Pointer to the base of the SPI peripheral within the device.\r
+ *\r
+ * \return The response byte from the attached SPI device.\r
+ */\r
+ static inline uint8_t SPI_ReceiveByte(SPI_t* const SPI) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t SPI_ReceiveByte(SPI_t* const SPI)\r
+ {\r
+ SPI->DATA = 0;\r
+ while (!(SPI->STATUS & SPI_IF_bm));\r
+ return SPI->DATA;\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master SPI Mode Serial USART Peripheral Driver (XMEGA)\r
+ *\r
+ * On-chip Master SPI mode USART driver for the XMEGA AVR microcontrollers.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the SPI Master\r
+ * Mode USART driver dispatch header located in LUFA/Drivers/Peripheral/Serial.h.\r
+ */\r
+\r
+/** \ingroup Group_SerialSPI\r
+ * \defgroup Group_SerialSPI_XMEGA Master SPI Mode Serial USART Peripheral Driver (XMEGA)\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * On-chip serial USART driver for the XMEGA AVR microcontrollers.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the ADC driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/SerialSPI.h.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * // Initialize the Master SPI mode USART driver before first use, with 1Mbit baud\r
+ * SerialSPI_Init(&USARTD0, (USART_SPI_SCK_LEAD_RISING | USART_SPI_SAMPLE_LEADING | USART_SPI_ORDER_MSB_FIRST), 1000000);\r
+ * \r
+ * // Send several bytes, ignoring the returned data\r
+ * SerialSPI_SendByte(&USARTD0, 0x01);\r
+ * SerialSPI_SendByte(&USARTD0, 0x02);\r
+ * SerialSPI_SendByte(&USARTD0, 0x03);\r
+ * \r
+ * // Receive several bytes, sending a dummy 0x00 byte each time\r
+ * uint8_t Byte1 = SerialSPI_ReceiveByte(&USARTD);\r
+ * uint8_t Byte2 = SerialSPI_ReceiveByte(&USARTD);\r
+ * uint8_t Byte3 = SerialSPI_ReceiveByte(&USARTD);\r
+ * \r
+ * // Send a byte, and store the received byte from the same transaction\r
+ * uint8_t ResponseByte = SerialSPI_TransferByte(&USARTD0, 0xDC);\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __SERIAL_SPI_XMEGA_H__\r
+#define __SERIAL_SPI_XMEGA_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+\r
+ #include <stdio.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_SERIAL_SPI_H)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Peripheral/Serial.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ #define SERIAL_SPI_UBBRVAL(Baud) ((Baud < (F_CPU / 2)) ? ((F_CPU / (2 * Baud)) - 1) : 0)\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name SPI SCK Polarity Configuration Masks */\r
+ //@{\r
+ /** SPI clock polarity mask for \ref SerialSPI_Init(). Indicates that the SCK should lead on the rising edge. */\r
+ #define USART_SPI_SCK_LEAD_RISING 0\r
+ //@}\r
+\r
+ /** \name SPI Sample Edge Configuration Masks */\r
+ //@{\r
+ /** SPI data sample mode mask for \ref SerialSPI_Init(). Indicates that the data should sampled on the leading edge. */\r
+ #define USART_SPI_SAMPLE_LEADING 0\r
+\r
+ /** SPI data sample mode mask for \ref SerialSPI_Init(). Indicates that the data should be sampled on the trailing edge. */\r
+ #define USART_SPI_SAMPLE_TRAILING USART_UPCHA_bm\r
+ //@}\r
+\r
+ /** \name SPI Data Ordering Configuration Masks */\r
+ //@{\r
+ /** SPI data order mask for \ref SerialSPI_Init(). Indicates that data should be shifted out MSB first. */\r
+ #define USART_SPI_ORDER_MSB_FIRST 0\r
+\r
+ /** SPI data order mask for \ref SerialSPI_Init(). Indicates that data should be shifted out LSB first. */\r
+ #define USART_SPI_ORDER_LSB_FIRST USART_UDORD_bm\r
+ //@} \r
+\r
+ /* Inline Functions: */\r
+ /** Initialize the USART module in Master SPI mode. \r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ * \param[in] SPIOptions USART SPI Options, a mask consisting of one of each of the \c USART_SPI_SCK_*,\r
+ * \c USART_SPI_SAMPLE_* and \c USART_SPI_ORDER_* masks.\r
+ * \param[in] BaudRate SPI baud rate, in bits per second.\r
+ */\r
+ static inline void SerialSPI_Init(USART_t* const USART,\r
+ const uint8_t SPIOptions,\r
+ const uint32_t BaudRate)\r
+ {\r
+ uint16_t BaudValue = SERIAL_SPI_UBBRVAL(BaudRate);\r
+ \r
+ USART->BAUDCTRLB = (BaudValue >> 8);\r
+ USART->BAUDCTRLA = (BaudValue & 0xFF);\r
+ \r
+ USART->CTRLC = (USART_CMODE_MSPI_gc | SPIOptions);\r
+ USART->CTRLB = (USART_RXEN_bm | USART_TXEN_bm);\r
+ }\r
+ \r
+ /** Turns off the USART driver, disabling and returning used hardware to their default configuration.\r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ */\r
+ static inline void SerialSPI_Disable(USART_t* const USART)\r
+ {\r
+ USART->CTRLA = 0;\r
+ USART->CTRLB = 0;\r
+ USART->CTRLC = 0;\r
+ }\r
+ \r
+ /** Sends and receives a byte through the USART SPI interface, blocking until the transfer is complete.\r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ * \param[in] DataByte Byte to send through the USART SPI interface.\r
+ *\r
+ * \return Response byte from the attached SPI device.\r
+ */\r
+ static inline uint8_t SerialSPI_TransferByte(USART_t* const USART,\r
+ const uint8_t DataByte)\r
+ {\r
+ USART->DATA = DataByte;\r
+ while (!(USART->STATUS & USART_TXCIF_bm));\r
+ USART->STATUS = USART_TXCIF_bm;\r
+ return USART->DATA;\r
+ }\r
+\r
+ /** Sends a byte through the USART SPI interface, blocking until the transfer is complete. The response\r
+ * byte sent to from the attached SPI device is ignored.\r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ * \param[in] DataByte Byte to send through the USART SPI interface.\r
+ */\r
+ static inline void SerialSPI_SendByte(USART_t* const USART,\r
+ const uint8_t DataByte)\r
+ {\r
+ SerialSPI_TransferByte(USART, DataByte);\r
+ }\r
+\r
+ /** Sends a dummy byte through the USART SPI interface, blocking until the transfer is complete. The response\r
+ * byte from the attached SPI device is returned.\r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ *\r
+ * \return The response byte from the attached SPI device.\r
+ */\r
+ static inline uint8_t SerialSPI_ReceiveByte(USART_t* const USART)\r
+ {\r
+ return SerialSPI_TransferByte(USART, 0);\r
+ }\r
+ \r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../Common/Common.h"\r
+#if (ARCH == ARCH_XMEGA)\r
+\r
+#define __INCLUDE_FROM_SERIAL_C\r
+#include "../Serial.h"\r
+\r
+FILE USARTSerialStream;\r
+\r
+int Serial_putchar(char DataByte,\r
+ FILE *Stream)\r
+{\r
+ USART_t* USART = fdev_get_udata(Stream);\r
+\r
+ Serial_SendByte(USART, DataByte);\r
+ return 0;\r
+}\r
+\r
+int Serial_getchar(FILE *Stream)\r
+{\r
+ USART_t* USART = fdev_get_udata(Stream);\r
+\r
+ if (!(Serial_IsCharReceived(USART)))\r
+ return _FDEV_EOF;\r
+\r
+ return Serial_ReceiveByte(USART);\r
+}\r
+\r
+int Serial_getchar_Blocking(FILE *Stream)\r
+{\r
+ USART_t* USART = fdev_get_udata(Stream);\r
+\r
+ while (!(Serial_IsCharReceived(USART)));\r
+ return Serial_ReceiveByte(USART);\r
+}\r
+\r
+void Serial_SendString_P(USART_t* const USART,\r
+ const char* FlashStringPtr)\r
+{\r
+ uint8_t CurrByte;\r
+\r
+ while ((CurrByte = pgm_read_byte(FlashStringPtr)) != 0x00)\r
+ {\r
+ Serial_SendByte(USART, CurrByte);\r
+ FlashStringPtr++;\r
+ }\r
+}\r
+\r
+void Serial_SendString(USART_t* const USART,\r
+ const char* StringPtr)\r
+{\r
+ uint8_t CurrByte;\r
+\r
+ while ((CurrByte = *StringPtr) != 0x00)\r
+ {\r
+ Serial_SendByte(USART, CurrByte);\r
+ StringPtr++;\r
+ }\r
+}\r
+\r
+void Serial_SendData(USART_t* const USART,\r
+ const uint8_t* Buffer,\r
+ uint16_t Length)\r
+{\r
+ while (Length--)\r
+ Serial_SendByte(USART, *(Buffer++));\r
+}\r
+\r
+void Serial_CreateStream(FILE* Stream)\r
+{\r
+ if (!(Stream))\r
+ {\r
+ Stream = &USARTSerialStream;\r
+ stdin = Stream;\r
+ stdout = Stream;\r
+ }\r
+\r
+ *Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar, _FDEV_SETUP_RW);\r
+}\r
+\r
+void Serial_CreateBlockingStream(FILE* Stream)\r
+{\r
+ if (!(Stream))\r
+ {\r
+ Stream = &USARTSerialStream;\r
+ stdin = Stream;\r
+ stdout = Stream;\r
+ }\r
+\r
+ *Stream = (FILE)FDEV_SETUP_STREAM(Serial_putchar, Serial_getchar_Blocking, _FDEV_SETUP_RW);\r
+}\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Serial USART Peripheral Driver (XMEGA)\r
+ *\r
+ * On-chip serial USART driver for the XMEGA AVR microcontrollers.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USART driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/Serial.h.\r
+ */\r
+\r
+/** \ingroup Group_Serial\r
+ * \defgroup Group_Serial_XMEGA Serial USART Peripheral Driver (XMEGA)\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * On-chip serial USART driver for the XMEGA AVR microcontrollers.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USART driver\r
+ * dispatch header located in LUFA/Drivers/Peripheral/Serial.h.\r
+ *\r
+ * \section Sec_ExampleUsage Example Usage\r
+ * The following snippet is an example of how this module may be used within a typical\r
+ * application.\r
+ *\r
+ * \code\r
+ * // Initialize the serial USART driver before first use, with 9600 baud (and no double-speed mode)\r
+ * Serial_Init(&USARTD0, 9600, false);\r
+ * \r
+ * // Send a string through the USART\r
+ * Serial_TxString(&USARTD0, "Test String\r\n");\r
+ * \r
+ * // Receive a byte through the USART\r
+ * uint8_t DataByte = Serial_RxByte(&USARTD0);\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __SERIAL_XMEGA_H__\r
+#define __SERIAL_XMEGA_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "../../Misc/TerminalCodes.h"\r
+\r
+ #include <stdio.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_SERIAL_H) && !defined(__INCLUDE_FROM_SERIAL_C)\r
+ #error Do not include this file directly. Include LUFA/Drivers/Peripheral/Serial.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* External Variables: */\r
+ extern FILE USARTSerialStream;\r
+\r
+ /* Function Prototypes: */\r
+ int Serial_putchar(char DataByte,\r
+ FILE *Stream);\r
+ int Serial_getchar(FILE *Stream);\r
+ int Serial_getchar_Blocking(FILE *Stream);\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Macro for calculating the baud value from a given baud rate when the \c U2X (double speed) bit is\r
+ * not set.\r
+ *\r
+ * \param[in] Baud Target serial UART baud rate.\r
+ *\r
+ * \return Closest UBRR register value for the given UART frequency.\r
+ */\r
+ #define SERIAL_UBBRVAL(Baud) ((((F_CPU / 16) + (Baud / 2)) / (Baud)) - 1)\r
+\r
+ /** Macro for calculating the baud value from a given baud rate when the \c U2X (double speed) bit is\r
+ * set.\r
+ *\r
+ * \param[in] Baud Target serial UART baud rate.\r
+ *\r
+ * \return Closest UBRR register value for the given UART frequency.\r
+ */\r
+ #define SERIAL_2X_UBBRVAL(Baud) ((((F_CPU / 8) + (Baud / 2)) / (Baud)) - 1)\r
+\r
+ /* Function Prototypes: */\r
+ /** Transmits a given string located in program space (FLASH) through the USART.\r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ * \param[in] FlashStringPtr Pointer to a string located in program space.\r
+ */\r
+ void Serial_SendString_P(USART_t* const USART,\r
+ const char* FlashStringPtr) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Transmits a given string located in SRAM memory through the USART.\r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ * \param[in] StringPtr Pointer to a string located in SRAM space.\r
+ */\r
+ void Serial_SendString(USART_t* const USART,\r
+ const char* StringPtr) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Transmits a given buffer located in SRAM memory through the USART.\r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ * \param[in] Buffer Pointer to a buffer containing the data to send.\r
+ * \param[in] Length Length of the data to send, in bytes.\r
+ */\r
+ void Serial_SendData(USART_t* const USART,\r
+ const uint8_t* Buffer, uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Creates a standard character stream from the USART so that it can be used with all the regular functions\r
+ * in the avr-libc \c <stdio.h> library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created\r
+ * stream is bidirectional and can be used for both input and output functions.\r
+ *\r
+ * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single\r
+ * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may\r
+ * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own\r
+ * line buffering.\r
+ *\r
+ * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL, \c stdout\r
+ * and \c stdin will be configured to use the USART.\r
+ *\r
+ * \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used.\r
+ */\r
+ void Serial_CreateStream(FILE* Stream);\r
+ \r
+ /** Identical to \ref Serial_CreateStream(), except that reads are blocking until the calling stream function terminates\r
+ * the transfer.\r
+ *\r
+ * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed, if \c NULL, \c stdout\r
+ * and \c stdin will be configured to use the USART.\r
+ *\r
+ * \pre The USART must first be configured via a call to \ref Serial_Init() before the stream is used.\r
+ */\r
+ void Serial_CreateBlockingStream(FILE* Stream);\r
+\r
+ /* Inline Functions: */\r
+ /** Initializes the USART, ready for serial data transmission and reception. This initializes the interface to\r
+ * standard 8-bit, no parity, 1 stop bit settings suitable for most applications.\r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ * \param[in] BaudRate Serial baud rate, in bits per second.\r
+ * \param[in] DoubleSpeed Enables double speed mode when set, halving the sample time to double the baud rate.\r
+ */\r
+ static inline void Serial_Init(USART_t* const USART,\r
+ const uint32_t BaudRate,\r
+ const bool DoubleSpeed)\r
+ {\r
+ uint16_t BaudValue = (DoubleSpeed ? SERIAL_2X_UBBRVAL(BaudRate) : SERIAL_UBBRVAL(BaudRate));\r
+\r
+ USART->BAUDCTRLB = (BaudValue >> 8);\r
+ USART->BAUDCTRLA = (BaudValue & 0xFF);\r
+ \r
+ USART->CTRLC = (USART_CMODE_ASYNCHRONOUS_gc | USART_PMODE_DISABLED_gc | USART_CHSIZE_8BIT_gc);\r
+ USART->CTRLB = (USART_RXEN_bm | USART_TXEN_bm | (DoubleSpeed ? USART_CLK2X_bm : 0));\r
+ }\r
+\r
+ /** Turns off the USART driver, disabling and returning used hardware to their default configuration.\r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ */\r
+ static inline void Serial_Disable(USART_t* const USART)\r
+ {\r
+ USART->CTRLA = 0;\r
+ USART->CTRLB = 0;\r
+ USART->CTRLC = 0;\r
+ }\r
+ \r
+ /** Indicates whether a character has been received through the USART.\r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ *\r
+ * \return Boolean \c true if a character has been received, \c false otherwise.\r
+ */\r
+ static inline bool Serial_IsCharReceived(USART_t* const USART) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Serial_IsCharReceived(USART_t* const USART)\r
+ {\r
+ return ((USART->STATUS & USART_RXCIF_bm) ? true : false);\r
+ }\r
+\r
+ /** Transmits a given byte through the USART.\r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ * \param[in] DataByte Byte to transmit through the USART.\r
+ */\r
+ static inline void Serial_SendByte(USART_t* const USART,\r
+ const char DataByte) ATTR_ALWAYS_INLINE;\r
+ static inline void Serial_SendByte(USART_t* const USART,\r
+ const char DataByte)\r
+ {\r
+ while (!(USART->STATUS & USART_DREIF_bm));\r
+ USART->DATA = DataByte;\r
+ }\r
+\r
+ /** Receives the next byte from the USART.\r
+ *\r
+ * \param[in,out] USART Pointer to the base of the USART peripheral within the device.\r
+ *\r
+ * \return Next byte received from the USART, or a negative value if no byte has been received.\r
+ */\r
+ static inline int16_t Serial_ReceiveByte(USART_t* const USART) ATTR_ALWAYS_INLINE;\r
+ static inline int16_t Serial_ReceiveByte(USART_t* const USART)\r
+ {\r
+ if (!(Serial_IsCharReceived(USART)))\r
+ return -1;\r
+\r
+ USART->STATUS = USART_RXCIF_bm;\r
+ return USART->DATA;\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master include file for the library USB Android Open Accessory Class driver.\r
+ *\r
+ * Master include file for the library USB Android Open Accessory Class driver, for both host and device modes, where available.\r
+ *\r
+ * This file should be included in all user projects making use of this optional class driver, instead of\r
+ * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories.\r
+ */\r
+\r
+/** \ingroup Group_USBClassDrivers\r
+ * \defgroup Group_USBClassAOA Android Open Accessory Class Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Android Open Accessory Class Driver module. This module contains an internal implementation of the USB Android Open Accessory\r
+ * Class, for Host USB mode. User applications can use this class driver instead of implementing the Android Open Accessory Class\r
+ * manually via the low-level LUFA APIs.\r
+ *\r
+ * This module is designed to simplify the user code by exposing only the required interface needed to interface with\r
+ * Host using the USB Android Open Accessory Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _AOA_CLASS_H_\r
+#define _AOA_CLASS_H_\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_USB_DRIVER\r
+ #define __INCLUDE_FROM_AOA_DRIVER\r
+\r
+ /* Includes: */\r
+ #include "../Core/USBMode.h"\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #include "Host/AndroidAccessoryClassHost.h"\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master include file for the library USB Audio 1.0 Class driver.\r
+ *\r
+ * Master include file for the library USB Audio 1.0 Class driver, for both host and device modes, where available.\r
+ *\r
+ * This file should be included in all user projects making use of this optional class driver, instead of\r
+ * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories.\r
+ */\r
+\r
+/** \ingroup Group_USBClassDrivers\r
+ * \defgroup Group_USBClassAudio Audio 1.0 Class Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Device/AudioClassDevice.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ * - LUFA/Drivers/USB/Class/Host/AudioClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Audio 1.0 Class Driver module. This module contains an internal implementation of the USB Audio 1.0 Class, for both\r
+ * Device and Host USB modes. User applications can use this class driver instead of implementing the Audio 1.0 class\r
+ * manually via the low-level LUFA APIs.\r
+ *\r
+ * This module is designed to simplify the user code by exposing only the required interface needed to interface with\r
+ * Hosts or Devices using the USB Audio 1.0 Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _AUDIO_CLASS_H_\r
+#define _AUDIO_CLASS_H_\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_USB_DRIVER\r
+ #define __INCLUDE_FROM_AUDIO_DRIVER\r
+\r
+ /* Includes: */\r
+ #include "../Core/USBMode.h"\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #include "Device/AudioClassDevice.h"\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #include "Host/AudioClassHost.h"\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master include file for the library USB CDC-ACM Class driver.\r
+ *\r
+ * Master include file for the library USB CDC Class driver, for both host and device modes, where available.\r
+ *\r
+ * This file should be included in all user projects making use of this optional class driver, instead of\r
+ * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories.\r
+ */\r
+\r
+/** \ingroup Group_USBClassDrivers\r
+ * \defgroup Group_USBClassCDC CDC-ACM (Virtual Serial) Class Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Device/CDCClassDevice.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ * - LUFA/Drivers/USB/Class/Host/CDCClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * CDC Class Driver module. This module contains an internal implementation of the USB CDC-ACM class Virtual Serial\r
+ * Ports, for both Device and Host USB modes. User applications can use this class driver instead of implementing the\r
+ * CDC class manually via the low-level LUFA APIs.\r
+ *\r
+ * This module is designed to simplify the user code by exposing only the required interface needed to interface with\r
+ * Hosts or Devices using the USB CDC Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _CDC_CLASS_H_\r
+#define _CDC_CLASS_H_\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_USB_DRIVER\r
+ #define __INCLUDE_FROM_CDC_DRIVER\r
+\r
+ /* Includes: */\r
+ #include "../Core/USBMode.h"\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #include "Device/CDCClassDevice.h"\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #include "Host/CDCClassHost.h"\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common definitions and declarations for the library USB Android Open Accessory Class driver.\r
+ *\r
+ * Common definitions and declarations for the library USB Android Open Accessory Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassAOA\r
+ * \defgroup Group_USBClassAOACommon Common Class Definitions\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB\r
+ * Android Open Accessory Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _AOA_CLASS_COMMON_H_\r
+#define _AOA_CLASS_COMMON_H_\r
+\r
+ /* Includes: */\r
+ #include "../../Core/StdDescriptors.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_AOA_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Macros: */\r
+ /** Product ID value in a Device Descriptor to indicate an Android device in Open Accessory mode. */\r
+ #define ANDROID_ACCESSORY_PRODUCT_ID 0x2D00\r
+\r
+ /** Product ID value in a Device Descriptor to indicate an Android device in Open Accessory and Android Debug mode. */\r
+ #define ANDROID_ACCESSORY_ADB_PRODUCT_ID 0x2D01\r
+\r
+ /* Enums: */\r
+ /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the\r
+ * Android Open Accessory class.\r
+ */\r
+ enum AOA_Descriptor_ClassSubclassProtocol_t\r
+ {\r
+ AOA_CSCP_AOADataClass = 0xFF, /**< Descriptor Class value indicating that the device or interface\r
+ * belongs to the AOA data class.\r
+ */\r
+ AOA_CSCP_AOADataSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device or interface\r
+ * belongs to AOA data subclass.\r
+ */\r
+ AOA_CSCP_AOADataProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface\r
+ * belongs to the AOA data class protocol.\r
+ */\r
+ };\r
+\r
+ /** Enum for the Android Open Accessory class specific control requests that can be issued by the USB bus host. */\r
+ enum AOA_ClassRequests_t\r
+ {\r
+ AOA_REQ_GetAccessoryProtocol = 0x33, /**< Android Open Accessory control request to retrieve the device's supported Accessory Protocol version. */\r
+ AOA_REQ_SendString = 0x34, /**< Android Open Accessory control request to set an accessory property string in the device. */\r
+ AOA_REQ_StartAccessoryMode = 0x35, /**< Android Open Accessory control request to switch the device into Accessory mode. */\r
+ };\r
+\r
+ /** Enum for the possible Android Open Accessory property string indexes. */\r
+ enum AOA_Strings_t\r
+ {\r
+ AOA_STRING_Manufacturer = 0, /**< Index of the Manufacturer property string. */\r
+ AOA_STRING_Model = 1, /**< Index of the Model Name property string. */\r
+ AOA_STRING_Description = 2, /**< Index of the Description property string. */\r
+ AOA_STRING_Version = 3, /**< Index of the Version Number property string. */\r
+ AOA_STRING_URI = 4, /**< Index of the URI Information property string. */\r
+ AOA_STRING_Serial = 5, /**< Index of the Serial Number property string. */\r
+ \r
+ #if !defined(__DOXYGEN__)\r
+ AOA_STRING_TOTAL_STRINGS\r
+ #endif\r
+ };\r
+ \r
+ /** Enum for the possible Android Open Accessory protocol versions. */\r
+ enum AOA_Protocols_t\r
+ {\r
+ AOA_PROTOCOL_AccessoryV1 = 0x0001, /**< Android Open Accessory version 1. */\r
+ };\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common definitions and declarations for the library USB Audio 1.0 Class driver.\r
+ *\r
+ * Common definitions and declarations for the library USB Audio 1.0 Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassAudio\r
+ * \defgroup Group_USBClassAudioCommon Common Class Definitions\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB\r
+ * Audio 1.0 Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _AUDIO_CLASS_COMMON_H_\r
+#define _AUDIO_CLASS_COMMON_H_\r
+\r
+ /* Includes: */\r
+ #include "../../Core/StdDescriptors.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_AUDIO_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Macros: */\r
+ /** \name Audio Channel Masks */\r
+ //@{\r
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_CHANNEL_LEFT_FRONT (1 << 0)\r
+\r
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_CHANNEL_RIGHT_FRONT (1 << 1)\r
+\r
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_CHANNEL_CENTER_FRONT (1 << 2)\r
+\r
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_CHANNEL_LOW_FREQ_ENHANCE (1 << 3)\r
+\r
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_CHANNEL_LEFT_SURROUND (1 << 4)\r
+\r
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_CHANNEL_RIGHT_SURROUND (1 << 5)\r
+\r
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_CHANNEL_LEFT_OF_CENTER (1 << 6)\r
+\r
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_CHANNEL_RIGHT_OF_CENTER (1 << 7)\r
+\r
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_CHANNEL_SURROUND (1 << 8)\r
+\r
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_CHANNEL_SIDE_LEFT (1 << 9)\r
+\r
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_CHANNEL_SIDE_RIGHT (1 << 10)\r
+\r
+ /** Supported channel mask for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_CHANNEL_TOP (1 << 11)\r
+ //@}\r
+\r
+ /** \name Audio Feature Masks */\r
+ //@{\r
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_FEATURE_MUTE (1 << 0)\r
+\r
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_FEATURE_VOLUME (1 << 1)\r
+\r
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_FEATURE_BASS (1 << 2)\r
+\r
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_FEATURE_MID (1 << 3)\r
+\r
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_FEATURE_TREBLE (1 << 4)\r
+\r
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_FEATURE_GRAPHIC_EQUALIZER (1 << 5)\r
+\r
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_FEATURE_AUTOMATIC_GAIN (1 << 6)\r
+\r
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_FEATURE_DELAY (1 << 7)\r
+\r
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_FEATURE_BASS_BOOST (1 << 8)\r
+\r
+ /** Supported feature mask for an Audio class feature unit descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_FEATURE_BASS_LOUDNESS (1 << 9)\r
+ //@}\r
+\r
+ /** \name Audio Terminal Types */\r
+ //@{\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_UNDEFINED 0x0100\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_STREAMING 0x0101\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_VENDOR 0x01FF\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_IN_UNDEFINED 0x0200\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_IN_MIC 0x0201\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_IN_DESKTOP_MIC 0x0202\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_IN_PERSONAL_MIC 0x0203\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_IN_OMNIDIR_MIC 0x0204\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_IN_MIC_ARRAY 0x0205\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_IN_PROCESSING_MIC 0x0206\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_IN_OUT_UNDEFINED 0x0300\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_OUT_SPEAKER 0x0301\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_OUT_HEADPHONES 0x0302\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_OUT_HEAD_MOUNTED 0x0303\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_OUT_DESKTOP 0x0304\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_OUT_ROOM 0x0305\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_OUT_COMMUNICATION 0x0306\r
+\r
+ /** Terminal type constant for an Audio class terminal descriptor. See the Audio class specification for more details. */\r
+ #define AUDIO_TERMINAL_OUT_LOWFREQ 0x0307\r
+ //@}\r
+\r
+ /** Convenience macro to fill a 24-bit \ref USB_Audio_SampleFreq_t structure with the given sample rate as a 24-bit number.\r
+ *\r
+ * \param[in] freq Required audio sampling frequency in HZ\r
+ */\r
+ #define AUDIO_SAMPLE_FREQ(freq) {.Byte1 = ((uint32_t)freq & 0xFF), .Byte2 = (((uint32_t)freq >> 8) & 0xFF), .Byte3 = (((uint32_t)freq >> 16) & 0xFF)}\r
+\r
+ /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint\r
+ * accepts only filled endpoint packets of audio samples.\r
+ */\r
+ #define AUDIO_EP_FULL_PACKETS_ONLY (1 << 7)\r
+\r
+ /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint\r
+ * will accept partially filled endpoint packets of audio samples.\r
+ */\r
+ #define AUDIO_EP_ACCEPTS_SMALL_PACKETS (0 << 7)\r
+\r
+ /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint\r
+ * allows for sampling frequency adjustments to be made via control requests directed at the endpoint.\r
+ */\r
+ #define AUDIO_EP_SAMPLE_FREQ_CONTROL (1 << 0)\r
+\r
+ /** Mask for the attributes parameter of an Audio class-specific Endpoint descriptor, indicating that the endpoint\r
+ * allows for pitch adjustments to be made via control requests directed at the endpoint.\r
+ */\r
+ #define AUDIO_EP_PITCH_CONTROL (1 << 1)\r
+\r
+ /* Enums: */\r
+ /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the Audio\r
+ * device class.\r
+ */\r
+ enum Audio_Descriptor_ClassSubclassProtocol_t\r
+ {\r
+ AUDIO_CSCP_AudioClass = 0x01, /**< Descriptor Class value indicating that the device or\r
+ * interface belongs to the USB Audio 1.0 class.\r
+ */\r
+ AUDIO_CSCP_ControlSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or\r
+ * interface belongs to the Audio Control subclass.\r
+ */\r
+ AUDIO_CSCP_ControlProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or\r
+ * interface belongs to the Audio Control protocol.\r
+ */\r
+ AUDIO_CSCP_AudioStreamingSubclass = 0x02, /**< Descriptor Subclass value indicating that the device or\r
+ * interface belongs to the MIDI Streaming subclass.\r
+ */\r
+ AUDIO_CSCP_MIDIStreamingSubclass = 0x03, /**< Descriptor Subclass value indicating that the device or\r
+ * interface belongs to the Audio streaming subclass.\r
+ */\r
+ AUDIO_CSCP_StreamingProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or\r
+ * interface belongs to the Streaming Audio protocol.\r
+ */\r
+ };\r
+\r
+ /** Audio class specific interface description subtypes, for the Audio Control interface. */\r
+ enum Audio_CSInterface_AC_SubTypes_t\r
+ {\r
+ AUDIO_DSUBTYPE_CSInterface_Header = 0x01, /**< Audio class specific control interface header. */\r
+ AUDIO_DSUBTYPE_CSInterface_InputTerminal = 0x02, /**< Audio class specific control interface Input Terminal. */\r
+ AUDIO_DSUBTYPE_CSInterface_OutputTerminal = 0x03, /**< Audio class specific control interface Output Terminal. */\r
+ AUDIO_DSUBTYPE_CSInterface_Mixer = 0x04, /**< Audio class specific control interface Mixer Unit. */\r
+ AUDIO_DSUBTYPE_CSInterface_Selector = 0x05, /**< Audio class specific control interface Selector Unit. */\r
+ AUDIO_DSUBTYPE_CSInterface_Feature = 0x06, /**< Audio class specific control interface Feature Unit. */\r
+ AUDIO_DSUBTYPE_CSInterface_Processing = 0x07, /**< Audio class specific control interface Processing Unit. */\r
+ AUDIO_DSUBTYPE_CSInterface_Extension = 0x08, /**< Audio class specific control interface Extension Unit. */\r
+ };\r
+\r
+ /** Audio class specific interface description subtypes, for the Audio Streaming interface. */\r
+ enum Audio_CSInterface_AS_SubTypes_t\r
+ {\r
+ AUDIO_DSUBTYPE_CSInterface_General = 0x01, /**< Audio class specific streaming interface general descriptor. */\r
+ AUDIO_DSUBTYPE_CSInterface_FormatType = 0x02, /**< Audio class specific streaming interface format type descriptor. */\r
+ AUDIO_DSUBTYPE_CSInterface_FormatSpecific = 0x03, /**< Audio class specific streaming interface format information descriptor. */\r
+ };\r
+\r
+ /** Audio class specific endpoint description subtypes, for the Audio Streaming interface. */\r
+ enum Audio_CSEndpoint_SubTypes_t\r
+ {\r
+ AUDIO_DSUBTYPE_CSEndpoint_General = 0x01, /**< Audio class specific endpoint general descriptor. */\r
+ };\r
+\r
+ /** Enum for the Audio class specific control requests that can be issued by the USB bus host. */\r
+ enum Audio_ClassRequests_t\r
+ {\r
+ AUDIO_REQ_SetCurrent = 0x01, /**< Audio class-specific request to set the current value of a parameter within the device. */\r
+ AUDIO_REQ_SetMinimum = 0x02, /**< Audio class-specific request to set the minimum value of a parameter within the device. */\r
+ AUDIO_REQ_SetMaximum = 0x03, /**< Audio class-specific request to set the maximum value of a parameter within the device. */\r
+ AUDIO_REQ_SetResolution = 0x04, /**< Audio class-specific request to set the resolution value of a parameter within the device. */\r
+ AUDIO_REQ_SetMemory = 0x05, /**< Audio class-specific request to set the memory value of a parameter within the device. */\r
+ AUDIO_REQ_GetCurrent = 0x81, /**< Audio class-specific request to get the current value of a parameter within the device. */\r
+ AUDIO_REQ_GetMinimum = 0x82, /**< Audio class-specific request to get the minimum value of a parameter within the device. */\r
+ AUDIO_REQ_GetMaximum = 0x83, /**< Audio class-specific request to get the maximum value of a parameter within the device. */\r
+ AUDIO_REQ_GetResolution = 0x84, /**< Audio class-specific request to get the resolution value of a parameter within the device. */\r
+ AUDIO_REQ_GetMemory = 0x85, /**< Audio class-specific request to get the memory value of a parameter within the device. */\r
+ AUDIO_REQ_GetStatus = 0xFF, /**< Audio class-specific request to get the device status. */\r
+ };\r
+\r
+ /** Enum for Audio class specific Endpoint control modifiers which can be set and retrieved by a USB host, if the corresponding\r
+ * endpoint control is indicated to be supported in the Endpoint's Audio-class specific endpoint descriptor.\r
+ */\r
+ enum Audio_EndpointControls_t\r
+ {\r
+ AUDIO_EPCONTROL_SamplingFreq = 0x01, /**< Sampling frequency adjustment of the endpoint. */\r
+ AUDIO_EPCONTROL_Pitch = 0x02, /**< Pitch adjustment of the endpoint. */\r
+ };\r
+\r
+ /* Type Defines: */\r
+ /** \brief Audio class-specific Input Terminal Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific input terminal descriptor. This indicates to the host that the device\r
+ * contains an input audio source, either from a physical terminal on the device, or a logical terminal (for example,\r
+ * a USB endpoint). See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_Audio_StdDescriptor_InputTerminal_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * must be \ref AUDIO_DSUBTYPE_CSInterface_InputTerminal.\r
+ */\r
+\r
+ uint8_t TerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */\r
+ uint16_t TerminalType; /**< Type of terminal, a \c TERMINAL_* mask. */\r
+ uint8_t AssociatedOutputTerminal; /**< ID of associated output terminal, for physically grouped terminals\r
+ * such as the speaker and microphone of a phone handset.\r
+ */\r
+ uint8_t TotalChannels; /**< Total number of separate audio channels within this interface (right, left, etc.) */\r
+ uint16_t ChannelConfig; /**< \c CHANNEL_* masks indicating what channel layout is supported by this terminal. */\r
+\r
+ uint8_t ChannelStrIndex; /**< Index of a string descriptor describing this channel within the device. */\r
+ uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */\r
+ } ATTR_PACKED USB_Audio_Descriptor_InputTerminal_t;\r
+\r
+ /** \brief Audio class-specific Input Terminal Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific input terminal descriptor. This indicates to the host that the device\r
+ * contains an input audio source, either from a physical terminal on the device, or a logical terminal (for example,\r
+ * a USB endpoint). See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_Audio_Descriptor_InputTerminal_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+\r
+ uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * must be \ref AUDIO_DSUBTYPE_CSInterface_InputTerminal.\r
+ */\r
+ uint8_t bTerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */\r
+ uint16_t wTerminalType; /**< Type of terminal, a \c TERMINAL_* mask. */\r
+ uint8_t bAssocTerminal; /**< ID of associated output terminal, for physically grouped terminals\r
+ * such as the speaker and microphone of a phone handset.\r
+ */\r
+ uint8_t bNrChannels; /**< Total number of separate audio channels within this interface (right, left, etc.) */\r
+ uint16_t wChannelConfig; /**< \c CHANNEL_* masks indicating what channel layout is supported by this terminal. */\r
+\r
+ uint8_t iChannelNames; /**< Index of a string descriptor describing this channel within the device. */\r
+ uint8_t iTerminal; /**< Index of a string descriptor describing this descriptor within the device. */\r
+ } ATTR_PACKED USB_Audio_StdDescriptor_InputTerminal_t;\r
+\r
+ /** \brief Audio class-specific Output Terminal Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific output terminal descriptor. This indicates to the host that the device\r
+ * contains an output audio sink, either to a physical terminal on the device, or a logical terminal (for example,\r
+ * a USB endpoint). See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_Audio_StdDescriptor_OutputTerminal_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * must be \ref AUDIO_DSUBTYPE_CSInterface_OutputTerminal.\r
+ */\r
+\r
+ uint8_t TerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */\r
+ uint16_t TerminalType; /**< Type of terminal, a \c TERMINAL_* mask. */\r
+ uint8_t AssociatedInputTerminal; /**< ID of associated input terminal, for physically grouped terminals\r
+ * such as the speaker and microphone of a phone handset.\r
+ */\r
+ uint8_t SourceID; /**< ID value of the unit this terminal's audio is sourced from. */\r
+\r
+ uint8_t TerminalStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */\r
+ } ATTR_PACKED USB_Audio_Descriptor_OutputTerminal_t;\r
+\r
+ /** \brief Audio class-specific Output Terminal Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific output terminal descriptor. This indicates to the host that the device\r
+ * contains an output audio sink, either to a physical terminal on the device, or a logical terminal (for example,\r
+ * a USB endpoint). See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_Audio_Descriptor_OutputTerminal_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * must be \ref AUDIO_DSUBTYPE_CSInterface_OutputTerminal.\r
+ */\r
+\r
+ uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * a value from the \ref Audio_CSInterface_AC_SubTypes_t enum.\r
+ */\r
+ uint8_t bTerminalID; /**< ID value of this terminal unit - must be a unique value within the device. */\r
+ uint16_t wTerminalType; /**< Type of terminal, a \c TERMINAL_* mask. */\r
+ uint8_t bAssocTerminal; /**< ID of associated input terminal, for physically grouped terminals\r
+ * such as the speaker and microphone of a phone handset.\r
+ */\r
+ uint8_t bSourceID; /**< ID value of the unit this terminal's audio is sourced from. */\r
+\r
+ uint8_t iTerminal; /**< Index of a string descriptor describing this descriptor within the device. */\r
+ } ATTR_PACKED USB_Audio_StdDescriptor_OutputTerminal_t;\r
+\r
+ /** \brief Audio class-specific Interface Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific interface descriptor. This follows a regular interface descriptor to\r
+ * supply extra information about the audio device's layout to the host. See the USB Audio specification for more\r
+ * details.\r
+ *\r
+ * \see \ref USB_Audio_StdDescriptor_Interface_AC_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum.\r
+ */\r
+\r
+ uint16_t ACSpecification; /**< Binary coded decimal value, indicating the supported Audio Class specification version. */\r
+ uint16_t TotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */\r
+\r
+ uint8_t InCollection; /**< Total number of Audio Streaming interfaces linked to this Audio Control interface (must be 1). */\r
+ uint8_t InterfaceNumber; /**< Interface number of the associated Audio Streaming interface. */\r
+ } ATTR_PACKED USB_Audio_Descriptor_Interface_AC_t;\r
+\r
+ /** \brief Audio class-specific Interface Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific interface descriptor. This follows a regular interface descriptor to\r
+ * supply extra information about the audio device's layout to the host. See the USB Audio specification for more\r
+ * details.\r
+ *\r
+ * \see \ref USB_Audio_Descriptor_Interface_AC_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+\r
+ uint8_t bDescriptorSubtype;/**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum.\r
+ */\r
+\r
+ uint16_t bcdADC; /**< Binary coded decimal value, indicating the supported Audio Class specification version. */\r
+ uint16_t wTotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */\r
+\r
+ uint8_t bInCollection; /**< Total number of Audio Streaming interfaces linked to this Audio Control interface (must be 1). */\r
+ uint8_t bInterfaceNumbers; /**< Interface number of the associated Audio Streaming interface. */\r
+ } ATTR_PACKED USB_Audio_StdDescriptor_Interface_AC_t;\r
+\r
+ /** \brief Audio class-specific Feature Unit Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific Feature Unit descriptor. This indicates to the host what features\r
+ * are present in the device's audio stream for basic control, such as per-channel volume. See the USB Audio\r
+ * specification for more details.\r
+ *\r
+ * \see \ref USB_Audio_StdDescriptor_FeatureUnit_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * must be \ref AUDIO_DSUBTYPE_CSInterface_Feature.\r
+ */\r
+\r
+ uint8_t UnitID; /**< ID value of this feature unit - must be a unique value within the device. */\r
+ uint8_t SourceID; /**< Source ID value of the audio source input into this feature unit. */\r
+\r
+ uint8_t ControlSize; /**< Size of each element in the \c ChannelControls array. */\r
+ uint8_t ChannelControls[3]; /**< Feature masks for the control channel, and each separate audio channel. */\r
+\r
+ uint8_t FeatureUnitStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */\r
+ } ATTR_PACKED USB_Audio_Descriptor_FeatureUnit_t;\r
+\r
+ /** \brief Audio class-specific Feature Unit Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific Feature Unit descriptor. This indicates to the host what features\r
+ * are present in the device's audio stream for basic control, such as per-channel volume. See the USB Audio\r
+ * specification for more details.\r
+ *\r
+ * \see \ref USB_Audio_Descriptor_FeatureUnit_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+\r
+ uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * must be \ref AUDIO_DSUBTYPE_CSInterface_Feature.\r
+ */\r
+\r
+ uint8_t bUnitID; /**< ID value of this feature unit - must be a unique value within the device. */\r
+ uint8_t bSourceID; /**< Source ID value of the audio source input into this feature unit. */\r
+\r
+ uint8_t bControlSize; /**< Size of each element in the \c ChannelControls array. */\r
+ uint8_t bmaControls[3]; /**< Feature masks for the control channel, and each separate audio channel. */\r
+\r
+ uint8_t iFeature; /**< Index of a string descriptor describing this descriptor within the device. */\r
+ } ATTR_PACKED USB_Audio_StdDescriptor_FeatureUnit_t;\r
+\r
+ /** \brief Audio class-specific Streaming Audio Interface Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific streaming interface descriptor. This indicates to the host\r
+ * how audio streams within the device are formatted. See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_Audio_StdDescriptor_Interface_AS_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum.\r
+ */\r
+\r
+ uint8_t TerminalLink; /**< ID value of the output terminal this descriptor is describing. */\r
+\r
+ uint8_t FrameDelay; /**< Delay in frames resulting from the complete sample processing from input to output. */\r
+ uint16_t AudioFormat; /**< Format of the audio stream, see Audio Device Formats specification. */\r
+ } ATTR_PACKED USB_Audio_Descriptor_Interface_AS_t;\r
+\r
+ /** \brief Audio class-specific Streaming Audio Interface Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific streaming interface descriptor. This indicates to the host\r
+ * how audio streams within the device are formatted. See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_Audio_Descriptor_Interface_AS_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+\r
+ uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum.\r
+ */\r
+\r
+ uint8_t bTerminalLink; /**< ID value of the output terminal this descriptor is describing. */\r
+\r
+ uint8_t bDelay; /**< Delay in frames resulting from the complete sample processing from input to output. */\r
+ uint16_t wFormatTag; /**< Format of the audio stream, see Audio Device Formats specification. */\r
+ } ATTR_PACKED USB_Audio_StdDescriptor_Interface_AS_t;\r
+\r
+ /** \brief Audio class-specific Format Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific audio format descriptor. This is used to give the host full details\r
+ * about the number of channels, the sample resolution, acceptable sample frequencies and encoding method used\r
+ * in the device's audio streams. See the USB Audio specification for more details.\r
+ *\r
+ * \attention This descriptor <b>must</b> be followed by one or more \ref USB_Audio_SampleFreq_t elements containing\r
+ * the continuous or discrete sample frequencies.\r
+ *\r
+ * \see \ref USB_Audio_StdDescriptor_Format_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * must be \ref AUDIO_DSUBTYPE_CSInterface_FormatType.\r
+ */\r
+\r
+ uint8_t FormatType; /**< Format of the audio stream, see Audio Device Formats specification. */\r
+ uint8_t Channels; /**< Total number of discrete channels in the stream. */\r
+\r
+ uint8_t SubFrameSize; /**< Size in bytes of each channel's sample data in the stream. */\r
+ uint8_t BitResolution; /**< Bits of resolution of each channel's samples in the stream. */\r
+\r
+ uint8_t TotalDiscreteSampleRates; /**< Total number of discrete sample frequencies supported by the device. When\r
+ * zero, this must be followed by the lower and upper continuous sampling\r
+ * frequencies supported by the device; otherwise, this must be followed\r
+ * by the given number of discrete sampling frequencies supported.\r
+ */\r
+ } ATTR_PACKED USB_Audio_Descriptor_Format_t;\r
+\r
+ /** \brief 24-Bit Audio Frequency Structure.\r
+ *\r
+ * Type define for a 24bit audio sample frequency structure. As GCC does not contain a built in 24-bit datatype,\r
+ * this this structure is used to build up the value instead. Fill this structure with the \ref AUDIO_SAMPLE_FREQ() macro.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t Byte1; /**< Lowest 8 bits of the 24-bit value. */\r
+ uint8_t Byte2; /**< Middle 8 bits of the 24-bit value. */\r
+ uint8_t Byte3; /**< Upper 8 bits of the 24-bit value. */\r
+ } ATTR_PACKED USB_Audio_SampleFreq_t;\r
+\r
+ /** \brief Audio class-specific Format Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific audio format descriptor. This is used to give the host full details\r
+ * about the number of channels, the sample resolution, acceptable sample frequencies and encoding method used\r
+ * in the device's audio streams. See the USB Audio specification for more details.\r
+ *\r
+ * \attention This descriptor <b>must</b> be followed by one or more 24-bit integer elements containing the continuous\r
+ * or discrete sample frequencies.\r
+ *\r
+ * \see \ref USB_Audio_Descriptor_Format_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * must be \ref AUDIO_DSUBTYPE_CSInterface_FormatType.\r
+ */\r
+\r
+ uint8_t bDescriptorSubtype;/**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * a value from the \ref Audio_CSInterface_AS_SubTypes_t enum.\r
+ */\r
+\r
+ uint8_t bFormatType; /**< Format of the audio stream, see Audio Device Formats specification. */\r
+ uint8_t bNrChannels; /**< Total number of discrete channels in the stream. */\r
+\r
+ uint8_t bSubFrameSize; /**< Size in bytes of each channel's sample data in the stream. */\r
+ uint8_t bBitResolution; /**< Bits of resolution of each channel's samples in the stream. */\r
+\r
+ uint8_t bSampleFrequencyType; /**< Total number of sample frequencies supported by the device. When\r
+ * zero, this must be followed by the lower and upper continuous sampling\r
+ * frequencies supported by the device; otherwise, this must be followed\r
+ * by the given number of discrete sampling frequencies supported.\r
+ */\r
+ } ATTR_PACKED USB_Audio_StdDescriptor_Format_t;\r
+\r
+ /** \brief Audio class-specific Streaming Endpoint Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific endpoint descriptor. This contains a regular endpoint\r
+ * descriptor with a few Audio-class-specific extensions. See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_Audio_StdDescriptor_StreamEndpoint_Std_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Endpoint_t Endpoint; /**< Standard endpoint descriptor describing the audio endpoint. */\r
+\r
+ uint8_t Refresh; /**< Always set to zero for Audio class devices. */\r
+ uint8_t SyncEndpointNumber; /**< Endpoint address to send synchronization information to, if needed (zero otherwise). */\r
+ } ATTR_PACKED USB_Audio_Descriptor_StreamEndpoint_Std_t;\r
+\r
+ /** \brief Audio class-specific Streaming Endpoint Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific endpoint descriptor. This contains a regular endpoint\r
+ * descriptor with a few Audio-class-specific extensions. See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_Audio_Descriptor_StreamEndpoint_Std_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a\r
+ * value given by the specific class.\r
+ */\r
+ uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current\r
+ * configuration, including direction mask.\r
+ */\r
+ uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (\c EP_TYPE_*)\r
+ * and attributes (\c ENDPOINT_ATTR_*) masks.\r
+ */\r
+ uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size\r
+ * that the endpoint can receive at a time.\r
+ */\r
+ uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or\r
+ * ISOCHRONOUS type.\r
+ */\r
+\r
+ uint8_t bRefresh; /**< Always set to zero for Audio class devices. */\r
+ uint8_t bSynchAddress; /**< Endpoint address to send synchronization information to, if needed (zero otherwise). */\r
+ } ATTR_PACKED USB_Audio_StdDescriptor_StreamEndpoint_Std_t;\r
+\r
+ /** \brief Audio class-specific Extended Endpoint Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific extended endpoint descriptor. This contains extra information\r
+ * on the usage of endpoints used to stream audio in and out of the USB Audio device, and follows an Audio\r
+ * class-specific extended endpoint descriptor. See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_Audio_StdDescriptor_StreamEndpoint_Spc_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * a value from the \ref Audio_CSEndpoint_SubTypes_t enum.\r
+ */\r
+\r
+ uint8_t Attributes; /**< Audio class-specific endpoint attributes, such as \ref AUDIO_EP_FULL_PACKETS_ONLY. */\r
+\r
+ uint8_t LockDelayUnits; /**< Units used for the LockDelay field, see Audio class specification. */\r
+ uint16_t LockDelay; /**< Time required to internally lock endpoint's internal clock recovery circuitry. */\r
+ } ATTR_PACKED USB_Audio_Descriptor_StreamEndpoint_Spc_t;\r
+\r
+ /** \brief Audio class-specific Extended Endpoint Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific extended endpoint descriptor. This contains extra information\r
+ * on the usage of endpoints used to stream audio in and out of the USB Audio device, and follows an Audio\r
+ * class-specific extended endpoint descriptor. See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_Audio_Descriptor_StreamEndpoint_Spc_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+\r
+ uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors,\r
+ * a value from the \ref Audio_CSEndpoint_SubTypes_t enum.\r
+ */\r
+\r
+ uint8_t bmAttributes; /**< Audio class-specific endpoint attributes, such as \ref AUDIO_EP_FULL_PACKETS_ONLY. */\r
+\r
+ uint8_t bLockDelayUnits; /**< Units used for the LockDelay field, see Audio class specification. */\r
+ uint16_t wLockDelay; /**< Time required to internally lock endpoint's internal clock recovery circuitry. */\r
+ } ATTR_PACKED USB_Audio_StdDescriptor_StreamEndpoint_Spc_t;\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common definitions and declarations for the library USB CDC Class driver.\r
+ *\r
+ * Common definitions and declarations for the library USB CDC Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassCDC\r
+ * \defgroup Group_USBClassCDCCommon Common Class Definitions\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB\r
+ * CDC Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _CDC_CLASS_COMMON_H_\r
+#define _CDC_CLASS_COMMON_H_\r
+\r
+ /* Includes: */\r
+ #include "../../Core/StdDescriptors.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_CDC_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Macros: */\r
+ /** \name Virtual Control Line Masks */\r
+ //@{\r
+ /** Mask for the DTR handshake line for use with the \ref CDC_REQ_SetControlLineState class-specific request\r
+ * from the host, to indicate that the DTR line state should be high.\r
+ */\r
+ #define CDC_CONTROL_LINE_OUT_DTR (1 << 0)\r
+\r
+ /** Mask for the RTS handshake line for use with the \ref CDC_REQ_SetControlLineState class-specific request\r
+ * from the host, to indicate that the RTS line state should be high.\r
+ */\r
+ #define CDC_CONTROL_LINE_OUT_RTS (1 << 1)\r
+\r
+ /** Mask for the DCD handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification\r
+ * from the device to the host, to indicate that the DCD line state is currently high.\r
+ */\r
+ #define CDC_CONTROL_LINE_IN_DCD (1 << 0)\r
+\r
+ /** Mask for the DSR handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification\r
+ * from the device to the host, to indicate that the DSR line state is currently high.\r
+ */\r
+ #define CDC_CONTROL_LINE_IN_DSR (1 << 1)\r
+\r
+ /** Mask for the BREAK handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification\r
+ * from the device to the host, to indicate that the BREAK line state is currently high.\r
+ */\r
+ #define CDC_CONTROL_LINE_IN_BREAK (1 << 2)\r
+\r
+ /** Mask for the RING handshake line for use with the \ref CDC_NOTIF_SerialState class-specific notification\r
+ * from the device to the host, to indicate that the RING line state is currently high.\r
+ */\r
+ #define CDC_CONTROL_LINE_IN_RING (1 << 3)\r
+\r
+ /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host,\r
+ * to indicate that a framing error has occurred on the virtual serial port.\r
+ */\r
+ #define CDC_CONTROL_LINE_IN_FRAMEERROR (1 << 4)\r
+\r
+ /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host,\r
+ * to indicate that a parity error has occurred on the virtual serial port.\r
+ */\r
+ #define CDC_CONTROL_LINE_IN_PARITYERROR (1 << 5)\r
+\r
+ /** Mask for use with the \ref CDC_NOTIF_SerialState class-specific notification from the device to the host,\r
+ * to indicate that a data overrun error has occurred on the virtual serial port.\r
+ */\r
+ #define CDC_CONTROL_LINE_IN_OVERRUNERROR (1 << 6)\r
+ //@}\r
+\r
+ /** Macro to define a CDC class-specific functional descriptor. CDC functional descriptors have a\r
+ * uniform structure but variable sized data payloads, thus cannot be represented accurately by\r
+ * a single typedef struct. A macro is used instead so that functional descriptors can be created\r
+ * easily by specifying the size of the payload. This allows \c sizeof() to work correctly.\r
+ *\r
+ * \param[in] DataSize Size in bytes of the CDC functional descriptor's data payload.\r
+ */\r
+ #define CDC_FUNCTIONAL_DESCRIPTOR(DataSize) \\r
+ struct \\r
+ { \\r
+ USB_Descriptor_Header_t Header; \\r
+ uint8_t SubType; \\r
+ uint8_t Data[DataSize]; \\r
+ }\r
+\r
+ /* Enums: */\r
+ /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the CDC\r
+ * device class.\r
+ */\r
+ enum CDC_Descriptor_ClassSubclassProtocol_t\r
+ {\r
+ CDC_CSCP_CDCClass = 0x02, /**< Descriptor Class value indicating that the device or interface\r
+ * belongs to the CDC class.\r
+ */\r
+ CDC_CSCP_NoSpecificSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface\r
+ * belongs to no specific subclass of the CDC class.\r
+ */\r
+ CDC_CSCP_ACMSubclass = 0x02, /**< Descriptor Subclass value indicating that the device or interface\r
+ * belongs to the Abstract Control Model CDC subclass.\r
+ */\r
+ CDC_CSCP_ATCommandProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface\r
+ * belongs to the AT Command protocol of the CDC class.\r
+ */\r
+ CDC_CSCP_NoSpecificProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface\r
+ * belongs to no specific protocol of the CDC class.\r
+ */\r
+ CDC_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device or interface\r
+ * belongs to a vendor-specific protocol of the CDC class.\r
+ */\r
+ CDC_CSCP_CDCDataClass = 0x0A, /**< Descriptor Class value indicating that the device or interface\r
+ * belongs to the CDC Data class.\r
+ */\r
+ CDC_CSCP_NoDataSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface\r
+ * belongs to no specific subclass of the CDC data class.\r
+ */\r
+ CDC_CSCP_NoDataProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface\r
+ * belongs to no specific protocol of the CDC data class.\r
+ */\r
+ };\r
+\r
+ /** Enum for the CDC class specific control requests that can be issued by the USB bus host. */\r
+ enum CDC_ClassRequests_t\r
+ {\r
+ CDC_REQ_SendEncapsulatedCommand = 0x00, /**< CDC class-specific request to send an encapsulated command to the device. */\r
+ CDC_REQ_GetEncapsulatedResponse = 0x01, /**< CDC class-specific request to retrieve an encapsulated command response from the device. */\r
+ CDC_REQ_SetLineEncoding = 0x20, /**< CDC class-specific request to set the current virtual serial port configuration settings. */\r
+ CDC_REQ_GetLineEncoding = 0x21, /**< CDC class-specific request to get the current virtual serial port configuration settings. */\r
+ CDC_REQ_SetControlLineState = 0x22, /**< CDC class-specific request to set the current virtual serial port handshake line states. */\r
+ CDC_REQ_SendBreak = 0x23, /**< CDC class-specific request to send a break to the receiver via the carrier channel. */\r
+ };\r
+\r
+ /** Enum for the CDC class specific notification requests that can be issued by a CDC device to a host. */\r
+ enum CDC_ClassNotifications_t\r
+ {\r
+ CDC_NOTIF_SerialState = 0x20, /**< Notification type constant for a change in the virtual serial port\r
+ * handshake line states, for use with a \ref USB_Request_Header_t\r
+ * notification structure when sent to the host via the CDC notification\r
+ * endpoint.\r
+ */\r
+ };\r
+\r
+ /** Enum for the CDC class specific interface descriptor subtypes. */\r
+ enum CDC_DescriptorSubtypes_t\r
+ {\r
+ CDC_DSUBTYPE_CSInterface_Header = 0x00, /**< CDC class-specific Header functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_CallManagement = 0x01, /**< CDC class-specific Call Management functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_ACM = 0x02, /**< CDC class-specific Abstract Control Model functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_DirectLine = 0x03, /**< CDC class-specific Direct Line functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_TelephoneRinger = 0x04, /**< CDC class-specific Telephone Ringer functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_TelephoneCall = 0x05, /**< CDC class-specific Telephone Call functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_Union = 0x06, /**< CDC class-specific Union functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_CountrySelection = 0x07, /**< CDC class-specific Country Selection functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_TelephoneOpModes = 0x08, /**< CDC class-specific Telephone Operation Modes functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_USBTerminal = 0x09, /**< CDC class-specific USB Terminal functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_NetworkChannel = 0x0A, /**< CDC class-specific Network Channel functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_ProtocolUnit = 0x0B, /**< CDC class-specific Protocol Unit functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_ExtensionUnit = 0x0C, /**< CDC class-specific Extension Unit functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_MultiChannel = 0x0D, /**< CDC class-specific Multi-Channel Management functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_CAPI = 0x0E, /**< CDC class-specific Common ISDN API functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_Ethernet = 0x0F, /**< CDC class-specific Ethernet functional descriptor. */\r
+ CDC_DSUBTYPE_CSInterface_ATM = 0x10, /**< CDC class-specific Asynchronous Transfer Mode functional descriptor. */\r
+ };\r
+\r
+ /** Enum for the possible line encoding formats of a virtual serial port. */\r
+ enum CDC_LineEncodingFormats_t\r
+ {\r
+ CDC_LINEENCODING_OneStopBit = 0, /**< Each frame contains one stop bit. */\r
+ CDC_LINEENCODING_OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits. */\r
+ CDC_LINEENCODING_TwoStopBits = 2, /**< Each frame contains two stop bits. */\r
+ };\r
+\r
+ /** Enum for the possible line encoding parity settings of a virtual serial port. */\r
+ enum CDC_LineEncodingParity_t\r
+ {\r
+ CDC_PARITY_None = 0, /**< No parity bit mode on each frame. */\r
+ CDC_PARITY_Odd = 1, /**< Odd parity bit mode on each frame. */\r
+ CDC_PARITY_Even = 2, /**< Even parity bit mode on each frame. */\r
+ CDC_PARITY_Mark = 3, /**< Mark parity bit mode on each frame. */\r
+ CDC_PARITY_Space = 4, /**< Space parity bit mode on each frame. */\r
+ };\r
+\r
+ /* Type Defines: */\r
+ /** \brief CDC class-specific Functional Header Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device\r
+ * contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration.\r
+ * See the CDC class specification for more details.\r
+ *\r
+ * \see \ref USB_CDC_StdDescriptor_FunctionalHeader_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors,\r
+ * must be \ref CDC_DSUBTYPE_CSInterface_Header.\r
+ */\r
+ uint16_t CDCSpecification; /**< Version number of the CDC specification implemented by the device,\r
+ * encoded in BCD format.\r
+ */\r
+ } ATTR_PACKED USB_CDC_Descriptor_FunctionalHeader_t;\r
+\r
+ /** \brief CDC class-specific Functional Header Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a CDC class-specific functional header descriptor. This indicates to the host that the device\r
+ * contains one or more CDC functional data descriptors, which give the CDC interface's capabilities and configuration.\r
+ * See the CDC class specification for more details.\r
+ *\r
+ * \see \ref USB_CDC_Descriptor_FunctionalHeader_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+ uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors,\r
+ * must be \ref CDC_DSUBTYPE_CSInterface_Header.\r
+ */\r
+ uint16_t bcdCDC; /**< Version number of the CDC specification implemented by the device, encoded in BCD format. */\r
+ } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalHeader_t;\r
+\r
+ /** \brief CDC class-specific Functional ACM Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface\r
+ * supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details.\r
+ *\r
+ * \see \ref USB_CDC_StdDescriptor_FunctionalACM_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors,\r
+ * must be \ref CDC_DSUBTYPE_CSInterface_ACM.\r
+ */\r
+ uint8_t Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. For most devices,\r
+ * this should be set to a fixed value of 0x06 - for other capabilities, refer\r
+ * to the CDC ACM specification.\r
+ */\r
+ } ATTR_PACKED USB_CDC_Descriptor_FunctionalACM_t;\r
+\r
+ /** \brief CDC class-specific Functional ACM Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a CDC class-specific functional ACM descriptor. This indicates to the host that the CDC interface\r
+ * supports the CDC ACM subclass of the CDC specification. See the CDC class specification for more details.\r
+ *\r
+ * \see \ref USB_CDC_Descriptor_FunctionalACM_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+ uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors,\r
+ * must be \ref CDC_DSUBTYPE_CSInterface_ACM.\r
+ */\r
+ uint8_t bmCapabilities; /**< Capabilities of the ACM interface, given as a bit mask. For most devices,\r
+ * this should be set to a fixed value of 0x06 - for other capabilities, refer\r
+ * to the CDC ACM specification.\r
+ */\r
+ } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalACM_t;\r
+\r
+ /** \brief CDC class-specific Functional Union Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific\r
+ * CDC control and data interfaces are related. See the CDC class specification for more details.\r
+ *\r
+ * \see \ref USB_CDC_StdDescriptor_FunctionalUnion_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors,\r
+ * must be \ref CDC_DSUBTYPE_CSInterface_Union.\r
+ */\r
+ uint8_t MasterInterfaceNumber; /**< Interface number of the CDC Control interface. */\r
+ uint8_t SlaveInterfaceNumber; /**< Interface number of the CDC Data interface. */\r
+ } ATTR_PACKED USB_CDC_Descriptor_FunctionalUnion_t;\r
+\r
+ /** \brief CDC class-specific Functional Union Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific\r
+ * CDC control and data interfaces are related. See the CDC class specification for more details.\r
+ *\r
+ * \see \ref USB_CDC_Descriptor_FunctionalUnion_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bFunctionLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+ uint8_t bDescriptorSubType; /**< Sub type value used to distinguish between CDC class-specific descriptors,\r
+ * must be \ref CDC_DSUBTYPE_CSInterface_Union.\r
+ */\r
+ uint8_t bMasterInterface; /**< Interface number of the CDC Control interface. */\r
+ uint8_t bSlaveInterface0; /**< Interface number of the CDC Data interface. */\r
+ } ATTR_PACKED USB_CDC_StdDescriptor_FunctionalUnion_t;\r
+\r
+ /** \brief CDC Virtual Serial Port Line Encoding Settings Structure.\r
+ *\r
+ * Type define for a CDC Line Encoding structure, used to hold the various encoding parameters for a virtual\r
+ * serial port.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t BaudRateBPS; /**< Baud rate of the virtual serial port, in bits per second. */\r
+ uint8_t CharFormat; /**< Character format of the virtual serial port, a value from the\r
+ * \ref CDC_LineEncodingFormats_t enum.\r
+ */\r
+ uint8_t ParityType; /**< Parity setting of the virtual serial port, a value from the\r
+ * \ref CDC_LineEncodingParity_t enum.\r
+ */\r
+ uint8_t DataBits; /**< Bits of data per character of the virtual serial port. */\r
+ } ATTR_PACKED CDC_LineEncoding_t;\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common definitions and declarations for the library USB HID Class driver.\r
+ *\r
+ * Common definitions and declarations for the library USB HID Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassHID\r
+ * \defgroup Group_USBClassHIDCommon Common Class Definitions\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB\r
+ * HID Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _HID_CLASS_COMMON_H_\r
+#define _HID_CLASS_COMMON_H_\r
+\r
+ /* Includes: */\r
+ #include "../../Core/StdDescriptors.h"\r
+ #include "HIDParser.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_HID_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Macros: */\r
+ /** \name Keyboard Standard Report Modifier Masks */\r
+ //@{\r
+ /** Constant for a keyboard report modifier byte, indicating that the keyboard's left control key is currently pressed. */\r
+ #define HID_KEYBOARD_MODIFIER_LEFTCTRL (1 << 0)\r
+\r
+ /** Constant for a keyboard report modifier byte, indicating that the keyboard's left shift key is currently pressed. */\r
+ #define HID_KEYBOARD_MODIFIER_LEFTSHIFT (1 << 1)\r
+\r
+ /** Constant for a keyboard report modifier byte, indicating that the keyboard's left alt key is currently pressed. */\r
+ #define HID_KEYBOARD_MODIFIER_LEFTALT (1 << 2)\r
+\r
+ /** Constant for a keyboard report modifier byte, indicating that the keyboard's left GUI key is currently pressed. */\r
+ #define HID_KEYBOARD_MODIFIER_LEFTGUI (1 << 3)\r
+\r
+ /** Constant for a keyboard report modifier byte, indicating that the keyboard's right control key is currently pressed. */\r
+ #define HID_KEYBOARD_MODIFIER_RIGHTCTRL (1 << 4)\r
+\r
+ /** Constant for a keyboard report modifier byte, indicating that the keyboard's right shift key is currently pressed. */\r
+ #define HID_KEYBOARD_MODIFIER_RIGHTSHIFT (1 << 5)\r
+\r
+ /** Constant for a keyboard report modifier byte, indicating that the keyboard's right alt key is currently pressed. */\r
+ #define HID_KEYBOARD_MODIFIER_RIGHTALT (1 << 6)\r
+\r
+ /** Constant for a keyboard report modifier byte, indicating that the keyboard's right GUI key is currently pressed. */\r
+ #define HID_KEYBOARD_MODIFIER_RIGHTGUI (1 << 7)\r
+ //@}\r
+\r
+ /** \name Keyboard Standard Report LED Masks */\r
+ //@{\r
+ /** Constant for a keyboard output report LED byte, indicating that the host's NUM LOCK mode is currently set. */\r
+ #define HID_KEYBOARD_LED_NUMLOCK (1 << 0)\r
+\r
+ /** Constant for a keyboard output report LED byte, indicating that the host's CAPS LOCK mode is currently set. */\r
+ #define HID_KEYBOARD_LED_CAPSLOCK (1 << 1)\r
+\r
+ /** Constant for a keyboard output report LED byte, indicating that the host's SCROLL LOCK mode is currently set. */\r
+ #define HID_KEYBOARD_LED_SCROLLLOCK (1 << 2)\r
+\r
+ /** Constant for a keyboard output report LED byte, indicating that the host's KATANA mode is currently set. */\r
+ #define HID_KEYBOARD_LED_KATANA (1 << 3)\r
+ //@}\r
+\r
+ /** \name Keyboard Standard Report Key Scan-codes */\r
+ //@{\r
+ #define HID_KEYBOARD_SC_ERROR_ROLLOVER 0x01\r
+ #define HID_KEYBOARD_SC_POST_FAIL 0x02\r
+ #define HID_KEYBOARD_SC_ERROR_UNDEFINED 0x03\r
+ #define HID_KEYBOARD_SC_A 0x04\r
+ #define HID_KEYBOARD_SC_B 0x05\r
+ #define HID_KEYBOARD_SC_C 0x06\r
+ #define HID_KEYBOARD_SC_D 0x07\r
+ #define HID_KEYBOARD_SC_E 0x08\r
+ #define HID_KEYBOARD_SC_F 0x09\r
+ #define HID_KEYBOARD_SC_G 0x0A\r
+ #define HID_KEYBOARD_SC_H 0x0B\r
+ #define HID_KEYBOARD_SC_I 0x0C\r
+ #define HID_KEYBOARD_SC_J 0x0D\r
+ #define HID_KEYBOARD_SC_K 0x0E\r
+ #define HID_KEYBOARD_SC_L 0x0F\r
+ #define HID_KEYBOARD_SC_M 0x10\r
+ #define HID_KEYBOARD_SC_N 0x11\r
+ #define HID_KEYBOARD_SC_O 0x12\r
+ #define HID_KEYBOARD_SC_P 0x13\r
+ #define HID_KEYBOARD_SC_Q 0x14\r
+ #define HID_KEYBOARD_SC_R 0x15\r
+ #define HID_KEYBOARD_SC_S 0x16\r
+ #define HID_KEYBOARD_SC_T 0x17\r
+ #define HID_KEYBOARD_SC_U 0x18\r
+ #define HID_KEYBOARD_SC_V 0x19\r
+ #define HID_KEYBOARD_SC_W 0x1A\r
+ #define HID_KEYBOARD_SC_X 0x1B\r
+ #define HID_KEYBOARD_SC_Y 0x1C\r
+ #define HID_KEYBOARD_SC_Z 0x1D\r
+ #define HID_KEYBOARD_SC_1_AND_EXCLAMATION 0x1E\r
+ #define HID_KEYBOARD_SC_2_AND_AT 0x1F\r
+ #define HID_KEYBOARD_SC_3_AND_HASHMARK 0x20\r
+ #define HID_KEYBOARD_SC_4_AND_DOLLAR 0x21\r
+ #define HID_KEYBOARD_SC_5_AND_PERCENTAGE 0x22\r
+ #define HID_KEYBOARD_SC_6_AND_CARET 0x23\r
+ #define HID_KEYBOARD_SC_7_AND_AND_AMPERSAND 0x24\r
+ #define HID_KEYBOARD_SC_8_AND_ASTERISK 0x25\r
+ #define HID_KEYBOARD_SC_9_AND_OPENING_PARENTHESIS 0x26\r
+ #define HID_KEYBOARD_SC_0_AND_CLOSING_PARENTHESIS 0x27\r
+ #define HID_KEYBOARD_SC_ENTER 0x28\r
+ #define HID_KEYBOARD_SC_ESCAPE 0x29\r
+ #define HID_KEYBOARD_SC_BACKSPACE 0x2A\r
+ #define HID_KEYBOARD_SC_TAB 0x2B\r
+ #define HID_KEYBOARD_SC_SPACE 0x2C\r
+ #define HID_KEYBOARD_SC_MINUS_AND_UNDERSCORE 0x2D\r
+ #define HID_KEYBOARD_SC_EQUAL_AND_PLUS 0x2E\r
+ #define HID_KEYBOARD_SC_OPENING_BRACKET_AND_OPENING_BRACE 0x2F\r
+ #define HID_KEYBOARD_SC_CLOSING_BRACKET_AND_CLOSING_BRACE 0x30\r
+ #define HID_KEYBOARD_SC_BACKSLASH_AND_PIPE 0x31\r
+ #define HID_KEYBOARD_SC_NON_US_HASHMARK_AND_TILDE 0x32\r
+ #define HID_KEYBOARD_SC_SEMICOLON_AND_COLON 0x33\r
+ #define HID_KEYBOARD_SC_APOSTROPHE_AND_QUOTE 0x34\r
+ #define HID_KEYBOARD_SC_GRAVE_ACCENT_AND_TILDE 0x35\r
+ #define HID_KEYBOARD_SC_COMMA_AND_LESS_THAN_SIGN 0x36\r
+ #define HID_KEYBOARD_SC_DOT_AND_GREATER_THAN_SIGN 0x37\r
+ #define HID_KEYBOARD_SC_SLASH_AND_QUESTION_MARK 0x38\r
+ #define HID_KEYBOARD_SC_CAPS_LOCK 0x39\r
+ #define HID_KEYBOARD_SC_F1 0x3A\r
+ #define HID_KEYBOARD_SC_F2 0x3B\r
+ #define HID_KEYBOARD_SC_F3 0x3C\r
+ #define HID_KEYBOARD_SC_F4 0x3D\r
+ #define HID_KEYBOARD_SC_F5 0x3E\r
+ #define HID_KEYBOARD_SC_F6 0x3F\r
+ #define HID_KEYBOARD_SC_F7 0x40\r
+ #define HID_KEYBOARD_SC_F8 0x41\r
+ #define HID_KEYBOARD_SC_F9 0x42\r
+ #define HID_KEYBOARD_SC_F10 0x43\r
+ #define HID_KEYBOARD_SC_F11 0x44\r
+ #define HID_KEYBOARD_SC_F12 0x45\r
+ #define HID_KEYBOARD_SC_PRINT_SCREEN 0x46\r
+ #define HID_KEYBOARD_SC_SCROLL_LOCK 0x47\r
+ #define HID_KEYBOARD_SC_PAUSE 0x48\r
+ #define HID_KEYBOARD_SC_INSERT 0x49\r
+ #define HID_KEYBOARD_SC_HOME 0x4A\r
+ #define HID_KEYBOARD_SC_PAGE_UP 0x4B\r
+ #define HID_KEYBOARD_SC_DELETE 0x4C\r
+ #define HID_KEYBOARD_SC_END 0x4D\r
+ #define HID_KEYBOARD_SC_PAGE_DOWN 0x4E\r
+ #define HID_KEYBOARD_SC_RIGHT_ARROW 0x4F\r
+ #define HID_KEYBOARD_SC_LEFT_ARROW 0x50\r
+ #define HID_KEYBOARD_SC_DOWN_ARROW 0x51\r
+ #define HID_KEYBOARD_SC_UP_ARROW 0x52\r
+ #define HID_KEYBOARD_SC_NUM_LOCK 0x53\r
+ #define HID_KEYBOARD_SC_KEYPAD_SLASH 0x54\r
+ #define HID_KEYBOARD_SC_KEYPAD_ASTERISK 0x55\r
+ #define HID_KEYBOARD_SC_KEYPAD_MINUS 0x56\r
+ #define HID_KEYBOARD_SC_KEYPAD_PLUS 0x57\r
+ #define HID_KEYBOARD_SC_KEYPAD_ENTER 0x58\r
+ #define HID_KEYBOARD_SC_KEYPAD_1_AND_END 0x59\r
+ #define HID_KEYBOARD_SC_KEYPAD_2_AND_DOWN_ARROW 0x5A\r
+ #define HID_KEYBOARD_SC_KEYPAD_3_AND_PAGE_DOWN 0x5B\r
+ #define HID_KEYBOARD_SC_KEYPAD_4_AND_LEFT_ARROW 0x5C\r
+ #define HID_KEYBOARD_SC_KEYPAD_5 0x5D\r
+ #define HID_KEYBOARD_SC_KEYPAD_6_AND_RIGHT_ARROW 0x5E\r
+ #define HID_KEYBOARD_SC_KEYPAD_7_AND_HOME 0x5F\r
+ #define HID_KEYBOARD_SC_KEYPAD_8_AND_UP_ARROW 0x60\r
+ #define HID_KEYBOARD_SC_KEYPAD_9_AND_PAGE_UP 0x61\r
+ #define HID_KEYBOARD_SC_KEYPAD_0_AND_INSERT 0x62\r
+ #define HID_KEYBOARD_SC_KEYPAD_DOT_AND_DELETE 0x63\r
+ #define HID_KEYBOARD_SC_NON_US_BACKSLASH_AND_PIPE 0x64\r
+ #define HID_KEYBOARD_SC_POWER 0x66\r
+ #define HID_KEYBOARD_SC_EQUAL_SIGN 0x67\r
+ #define HID_KEYBOARD_SC_F13 0x68\r
+ #define HID_KEYBOARD_SC_F14 0x69\r
+ #define HID_KEYBOARD_SC_F15 0x6A\r
+ #define HID_KEYBOARD_SC_F16 0x6B\r
+ #define HID_KEYBOARD_SC_F17 0x6C\r
+ #define HID_KEYBOARD_SC_F18 0x6D\r
+ #define HID_KEYBOARD_SC_F19 0x6E\r
+ #define HID_KEYBOARD_SC_F20 0x6F\r
+ #define HID_KEYBOARD_SC_F21 0x70\r
+ #define HID_KEYBOARD_SC_F22 0x71\r
+ #define HID_KEYBOARD_SC_F23 0x72\r
+ #define HID_KEYBOARD_SC_F24 0x73\r
+ #define HID_KEYBOARD_SC_EXECUTE 0x74\r
+ #define HID_KEYBOARD_SC_HELP 0x75\r
+ #define HID_KEYBOARD_SC_MANU 0x76\r
+ #define HID_KEYBOARD_SC_SELECT 0x77\r
+ #define HID_KEYBOARD_SC_STOP 0x78\r
+ #define HID_KEYBOARD_SC_AGAIN 0x79\r
+ #define HID_KEYBOARD_SC_UNDO 0x7A\r
+ #define HID_KEYBOARD_SC_CUT 0x7B\r
+ #define HID_KEYBOARD_SC_COPY 0x7C\r
+ #define HID_KEYBOARD_SC_PASTE 0x7D\r
+ #define HID_KEYBOARD_SC_FIND 0x7E\r
+ #define HID_KEYBOARD_SC_MUTE 0x7F\r
+ #define HID_KEYBOARD_SC_VOLUME_UP 0x80\r
+ #define HID_KEYBOARD_SC_VOLUME_DOWN 0x81\r
+ #define HID_KEYBOARD_SC_LOCKING_CAPS_LOCK 0x82\r
+ #define HID_KEYBOARD_SC_LOCKING_NUM_LOCK 0x83\r
+ #define HID_KEYBOARD_SC_LOCKING_SCROLL_LOCK 0x84\r
+ #define HID_KEYBOARD_SC_KEYPAD_COMMA 0x85\r
+ #define HID_KEYBOARD_SC_KEYPAD_EQUAL_SIGN 0x86\r
+ #define HID_KEYBOARD_SC_INTERNATIONAL1 0x87\r
+ #define HID_KEYBOARD_SC_INTERNATIONAL2 0x88\r
+ #define HID_KEYBOARD_SC_INTERNATIONAL3 0x89\r
+ #define HID_KEYBOARD_SC_INTERNATIONAL4 0x8A\r
+ #define HID_KEYBOARD_SC_INTERNATIONAL5 0x8B\r
+ #define HID_KEYBOARD_SC_INTERNATIONAL6 0x8C\r
+ #define HID_KEYBOARD_SC_INTERNATIONAL7 0x8D\r
+ #define HID_KEYBOARD_SC_INTERNATIONAL8 0x8E\r
+ #define HID_KEYBOARD_SC_INTERNATIONAL9 0x8F\r
+ #define HID_KEYBOARD_SC_LANG1 0x90\r
+ #define HID_KEYBOARD_SC_LANG2 0x91\r
+ #define HID_KEYBOARD_SC_LANG3 0x92\r
+ #define HID_KEYBOARD_SC_LANG4 0x93\r
+ #define HID_KEYBOARD_SC_LANG5 0x94\r
+ #define HID_KEYBOARD_SC_LANG6 0x95\r
+ #define HID_KEYBOARD_SC_LANG7 0x96\r
+ #define HID_KEYBOARD_SC_LANG8 0x97\r
+ #define HID_KEYBOARD_SC_LANG9 0x98\r
+ #define HID_KEYBOARD_SC_ALTERNATE_ERASE 0x99\r
+ #define HID_KEYBOARD_SC_SISREQ 0x9A\r
+ #define HID_KEYBOARD_SC_CANCEL 0x9B\r
+ #define HID_KEYBOARD_SC_CLEAR 0x9C\r
+ #define HID_KEYBOARD_SC_PRIOR 0x9D\r
+ #define HID_KEYBOARD_SC_RETURN 0x9E\r
+ #define HID_KEYBOARD_SC_SEPARATOR 0x9F\r
+ #define HID_KEYBOARD_SC_OUT 0xA0\r
+ #define HID_KEYBOARD_SC_OPER 0xA1\r
+ #define HID_KEYBOARD_SC_CLEAR_AND_AGAIN 0xA2\r
+ #define HID_KEYBOARD_SC_CRSEL_ANDPROPS 0xA3\r
+ #define HID_KEYBOARD_SC_EXSEL 0xA4\r
+ #define HID_KEYBOARD_SC_KEYPAD_00 0xB0\r
+ #define HID_KEYBOARD_SC_KEYPAD_000 0xB1\r
+ #define HID_KEYBOARD_SC_THOUSANDS_SEPARATOR 0xB2\r
+ #define HID_KEYBOARD_SC_DECIMAL_SEPARATOR 0xB3\r
+ #define HID_KEYBOARD_SC_CURRENCY_UNIT 0xB4\r
+ #define HID_KEYBOARD_SC_CURRENCY_SUB_UNIT 0xB5\r
+ #define HID_KEYBOARD_SC_KEYPAD_OPENING_PARENTHESIS 0xB6\r
+ #define HID_KEYBOARD_SC_KEYPAD_CLOSING_PARENTHESIS 0xB7\r
+ #define HID_KEYBOARD_SC_KEYPAD_OPENING_BRACE 0xB8\r
+ #define HID_KEYBOARD_SC_KEYPAD_CLOSING_BRACE 0xB9\r
+ #define HID_KEYBOARD_SC_KEYPAD_TAB 0xBA\r
+ #define HID_KEYBOARD_SC_KEYPAD_BACKSPACE 0xBB\r
+ #define HID_KEYBOARD_SC_KEYPAD_A 0xBC\r
+ #define HID_KEYBOARD_SC_KEYPAD_B 0xBD\r
+ #define HID_KEYBOARD_SC_KEYPAD_C 0xBE\r
+ #define HID_KEYBOARD_SC_KEYPAD_D 0xBF\r
+ #define HID_KEYBOARD_SC_KEYPAD_E 0xC0\r
+ #define HID_KEYBOARD_SC_KEYPAD_F 0xC1\r
+ #define HID_KEYBOARD_SC_KEYPAD_XOR 0xC2\r
+ #define HID_KEYBOARD_SC_KEYPAD_CARET 0xC3\r
+ #define HID_KEYBOARD_SC_KEYPAD_PERCENTAGE 0xC4\r
+ #define HID_KEYBOARD_SC_KEYPAD_LESS_THAN_SIGN 0xC5\r
+ #define HID_KEYBOARD_SC_KEYPAD_GREATER_THAN_SIGN 0xC6\r
+ #define HID_KEYBOARD_SC_KEYPAD_AMP 0xC7\r
+ #define HID_KEYBOARD_SC_KEYPAD_AMP_AMP 0xC8\r
+ #define HID_KEYBOARD_SC_KEYPAD_PIPE 0xC9\r
+ #define HID_KEYBOARD_SC_KEYPAD_PIPE_PIPE 0xCA\r
+ #define HID_KEYBOARD_SC_KEYPAD_COLON 0xCB\r
+ #define HID_KEYBOARD_SC_KEYPAD_HASHMARK 0xCC\r
+ #define HID_KEYBOARD_SC_KEYPAD_SPACE 0xCD\r
+ #define HID_KEYBOARD_SC_KEYPAD_AT 0xCE\r
+ #define HID_KEYBOARD_SC_KEYPAD_EXCLAMATION_SIGN 0xCF\r
+ #define HID_KEYBOARD_SC_KEYPAD_MEMORY_STORE 0xD0\r
+ #define HID_KEYBOARD_SC_KEYPAD_MEMORY_RECALL 0xD1\r
+ #define HID_KEYBOARD_SC_KEYPAD_MEMORY_CLEAR 0xD2\r
+ #define HID_KEYBOARD_SC_KEYPAD_MEMORY_ADD 0xD3\r
+ #define HID_KEYBOARD_SC_KEYPAD_MEMORY_SUBTRACT 0xD4\r
+ #define HID_KEYBOARD_SC_KEYPAD_MEMORY_MULTIPLY 0xD5\r
+ #define HID_KEYBOARD_SC_KEYPAD_MEMORY_DIVIDE 0xD6\r
+ #define HID_KEYBOARD_SC_KEYPAD_PLUS_AND_MINUS 0xD7\r
+ #define HID_KEYBOARD_SC_KEYPAD_CLEAR 0xD8\r
+ #define HID_KEYBOARD_SC_KEYPAD_CLEAR_ENTRY 0xD9\r
+ #define HID_KEYBOARD_SC_KEYPAD_BINARY 0xDA\r
+ #define HID_KEYBOARD_SC_KEYPAD_OCTAL 0xDB\r
+ #define HID_KEYBOARD_SC_KEYPAD_DECIMAL 0xDC\r
+ #define HID_KEYBOARD_SC_KEYPAD_HEXADECIMAL 0xDD\r
+ #define HID_KEYBOARD_SC_LEFT_CONTROL 0xE0\r
+ #define HID_KEYBOARD_SC_LEFT_SHIFT 0xE1\r
+ #define HID_KEYBOARD_SC_LEFT_ALT 0xE2\r
+ #define HID_KEYBOARD_SC_LEFT_GUI 0xE3\r
+ #define HID_KEYBOARD_SC_RIGHT_CONTROL 0xE4\r
+ #define HID_KEYBOARD_SC_RIGHT_SHIFT 0xE5\r
+ #define HID_KEYBOARD_SC_RIGHT_ALT 0xE6\r
+ #define HID_KEYBOARD_SC_RIGHT_GUI 0xE7\r
+ //@}\r
+\r
+ /** \name Common HID Device Report Descriptors */\r
+ //@{\r
+ /** \hideinitializer\r
+ * A list of HID report item array elements that describe a typical HID USB Joystick. The resulting report\r
+ * descriptor is structured according to the following layout:\r
+ *\r
+ * \code\r
+ * struct\r
+ * {\r
+ * intA_t X; // Signed X axis value\r
+ * intA_t Y; // Signed Y axis value\r
+ * intA_t Z; // Signed Z axis value\r
+ * uintB_t Buttons; // Pressed buttons bitmask\r
+ * } Joystick_Report;\r
+ * \endcode\r
+ *\r
+ * Where \c uintA_t is a type large enough to hold the ranges of the signed \c MinAxisVal and \c MaxAxisVal values,\r
+ * and \c intB_t is a type large enough to hold one bit per button.\r
+ *\r
+ * \param[in] MinAxisVal Minimum logical axis value (16-bit).\r
+ * \param[in] MaxAxisVal Maximum logical axis value (16-bit).\r
+ * \param[in] MinPhysicalVal Minimum physical axis value, for movement resolution calculations (16-bit).\r
+ * \param[in] MaxPhysicalVal Maximum physical axis value, for movement resolution calculations (16-bit).\r
+ * \param[in] Buttons Total number of buttons in the device (8-bit).\r
+ */\r
+ #define HID_DESCRIPTOR_JOYSTICK(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons) \\r
+ HID_RI_USAGE_PAGE(8, 0x01), \\r
+ HID_RI_USAGE(8, 0x04), \\r
+ HID_RI_COLLECTION(8, 0x01), \\r
+ HID_RI_USAGE(8, 0x01), \\r
+ HID_RI_COLLECTION(8, 0x00), \\r
+ HID_RI_USAGE(8, 0x30), \\r
+ HID_RI_USAGE(8, 0x31), \\r
+ HID_RI_USAGE(8, 0x32), \\r
+ HID_RI_LOGICAL_MINIMUM(16, MinAxisVal), \\r
+ HID_RI_LOGICAL_MAXIMUM(16, MaxAxisVal), \\r
+ HID_RI_PHYSICAL_MINIMUM(16, MinPhysicalVal), \\r
+ HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \\r
+ HID_RI_REPORT_COUNT(8, 3), \\r
+ HID_RI_REPORT_SIZE(8, ((((MinAxisVal >= -0xFF) && (MaxAxisVal <= 0xFF)) ? 8 : 16))), \\r
+ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \\r
+ HID_RI_END_COLLECTION(0), \\r
+ HID_RI_USAGE_PAGE(8, 0x09), \\r
+ HID_RI_USAGE_MINIMUM(8, 0x01), \\r
+ HID_RI_USAGE_MAXIMUM(8, Buttons), \\r
+ HID_RI_LOGICAL_MINIMUM(8, 0x00), \\r
+ HID_RI_LOGICAL_MAXIMUM(8, 0x01), \\r
+ HID_RI_REPORT_SIZE(8, 0x01), \\r
+ HID_RI_REPORT_COUNT(8, Buttons), \\r
+ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \\r
+ HID_RI_REPORT_SIZE(8, (8 - (Buttons % 8))), \\r
+ HID_RI_REPORT_COUNT(8, 0x01), \\r
+ HID_RI_INPUT(8, HID_IOF_CONSTANT), \\r
+ HID_RI_END_COLLECTION(0)\r
+\r
+ /** \hideinitializer\r
+ * A list of HID report item array elements that describe a typical HID USB keyboard. The resulting report descriptor\r
+ * is compatible with \ref USB_KeyboardReport_Data_t when \c MaxKeys is equal to 6. For other values, the report will\r
+ * be structured according to the following layout:\r
+ *\r
+ * \code\r
+ * struct\r
+ * {\r
+ * uint8_t Modifier; // Keyboard modifier byte indicating pressed modifier keys (\c HID_KEYBOARD_MODIFER_* masks)\r
+ * uint8_t Reserved; // Reserved for OEM use, always set to 0.\r
+ * uint8_t KeyCode[MaxKeys]; // Length determined by the number of keys that can be reported\r
+ * } Keyboard_Report;\r
+ * \endcode\r
+ *\r
+ * \param[in] MaxKeys Number of simultaneous keys that can be reported at the one time (8-bit).\r
+ */\r
+ #define HID_DESCRIPTOR_KEYBOARD(MaxKeys) \\r
+ HID_RI_USAGE_PAGE(8, 0x01), \\r
+ HID_RI_USAGE(8, 0x06), \\r
+ HID_RI_COLLECTION(8, 0x01), \\r
+ HID_RI_USAGE_PAGE(8, 0x07), \\r
+ HID_RI_USAGE_MINIMUM(8, 0xE0), \\r
+ HID_RI_USAGE_MAXIMUM(8, 0xE7), \\r
+ HID_RI_LOGICAL_MINIMUM(8, 0x00), \\r
+ HID_RI_LOGICAL_MAXIMUM(8, 0x01), \\r
+ HID_RI_REPORT_SIZE(8, 0x01), \\r
+ HID_RI_REPORT_COUNT(8, 0x08), \\r
+ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \\r
+ HID_RI_REPORT_COUNT(8, 0x01), \\r
+ HID_RI_REPORT_SIZE(8, 0x08), \\r
+ HID_RI_INPUT(8, HID_IOF_CONSTANT), \\r
+ HID_RI_USAGE_PAGE(8, 0x08), \\r
+ HID_RI_USAGE_MINIMUM(8, 0x01), \\r
+ HID_RI_USAGE_MAXIMUM(8, 0x05), \\r
+ HID_RI_REPORT_COUNT(8, 0x05), \\r
+ HID_RI_REPORT_SIZE(8, 0x01), \\r
+ HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \\r
+ HID_RI_REPORT_COUNT(8, 0x01), \\r
+ HID_RI_REPORT_SIZE(8, 0x03), \\r
+ HID_RI_OUTPUT(8, HID_IOF_CONSTANT), \\r
+ HID_RI_LOGICAL_MINIMUM(8, 0x00), \\r
+ HID_RI_LOGICAL_MAXIMUM(8, 0x65), \\r
+ HID_RI_USAGE_PAGE(8, 0x07), \\r
+ HID_RI_USAGE_MINIMUM(8, 0x00), \\r
+ HID_RI_USAGE_MAXIMUM(8, 0x65), \\r
+ HID_RI_REPORT_COUNT(8, MaxKeys), \\r
+ HID_RI_REPORT_SIZE(8, 0x08), \\r
+ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), \\r
+ HID_RI_END_COLLECTION(0)\r
+\r
+ /** \hideinitializer\r
+ * A list of HID report item array elements that describe a typical HID USB mouse. The resulting report descriptor\r
+ * is compatible with \ref USB_MouseReport_Data_t if the \c MinAxisVal and \c MaxAxisVal values fit within a \c int8_t range\r
+ * and the number of Buttons is less than 8. For other values, the report is structured according to the following layout:\r
+ *\r
+ * \code\r
+ * struct\r
+ * {\r
+ * uintA_t Buttons; // Pressed buttons bitmask\r
+ * intB_t X; // X axis value\r
+ * intB_t Y; // Y axis value\r
+ * } Mouse_Report;\r
+ * \endcode\r
+ *\r
+ * Where \c intA_t is a type large enough to hold one bit per button, and \c intB_t is a type large enough to hold the\r
+ * ranges of the signed \c MinAxisVal and \c MaxAxisVal values.\r
+ *\r
+ * \param[in] MinAxisVal Minimum X/Y logical axis value (16-bit).\r
+ * \param[in] MaxAxisVal Maximum X/Y logical axis value (16-bit).\r
+ * \param[in] MinPhysicalVal Minimum X/Y physical axis value, for movement resolution calculations (16-bit).\r
+ * \param[in] MaxPhysicalVal Maximum X/Y physical axis value, for movement resolution calculations (16-bit).\r
+ * \param[in] Buttons Total number of buttons in the device (8-bit).\r
+ * \param[in] AbsoluteCoords Boolean \c true to use absolute X/Y coordinates (e.g. touchscreen).\r
+ */\r
+ #define HID_DESCRIPTOR_MOUSE(MinAxisVal, MaxAxisVal, MinPhysicalVal, MaxPhysicalVal, Buttons, AbsoluteCoords) \\r
+ HID_RI_USAGE_PAGE(8, 0x01), \\r
+ HID_RI_USAGE(8, 0x02), \\r
+ HID_RI_COLLECTION(8, 0x01), \\r
+ HID_RI_USAGE(8, 0x01), \\r
+ HID_RI_COLLECTION(8, 0x00), \\r
+ HID_RI_USAGE_PAGE(8, 0x09), \\r
+ HID_RI_USAGE_MINIMUM(8, 0x01), \\r
+ HID_RI_USAGE_MAXIMUM(8, Buttons), \\r
+ HID_RI_LOGICAL_MINIMUM(8, 0x00), \\r
+ HID_RI_LOGICAL_MAXIMUM(8, 0x01), \\r
+ HID_RI_REPORT_COUNT(8, Buttons), \\r
+ HID_RI_REPORT_SIZE(8, 0x01), \\r
+ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \\r
+ HID_RI_REPORT_COUNT(8, 0x01), \\r
+ HID_RI_REPORT_SIZE(8, (8 - (Buttons % 8))), \\r
+ HID_RI_INPUT(8, HID_IOF_CONSTANT), \\r
+ HID_RI_USAGE_PAGE(8, 0x01), \\r
+ HID_RI_USAGE(8, 0x30), \\r
+ HID_RI_USAGE(8, 0x31), \\r
+ HID_RI_LOGICAL_MINIMUM(16, MinAxisVal), \\r
+ HID_RI_LOGICAL_MAXIMUM(16, MaxAxisVal), \\r
+ HID_RI_PHYSICAL_MINIMUM(16, MinPhysicalVal), \\r
+ HID_RI_PHYSICAL_MAXIMUM(16, MaxPhysicalVal), \\r
+ HID_RI_REPORT_COUNT(8, 0x02), \\r
+ HID_RI_REPORT_SIZE(8, ((((MinAxisVal >= -0xFF) && (MaxAxisVal <= 0xFF)) ? 8 : 16))), \\r
+ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | (AbsoluteCoords ? HID_IOF_ABSOLUTE : HID_IOF_RELATIVE)), \\r
+ HID_RI_END_COLLECTION(0), \\r
+ HID_RI_END_COLLECTION(0)\r
+\r
+ /** \hideinitializer\r
+ * A list of HID report item array elements that describe a typical Vendor Defined byte array HID report descriptor,\r
+ * used for transporting arbitrary data between the USB host and device via HID reports. The resulting report should be\r
+ * a \c uint8_t byte array of the specified length in both Device to Host (IN) and Host to Device (OUT) directions.\r
+ *\r
+ * \param[in] VendorPageNum Vendor Defined HID Usage Page index, ranging from 0x00 to 0xFF.\r
+ * \param[in] CollectionUsage Vendor Usage for the encompassing report IN and OUT collection, ranging from 0x00 to 0xFF.\r
+ * \param[in] DataINUsage Vendor Usage for the IN report data, ranging from 0x00 to 0xFF.\r
+ * \param[in] DataOUTUsage Vendor Usage for the OUT report data, ranging from 0x00 to 0xFF.\r
+ * \param[in] NumBytes Length of the data IN and OUT reports.\r
+ */\r
+ #define HID_DESCRIPTOR_VENDOR(VendorPageNum, CollectionUsage, DataINUsage, DataOUTUsage, NumBytes) \\r
+ HID_RI_USAGE_PAGE(16, (0xFF00 | VendorPageNum)), \\r
+ HID_RI_USAGE(8, CollectionUsage), \\r
+ HID_RI_COLLECTION(8, 0x01), \\r
+ HID_RI_USAGE(8, DataINUsage), \\r
+ HID_RI_LOGICAL_MINIMUM(8, 0x00), \\r
+ HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \\r
+ HID_RI_REPORT_SIZE(8, 0x08), \\r
+ HID_RI_REPORT_COUNT(8, NumBytes), \\r
+ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), \\r
+ HID_RI_USAGE(8, DataOUTUsage), \\r
+ HID_RI_LOGICAL_MINIMUM(8, 0x00), \\r
+ HID_RI_LOGICAL_MAXIMUM(8, 0xFF), \\r
+ HID_RI_REPORT_SIZE(8, 0x08), \\r
+ HID_RI_REPORT_COUNT(8, NumBytes), \\r
+ HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), \\r
+ HID_RI_END_COLLECTION(0)\r
+ //@}\r
+\r
+ /* Type Defines: */\r
+ /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the HID\r
+ * device class.\r
+ */\r
+ enum HID_Descriptor_ClassSubclassProtocol_t\r
+ {\r
+ HID_CSCP_HIDClass = 0x03, /**< Descriptor Class value indicating that the device or interface\r
+ * belongs to the HID class.\r
+ */\r
+ HID_CSCP_NonBootSubclass = 0x00, /**< Descriptor Subclass value indicating that the device or interface\r
+ * does not implement a HID boot protocol.\r
+ */\r
+ HID_CSCP_BootSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or interface\r
+ * implements a HID boot protocol.\r
+ */\r
+ HID_CSCP_NonBootProtocol = 0x00, /**< Descriptor Protocol value indicating that the device or interface\r
+ * does not belong to a HID boot protocol.\r
+ */\r
+ HID_CSCP_KeyboardBootProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface\r
+ * belongs to the Keyboard HID boot protocol.\r
+ */\r
+ HID_CSCP_MouseBootProtocol = 0x02, /**< Descriptor Protocol value indicating that the device or interface\r
+ * belongs to the Mouse HID boot protocol.\r
+ */\r
+ };\r
+\r
+ /** Enum for the HID class specific control requests that can be issued by the USB bus host. */\r
+ enum HID_ClassRequests_t\r
+ {\r
+ HID_REQ_GetReport = 0x01, /**< HID class-specific Request to get the current HID report from the device. */\r
+ HID_REQ_GetIdle = 0x02, /**< HID class-specific Request to get the current device idle count. */\r
+ HID_REQ_GetProtocol = 0x03, /**< HID class-specific Request to get the current HID report protocol mode. */\r
+ HID_REQ_SetReport = 0x09, /**< HID class-specific Request to set the current HID report to the device. */\r
+ HID_REQ_SetIdle = 0x0A, /**< HID class-specific Request to set the device's idle count. */\r
+ HID_REQ_SetProtocol = 0x0B, /**< HID class-specific Request to set the current HID report protocol mode. */\r
+ };\r
+\r
+ /** Enum for the HID class specific descriptor types. */\r
+ enum HID_DescriptorTypes_t\r
+ {\r
+ HID_DTYPE_HID = 0x21, /**< Descriptor header type value, to indicate a HID class HID descriptor. */\r
+ HID_DTYPE_Report = 0x22, /**< Descriptor header type value, to indicate a HID class HID report descriptor. */\r
+ };\r
+\r
+ /** Enum for the different types of HID reports. */\r
+ enum HID_ReportItemTypes_t\r
+ {\r
+ HID_REPORT_ITEM_In = 0, /**< Indicates that the item is an IN report type. */\r
+ HID_REPORT_ITEM_Out = 1, /**< Indicates that the item is an OUT report type. */\r
+ HID_REPORT_ITEM_Feature = 2, /**< Indicates that the item is a FEATURE report type. */\r
+ };\r
+\r
+ /** \brief HID class-specific HID Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID\r
+ * specification for details on the structure elements.\r
+ *\r
+ * \see \ref USB_HID_StdDescriptor_HID_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+\r
+ uint16_t HIDSpec; /**< BCD encoded version that the HID descriptor and device complies to. */\r
+ uint8_t CountryCode; /**< Country code of the localized device, or zero if universal. */\r
+\r
+ uint8_t TotalReportDescriptors; /**< Total number of HID report descriptors for the interface. */\r
+\r
+ uint8_t HIDReportType; /**< Type of HID report, set to \ref HID_DTYPE_Report. */\r
+ uint16_t HIDReportLength; /**< Length of the associated HID report descriptor, in bytes. */\r
+ } ATTR_PACKED USB_HID_Descriptor_HID_t;\r
+\r
+ /** \brief HID class-specific HID Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for the HID class-specific HID descriptor, to describe the HID device's specifications. Refer to the HID\r
+ * specification for details on the structure elements.\r
+ *\r
+ * \see \ref USB_HID_Descriptor_HID_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+\r
+ uint16_t bcdHID; /**< BCD encoded version that the HID descriptor and device complies to. */\r
+ uint8_t bCountryCode; /**< Country code of the localized device, or zero if universal. */\r
+\r
+ uint8_t bNumDescriptors; /**< Total number of HID report descriptors for the interface. */\r
+\r
+ uint8_t bDescriptorType2; /**< Type of HID report, set to \ref HID_DTYPE_Report. */\r
+ uint16_t wDescriptorLength; /**< Length of the associated HID report descriptor, in bytes. */\r
+ } ATTR_PACKED USB_HID_StdDescriptor_HID_t;\r
+\r
+ /** \brief Standard HID Boot Protocol Mouse Report.\r
+ *\r
+ * Type define for a standard Boot Protocol Mouse report\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t Button; /**< Button mask for currently pressed buttons in the mouse. */\r
+ int8_t X; /**< Current delta X movement of the mouse. */\r
+ int8_t Y; /**< Current delta Y movement on the mouse. */\r
+ } ATTR_PACKED USB_MouseReport_Data_t;\r
+\r
+ /** \brief Standard HID Boot Protocol Keyboard Report.\r
+ *\r
+ * Type define for a standard Boot Protocol Keyboard report\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t Modifier; /**< Keyboard modifier byte, indicating pressed modifier keys (a combination of\r
+ * \c HID_KEYBOARD_MODIFER_* masks).\r
+ */\r
+ uint8_t Reserved; /**< Reserved for OEM use, always set to 0. */\r
+ uint8_t KeyCode[6]; /**< Key codes of the currently pressed keys. */\r
+ } ATTR_PACKED USB_KeyboardReport_Data_t;\r
+\r
+ /** Type define for the data type used to store HID report descriptor elements. */\r
+ typedef uint8_t USB_Descriptor_HIDReport_Datatype_t;\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#define __INCLUDE_FROM_HID_DRIVER\r
+#include "HIDParser.h"\r
+\r
+uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,\r
+ uint16_t ReportSize,\r
+ HID_ReportInfo_t* const ParserData)\r
+{\r
+ HID_StateTable_t StateTable[HID_STATETABLE_STACK_DEPTH];\r
+ HID_StateTable_t* CurrStateTable = &StateTable[0];\r
+ HID_CollectionPath_t* CurrCollectionPath = NULL;\r
+ HID_ReportSizeInfo_t* CurrReportIDInfo = &ParserData->ReportIDSizes[0];\r
+ uint16_t UsageList[HID_USAGE_STACK_DEPTH];\r
+ uint8_t UsageListSize = 0;\r
+ HID_MinMax_t UsageMinMax = {0, 0};\r
+\r
+ memset(ParserData, 0x00, sizeof(HID_ReportInfo_t));\r
+ memset(CurrStateTable, 0x00, sizeof(HID_StateTable_t));\r
+ memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t));\r
+\r
+ ParserData->TotalDeviceReports = 1;\r
+\r
+ while (ReportSize)\r
+ {\r
+ uint8_t HIDReportItem = *ReportData;\r
+ uint32_t ReportItemData = 0;\r
+\r
+ ReportData++;\r
+ ReportSize--;\r
+\r
+ switch (HIDReportItem & HID_RI_DATA_SIZE_MASK)\r
+ {\r
+ case HID_RI_DATA_BITS_32:\r
+ ReportItemData = (((uint32_t)ReportData[3] << 24) | ((uint32_t)ReportData[2] << 16) |\r
+ ((uint16_t)ReportData[1] << 8) | ReportData[0]);\r
+ ReportSize -= 4;\r
+ ReportData += 4;\r
+ break;\r
+ case HID_RI_DATA_BITS_16:\r
+ ReportItemData = (((uint16_t)ReportData[1] << 8) | (ReportData[0]));\r
+ ReportSize -= 2;\r
+ ReportData += 2;\r
+ break;\r
+ case HID_RI_DATA_BITS_8:\r
+ ReportItemData = ReportData[0];\r
+ ReportSize -= 1;\r
+ ReportData += 1;\r
+ break;\r
+ }\r
+\r
+ switch (HIDReportItem & (HID_RI_TYPE_MASK | HID_RI_TAG_MASK))\r
+ {\r
+ case HID_RI_PUSH(0):\r
+ if (CurrStateTable == &StateTable[HID_STATETABLE_STACK_DEPTH - 1])\r
+ return HID_PARSE_HIDStackOverflow;\r
+\r
+ memcpy((CurrStateTable + 1),\r
+ CurrStateTable,\r
+ sizeof(HID_ReportItem_t));\r
+\r
+ CurrStateTable++;\r
+ break;\r
+ case HID_RI_POP(0):\r
+ if (CurrStateTable == &StateTable[0])\r
+ return HID_PARSE_HIDStackUnderflow;\r
+\r
+ CurrStateTable--;\r
+ break;\r
+ case HID_RI_USAGE_PAGE(0):\r
+ if ((HIDReportItem & HID_RI_DATA_SIZE_MASK) == HID_RI_DATA_BITS_32)\r
+ CurrStateTable->Attributes.Usage.Page = (ReportItemData >> 16);\r
+\r
+ CurrStateTable->Attributes.Usage.Page = ReportItemData;\r
+ break;\r
+ case HID_RI_LOGICAL_MINIMUM(0):\r
+ CurrStateTable->Attributes.Logical.Minimum = ReportItemData;\r
+ break;\r
+ case HID_RI_LOGICAL_MAXIMUM(0):\r
+ CurrStateTable->Attributes.Logical.Maximum = ReportItemData;\r
+ break;\r
+ case HID_RI_PHYSICAL_MINIMUM(0):\r
+ CurrStateTable->Attributes.Physical.Minimum = ReportItemData;\r
+ break;\r
+ case HID_RI_PHYSICAL_MAXIMUM(0):\r
+ CurrStateTable->Attributes.Physical.Maximum = ReportItemData;\r
+ break;\r
+ case HID_RI_UNIT_EXPONENT(0):\r
+ CurrStateTable->Attributes.Unit.Exponent = ReportItemData;\r
+ break;\r
+ case HID_RI_UNIT(0):\r
+ CurrStateTable->Attributes.Unit.Type = ReportItemData;\r
+ break;\r
+ case HID_RI_REPORT_SIZE(0):\r
+ CurrStateTable->Attributes.BitSize = ReportItemData;\r
+ break;\r
+ case HID_RI_REPORT_COUNT(0):\r
+ CurrStateTable->ReportCount = ReportItemData;\r
+ break;\r
+ case HID_RI_REPORT_ID(0):\r
+ CurrStateTable->ReportID = ReportItemData;\r
+\r
+ if (ParserData->UsingReportIDs)\r
+ {\r
+ CurrReportIDInfo = NULL;\r
+\r
+ for (uint8_t i = 0; i < ParserData->TotalDeviceReports; i++)\r
+ {\r
+ if (ParserData->ReportIDSizes[i].ReportID == CurrStateTable->ReportID)\r
+ {\r
+ CurrReportIDInfo = &ParserData->ReportIDSizes[i];\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (CurrReportIDInfo == NULL)\r
+ {\r
+ if (ParserData->TotalDeviceReports == HID_MAX_REPORT_IDS)\r
+ return HID_PARSE_InsufficientReportIDItems;\r
+\r
+ CurrReportIDInfo = &ParserData->ReportIDSizes[ParserData->TotalDeviceReports++];\r
+ memset(CurrReportIDInfo, 0x00, sizeof(HID_ReportSizeInfo_t));\r
+ }\r
+ }\r
+\r
+ ParserData->UsingReportIDs = true;\r
+\r
+ CurrReportIDInfo->ReportID = CurrStateTable->ReportID;\r
+ break;\r
+ case HID_RI_USAGE(0):\r
+ if (UsageListSize == HID_USAGE_STACK_DEPTH)\r
+ return HID_PARSE_UsageListOverflow;\r
+\r
+ UsageList[UsageListSize++] = ReportItemData;\r
+ break;\r
+ case HID_RI_USAGE_MINIMUM(0):\r
+ UsageMinMax.Minimum = ReportItemData;\r
+ break;\r
+ case HID_RI_USAGE_MAXIMUM(0):\r
+ UsageMinMax.Maximum = ReportItemData;\r
+ break;\r
+ case HID_RI_COLLECTION(0):\r
+ if (CurrCollectionPath == NULL)\r
+ {\r
+ CurrCollectionPath = &ParserData->CollectionPaths[0];\r
+ }\r
+ else\r
+ {\r
+ HID_CollectionPath_t* ParentCollectionPath = CurrCollectionPath;\r
+\r
+ CurrCollectionPath = &ParserData->CollectionPaths[1];\r
+\r
+ while (CurrCollectionPath->Parent != NULL)\r
+ {\r
+ if (CurrCollectionPath == &ParserData->CollectionPaths[HID_MAX_COLLECTIONS - 1])\r
+ return HID_PARSE_InsufficientCollectionPaths;\r
+\r
+ CurrCollectionPath++;\r
+ }\r
+\r
+ CurrCollectionPath->Parent = ParentCollectionPath;\r
+ }\r
+\r
+ CurrCollectionPath->Type = ReportItemData;\r
+ CurrCollectionPath->Usage.Page = CurrStateTable->Attributes.Usage.Page;\r
+\r
+ if (UsageListSize)\r
+ {\r
+ CurrCollectionPath->Usage.Usage = UsageList[0];\r
+\r
+ for (uint8_t i = 0; i < UsageListSize; i++)\r
+ UsageList[i] = UsageList[i + 1];\r
+\r
+ UsageListSize--;\r
+ }\r
+ else if (UsageMinMax.Minimum <= UsageMinMax.Maximum)\r
+ {\r
+ CurrCollectionPath->Usage.Usage = UsageMinMax.Minimum++;\r
+ }\r
+\r
+ break;\r
+ case HID_RI_END_COLLECTION(0):\r
+ if (CurrCollectionPath == NULL)\r
+ return HID_PARSE_UnexpectedEndCollection;\r
+\r
+ CurrCollectionPath = CurrCollectionPath->Parent;\r
+ break;\r
+ case HID_RI_INPUT(0):\r
+ case HID_RI_OUTPUT(0):\r
+ case HID_RI_FEATURE(0):\r
+ for (uint8_t ReportItemNum = 0; ReportItemNum < CurrStateTable->ReportCount; ReportItemNum++)\r
+ {\r
+ HID_ReportItem_t NewReportItem;\r
+\r
+ memcpy(&NewReportItem.Attributes,\r
+ &CurrStateTable->Attributes,\r
+ sizeof(HID_ReportItem_Attributes_t));\r
+\r
+ NewReportItem.ItemFlags = ReportItemData;\r
+ NewReportItem.CollectionPath = CurrCollectionPath;\r
+ NewReportItem.ReportID = CurrStateTable->ReportID;\r
+\r
+ if (UsageListSize)\r
+ {\r
+ NewReportItem.Attributes.Usage.Usage = UsageList[0];\r
+\r
+ for (uint8_t i = 0; i < UsageListSize; i++)\r
+ UsageList[i] = UsageList[i + 1];\r
+\r
+ UsageListSize--;\r
+ }\r
+ else if (UsageMinMax.Minimum <= UsageMinMax.Maximum)\r
+ {\r
+ NewReportItem.Attributes.Usage.Usage = UsageMinMax.Minimum++;\r
+ }\r
+\r
+ uint8_t ItemTypeTag = (HIDReportItem & (HID_RI_TYPE_MASK | HID_RI_TAG_MASK));\r
+\r
+ if (ItemTypeTag == HID_RI_INPUT(0))\r
+ NewReportItem.ItemType = HID_REPORT_ITEM_In;\r
+ else if (ItemTypeTag == HID_RI_OUTPUT(0))\r
+ NewReportItem.ItemType = HID_REPORT_ITEM_Out;\r
+ else\r
+ NewReportItem.ItemType = HID_REPORT_ITEM_Feature;\r
+\r
+ NewReportItem.BitOffset = CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType];\r
+\r
+ CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType] += CurrStateTable->Attributes.BitSize;\r
+\r
+ ParserData->LargestReportSizeBits = MAX(ParserData->LargestReportSizeBits, CurrReportIDInfo->ReportSizeBits[NewReportItem.ItemType]);\r
+\r
+ if (ParserData->TotalReportItems == HID_MAX_REPORTITEMS)\r
+ return HID_PARSE_InsufficientReportItems;\r
+\r
+ memcpy(&ParserData->ReportItems[ParserData->TotalReportItems],\r
+ &NewReportItem, sizeof(HID_ReportItem_t));\r
+\r
+ if (!(ReportItemData & HID_IOF_CONSTANT) && CALLBACK_HIDParser_FilterHIDReportItem(&NewReportItem))\r
+ ParserData->TotalReportItems++;\r
+ }\r
+\r
+ break;\r
+ }\r
+\r
+ if ((HIDReportItem & HID_RI_TYPE_MASK) == HID_RI_TYPE_MAIN)\r
+ {\r
+ UsageMinMax.Minimum = 0;\r
+ UsageMinMax.Maximum = 0;\r
+ UsageListSize = 0;\r
+ }\r
+ }\r
+\r
+ if (!(ParserData->TotalReportItems))\r
+ return HID_PARSE_NoUnfilteredReportItems;\r
+\r
+ return HID_PARSE_Successful;\r
+}\r
+\r
+bool USB_GetHIDReportItemInfo(const uint8_t* ReportData,\r
+ HID_ReportItem_t* const ReportItem)\r
+{\r
+ if (ReportItem == NULL)\r
+ return false;\r
+\r
+ uint16_t DataBitsRem = ReportItem->Attributes.BitSize;\r
+ uint16_t CurrentBit = ReportItem->BitOffset;\r
+ uint32_t BitMask = (1 << 0);\r
+\r
+ if (ReportItem->ReportID)\r
+ {\r
+ if (ReportItem->ReportID != ReportData[0])\r
+ return false;\r
+\r
+ ReportData++;\r
+ }\r
+\r
+ ReportItem->PreviousValue = ReportItem->Value;\r
+ ReportItem->Value = 0;\r
+\r
+ while (DataBitsRem--)\r
+ {\r
+ if (ReportData[CurrentBit / 8] & (1 << (CurrentBit % 8)))\r
+ ReportItem->Value |= BitMask;\r
+\r
+ CurrentBit++;\r
+ BitMask <<= 1;\r
+ }\r
+\r
+ return true;\r
+}\r
+\r
+void USB_SetHIDReportItemInfo(uint8_t* ReportData,\r
+ HID_ReportItem_t* const ReportItem)\r
+{\r
+ if (ReportItem == NULL)\r
+ return;\r
+\r
+ uint16_t DataBitsRem = ReportItem->Attributes.BitSize;\r
+ uint16_t CurrentBit = ReportItem->BitOffset;\r
+ uint32_t BitMask = (1 << 0);\r
+\r
+ if (ReportItem->ReportID)\r
+ {\r
+ ReportData[0] = ReportItem->ReportID;\r
+ ReportData++;\r
+ }\r
+\r
+ ReportItem->PreviousValue = ReportItem->Value;\r
+\r
+ while (DataBitsRem--)\r
+ {\r
+ if (ReportItem->Value & (1 << (CurrentBit % 8)))\r
+ ReportData[CurrentBit / 8] |= BitMask;\r
+\r
+ CurrentBit++;\r
+ BitMask <<= 1;\r
+ }\r
+}\r
+\r
+uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData,\r
+ const uint8_t ReportID,\r
+ const uint8_t ReportType)\r
+{\r
+ for (uint8_t i = 0; i < HID_MAX_REPORT_IDS; i++)\r
+ {\r
+ uint16_t ReportSizeBits = ParserData->ReportIDSizes[i].ReportSizeBits[ReportType];\r
+\r
+ if (ParserData->ReportIDSizes[i].ReportID == ReportID)\r
+ return (ReportSizeBits / 8) + ((ReportSizeBits % 8) ? 1 : 0);\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Human Interface Device (HID) Class report descriptor parser.\r
+ *\r
+ * This file allows for the easy parsing of complex HID report descriptors, which describes the data that\r
+ * a HID device transmits to the host. It also provides an easy API for extracting and processing the data\r
+ * elements inside a HID report sent from an attached HID device.\r
+ */\r
+\r
+/** \ingroup Group_USB\r
+ * \defgroup Group_HIDParser HID Report Parser\r
+ * \brief USB Human Interface Device (HID) Class report descriptor parser.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/HIDParser.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Human Interface Device (HID) class report descriptor parser. This module implements a parser than is\r
+ * capable of processing a complete HID report descriptor, and outputting a flat structure containing the\r
+ * contents of the report in an a more friendly format. The parsed data may then be further processed and used\r
+ * within an application to process sent and received HID reports to and from an attached HID device.\r
+ *\r
+ * A HID report descriptor consists of a set of HID report items, which describe the function and layout\r
+ * of data exchanged between a HID device and a host, including both the physical encoding of each item\r
+ * (such as a button, key press or joystick axis) in the sent and received data packets - known as "reports" -\r
+ * as well as other information about each item such as the usages, data range, physical location and other\r
+ * characteristics. In this way a HID device can retain a high degree of flexibility in its capabilities, as it\r
+ * is not forced to comply with a given report layout or feature-set.\r
+ *\r
+ * This module also contains routines for the processing of data in an actual HID report, using the parsed report\r
+ * descriptor data as a guide for the encoding.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __HIDPARSER_H__\r
+#define __HIDPARSER_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ #include "HIDReportData.h"\r
+ #include "HIDClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Macros: */\r
+ #if !defined(HID_STATETABLE_STACK_DEPTH) || defined(__DOXYGEN__)\r
+ /** Constant indicating the maximum stack depth of the state table. A larger state table\r
+ * allows for more PUSH/POP report items to be nested, but consumes more memory. By default\r
+ * this is set to 2 levels (allowing non-nested PUSH items) but this can be overridden by\r
+ * defining \c HID_STATETABLE_STACK_DEPTH to another value in the user project makefile, passing the\r
+ * define to the compiler using the -D compiler switch.\r
+ */\r
+ #define HID_STATETABLE_STACK_DEPTH 2\r
+ #endif\r
+\r
+ #if !defined(HID_USAGE_STACK_DEPTH) || defined(__DOXYGEN__)\r
+ /** Constant indicating the maximum stack depth of the usage table. A larger usage table\r
+ * allows for more USAGE items to be indicated sequentially for REPORT COUNT entries of more than\r
+ * one, but requires more stack space. By default this is set to 8 levels (allowing for a report\r
+ * item with a count of 8) but this can be overridden by defining \c HID_USAGE_STACK_DEPTH to another\r
+ * value in the user project makefile, passing the define to the compiler using the -D compiler\r
+ * switch.\r
+ */\r
+ #define HID_USAGE_STACK_DEPTH 8\r
+ #endif\r
+\r
+ #if !defined(HID_MAX_COLLECTIONS) || defined(__DOXYGEN__)\r
+ /** Constant indicating the maximum number of COLLECTION items (nested or unnested) that can be\r
+ * processed in the report item descriptor. A large value allows for more COLLECTION items to be\r
+ * processed, but consumes more memory. By default this is set to 10 collections, but this can be\r
+ * overridden by defining \c HID_MAX_COLLECTIONS to another value in the user project makefile, passing\r
+ * the define to the compiler using the -D compiler switch.\r
+ */\r
+ #define HID_MAX_COLLECTIONS 10\r
+ #endif\r
+\r
+ #if !defined(HID_MAX_REPORTITEMS) || defined(__DOXYGEN__)\r
+ /** Constant indicating the maximum number of report items (IN, OUT or FEATURE) that can be processed\r
+ * in the report item descriptor and stored in the user HID Report Info structure. A large value allows\r
+ * for more report items to be stored, but consumes more memory. By default this is set to 20 items,\r
+ * but this can be overridden by defining \c HID_MAX_REPORTITEMS to another value in the user project\r
+ * makefile, and passing the define to the compiler using the -D compiler switch.\r
+ */\r
+ #define HID_MAX_REPORTITEMS 20\r
+ #endif\r
+\r
+ #if !defined(HID_MAX_REPORT_IDS) || defined(__DOXYGEN__)\r
+ /** Constant indicating the maximum number of unique report IDs that can be processed in the report item\r
+ * descriptor for the report size information array in the user HID Report Info structure. A large value\r
+ * allows for more report ID report sizes to be stored, but consumes more memory. By default this is set\r
+ * to 10 items, but this can be overridden by defining \c HID_MAX_REPORT_IDS to another value in the user project\r
+ * makefile, and passing the define to the compiler using the -D compiler switch. Note that IN, OUT and FEATURE\r
+ * items sharing the same report ID consume only one size item in the array.\r
+ */\r
+ #define HID_MAX_REPORT_IDS 10\r
+ #endif\r
+\r
+ /** Returns the value a given HID report item (once its value has been fetched via \ref USB_GetHIDReportItemInfo())\r
+ * left-aligned to the given data type. This allows for signed data to be interpreted correctly, by shifting the data\r
+ * leftwards until the data's sign bit is in the correct position.\r
+ *\r
+ * \param[in] ReportItem HID Report Item whose retrieved value is to be aligned.\r
+ * \param[in] Type Data type to align the HID report item's value to.\r
+ *\r
+ * \return Left-aligned data of the given report item's pre-retrieved value for the given datatype.\r
+ */\r
+ #define HID_ALIGN_DATA(ReportItem, Type) ((Type)(ReportItem->Value << ((8 * sizeof(Type)) - ReportItem->Attributes.BitSize)))\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Enums: */\r
+ /** Enum for the possible error codes in the return value of the \ref USB_ProcessHIDReport() function. */\r
+ enum HID_Parse_ErrorCodes_t\r
+ {\r
+ HID_PARSE_Successful = 0, /**< Successful parse of the HID report descriptor, no error. */\r
+ HID_PARSE_HIDStackOverflow = 1, /**< More than \ref HID_STATETABLE_STACK_DEPTH nested PUSHes in the report. */\r
+ HID_PARSE_HIDStackUnderflow = 2, /**< A POP was found when the state table stack was empty. */\r
+ HID_PARSE_InsufficientReportItems = 3, /**< More than \ref HID_MAX_REPORTITEMS report items in the report. */\r
+ HID_PARSE_UnexpectedEndCollection = 4, /**< An END COLLECTION item found without matching COLLECTION item. */\r
+ HID_PARSE_InsufficientCollectionPaths = 5, /**< More than \ref HID_MAX_COLLECTIONS collections in the report. */\r
+ HID_PARSE_UsageListOverflow = 6, /**< More than \ref HID_USAGE_STACK_DEPTH usages listed in a row. */\r
+ HID_PARSE_InsufficientReportIDItems = 7, /**< More than \ref HID_MAX_REPORT_IDS report IDs in the device. */\r
+ HID_PARSE_NoUnfilteredReportItems = 8, /**< All report items from the device were filtered by the filtering callback routine. */\r
+ };\r
+\r
+ /* Type Defines: */\r
+ /** \brief HID Parser Report Item Min/Max Structure.\r
+ *\r
+ * Type define for an attribute with both minimum and maximum values (e.g. Logical Min/Max).\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t Minimum; /**< Minimum value for the attribute. */\r
+ uint32_t Maximum; /**< Maximum value for the attribute. */\r
+ } HID_MinMax_t;\r
+\r
+ /** \brief HID Parser Report Item Unit Structure.\r
+ *\r
+ * Type define for the Unit attributes of a report item.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t Type; /**< Unit type (refer to HID specifications for details). */\r
+ uint8_t Exponent; /**< Unit exponent (refer to HID specifications for details). */\r
+ } HID_Unit_t;\r
+\r
+ /** \brief HID Parser Report Item Usage Structure.\r
+ *\r
+ * Type define for the Usage attributes of a report item.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint16_t Page; /**< Usage page of the report item. */\r
+ uint16_t Usage; /**< Usage of the report item. */\r
+ } HID_Usage_t;\r
+\r
+ /** \brief HID Parser Report Item Collection Path Structure.\r
+ *\r
+ * Type define for a COLLECTION object. Contains the collection attributes and a reference to the\r
+ * parent collection if any.\r
+ */\r
+ typedef struct HID_CollectionPath\r
+ {\r
+ uint8_t Type; /**< Collection type (e.g. "Generic Desktop"). */\r
+ HID_Usage_t Usage; /**< Collection usage. */\r
+ struct HID_CollectionPath* Parent; /**< Reference to parent collection, or \c NULL if root collection. */\r
+ } HID_CollectionPath_t;\r
+\r
+ /** \brief HID Parser Report Item Attributes Structure.\r
+ *\r
+ * Type define for all the data attributes of a report item, except flags.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t BitSize; /**< Size in bits of the report item's data. */\r
+\r
+ HID_Usage_t Usage; /**< Usage of the report item. */\r
+ HID_Unit_t Unit; /**< Unit type and exponent of the report item. */\r
+ HID_MinMax_t Logical; /**< Logical minimum and maximum of the report item. */\r
+ HID_MinMax_t Physical; /**< Physical minimum and maximum of the report item. */\r
+ } HID_ReportItem_Attributes_t;\r
+\r
+ /** \brief HID Parser Report Item Details Structure.\r
+ *\r
+ * Type define for a report item (IN, OUT or FEATURE) layout attributes and other details.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint16_t BitOffset; /**< Bit offset in the IN, OUT or FEATURE report of the item. */\r
+ uint8_t ItemType; /**< Report item type, a value in \ref HID_ReportItemTypes_t. */\r
+ uint16_t ItemFlags; /**< Item data flags, a mask of \c HID_IOF_* constants. */\r
+ uint8_t ReportID; /**< Report ID this item belongs to, or 0x00 if device has only one report */\r
+ HID_CollectionPath_t* CollectionPath; /**< Collection path of the item. */\r
+\r
+ HID_ReportItem_Attributes_t Attributes; /**< Report item attributes. */\r
+\r
+ uint32_t Value; /**< Current value of the report item - use \ref HID_ALIGN_DATA() when processing\r
+ * a retrieved value so that it is aligned to a specific type.\r
+ */\r
+ uint32_t PreviousValue; /**< Previous value of the report item. */\r
+ } HID_ReportItem_t;\r
+\r
+ /** \brief HID Parser Report Size Structure.\r
+ *\r
+ * Type define for a report item size information structure, to retain the size of a device's reports by ID.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t ReportID; /**< Report ID of the report within the HID interface. */\r
+ uint16_t ReportSizeBits[3]; /**< Total number of bits in each report type for the given Report ID,\r
+ * indexed by the \ref HID_ReportItemTypes_t enum.\r
+ */\r
+ } HID_ReportSizeInfo_t;\r
+\r
+ /** \brief HID Parser State Structure.\r
+ *\r
+ * Type define for a complete processed HID report, including all report item data and collections.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t TotalReportItems; /**< Total number of report items stored in the \c ReportItems array. */\r
+ HID_ReportItem_t ReportItems[HID_MAX_REPORTITEMS]; /**< Report items array, including all IN, OUT\r
+ * and FEATURE items.\r
+ */\r
+ HID_CollectionPath_t CollectionPaths[HID_MAX_COLLECTIONS]; /**< All collection items, referenced\r
+ * by the report items.\r
+ */\r
+ uint8_t TotalDeviceReports; /**< Number of reports within the HID interface */\r
+ HID_ReportSizeInfo_t ReportIDSizes[HID_MAX_REPORT_IDS]; /**< Report sizes for each report in the interface */\r
+ uint16_t LargestReportSizeBits; /**< Largest report that the attached device will generate, in bits */\r
+ bool UsingReportIDs; /**< Indicates if the device has at least one REPORT ID\r
+ * element in its HID report descriptor.\r
+ */\r
+ } HID_ReportInfo_t;\r
+\r
+ /* Function Prototypes: */\r
+ /** Function to process a given HID report returned from an attached device, and store it into a given\r
+ * \ref HID_ReportInfo_t structure.\r
+ *\r
+ * \param[in] ReportData Buffer containing the device's HID report table.\r
+ * \param[in] ReportSize Size in bytes of the HID report table.\r
+ * \param[out] ParserData Pointer to a \ref HID_ReportInfo_t instance for the parser output.\r
+ *\r
+ * \return A value in the \ref HID_Parse_ErrorCodes_t enum.\r
+ */\r
+ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,\r
+ uint16_t ReportSize,\r
+ HID_ReportInfo_t* const ParserData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Extracts the given report item's value out of the given HID report and places it into the Value\r
+ * member of the report item's \ref HID_ReportItem_t structure.\r
+ *\r
+ * When called on a report with an item that exists in that report, this copies the report item's \c Value\r
+ * to its \c PreviousValue element for easy checking to see if an item's value has changed before processing\r
+ * a report. If the given item does not exist in the report, the function does not modify the report item's\r
+ * data.\r
+ *\r
+ * \param[in] ReportData Buffer containing an IN or FEATURE report from an attached device.\r
+ * \param[in,out] ReportItem Pointer to the report item of interest in a \ref HID_ReportInfo_t ReportItem array.\r
+ *\r
+ * \returns Boolean \c true if the item to retrieve was located in the given report, \c false otherwise.\r
+ */\r
+ bool USB_GetHIDReportItemInfo(const uint8_t* ReportData,\r
+ HID_ReportItem_t* const ReportItem) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Retrieves the given report item's value out of the \c Value member of the report item's\r
+ * \ref HID_ReportItem_t structure and places it into the correct position in the HID report\r
+ * buffer. The report buffer is assumed to have the appropriate bits cleared before calling\r
+ * this function (i.e., the buffer should be explicitly cleared before report values are added).\r
+ *\r
+ * When called, this copies the report item's \c Value element to its \c PreviousValue element for easy\r
+ * checking to see if an item's value has changed before sending a report.\r
+ *\r
+ * If the device has multiple HID reports, the first byte in the report is set to the report ID of the given item.\r
+ *\r
+ * \param[out] ReportData Buffer holding the current OUT or FEATURE report data.\r
+ * \param[in] ReportItem Pointer to the report item of interest in a \ref HID_ReportInfo_t ReportItem array.\r
+ */\r
+ void USB_SetHIDReportItemInfo(uint8_t* ReportData,\r
+ HID_ReportItem_t* const ReportItem) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Retrieves the size of a given HID report in bytes from its Report ID.\r
+ *\r
+ * \param[in] ParserData Pointer to a \ref HID_ReportInfo_t instance containing the parser output.\r
+ * \param[in] ReportID Report ID of the report whose size is to be determined.\r
+ * \param[in] ReportType Type of the report whose size is to be determined, a value from the\r
+ * \ref HID_ReportItemTypes_t enum.\r
+ *\r
+ * \return Size of the report in bytes, or \c 0 if the report does not exist.\r
+ */\r
+ uint16_t USB_GetHIDReportSize(HID_ReportInfo_t* const ParserData,\r
+ const uint8_t ReportID,\r
+ const uint8_t ReportType) ATTR_CONST ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Callback routine for the HID Report Parser. This callback <b>must</b> be implemented by the user code when\r
+ * the parser is used, to determine what report IN, OUT and FEATURE item's information is stored into the user\r
+ * \ref HID_ReportInfo_t structure. This can be used to filter only those items the application will be using, so that\r
+ * no RAM is wasted storing the attributes for report items which will never be referenced by the application.\r
+ *\r
+ * Report item pointers passed to this callback function may be cached by the user application for later use\r
+ * when processing report items. This provides faster report processing in the user application than would\r
+ * a search of the entire parsed report item table for each received or sent report.\r
+ *\r
+ * \param[in] CurrentItem Pointer to the current report item for user checking.\r
+ *\r
+ * \return Boolean \c true if the item should be stored into the \ref HID_ReportInfo_t structure, \c false if\r
+ * it should be ignored.\r
+ */\r
+ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Type Defines: */\r
+ typedef struct\r
+ {\r
+ HID_ReportItem_Attributes_t Attributes;\r
+ uint8_t ReportCount;\r
+ uint8_t ReportID;\r
+ } HID_StateTable_t;\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Constants for HID report item attributes.\r
+ *\r
+ * HID report item constants for report item attributes. Refer to the HID specification for\r
+ * details on each flag's meaning when applied to an IN, OUT or FEATURE item.\r
+ */\r
+\r
+/** \ingroup Group_HIDParser\r
+ * \defgroup Group_HIDReportItemConst HID Report Descriptor Item Constants\r
+ *\r
+ * General HID constant definitions for HID Report Descriptor elements.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __HIDREPORTDATA_H__\r
+#define __HIDREPORTDATA_H__\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define HID_RI_DATA_SIZE_MASK 0x03\r
+ #define HID_RI_TYPE_MASK 0x0C\r
+ #define HID_RI_TAG_MASK 0xF0\r
+\r
+ #define HID_RI_TYPE_MAIN 0x00\r
+ #define HID_RI_TYPE_GLOBAL 0x04\r
+ #define HID_RI_TYPE_LOCAL 0x08\r
+\r
+ #define HID_RI_DATA_BITS_0 0x00\r
+ #define HID_RI_DATA_BITS_8 0x01\r
+ #define HID_RI_DATA_BITS_16 0x02\r
+ #define HID_RI_DATA_BITS_32 0x03\r
+ #define HID_RI_DATA_BITS(DataBits) HID_RI_DATA_BITS_ ## DataBits\r
+\r
+ #define _HID_RI_ENCODE_0(Data)\r
+ #define _HID_RI_ENCODE_8(Data) , (Data & 0xFF)\r
+ #define _HID_RI_ENCODE_16(Data) _HID_RI_ENCODE_8(Data) _HID_RI_ENCODE_8(Data >> 8)\r
+ #define _HID_RI_ENCODE_32(Data) _HID_RI_ENCODE_16(Data) _HID_RI_ENCODE_16(Data >> 16)\r
+ #define _HID_RI_ENCODE(DataBits, ...) _HID_RI_ENCODE_ ## DataBits(__VA_ARGS__)\r
+\r
+ #define _HID_RI_ENTRY(Type, Tag, DataBits, ...) (Type | Tag | HID_RI_DATA_BITS(DataBits)) _HID_RI_ENCODE(DataBits, (__VA_ARGS__))\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name HID Input, Output and Feature Report Descriptor Item Flags */\r
+ //@{\r
+ #define HID_IOF_CONSTANT (1 << 0)\r
+ #define HID_IOF_DATA (0 << 0)\r
+ #define HID_IOF_VARIABLE (1 << 1)\r
+ #define HID_IOF_ARRAY (0 << 1)\r
+ #define HID_IOF_RELATIVE (1 << 2)\r
+ #define HID_IOF_ABSOLUTE (0 << 2)\r
+ #define HID_IOF_WRAP (1 << 3)\r
+ #define HID_IOF_NO_WRAP (0 << 3)\r
+ #define HID_IOF_NON_LINEAR (1 << 4)\r
+ #define HID_IOF_LINEAR (0 << 4)\r
+ #define HID_IOF_NO_PREFERRED_STATE (1 << 5)\r
+ #define HID_IOF_PREFERRED_STATE (0 << 5)\r
+ #define HID_IOF_NULLSTATE (1 << 6)\r
+ #define HID_IOF_NO_NULL_POSITION (0 << 6)\r
+ #define HID_IOF_VOLATILE (1 << 7)\r
+ #define HID_IOF_NON_VOLATILE (0 << 7)\r
+ #define HID_IOF_BUFFERED_BYTES (1 << 8)\r
+ #define HID_IOF_BITFIELD (0 << 8)\r
+ //@}\r
+\r
+ /** \name HID Report Descriptor Item Macros */\r
+ //@{\r
+ #define HID_RI_INPUT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0x80, DataBits, __VA_ARGS__)\r
+ #define HID_RI_OUTPUT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0x90, DataBits, __VA_ARGS__)\r
+ #define HID_RI_COLLECTION(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0xA0, DataBits, __VA_ARGS__)\r
+ #define HID_RI_FEATURE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0xB0, DataBits, __VA_ARGS__)\r
+ #define HID_RI_END_COLLECTION(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_MAIN , 0xC0, DataBits, __VA_ARGS__)\r
+ #define HID_RI_USAGE_PAGE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x00, DataBits, __VA_ARGS__)\r
+ #define HID_RI_LOGICAL_MINIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x10, DataBits, __VA_ARGS__)\r
+ #define HID_RI_LOGICAL_MAXIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x20, DataBits, __VA_ARGS__)\r
+ #define HID_RI_PHYSICAL_MINIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x30, DataBits, __VA_ARGS__)\r
+ #define HID_RI_PHYSICAL_MAXIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x40, DataBits, __VA_ARGS__)\r
+ #define HID_RI_UNIT_EXPONENT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x50, DataBits, __VA_ARGS__)\r
+ #define HID_RI_UNIT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x60, DataBits, __VA_ARGS__)\r
+ #define HID_RI_REPORT_SIZE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x70, DataBits, __VA_ARGS__)\r
+ #define HID_RI_REPORT_ID(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x80, DataBits, __VA_ARGS__)\r
+ #define HID_RI_REPORT_COUNT(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0x90, DataBits, __VA_ARGS__)\r
+ #define HID_RI_PUSH(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0xA0, DataBits, __VA_ARGS__)\r
+ #define HID_RI_POP(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_GLOBAL, 0xB0, DataBits, __VA_ARGS__)\r
+ #define HID_RI_USAGE(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x00, DataBits, __VA_ARGS__)\r
+ #define HID_RI_USAGE_MINIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x10, DataBits, __VA_ARGS__)\r
+ #define HID_RI_USAGE_MAXIMUM(DataBits, ...) _HID_RI_ENTRY(HID_RI_TYPE_LOCAL , 0x20, DataBits, __VA_ARGS__)\r
+ //@}\r
+\r
+/** @} */\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common definitions and declarations for the library USB MIDI Class driver.\r
+ *\r
+ * Common definitions and declarations for the library USB MIDI Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassMIDI\r
+ * \defgroup Group_USBClassMIDICommon Common Class Definitions\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB\r
+ * MIDI Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _MIDI_CLASS_COMMON_H_\r
+#define _MIDI_CLASS_COMMON_H_\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_AUDIO_DRIVER\r
+\r
+ /* Includes: */\r
+ #include "../../Core/StdDescriptors.h"\r
+ #include "AudioClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_MIDI_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Macros: */\r
+ /** \name MIDI Command Values */\r
+ //@{\r
+ /** MIDI command for a note on (activation) event. */\r
+ #define MIDI_COMMAND_NOTE_ON 0x90\r
+\r
+ /** MIDI command for a note off (deactivation) event. */\r
+ #define MIDI_COMMAND_NOTE_OFF 0x80\r
+ //@}\r
+\r
+ /** Standard key press velocity value used for all note events. */\r
+ #define MIDI_STANDARD_VELOCITY 64\r
+\r
+ /** Convenience macro. MIDI channels are numbered from 1-10 (natural numbers) however the logical channel\r
+ * addresses are zero-indexed. This converts a natural MIDI channel number into the logical channel address.\r
+ *\r
+ * \param[in] channel MIDI channel number to address.\r
+ *\r
+ * \return Constructed MIDI channel ID.\r
+ */\r
+ #define MIDI_CHANNEL(channel) ((channel) - 1)\r
+ \r
+ /** Constructs a MIDI event ID from a given MIDI command and a virtual MIDI cable index. This can then be\r
+ * used to create and decode \ref MIDI_EventPacket_t MIDI event packets.\r
+ *\r
+ * \param[in] virtualcable Index of the virtual MIDI cable the event relates to\r
+ * \param[in] command MIDI command to send through the virtual MIDI cable\r
+ *\r
+ * \return Constructed MIDI event ID.\r
+ */\r
+ #define MIDI_EVENT(virtualcable, command) ((virtualcable << 4) | (command >> 4))\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible MIDI jack types in a MIDI device jack descriptor. */\r
+ enum MIDI_JackTypes_t\r
+ {\r
+ MIDI_JACKTYPE_Embedded = 0x01, /**< MIDI class descriptor jack type value for an embedded (logical) MIDI input or output jack. */\r
+ MIDI_JACKTYPE_External = 0x02, /**< MIDI class descriptor jack type value for an external (physical) MIDI input or output jack. */\r
+ };\r
+\r
+ /* Type Defines: */\r
+ /** \brief MIDI class-specific Streaming Interface Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific MIDI streaming interface descriptor. This indicates to the host\r
+ * how MIDI the specification compliance of the device and the total length of the Audio class-specific descriptors.\r
+ * See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_MIDI_StdDescriptor_AudioInterface_AS_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
+\r
+ uint16_t AudioSpecification; /**< Binary coded decimal value, indicating the supported Audio Class\r
+ * specification version.\r
+ */\r
+ uint16_t TotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */\r
+ } ATTR_PACKED USB_MIDI_Descriptor_AudioInterface_AS_t;\r
+\r
+ /** \brief MIDI class-specific Streaming Interface Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific MIDI streaming interface descriptor. This indicates to the host\r
+ * how MIDI the specification compliance of the device and the total length of the Audio class-specific descriptors.\r
+ * See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_MIDI_Descriptor_AudioInterface_AS_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+\r
+ uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
+\r
+ uint16_t bcdMSC; /**< Binary coded decimal value, indicating the supported MIDI Class specification version. */\r
+ uint16_t wTotalLength; /**< Total length of the Audio class-specific descriptors, including this descriptor. */\r
+ } ATTR_PACKED USB_MIDI_StdDescriptor_AudioInterface_AS_t;\r
+\r
+ /** \brief MIDI class-specific Input Jack Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific MIDI IN jack. This gives information to the host on a MIDI input, either\r
+ * a physical input jack, or a logical jack (receiving input data internally, or from the host via an endpoint).\r
+ *\r
+ * \see \ref USB_MIDI_StdDescriptor_InputJack_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
+\r
+ uint8_t JackType; /**< Type of jack, one of the \c JACKTYPE_* mask values. */\r
+ uint8_t JackID; /**< ID value of this jack - must be a unique value within the device. */\r
+\r
+ uint8_t JackStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */\r
+ } ATTR_PACKED USB_MIDI_Descriptor_InputJack_t;\r
+\r
+ /** \brief MIDI class-specific Input Jack Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific MIDI IN jack. This gives information to the host on a MIDI input, either\r
+ * a physical input jack, or a logical jack (receiving input data internally, or from the host via an endpoint).\r
+ *\r
+ * \see \ref USB_MIDI_Descriptor_InputJack_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+\r
+ uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
+\r
+ uint8_t bJackType; /**< Type of jack, one of the \c JACKTYPE_* mask values. */\r
+ uint8_t bJackID; /**< ID value of this jack - must be a unique value within the device. */\r
+\r
+ uint8_t iJack; /**< Index of a string descriptor describing this descriptor within the device. */\r
+ } ATTR_PACKED USB_MIDI_StdDescriptor_InputJack_t;\r
+\r
+ /** \brief MIDI class-specific Output Jack Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific MIDI OUT jack. This gives information to the host on a MIDI output, either\r
+ * a physical output jack, or a logical jack (sending output data internally, or to the host via an endpoint).\r
+ *\r
+ * \see \ref USB_MIDI_StdDescriptor_OutputJack_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
+\r
+ uint8_t JackType; /**< Type of jack, one of the \c JACKTYPE_* mask values. */\r
+ uint8_t JackID; /**< ID value of this jack - must be a unique value within the device. */\r
+\r
+ uint8_t NumberOfPins; /**< Number of output channels within the jack, either physical or logical. */\r
+ uint8_t SourceJackID[1]; /**< ID of each output pin's source data jack. */\r
+ uint8_t SourcePinID[1]; /**< Pin number in the input jack of each output pin's source data. */\r
+\r
+ uint8_t JackStrIndex; /**< Index of a string descriptor describing this descriptor within the device. */\r
+ } ATTR_PACKED USB_MIDI_Descriptor_OutputJack_t;\r
+\r
+ /** \brief MIDI class-specific Output Jack Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific MIDI OUT jack. This gives information to the host on a MIDI output, either\r
+ * a physical output jack, or a logical jack (sending output data internally, or to the host via an endpoint).\r
+ *\r
+ * \see \ref USB_MIDI_Descriptor_OutputJack_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+\r
+ uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
+\r
+ uint8_t bJackType; /**< Type of jack, one of the \c JACKTYPE_* mask values. */\r
+ uint8_t bJackID; /**< ID value of this jack - must be a unique value within the device. */\r
+\r
+ uint8_t bNrInputPins; /**< Number of output channels within the jack, either physical or logical. */\r
+ uint8_t baSourceID[1]; /**< ID of each output pin's source data jack. */\r
+ uint8_t baSourcePin[1]; /**< Pin number in the input jack of each output pin's source data. */\r
+\r
+ uint8_t iJack; /**< Index of a string descriptor describing this descriptor within the device. */\r
+ } ATTR_PACKED USB_MIDI_StdDescriptor_OutputJack_t;\r
+\r
+ /** \brief Audio class-specific Jack Endpoint Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific extended MIDI jack endpoint descriptor. This contains extra information\r
+ * on the usage of MIDI endpoints used to stream MIDI events in and out of the USB Audio device, and follows an Audio\r
+ * class-specific extended MIDI endpoint descriptor. See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_MIDI_StdDescriptor_Jack_Endpoint_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length. */\r
+ uint8_t Subtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
+\r
+ uint8_t TotalEmbeddedJacks; /**< Total number of jacks inside this endpoint. */\r
+ uint8_t AssociatedJackID[1]; /**< IDs of each jack inside the endpoint. */\r
+ } ATTR_PACKED USB_MIDI_Descriptor_Jack_Endpoint_t;\r
+\r
+ /** \brief Audio class-specific Jack Endpoint Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for an Audio class-specific extended MIDI jack endpoint descriptor. This contains extra information\r
+ * on the usage of MIDI endpoints used to stream MIDI events in and out of the USB Audio device, and follows an Audio\r
+ * class-specific extended MIDI endpoint descriptor. See the USB Audio specification for more details.\r
+ *\r
+ * \see \ref USB_MIDI_Descriptor_Jack_Endpoint_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+\r
+ uint8_t bDescriptorSubtype; /**< Sub type value used to distinguish between audio class-specific descriptors. */\r
+\r
+ uint8_t bNumEmbMIDIJack; /**< Total number of jacks inside this endpoint. */\r
+ uint8_t bAssocJackID[1]; /**< IDs of each jack inside the endpoint. */\r
+ } ATTR_PACKED USB_MIDI_StdDescriptor_Jack_Endpoint_t;\r
+\r
+ /** \brief MIDI Class Driver Event Packet.\r
+ *\r
+ * Type define for a USB MIDI event packet, used to encapsulate sent and received MIDI messages from a USB MIDI interface.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t Event; /**< MIDI event type, constructed with the \ref MIDI_EVENT() macro. */\r
+\r
+ uint8_t Data1; /**< First byte of data in the MIDI event. */\r
+ uint8_t Data2; /**< Second byte of data in the MIDI event. */\r
+ uint8_t Data3; /**< Third byte of data in the MIDI event. */\r
+ } ATTR_PACKED MIDI_EventPacket_t;\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common definitions and declarations for the library USB Mass Storage Class driver.\r
+ *\r
+ * Common definitions and declarations for the library USB Mass Storage Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassMS\r
+ * \defgroup Group_USBClassMSCommon Common Class Definitions\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB\r
+ * Mass Storage Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _MS_CLASS_COMMON_H_\r
+#define _MS_CLASS_COMMON_H_\r
+\r
+ /* Includes: */\r
+ #include "../../Core/StdDescriptors.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_MS_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Macros: */\r
+ /** Magic signature for a Command Block Wrapper used in the Mass Storage Bulk-Only transport protocol. */\r
+ #define MS_CBW_SIGNATURE 0x43425355UL\r
+\r
+ /** Magic signature for a Command Status Wrapper used in the Mass Storage Bulk-Only transport protocol. */\r
+ #define MS_CSW_SIGNATURE 0x53425355UL\r
+\r
+ /** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from host-to-device. */\r
+ #define MS_COMMAND_DIR_DATA_OUT (0 << 7)\r
+\r
+ /** Mask for a Command Block Wrapper's flags attribute to specify a command with data sent from device-to-host. */\r
+ #define MS_COMMAND_DIR_DATA_IN (1 << 7)\r
+\r
+ /** \name SCSI Commands*/\r
+ //@{\r
+ /** SCSI Command Code for an INQUIRY command. */\r
+ #define SCSI_CMD_INQUIRY 0x12\r
+\r
+ /** SCSI Command Code for a REQUEST SENSE command. */\r
+ #define SCSI_CMD_REQUEST_SENSE 0x03\r
+\r
+ /** SCSI Command Code for a TEST UNIT READY command. */\r
+ #define SCSI_CMD_TEST_UNIT_READY 0x00\r
+\r
+ /** SCSI Command Code for a READ CAPACITY (10) command. */\r
+ #define SCSI_CMD_READ_CAPACITY_10 0x25\r
+\r
+ /** SCSI Command Code for a SEND DIAGNOSTIC command. */\r
+ #define SCSI_CMD_SEND_DIAGNOSTIC 0x1D\r
+\r
+ /** SCSI Command Code for a PREVENT ALLOW MEDIUM REMOVAL command. */\r
+ #define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1E\r
+\r
+ /** SCSI Command Code for a WRITE (10) command. */\r
+ #define SCSI_CMD_WRITE_10 0x2A\r
+\r
+ /** SCSI Command Code for a READ (10) command. */\r
+ #define SCSI_CMD_READ_10 0x28\r
+\r
+ /** SCSI Command Code for a WRITE (6) command. */\r
+ #define SCSI_CMD_WRITE_6 0x0A\r
+\r
+ /** SCSI Command Code for a READ (6) command. */\r
+ #define SCSI_CMD_READ_6 0x08\r
+\r
+ /** SCSI Command Code for a VERIFY (10) command. */\r
+ #define SCSI_CMD_VERIFY_10 0x2F\r
+\r
+ /** SCSI Command Code for a MODE SENSE (6) command. */\r
+ #define SCSI_CMD_MODE_SENSE_6 0x1A\r
+\r
+ /** SCSI Command Code for a MODE SENSE (10) command. */\r
+ #define SCSI_CMD_MODE_SENSE_10 0x5A\r
+ //@}\r
+\r
+ /** \name SCSI Sense Key Values */\r
+ //@{\r
+ /** SCSI Sense Code to indicate no error has occurred. */\r
+ #define SCSI_SENSE_KEY_GOOD 0x00\r
+\r
+ /** SCSI Sense Code to indicate that the device has recovered from an error. */\r
+ #define SCSI_SENSE_KEY_RECOVERED_ERROR 0x01\r
+\r
+ /** SCSI Sense Code to indicate that the device is not ready for a new command. */\r
+ #define SCSI_SENSE_KEY_NOT_READY 0x02\r
+\r
+ /** SCSI Sense Code to indicate an error whilst accessing the medium. */\r
+ #define SCSI_SENSE_KEY_MEDIUM_ERROR 0x03\r
+\r
+ /** SCSI Sense Code to indicate a hardware error has occurred. */\r
+ #define SCSI_SENSE_KEY_HARDWARE_ERROR 0x04\r
+\r
+ /** SCSI Sense Code to indicate that an illegal request has been issued. */\r
+ #define SCSI_SENSE_KEY_ILLEGAL_REQUEST 0x05\r
+\r
+ /** SCSI Sense Code to indicate that the unit requires attention from the host to indicate\r
+ * a reset event, medium removal or other condition.\r
+ */\r
+ #define SCSI_SENSE_KEY_UNIT_ATTENTION 0x06\r
+\r
+ /** SCSI Sense Code to indicate that a write attempt on a protected block has been made. */\r
+ #define SCSI_SENSE_KEY_DATA_PROTECT 0x07\r
+\r
+ /** SCSI Sense Code to indicate an error while trying to write to a write-once medium. */\r
+ #define SCSI_SENSE_KEY_BLANK_CHECK 0x08\r
+\r
+ /** SCSI Sense Code to indicate a vendor specific error has occurred. */\r
+ #define SCSI_SENSE_KEY_VENDOR_SPECIFIC 0x09\r
+\r
+ /** SCSI Sense Code to indicate that an EXTENDED COPY command has aborted due to an error. */\r
+ #define SCSI_SENSE_KEY_COPY_ABORTED 0x0A\r
+\r
+ /** SCSI Sense Code to indicate that the device has aborted the issued command. */\r
+ #define SCSI_SENSE_KEY_ABORTED_COMMAND 0x0B\r
+\r
+ /** SCSI Sense Code to indicate an attempt to write past the end of a partition has been made. */\r
+ #define SCSI_SENSE_KEY_VOLUME_OVERFLOW 0x0D\r
+\r
+ /** SCSI Sense Code to indicate that the source data did not match the data read from the medium. */\r
+ #define SCSI_SENSE_KEY_MISCOMPARE 0x0E\r
+ //@}\r
+\r
+ /** \name SCSI Additional Sense Codes */\r
+ //@{\r
+ /** SCSI Additional Sense Code to indicate no additional sense information is available. */\r
+ #define SCSI_ASENSE_NO_ADDITIONAL_INFORMATION 0x00\r
+\r
+ /** SCSI Additional Sense Code to indicate that the logical unit (LUN) addressed is not ready. */\r
+ #define SCSI_ASENSE_LOGICAL_UNIT_NOT_READY 0x04\r
+\r
+ /** SCSI Additional Sense Code to indicate an invalid field was encountered while processing the issued command. */\r
+ #define SCSI_ASENSE_INVALID_FIELD_IN_CDB 0x24\r
+\r
+ /** SCSI Additional Sense Code to indicate that a medium that was previously indicated as not ready has now\r
+ * become ready for use.\r
+ */\r
+ #define SCSI_ASENSE_NOT_READY_TO_READY_CHANGE 0x28\r
+\r
+ /** SCSI Additional Sense Code to indicate that an attempt to write to a protected area was made. */\r
+ #define SCSI_ASENSE_WRITE_PROTECTED 0x27\r
+\r
+ /** SCSI Additional Sense Code to indicate an error whilst formatting the device medium. */\r
+ #define SCSI_ASENSE_FORMAT_ERROR 0x31\r
+\r
+ /** SCSI Additional Sense Code to indicate an invalid command was issued. */\r
+ #define SCSI_ASENSE_INVALID_COMMAND 0x20\r
+\r
+ /** SCSI Additional Sense Code to indicate a write to a block out outside of the medium's range was issued. */\r
+ #define SCSI_ASENSE_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE 0x21\r
+\r
+ /** SCSI Additional Sense Code to indicate that no removable medium is inserted into the device. */\r
+ #define SCSI_ASENSE_MEDIUM_NOT_PRESENT 0x3A\r
+ //@}\r
+\r
+ /** \name SCSI Additional Sense Key Code Qualifiers */\r
+ //@{\r
+ /** SCSI Additional Sense Qualifier Code to indicate no additional sense qualifier information is available. */\r
+ #define SCSI_ASENSEQ_NO_QUALIFIER 0x00\r
+\r
+ /** SCSI Additional Sense Qualifier Code to indicate that a medium format command failed to complete. */\r
+ #define SCSI_ASENSEQ_FORMAT_COMMAND_FAILED 0x01\r
+\r
+ /** SCSI Additional Sense Qualifier Code to indicate that an initializing command must be issued before the issued\r
+ * command can be executed.\r
+ */\r
+ #define SCSI_ASENSEQ_INITIALIZING_COMMAND_REQUIRED 0x02\r
+\r
+ /** SCSI Additional Sense Qualifier Code to indicate that an operation is currently in progress. */\r
+ #define SCSI_ASENSEQ_OPERATION_IN_PROGRESS 0x07\r
+ //@}\r
+\r
+ /* Enums: */\r
+ /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the Mass\r
+ * Storage device class.\r
+ */\r
+ enum MS_Descriptor_ClassSubclassProtocol_t\r
+ {\r
+ MS_CSCP_MassStorageClass = 0x08, /**< Descriptor Class value indicating that the device or interface\r
+ * belongs to the Mass Storage class.\r
+ */\r
+ MS_CSCP_SCSITransparentSubclass = 0x06, /**< Descriptor Subclass value indicating that the device or interface\r
+ * belongs to the SCSI Transparent Command Set subclass of the Mass\r
+ * storage class.\r
+ */\r
+ MS_CSCP_BulkOnlyTransportProtocol = 0x50, /**< Descriptor Protocol value indicating that the device or interface\r
+ * belongs to the Bulk Only Transport protocol of the Mass Storage class.\r
+ */\r
+ };\r
+\r
+ /** Enum for the Mass Storage class specific control requests that can be issued by the USB bus host. */\r
+ enum MS_ClassRequests_t\r
+ {\r
+ MS_REQ_GetMaxLUN = 0xFE, /**< Mass Storage class-specific request to retrieve the total number of Logical\r
+ * Units (drives) in the SCSI device.\r
+ */\r
+ MS_REQ_MassStorageReset = 0xFF, /**< Mass Storage class-specific request to reset the Mass Storage interface,\r
+ * ready for the next command.\r
+ */\r
+ };\r
+\r
+ /** Enum for the possible command status wrapper return status codes. */\r
+ enum MS_CommandStatusCodes_t\r
+ {\r
+ MS_SCSI_COMMAND_Pass = 0, /**< Command completed with no error */\r
+ MS_SCSI_COMMAND_Fail = 1, /**< Command failed to complete - host may check the exact error via a\r
+ * SCSI REQUEST SENSE command.\r
+ */\r
+ MS_SCSI_COMMAND_PhaseError = 2, /**< Command failed due to being invalid in the current phase. */\r
+ };\r
+\r
+ /* Type Defines: */\r
+ /** \brief Mass Storage Class Command Block Wrapper.\r
+ *\r
+ * Type define for a Command Block Wrapper, used in the Mass Storage Bulk-Only Transport protocol.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t Signature; /**< Command block signature, must be \ref MS_CBW_SIGNATURE to indicate a valid Command Block. */\r
+ uint32_t Tag; /**< Unique command ID value, to associate a command block wrapper with its command status wrapper. */\r
+ uint32_t DataTransferLength; /**< Length of the optional data portion of the issued command, in bytes. */\r
+ uint8_t Flags; /**< Command block flags, indicating command data direction. */\r
+ uint8_t LUN; /**< Logical Unit number this command is issued to. */\r
+ uint8_t SCSICommandLength; /**< Length of the issued SCSI command within the SCSI command data array. */\r
+ uint8_t SCSICommandData[16]; /**< Issued SCSI command in the Command Block. */\r
+ } ATTR_PACKED MS_CommandBlockWrapper_t;\r
+\r
+ /** \brief Mass Storage Class Command Status Wrapper.\r
+ *\r
+ * Type define for a Command Status Wrapper, used in the Mass Storage Bulk-Only Transport protocol.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t Signature; /**< Status block signature, must be \ref MS_CSW_SIGNATURE to indicate a valid Command Status. */\r
+ uint32_t Tag; /**< Unique command ID value, to associate a command block wrapper with its command status wrapper. */\r
+ uint32_t DataTransferResidue; /**< Number of bytes of data not processed in the SCSI command. */\r
+ uint8_t Status; /**< Status code of the issued command - a value from the \ref MS_CommandStatusCodes_t enum. */\r
+ } ATTR_PACKED MS_CommandStatusWrapper_t;\r
+\r
+ /** \brief Mass Storage Class SCSI Sense Structure\r
+ *\r
+ * Type define for a SCSI Sense structure. Structures of this type are filled out by the\r
+ * device via the \ref MS_Host_RequestSense() function, indicating the current sense data of the\r
+ * device (giving explicit error codes for the last issued command). For details of the\r
+ * structure contents, refer to the SCSI specifications.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t ResponseCode;\r
+\r
+ uint8_t SegmentNumber;\r
+\r
+ unsigned SenseKey : 4;\r
+ unsigned Reserved : 1;\r
+ unsigned ILI : 1;\r
+ unsigned EOM : 1;\r
+ unsigned FileMark : 1;\r
+\r
+ uint8_t Information[4];\r
+ uint8_t AdditionalLength;\r
+ uint8_t CmdSpecificInformation[4];\r
+ uint8_t AdditionalSenseCode;\r
+ uint8_t AdditionalSenseQualifier;\r
+ uint8_t FieldReplaceableUnitCode;\r
+ uint8_t SenseKeySpecific[3];\r
+ } ATTR_PACKED SCSI_Request_Sense_Response_t;\r
+\r
+ /** \brief Mass Storage Class SCSI Inquiry Structure.\r
+ *\r
+ * Type define for a SCSI Inquiry structure. Structures of this type are filled out by the\r
+ * device via the \ref MS_Host_GetInquiryData() function, retrieving the attached device's\r
+ * information.\r
+ *\r
+ * For details of the structure contents, refer to the SCSI specifications.\r
+ */\r
+ typedef struct\r
+ {\r
+ unsigned DeviceType : 5;\r
+ unsigned PeripheralQualifier : 3;\r
+\r
+ unsigned Reserved : 7;\r
+ unsigned Removable : 1;\r
+\r
+ uint8_t Version;\r
+\r
+ unsigned ResponseDataFormat : 4;\r
+ unsigned Reserved2 : 1;\r
+ unsigned NormACA : 1;\r
+ unsigned TrmTsk : 1;\r
+ unsigned AERC : 1;\r
+\r
+ uint8_t AdditionalLength;\r
+ uint8_t Reserved3[2];\r
+\r
+ unsigned SoftReset : 1;\r
+ unsigned CmdQue : 1;\r
+ unsigned Reserved4 : 1;\r
+ unsigned Linked : 1;\r
+ unsigned Sync : 1;\r
+ unsigned WideBus16Bit : 1;\r
+ unsigned WideBus32Bit : 1;\r
+ unsigned RelAddr : 1;\r
+\r
+ uint8_t VendorID[8];\r
+ uint8_t ProductID[16];\r
+ uint8_t RevisionID[4];\r
+ } ATTR_PACKED SCSI_Inquiry_Response_t;\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common definitions and declarations for the library USB Printer Class driver.\r
+ *\r
+ * Common definitions and declarations for the library USB Printer Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassPrinter\r
+ * \defgroup Group_USBClassPrinterCommon Common Class Definitions\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB\r
+ * Printer Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _PRINTER_CLASS_COMMON_H_\r
+#define _PRINTER_CLASS_COMMON_H_\r
+\r
+ /* Includes: */\r
+ #include "../../Core/StdDescriptors.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_PRINTER_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Macros: */\r
+ /** \name Virtual Printer Status Line Masks */\r
+ //@{\r
+ /** Port status mask for a printer device, indicating that an error has *not* occurred. */\r
+ #define PRNT_PORTSTATUS_NOTERROR (1 << 3)\r
+\r
+ /** Port status mask for a printer device, indicating that the device is currently selected. */\r
+ #define PRNT_PORTSTATUS_SELECT (1 << 4)\r
+\r
+ /** Port status mask for a printer device, indicating that the device is currently out of paper. */\r
+ #define PRNT_PORTSTATUS_PAPEREMPTY (1 << 5)\r
+ //@}\r
+\r
+ /* Enums: */\r
+ /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the Printer\r
+ * device class.\r
+ */\r
+ enum PRNT_Descriptor_ClassSubclassProtocol_t\r
+ {\r
+ PRNT_CSCP_PrinterClass = 0x07, /**< Descriptor Class value indicating that the device or interface\r
+ * belongs to the Printer class.\r
+ */\r
+ PRNT_CSCP_PrinterSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or interface\r
+ * belongs to the Printer subclass.\r
+ */\r
+ PRNT_CSCP_BidirectionalProtocol = 0x02, /**< Descriptor Protocol value indicating that the device or interface\r
+ * belongs to the Bidirectional protocol of the Printer class.\r
+ */\r
+ };\r
+\r
+ /** Enum for the Printer class specific control requests that can be issued by the USB bus host. */\r
+ enum PRNT_ClassRequests_t\r
+ {\r
+ PRNT_REQ_GetDeviceID = 0x00, /**< Printer class-specific request to retrieve the Unicode ID\r
+ * string of the device, containing the device's name, manufacturer\r
+ * and supported printer languages.\r
+ */\r
+ PRNT_REQ_GetPortStatus = 0x01, /**< Printer class-specific request to get the current status of the\r
+ * virtual printer port, for device selection and ready states.\r
+ */\r
+ PRNT_REQ_SoftReset = 0x02, /**< Printer class-specific request to reset the device, ready for new\r
+ * printer commands.\r
+ */\r
+ };\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common definitions and declarations for the library USB RNDIS Class driver.\r
+ *\r
+ * Common definitions and declarations for the library USB RNDIS Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassRNDIS\r
+ * \defgroup Group_USBClassRNDISCommon Common Class Definitions\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB\r
+ * RNDIS Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _RNDIS_CLASS_COMMON_H_\r
+#define _RNDIS_CLASS_COMMON_H_\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_CDC_DRIVER\r
+\r
+ /* Includes: */\r
+ #include "../../Core/StdDescriptors.h"\r
+ #include "CDCClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_RNDIS_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Macros: */\r
+ /** Additional error code for RNDIS functions when a device returns a logical command failure. */\r
+ #define RNDIS_ERROR_LOGICAL_CMD_FAILED 0x80\r
+\r
+ /** Implemented RNDIS Version Major. */\r
+ #define REMOTE_NDIS_VERSION_MAJOR 0x01\r
+\r
+ /** Implemented RNDIS Version Minor. */\r
+ #define REMOTE_NDIS_VERSION_MINOR 0x00\r
+\r
+ /** \name RNDIS Message Values */\r
+ //@{\r
+ #define REMOTE_NDIS_PACKET_MSG 0x00000001UL\r
+ #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002UL\r
+ #define REMOTE_NDIS_HALT_MSG 0x00000003UL\r
+ #define REMOTE_NDIS_QUERY_MSG 0x00000004UL\r
+ #define REMOTE_NDIS_SET_MSG 0x00000005UL\r
+ #define REMOTE_NDIS_RESET_MSG 0x00000006UL\r
+ #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007UL\r
+ #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008UL\r
+ //@}\r
+\r
+ /** \name RNDIS Response Values */\r
+ //@{\r
+ #define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002UL\r
+ #define REMOTE_NDIS_QUERY_CMPLT 0x80000004UL\r
+ #define REMOTE_NDIS_SET_CMPLT 0x80000005UL\r
+ #define REMOTE_NDIS_RESET_CMPLT 0x80000006UL\r
+ #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008UL\r
+ //@}\r
+\r
+ /** \name RNDIS Status Values */\r
+ //@{\r
+ #define REMOTE_NDIS_STATUS_SUCCESS 0x00000000UL\r
+ #define REMOTE_NDIS_STATUS_FAILURE 0xC0000001UL\r
+ #define REMOTE_NDIS_STATUS_INVALID_DATA 0xC0010015UL\r
+ #define REMOTE_NDIS_STATUS_NOT_SUPPORTED 0xC00000BBUL\r
+ #define REMOTE_NDIS_STATUS_MEDIA_CONNECT 0x4001000BUL\r
+ #define REMOTE_NDIS_STATUS_MEDIA_DISCONNECT 0x4001000CUL\r
+ //@}\r
+\r
+ /** \name RNDIS Media States */\r
+ //@{\r
+ #define REMOTE_NDIS_MEDIA_STATE_CONNECTED 0x00000000UL\r
+ #define REMOTE_NDIS_MEDIA_STATE_DISCONNECTED 0x00000001UL\r
+ //@}\r
+\r
+ /** \name RNDIS Media Types */\r
+ //@{\r
+ #define REMOTE_NDIS_MEDIUM_802_3 0x00000000UL\r
+ //@}\r
+\r
+ /** \name RNDIS Connection Types */\r
+ //@{\r
+ #define REMOTE_NDIS_DF_CONNECTIONLESS 0x00000001UL\r
+ #define REMOTE_NDIS_DF_CONNECTION_ORIENTED 0x00000002UL\r
+ //@}\r
+\r
+ /** \name RNDIS Packet Types */\r
+ //@{\r
+ #define REMOTE_NDIS_PACKET_DIRECTED 0x00000001UL\r
+ #define REMOTE_NDIS_PACKET_MULTICAST 0x00000002UL\r
+ #define REMOTE_NDIS_PACKET_ALL_MULTICAST 0x00000004UL\r
+ #define REMOTE_NDIS_PACKET_BROADCAST 0x00000008UL\r
+ #define REMOTE_NDIS_PACKET_SOURCE_ROUTING 0x00000010UL\r
+ #define REMOTE_NDIS_PACKET_PROMISCUOUS 0x00000020UL\r
+ #define REMOTE_NDIS_PACKET_SMT 0x00000040UL\r
+ #define REMOTE_NDIS_PACKET_ALL_LOCAL 0x00000080UL\r
+ #define REMOTE_NDIS_PACKET_GROUP 0x00001000UL\r
+ #define REMOTE_NDIS_PACKET_ALL_FUNCTIONAL 0x00002000UL\r
+ #define REMOTE_NDIS_PACKET_FUNCTIONAL 0x00004000UL\r
+ #define REMOTE_NDIS_PACKET_MAC_FRAME 0x00008000UL\r
+ //@}\r
+\r
+ /** \name RNDIS OID Values */\r
+ //@{\r
+ #define OID_GEN_SUPPORTED_LIST 0x00010101UL\r
+ #define OID_GEN_HARDWARE_STATUS 0x00010102UL\r
+ #define OID_GEN_MEDIA_SUPPORTED 0x00010103UL\r
+ #define OID_GEN_MEDIA_IN_USE 0x00010104UL\r
+ #define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106UL\r
+ #define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111UL\r
+ #define OID_GEN_LINK_SPEED 0x00010107UL\r
+ #define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010AUL\r
+ #define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010BUL\r
+ #define OID_GEN_VENDOR_ID 0x0001010CUL\r
+ #define OID_GEN_VENDOR_DESCRIPTION 0x0001010DUL\r
+ #define OID_GEN_CURRENT_PACKET_FILTER 0x0001010EUL\r
+ #define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111UL\r
+ #define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114UL\r
+ #define OID_GEN_PHYSICAL_MEDIUM 0x00010202UL\r
+ #define OID_GEN_XMIT_OK 0x00020101UL\r
+ #define OID_GEN_RCV_OK 0x00020102UL\r
+ #define OID_GEN_XMIT_ERROR 0x00020103UL\r
+ #define OID_GEN_RCV_ERROR 0x00020104UL\r
+ #define OID_GEN_RCV_NO_BUFFER 0x00020105UL\r
+ #define OID_802_3_PERMANENT_ADDRESS 0x01010101UL\r
+ #define OID_802_3_CURRENT_ADDRESS 0x01010102UL\r
+ #define OID_802_3_MULTICAST_LIST 0x01010103UL\r
+ #define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104UL\r
+ #define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101UL\r
+ #define OID_802_3_XMIT_ONE_COLLISION 0x01020102UL\r
+ #define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103UL\r
+ //@}\r
+\r
+ /** Maximum size in bytes of a RNDIS control message which can be sent or received. */\r
+ #define RNDIS_MESSAGE_BUFFER_SIZE 128\r
+\r
+ /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard. */\r
+ #define ETHERNET_FRAME_SIZE_MAX 1500\r
+\r
+ /* Enums: */\r
+ /** Enum for the RNDIS class specific control requests that can be issued by the USB bus host. */\r
+ enum RNDIS_ClassRequests_t\r
+ {\r
+ RNDIS_REQ_SendEncapsulatedCommand = 0x00, /**< RNDIS request to issue a host-to-device NDIS command. */\r
+ RNDIS_REQ_GetEncapsulatedResponse = 0x01, /**< RNDIS request to issue a device-to-host NDIS response. */\r
+ };\r
+\r
+ /** Enum for the possible NDIS adapter states. */\r
+ enum RNDIS_States_t\r
+ {\r
+ RNDIS_Uninitialized = 0, /**< Adapter currently uninitialized. */\r
+ RNDIS_Initialized = 1, /**< Adapter currently initialized but not ready for data transfers. */\r
+ RNDIS_Data_Initialized = 2, /**< Adapter currently initialized and ready for data transfers. */\r
+ };\r
+\r
+ /** Enum for the RNDIS class specific notification requests that can be issued by a RNDIS device to a host. */\r
+ enum RNDIS_ClassNotifications_t\r
+ {\r
+ RNDIS_NOTIF_ResponseAvailable = 0x01, /**< Notification request value for a RNDIS Response Available notification. */\r
+ };\r
+\r
+ /** Enum for the NDIS hardware states. */\r
+ enum NDIS_Hardware_Status_t\r
+ {\r
+ NDIS_HardwareStatus_Ready, /**< Hardware Ready to accept commands from the host. */\r
+ NDIS_HardwareStatus_Initializing, /**< Hardware busy initializing. */\r
+ NDIS_HardwareStatus_Reset, /**< Hardware reset. */\r
+ NDIS_HardwareStatus_Closing, /**< Hardware currently closing. */\r
+ NDIS_HardwareStatus_NotReady /**< Hardware not ready to accept commands from the host. */\r
+ };\r
+\r
+ /* Type Defines: */\r
+ /** \brief MAC Address Structure.\r
+ *\r
+ * Type define for a physical MAC address of a device on a network.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t Octets[6]; /**< Individual bytes of a MAC address */\r
+ } ATTR_PACKED MAC_Address_t;\r
+\r
+ /** \brief RNDIS Common Message Header Structure.\r
+ *\r
+ * Type define for a RNDIS message header, sent before RNDIS messages.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t MessageType; /**< RNDIS message type, a \c REMOTE_NDIS_*_MSG constant */\r
+ uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */\r
+ } ATTR_PACKED RNDIS_Message_Header_t;\r
+\r
+ /** \brief RNDIS Message Structure.\r
+ *\r
+ * Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t MessageType;\r
+ uint32_t MessageLength;\r
+ uint32_t DataOffset;\r
+ uint32_t DataLength;\r
+ uint32_t OOBDataOffset;\r
+ uint32_t OOBDataLength;\r
+ uint32_t NumOOBDataElements;\r
+ uint32_t PerPacketInfoOffset;\r
+ uint32_t PerPacketInfoLength;\r
+ uint32_t VcHandle;\r
+ uint32_t Reserved;\r
+ } ATTR_PACKED RNDIS_Packet_Message_t;\r
+\r
+ /** \brief RNDIS Initialization Message Structure.\r
+ *\r
+ * Type define for a RNDIS Initialize command message.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t MessageType;\r
+ uint32_t MessageLength;\r
+ uint32_t RequestId;\r
+\r
+ uint32_t MajorVersion;\r
+ uint32_t MinorVersion;\r
+ uint32_t MaxTransferSize;\r
+ } ATTR_PACKED RNDIS_Initialize_Message_t;\r
+\r
+ /** \brief RNDIS Initialize Complete Message Structure.\r
+ *\r
+ * Type define for a RNDIS Initialize Complete response message.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t MessageType;\r
+ uint32_t MessageLength;\r
+ uint32_t RequestId;\r
+ uint32_t Status;\r
+\r
+ uint32_t MajorVersion;\r
+ uint32_t MinorVersion;\r
+ uint32_t DeviceFlags;\r
+ uint32_t Medium;\r
+ uint32_t MaxPacketsPerTransfer;\r
+ uint32_t MaxTransferSize;\r
+ uint32_t PacketAlignmentFactor;\r
+ uint32_t AFListOffset;\r
+ uint32_t AFListSize;\r
+ } ATTR_PACKED RNDIS_Initialize_Complete_t;\r
+\r
+ /** \brief RNDIS Keep Alive Message Structure.\r
+ *\r
+ * Type define for a RNDIS Keep Alive command message.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t MessageType;\r
+ uint32_t MessageLength;\r
+ uint32_t RequestId;\r
+ } ATTR_PACKED RNDIS_KeepAlive_Message_t;\r
+\r
+ /** \brief RNDIS Keep Alive Complete Message Structure.\r
+ *\r
+ * Type define for a RNDIS Keep Alive Complete response message.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t MessageType;\r
+ uint32_t MessageLength;\r
+ uint32_t RequestId;\r
+ uint32_t Status;\r
+ } ATTR_PACKED RNDIS_KeepAlive_Complete_t;\r
+\r
+ /** \brief RNDIS Reset Complete Message Structure.\r
+ *\r
+ * Type define for a RNDIS Reset Complete response message.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t MessageType;\r
+ uint32_t MessageLength;\r
+ uint32_t Status;\r
+\r
+ uint32_t AddressingReset;\r
+ } ATTR_PACKED RNDIS_Reset_Complete_t;\r
+\r
+ /** \brief RNDIS OID Property Set Message Structure.\r
+ *\r
+ * Type define for a RNDIS OID Property Set command message.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t MessageType;\r
+ uint32_t MessageLength;\r
+ uint32_t RequestId;\r
+\r
+ uint32_t Oid;\r
+ uint32_t InformationBufferLength;\r
+ uint32_t InformationBufferOffset;\r
+ uint32_t DeviceVcHandle;\r
+ } ATTR_PACKED RNDIS_Set_Message_t;\r
+\r
+ /** \brief RNDIS OID Property Set Complete Message Structure.\r
+ *\r
+ * Type define for a RNDIS OID Property Set Complete response message.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t MessageType;\r
+ uint32_t MessageLength;\r
+ uint32_t RequestId;\r
+ uint32_t Status;\r
+ } ATTR_PACKED RNDIS_Set_Complete_t;\r
+\r
+ /** \brief RNDIS OID Property Query Message Structure.\r
+ *\r
+ * Type define for a RNDIS OID Property Query command message.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t MessageType;\r
+ uint32_t MessageLength;\r
+ uint32_t RequestId;\r
+\r
+ uint32_t Oid;\r
+ uint32_t InformationBufferLength;\r
+ uint32_t InformationBufferOffset;\r
+ uint32_t DeviceVcHandle;\r
+ } ATTR_PACKED RNDIS_Query_Message_t;\r
+\r
+ /** \brief RNDIS OID Property Query Complete Message Structure.\r
+ *\r
+ * Type define for a RNDIS OID Property Query Complete response message.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t MessageType;\r
+ uint32_t MessageLength;\r
+ uint32_t RequestId;\r
+ uint32_t Status;\r
+\r
+ uint32_t InformationBufferLength;\r
+ uint32_t InformationBufferOffset;\r
+ } ATTR_PACKED RNDIS_Query_Complete_t;\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common definitions and declarations for the library USB Still Image Class driver.\r
+ *\r
+ * Common definitions and declarations for the library USB Still Image Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassSI\r
+ * \defgroup Group_USBClassSICommon Common Class Definitions\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB\r
+ * Still Image Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _SI_CLASS_COMMON_H_\r
+#define _SI_CLASS_COMMON_H_\r
+\r
+ /* Includes: */\r
+ #include "../../Core/StdDescriptors.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_SI_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Macros: */\r
+ /** Length in bytes of a given Unicode string's character length.\r
+ *\r
+ * \param[in] Chars Total number of Unicode characters in the string.\r
+ *\r
+ * \return Number of bytes of the given unicode string.\r
+ */\r
+ #define UNICODE_STRING_LENGTH(Chars) ((Chars) << 1)\r
+\r
+ /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for\r
+ * a command container.\r
+ *\r
+ * \param[in] Params Number of parameters which are to be sent in the \c Param field of the container.\r
+ */\r
+ #define PIMA_COMMAND_SIZE(Params) ((sizeof(PIMA_Container_t) - 12) + ((Params) * sizeof(uint32_t)))\r
+\r
+ /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for\r
+ * a data container.\r
+ *\r
+ * \param[in] DataLen Length in bytes of the data in the container.\r
+ */\r
+ #define PIMA_DATA_SIZE(DataLen) ((sizeof(PIMA_Container_t) - 12) + (DataLen))\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible PIMA contains types. */\r
+ enum PIMA_Container_Types_t\r
+ {\r
+ PIMA_CONTAINER_Undefined = 0, /**< Undefined container type. */\r
+ PIMA_CONTAINER_CommandBlock = 1, /**< Command Block container type. */\r
+ PIMA_CONTAINER_DataBlock = 2, /**< Data Block container type. */\r
+ PIMA_CONTAINER_ResponseBlock = 3, /**< Response container type. */\r
+ PIMA_CONTAINER_EventBlock = 4, /**< Event Block container type. */\r
+ };\r
+\r
+ /* Enums: */\r
+ /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors relating to the\r
+ * Still Image device class.\r
+ */\r
+ enum SI_Descriptor_ClassSubclassProtocol_t\r
+ {\r
+ SI_CSCP_StillImageClass = 0x06, /**< Descriptor Class value indicating that the device or interface\r
+ * belongs to the Still Image class.\r
+ */\r
+ SI_CSCP_StillImageSubclass = 0x01, /**< Descriptor Subclass value indicating that the device or interface\r
+ * belongs to the Still Image subclass.\r
+ */\r
+ SI_CSCP_BulkOnlyProtocol = 0x01, /**< Descriptor Protocol value indicating that the device or interface\r
+ * belongs to the Bulk Only Transport protocol of the Still Image class.\r
+ */\r
+ };\r
+\r
+ /** Enums for the possible status codes of a returned Response Block from an attached PIMA compliant Still Image device. */\r
+ enum PIMA_ResponseCodes_t\r
+ {\r
+ PIMA_RESPONSE_OK = 1, /**< Response code indicating no error in the issued command. */\r
+ PIMA_RESPONSE_GeneralError = 2, /**< Response code indicating a general error while processing the\r
+ * issued command.\r
+ */\r
+ PIMA_RESPONSE_SessionNotOpen = 3, /**< Response code indicating that the sent command requires an open\r
+ * session before being issued.\r
+ */\r
+ PIMA_RESPONSE_InvalidTransaction = 4, /**< Response code indicating an invalid transaction occurred. */\r
+ PIMA_RESPONSE_OperationNotSupported = 5, /**< Response code indicating that the issued command is not supported\r
+ * by the attached device.\r
+ */\r
+ PIMA_RESPONSE_ParameterNotSupported = 6, /**< Response code indicating that one or more of the issued command's\r
+ * parameters are not supported by the device.\r
+ */\r
+ };\r
+\r
+ /* Type Defines: */\r
+ /** \brief PIMA Still Image Device Command/Response Container.\r
+ *\r
+ * Type define for a PIMA container, use to send commands and receive responses to and from an\r
+ * attached Still Image device.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t DataLength; /**< Length of the container and data, in bytes. */\r
+ uint16_t Type; /**< Container type, a value from the \ref PIMA_Container_Types_t enum. */\r
+ uint16_t Code; /**< Command, event or response code of the container. */\r
+ uint32_t TransactionID; /**< Unique container ID to link blocks together. */\r
+ uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only). */\r
+ } ATTR_PACKED PIMA_Container_t;\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#define __INCLUDE_FROM_AUDIO_DRIVER\r
+#define __INCLUDE_FROM_AUDIO_DEVICE_C\r
+#include "AudioClassDevice.h"\r
+\r
+void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+{\r
+ if (!(Endpoint_IsSETUPReceived()))\r
+ return;\r
+\r
+ if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_INTERFACE)\r
+ {\r
+ uint8_t InterfaceIndex = (USB_ControlRequest.wIndex & 0xFF);\r
+ \r
+ if ((InterfaceIndex != AudioInterfaceInfo->Config.ControlInterfaceNumber) &&\r
+ (InterfaceIndex != AudioInterfaceInfo->Config.StreamingInterfaceNumber))\r
+ {\r
+ return;\r
+ }\r
+ }\r
+ else if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_ENDPOINT)\r
+ {\r
+ uint8_t EndpointAddress = (USB_ControlRequest.wIndex & 0xFF);\r
+ \r
+ if ((EndpointAddress != AudioInterfaceInfo->Config.DataINEndpoint.Address) &&\r
+ (EndpointAddress != AudioInterfaceInfo->Config.DataOUTEndpoint.Address))\r
+ {\r
+ return;\r
+ }\r
+ }\r
+\r
+ switch (USB_ControlRequest.bRequest)\r
+ {\r
+ case REQ_SetInterface:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_ClearStatusStage();\r
+\r
+ AudioInterfaceInfo->State.InterfaceEnabled = ((USB_ControlRequest.wValue & 0xFF) != 0);\r
+ EVENT_Audio_Device_StreamStartStop(AudioInterfaceInfo);\r
+ }\r
+\r
+ break;\r
+ case AUDIO_REQ_GetStatus:\r
+ if ((USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE)) ||\r
+ (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_ENDPOINT)))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_ClearStatusStage();\r
+ }\r
+\r
+ break;\r
+ case AUDIO_REQ_SetCurrent:\r
+ case AUDIO_REQ_SetMinimum:\r
+ case AUDIO_REQ_SetMaximum:\r
+ case AUDIO_REQ_SetResolution:\r
+ if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_ENDPOINT)\r
+ {\r
+ uint8_t EndpointProperty = USB_ControlRequest.bRequest;\r
+ uint8_t EndpointAddress = (uint8_t)USB_ControlRequest.wIndex;\r
+ uint8_t EndpointControl = (USB_ControlRequest.wValue >> 8);\r
+\r
+ if (CALLBACK_Audio_Device_GetSetEndpointProperty(AudioInterfaceInfo, EndpointProperty, EndpointAddress,\r
+ EndpointControl, NULL, NULL))\r
+ {\r
+ uint16_t ValueLength = USB_ControlRequest.wLength;\r
+ uint8_t Value[ValueLength];\r
+\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_Read_Control_Stream_LE(Value, ValueLength);\r
+ Endpoint_ClearIN();\r
+\r
+ CALLBACK_Audio_Device_GetSetEndpointProperty(AudioInterfaceInfo, EndpointProperty, EndpointAddress,\r
+ EndpointControl, &ValueLength, Value);\r
+ }\r
+ }\r
+ else if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_INTERFACE)\r
+ {\r
+ uint8_t Property = USB_ControlRequest.bRequest;\r
+ uint8_t Entity = (USB_ControlRequest.wIndex >> 8);\r
+ uint16_t Parameter = USB_ControlRequest.wValue;\r
+\r
+ if (CALLBACK_Audio_Device_GetSetInterfaceProperty(AudioInterfaceInfo, Property, Entity,\r
+ Parameter, NULL, NULL))\r
+ {\r
+ uint16_t ValueLength = USB_ControlRequest.wLength;\r
+ uint8_t Value[ValueLength];\r
+\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_Read_Control_Stream_LE(Value, ValueLength);\r
+ Endpoint_ClearIN();\r
+\r
+ CALLBACK_Audio_Device_GetSetInterfaceProperty(AudioInterfaceInfo, Property, Entity,\r
+ Parameter, &ValueLength, Value);\r
+ }\r
+ }\r
+\r
+ break;\r
+ case AUDIO_REQ_GetCurrent:\r
+ case AUDIO_REQ_GetMinimum:\r
+ case AUDIO_REQ_GetMaximum:\r
+ case AUDIO_REQ_GetResolution:\r
+ if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_ENDPOINT)\r
+ {\r
+ uint8_t EndpointProperty = USB_ControlRequest.bRequest;\r
+ uint8_t EndpointAddress = (uint8_t)USB_ControlRequest.wIndex;\r
+ uint8_t EndpointControl = (USB_ControlRequest.wValue >> 8);\r
+ uint16_t ValueLength = USB_ControlRequest.wLength;\r
+ uint8_t Value[ValueLength];\r
+\r
+ if (CALLBACK_Audio_Device_GetSetEndpointProperty(AudioInterfaceInfo, EndpointProperty, EndpointAddress,\r
+ EndpointControl, &ValueLength, Value))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_Write_Control_Stream_LE(Value, ValueLength);\r
+ Endpoint_ClearOUT();\r
+ }\r
+ }\r
+ else if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT) == REQREC_INTERFACE)\r
+ {\r
+ uint8_t Property = USB_ControlRequest.bRequest;\r
+ uint8_t Entity = (USB_ControlRequest.wIndex >> 8);\r
+ uint16_t Parameter = USB_ControlRequest.wValue;\r
+ uint16_t ValueLength = USB_ControlRequest.wLength;\r
+ uint8_t Value[ValueLength];\r
+\r
+ if (CALLBACK_Audio_Device_GetSetInterfaceProperty(AudioInterfaceInfo, Property, Entity,\r
+ Parameter, &ValueLength, Value))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_Write_Control_Stream_LE(Value, ValueLength);\r
+ Endpoint_ClearOUT();\r
+ }\r
+ }\r
+\r
+ break;\r
+ }\r
+}\r
+\r
+bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+{\r
+ memset(&AudioInterfaceInfo->State, 0x00, sizeof(AudioInterfaceInfo->State));\r
+ \r
+ AudioInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_ISOCHRONOUS;\r
+ AudioInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_ISOCHRONOUS;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&AudioInterfaceInfo->Config.DataINEndpoint, 1)))\r
+ return false;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&AudioInterfaceInfo->Config.DataOUTEndpoint, 1)))\r
+ return false;\r
+\r
+ return true;\r
+}\r
+\r
+// cppcheck-suppress unusedFunction\r
+void Audio_Device_Event_Stub(void)\r
+{\r
+\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Device mode driver for the library USB Audio 1.0 Class driver.\r
+ *\r
+ * Device mode driver for the library USB Audio 1.0 Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassAudio\r
+ * \defgroup Group_USBClassAudioDevice Audio 1.0 Class Device Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Device/AudioClassDevice.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Device Mode USB Class driver framework interface, for the Audio 1.0 USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _AUDIO_CLASS_DEVICE_H_\r
+#define _AUDIO_CLASS_DEVICE_H_\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/AudioClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_AUDIO_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** \brief Audio Class Device Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made for each Audio interface\r
+ * within the user application, and passed to each of the Audio class driver functions as the\r
+ * \c AudioInterfaceInfo parameter. This stores each Audio interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ uint8_t ControlInterfaceNumber; /**< Index of the Audio Control interface within the device this\r
+ * structure controls.\r
+ */\r
+ uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this\r
+ * structure controls.\r
+ */\r
+\r
+ USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */\r
+ USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ bool InterfaceEnabled; /**< Set and cleared by the class driver to indicate if the host has enabled the streaming endpoints\r
+ * of the Audio Streaming interface.\r
+ */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * are reset to their defaults when the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_Audio_Device_t;\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures the endpoints of a given Audio interface, ready for use. This should be linked to the library\r
+ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing the\r
+ * given Audio interface is selected.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ *\r
+ * \return Boolean \c true if the endpoints were successfully configured, \c false otherwise.\r
+ */\r
+ bool Audio_Device_ConfigureEndpoints(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Processes incoming control requests from the host, that are directed to the given Audio class interface. This should be\r
+ * linked to the library \ref EVENT_USB_Device_ControlRequest() event.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ */\r
+ void Audio_Device_ProcessControlRequest(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Audio class driver callback for the setting and retrieval of streaming endpoint properties. This callback must be implemented\r
+ * in the user application to handle property manipulations on streaming audio endpoints.\r
+ *\r
+ * When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for\r
+ * the given endpoint index, and should return as fast as possible. When non-NULL, this value may be altered for GET operations\r
+ * to indicate the size of the retrieved data.\r
+ *\r
+ * \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value\r
+ * of the \c DataLength parameter.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ * \param[in] EndpointProperty Property of the endpoint to get or set, a value from \ref Audio_ClassRequests_t.\r
+ * \param[in] EndpointAddress Address of the streaming endpoint whose property is being referenced.\r
+ * \param[in] EndpointControl Parameter of the endpoint to get or set, a value from \ref Audio_EndpointControls_t.\r
+ * \param[in,out] DataLength For SET operations, the length of the parameter data to set. For GET operations, the maximum\r
+ * length of the retrieved data. When NULL, the function should return whether the given property\r
+ * and parameter is valid for the requested endpoint without reading or modifying the Data buffer.\r
+ * \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where\r
+ * the retrieved data is to be stored for GET operations.\r
+ *\r
+ * \return Boolean \c true if the property GET/SET was successful, \c false otherwise\r
+ */\r
+ bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,\r
+ const uint8_t EndpointProperty,\r
+ const uint8_t EndpointAddress,\r
+ const uint8_t EndpointControl,\r
+ uint16_t* const DataLength,\r
+ uint8_t* Data) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Audio class driver callback for the setting and retrieval of streaming interface properties. This callback must be implemented\r
+ * in the user application to handle property manipulations on streaming audio interfaces.\r
+ *\r
+ * When the DataLength parameter is NULL, this callback should only indicate whether the specified operation is valid for\r
+ * the given entity and should return as fast as possible. When non-NULL, this value may be altered for GET operations\r
+ * to indicate the size of the retrieved data.\r
+ *\r
+ * \note The length of the retrieved data stored into the Data buffer on GET operations should not exceed the initial value\r
+ * of the \c DataLength parameter.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ * \param[in] Property Property of the interface to get or set, a value from \ref Audio_ClassRequests_t.\r
+ * \param[in] EntityAddress Address of the audio entity whose property is being referenced.\r
+ * \param[in] Parameter Parameter of the entity to get or set, specific to each type of entity (see USB Audio specification).\r
+ * \param[in,out] DataLength For SET operations, the length of the parameter data to set. For GET operations, the maximum\r
+ * length of the retrieved data. When NULL, the function should return whether the given property\r
+ * and parameter is valid for the requested endpoint without reading or modifying the Data buffer.\r
+ * \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where\r
+ * the retrieved data is to be stored for GET operations.\r
+ *\r
+ * \return Boolean \c true if the property GET/SET was successful, \c false otherwise\r
+ */\r
+ bool CALLBACK_Audio_Device_GetSetInterfaceProperty(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,\r
+ const uint8_t Property,\r
+ const uint8_t EntityAddress,\r
+ const uint16_t Parameter,\r
+ uint16_t* const DataLength,\r
+ uint8_t* Data) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Audio class driver event for an Audio Stream start/stop change. This event fires each time the device receives a stream enable or\r
+ * disable control request from the host, to start and stop the audio stream. The current state of the stream can be determined by the\r
+ * State.InterfaceEnabled value inside the Audio interface structure passed as a parameter.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ */\r
+ void EVENT_Audio_Device_StreamStartStop(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo);\r
+\r
+ /* Inline Functions: */\r
+ /** General management task for a given Audio class interface, required for the correct operation of the interface. This should\r
+ * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ */\r
+ static inline void Audio_Device_USBTask(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline void Audio_Device_USBTask(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ {\r
+ (void)AudioInterfaceInfo;\r
+ }\r
+\r
+ /** Determines if the given audio interface is ready for a sample to be read from it, and selects the streaming\r
+ * OUT endpoint ready for reading.\r
+ *\r
+ * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or\r
+ * the call will fail.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ *\r
+ * \return Boolean \c true if the given Audio interface has a sample to be read, \c false otherwise.\r
+ */\r
+ static inline bool Audio_Device_IsSampleReceived(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline bool Audio_Device_IsSampleReceived(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ {\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(AudioInterfaceInfo->State.InterfaceEnabled))\r
+ return false;\r
+\r
+ Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataOUTEndpoint.Address);\r
+ return Endpoint_IsOUTReceived();\r
+ }\r
+\r
+ /** Determines if the given audio interface is ready to accept the next sample to be written to it, and selects\r
+ * the streaming IN endpoint ready for writing.\r
+ *\r
+ * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or\r
+ * the call will fail.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ *\r
+ * \return Boolean \c true if the given Audio interface is ready to accept the next sample, \c false otherwise.\r
+ */\r
+ static inline bool Audio_Device_IsReadyForNextSample(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline bool Audio_Device_IsReadyForNextSample(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ {\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(AudioInterfaceInfo->State.InterfaceEnabled))\r
+ return false;\r
+\r
+ Endpoint_SelectEndpoint(AudioInterfaceInfo->Config.DataINEndpoint.Address);\r
+ return Endpoint_IsINReady();\r
+ }\r
+\r
+ /** Reads the next 8-bit audio sample from the current audio interface.\r
+ *\r
+ * \pre This should be preceded immediately by a call to the \ref Audio_Device_IsSampleReceived() function to ensure\r
+ * that the correct endpoint is selected and ready for data.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ *\r
+ * \return Signed 8-bit audio sample from the audio interface.\r
+ */\r
+ static inline int8_t Audio_Device_ReadSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline int8_t Audio_Device_ReadSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ {\r
+ int8_t Sample;\r
+\r
+ (void)AudioInterfaceInfo;\r
+\r
+ Sample = Endpoint_Read_8();\r
+\r
+ if (!(Endpoint_BytesInEndpoint()))\r
+ Endpoint_ClearOUT();\r
+\r
+ return Sample;\r
+ }\r
+\r
+ /** Reads the next 16-bit audio sample from the current audio interface.\r
+ *\r
+ * \pre This should be preceded immediately by a call to the \ref Audio_Device_IsSampleReceived() function to ensure\r
+ * that the correct endpoint is selected and ready for data.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ *\r
+ * \return Signed 16-bit audio sample from the audio interface.\r
+ */\r
+ static inline int16_t Audio_Device_ReadSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline int16_t Audio_Device_ReadSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ {\r
+ int16_t Sample;\r
+\r
+ (void)AudioInterfaceInfo;\r
+\r
+ Sample = (int16_t)Endpoint_Read_16_LE();\r
+\r
+ if (!(Endpoint_BytesInEndpoint()))\r
+ Endpoint_ClearOUT();\r
+\r
+ return Sample;\r
+ }\r
+\r
+ /** Reads the next 24-bit audio sample from the current audio interface.\r
+ *\r
+ * \pre This should be preceded immediately by a call to the \ref Audio_Device_IsSampleReceived() function to ensure\r
+ * that the correct endpoint is selected and ready for data.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ *\r
+ * \return Signed 24-bit audio sample from the audio interface.\r
+ */\r
+ static inline int32_t Audio_Device_ReadSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline int32_t Audio_Device_ReadSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ {\r
+ int32_t Sample;\r
+\r
+ (void)AudioInterfaceInfo;\r
+\r
+ Sample = (((uint32_t)Endpoint_Read_8() << 16) | Endpoint_Read_16_LE());\r
+\r
+ if (!(Endpoint_BytesInEndpoint()))\r
+ Endpoint_ClearOUT();\r
+\r
+ return Sample;\r
+ }\r
+\r
+ /** Writes the next 8-bit audio sample to the current audio interface.\r
+ *\r
+ * \pre This should be preceded immediately by a call to the \ref Audio_Device_IsReadyForNextSample() function to\r
+ * ensure that the correct endpoint is selected and ready for data.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ * \param[in] Sample Signed 8-bit audio sample.\r
+ */\r
+ static inline void Audio_Device_WriteSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,\r
+ const int8_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline void Audio_Device_WriteSample8(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,\r
+ const int8_t Sample)\r
+ {\r
+ Endpoint_Write_8(Sample);\r
+\r
+ if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpoint.Size)\r
+ Endpoint_ClearIN();\r
+ }\r
+\r
+ /** Writes the next 16-bit audio sample to the current audio interface.\r
+ *\r
+ * \pre This should be preceded immediately by a call to the \ref Audio_Device_IsReadyForNextSample() function to\r
+ * ensure that the correct endpoint is selected and ready for data.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ * \param[in] Sample Signed 16-bit audio sample.\r
+ */\r
+ static inline void Audio_Device_WriteSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,\r
+ const int16_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline void Audio_Device_WriteSample16(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,\r
+ const int16_t Sample)\r
+ {\r
+ Endpoint_Write_16_LE(Sample);\r
+\r
+ if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpoint.Size)\r
+ Endpoint_ClearIN();\r
+ }\r
+\r
+ /** Writes the next 24-bit audio sample to the current audio interface.\r
+ *\r
+ * \pre This should be preceded immediately by a call to the \ref Audio_Device_IsReadyForNextSample() function to\r
+ * ensure that the correct endpoint is selected and ready for data.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ * \param[in] Sample Signed 24-bit audio sample.\r
+ */\r
+ static inline void Audio_Device_WriteSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,\r
+ const int32_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline void Audio_Device_WriteSample24(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo,\r
+ const int32_t Sample)\r
+ {\r
+ Endpoint_Write_16_LE(Sample);\r
+ Endpoint_Write_8(Sample >> 16);\r
+\r
+ if (Endpoint_BytesInEndpoint() == AudioInterfaceInfo->Config.DataINEndpoint.Size)\r
+ Endpoint_ClearIN();\r
+ }\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_AUDIO_DEVICE_C)\r
+ void Audio_Device_Event_Stub(void) ATTR_CONST;\r
+\r
+ void EVENT_Audio_Device_StreamStartStop(USB_ClassInfo_Audio_Device_t* const AudioInterfaceInfo)\r
+ ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(Audio_Device_Event_Stub);\r
+ #endif\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#define __INCLUDE_FROM_CDC_DRIVER\r
+#define __INCLUDE_FROM_CDC_DEVICE_C\r
+#include "CDCClassDevice.h"\r
+\r
+void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
+{\r
+ if (!(Endpoint_IsSETUPReceived()))\r
+ return;\r
+\r
+ if (USB_ControlRequest.wIndex != CDCInterfaceInfo->Config.ControlInterfaceNumber)\r
+ return;\r
+\r
+ switch (USB_ControlRequest.bRequest)\r
+ {\r
+ case CDC_REQ_GetLineEncoding:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+\r
+ while (!(Endpoint_IsINReady()));\r
+\r
+ Endpoint_Write_32_LE(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS);\r
+ Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.CharFormat);\r
+ Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.ParityType);\r
+ Endpoint_Write_8(CDCInterfaceInfo->State.LineEncoding.DataBits);\r
+\r
+ Endpoint_ClearIN();\r
+ Endpoint_ClearStatusStage();\r
+ }\r
+\r
+ break;\r
+ case CDC_REQ_SetLineEncoding:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+\r
+ while (!(Endpoint_IsOUTReceived()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return;\r
+ }\r
+ \r
+ CDCInterfaceInfo->State.LineEncoding.BaudRateBPS = Endpoint_Read_32_LE();\r
+ CDCInterfaceInfo->State.LineEncoding.CharFormat = Endpoint_Read_8();\r
+ CDCInterfaceInfo->State.LineEncoding.ParityType = Endpoint_Read_8();\r
+ CDCInterfaceInfo->State.LineEncoding.DataBits = Endpoint_Read_8();\r
+\r
+ Endpoint_ClearOUT();\r
+ Endpoint_ClearStatusStage();\r
+\r
+ EVENT_CDC_Device_LineEncodingChanged(CDCInterfaceInfo);\r
+ }\r
+\r
+ break;\r
+ case CDC_REQ_SetControlLineState:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_ClearStatusStage();\r
+\r
+ CDCInterfaceInfo->State.ControlLineStates.HostToDevice = USB_ControlRequest.wValue;\r
+\r
+ EVENT_CDC_Device_ControLineStateChanged(CDCInterfaceInfo);\r
+ }\r
+\r
+ break;\r
+ case CDC_REQ_SendBreak:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_ClearStatusStage();\r
+\r
+ EVENT_CDC_Device_BreakSent(CDCInterfaceInfo, (uint8_t)USB_ControlRequest.wValue);\r
+ }\r
+\r
+ break;\r
+ }\r
+}\r
+\r
+bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
+{\r
+ memset(&CDCInterfaceInfo->State, 0x00, sizeof(CDCInterfaceInfo->State));\r
+\r
+ CDCInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_BULK;\r
+ CDCInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK;\r
+ CDCInterfaceInfo->Config.NotificationEndpoint.Type = EP_TYPE_INTERRUPT;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&CDCInterfaceInfo->Config.DataINEndpoint, 1)))\r
+ return false;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&CDCInterfaceInfo->Config.DataOUTEndpoint, 1)))\r
+ return false;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&CDCInterfaceInfo->Config.NotificationEndpoint, 1)))\r
+ return false;\r
+\r
+ return true;\r
+}\r
+\r
+void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
+{\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))\r
+ return;\r
+\r
+ #if !defined(NO_CLASS_DRIVER_AUTOFLUSH)\r
+ CDC_Device_Flush(CDCInterfaceInfo);\r
+ #endif\r
+}\r
+\r
+uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,\r
+ const char* const String)\r
+{\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))\r
+ return ENDPOINT_RWSTREAM_DeviceDisconnected;\r
+\r
+ Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address);\r
+ return Endpoint_Write_Stream_LE(String, strlen(String), NULL);\r
+}\r
+\r
+uint8_t CDC_Device_SendData(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,\r
+ const char* const Buffer,\r
+ const uint16_t Length)\r
+{\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))\r
+ return ENDPOINT_RWSTREAM_DeviceDisconnected;\r
+\r
+ Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address);\r
+ return Endpoint_Write_Stream_LE(Buffer, Length, NULL);\r
+}\r
+\r
+uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,\r
+ const uint8_t Data)\r
+{\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))\r
+ return ENDPOINT_RWSTREAM_DeviceDisconnected;\r
+\r
+ Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address);\r
+\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ {\r
+ Endpoint_ClearIN();\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)\r
+ return ErrorCode;\r
+ }\r
+\r
+ Endpoint_Write_8(Data);\r
+ return ENDPOINT_READYWAIT_NoError;\r
+}\r
+\r
+uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
+{\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))\r
+ return ENDPOINT_RWSTREAM_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataINEndpoint.Address);\r
+\r
+ if (!(Endpoint_BytesInEndpoint()))\r
+ return ENDPOINT_READYWAIT_NoError;\r
+\r
+ bool BankFull = !(Endpoint_IsReadWriteAllowed());\r
+\r
+ Endpoint_ClearIN();\r
+\r
+ if (BankFull)\r
+ {\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)\r
+ return ErrorCode;\r
+\r
+ Endpoint_ClearIN();\r
+ }\r
+\r
+ return ENDPOINT_READYWAIT_NoError;\r
+}\r
+\r
+uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
+{\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))\r
+ return 0;\r
+\r
+ Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpoint.Address);\r
+\r
+ if (Endpoint_IsOUTReceived())\r
+ {\r
+ if (!(Endpoint_BytesInEndpoint()))\r
+ {\r
+ Endpoint_ClearOUT();\r
+ return 0;\r
+ }\r
+ else\r
+ {\r
+ return Endpoint_BytesInEndpoint();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ return 0;\r
+ }\r
+}\r
+\r
+int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
+{\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))\r
+ return -1;\r
+\r
+ int16_t ReceivedByte = -1;\r
+\r
+ Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.DataOUTEndpoint.Address);\r
+\r
+ if (Endpoint_IsOUTReceived())\r
+ {\r
+ if (Endpoint_BytesInEndpoint())\r
+ ReceivedByte = Endpoint_Read_8();\r
+\r
+ if (!(Endpoint_BytesInEndpoint()))\r
+ Endpoint_ClearOUT();\r
+ }\r
+\r
+ return ReceivedByte;\r
+}\r
+\r
+void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
+{\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) || !(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS))\r
+ return;\r
+\r
+ Endpoint_SelectEndpoint(CDCInterfaceInfo->Config.NotificationEndpoint.Address);\r
+\r
+ USB_Request_Header_t Notification = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = CDC_NOTIF_SerialState,\r
+ .wValue = CPU_TO_LE16(0),\r
+ .wIndex = CPU_TO_LE16(0),\r
+ .wLength = CPU_TO_LE16(sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost)),\r
+ };\r
+\r
+ Endpoint_Write_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NULL);\r
+ Endpoint_Write_Stream_LE(&CDCInterfaceInfo->State.ControlLineStates.DeviceToHost,\r
+ sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost),\r
+ NULL);\r
+ Endpoint_ClearIN();\r
+}\r
+\r
+#if defined(FDEV_SETUP_STREAM)\r
+void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,\r
+ FILE* const Stream)\r
+{\r
+ *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Device_putchar, CDC_Device_getchar, _FDEV_SETUP_RW);\r
+ fdev_set_udata(Stream, CDCInterfaceInfo);\r
+}\r
+\r
+void CDC_Device_CreateBlockingStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,\r
+ FILE* const Stream)\r
+{\r
+ *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Device_putchar, CDC_Device_getchar_Blocking, _FDEV_SETUP_RW);\r
+ fdev_set_udata(Stream, CDCInterfaceInfo);\r
+}\r
+\r
+static int CDC_Device_putchar(char c,\r
+ FILE* Stream)\r
+{\r
+ return CDC_Device_SendByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0;\r
+}\r
+\r
+static int CDC_Device_getchar(FILE* Stream)\r
+{\r
+ int16_t ReceivedByte = CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream));\r
+\r
+ if (ReceivedByte < 0)\r
+ return _FDEV_EOF;\r
+\r
+ return ReceivedByte;\r
+}\r
+\r
+static int CDC_Device_getchar_Blocking(FILE* Stream)\r
+{\r
+ int16_t ReceivedByte;\r
+\r
+ while ((ReceivedByte = CDC_Device_ReceiveByte((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream))) < 0)\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return _FDEV_EOF;\r
+\r
+ CDC_Device_USBTask((USB_ClassInfo_CDC_Device_t*)fdev_get_udata(Stream));\r
+ USB_USBTask();\r
+ }\r
+\r
+ return ReceivedByte;\r
+}\r
+#endif\r
+\r
+// cppcheck-suppress unusedFunction\r
+void CDC_Device_Event_Stub(void)\r
+{\r
+\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Device mode driver for the library USB CDC Class driver.\r
+ *\r
+ * Device mode driver for the library USB CDC Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassCDC\r
+ * \defgroup Group_USBClassCDCDevice CDC Class Device Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Device/CDCClassDevice.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Device Mode USB Class driver framework interface, for the CDC USB Class driver.\r
+ *\r
+ * \note There are several major drawbacks to the CDC-ACM standard USB class, however\r
+ * it is very standardized and thus usually available as a built-in driver on\r
+ * most platforms, and so is a better choice than a proprietary serial class.\r
+ *\r
+ * One major issue with CDC-ACM is that it requires two Interface descriptors,\r
+ * which will upset most hosts when part of a multi-function "Composite" USB\r
+ * device. This is because each interface will be loaded into a separate driver\r
+ * instance, causing the two interfaces be become unlinked. To prevent this, you\r
+ * should use the "Interface Association Descriptor" addendum to the USB 2.0 standard\r
+ * which is available on most OSes when creating Composite devices.\r
+ *\r
+ * Another major oversight is that there is no mechanism for the host to notify the\r
+ * device that there is a data sink on the host side ready to accept data. This\r
+ * means that the device may try to send data while the host isn't listening, causing\r
+ * lengthy blocking timeouts in the transmission routines. It is thus highly recommended\r
+ * that the virtual serial line DTR (Data Terminal Ready) signal be used where possible\r
+ * to determine if a host application is ready for data.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _CDC_CLASS_DEVICE_H_\r
+#define _CDC_CLASS_DEVICE_H_\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/CDCClassCommon.h"\r
+\r
+ #include <stdio.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_CDC_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** \brief CDC Class Device Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made for each CDC interface\r
+ * within the user application, and passed to each of the CDC class driver functions as the\r
+ * CDCInterfaceInfo parameter. This stores each CDC interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device. */\r
+ \r
+ USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */\r
+ USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */\r
+ USB_Endpoint_Table_t NotificationEndpoint; /**< Notification IN Endpoint configuration table. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ struct\r
+ {\r
+ uint16_t HostToDevice; /**< Control line states from the host to device, as a set of \c CDC_CONTROL_LINE_OUT_*\r
+ * masks. This value is updated each time \ref CDC_Device_USBTask() is called.\r
+ */\r
+ uint16_t DeviceToHost; /**< Control line states from the device to host, as a set of \c CDC_CONTROL_LINE_IN_*\r
+ * masks - to notify the host of changes to these values, call the\r
+ * \ref CDC_Device_SendControlLineStateChange() function.\r
+ */\r
+ } ControlLineStates; /**< Current states of the virtual serial port's control lines between the device and host. */\r
+\r
+ CDC_LineEncoding_t LineEncoding; /** Line encoding used in the virtual serial port, for the device's information.\r
+ * This is generally only used if the virtual serial port data is to be\r
+ * reconstructed on a physical UART.\r
+ */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * are reset to their defaults when the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_CDC_Device_t;\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures the endpoints of a given CDC interface, ready for use. This should be linked to the library\r
+ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration containing\r
+ * the given CDC interface is selected.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ *\r
+ * \return Boolean \c true if the endpoints were successfully configured, \c false otherwise.\r
+ */\r
+ bool CDC_Device_ConfigureEndpoints(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Processes incoming control requests from the host, that are directed to the given CDC class interface. This should be\r
+ * linked to the library \ref EVENT_USB_Device_ControlRequest() event.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ */\r
+ void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** General management task for a given CDC class interface, required for the correct operation of the interface. This should\r
+ * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ */\r
+ void CDC_Device_USBTask(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** CDC class driver event for a line encoding change on a CDC interface. This event fires each time the host requests a\r
+ * line encoding change (containing the serial parity, baud and other configuration information) and may be hooked in the\r
+ * user program by declaring a handler function with the same name and parameters listed here. The new line encoding\r
+ * settings are available in the LineEncoding structure inside the CDC interface structure passed as a parameter.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ */\r
+ void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** CDC class driver event for a control line state change on a CDC interface. This event fires each time the host requests a\r
+ * control line state change (containing the virtual serial control line states, such as DTR) and may be hooked in the\r
+ * user program by declaring a handler function with the same name and parameters listed here. The new control line states\r
+ * are available in the \c ControlLineStates.HostToDevice value inside the CDC interface structure passed as a parameter, set as\r
+ * a mask of \c CDC_CONTROL_LINE_OUT_* masks.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ */\r
+ void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** CDC class driver event for a send break request sent to the device from the host. This is generally used to separate\r
+ * data or to indicate a special condition to the receiving device.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ * \param[in] Duration Duration of the break that has been sent by the host, in milliseconds.\r
+ */\r
+ void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,\r
+ const uint8_t Duration) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sends a given data buffer to the attached USB host, if connected. If a host is not connected when the function is\r
+ * called, the string is discarded. Bytes will be queued for transmission to the host until either the endpoint bank\r
+ * becomes full, or the \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows\r
+ * for multiple bytes to be packed into a single endpoint packet, increasing data throughput.\r
+ *\r
+ * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or\r
+ * the call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ * \param[in] Buffer Pointer to a buffer containing the data to send to the device.\r
+ * \param[in] Length Length of the data to send to the host.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t CDC_Device_SendData(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,\r
+ const char* const Buffer,\r
+ const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Sends a given null terminated string to the attached USB host, if connected. If a host is not connected when\r
+ * the function is called, the string is discarded. Bytes will be queued for transmission to the host until either\r
+ * the endpoint bank becomes full, or the \ref CDC_Device_Flush() function is called to flush the pending data to\r
+ * the host. This allows for multiple bytes to be packed into a single endpoint packet, increasing data throughput.\r
+ *\r
+ * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or\r
+ * the call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ * \param[in] String Pointer to the null terminated string to send to the host.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t CDC_Device_SendString(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,\r
+ const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Sends a given byte to the attached USB host, if connected. If a host is not connected when the function is called, the\r
+ * byte is discarded. Bytes will be queued for transmission to the host until either the endpoint bank becomes full, or the\r
+ * \ref CDC_Device_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be\r
+ * packed into a single endpoint packet, increasing data throughput.\r
+ *\r
+ * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or\r
+ * the call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ * \param[in] Data Byte of data to send to the host.\r
+ *\r
+ * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t CDC_Device_SendByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,\r
+ const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Determines the number of bytes received by the CDC interface from the host, waiting to be read. This indicates the number\r
+ * of bytes in the OUT endpoint bank only, and thus the number of calls to \ref CDC_Device_ReceiveByte() which are guaranteed to\r
+ * succeed immediately. If multiple bytes are to be received, they should be buffered by the user application, as the endpoint\r
+ * bank will not be released back to the USB controller until all bytes are read.\r
+ *\r
+ * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or\r
+ * the call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ *\r
+ * \return Total number of buffered bytes received from the host.\r
+ */\r
+ uint16_t CDC_Device_BytesReceived(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads a byte of data from the host. If no data is waiting to be read of if a USB host is not connected, the function\r
+ * returns a negative value. The \ref CDC_Device_BytesReceived() function may be queried in advance to determine how many\r
+ * bytes are currently buffered in the CDC interface's data receive endpoint bank, and thus how many repeated calls to this\r
+ * function which are guaranteed to succeed.\r
+ *\r
+ * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or\r
+ * the call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ *\r
+ * \return Next received byte from the host, or a negative value if no data received.\r
+ */\r
+ int16_t CDC_Device_ReceiveByte(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.\r
+ *\r
+ * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or\r
+ * the call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ *\r
+ * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t CDC_Device_Flush(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sends a Serial Control Line State Change notification to the host. This should be called when the virtual serial\r
+ * control lines (DCD, DSR, etc.) have changed states, or to give BREAK notifications to the host. Line states persist\r
+ * until they are cleared via a second notification. This should be called each time the CDC class driver's\r
+ * \c ControlLineStates.DeviceToHost value is updated to push the new states to the USB host.\r
+ *\r
+ * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or\r
+ * the call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ */\r
+ void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ #if defined(FDEV_SETUP_STREAM) || defined(__DOXYGEN__)\r
+ /** Creates a standard character stream for the given CDC Device instance so that it can be used with all the regular\r
+ * functions in the standard <stdio.h> library that accept a \c FILE stream as a destination (e.g. \c fprintf()). The created\r
+ * stream is bidirectional and can be used for both input and output functions.\r
+ *\r
+ * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single\r
+ * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may\r
+ * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own\r
+ * line buffering.\r
+ *\r
+ * \note The created stream can be given as \c stdout if desired to direct the standard output from all <stdio.h> functions\r
+ * to the given CDC interface.\r
+ * \n\n\r
+ *\r
+ * \note This function is not available on all microcontroller architectures.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.\r
+ */\r
+ void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,\r
+ FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Identical to \ref CDC_Device_CreateStream(), except that reads are blocking until the calling stream function terminates\r
+ * the transfer. While blocking, the USB and CDC service tasks are called repeatedly to maintain USB communications.\r
+ *\r
+ * \note This function is not available on all microcontroller architectures.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.\r
+ */\r
+ void CDC_Device_CreateBlockingStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,\r
+ FILE* const Stream) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+ #endif\r
+ \r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_CDC_DEVICE_C)\r
+ #if defined(FDEV_SETUP_STREAM)\r
+ static int CDC_Device_putchar(char c,\r
+ FILE* Stream) ATTR_NON_NULL_PTR_ARG(2);\r
+ static int CDC_Device_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);\r
+ static int CDC_Device_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+\r
+ void CDC_Device_Event_Stub(void) ATTR_CONST;\r
+\r
+ void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
+ ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub);\r
+ void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)\r
+ ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Device_Event_Stub);\r
+ void EVENT_CDC_Device_BreakSent(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,\r
+ const uint8_t Duration) ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_ALIAS(CDC_Device_Event_Stub);\r
+ #endif\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#define __INCLUDE_FROM_HID_DRIVER\r
+#define __INCLUDE_FROM_HID_DEVICE_C\r
+#include "HIDClassDevice.h"\r
+\r
+void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)\r
+{\r
+ if (!(Endpoint_IsSETUPReceived()))\r
+ return;\r
+\r
+ if (USB_ControlRequest.wIndex != HIDInterfaceInfo->Config.InterfaceNumber)\r
+ return;\r
+\r
+ switch (USB_ControlRequest.bRequest)\r
+ {\r
+ case HID_REQ_GetReport:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ uint16_t ReportSize = 0;\r
+ uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);\r
+ uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1;\r
+ uint8_t ReportData[HIDInterfaceInfo->Config.PrevReportINBufferSize];\r
+\r
+ memset(ReportData, 0, sizeof(ReportData));\r
+\r
+ CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, ReportType, ReportData, &ReportSize);\r
+\r
+ if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL)\r
+ {\r
+ memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportData,\r
+ HIDInterfaceInfo->Config.PrevReportINBufferSize);\r
+ }\r
+\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_Write_Control_Stream_LE(ReportData, ReportSize);\r
+ Endpoint_ClearOUT();\r
+ }\r
+\r
+ break;\r
+ case HID_REQ_SetReport:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ uint16_t ReportSize = USB_ControlRequest.wLength;\r
+ uint8_t ReportID = (USB_ControlRequest.wValue & 0xFF);\r
+ uint8_t ReportType = (USB_ControlRequest.wValue >> 8) - 1;\r
+ uint8_t ReportData[ReportSize];\r
+\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_Read_Control_Stream_LE(ReportData, ReportSize);\r
+ Endpoint_ClearIN();\r
+\r
+ CALLBACK_HID_Device_ProcessHIDReport(HIDInterfaceInfo, ReportID, ReportType,\r
+ &ReportData[ReportID ? 1 : 0], ReportSize - (ReportID ? 1 : 0));\r
+ }\r
+\r
+ break;\r
+ case HID_REQ_GetProtocol:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ while (!(Endpoint_IsINReady()));\r
+ Endpoint_Write_8(HIDInterfaceInfo->State.UsingReportProtocol);\r
+ Endpoint_ClearIN();\r
+ Endpoint_ClearStatusStage();\r
+ }\r
+\r
+ break;\r
+ case HID_REQ_SetProtocol:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_ClearStatusStage();\r
+\r
+ HIDInterfaceInfo->State.UsingReportProtocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00);\r
+ }\r
+\r
+ break;\r
+ case HID_REQ_SetIdle:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_ClearStatusStage();\r
+\r
+ HIDInterfaceInfo->State.IdleCount = ((USB_ControlRequest.wValue & 0xFF00) >> 6);\r
+ }\r
+\r
+ break;\r
+ case HID_REQ_GetIdle:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ while (!(Endpoint_IsINReady()));\r
+ Endpoint_Write_8(HIDInterfaceInfo->State.IdleCount >> 2);\r
+ Endpoint_ClearIN();\r
+ Endpoint_ClearStatusStage();\r
+ }\r
+\r
+ break;\r
+ }\r
+}\r
+\r
+bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)\r
+{\r
+ memset(&HIDInterfaceInfo->State, 0x00, sizeof(HIDInterfaceInfo->State));\r
+ HIDInterfaceInfo->State.UsingReportProtocol = true;\r
+ HIDInterfaceInfo->State.IdleCount = 500;\r
+\r
+ HIDInterfaceInfo->Config.ReportINEndpoint.Type = EP_TYPE_INTERRUPT;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&HIDInterfaceInfo->Config.ReportINEndpoint, 1)))\r
+ return false; \r
+ \r
+ return true;\r
+}\r
+\r
+void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)\r
+{\r
+ if (USB_DeviceState != DEVICE_STATE_Configured)\r
+ return;\r
+\r
+ if (HIDInterfaceInfo->State.PrevFrameNum == USB_Device_GetFrameNumber())\r
+ return;\r
+ \r
+ Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpoint.Address);\r
+\r
+ if (Endpoint_IsReadWriteAllowed())\r
+ {\r
+ uint8_t ReportINData[HIDInterfaceInfo->Config.PrevReportINBufferSize];\r
+ uint8_t ReportID = 0;\r
+ uint16_t ReportINSize = 0;\r
+\r
+ memset(ReportINData, 0, sizeof(ReportINData));\r
+\r
+ bool ForceSend = CALLBACK_HID_Device_CreateHIDReport(HIDInterfaceInfo, &ReportID, HID_REPORT_ITEM_In,\r
+ ReportINData, &ReportINSize);\r
+ bool StatesChanged = false;\r
+ bool IdlePeriodElapsed = (HIDInterfaceInfo->State.IdleCount && !(HIDInterfaceInfo->State.IdleMSRemaining));\r
+\r
+ if (HIDInterfaceInfo->Config.PrevReportINBuffer != NULL)\r
+ {\r
+ StatesChanged = (memcmp(ReportINData, HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINSize) != 0);\r
+ memcpy(HIDInterfaceInfo->Config.PrevReportINBuffer, ReportINData, HIDInterfaceInfo->Config.PrevReportINBufferSize);\r
+ }\r
+\r
+ if (ReportINSize && (ForceSend || StatesChanged || IdlePeriodElapsed))\r
+ {\r
+ HIDInterfaceInfo->State.IdleMSRemaining = HIDInterfaceInfo->State.IdleCount;\r
+\r
+ Endpoint_SelectEndpoint(HIDInterfaceInfo->Config.ReportINEndpoint.Address);\r
+\r
+ if (ReportID)\r
+ Endpoint_Write_8(ReportID);\r
+\r
+ Endpoint_Write_Stream_LE(ReportINData, ReportINSize, NULL);\r
+\r
+ Endpoint_ClearIN();\r
+ }\r
+ \r
+ HIDInterfaceInfo->State.PrevFrameNum = USB_Device_GetFrameNumber();\r
+ }\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Device mode driver for the library USB HID Class driver.\r
+ *\r
+ * Device mode driver for the library USB HID Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassHID\r
+ * \defgroup Group_USBClassHIDDevice HID Class Device Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Device/HIDClassDevice.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Device Mode USB Class driver framework interface, for the HID USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _HID_CLASS_DEVICE_H_\r
+#define _HID_CLASS_DEVICE_H_\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/HIDClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_HID_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** \brief HID Class Device Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made for each HID interface\r
+ * within the user application, and passed to each of the HID class driver functions as the\r
+ * \c HIDInterfaceInfo parameter. This stores each HID interface's configuration and state information.\r
+ *\r
+ * \note Due to technical limitations, the HID device class driver does not utilize a separate OUT\r
+ * endpoint for host->device communications. Instead, the host->device data (if any) is sent to\r
+ * the device via the control endpoint.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ uint8_t InterfaceNumber; /**< Interface number of the HID interface within the device. */\r
+\r
+ USB_Endpoint_Table_t ReportINEndpoint; /**< Data IN HID report endpoint configuration table. */\r
+\r
+ void* PrevReportINBuffer; /**< Pointer to a buffer where the previously created HID input report can be\r
+ * stored by the driver, for comparison purposes to detect report changes that\r
+ * must be sent immediately to the host. This should point to a buffer big enough\r
+ * to hold the largest HID input report sent from the HID interface. If this is set\r
+ * to \c NULL, it is up to the user to force transfers when needed in the\r
+ * \ref CALLBACK_HID_Device_CreateHIDReport() callback function.\r
+ *\r
+ * \note Due to the single buffer, the internal driver can only correctly compare\r
+ * subsequent reports with identical report IDs. In multiple report devices,\r
+ * this buffer should be set to \c NULL and the decision to send reports made\r
+ * by the user application instead.\r
+ */\r
+ uint8_t PrevReportINBufferSize; /**< Size in bytes of the given input report buffer. This is used to create a\r
+ * second buffer of the same size within the driver so that subsequent reports\r
+ * can be compared. If the user app is to determine when reports are to be sent\r
+ * exclusively (i.e. \ref PrevReportINBuffer is \c NULL) this value must still be\r
+ * set to the size of the largest report the device can issue to the host.\r
+ */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ bool UsingReportProtocol; /**< Indicates if the HID interface is set to Boot or Report protocol mode. */\r
+ uint16_t PrevFrameNum; /**< Frame number of the previous HID report packet opportunity. */\r
+ uint16_t IdleCount; /**< Report idle period, in milliseconds, set by the host. */\r
+ uint16_t IdleMSRemaining; /**< Total number of milliseconds remaining before the idle period elapsed - this\r
+ * should be decremented by the user application if non-zero each millisecond. */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * are reset to their defaults when the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_HID_Device_t;\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures the endpoints of a given HID interface, ready for use. This should be linked to the library\r
+ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration\r
+ * containing the given HID interface is selected.\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.\r
+ *\r
+ * \return Boolean \c true if the endpoints were successfully configured, \c false otherwise.\r
+ */\r
+ bool HID_Device_ConfigureEndpoints(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Processes incoming control requests from the host, that are directed to the given HID class interface. This should be\r
+ * linked to the library \ref EVENT_USB_Device_ControlRequest() event.\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.\r
+ */\r
+ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** General management task for a given HID class interface, required for the correct operation of the interface. This should\r
+ * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.\r
+ */\r
+ void HID_Device_USBTask(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** HID class driver callback for the user creation of a HID IN report. This callback may fire in response to either\r
+ * HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback the\r
+ * user is responsible for the creation of the next HID input report to be sent to the host.\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.\r
+ * \param[in,out] ReportID If preset to a non-zero value, this is the report ID being requested by the host. If zero,\r
+ * this should be set to the report ID of the generated HID input report (if any). If multiple\r
+ * reports are not sent via the given HID interface, this parameter should be ignored.\r
+ * \param[in] ReportType Type of HID report to generate, either \ref HID_REPORT_ITEM_In or \ref HID_REPORT_ITEM_Feature.\r
+ * \param[out] ReportData Pointer to a buffer where the generated HID report should be stored.\r
+ * \param[out] ReportSize Number of bytes in the generated input report, or zero if no report is to be sent.\r
+ *\r
+ * \return Boolean \c true to force the sending of the report even if it is identical to the previous report and still within\r
+ * the idle period (useful for devices which report relative movement), \c false otherwise.\r
+ */\r
+ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,\r
+ uint8_t* const ReportID,\r
+ const uint8_t ReportType,\r
+ void* ReportData,\r
+ uint16_t* const ReportSize) ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(4) ATTR_NON_NULL_PTR_ARG(5);\r
+\r
+ /** HID class driver callback for the user processing of a received HID OUT report. This callback may fire in response to\r
+ * either HID class control requests from the host, or by the normal HID endpoint polling procedure. Inside this callback\r
+ * the user is responsible for the processing of the received HID output report from the host.\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.\r
+ * \param[in] ReportID Report ID of the received output report. If multiple reports are not received via the given HID\r
+ * interface, this parameter should be ignored.\r
+ * \param[in] ReportType Type of received HID report, either \ref HID_REPORT_ITEM_Out or \ref HID_REPORT_ITEM_Feature.\r
+ * \param[in] ReportData Pointer to a buffer where the received HID report is stored.\r
+ * \param[in] ReportSize Size in bytes of the received report from the host.\r
+ */\r
+ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,\r
+ const uint8_t ReportID,\r
+ const uint8_t ReportType,\r
+ const void* ReportData,\r
+ const uint16_t ReportSize) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(4);\r
+\r
+ /* Inline Functions: */\r
+ /** Indicates that a millisecond of idle time has elapsed on the given HID interface, and the interface's idle count should be\r
+ * decremented. This should be called once per millisecond so that hardware key-repeats function correctly. It is recommended\r
+ * that this be called by the \ref EVENT_USB_Device_StartOfFrame() event, once SOF events have been enabled via\r
+ * \ref USB_Device_EnableSOFEvents().\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class configuration and state.\r
+ */\r
+ static inline void HID_Device_MillisecondElapsed(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo) ATTR_ALWAYS_INLINE ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline void HID_Device_MillisecondElapsed(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo)\r
+ {\r
+ if (HIDInterfaceInfo->State.IdleMSRemaining)\r
+ HIDInterfaceInfo->State.IdleMSRemaining--;\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#define __INCLUDE_FROM_MIDI_DRIVER\r
+#define __INCLUDE_FROM_MIDI_DEVICE_C\r
+#include "MIDIClassDevice.h"\r
+\r
+bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo)\r
+{\r
+ memset(&MIDIInterfaceInfo->State, 0x00, sizeof(MIDIInterfaceInfo->State));\r
+\r
+ MIDIInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_BULK;\r
+ MIDIInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&MIDIInterfaceInfo->Config.DataINEndpoint, 1)))\r
+ return false;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&MIDIInterfaceInfo->Config.DataOUTEndpoint, 1)))\r
+ return false;\r
+\r
+ return true;\r
+}\r
+\r
+void MIDI_Device_USBTask(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo)\r
+{\r
+ if (USB_DeviceState != DEVICE_STATE_Configured)\r
+ return;\r
+\r
+ #if !defined(NO_CLASS_DRIVER_AUTOFLUSH)\r
+ MIDI_Device_Flush(MIDIInterfaceInfo);\r
+ #endif\r
+}\r
+\r
+uint8_t MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo,\r
+ const MIDI_EventPacket_t* const Event)\r
+{\r
+ if (USB_DeviceState != DEVICE_STATE_Configured)\r
+ return ENDPOINT_RWSTREAM_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpoint.Address);\r
+\r
+ if ((ErrorCode = Endpoint_Write_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ Endpoint_ClearIN();\r
+\r
+ return ENDPOINT_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t MIDI_Device_Flush(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo)\r
+{\r
+ if (USB_DeviceState != DEVICE_STATE_Configured)\r
+ return ENDPOINT_RWSTREAM_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataINEndpoint.Address);\r
+\r
+ if (Endpoint_BytesInEndpoint())\r
+ {\r
+ Endpoint_ClearIN();\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)\r
+ return ErrorCode;\r
+ }\r
+\r
+ return ENDPOINT_READYWAIT_NoError;\r
+}\r
+\r
+bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo,\r
+ MIDI_EventPacket_t* const Event)\r
+{\r
+ if (USB_DeviceState != DEVICE_STATE_Configured)\r
+ return false;\r
+\r
+ Endpoint_SelectEndpoint(MIDIInterfaceInfo->Config.DataOUTEndpoint.Address);\r
+\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ return false;\r
+\r
+ Endpoint_Read_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NULL);\r
+\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ Endpoint_ClearOUT();\r
+\r
+ return true;\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Device mode driver for the library USB MIDI Class driver.\r
+ *\r
+ * Device mode driver for the library USB MIDI Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassMIDI\r
+ * \defgroup Group_USBClassMIDIDevice MIDI Class Device Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Device Mode USB Class driver framework interface, for the MIDI USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _MIDI_CLASS_DEVICE_H_\r
+#define _MIDI_CLASS_DEVICE_H_\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/MIDIClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_MIDI_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Define: */\r
+ /** \brief MIDI Class Device Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made for each MIDI interface\r
+ * within the user application, and passed to each of the MIDI class driver functions as the\r
+ * \c MIDIInterfaceInfo parameter. This stores each MIDI interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ uint8_t StreamingInterfaceNumber; /**< Index of the Audio Streaming interface within the device this structure controls. */\r
+\r
+ USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */\r
+ USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+\r
+ struct\r
+ {\r
+ uint8_t RESERVED; // No state information for this class\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * are reset to their defaults when the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_MIDI_Device_t;\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures the endpoints of a given MIDI interface, ready for use. This should be linked to the library\r
+ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration\r
+ * containing the given MIDI interface is selected.\r
+ *\r
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ *\r
+ * \return Boolean \c true if the endpoints were successfully configured, \c false otherwise.\r
+ */\r
+ bool MIDI_Device_ConfigureEndpoints(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** General management task for a given MIDI class interface, required for the correct operation of the interface. This should\r
+ * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ */\r
+ void MIDI_Device_USBTask(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sends a MIDI event packet to the host. If no host is connected, the event packet is discarded. Events are queued into the\r
+ * endpoint bank until either the endpoint bank is full, or \ref MIDI_Device_Flush() is called. This allows for multiple\r
+ * MIDI events to be packed into a single endpoint packet, increasing data throughput.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ * \param[in] Event Pointer to a populated \ref MIDI_EventPacket_t structure containing the MIDI event to send.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t MIDI_Device_SendEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo,\r
+ const MIDI_EventPacket_t* const Event) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+\r
+ /** Flushes the MIDI send buffer, sending any queued MIDI events to the host. This should be called to override the\r
+ * \ref MIDI_Device_SendEventPacket() function's packing behavior, to flush queued events.\r
+ *\r
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ *\r
+ * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t MIDI_Device_Flush(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Receives a MIDI event packet from the host. Events are unpacked from the endpoint, thus if the endpoint bank contains\r
+ * multiple MIDI events from the host in the one packet, multiple calls to this function will return each individual event.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ * \param[out] Event Pointer to a USB_MIDI_EventPacket_t structure where the received MIDI event is to be placed.\r
+ *\r
+ * \return Boolean \c true if a MIDI event packet was received, \c false otherwise.\r
+ */\r
+ bool MIDI_Device_ReceiveEventPacket(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo,\r
+ MIDI_EventPacket_t* const Event) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /* Inline Functions: */\r
+ /** Processes incoming control requests from the host, that are directed to the given MIDI class interface. This should be\r
+ * linked to the library \ref EVENT_USB_Device_ControlRequest() event.\r
+ *\r
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ */\r
+ static inline void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline void MIDI_Device_ProcessControlRequest(USB_ClassInfo_MIDI_Device_t* const MIDIInterfaceInfo)\r
+ {\r
+ (void)MIDIInterfaceInfo;\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#define __INCLUDE_FROM_MS_DRIVER\r
+#define __INCLUDE_FROM_MASSSTORAGE_DEVICE_C\r
+#include "MassStorageClassDevice.h"\r
+\r
+void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)\r
+{\r
+ if (!(Endpoint_IsSETUPReceived()))\r
+ return;\r
+\r
+ if (USB_ControlRequest.wIndex != MSInterfaceInfo->Config.InterfaceNumber)\r
+ return;\r
+\r
+ switch (USB_ControlRequest.bRequest)\r
+ {\r
+ case MS_REQ_MassStorageReset:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_ClearStatusStage();\r
+\r
+ MSInterfaceInfo->State.IsMassStoreReset = true;\r
+ }\r
+\r
+ break;\r
+ case MS_REQ_GetMaxLUN:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ while (!(Endpoint_IsINReady()));\r
+ Endpoint_Write_8(MSInterfaceInfo->Config.TotalLUNs - 1);\r
+ Endpoint_ClearIN();\r
+ Endpoint_ClearStatusStage();\r
+ }\r
+\r
+ break;\r
+ }\r
+}\r
+\r
+bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)\r
+{\r
+ memset(&MSInterfaceInfo->State, 0x00, sizeof(MSInterfaceInfo->State));\r
+\r
+ MSInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_BULK;\r
+ MSInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&MSInterfaceInfo->Config.DataINEndpoint, 1)))\r
+ return false;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&MSInterfaceInfo->Config.DataOUTEndpoint, 1)))\r
+ return false;\r
+\r
+ return true;\r
+}\r
+\r
+void MS_Device_USBTask(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)\r
+{\r
+ if (USB_DeviceState != DEVICE_STATE_Configured)\r
+ return;\r
+\r
+ Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address);\r
+\r
+ if (Endpoint_IsOUTReceived())\r
+ {\r
+ if (MS_Device_ReadInCommandBlock(MSInterfaceInfo))\r
+ {\r
+ if (MSInterfaceInfo->State.CommandBlock.Flags & MS_COMMAND_DIR_DATA_IN)\r
+ Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address);\r
+\r
+ bool SCSICommandResult = CALLBACK_MS_Device_SCSICommandReceived(MSInterfaceInfo);\r
+\r
+ MSInterfaceInfo->State.CommandStatus.Status = (SCSICommandResult) ? MS_SCSI_COMMAND_Pass : MS_SCSI_COMMAND_Fail;\r
+ MSInterfaceInfo->State.CommandStatus.Signature = CPU_TO_LE32(MS_CSW_SIGNATURE);\r
+ MSInterfaceInfo->State.CommandStatus.Tag = MSInterfaceInfo->State.CommandBlock.Tag;\r
+ MSInterfaceInfo->State.CommandStatus.DataTransferResidue = MSInterfaceInfo->State.CommandBlock.DataTransferLength;\r
+\r
+ if (!(SCSICommandResult) && (le32_to_cpu(MSInterfaceInfo->State.CommandStatus.DataTransferResidue)))\r
+ Endpoint_StallTransaction();\r
+\r
+ MS_Device_ReturnCommandStatus(MSInterfaceInfo);\r
+ }\r
+ }\r
+\r
+ if (MSInterfaceInfo->State.IsMassStoreReset)\r
+ {\r
+ Endpoint_ResetEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address);\r
+ Endpoint_ResetEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address);\r
+\r
+ Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address);\r
+ Endpoint_ClearStall();\r
+ Endpoint_ResetDataToggle();\r
+ Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address);\r
+ Endpoint_ClearStall();\r
+ Endpoint_ResetDataToggle();\r
+\r
+ MSInterfaceInfo->State.IsMassStoreReset = false;\r
+ }\r
+}\r
+\r
+static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)\r
+{\r
+ uint16_t BytesProcessed;\r
+\r
+ Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address);\r
+ \r
+ BytesProcessed = 0;\r
+ while (Endpoint_Read_Stream_LE(&MSInterfaceInfo->State.CommandBlock,\r
+ (sizeof(MS_CommandBlockWrapper_t) - 16), &BytesProcessed) ==\r
+ ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ {\r
+ if (MSInterfaceInfo->State.IsMassStoreReset)\r
+ return false;\r
+ }\r
+\r
+ if ((MSInterfaceInfo->State.CommandBlock.Signature != CPU_TO_LE32(MS_CBW_SIGNATURE)) ||\r
+ (MSInterfaceInfo->State.CommandBlock.LUN >= MSInterfaceInfo->Config.TotalLUNs) ||\r
+ (MSInterfaceInfo->State.CommandBlock.Flags & 0x1F) ||\r
+ (MSInterfaceInfo->State.CommandBlock.SCSICommandLength == 0) ||\r
+ (MSInterfaceInfo->State.CommandBlock.SCSICommandLength > 16))\r
+ { \r
+ Endpoint_StallTransaction();\r
+ Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address);\r
+ Endpoint_StallTransaction();\r
+\r
+ return false;\r
+ }\r
+\r
+ BytesProcessed = 0;\r
+ while (Endpoint_Read_Stream_LE(&MSInterfaceInfo->State.CommandBlock.SCSICommandData,\r
+ MSInterfaceInfo->State.CommandBlock.SCSICommandLength, &BytesProcessed) ==\r
+ ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ {\r
+ if (MSInterfaceInfo->State.IsMassStoreReset)\r
+ return false;\r
+ }\r
+\r
+ Endpoint_ClearOUT();\r
+\r
+ return true;\r
+}\r
+\r
+static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)\r
+{\r
+ Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataOUTEndpoint.Address);\r
+\r
+ while (Endpoint_IsStalled())\r
+ {\r
+ #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
+ USB_USBTask();\r
+ #endif\r
+\r
+ if (MSInterfaceInfo->State.IsMassStoreReset)\r
+ return;\r
+ }\r
+\r
+ Endpoint_SelectEndpoint(MSInterfaceInfo->Config.DataINEndpoint.Address);\r
+\r
+ while (Endpoint_IsStalled())\r
+ {\r
+ #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
+ USB_USBTask();\r
+ #endif\r
+\r
+ if (MSInterfaceInfo->State.IsMassStoreReset)\r
+ return;\r
+ }\r
+\r
+ uint16_t BytesProcessed = 0;\r
+ while (Endpoint_Write_Stream_LE(&MSInterfaceInfo->State.CommandStatus,\r
+ sizeof(MS_CommandStatusWrapper_t), &BytesProcessed) ==\r
+ ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ {\r
+ if (MSInterfaceInfo->State.IsMassStoreReset)\r
+ return;\r
+ }\r
+\r
+ Endpoint_ClearIN();\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Device mode driver for the library USB Mass Storage Class driver.\r
+ *\r
+ * Device mode driver for the library USB Mass Storage Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassMS\r
+ * \defgroup Group_USBClassMSDevice Mass Storage Class Device Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Device Mode USB Class driver framework interface, for the Mass Storage USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _MS_CLASS_DEVICE_H_\r
+#define _MS_CLASS_DEVICE_H_\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/MassStorageClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_MS_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** \brief Mass Storage Class Device Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made for each Mass Storage interface\r
+ * within the user application, and passed to each of the Mass Storage class driver functions as the\r
+ * \c MSInterfaceInfo parameter. This stores each Mass Storage interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ uint8_t InterfaceNumber; /**< Interface number of the Mass Storage interface within the device. */\r
+\r
+ USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */\r
+ USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */\r
+\r
+ uint8_t TotalLUNs; /**< Total number of logical drives in the Mass Storage interface. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ MS_CommandBlockWrapper_t CommandBlock; /**< Mass Storage class command block structure, stores the received SCSI\r
+ * command from the host which is to be processed.\r
+ */\r
+ MS_CommandStatusWrapper_t CommandStatus; /**< Mass Storage class command status structure, set elements to indicate\r
+ * the issued command's success or failure to the host.\r
+ */\r
+ volatile bool IsMassStoreReset; /**< Flag indicating that the host has requested that the Mass Storage interface be reset\r
+ * and that all current Mass Storage operations should immediately abort.\r
+ */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * are reset to their defaults when the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_MS_Device_t;\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures the endpoints of a given Mass Storage interface, ready for use. This should be linked to the library\r
+ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration\r
+ * containing the given Mass Storage interface is selected.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.\r
+ *\r
+ * \return Boolean \c true if the endpoints were successfully configured, \c false otherwise.\r
+ */\r
+ bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Processes incoming control requests from the host, that are directed to the given Mass Storage class interface. This should be\r
+ * linked to the library \ref EVENT_USB_Device_ControlRequest() event.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.\r
+ */\r
+ void MS_Device_ProcessControlRequest(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** General management task for a given Mass Storage class interface, required for the correct operation of the interface. This should\r
+ * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage configuration and state.\r
+ */\r
+ void MS_Device_USBTask(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Mass Storage class driver callback for the user processing of a received SCSI command. This callback will fire each time the\r
+ * host sends a SCSI command which requires processing by the user application. Inside this callback the user is responsible\r
+ * for the processing of the received SCSI command from the host. The SCSI command is available in the CommandBlock structure\r
+ * inside the Mass Storage class state structure passed as a parameter to the callback function.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a Mass Storage Class configuration and state.\r
+ *\r
+ * \return Boolean \c true if the SCSI command was successfully processed, \c false otherwise.\r
+ */\r
+ bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_MASSSTORAGE_DEVICE_C)\r
+ static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+ static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#define __INCLUDE_FROM_RNDIS_DRIVER\r
+#define __INCLUDE_FROM_RNDIS_DEVICE_C\r
+#include "RNDISClassDevice.h"\r
+\r
+static const uint32_t PROGMEM AdapterSupportedOIDList[] =\r
+ {\r
+ CPU_TO_LE32(OID_GEN_SUPPORTED_LIST),\r
+ CPU_TO_LE32(OID_GEN_PHYSICAL_MEDIUM),\r
+ CPU_TO_LE32(OID_GEN_HARDWARE_STATUS),\r
+ CPU_TO_LE32(OID_GEN_MEDIA_SUPPORTED),\r
+ CPU_TO_LE32(OID_GEN_MEDIA_IN_USE),\r
+ CPU_TO_LE32(OID_GEN_MAXIMUM_FRAME_SIZE),\r
+ CPU_TO_LE32(OID_GEN_MAXIMUM_TOTAL_SIZE),\r
+ CPU_TO_LE32(OID_GEN_LINK_SPEED),\r
+ CPU_TO_LE32(OID_GEN_TRANSMIT_BLOCK_SIZE),\r
+ CPU_TO_LE32(OID_GEN_RECEIVE_BLOCK_SIZE),\r
+ CPU_TO_LE32(OID_GEN_VENDOR_ID),\r
+ CPU_TO_LE32(OID_GEN_VENDOR_DESCRIPTION),\r
+ CPU_TO_LE32(OID_GEN_CURRENT_PACKET_FILTER),\r
+ CPU_TO_LE32(OID_GEN_MAXIMUM_TOTAL_SIZE),\r
+ CPU_TO_LE32(OID_GEN_MEDIA_CONNECT_STATUS),\r
+ CPU_TO_LE32(OID_GEN_XMIT_OK),\r
+ CPU_TO_LE32(OID_GEN_RCV_OK),\r
+ CPU_TO_LE32(OID_GEN_XMIT_ERROR),\r
+ CPU_TO_LE32(OID_GEN_RCV_ERROR),\r
+ CPU_TO_LE32(OID_GEN_RCV_NO_BUFFER),\r
+ CPU_TO_LE32(OID_802_3_PERMANENT_ADDRESS),\r
+ CPU_TO_LE32(OID_802_3_CURRENT_ADDRESS),\r
+ CPU_TO_LE32(OID_802_3_MULTICAST_LIST),\r
+ CPU_TO_LE32(OID_802_3_MAXIMUM_LIST_SIZE),\r
+ CPU_TO_LE32(OID_802_3_RCV_ERROR_ALIGNMENT),\r
+ CPU_TO_LE32(OID_802_3_XMIT_ONE_COLLISION),\r
+ CPU_TO_LE32(OID_802_3_XMIT_MORE_COLLISIONS),\r
+ };\r
+\r
+void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)\r
+{\r
+ if (!(Endpoint_IsSETUPReceived()))\r
+ return;\r
+\r
+ if (USB_ControlRequest.wIndex != RNDISInterfaceInfo->Config.ControlInterfaceNumber)\r
+ return;\r
+\r
+ switch (USB_ControlRequest.bRequest)\r
+ {\r
+ case RNDIS_REQ_SendEncapsulatedCommand:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_Read_Control_Stream_LE(RNDISInterfaceInfo->State.RNDISMessageBuffer, USB_ControlRequest.wLength);\r
+ Endpoint_ClearIN();\r
+\r
+ RNDIS_Device_ProcessRNDISControlMessage(RNDISInterfaceInfo);\r
+ }\r
+\r
+ break;\r
+ case RNDIS_REQ_GetEncapsulatedResponse:\r
+ if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))\r
+ {\r
+ RNDIS_Message_Header_t* MessageHeader = (RNDIS_Message_Header_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;\r
+\r
+ if (!(MessageHeader->MessageLength))\r
+ {\r
+ RNDISInterfaceInfo->State.RNDISMessageBuffer[0] = 0;\r
+ MessageHeader->MessageLength = CPU_TO_LE32(1);\r
+ }\r
+\r
+ Endpoint_ClearSETUP();\r
+ Endpoint_Write_Control_Stream_LE(RNDISInterfaceInfo->State.RNDISMessageBuffer, le32_to_cpu(MessageHeader->MessageLength));\r
+ Endpoint_ClearOUT();\r
+\r
+ MessageHeader->MessageLength = CPU_TO_LE32(0);\r
+ }\r
+\r
+ break;\r
+ }\r
+}\r
+\r
+bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)\r
+{\r
+ memset(&RNDISInterfaceInfo->State, 0x00, sizeof(RNDISInterfaceInfo->State));\r
+\r
+ RNDISInterfaceInfo->Config.DataINEndpoint.Type = EP_TYPE_BULK;\r
+ RNDISInterfaceInfo->Config.DataOUTEndpoint.Type = EP_TYPE_BULK;\r
+ RNDISInterfaceInfo->Config.NotificationEndpoint.Type = EP_TYPE_INTERRUPT;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.DataINEndpoint, 1)))\r
+ return false;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.DataOUTEndpoint, 1)))\r
+ return false;\r
+\r
+ if (!(Endpoint_ConfigureEndpointTable(&RNDISInterfaceInfo->Config.NotificationEndpoint, 1)))\r
+ return false;\r
+\r
+ return true;\r
+}\r
+\r
+void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)\r
+{\r
+ if (USB_DeviceState != DEVICE_STATE_Configured)\r
+ return;\r
+\r
+ Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.NotificationEndpoint.Address);\r
+\r
+ if (Endpoint_IsINReady() && RNDISInterfaceInfo->State.ResponseReady)\r
+ {\r
+ USB_Request_Header_t Notification = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = RNDIS_NOTIF_ResponseAvailable,\r
+ .wValue = CPU_TO_LE16(0),\r
+ .wIndex = CPU_TO_LE16(0),\r
+ .wLength = CPU_TO_LE16(0),\r
+ };\r
+\r
+ Endpoint_Write_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NULL);\r
+\r
+ Endpoint_ClearIN();\r
+\r
+ RNDISInterfaceInfo->State.ResponseReady = false;\r
+ }\r
+}\r
+\r
+void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)\r
+{\r
+ /* Note: Only a single buffer is used for both the received message and its response to save SRAM. Because of\r
+ this, response bytes should be filled in order so that they do not clobber unread data in the buffer. */\r
+\r
+ RNDIS_Message_Header_t* MessageHeader = (RNDIS_Message_Header_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;\r
+\r
+ switch (le32_to_cpu(MessageHeader->MessageType))\r
+ {\r
+ case REMOTE_NDIS_INITIALIZE_MSG:\r
+ RNDISInterfaceInfo->State.ResponseReady = true;\r
+\r
+ RNDIS_Initialize_Message_t* INITIALIZE_Message =\r
+ (RNDIS_Initialize_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;\r
+ RNDIS_Initialize_Complete_t* INITIALIZE_Response =\r
+ (RNDIS_Initialize_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;\r
+\r
+ INITIALIZE_Response->MessageType = CPU_TO_LE32(REMOTE_NDIS_INITIALIZE_CMPLT);\r
+ INITIALIZE_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_Initialize_Complete_t));\r
+ INITIALIZE_Response->RequestId = INITIALIZE_Message->RequestId;\r
+ INITIALIZE_Response->Status = CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS);\r
+\r
+ INITIALIZE_Response->MajorVersion = CPU_TO_LE32(REMOTE_NDIS_VERSION_MAJOR);\r
+ INITIALIZE_Response->MinorVersion = CPU_TO_LE32(REMOTE_NDIS_VERSION_MINOR);\r
+ INITIALIZE_Response->DeviceFlags = CPU_TO_LE32(REMOTE_NDIS_DF_CONNECTIONLESS);\r
+ INITIALIZE_Response->Medium = CPU_TO_LE32(REMOTE_NDIS_MEDIUM_802_3);\r
+ INITIALIZE_Response->MaxPacketsPerTransfer = CPU_TO_LE32(1);\r
+ INITIALIZE_Response->MaxTransferSize = CPU_TO_LE32(sizeof(RNDIS_Packet_Message_t) + ETHERNET_FRAME_SIZE_MAX);\r
+ INITIALIZE_Response->PacketAlignmentFactor = CPU_TO_LE32(0);\r
+ INITIALIZE_Response->AFListOffset = CPU_TO_LE32(0);\r
+ INITIALIZE_Response->AFListSize = CPU_TO_LE32(0);\r
+\r
+ RNDISInterfaceInfo->State.CurrRNDISState = RNDIS_Initialized;\r
+ break;\r
+ case REMOTE_NDIS_HALT_MSG:\r
+ RNDISInterfaceInfo->State.ResponseReady = false;\r
+\r
+ MessageHeader->MessageLength = CPU_TO_LE32(0);\r
+\r
+ RNDISInterfaceInfo->State.CurrRNDISState = RNDIS_Uninitialized;\r
+ break;\r
+ case REMOTE_NDIS_QUERY_MSG:\r
+ RNDISInterfaceInfo->State.ResponseReady = true;\r
+\r
+ RNDIS_Query_Message_t* QUERY_Message = (RNDIS_Query_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;\r
+ RNDIS_Query_Complete_t* QUERY_Response = (RNDIS_Query_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;\r
+ uint32_t Query_Oid = CPU_TO_LE32(QUERY_Message->Oid);\r
+\r
+ void* QueryData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Message_Header_t) +\r
+ le32_to_cpu(QUERY_Message->InformationBufferOffset)];\r
+ void* ResponseData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Query_Complete_t)];\r
+ uint16_t ResponseSize;\r
+\r
+ QUERY_Response->MessageType = CPU_TO_LE32(REMOTE_NDIS_QUERY_CMPLT);\r
+\r
+ if (RNDIS_Device_ProcessNDISQuery(RNDISInterfaceInfo, Query_Oid, QueryData, le32_to_cpu(QUERY_Message->InformationBufferLength),\r
+ ResponseData, &ResponseSize))\r
+ {\r
+ QUERY_Response->Status = CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS);\r
+ QUERY_Response->MessageLength = cpu_to_le32(sizeof(RNDIS_Query_Complete_t) + ResponseSize);\r
+\r
+ QUERY_Response->InformationBufferLength = CPU_TO_LE32(ResponseSize);\r
+ QUERY_Response->InformationBufferOffset = CPU_TO_LE32(sizeof(RNDIS_Query_Complete_t) - sizeof(RNDIS_Message_Header_t));\r
+ }\r
+ else\r
+ {\r
+ QUERY_Response->Status = CPU_TO_LE32(REMOTE_NDIS_STATUS_NOT_SUPPORTED);\r
+ QUERY_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_Query_Complete_t));\r
+\r
+ QUERY_Response->InformationBufferLength = CPU_TO_LE32(0);\r
+ QUERY_Response->InformationBufferOffset = CPU_TO_LE32(0);\r
+ }\r
+\r
+ break;\r
+ case REMOTE_NDIS_SET_MSG:\r
+ RNDISInterfaceInfo->State.ResponseReady = true;\r
+\r
+ RNDIS_Set_Message_t* SET_Message = (RNDIS_Set_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;\r
+ RNDIS_Set_Complete_t* SET_Response = (RNDIS_Set_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;\r
+ uint32_t SET_Oid = le32_to_cpu(SET_Message->Oid);\r
+\r
+ SET_Response->MessageType = CPU_TO_LE32(REMOTE_NDIS_SET_CMPLT);\r
+ SET_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_Set_Complete_t));\r
+ SET_Response->RequestId = SET_Message->RequestId;\r
+\r
+ void* SetData = &RNDISInterfaceInfo->State.RNDISMessageBuffer[sizeof(RNDIS_Message_Header_t) +\r
+ le32_to_cpu(SET_Message->InformationBufferOffset)];\r
+\r
+ SET_Response->Status = RNDIS_Device_ProcessNDISSet(RNDISInterfaceInfo, SET_Oid, SetData,\r
+ le32_to_cpu(SET_Message->InformationBufferLength)) ?\r
+ REMOTE_NDIS_STATUS_SUCCESS : REMOTE_NDIS_STATUS_NOT_SUPPORTED;\r
+ break;\r
+ case REMOTE_NDIS_RESET_MSG:\r
+ RNDISInterfaceInfo->State.ResponseReady = true;\r
+\r
+ RNDIS_Reset_Complete_t* RESET_Response = (RNDIS_Reset_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;\r
+\r
+ RESET_Response->MessageType = CPU_TO_LE32(REMOTE_NDIS_RESET_CMPLT);\r
+ RESET_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_Reset_Complete_t));\r
+ RESET_Response->Status = CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS);\r
+ RESET_Response->AddressingReset = CPU_TO_LE32(0);\r
+\r
+ break;\r
+ case REMOTE_NDIS_KEEPALIVE_MSG:\r
+ RNDISInterfaceInfo->State.ResponseReady = true;\r
+\r
+ RNDIS_KeepAlive_Message_t* KEEPALIVE_Message =\r
+ (RNDIS_KeepAlive_Message_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;\r
+ RNDIS_KeepAlive_Complete_t* KEEPALIVE_Response =\r
+ (RNDIS_KeepAlive_Complete_t*)&RNDISInterfaceInfo->State.RNDISMessageBuffer;\r
+\r
+ KEEPALIVE_Response->MessageType = CPU_TO_LE32(REMOTE_NDIS_KEEPALIVE_CMPLT);\r
+ KEEPALIVE_Response->MessageLength = CPU_TO_LE32(sizeof(RNDIS_KeepAlive_Complete_t));\r
+ KEEPALIVE_Response->RequestId = KEEPALIVE_Message->RequestId;\r
+ KEEPALIVE_Response->Status = CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS);\r
+\r
+ break;\r
+ }\r
+}\r
+\r
+static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,\r
+ const uint32_t OId,\r
+ void* const QueryData,\r
+ const uint16_t QuerySize,\r
+ void* ResponseData,\r
+ uint16_t* const ResponseSize)\r
+{\r
+ (void)QueryData;\r
+ (void)QuerySize;\r
+\r
+ switch (OId)\r
+ {\r
+ case OID_GEN_SUPPORTED_LIST:\r
+ *ResponseSize = sizeof(AdapterSupportedOIDList);\r
+\r
+ memcpy_P(ResponseData, AdapterSupportedOIDList, sizeof(AdapterSupportedOIDList));\r
+\r
+ return true;\r
+ case OID_GEN_PHYSICAL_MEDIUM:\r
+ *ResponseSize = sizeof(uint32_t);\r
+\r
+ /* Indicate that the device is a true ethernet link */\r
+ *((uint32_t*)ResponseData) = CPU_TO_LE32(0);\r
+\r
+ return true;\r
+ case OID_GEN_HARDWARE_STATUS:\r
+ *ResponseSize = sizeof(uint32_t);\r
+\r
+ *((uint32_t*)ResponseData) = CPU_TO_LE32(NDIS_HardwareStatus_Ready);\r
+\r
+ return true;\r
+ case OID_GEN_MEDIA_SUPPORTED:\r
+ case OID_GEN_MEDIA_IN_USE:\r
+ *ResponseSize = sizeof(uint32_t);\r
+\r
+ *((uint32_t*)ResponseData) = CPU_TO_LE32(REMOTE_NDIS_MEDIUM_802_3);\r
+\r
+ return true;\r
+ case OID_GEN_VENDOR_ID:\r
+ *ResponseSize = sizeof(uint32_t);\r
+\r
+ /* Vendor ID 0x0xFFFFFF is reserved for vendors who have not purchased a NDIS VID */\r
+ *((uint32_t*)ResponseData) = CPU_TO_LE32(0x00FFFFFF);\r
+\r
+ return true;\r
+ case OID_GEN_MAXIMUM_FRAME_SIZE:\r
+ case OID_GEN_TRANSMIT_BLOCK_SIZE:\r
+ case OID_GEN_RECEIVE_BLOCK_SIZE:\r
+ *ResponseSize = sizeof(uint32_t);\r
+\r
+ *((uint32_t*)ResponseData) = CPU_TO_LE32(ETHERNET_FRAME_SIZE_MAX);\r
+\r
+ return true;\r
+ case OID_GEN_VENDOR_DESCRIPTION:\r
+ *ResponseSize = (strlen(RNDISInterfaceInfo->Config.AdapterVendorDescription) + 1);\r
+\r
+ memcpy(ResponseData, RNDISInterfaceInfo->Config.AdapterVendorDescription, *ResponseSize);\r
+\r
+ return true;\r
+ case OID_GEN_MEDIA_CONNECT_STATUS:\r
+ *ResponseSize = sizeof(uint32_t);\r
+\r
+ *((uint32_t*)ResponseData) = CPU_TO_LE32(REMOTE_NDIS_MEDIA_STATE_CONNECTED);\r
+\r
+ return true;\r
+ case OID_GEN_LINK_SPEED:\r
+ *ResponseSize = sizeof(uint32_t);\r
+\r
+ /* Indicate 10Mb/s link speed */\r
+ *((uint32_t*)ResponseData) = CPU_TO_LE32(100000);\r
+\r
+ return true;\r
+ case OID_802_3_PERMANENT_ADDRESS:\r
+ case OID_802_3_CURRENT_ADDRESS:\r
+ *ResponseSize = sizeof(MAC_Address_t);\r
+\r
+ memcpy(ResponseData, &RNDISInterfaceInfo->Config.AdapterMACAddress, sizeof(MAC_Address_t));\r
+\r
+ return true;\r
+ case OID_802_3_MAXIMUM_LIST_SIZE:\r
+ *ResponseSize = sizeof(uint32_t);\r
+\r
+ /* Indicate only one multicast address supported */\r
+ *((uint32_t*)ResponseData) = CPU_TO_LE32(1);\r
+\r
+ return true;\r
+ case OID_GEN_CURRENT_PACKET_FILTER:\r
+ *ResponseSize = sizeof(uint32_t);\r
+\r
+ *((uint32_t*)ResponseData) = cpu_to_le32(RNDISInterfaceInfo->State.CurrPacketFilter);\r
+\r
+ return true;\r
+ case OID_GEN_XMIT_OK:\r
+ case OID_GEN_RCV_OK:\r
+ case OID_GEN_XMIT_ERROR:\r
+ case OID_GEN_RCV_ERROR:\r
+ case OID_GEN_RCV_NO_BUFFER:\r
+ case OID_802_3_RCV_ERROR_ALIGNMENT:\r
+ case OID_802_3_XMIT_ONE_COLLISION:\r
+ case OID_802_3_XMIT_MORE_COLLISIONS:\r
+ *ResponseSize = sizeof(uint32_t);\r
+\r
+ /* Unused statistic OIDs - always return 0 for each */\r
+ *((uint32_t*)ResponseData) = CPU_TO_LE32(0);\r
+\r
+ return true;\r
+ case OID_GEN_MAXIMUM_TOTAL_SIZE:\r
+ *ResponseSize = sizeof(uint32_t);\r
+\r
+ /* Indicate maximum overall buffer (Ethernet frame and RNDIS header) the adapter can handle */\r
+ *((uint32_t*)ResponseData) = CPU_TO_LE32(RNDIS_MESSAGE_BUFFER_SIZE + ETHERNET_FRAME_SIZE_MAX);\r
+\r
+ return true;\r
+ default:\r
+ return false;\r
+ }\r
+}\r
+\r
+static bool RNDIS_Device_ProcessNDISSet(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,\r
+ const uint32_t OId,\r
+ const void* SetData,\r
+ const uint16_t SetSize)\r
+{\r
+ (void)SetSize;\r
+\r
+ switch (OId)\r
+ {\r
+ case OID_GEN_CURRENT_PACKET_FILTER:\r
+ RNDISInterfaceInfo->State.CurrPacketFilter = le32_to_cpu(*((uint32_t*)SetData));\r
+ RNDISInterfaceInfo->State.CurrRNDISState = (RNDISInterfaceInfo->State.CurrPacketFilter) ? RNDIS_Data_Initialized : RNDIS_Initialized;\r
+\r
+ return true;\r
+ case OID_802_3_MULTICAST_LIST:\r
+ /* Do nothing - throw away the value from the host as it is unused */\r
+\r
+ return true;\r
+ default:\r
+ return false;\r
+ }\r
+}\r
+\r
+bool RNDIS_Device_IsPacketReceived(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)\r
+{\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) ||\r
+ (RNDISInterfaceInfo->State.CurrRNDISState != RNDIS_Data_Initialized))\r
+ {\r
+ return false;\r
+ }\r
+\r
+ Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpoint.Address);\r
+ return Endpoint_IsOUTReceived();\r
+}\r
+\r
+uint8_t RNDIS_Device_ReadPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,\r
+ void* Buffer,\r
+ uint16_t* const PacketLength)\r
+{\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) ||\r
+ (RNDISInterfaceInfo->State.CurrRNDISState != RNDIS_Data_Initialized))\r
+ {\r
+ return ENDPOINT_RWSTREAM_DeviceDisconnected;\r
+ }\r
+\r
+ Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataOUTEndpoint.Address);\r
+\r
+ *PacketLength = 0;\r
+\r
+ if (!(Endpoint_IsOUTReceived()))\r
+ return ENDPOINT_RWSTREAM_NoError;\r
+\r
+ RNDIS_Packet_Message_t RNDISPacketHeader;\r
+ Endpoint_Read_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_Packet_Message_t), NULL);\r
+\r
+ if (le32_to_cpu(RNDISPacketHeader.DataLength) > ETHERNET_FRAME_SIZE_MAX)\r
+ {\r
+ Endpoint_StallTransaction();\r
+\r
+ return RNDIS_ERROR_LOGICAL_CMD_FAILED;\r
+ }\r
+\r
+ *PacketLength = (uint16_t)le32_to_cpu(RNDISPacketHeader.DataLength);\r
+\r
+ Endpoint_Read_Stream_LE(Buffer, *PacketLength, NULL);\r
+ Endpoint_ClearOUT();\r
+\r
+ return ENDPOINT_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t RNDIS_Device_SendPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t PacketLength)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ if ((USB_DeviceState != DEVICE_STATE_Configured) ||\r
+ (RNDISInterfaceInfo->State.CurrRNDISState != RNDIS_Data_Initialized))\r
+ {\r
+ return ENDPOINT_RWSTREAM_DeviceDisconnected;\r
+ }\r
+\r
+ Endpoint_SelectEndpoint(RNDISInterfaceInfo->Config.DataINEndpoint.Address);\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()) != ENDPOINT_READYWAIT_NoError)\r
+ return ErrorCode;\r
+\r
+ RNDIS_Packet_Message_t RNDISPacketHeader;\r
+\r
+ memset(&RNDISPacketHeader, 0, sizeof(RNDIS_Packet_Message_t));\r
+\r
+ RNDISPacketHeader.MessageType = CPU_TO_LE32(REMOTE_NDIS_PACKET_MSG);\r
+ RNDISPacketHeader.MessageLength = cpu_to_le32(sizeof(RNDIS_Packet_Message_t) + PacketLength);\r
+ RNDISPacketHeader.DataOffset = CPU_TO_LE32(sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t));\r
+ RNDISPacketHeader.DataLength = cpu_to_le32(PacketLength);\r
+\r
+ Endpoint_Write_Stream_LE(&RNDISPacketHeader, sizeof(RNDIS_Packet_Message_t), NULL);\r
+ Endpoint_Write_Stream_LE(Buffer, PacketLength, NULL);\r
+ Endpoint_ClearIN();\r
+\r
+ return ENDPOINT_RWSTREAM_NoError;\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Device mode driver for the library USB RNDIS Class driver.\r
+ *\r
+ * Device mode driver for the library USB RNDIS Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassRNDIS\r
+ * \defgroup Group_USBClassRNDISDevice RNDIS Class Device Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Device Mode USB Class driver framework interface, for the RNDIS USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _RNDIS_CLASS_DEVICE_H_\r
+#define _RNDIS_CLASS_DEVICE_H_\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/RNDISClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_RNDIS_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** \brief RNDIS Class Device Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made for each RNDIS interface\r
+ * within the user application, and passed to each of the RNDIS class driver functions as the\r
+ * \c RNDISInterfaceInfo parameter. This stores each RNDIS interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ uint8_t ControlInterfaceNumber; /**< Interface number of the RNDIS control interface within the device. */\r
+\r
+ USB_Endpoint_Table_t DataINEndpoint; /**< Data IN endpoint configuration table. */\r
+ USB_Endpoint_Table_t DataOUTEndpoint; /**< Data OUT endpoint configuration table. */\r
+ USB_Endpoint_Table_t NotificationEndpoint; /**< Notification IN Endpoint configuration table. */\r
+\r
+ char* AdapterVendorDescription; /**< String description of the adapter vendor. */\r
+ MAC_Address_t AdapterMACAddress; /**< MAC address of the adapter. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ uint8_t RNDISMessageBuffer[RNDIS_MESSAGE_BUFFER_SIZE]; /**< Buffer to hold RNDIS messages to and from the host,\r
+ * managed by the class driver.\r
+ */\r
+ bool ResponseReady; /**< Internal flag indicating if a RNDIS message is waiting to be returned to the host. */\r
+ uint8_t CurrRNDISState; /**< Current RNDIS state of the adapter, a value from the \ref RNDIS_States_t enum. */\r
+ uint32_t CurrPacketFilter; /**< Current packet filter mode, used internally by the class driver. */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * are reset to their defaults when the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_RNDIS_Device_t;\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures the endpoints of a given RNDIS interface, ready for use. This should be linked to the library\r
+ * \ref EVENT_USB_Device_ConfigurationChanged() event so that the endpoints are configured when the configuration\r
+ * containing the given RNDIS interface is selected.\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.\r
+ *\r
+ * \return Boolean \c true if the endpoints were successfully configured, \c false otherwise.\r
+ */\r
+ bool RNDIS_Device_ConfigureEndpoints(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Processes incoming control requests from the host, that are directed to the given RNDIS class interface. This should be\r
+ * linked to the library \ref EVENT_USB_Device_ControlRequest() event.\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.\r
+ */\r
+ void RNDIS_Device_ProcessControlRequest(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** General management task for a given RNDIS class interface, required for the correct operation of the interface. This should\r
+ * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing a RNDIS Class configuration and state.\r
+ */\r
+ void RNDIS_Device_USBTask(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Determines if a packet is currently waiting for the device to read in and process.\r
+ *\r
+ * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class configuration and state.\r
+ *\r
+ * \return Boolean \c true if a packet is waiting to be read in by the host, \c false otherwise.\r
+ */\r
+ bool RNDIS_Device_IsPacketReceived(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo);\r
+\r
+ /** Retrieves the next pending packet from the device, discarding the remainder of the RNDIS packet header to leave\r
+ * only the packet contents for processing by the device in the nominated buffer.\r
+ *\r
+ * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class configuration and state.\r
+ * \param[out] Buffer Pointer to a buffer where the packer data is to be written to.\r
+ * \param[out] PacketLength Pointer to where the length in bytes of the read packet is to be stored.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t RNDIS_Device_ReadPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,\r
+ void* Buffer,\r
+ uint16_t* const PacketLength);\r
+\r
+ /** Sends the given packet to the attached RNDIS device, after adding a RNDIS packet message header.\r
+ *\r
+ * \pre This function must only be called when the Device state machine is in the \ref DEVICE_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class configuration and state.\r
+ * \param[in] Buffer Pointer to a buffer where the packer data is to be read from.\r
+ * \param[in] PacketLength Length in bytes of the packet to send.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t RNDIS_Device_SendPacket(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t PacketLength);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_RNDIS_DEVICE_C)\r
+ static void RNDIS_Device_ProcessRNDISControlMessage(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1);\r
+ static bool RNDIS_Device_ProcessNDISQuery(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,\r
+ const uint32_t OId,\r
+ void* const QueryData,\r
+ const uint16_t QuerySize,\r
+ void* ResponseData,\r
+ uint16_t* const ResponseSize) ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_NON_NULL_PTR_ARG(5) ATTR_NON_NULL_PTR_ARG(6);\r
+ static bool RNDIS_Device_ProcessNDISSet(USB_ClassInfo_RNDIS_Device_t* const RNDISInterfaceInfo,\r
+ const uint32_t OId,\r
+ const void* SetData,\r
+ const uint16_t SetSize) ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_NON_NULL_PTR_ARG(3);\r
+ #endif\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master include file for the library USB HID Class driver.\r
+ *\r
+ * Master include file for the library USB HID Class driver, for both host and device modes, where available.\r
+ *\r
+ * This file should be included in all user projects making use of this optional class driver, instead of\r
+ * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories.\r
+ */\r
+\r
+/** \ingroup Group_USBClassDrivers\r
+ * \defgroup Group_USBClassHID HID Class Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Device/HIDClassDevice.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ * - LUFA/Drivers/USB/Class/Host/HIDClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ * - LUFA/Drivers/USB/Class/Host/HIDParser.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * HID Class Driver module. This module contains an internal implementation of the USB HID Class, for both Device\r
+ * and Host USB modes. User applications can use this class driver instead of implementing the HID class manually\r
+ * via the low-level LUFA APIs.\r
+ *\r
+ * This module is designed to simplify the user code by exposing only the required interface needed to interface with\r
+ * Hosts or Devices using the USB HID Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _HID_CLASS_H_\r
+#define _HID_CLASS_H_\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_USB_DRIVER\r
+ #define __INCLUDE_FROM_HID_DRIVER\r
+\r
+ /* Includes: */\r
+ #include "../Core/USBMode.h"\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #include "Device/HIDClassDevice.h"\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #include "Host/HIDClassHost.h"\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_AOA_DRIVER\r
+#define __INCLUDE_FROM_ANDROIDACCESSORY_HOST_C\r
+#include "AndroidAccessoryClassHost.h"\r
+\r
+bool AOA_Host_ValidateAccessoryDevice(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ const USB_Descriptor_Device_t* const DeviceDescriptor,\r
+ bool* const NeedModeSwitch)\r
+{\r
+ (void)AOAInterfaceInfo;\r
+\r
+ if (DeviceDescriptor->Header.Type != DTYPE_Device)\r
+ return false;\r
+\r
+ *NeedModeSwitch = ((DeviceDescriptor->ProductID != ANDROID_ACCESSORY_PRODUCT_ID) &&\r
+ (DeviceDescriptor->ProductID != ANDROID_ACCESSORY_ADB_PRODUCT_ID));\r
+\r
+ return true;\r
+}\r
+\r
+uint8_t AOA_Host_ConfigurePipes(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData)\r
+{\r
+ USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;\r
+ USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;\r
+ USB_Descriptor_Interface_t* AOAInterface = NULL;\r
+\r
+ memset(&AOAInterfaceInfo->State, 0x00, sizeof(AOAInterfaceInfo->State));\r
+\r
+ if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)\r
+ return AOA_ENUMERROR_InvalidConfigDescriptor;\r
+ \r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_AOA_Host_NextAndroidAccessoryInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return AOA_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+ \r
+ AOAInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);\r
+\r
+ while (!(DataINEndpoint) || !(DataOUTEndpoint))\r
+ {\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_AOA_Host_NextInterfaceBulkEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return AOA_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+\r
+ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);\r
+\r
+ if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN)\r
+ DataINEndpoint = EndpointData;\r
+ else\r
+ DataOUTEndpoint = EndpointData;\r
+ }\r
+\r
+ AOAInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize);\r
+ AOAInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress;\r
+ AOAInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK;\r
+ \r
+ AOAInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);\r
+ AOAInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress;\r
+ AOAInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&AOAInterfaceInfo->Config.DataINPipe, 1)))\r
+ return false;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&AOAInterfaceInfo->Config.DataOUTPipe, 1)))\r
+ return false;\r
+\r
+ AOAInterfaceInfo->State.IsActive = true;\r
+ AOAInterfaceInfo->State.InterfaceNumber = AOAInterface->InterfaceNumber;\r
+\r
+ return AOA_ENUMERROR_NoError;\r
+}\r
+\r
+static uint8_t DCOMP_AOA_Host_NextAndroidAccessoryInterface(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Interface)\r
+ {\r
+ USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);\r
+\r
+ if ((Interface->Class == AOA_CSCP_AOADataClass) &&\r
+ (Interface->SubClass == AOA_CSCP_AOADataSubclass) &&\r
+ (Interface->Protocol == AOA_CSCP_AOADataProtocol))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t DCOMP_AOA_Host_NextInterfaceBulkEndpoint(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Endpoint)\r
+ {\r
+ USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);\r
+\r
+ uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);\r
+\r
+ if ((EndpointType == EP_TYPE_BULK) && (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress))))\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ else if (Header->Type == DTYPE_Interface)\r
+ {\r
+ return DESCRIPTOR_SEARCH_Fail;\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+void AOA_Host_USBTask(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))\r
+ return;\r
+\r
+ #if !defined(NO_CLASS_DRIVER_AUTOFLUSH)\r
+ AOA_Host_Flush(AOAInterfaceInfo);\r
+ #endif\r
+}\r
+\r
+uint8_t AOA_Host_StartAccessoryMode(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)\r
+{\r
+ uint8_t ErrorCode;\r
+ \r
+ uint16_t AccessoryProtocol;\r
+ if ((ErrorCode = AOA_Host_GetAccessoryProtocol(&AccessoryProtocol)) != HOST_WAITERROR_Successful)\r
+ return ErrorCode;\r
+\r
+ if (AccessoryProtocol != CPU_TO_LE16(AOA_PROTOCOL_AccessoryV1))\r
+ return AOA_ERROR_LOGICAL_CMD_FAILED;\r
+\r
+ for (uint8_t PropertyIndex = 0; PropertyIndex < AOA_STRING_TOTAL_STRINGS; PropertyIndex++)\r
+ {\r
+ if ((ErrorCode = AOA_Host_SendPropertyString(AOAInterfaceInfo, PropertyIndex)) != HOST_WAITERROR_Successful)\r
+ return ErrorCode;\r
+ }\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_VENDOR | REQREC_DEVICE),\r
+ .bRequest = AOA_REQ_StartAccessoryMode,\r
+ .wValue = 0,\r
+ .wIndex = 0,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+ return USB_Host_SendControlRequest(NULL); \r
+}\r
+\r
+static uint8_t AOA_Host_GetAccessoryProtocol(uint16_t* const Protocol)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_VENDOR | REQREC_DEVICE),\r
+ .bRequest = AOA_REQ_GetAccessoryProtocol,\r
+ .wValue = 0,\r
+ .wIndex = 0,\r
+ .wLength = sizeof(uint16_t),\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+ return USB_Host_SendControlRequest(Protocol);\r
+}\r
+\r
+static uint8_t AOA_Host_SendPropertyString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ const uint8_t StringIndex)\r
+{ \r
+ const char* String = AOAInterfaceInfo->Config.PropertyStrings[StringIndex];\r
+ \r
+ if (String == NULL)\r
+ String = "";\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_VENDOR | REQREC_DEVICE),\r
+ .bRequest = AOA_REQ_SendString,\r
+ .wValue = 0,\r
+ .wIndex = StringIndex,\r
+ .wLength = (strlen(String) + 1),\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+ return USB_Host_SendControlRequest((char*)String);\r
+}\r
+\r
+uint8_t AOA_Host_SendData(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ const uint8_t* const Buffer,\r
+ const uint16_t Length)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address);\r
+\r
+ Pipe_Unfreeze();\r
+ ErrorCode = Pipe_Write_Stream_LE(Buffer, Length, NULL);\r
+ Pipe_Freeze();\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+uint8_t AOA_Host_SendString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ const char* const String)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address);\r
+\r
+ Pipe_Unfreeze();\r
+ ErrorCode = Pipe_Write_Stream_LE(String, strlen(String), NULL);\r
+ Pipe_Freeze();\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+uint8_t AOA_Host_SendByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ const uint8_t Data)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ Pipe_ClearOUT();\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)\r
+ return ErrorCode;\r
+ }\r
+\r
+ Pipe_Write_8(Data);\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_READYWAIT_NoError;\r
+}\r
+\r
+uint16_t AOA_Host_BytesReceived(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))\r
+ return 0;\r
+\r
+ Pipe_SelectPipe(AOAInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_IsINReceived())\r
+ {\r
+ if (!(Pipe_BytesInPipe()))\r
+ {\r
+ Pipe_ClearIN();\r
+ Pipe_Freeze();\r
+ return 0;\r
+ }\r
+ else\r
+ {\r
+ Pipe_Freeze();\r
+ return Pipe_BytesInPipe();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ Pipe_Freeze();\r
+\r
+ return 0;\r
+ }\r
+}\r
+\r
+int16_t AOA_Host_ReceiveByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))\r
+ return -1;\r
+\r
+ int16_t ReceivedByte = -1;\r
+\r
+ Pipe_SelectPipe(AOAInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_IsINReceived())\r
+ {\r
+ if (Pipe_BytesInPipe())\r
+ ReceivedByte = Pipe_Read_8();\r
+\r
+ if (!(Pipe_BytesInPipe()))\r
+ Pipe_ClearIN();\r
+ }\r
+\r
+ Pipe_Freeze();\r
+\r
+ return ReceivedByte;\r
+}\r
+\r
+uint8_t AOA_Host_Flush(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(AOAInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(AOAInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (!(Pipe_BytesInPipe()))\r
+ return PIPE_READYWAIT_NoError;\r
+\r
+ bool BankFull = !(Pipe_IsReadWriteAllowed());\r
+\r
+ Pipe_ClearOUT();\r
+\r
+ if (BankFull)\r
+ {\r
+ if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)\r
+ return ErrorCode;\r
+\r
+ Pipe_ClearOUT();\r
+ }\r
+\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_READYWAIT_NoError;\r
+}\r
+\r
+#if defined(FDEV_SETUP_STREAM)\r
+void AOA_Host_CreateStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ FILE* const Stream)\r
+{\r
+ *Stream = (FILE)FDEV_SETUP_STREAM(AOA_Host_putchar, AOA_Host_getchar, _FDEV_SETUP_RW);\r
+ fdev_set_udata(Stream, AOAInterfaceInfo);\r
+}\r
+\r
+void AOA_Host_CreateBlockingStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ FILE* const Stream)\r
+{\r
+ *Stream = (FILE)FDEV_SETUP_STREAM(AOA_Host_putchar, AOA_Host_getchar_Blocking, _FDEV_SETUP_RW);\r
+ fdev_set_udata(Stream, AOAInterfaceInfo);\r
+}\r
+\r
+static int AOA_Host_putchar(char c,\r
+ FILE* Stream)\r
+{\r
+ return AOA_Host_SendByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0;\r
+}\r
+\r
+static int AOA_Host_getchar(FILE* Stream)\r
+{\r
+ int16_t ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream));\r
+\r
+ if (ReceivedByte < 0)\r
+ return _FDEV_EOF;\r
+\r
+ return ReceivedByte;\r
+}\r
+\r
+static int AOA_Host_getchar_Blocking(FILE* Stream)\r
+{\r
+ int16_t ReceivedByte;\r
+\r
+ while ((ReceivedByte = AOA_Host_ReceiveByte((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream))) < 0)\r
+ {\r
+ if (USB_HostState == HOST_STATE_Unattached)\r
+ return _FDEV_EOF;\r
+\r
+ AOA_Host_USBTask((USB_ClassInfo_AOA_Host_t*)fdev_get_udata(Stream));\r
+ USB_USBTask();\r
+ }\r
+\r
+ return ReceivedByte;\r
+}\r
+#endif\r
+\r
+#endif\r
+\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Host mode driver for the library USB Android Open Accessory Class driver.\r
+ *\r
+ * Host mode driver for the library USB Android Open Accessory Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassAOA\r
+ * \defgroup Group_USBClassAndroidAccessoryHost Android Open Accessory Class Host Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/AndroidAccessoryClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Host Mode USB Class driver framework interface, for the Android Open Accessory USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __AOA_CLASS_HOST_H__\r
+#define __AOA_CLASS_HOST_H__\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/AndroidAccessoryClassCommon.h"\r
+\r
+ #include <stdio.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_AOA_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Error code for some Android Open Accessory Host functions, indicating a logical (and not hardware) error. */\r
+ #define AOA_ERROR_LOGICAL_CMD_FAILED 0x80\r
+\r
+ /* Type Defines: */\r
+ /** \brief Android Open Accessory Class Host Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made within the user application,\r
+ * and passed to each of the Android Open Accessory class driver functions as the \c AOAInterfaceInfo\r
+ * parameter. This stores each Android Open Accessory interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */\r
+ USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */\r
+ \r
+ char* PropertyStrings[AOA_STRING_TOTAL_STRINGS]; /**< Android Accessory property strings, sent to identify the accessory when the\r
+ * Android device is switched into Open Accessory mode. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+ * after \ref AOA_Host_ConfigurePipes() is called and the Host state machine is in the\r
+ * Configured state.\r
+ */\r
+ uint8_t InterfaceNumber; /**< Interface index of the AOA interface within the attached device. */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * <b>may</b> be set to initial values, but may also be ignored to default to sane values when\r
+ * the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_AOA_Host_t;\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error codes returned by the \ref AOA_Host_ConfigurePipes() function. */\r
+ enum AOA_Host_EnumerationFailure_ErrorCodes_t\r
+ {\r
+ AOA_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */\r
+ AOA_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */\r
+ AOA_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Android Open Accessory interface was not found in the device's Configuration Descriptor. */\r
+ AOA_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ /** General management task for a given Android Open Accessory host class interface, required for the correct operation of the interface.\r
+ * This should be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] AOAInterfaceInfo Pointer to a structure containing an Android Open Accessory Class host configuration and state.\r
+ */\r
+ void AOA_Host_USBTask(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Validates a device descriptor, to check if the device is a valid Android device, and if it is currently in Android Open Accessory mode.\r
+ *\r
+ * \param[in,out] AOAInterfaceInfo Pointer to a structure containing an AOA Class host configuration and state.\r
+ * \param[in] DeviceDescriptor Pointer a buffer containing the attached device's Device Descriptor.\r
+ * \param[out] NeedModeSwitch Pointer to a boolean where the mode switch requirement of the attached device is to be stored.\r
+ *\r
+ * \return Boolean \c true if the attached device is a valid Android device, \c false otherwise.\r
+ */\r
+ bool AOA_Host_ValidateAccessoryDevice(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ const USB_Descriptor_Device_t* const DeviceDescriptor,\r
+ bool* const NeedModeSwitch) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Host interface configuration routine, to configure a given Android Open Accessory host interface instance using the Configuration\r
+ * Descriptor read from an attached USB device. This function automatically updates the given Android Open Accessory Host instance's\r
+ * state values and configures the pipes required to communicate with the interface if it is found within the device. This should be\r
+ * called once after the stack has enumerated the attached device, while the host state machine is in the Addressed state.\r
+ *\r
+ * \param[in,out] AOAInterfaceInfo Pointer to a structure containing an AOA Class host configuration and state.\r
+ * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor.\r
+ * \param[in] ConfigDescriptorData Pointer to a buffer containing the attached device's Configuration Descriptor.\r
+ *\r
+ * \return A value from the \ref AOA_Host_EnumerationFailure_ErrorCodes_t enum.\r
+ */\r
+ uint8_t AOA_Host_ConfigurePipes(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+ \r
+ /** Starts Accessory Mode in the attached Android device. This function will validate the device's Android Open Accessory protocol\r
+ * version, send the configured property strings, and request a switch to Android Open Accessory mode.\r
+ *\r
+ * \param[in,out] AOAInterfaceInfo Pointer to a structure containing an AOA Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum, or \ref AOA_ERROR_LOGICAL_CMD_FAILED if a logical error occurred..\r
+ */\r
+ uint8_t AOA_Host_StartAccessoryMode(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sends a given data buffer to the attached USB device, if connected. If a device is not connected when the function is\r
+ * called, the data will be discarded. Bytes will be queued for transmission to the device until either the pipe bank\r
+ * becomes full, or the \ref AOA_Host_Flush() function is called to flush the pending data to the device. This allows for\r
+ * multiple bytes to be packed into a single pipe packet, increasing data throughput.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.\r
+ * \param[in] Buffer Pointer to a buffer containing the data to send to the device.\r
+ * \param[in] Length Length of the data to send to the device.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t AOA_Host_SendData(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ const uint8_t* const Buffer,\r
+ const uint16_t Length);\r
+\r
+ /** Sends a given null-terminated string to the attached USB device, if connected. If a device is not connected when the\r
+ * function is called, the string is discarded. Bytes will be queued for transmission to the device until either the pipe\r
+ * bank becomes full, or the \ref AOA_Host_Flush() function is called to flush the pending data to the device. This allows\r
+ * for multiple bytes to be packed into a single pipe packet, increasing data throughput.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.\r
+ * \param[in] String Pointer to the null terminated string to send to the device.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t AOA_Host_SendString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Sends a given byte to the attached USB device, if connected. If a device is not connected when the function is called, the\r
+ * byte is discarded. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the\r
+ * \ref AOA_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be\r
+ * packed into a single pipe packet, increasing data throughput.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.\r
+ * \param[in] Data Byte of data to send to the device.\r
+ *\r
+ * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t AOA_Host_SendByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Determines the number of bytes received by the AOA interface from the device, waiting to be read. This indicates the number\r
+ * of bytes in the IN pipe bank only, and thus the number of calls to \ref AOA_Host_ReceiveByte() which are guaranteed to succeed\r
+ * immediately. If multiple bytes are to be received, they should be buffered by the user application, as the pipe bank will not be\r
+ * released back to the USB controller until all bytes are read.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.\r
+ *\r
+ * \return Total number of buffered bytes received from the device.\r
+ */\r
+ uint16_t AOA_Host_BytesReceived(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads a byte of data from the device. If no data is waiting to be read of if a USB device is not connected, the function\r
+ * returns a negative value. The \ref AOA_Host_BytesReceived() function may be queried in advance to determine how many bytes\r
+ * are currently buffered in the AOA interface's data receive pipe.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.\r
+ *\r
+ * \return Next received byte from the device, or a negative value if no data received.\r
+ */\r
+ int16_t AOA_Host_ReceiveByte(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t AOA_Host_Flush(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Creates a standard character stream for the given AOA Device instance so that it can be used with all the regular\r
+ * functions in the standard \c <stdio.h> library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created\r
+ * stream is bidirectional and can be used for both input and output functions.\r
+ *\r
+ * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single\r
+ * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may\r
+ * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own\r
+ * line buffering.\r
+ *\r
+ * \note The created stream can be given as \c stdout if desired to direct the standard output from all \c <stdio.h> functions\r
+ * to the given AOA interface.\r
+ * \n\n\r
+ *\r
+ * \note This function is not available on all microcontroller architectures.\r
+ *\r
+ * \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class configuration and state.\r
+ * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.\r
+ */\r
+ void AOA_Host_CreateStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ FILE* const Stream);\r
+\r
+ /** Identical to \ref AOA_Host_CreateStream(), except that reads are blocking until the calling stream function terminates\r
+ * the transfer. While blocking, the USB and AOA service tasks are called repeatedly to maintain USB communications.\r
+ *\r
+ * \note This function is not available on all microcontroller architectures.\r
+ *\r
+ * \param[in,out] AOAInterfaceInfo Pointer to a structure containing a AOA Class configuration and state.\r
+ * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.\r
+ */\r
+ void AOA_Host_CreateBlockingStream(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ FILE* const Stream);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_ANDROIDACCESSORY_HOST_C)\r
+ #if defined(FDEV_SETUP_STREAM)\r
+ static int AOA_Host_putchar(char c,\r
+ FILE* Stream) ATTR_NON_NULL_PTR_ARG(2);\r
+ static int AOA_Host_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);\r
+ static int AOA_Host_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+\r
+ static uint8_t AOA_Host_GetAccessoryProtocol(uint16_t* const Protocol) ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t AOA_Host_SendPropertyString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,\r
+ const uint8_t StringIndex) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ static uint8_t DCOMP_AOA_Host_NextAndroidAccessoryInterface(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_AOA_Host_NextInterfaceBulkEndpoint(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_AUDIO_DRIVER\r
+#define __INCLUDE_FROM_AUDIO_HOST_C\r
+#include "AudioClassHost.h"\r
+\r
+uint8_t Audio_Host_ConfigurePipes(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData)\r
+{\r
+ USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;\r
+ USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;\r
+ USB_Descriptor_Interface_t* AudioControlInterface = NULL;\r
+ USB_Descriptor_Interface_t* AudioStreamingInterface = NULL;\r
+\r
+ memset(&AudioInterfaceInfo->State, 0x00, sizeof(AudioInterfaceInfo->State));\r
+\r
+ if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)\r
+ return AUDIO_ENUMERROR_InvalidConfigDescriptor;\r
+\r
+ while ((AudioInterfaceInfo->Config.DataINPipe.Address && !(DataINEndpoint)) ||\r
+ (AudioInterfaceInfo->Config.DataOUTPipe.Address && !(DataOUTEndpoint)))\r
+ {\r
+ if (!(AudioControlInterface) ||\r
+ USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_Audio_Host_NextAudioInterfaceDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ if (!(AudioControlInterface) ||\r
+ USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_Audio_Host_NextAudioStreamInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_Audio_Host_NextAudioControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return AUDIO_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+\r
+ AudioControlInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);\r
+\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_Audio_Host_NextAudioStreamInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return AUDIO_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+ }\r
+\r
+ AudioStreamingInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);\r
+\r
+ DataINEndpoint = NULL;\r
+ DataOUTEndpoint = NULL;\r
+\r
+ continue;\r
+ }\r
+\r
+ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);\r
+\r
+ if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN)\r
+ DataINEndpoint = EndpointData;\r
+ else\r
+ DataOUTEndpoint = EndpointData;\r
+ }\r
+\r
+ AudioInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize);\r
+ AudioInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress;\r
+ AudioInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_ISOCHRONOUS;\r
+ AudioInterfaceInfo->Config.DataINPipe.Banks = 2;\r
+ \r
+ AudioInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);\r
+ AudioInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress;\r
+ AudioInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_ISOCHRONOUS;\r
+ AudioInterfaceInfo->Config.DataOUTPipe.Banks = 2;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&AudioInterfaceInfo->Config.DataINPipe, 1)))\r
+ return false;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&AudioInterfaceInfo->Config.DataOUTPipe, 1)))\r
+ return false;\r
+\r
+ AudioInterfaceInfo->State.ControlInterfaceNumber = AudioControlInterface->InterfaceNumber;\r
+ AudioInterfaceInfo->State.StreamingInterfaceNumber = AudioStreamingInterface->InterfaceNumber;\r
+ AudioInterfaceInfo->State.EnabledStreamingAltIndex = AudioStreamingInterface->AlternateSetting;\r
+ AudioInterfaceInfo->State.IsActive = true;\r
+\r
+ return AUDIO_ENUMERROR_NoError;\r
+}\r
+\r
+static uint8_t DCOMP_Audio_Host_NextAudioControlInterface(void* CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Interface)\r
+ {\r
+ USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);\r
+\r
+ if ((Interface->Class == AUDIO_CSCP_AudioClass) &&\r
+ (Interface->SubClass == AUDIO_CSCP_ControlSubclass) &&\r
+ (Interface->Protocol == AUDIO_CSCP_ControlProtocol))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t DCOMP_Audio_Host_NextAudioStreamInterface(void* CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Interface)\r
+ {\r
+ USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);\r
+\r
+ if ((Interface->Class == AUDIO_CSCP_AudioClass) &&\r
+ (Interface->SubClass == AUDIO_CSCP_AudioStreamingSubclass) &&\r
+ (Interface->Protocol == AUDIO_CSCP_StreamingProtocol))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t DCOMP_Audio_Host_NextAudioInterfaceDataEndpoint(void* CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Endpoint)\r
+ {\r
+ USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);\r
+\r
+ if ((Endpoint->Attributes & EP_TYPE_MASK) == EP_TYPE_ISOCHRONOUS)\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ else if (Header->Type == DTYPE_Interface)\r
+ {\r
+ return DESCRIPTOR_SEARCH_Fail;\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+uint8_t Audio_Host_StartStopStreaming(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+ const bool EnableStreaming)\r
+{\r
+ if (!(AudioInterfaceInfo->State.IsActive))\r
+ return HOST_SENDCONTROL_DeviceDisconnected;\r
+\r
+ return USB_Host_SetInterfaceAltSetting(AudioInterfaceInfo->State.StreamingInterfaceNumber,\r
+ EnableStreaming ? AudioInterfaceInfo->State.EnabledStreamingAltIndex : 0);\r
+}\r
+\r
+uint8_t Audio_Host_GetSetEndpointProperty(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+ const uint8_t DataPipeIndex,\r
+ const uint8_t EndpointProperty,\r
+ const uint8_t EndpointControl,\r
+ const uint16_t DataLength,\r
+ void* const Data)\r
+{\r
+ if (!(AudioInterfaceInfo->State.IsActive))\r
+ return HOST_SENDCONTROL_DeviceDisconnected;\r
+\r
+ uint8_t RequestType;\r
+ uint8_t EndpointAddress;\r
+\r
+ if (EndpointProperty & 0x80)\r
+ RequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT);\r
+ else\r
+ RequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_ENDPOINT);\r
+\r
+ Pipe_SelectPipe(DataPipeIndex);\r
+ EndpointAddress = Pipe_GetBoundEndpointAddress();\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = RequestType,\r
+ .bRequest = EndpointProperty,\r
+ .wValue = ((uint16_t)EndpointControl << 8),\r
+ .wIndex = EndpointAddress,\r
+ .wLength = DataLength,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(Data);\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Host mode driver for the library USB Audio 1.0 Class driver.\r
+ *\r
+ * Host mode driver for the library USB Audio 1.0 Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassAudio\r
+ * \defgroup Group_USBClassAudioHost Audio 1.0 Class Host Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/AudioClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Host Mode USB Class driver framework interface, for the Audio 1.0 USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __AUDIO_CLASS_HOST_H__\r
+#define __AUDIO_CLASS_HOST_H__\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/AudioClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_AUDIO_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** \brief Audio Class Host Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made within the user application,\r
+ * and passed to each of the Audio class driver functions as the \c AudioInterfaceInfo parameter. This\r
+ * stores each Audio interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */\r
+ USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+ * after \ref Audio_Host_ConfigurePipes() is called and the Host state machine is in the\r
+ * Configured state.\r
+ */\r
+ uint8_t ControlInterfaceNumber; /**< Interface index of the Audio Control interface within the attached device. */\r
+ uint8_t StreamingInterfaceNumber; /**< Interface index of the Audio Streaming interface within the attached device. */\r
+\r
+ uint8_t EnabledStreamingAltIndex; /**< Alternative setting index of the Audio Streaming interface when the stream is enabled. */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * <b>may</b> be set to initial values, but may also be ignored to default to sane values when\r
+ * the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_Audio_Host_t;\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error codes returned by the \ref Audio_Host_ConfigurePipes() function. */\r
+ enum AUDIO_Host_EnumerationFailure_ErrorCodes_t\r
+ {\r
+ AUDIO_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */\r
+ AUDIO_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */\r
+ AUDIO_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible AUDIO interface was not found in the device's Configuration Descriptor. */\r
+ AUDIO_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ /** Host interface configuration routine, to configure a given Audio host interface instance using the Configuration\r
+ * Descriptor read from an attached USB device. This function automatically updates the given Audio Host instance's\r
+ * state values and configures the pipes required to communicate with the interface if it is found within the\r
+ * device. This should be called once after the stack has enumerated the attached device, while the host state\r
+ * machine is in the Addressed state.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class host configuration and state.\r
+ * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor.\r
+ * \param[in] ConfigDescriptorData Pointer to a buffer containing the attached device's Configuration Descriptor.\r
+ *\r
+ * \return A value from the \ref AUDIO_Host_EnumerationFailure_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Audio_Host_ConfigurePipes(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Starts or stops the audio streaming for the given configured Audio Host interface, allowing for audio samples to be\r
+ * send and/or received.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class host configuration and state.\r
+ * \param[in] EnableStreaming Boolean true to enable streaming of the specified interface, false to disable\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+ */\r
+ uint8_t Audio_Host_StartStopStreaming(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+ const bool EnableStreaming) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Gets or sets the specified property of a streaming audio class endpoint that is bound to a pipe in the given\r
+ * class instance.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class host configuration and state.\r
+ * \param[in] DataPipeIndex Index of the data pipe whose bound endpoint is to be altered.\r
+ * \param[in] EndpointProperty Property of the endpoint to get or set, a value from \ref Audio_ClassRequests_t.\r
+ * \param[in] EndpointControl Parameter of the endpoint to get or set, a value from \ref Audio_EndpointControls_t.\r
+ * \param[in,out] DataLength For SET operations, the length of the parameter data to set. For GET operations, the maximum\r
+ * length of the retrieved data.\r
+ * \param[in,out] Data Pointer to a location where the parameter data is stored for SET operations, or where\r
+ * the retrieved data is to be stored for GET operations.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+ */\r
+ uint8_t Audio_Host_GetSetEndpointProperty(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+ const uint8_t DataPipeIndex,\r
+ const uint8_t EndpointProperty,\r
+ const uint8_t EndpointControl,\r
+ const uint16_t DataLength,\r
+ void* const Data) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6);\r
+\r
+ /* Inline Functions: */\r
+ /** General management task for a given Audio host class interface, required for the correct operation of\r
+ * the interface. This should be called frequently in the main program loop, before the master USB management task\r
+ * \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class host configuration and state.\r
+ */\r
+ static inline void Audio_Host_USBTask(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline void Audio_Host_USBTask(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo)\r
+ {\r
+ (void)AudioInterfaceInfo;\r
+ }\r
+\r
+ /** Determines if the given audio interface is ready for a sample to be read from it, and selects the streaming\r
+ * IN pipe ready for reading.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or\r
+ * the call will fail.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ *\r
+ * \return Boolean \c true if the given Audio interface has a sample to be read, \c false otherwise.\r
+ */\r
+ static inline bool Audio_Host_IsSampleReceived(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline bool Audio_Host_IsSampleReceived(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo)\r
+ {\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(AudioInterfaceInfo->State.IsActive))\r
+ return false;\r
+\r
+ bool SampleReceived = false;\r
+\r
+ Pipe_SelectPipe(AudioInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+ SampleReceived = Pipe_IsINReceived();\r
+ Pipe_Freeze();\r
+\r
+ return SampleReceived;\r
+ }\r
+\r
+ /** Determines if the given audio interface is ready to accept the next sample to be written to it, and selects\r
+ * the streaming OUT pipe ready for writing.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or\r
+ * the call will fail.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ *\r
+ * \return Boolean \c true if the given Audio interface is ready to accept the next sample, \c false otherwise.\r
+ */\r
+ static inline bool Audio_Host_IsReadyForNextSample(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline bool Audio_Host_IsReadyForNextSample(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo)\r
+ {\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(AudioInterfaceInfo->State.IsActive))\r
+ return false;\r
+\r
+ Pipe_SelectPipe(AudioInterfaceInfo->Config.DataOUTPipe.Address);\r
+ return Pipe_IsOUTReady();\r
+ }\r
+\r
+ /** Reads the next 8-bit audio sample from the current audio interface.\r
+ *\r
+ * \pre This should be preceded immediately by a call to the \ref Audio_Host_IsSampleReceived() function to ensure\r
+ * that the correct pipe is selected and ready for data.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ *\r
+ * \return Signed 8-bit audio sample from the audio interface.\r
+ */\r
+ static inline int8_t Audio_Host_ReadSample8(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline int8_t Audio_Host_ReadSample8(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo)\r
+ {\r
+ int8_t Sample;\r
+\r
+ (void)AudioInterfaceInfo;\r
+\r
+ Sample = Pipe_Read_8();\r
+\r
+ if (!(Pipe_BytesInPipe()))\r
+ {\r
+ Pipe_Unfreeze();\r
+ Pipe_ClearIN();\r
+ Pipe_Freeze();\r
+ }\r
+\r
+ return Sample;\r
+ }\r
+\r
+ /** Reads the next 16-bit audio sample from the current audio interface.\r
+ *\r
+ * \pre This should be preceded immediately by a call to the \ref Audio_Host_IsSampleReceived() function to ensure\r
+ * that the correct pipe is selected and ready for data.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ *\r
+ * \return Signed 16-bit audio sample from the audio interface.\r
+ */\r
+ static inline int16_t Audio_Host_ReadSample16(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline int16_t Audio_Host_ReadSample16(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo)\r
+ {\r
+ int16_t Sample;\r
+\r
+ (void)AudioInterfaceInfo;\r
+\r
+ Sample = (int16_t)Pipe_Read_16_LE();\r
+\r
+ if (!(Pipe_BytesInPipe()))\r
+ {\r
+ Pipe_Unfreeze();\r
+ Pipe_ClearIN();\r
+ Pipe_Freeze();\r
+ }\r
+\r
+ return Sample;\r
+ }\r
+\r
+ /** Reads the next 24-bit audio sample from the current audio interface.\r
+ *\r
+ * \pre This should be preceded immediately by a call to the \ref Audio_Host_IsSampleReceived() function to ensure\r
+ * that the correct pipe is selected and ready for data.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ *\r
+ * \return Signed 24-bit audio sample from the audio interface.\r
+ */\r
+ static inline int32_t Audio_Host_ReadSample24(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline int32_t Audio_Host_ReadSample24(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo)\r
+ {\r
+ int32_t Sample;\r
+\r
+ (void)AudioInterfaceInfo;\r
+\r
+ Sample = (((uint32_t)Pipe_Read_8() << 16) | Pipe_Read_16_LE());\r
+\r
+ if (!(Pipe_BytesInPipe()))\r
+ {\r
+ Pipe_Unfreeze();\r
+ Pipe_ClearIN();\r
+ Pipe_Freeze();\r
+ }\r
+\r
+ return Sample;\r
+ }\r
+\r
+ /** Writes the next 8-bit audio sample to the current audio interface.\r
+ *\r
+ * \pre This should be preceded immediately by a call to the \ref Audio_Host_IsReadyForNextSample() function to\r
+ * ensure that the correct pipe is selected and ready for data.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ * \param[in] Sample Signed 8-bit audio sample.\r
+ */\r
+ static inline void Audio_Host_WriteSample8(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+ const int8_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline void Audio_Host_WriteSample8(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+ const int8_t Sample)\r
+ {\r
+ (void)AudioInterfaceInfo;\r
+\r
+ Pipe_Write_8(Sample);\r
+\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ Pipe_Unfreeze();\r
+ Pipe_ClearOUT();\r
+ Pipe_WaitUntilReady();\r
+ Pipe_Freeze();\r
+ }\r
+ }\r
+\r
+ /** Writes the next 16-bit audio sample to the current audio interface.\r
+ *\r
+ * \pre This should be preceded immediately by a call to the \ref Audio_Host_IsReadyForNextSample() function to\r
+ * ensure that the correct pipe is selected and ready for data.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ * \param[in] Sample Signed 16-bit audio sample.\r
+ */\r
+ static inline void Audio_Host_WriteSample16(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+ const int16_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline void Audio_Host_WriteSample16(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+ const int16_t Sample)\r
+ {\r
+ (void)AudioInterfaceInfo;\r
+\r
+ Pipe_Write_16_LE(Sample);\r
+\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ Pipe_Unfreeze();\r
+ Pipe_ClearOUT();\r
+ Pipe_WaitUntilReady();\r
+ Pipe_Freeze();\r
+ }\r
+ }\r
+\r
+ /** Writes the next 24-bit audio sample to the current audio interface.\r
+ *\r
+ * \pre This should be preceded immediately by a call to the \ref Audio_Host_IsReadyForNextSample() function to\r
+ * ensure that the correct pipe is selected and ready for data.\r
+ *\r
+ * \param[in,out] AudioInterfaceInfo Pointer to a structure containing an Audio Class configuration and state.\r
+ * \param[in] Sample Signed 24-bit audio sample.\r
+ */\r
+ static inline void Audio_Host_WriteSample24(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+ const int32_t Sample) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline void Audio_Host_WriteSample24(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo,\r
+ const int32_t Sample)\r
+ {\r
+ (void)AudioInterfaceInfo;\r
+\r
+ Pipe_Write_16_LE(Sample);\r
+ Pipe_Write_8(Sample >> 16);\r
+\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ Pipe_Unfreeze();\r
+ Pipe_ClearOUT();\r
+ Pipe_WaitUntilReady();\r
+ Pipe_Freeze();\r
+ }\r
+ }\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_AUDIO_HOST_C)\r
+ static uint8_t DCOMP_Audio_Host_NextAudioControlInterface(void* CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_Audio_Host_NextAudioStreamInterface(void* CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_Audio_Host_NextAudioInterfaceDataEndpoint(void* CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_CDC_DRIVER\r
+#define __INCLUDE_FROM_CDC_HOST_C\r
+#include "CDCClassHost.h"\r
+\r
+uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData)\r
+{\r
+ USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;\r
+ USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;\r
+ USB_Descriptor_Endpoint_t* NotificationEndpoint = NULL;\r
+ USB_Descriptor_Interface_t* CDCControlInterface = NULL;\r
+\r
+ memset(&CDCInterfaceInfo->State, 0x00, sizeof(CDCInterfaceInfo->State));\r
+\r
+ if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)\r
+ return CDC_ENUMERROR_InvalidConfigDescriptor;\r
+\r
+ while (!(DataINEndpoint) || !(DataOUTEndpoint) || !(NotificationEndpoint))\r
+ {\r
+ if (!(CDCControlInterface) ||\r
+ USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_CDC_Host_NextCDCInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ if (NotificationEndpoint)\r
+ {\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_CDC_Host_NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return CDC_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+\r
+ DataINEndpoint = NULL;\r
+ DataOUTEndpoint = NULL;\r
+ }\r
+ else\r
+ {\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_CDC_Host_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return CDC_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+\r
+ CDCControlInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);\r
+\r
+ NotificationEndpoint = NULL;\r
+ }\r
+\r
+ continue;\r
+ }\r
+\r
+ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);\r
+\r
+ if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN)\r
+ {\r
+ if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT)\r
+ NotificationEndpoint = EndpointData;\r
+ else\r
+ DataINEndpoint = EndpointData;\r
+ }\r
+ else\r
+ {\r
+ DataOUTEndpoint = EndpointData;\r
+ }\r
+ }\r
+\r
+ CDCInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize);\r
+ CDCInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress;\r
+ CDCInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK;\r
+ \r
+ CDCInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);\r
+ CDCInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress;\r
+ CDCInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK;\r
+ \r
+ CDCInterfaceInfo->Config.NotificationPipe.Size = le16_to_cpu(NotificationEndpoint->EndpointSize);\r
+ CDCInterfaceInfo->Config.NotificationPipe.EndpointAddress = NotificationEndpoint->EndpointAddress;\r
+ CDCInterfaceInfo->Config.NotificationPipe.Type = EP_TYPE_INTERRUPT;\r
+\r
+ if (!(Pipe_ConfigurePipeTable(&CDCInterfaceInfo->Config.DataINPipe, 1)))\r
+ return false;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&CDCInterfaceInfo->Config.DataOUTPipe, 1)))\r
+ return false;\r
+\r
+ if (!(Pipe_ConfigurePipeTable(&CDCInterfaceInfo->Config.NotificationPipe, 1)))\r
+ return false;\r
+\r
+ CDCInterfaceInfo->State.ControlInterfaceNumber = CDCControlInterface->InterfaceNumber;\r
+ CDCInterfaceInfo->State.ControlLineStates.HostToDevice = (CDC_CONTROL_LINE_OUT_RTS | CDC_CONTROL_LINE_OUT_DTR);\r
+ CDCInterfaceInfo->State.ControlLineStates.DeviceToHost = (CDC_CONTROL_LINE_IN_DCD | CDC_CONTROL_LINE_IN_DSR);\r
+ CDCInterfaceInfo->State.IsActive = true;\r
+\r
+ return CDC_ENUMERROR_NoError;\r
+}\r
+\r
+static uint8_t DCOMP_CDC_Host_NextCDCControlInterface(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Interface)\r
+ {\r
+ USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);\r
+\r
+ if ((Interface->Class == CDC_CSCP_CDCClass) &&\r
+ (Interface->SubClass == CDC_CSCP_ACMSubclass) &&\r
+ (Interface->Protocol == CDC_CSCP_ATCommandProtocol))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Interface)\r
+ {\r
+ USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);\r
+\r
+ if ((Interface->Class == CDC_CSCP_CDCDataClass) &&\r
+ (Interface->SubClass == CDC_CSCP_NoDataSubclass) &&\r
+ (Interface->Protocol == CDC_CSCP_NoDataProtocol))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t DCOMP_CDC_Host_NextCDCInterfaceEndpoint(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Endpoint)\r
+ {\r
+ USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);\r
+\r
+ uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);\r
+\r
+ if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&\r
+ !(Pipe_IsEndpointBound(Endpoint->EndpointAddress)))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+ else if (Header->Type == DTYPE_Interface)\r
+ {\r
+ return DESCRIPTOR_SEARCH_Fail;\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
+ return;\r
+\r
+ Pipe_SelectPipe(CDCInterfaceInfo->Config.NotificationPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_IsINReceived())\r
+ {\r
+ USB_Request_Header_t Notification;\r
+ Pipe_Read_Stream_LE(&Notification, sizeof(USB_Request_Header_t), NULL);\r
+\r
+ if ((Notification.bRequest == CDC_NOTIF_SerialState) &&\r
+ (Notification.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE)))\r
+ {\r
+ Pipe_Read_Stream_LE(&CDCInterfaceInfo->State.ControlLineStates.DeviceToHost,\r
+ sizeof(CDCInterfaceInfo->State.ControlLineStates.DeviceToHost),\r
+ NULL);\r
+\r
+ Pipe_ClearIN();\r
+\r
+ EVENT_CDC_Host_ControLineStateChanged(CDCInterfaceInfo);\r
+ }\r
+ else\r
+ {\r
+ Pipe_ClearIN();\r
+ }\r
+ }\r
+\r
+ Pipe_Freeze();\r
+\r
+ #if !defined(NO_CLASS_DRIVER_AUTOFLUSH)\r
+ CDC_Host_Flush(CDCInterfaceInfo);\r
+ #endif\r
+}\r
+\r
+uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = CDC_REQ_SetLineEncoding,\r
+ .wValue = 0,\r
+ .wIndex = CDCInterfaceInfo->State.ControlInterfaceNumber,\r
+ .wLength = sizeof(CDCInterfaceInfo->State.LineEncoding),\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(&CDCInterfaceInfo->State.LineEncoding);\r
+}\r
+\r
+uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = CDC_REQ_SetControlLineState,\r
+ .wValue = CDCInterfaceInfo->State.ControlLineStates.HostToDevice,\r
+ .wIndex = CDCInterfaceInfo->State.ControlInterfaceNumber,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(NULL);\r
+}\r
+\r
+uint8_t CDC_Host_SendBreak(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ const uint8_t Duration)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = CDC_REQ_SendBreak,\r
+ .wValue = Duration,\r
+ .wIndex = CDCInterfaceInfo->State.ControlInterfaceNumber,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(NULL);\r
+}\r
+\r
+uint8_t CDC_Host_SendData(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ const uint8_t* const Buffer,\r
+ const uint16_t Length)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipe.Address);\r
+\r
+ Pipe_Unfreeze();\r
+ ErrorCode = Pipe_Write_Stream_LE(Buffer, Length, NULL);\r
+ Pipe_Freeze();\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ const char* const String)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipe.Address);\r
+\r
+ Pipe_Unfreeze();\r
+ ErrorCode = Pipe_Write_Stream_LE(String, strlen(String), NULL);\r
+ Pipe_Freeze();\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ const uint8_t Data)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ Pipe_ClearOUT();\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)\r
+ return ErrorCode;\r
+ }\r
+\r
+ Pipe_Write_8(Data);\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_READYWAIT_NoError;\r
+}\r
+\r
+uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
+ return 0;\r
+\r
+ Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_IsINReceived())\r
+ {\r
+ if (!(Pipe_BytesInPipe()))\r
+ {\r
+ Pipe_ClearIN();\r
+ Pipe_Freeze();\r
+ return 0;\r
+ }\r
+ else\r
+ {\r
+ Pipe_Freeze();\r
+ return Pipe_BytesInPipe();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ Pipe_Freeze();\r
+\r
+ return 0;\r
+ }\r
+}\r
+\r
+int16_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
+ return -1;\r
+\r
+ int16_t ReceivedByte = -1;\r
+\r
+ Pipe_SelectPipe(CDCInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_IsINReceived())\r
+ {\r
+ if (Pipe_BytesInPipe())\r
+ ReceivedByte = Pipe_Read_8();\r
+\r
+ if (!(Pipe_BytesInPipe()))\r
+ Pipe_ClearIN();\r
+ }\r
+\r
+ Pipe_Freeze();\r
+\r
+ return ReceivedByte;\r
+}\r
+\r
+uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(CDCInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(CDCInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (!(Pipe_BytesInPipe()))\r
+ return PIPE_READYWAIT_NoError;\r
+\r
+ bool BankFull = !(Pipe_IsReadWriteAllowed());\r
+\r
+ Pipe_ClearOUT();\r
+\r
+ if (BankFull)\r
+ {\r
+ if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)\r
+ return ErrorCode;\r
+\r
+ Pipe_ClearOUT();\r
+ }\r
+\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_READYWAIT_NoError;\r
+}\r
+\r
+#if defined(FDEV_SETUP_STREAM)\r
+void CDC_Host_CreateStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ FILE* const Stream)\r
+{\r
+ *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Host_putchar, CDC_Host_getchar, _FDEV_SETUP_RW);\r
+ fdev_set_udata(Stream, CDCInterfaceInfo);\r
+}\r
+\r
+void CDC_Host_CreateBlockingStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ FILE* const Stream)\r
+{\r
+ *Stream = (FILE)FDEV_SETUP_STREAM(CDC_Host_putchar, CDC_Host_getchar_Blocking, _FDEV_SETUP_RW);\r
+ fdev_set_udata(Stream, CDCInterfaceInfo);\r
+}\r
+\r
+static int CDC_Host_putchar(char c,\r
+ FILE* Stream)\r
+{\r
+ return CDC_Host_SendByte((USB_ClassInfo_CDC_Host_t*)fdev_get_udata(Stream), c) ? _FDEV_ERR : 0;\r
+}\r
+\r
+static int CDC_Host_getchar(FILE* Stream)\r
+{\r
+ int16_t ReceivedByte = CDC_Host_ReceiveByte((USB_ClassInfo_CDC_Host_t*)fdev_get_udata(Stream));\r
+\r
+ if (ReceivedByte < 0)\r
+ return _FDEV_EOF;\r
+\r
+ return ReceivedByte;\r
+}\r
+\r
+static int CDC_Host_getchar_Blocking(FILE* Stream)\r
+{\r
+ int16_t ReceivedByte;\r
+\r
+ while ((ReceivedByte = CDC_Host_ReceiveByte((USB_ClassInfo_CDC_Host_t*)fdev_get_udata(Stream))) < 0)\r
+ {\r
+ if (USB_HostState == HOST_STATE_Unattached)\r
+ return _FDEV_EOF;\r
+\r
+ CDC_Host_USBTask((USB_ClassInfo_CDC_Host_t*)fdev_get_udata(Stream));\r
+ USB_USBTask();\r
+ }\r
+\r
+ return ReceivedByte;\r
+}\r
+#endif\r
+\r
+// cppcheck-suppress unusedFunction\r
+void CDC_Host_Event_Stub(void)\r
+{\r
+\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Host mode driver for the library USB CDC Class driver.\r
+ *\r
+ * Host mode driver for the library USB CDC Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassCDC\r
+ * \defgroup Group_USBClassCDCHost CDC Class Host Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/CDCClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Host Mode USB Class driver framework interface, for the CDC USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __CDC_CLASS_HOST_H__\r
+#define __CDC_CLASS_HOST_H__\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/CDCClassCommon.h"\r
+\r
+ #include <stdio.h>\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_CDC_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** \brief CDC Class Host Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made within the user application,\r
+ * and passed to each of the CDC class driver functions as the \c CDCInterfaceInfo parameter. This\r
+ * stores each CDC interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */\r
+ USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */\r
+ USB_Pipe_Table_t NotificationPipe; /**< Notification IN Pipe configuration table. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+ * after \ref CDC_Host_ConfigurePipes() is called and the Host state machine is in the\r
+ * Configured state.\r
+ */\r
+ uint8_t ControlInterfaceNumber; /**< Interface index of the CDC-ACM control interface within the attached device. */\r
+\r
+ struct\r
+ {\r
+ uint16_t HostToDevice; /**< Control line states from the host to device, as a set of \c CDC_CONTROL_LINE_OUT_*\r
+ * masks - to notify the device of changes to these values, call the\r
+ * \ref CDC_Host_SendControlLineStateChange() function.\r
+ */\r
+ uint16_t DeviceToHost; /**< Control line states from the device to host, as a set of \c CDC_CONTROL_LINE_IN_*\r
+ * masks. This value is updated each time \ref CDC_Host_USBTask() is called.\r
+ */\r
+ } ControlLineStates; /**< Current states of the virtual serial port's control lines between the device and host. */\r
+\r
+ CDC_LineEncoding_t LineEncoding; /**< Line encoding used in the virtual serial port, for the device's information.\r
+ * This is generally only used if the virtual serial port data is to be\r
+ * reconstructed on a physical UART. When set by the host application, the\r
+ * \ref CDC_Host_SetLineEncoding() function must be called to push the changes\r
+ * to the device.\r
+ */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * <b>may</b> be set to initial values, but may also be ignored to default to sane values when\r
+ * the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_CDC_Host_t;\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error codes returned by the \ref CDC_Host_ConfigurePipes() function. */\r
+ enum CDC_Host_EnumerationFailure_ErrorCodes_t\r
+ {\r
+ CDC_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */\r
+ CDC_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */\r
+ CDC_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible CDC interface was not found in the device's Configuration Descriptor. */\r
+ CDC_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ /** General management task for a given CDC host class interface, required for the correct operation of the interface. This should\r
+ * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing an CDC Class host configuration and state.\r
+ */\r
+ void CDC_Host_USBTask(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Host interface configuration routine, to configure a given CDC host interface instance using the Configuration\r
+ * Descriptor read from an attached USB device. This function automatically updates the given CDC Host instance's\r
+ * state values and configures the pipes required to communicate with the interface if it is found within the device.\r
+ * This should be called once after the stack has enumerated the attached device, while the host state machine is in\r
+ * the Addressed state.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing an CDC Class host configuration and state.\r
+ * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor.\r
+ * \param[in] ConfigDescriptorData Pointer to a buffer containing the attached device's Configuration Descriptor.\r
+ *\r
+ * \return A value from the \ref CDC_Host_EnumerationFailure_ErrorCodes_t enum.\r
+ */\r
+ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Sets the line encoding for the attached device's virtual serial port. This should be called when the \c LineEncoding\r
+ * values of the interface have been changed to push the new settings to the USB device.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+ */\r
+ uint8_t CDC_Host_SetLineEncoding(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sends a Serial Control Line State Change notification to the device. This should be called when the virtual serial\r
+ * control lines (DTR, RTS, etc.) have changed states. Line states persist until they are cleared via a second\r
+ * notification. This should be called each time the CDC class driver's \c ControlLineStates.HostToDevice value is updated\r
+ * to push the new states to the USB device.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+ */\r
+ uint8_t CDC_Host_SendControlLineStateChange(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sends a Send Break request to the device. This is generally used to separate data or to indicate a special condition\r
+ * to the receiving device.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state.\r
+ * \param[in] Duration Duration of the break, in milliseconds.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+ */\r
+ uint8_t CDC_Host_SendBreak(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ const uint8_t Duration) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sends a given data buffer to the attached USB device, if connected. If a device is not connected when the function is\r
+ * called, the data will be discarded. Bytes will be queued for transmission to the device until either the pipe bank\r
+ * becomes full, or the \ref CDC_Host_Flush() function is called to flush the pending data to the device. This allows for\r
+ * multiple bytes to be packed into a single pipe packet, increasing data throughput.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state.\r
+ * \param[in] Buffer Pointer to a buffer containing the data to send to the device.\r
+ * \param[in] Length Length of the data to send to the device.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t CDC_Host_SendData(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ const uint8_t* const Buffer,\r
+ const uint16_t Length);\r
+\r
+ /** Sends a given null-terminated string to the attached USB device, if connected. If a device is not connected when the\r
+ * function is called, the string is discarded. Bytes will be queued for transmission to the device until either the pipe\r
+ * bank becomes full, or the \ref CDC_Host_Flush() function is called to flush the pending data to the device. This allows\r
+ * for multiple bytes to be packed into a single pipe packet, increasing data throughput.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state.\r
+ * \param[in] String Pointer to the null terminated string to send to the device.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t CDC_Host_SendString(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Sends a given byte to the attached USB device, if connected. If a device is not connected when the function is called, the\r
+ * byte is discarded. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the\r
+ * \ref CDC_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be\r
+ * packed into a single pipe packet, increasing data throughput.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state.\r
+ * \param[in] Data Byte of data to send to the device.\r
+ *\r
+ * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t CDC_Host_SendByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Determines the number of bytes received by the CDC interface from the device, waiting to be read. This indicates the number\r
+ * of bytes in the IN pipe bank only, and thus the number of calls to \ref CDC_Host_ReceiveByte() which are guaranteed to succeed\r
+ * immediately. If multiple bytes are to be received, they should be buffered by the user application, as the pipe bank will not be\r
+ * released back to the USB controller until all bytes are read.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state.\r
+ *\r
+ * \return Total number of buffered bytes received from the device.\r
+ */\r
+ uint16_t CDC_Host_BytesReceived(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads a byte of data from the device. If no data is waiting to be read of if a USB device is not connected, the function\r
+ * returns a negative value. The \ref CDC_Host_BytesReceived() function may be queried in advance to determine how many bytes\r
+ * are currently buffered in the CDC interface's data receive pipe.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state.\r
+ *\r
+ * \return Next received byte from the device, or a negative value if no data received.\r
+ */\r
+ int16_t CDC_Host_ReceiveByte(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ #if defined(FDEV_SETUP_STREAM) || defined(__DOXYGEN__)\r
+ /** Creates a standard character stream for the given CDC Device instance so that it can be used with all the regular\r
+ * functions in the standard \c <stdio.h> library that accept a \c FILE stream as a destination (e.g. \c fprintf). The created\r
+ * stream is bidirectional and can be used for both input and output functions.\r
+ *\r
+ * Reading data from this stream is non-blocking, i.e. in most instances, complete strings cannot be read in by a single\r
+ * fetch, as the endpoint will not be ready at some point in the transmission, aborting the transfer. However, this may\r
+ * be used when the read data is processed byte-per-bye (via \c getc()) or when the user application will implement its own\r
+ * line buffering.\r
+ *\r
+ * \note The created stream can be given as \c stdout if desired to direct the standard output from all \c <stdio.h> functions\r
+ * to the given CDC interface.\r
+ * \n\n\r
+ *\r
+ * \note This function is not available on all microcontroller architectures.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.\r
+ */\r
+ void CDC_Host_CreateStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ FILE* const Stream);\r
+\r
+ /** Identical to \ref CDC_Host_CreateStream(), except that reads are blocking until the calling stream function terminates\r
+ * the transfer. While blocking, the USB and CDC service tasks are called repeatedly to maintain USB communications.\r
+ *\r
+ * \note This function is not available on all microcontroller architectures.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.\r
+ * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.\r
+ */\r
+ void CDC_Host_CreateBlockingStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,\r
+ FILE* const Stream);\r
+ #endif\r
+ \r
+ /** CDC class driver event for a control line state change on a CDC host interface. This event fires each time the device notifies\r
+ * the host of a control line state change (containing the virtual serial control line states, such as DCD) and may be hooked in the\r
+ * user program by declaring a handler function with the same name and parameters listed here. The new control line states\r
+ * are available in the \c ControlLineStates.DeviceToHost value inside the CDC host interface structure passed as a parameter, set as\r
+ * a mask of \c CDC_CONTROL_LINE_IN_* masks.\r
+ *\r
+ * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class host configuration and state.\r
+ */\r
+ void EVENT_CDC_Host_ControLineStateChanged(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_CDC_HOST_C)\r
+ #if defined(FDEV_SETUP_STREAM)\r
+ static int CDC_Host_putchar(char c,\r
+ FILE* Stream) ATTR_NON_NULL_PTR_ARG(2);\r
+ static int CDC_Host_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);\r
+ static int CDC_Host_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+\r
+ void CDC_Host_Event_Stub(void) ATTR_CONST;\r
+\r
+ void EVENT_CDC_Host_ControLineStateChanged(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)\r
+ ATTR_WEAK ATTR_NON_NULL_PTR_ARG(1) ATTR_ALIAS(CDC_Host_Event_Stub);\r
+\r
+ static uint8_t DCOMP_CDC_Host_NextCDCControlInterface(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_CDC_Host_NextCDCDataInterface(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_CDC_Host_NextCDCInterfaceEndpoint(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_HID_DRIVER\r
+#define __INCLUDE_FROM_HID_HOST_C\r
+#include "HIDClassHost.h"\r
+\r
+uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData)\r
+{\r
+ USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;\r
+ USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;\r
+ USB_Descriptor_Interface_t* HIDInterface = NULL;\r
+ USB_HID_Descriptor_HID_t* HIDDescriptor = NULL;\r
+\r
+ memset(&HIDInterfaceInfo->State, 0x00, sizeof(HIDInterfaceInfo->State));\r
+\r
+ if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)\r
+ return HID_ENUMERROR_InvalidConfigDescriptor;\r
+\r
+ while (!(DataINEndpoint) || !(DataOUTEndpoint))\r
+ {\r
+ if (!(HIDInterface) ||\r
+ USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_HID_Host_NextHIDInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ if (DataINEndpoint || DataOUTEndpoint)\r
+ break;\r
+\r
+ do\r
+ {\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_HID_Host_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return HID_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+\r
+ HIDInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);\r
+ } while (HIDInterfaceInfo->Config.HIDInterfaceProtocol &&\r
+ (HIDInterface->Protocol != HIDInterfaceInfo->Config.HIDInterfaceProtocol));\r
+\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_HID_Host_NextHIDDescriptor) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return HID_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+\r
+ HIDDescriptor = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_HID_Descriptor_HID_t);\r
+\r
+ DataINEndpoint = NULL;\r
+ DataOUTEndpoint = NULL;\r
+\r
+ continue;\r
+ }\r
+\r
+ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);\r
+\r
+ if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN)\r
+ DataINEndpoint = EndpointData;\r
+ else\r
+ DataOUTEndpoint = EndpointData;\r
+ }\r
+\r
+ HIDInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize);\r
+ HIDInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress;\r
+ HIDInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_INTERRUPT;\r
+ \r
+ HIDInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);\r
+ HIDInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress;\r
+ HIDInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_INTERRUPT;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&HIDInterfaceInfo->Config.DataINPipe, 1)))\r
+ return false;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&HIDInterfaceInfo->Config.DataOUTPipe, 1)))\r
+ return false;\r
+\r
+ HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber;\r
+ HIDInterfaceInfo->State.HIDReportSize = LE16_TO_CPU(HIDDescriptor->HIDReportLength);\r
+ HIDInterfaceInfo->State.SupportsBootProtocol = (HIDInterface->SubClass != HID_CSCP_NonBootProtocol);\r
+ HIDInterfaceInfo->State.LargestReportSize = 8;\r
+ HIDInterfaceInfo->State.IsActive = true;\r
+\r
+ return HID_ENUMERROR_NoError;\r
+}\r
+\r
+static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Interface)\r
+ {\r
+ USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);\r
+\r
+ if (Interface->Class == HID_CSCP_HIDClass)\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t DCOMP_HID_Host_NextHIDDescriptor(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == HID_DTYPE_HID)\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ else if (Header->Type == DTYPE_Interface)\r
+ return DESCRIPTOR_SEARCH_Fail;\r
+ else\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Endpoint)\r
+ {\r
+ USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);\r
+\r
+ if (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress)))\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ else if (Header->Type == DTYPE_Interface)\r
+ {\r
+ return DESCRIPTOR_SEARCH_Fail;\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
+uint8_t HID_Host_ReceiveReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,\r
+ const uint8_t ReportID,\r
+ void* Buffer)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = HID_REQ_SetReport,\r
+ .wValue = ((HID_REPORT_ITEM_In + 1) << 8) | ReportID,\r
+ .wIndex = HIDInterfaceInfo->State.InterfaceNumber,\r
+ .wLength = USB_GetHIDReportSize(HIDInterfaceInfo->Config.HIDParserData, ReportID, HID_REPORT_ITEM_In),\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(Buffer);\r
+}\r
+#endif\r
+\r
+uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,\r
+ void* Buffer)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ uint16_t ReportSize;\r
+ uint8_t* BufferPos = Buffer;\r
+\r
+#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
+ if (!(HIDInterfaceInfo->State.UsingBootProtocol))\r
+ {\r
+ uint8_t ReportID = 0;\r
+\r
+ if (HIDInterfaceInfo->Config.HIDParserData->UsingReportIDs)\r
+ {\r
+ ReportID = Pipe_Read_8();\r
+ *(BufferPos++) = ReportID;\r
+ }\r
+\r
+ ReportSize = USB_GetHIDReportSize(HIDInterfaceInfo->Config.HIDParserData, ReportID, HID_REPORT_ITEM_In);\r
+ }\r
+ else\r
+#endif\r
+ {\r
+ ReportSize = Pipe_BytesInPipe();\r
+ }\r
+\r
+ if ((ErrorCode = Pipe_Read_Stream_LE(BufferPos, ReportSize, NULL)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ Pipe_ClearIN();\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t HID_Host_SendReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,\r
+#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
+ const uint8_t ReportID,\r
+#endif\r
+ const uint8_t ReportType,\r
+ void* Buffer,\r
+ const uint16_t ReportSize)\r
+{\r
+#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive))\r
+ return false;\r
+\r
+ if (HIDInterfaceInfo->State.DeviceUsesOUTPipe && (ReportType == HID_REPORT_ITEM_Out))\r
+ {\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(HIDInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (ReportID)\r
+ Pipe_Write_Stream_LE(&ReportID, sizeof(ReportID), NULL);\r
+\r
+ if ((ErrorCode = Pipe_Write_Stream_LE(Buffer, ReportSize, NULL)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ Pipe_ClearOUT();\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+ }\r
+ else\r
+#endif\r
+ {\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = HID_REQ_SetReport,\r
+#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
+ .wValue = ((ReportType + 1) << 8) | ReportID,\r
+#else\r
+ .wValue = ((ReportType + 1) << 8),\r
+#endif\r
+ .wIndex = HIDInterfaceInfo->State.InterfaceNumber,\r
+ .wLength = ReportSize,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(Buffer);\r
+ }\r
+}\r
+\r
+bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(HIDInterfaceInfo->State.IsActive))\r
+ return false;\r
+\r
+ bool ReportReceived;\r
+\r
+ Pipe_SelectPipe(HIDInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ ReportReceived = Pipe_IsINReceived();\r
+\r
+ Pipe_Freeze();\r
+\r
+ return ReportReceived;\r
+}\r
+\r
+uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ if (!(HIDInterfaceInfo->State.SupportsBootProtocol))\r
+ return HID_ERROR_LOGICAL;\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = HID_REQ_SetProtocol,\r
+ .wValue = 0,\r
+ .wIndex = HIDInterfaceInfo->State.InterfaceNumber,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)\r
+ return ErrorCode;\r
+\r
+ HIDInterfaceInfo->State.LargestReportSize = 8;\r
+ HIDInterfaceInfo->State.UsingBootProtocol = true;\r
+\r
+ return HOST_SENDCONTROL_Successful;\r
+}\r
+\r
+uint8_t HID_Host_SetIdlePeriod(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,\r
+ const uint16_t MS)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = HID_REQ_SetIdle,\r
+ .wValue = ((MS << 6) & 0xFF00),\r
+ .wIndex = HIDInterfaceInfo->State.InterfaceNumber,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(NULL);\r
+}\r
+\r
+#if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
+uint8_t HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ uint8_t HIDReportData[HIDInterfaceInfo->State.HIDReportSize];\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE),\r
+ .bRequest = REQ_GetDescriptor,\r
+ .wValue = (HID_DTYPE_Report << 8),\r
+ .wIndex = HIDInterfaceInfo->State.InterfaceNumber,\r
+ .wLength = HIDInterfaceInfo->State.HIDReportSize,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ if ((ErrorCode = USB_Host_SendControlRequest(HIDReportData)) != HOST_SENDCONTROL_Successful)\r
+ return ErrorCode;\r
+\r
+ if (HIDInterfaceInfo->State.UsingBootProtocol)\r
+ {\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = HID_REQ_SetProtocol,\r
+ .wValue = 1,\r
+ .wIndex = HIDInterfaceInfo->State.InterfaceNumber,\r
+ .wLength = 0,\r
+ };\r
+\r
+ if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)\r
+ return ErrorCode;\r
+\r
+ HIDInterfaceInfo->State.UsingBootProtocol = false;\r
+ }\r
+\r
+ if (HIDInterfaceInfo->Config.HIDParserData == NULL)\r
+ return HID_ERROR_LOGICAL;\r
+\r
+ if ((ErrorCode = USB_ProcessHIDReport(HIDReportData, HIDInterfaceInfo->State.HIDReportSize,\r
+ HIDInterfaceInfo->Config.HIDParserData)) != HID_PARSE_Successful)\r
+ {\r
+ return HID_ERROR_LOGICAL | ErrorCode;\r
+ }\r
+\r
+ uint16_t LargestReportSizeBits = HIDInterfaceInfo->Config.HIDParserData->LargestReportSizeBits;\r
+ HIDInterfaceInfo->State.LargestReportSize = (LargestReportSizeBits >> 3) + ((LargestReportSizeBits & 0x07) != 0);\r
+\r
+ return 0;\r
+}\r
+#endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Host mode driver for the library USB HID Class driver.\r
+ *\r
+ * Host mode driver for the library USB HID Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassHID\r
+ * \defgroup Group_USBClassHIDHost HID Class Host Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/HIDClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Host Mode USB Class driver framework interface, for the HID USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __HID_CLASS_HOST_H__\r
+#define __HID_CLASS_HOST_H__\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/HIDClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_HID_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Error code for some HID Host functions, indicating a logical (and not hardware) error. */\r
+ #define HID_ERROR_LOGICAL 0x80\r
+\r
+ /* Type Defines: */\r
+ /** \brief HID Class Host Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made within the user application,\r
+ * and passed to each of the HID class driver functions as the \c HIDInterfaceInfo parameter. This\r
+ * stores each HID interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */\r
+ USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */\r
+\r
+ uint8_t HIDInterfaceProtocol; /**< HID interface protocol value to match against if a specific\r
+ * boot subclass protocol is required, a protocol value from the\r
+ * \ref HID_Descriptor_ClassSubclassProtocol_t enum.\r
+ */\r
+ #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
+ HID_ReportInfo_t* HIDParserData; /**< HID parser data to store the parsed HID report data, when boot protocol\r
+ * is not used.\r
+ *\r
+ * \note When the \c HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined,\r
+ * this method is unavailable.\r
+ */\r
+ #endif\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+ * after \ref HID_Host_ConfigurePipes() is called and the Host state machine is in the\r
+ * Configured state.\r
+ */\r
+ uint8_t InterfaceNumber; /**< Interface index of the HID interface within the attached device. */\r
+\r
+ bool SupportsBootProtocol; /**< Indicates if the current interface instance supports the HID Boot\r
+ * Protocol when enabled via \ref HID_Host_SetBootProtocol().\r
+ */\r
+ bool DeviceUsesOUTPipe; /**< Indicates if the current interface instance uses a separate OUT data pipe for\r
+ * OUT reports, or if OUT reports are sent via the control pipe instead.\r
+ */\r
+ bool UsingBootProtocol; /**< Indicates that the interface is currently initialized in Boot Protocol mode */\r
+ uint16_t HIDReportSize; /**< Size in bytes of the HID report descriptor in the device. */\r
+\r
+ uint8_t LargestReportSize; /**< Largest report the device will send, in bytes. */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * <b>may</b> be set to initial values, but may also be ignored to default to sane values when\r
+ * the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_HID_Host_t;\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error codes returned by the \ref HID_Host_ConfigurePipes() function. */\r
+ enum HID_Host_EnumerationFailure_ErrorCodes_t\r
+ {\r
+ HID_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */\r
+ HID_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */\r
+ HID_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible HID interface was not found in the device's Configuration Descriptor. */\r
+ HID_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ /** Host interface configuration routine, to configure a given HID host interface instance using the Configuration\r
+ * Descriptor read from an attached USB device. This function automatically updates the given HID Host instance's\r
+ * state values and configures the pipes required to communicate with the interface if it is found within the\r
+ * device. This should be called once after the stack has enumerated the attached device, while the host state\r
+ * machine is in the Addressed state.\r
+ *\r
+ * \attention Once the device pipes are configured, the HID device's reporting protocol <b>must</b> be set via a call\r
+ * to either the \ref HID_Host_SetBootProtocol() or \ref HID_Host_SetReportProtocol() function.\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state.\r
+ * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor.\r
+ * \param[in] ConfigDescriptorData Pointer to a buffer containing the attached device's Configuration Descriptor.\r
+ *\r
+ * \return A value from the \ref HID_Host_EnumerationFailure_ErrorCodes_t enum.\r
+ */\r
+ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+\r
+ /** Receives a HID IN report from the attached HID device, when a report has been received on the HID IN Data pipe.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \attention The destination buffer should be large enough to accommodate the largest report that the attached device\r
+ * can generate.\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state.\r
+ * \param[in] Buffer Buffer to store the received report into.\r
+ *\r
+ * \return An error code from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t HID_Host_ReceiveReport(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,\r
+ void* Buffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
+ /** Receives a HID IN report from the attached device, by the report ID.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \note When the \c HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, this method is unavailable.\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state.\r
+ * \param[in] ReportID Report ID of the received report if ControlRequest is false, set by the to the Report ID to fetch.\r
+ * \param[in] Buffer Buffer to store the received report into.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+ */\r
+ uint8_t HID_Host_ReceiveReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,\r
+ const uint8_t ReportID,\r
+ void* Buffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+ #endif\r
+\r
+ /** Sends an OUT or FEATURE report to the currently attached HID device, using the device's OUT pipe if available,\r
+ * or the device's Control pipe if not.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \note When the \c HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, the ReportID parameter is removed\r
+ * from the parameter list of this function.\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state.\r
+ * \param[in] ReportID Report ID of the report to send to the device, or 0 if the device does not use report IDs.\r
+ * \param[in] ReportType Type of report to issue to the device, either \ref HID_REPORT_ITEM_Out or \ref HID_REPORT_ITEM_Feature.\r
+ * \param[in] Buffer Buffer containing the report to send to the attached device.\r
+ * \param[in] ReportSize Report size in bytes to send to the attached device.\r
+ *\r
+ * \return An error code from the \ref USB_Host_SendControlErrorCodes_t enum if the DeviceUsesOUTPipe flag is set in\r
+ * the interface's state structure, a value from the \ref Pipe_Stream_RW_ErrorCodes_t enum otherwise.\r
+ */\r
+ uint8_t HID_Host_SendReportByID(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,\r
+ #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
+ const uint8_t ReportID,\r
+ #endif\r
+ const uint8_t ReportType,\r
+ void* Buffer,\r
+ const uint16_t ReportSize) ATTR_NON_NULL_PTR_ARG(1)\r
+ #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
+ ATTR_NON_NULL_PTR_ARG(4);\r
+ #else\r
+ ATTR_NON_NULL_PTR_ARG(3);\r
+ #endif\r
+\r
+ /** Determines if a HID IN report has been received from the attached device on the data IN pipe.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state.\r
+ *\r
+ * \return Boolean \c true if a report has been received, \c false otherwise.\r
+ */\r
+ bool HID_Host_IsReportReceived(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Switches the attached HID device's reporting protocol over to the Boot Report protocol mode, on supported devices.\r
+ *\r
+ * \note When the \c HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, this method must still be called\r
+ * to explicitly place the attached device into boot protocol mode before use.\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state.\r
+ *\r
+ * \return \ref HID_ERROR_LOGICAL if the device does not support Boot Protocol mode, a value from the\r
+ * \ref USB_Host_SendControlErrorCodes_t enum otherwise.\r
+ */\r
+ uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sets the idle period for the attached HID device to the specified interval. The HID idle period determines the rate\r
+ * at which the device should send a report, when no state changes have occurred; i.e. on HID keyboards, this sets the\r
+ * hardware key repeat interval.\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state.\r
+ * \param[in] MS Idle period as a multiple of four milliseconds, zero to disable hardware repeats\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+ */\r
+ uint8_t HID_Host_SetIdlePeriod(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo,\r
+ const uint16_t MS) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ #if !defined(HID_HOST_BOOT_PROTOCOL_ONLY)\r
+ /** Switches the attached HID device's reporting protocol over to the standard Report protocol mode. This also retrieves\r
+ * and parses the device's HID report descriptor, so that the size of each report can be determined in advance.\r
+ *\r
+ * \attention Whether this function is used or not, the \ref CALLBACK_HIDParser_FilterHIDReportItem() callback from the HID\r
+ * Report Parser this function references <b>must</b> be implemented in the user code.\r
+ *\r
+ * \note When the \c HID_HOST_BOOT_PROTOCOL_ONLY compile time token is defined, this method is unavailable.\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum if an error occurs while retrieving the HID\r
+ * Report descriptor or the setting of the Report protocol, \ref HID_ERROR_LOGICAL if the HID interface does\r
+ * not have a valid \ref HID_ReportInfo_t structure set in its configuration, a mask of \ref HID_ERROR_LOGICAL\r
+ * and a value from the \ref HID_Parse_ErrorCodes_t otherwise.\r
+ */\r
+ uint8_t HID_Host_SetReportProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ /** General management task for a given Human Interface Class host class interface, required for the correct operation of\r
+ * the interface. This should be called frequently in the main program loop, before the master USB management task\r
+ * \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] HIDInterfaceInfo Pointer to a structure containing a HID Class host configuration and state.\r
+ */\r
+ static inline void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline void HID_Host_USBTask(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo)\r
+ {\r
+ (void)HIDInterfaceInfo;\r
+ }\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_HID_HOST_C)\r
+ static uint8_t DCOMP_HID_Host_NextHIDInterface(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_HID_Host_NextHIDDescriptor(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_HID_Host_NextHIDInterfaceEndpoint(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_MIDI_DRIVER\r
+#define __INCLUDE_FROM_MIDI_HOST_C\r
+#include "MIDIClassHost.h"\r
+\r
+uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData)\r
+{\r
+ USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;\r
+ USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;\r
+ USB_Descriptor_Interface_t* MIDIInterface = NULL;\r
+\r
+ memset(&MIDIInterfaceInfo->State, 0x00, sizeof(MIDIInterfaceInfo->State));\r
+\r
+ if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)\r
+ return MIDI_ENUMERROR_InvalidConfigDescriptor;\r
+\r
+ while (!(DataINEndpoint) || !(DataOUTEndpoint))\r
+ {\r
+ if (!(MIDIInterface) ||\r
+ USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_MIDI_Host_NextMIDIStreamingInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return MIDI_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+\r
+ MIDIInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);\r
+\r
+ DataINEndpoint = NULL;\r
+ DataOUTEndpoint = NULL;\r
+\r
+ continue;\r
+ }\r
+\r
+ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);\r
+\r
+ if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN)\r
+ DataINEndpoint = EndpointData;\r
+ else\r
+ DataOUTEndpoint = EndpointData;\r
+ }\r
+\r
+ MIDIInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize);\r
+ MIDIInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress;\r
+ MIDIInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK;\r
+ \r
+ MIDIInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);\r
+ MIDIInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress;\r
+ MIDIInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&MIDIInterfaceInfo->Config.DataINPipe, 1)))\r
+ return false;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&MIDIInterfaceInfo->Config.DataOUTPipe, 1)))\r
+ return false; \r
+\r
+ MIDIInterfaceInfo->State.InterfaceNumber = MIDIInterface->InterfaceNumber;\r
+ MIDIInterfaceInfo->State.IsActive = true;\r
+\r
+ return MIDI_ENUMERROR_NoError;\r
+}\r
+\r
+static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingInterface(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Interface)\r
+ {\r
+ USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);\r
+\r
+ if ((Interface->Class == AUDIO_CSCP_AudioClass) &&\r
+ (Interface->SubClass == AUDIO_CSCP_MIDIStreamingSubclass) &&\r
+ (Interface->Protocol == AUDIO_CSCP_StreamingProtocol))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Endpoint)\r
+ {\r
+ USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);\r
+\r
+ uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);\r
+\r
+ if ((EndpointType == EP_TYPE_BULK) && !(Pipe_IsEndpointBound(Endpoint->EndpointAddress)))\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ else if (Header->Type == DTYPE_Interface)\r
+ {\r
+ return DESCRIPTOR_SEARCH_Fail;\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+void MIDI_Host_USBTask(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive))\r
+ return;\r
+\r
+ #if !defined(NO_CLASS_DRIVER_AUTOFLUSH)\r
+ MIDI_Host_Flush(MIDIInterfaceInfo);\r
+ #endif\r
+}\r
+\r
+uint8_t MIDI_Host_Flush(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+ \r
+ if (Pipe_BytesInPipe())\r
+ {\r
+ Pipe_ClearOUT();\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)\r
+ {\r
+ Pipe_Freeze();\r
+ return ErrorCode;\r
+ }\r
+ }\r
+\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_READYWAIT_NoError;\r
+}\r
+\r
+uint8_t MIDI_Host_SendEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo,\r
+ MIDI_EventPacket_t* const Event)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive))\r
+ return HOST_SENDCONTROL_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+ \r
+ if ((ErrorCode = Pipe_Write_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NULL)) != PIPE_RWSTREAM_NoError)\r
+ {\r
+ Pipe_Freeze();\r
+ return ErrorCode;\r
+ }\r
+\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ Pipe_ClearOUT();\r
+\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+bool MIDI_Host_ReceiveEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo,\r
+ MIDI_EventPacket_t* const Event)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(MIDIInterfaceInfo->State.IsActive))\r
+ return HOST_SENDCONTROL_DeviceDisconnected;\r
+ \r
+ bool DataReady = false;\r
+\r
+ Pipe_SelectPipe(MIDIInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_IsINReceived())\r
+ {\r
+ if (Pipe_BytesInPipe())\r
+ {\r
+ Pipe_Read_Stream_LE(Event, sizeof(MIDI_EventPacket_t), NULL);\r
+ DataReady = true;\r
+ }\r
+\r
+ if (!(Pipe_BytesInPipe()))\r
+ Pipe_ClearIN();\r
+ }\r
+ \r
+ Pipe_Freeze();\r
+ \r
+ return DataReady;\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Host mode driver for the library USB MIDI Class driver.\r
+ *\r
+ * Host mode driver for the library USB MIDI Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassMIDI\r
+ * \defgroup Group_USBClassMIDIHost MIDI Class Host Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/MIDIClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Host Mode USB Class driver framework interface, for the MIDI USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __MIDI_CLASS_HOST_H__\r
+#define __MIDI_CLASS_HOST_H__\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/MIDIClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_MIDI_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** \brief MIDI Class Host Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made within the user application,\r
+ * and passed to each of the MIDI class driver functions as the \c MIDIInterfaceInfo parameter. This\r
+ * stores each MIDI interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */\r
+ USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+ * after \ref MIDI_Host_ConfigurePipes() is called and the Host state machine is in the\r
+ * Configured state.\r
+ */\r
+ uint8_t InterfaceNumber; /**< Interface index of the MIDI interface within the attached device. */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * <b>may</b> be set to initial values, but may also be ignored to default to sane values when\r
+ * the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_MIDI_Host_t;\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error codes returned by the \ref MIDI_Host_ConfigurePipes() function. */\r
+ enum MIDI_Host_EnumerationFailure_ErrorCodes_t\r
+ {\r
+ MIDI_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */\r
+ MIDI_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */\r
+ MIDI_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible MIDI interface was not found in the device's Configuration Descriptor. */\r
+ MIDI_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ /** Host interface configuration routine, to configure a given MIDI host interface instance using the Configuration\r
+ * Descriptor read from an attached USB device. This function automatically updates the given MIDI Host instance's\r
+ * state values and configures the pipes required to communicate with the interface if it is found within the device.\r
+ * This should be called once after the stack has enumerated the attached device, while the host state machine is in\r
+ * the Addressed state.\r
+ *\r
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing an MIDI Class host configuration and state.\r
+ * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor.\r
+ * \param[in] ConfigDescriptorData Pointer to a buffer containing the attached device's Configuration Descriptor.\r
+ *\r
+ * \return A value from the \ref MIDI_Host_EnumerationFailure_ErrorCodes_t enum.\r
+ */\r
+ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** General management task for a given MIDI host class interface, required for the correct operation of the interface. This should\r
+ * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing an MIDI Class host configuration and state.\r
+ */\r
+ void MIDI_Host_USBTask(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sends a MIDI event packet to the device. If no device is connected, the event packet is discarded.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ * \param[in] Event Pointer to a populated USB_MIDI_EventPacket_t structure containing the MIDI event to send.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t MIDI_Host_SendEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo,\r
+ MIDI_EventPacket_t* const Event) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Flushes the MIDI send buffer, sending any queued MIDI events to the device. This should be called to override the\r
+ * \ref MIDI_Host_SendEventPacket() function's packing behavior, to flush queued events. Events are queued into the\r
+ * pipe bank until either the pipe bank is full, or \ref MIDI_Host_Flush() is called. This allows for multiple MIDI\r
+ * events to be packed into a single pipe packet, increasing data throughput.\r
+ *\r
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ *\r
+ * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t MIDI_Host_Flush(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Receives a MIDI event packet from the device.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MIDIInterfaceInfo Pointer to a structure containing a MIDI Class configuration and state.\r
+ * \param[out] Event Pointer to a USB_MIDI_EventPacket_t structure where the received MIDI event is to be placed.\r
+ *\r
+ * \return Boolean \c true if a MIDI event packet was received, \c false otherwise.\r
+ */\r
+ bool MIDI_Host_ReceiveEventPacket(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceInfo,\r
+ MIDI_EventPacket_t* const Event) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_MIDI_HOST_C)\r
+ static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingInterface(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_MIDI_Host_NextMIDIStreamingDataEndpoint(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_MS_DRIVER\r
+#define __INCLUDE_FROM_MASSSTORAGE_HOST_C\r
+#include "MassStorageClassHost.h"\r
+\r
+uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData)\r
+{\r
+ USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;\r
+ USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;\r
+ USB_Descriptor_Interface_t* MassStorageInterface = NULL;\r
+\r
+ memset(&MSInterfaceInfo->State, 0x00, sizeof(MSInterfaceInfo->State));\r
+\r
+ if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)\r
+ return MS_ENUMERROR_InvalidConfigDescriptor;\r
+\r
+ while (!(DataINEndpoint) || !(DataOUTEndpoint))\r
+ {\r
+ if (!(MassStorageInterface) ||\r
+ USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_MS_Host_NextMSInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_MS_Host_NextMSInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return MS_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+\r
+ MassStorageInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);\r
+\r
+ DataINEndpoint = NULL;\r
+ DataOUTEndpoint = NULL;\r
+\r
+ continue;\r
+ }\r
+\r
+ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);\r
+\r
+ if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN)\r
+ DataINEndpoint = EndpointData;\r
+ else\r
+ DataOUTEndpoint = EndpointData;\r
+ }\r
+\r
+ MSInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize);\r
+ MSInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress;\r
+ MSInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK;\r
+ \r
+ MSInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);\r
+ MSInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress;\r
+ MSInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&MSInterfaceInfo->Config.DataINPipe, 1)))\r
+ return false;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&MSInterfaceInfo->Config.DataOUTPipe, 1)))\r
+ return false;\r
+\r
+ MSInterfaceInfo->State.InterfaceNumber = MassStorageInterface->InterfaceNumber;\r
+ MSInterfaceInfo->State.IsActive = true;\r
+\r
+ return MS_ENUMERROR_NoError;\r
+}\r
+\r
+static uint8_t DCOMP_MS_Host_NextMSInterface(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Interface)\r
+ {\r
+ USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);\r
+\r
+ if ((Interface->Class == MS_CSCP_MassStorageClass) &&\r
+ (Interface->SubClass == MS_CSCP_SCSITransparentSubclass) &&\r
+ (Interface->Protocol == MS_CSCP_BulkOnlyTransportProtocol))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t DCOMP_MS_Host_NextMSInterfaceEndpoint(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Endpoint)\r
+ {\r
+ USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);\r
+\r
+ uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);\r
+\r
+ if ((EndpointType == EP_TYPE_BULK) && (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress))))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+ else if (Header->Type == DTYPE_Interface)\r
+ {\r
+ return DESCRIPTOR_SEARCH_Fail;\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ MS_CommandBlockWrapper_t* const SCSICommandBlock,\r
+ const void* const BufferPtr)\r
+{\r
+ uint8_t ErrorCode = PIPE_RWSTREAM_NoError;\r
+\r
+ if (++MSInterfaceInfo->State.TransactionTag == 0xFFFFFFFF)\r
+ MSInterfaceInfo->State.TransactionTag = 1;\r
+\r
+ SCSICommandBlock->Signature = CPU_TO_LE32(MS_CBW_SIGNATURE);\r
+ SCSICommandBlock->Tag = cpu_to_le32(MSInterfaceInfo->State.TransactionTag);\r
+\r
+ Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ErrorCode = Pipe_Write_Stream_LE(SCSICommandBlock, sizeof(MS_CommandBlockWrapper_t),\r
+ NULL)) != PIPE_RWSTREAM_NoError)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+\r
+ Pipe_ClearOUT();\r
+ Pipe_WaitUntilReady();\r
+\r
+ Pipe_Freeze();\r
+\r
+ if (BufferPtr != NULL)\r
+ {\r
+ ErrorCode = MS_Host_SendReceiveData(MSInterfaceInfo, SCSICommandBlock, (void*)BufferPtr);\r
+\r
+ if ((ErrorCode != PIPE_RWSTREAM_NoError) && (ErrorCode != PIPE_RWSTREAM_PipeStalled))\r
+ {\r
+ Pipe_Freeze();\r
+ return ErrorCode;\r
+ }\r
+ }\r
+\r
+ MS_CommandStatusWrapper_t SCSIStatusBlock;\r
+ return MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSIStatusBlock);\r
+}\r
+\r
+static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo)\r
+{\r
+ uint16_t TimeoutMSRem = MS_COMMAND_DATA_TIMEOUT_MS;\r
+ uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();\r
+\r
+ Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ while (!(Pipe_IsINReceived()))\r
+ {\r
+ uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();\r
+\r
+ if (CurrentFrameNumber != PreviousFrameNumber)\r
+ {\r
+ PreviousFrameNumber = CurrentFrameNumber;\r
+\r
+ if (!(TimeoutMSRem--))\r
+ return PIPE_RWSTREAM_Timeout;\r
+ }\r
+\r
+ Pipe_Freeze();\r
+ Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_IsStalled())\r
+ {\r
+ USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress());\r
+ return PIPE_RWSTREAM_PipeStalled;\r
+ }\r
+\r
+ Pipe_Freeze();\r
+ Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_IsStalled())\r
+ {\r
+ USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress());\r
+ return PIPE_RWSTREAM_PipeStalled;\r
+ }\r
+\r
+ if (USB_HostState == HOST_STATE_Unattached)\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+ };\r
+\r
+ Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Freeze();\r
+\r
+ Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ MS_CommandBlockWrapper_t* const SCSICommandBlock,\r
+ void* BufferPtr)\r
+{\r
+ uint8_t ErrorCode = PIPE_RWSTREAM_NoError;\r
+ uint16_t BytesRem = le32_to_cpu(SCSICommandBlock->DataTransferLength);\r
+\r
+ if (SCSICommandBlock->Flags & MS_COMMAND_DIR_DATA_IN)\r
+ {\r
+ if ((ErrorCode = MS_Host_WaitForDataReceived(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError)\r
+ {\r
+ Pipe_Freeze();\r
+ return ErrorCode;\r
+ }\r
+\r
+ Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem, NULL)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ Pipe_ClearIN();\r
+ }\r
+ else\r
+ {\r
+ Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ErrorCode = Pipe_Write_Stream_LE(BufferPtr, BytesRem, NULL)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ Pipe_ClearOUT();\r
+\r
+ while (!(Pipe_IsOUTReady()))\r
+ {\r
+ if (USB_HostState == HOST_STATE_Unattached)\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+ }\r
+ }\r
+\r
+ Pipe_Freeze();\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ MS_CommandStatusWrapper_t* const SCSICommandStatus)\r
+{\r
+ uint8_t ErrorCode = PIPE_RWSTREAM_NoError;\r
+\r
+ if ((ErrorCode = MS_Host_WaitForDataReceived(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ErrorCode = Pipe_Read_Stream_LE(SCSICommandStatus, sizeof(MS_CommandStatusWrapper_t),\r
+ NULL)) != PIPE_RWSTREAM_NoError)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+\r
+ Pipe_ClearIN();\r
+ Pipe_Freeze();\r
+\r
+ if (SCSICommandStatus->Status != MS_SCSI_COMMAND_Pass)\r
+ ErrorCode = MS_ERROR_LOGICAL_CMD_FAILED;\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = MS_REQ_MassStorageReset,\r
+ .wValue = 0,\r
+ .wIndex = MSInterfaceInfo->State.InterfaceNumber,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)\r
+ return ErrorCode;\r
+\r
+ Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipe.Address);\r
+\r
+ if ((ErrorCode = USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress())) != HOST_SENDCONTROL_Successful)\r
+ return ErrorCode;\r
+\r
+ Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipe.Address);\r
+\r
+ if ((ErrorCode = USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress())) != HOST_SENDCONTROL_Successful)\r
+ return ErrorCode;\r
+\r
+ return HOST_SENDCONTROL_Successful;\r
+}\r
+\r
+uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ uint8_t* const MaxLUNIndex)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = MS_REQ_GetMaxLUN,\r
+ .wValue = 0,\r
+ .wIndex = MSInterfaceInfo->State.InterfaceNumber,\r
+ .wLength = 1,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ if ((ErrorCode = USB_Host_SendControlRequest(MaxLUNIndex)) == HOST_SENDCONTROL_SetupStalled)\r
+ {\r
+ *MaxLUNIndex = 0;\r
+ ErrorCode = HOST_SENDCONTROL_Successful;\r
+ }\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex,\r
+ SCSI_Inquiry_Response_t* const InquiryData)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
+ return HOST_SENDCONTROL_DeviceDisconnected;\r
+\r
+ MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
+ {\r
+ .DataTransferLength = CPU_TO_LE32(sizeof(SCSI_Inquiry_Response_t)),\r
+ .Flags = MS_COMMAND_DIR_DATA_IN,\r
+ .LUN = LUNIndex,\r
+ .SCSICommandLength = 6,\r
+ .SCSICommandData =\r
+ {\r
+ SCSI_CMD_INQUIRY,\r
+ 0x00, // Reserved\r
+ 0x00, // Reserved\r
+ 0x00, // Reserved\r
+ sizeof(SCSI_Inquiry_Response_t), // Allocation Length\r
+ 0x00 // Unused (control)\r
+ }\r
+ };\r
+\r
+ return MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, InquiryData);\r
+}\r
+\r
+uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
+ return HOST_SENDCONTROL_DeviceDisconnected;\r
+\r
+ MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
+ {\r
+ .DataTransferLength = CPU_TO_LE32(0),\r
+ .Flags = MS_COMMAND_DIR_DATA_IN,\r
+ .LUN = LUNIndex,\r
+ .SCSICommandLength = 6,\r
+ .SCSICommandData =\r
+ {\r
+ SCSI_CMD_TEST_UNIT_READY,\r
+ 0x00, // Reserved\r
+ 0x00, // Reserved\r
+ 0x00, // Reserved\r
+ 0x00, // Reserved\r
+ 0x00 // Unused (control)\r
+ }\r
+ };\r
+\r
+ return MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL);\r
+}\r
+\r
+uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex,\r
+ SCSI_Capacity_t* const DeviceCapacity)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
+ return HOST_SENDCONTROL_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
+ {\r
+ .DataTransferLength = CPU_TO_LE32(sizeof(SCSI_Capacity_t)),\r
+ .Flags = MS_COMMAND_DIR_DATA_IN,\r
+ .LUN = LUNIndex,\r
+ .SCSICommandLength = 10,\r
+ .SCSICommandData =\r
+ {\r
+ SCSI_CMD_READ_CAPACITY_10,\r
+ 0x00, // Reserved\r
+ 0x00, // MSB of Logical block address\r
+ 0x00,\r
+ 0x00,\r
+ 0x00, // LSB of Logical block address\r
+ 0x00, // Reserved\r
+ 0x00, // Reserved\r
+ 0x00, // Partial Medium Indicator\r
+ 0x00 // Unused (control)\r
+ }\r
+ };\r
+\r
+ if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ DeviceCapacity->Blocks = BE32_TO_CPU(DeviceCapacity->Blocks);\r
+ DeviceCapacity->BlockSize = BE32_TO_CPU(DeviceCapacity->BlockSize);\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex,\r
+ SCSI_Request_Sense_Response_t* const SenseData)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
+ return HOST_SENDCONTROL_DeviceDisconnected;\r
+\r
+ MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
+ {\r
+ .DataTransferLength = CPU_TO_LE32(sizeof(SCSI_Request_Sense_Response_t)),\r
+ .Flags = MS_COMMAND_DIR_DATA_IN,\r
+ .LUN = LUNIndex,\r
+ .SCSICommandLength = 6,\r
+ .SCSICommandData =\r
+ {\r
+ SCSI_CMD_REQUEST_SENSE,\r
+ 0x00, // Reserved\r
+ 0x00, // Reserved\r
+ 0x00, // Reserved\r
+ sizeof(SCSI_Request_Sense_Response_t), // Allocation Length\r
+ 0x00 // Unused (control)\r
+ }\r
+ };\r
+\r
+ return MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, SenseData);\r
+}\r
+\r
+uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex,\r
+ const bool PreventRemoval)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
+ return HOST_SENDCONTROL_DeviceDisconnected;\r
+\r
+ MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
+ {\r
+ .DataTransferLength = CPU_TO_LE32(0),\r
+ .Flags = MS_COMMAND_DIR_DATA_OUT,\r
+ .LUN = LUNIndex,\r
+ .SCSICommandLength = 6,\r
+ .SCSICommandData =\r
+ {\r
+ SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL,\r
+ 0x00, // Reserved\r
+ 0x00, // Reserved\r
+ PreventRemoval, // Prevent flag\r
+ 0x00, // Reserved\r
+ 0x00 // Unused (control)\r
+ }\r
+ };\r
+\r
+ return MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, NULL);\r
+}\r
+\r
+uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex,\r
+ const uint32_t BlockAddress,\r
+ const uint8_t Blocks,\r
+ const uint16_t BlockSize,\r
+ void* BlockBuffer)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
+ return HOST_SENDCONTROL_DeviceDisconnected;\r
+\r
+ MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
+ {\r
+ .DataTransferLength = cpu_to_le32((uint32_t)Blocks * BlockSize),\r
+ .Flags = MS_COMMAND_DIR_DATA_IN,\r
+ .LUN = LUNIndex,\r
+ .SCSICommandLength = 10,\r
+ .SCSICommandData =\r
+ {\r
+ SCSI_CMD_READ_10,\r
+ 0x00, // Unused (control bits, all off)\r
+ (BlockAddress >> 24), // MSB of Block Address\r
+ (BlockAddress >> 16),\r
+ (BlockAddress >> 8),\r
+ (BlockAddress & 0xFF), // LSB of Block Address\r
+ 0x00, // Reserved\r
+ 0x00, // MSB of Total Blocks to Read\r
+ Blocks, // LSB of Total Blocks to Read\r
+ 0x00 // Unused (control)\r
+ }\r
+ };\r
+\r
+ return MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer);\r
+}\r
+\r
+uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex,\r
+ const uint32_t BlockAddress,\r
+ const uint8_t Blocks,\r
+ const uint16_t BlockSize,\r
+ const void* BlockBuffer)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.IsActive))\r
+ return HOST_SENDCONTROL_DeviceDisconnected;\r
+\r
+ MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)\r
+ {\r
+ .DataTransferLength = cpu_to_le32((uint32_t)Blocks * BlockSize),\r
+ .Flags = MS_COMMAND_DIR_DATA_OUT,\r
+ .LUN = LUNIndex,\r
+ .SCSICommandLength = 10,\r
+ .SCSICommandData =\r
+ {\r
+ SCSI_CMD_WRITE_10,\r
+ 0x00, // Unused (control bits, all off)\r
+ (BlockAddress >> 24), // MSB of Block Address\r
+ (BlockAddress >> 16),\r
+ (BlockAddress >> 8),\r
+ (BlockAddress & 0xFF), // LSB of Block Address\r
+ 0x00, // Reserved\r
+ 0x00, // MSB of Total Blocks to Write\r
+ Blocks, // LSB of Total Blocks to Write\r
+ 0x00 // Unused (control)\r
+ }\r
+ };\r
+\r
+ return MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, BlockBuffer);\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Host mode driver for the library USB Mass Storage Class driver.\r
+ *\r
+ * Host mode driver for the library USB Mass Storage Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassMS\r
+ * \defgroup Group_USBClassMassStorageHost Mass Storage Class Host Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/MassStorageClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Host Mode USB Class driver framework interface, for the Mass Storage USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __MS_CLASS_HOST_H__\r
+#define __MS_CLASS_HOST_H__\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/MassStorageClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_MS_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Error code for some Mass Storage Host functions, indicating a logical (and not hardware) error. */\r
+ #define MS_ERROR_LOGICAL_CMD_FAILED 0x80\r
+\r
+ /* Type Defines: */\r
+ /** \brief Mass Storage Class Host Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made within the user application,\r
+ * and passed to each of the Mass Storage class driver functions as the \c MSInterfaceInfo parameter. This\r
+ * stores each Mass Storage interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */\r
+ USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+ * after \ref MS_Host_ConfigurePipes() is called and the Host state machine is in the\r
+ * Configured state.\r
+ */\r
+ uint8_t InterfaceNumber; /**< Interface index of the Mass Storage interface within the attached device. */\r
+\r
+ uint32_t TransactionTag; /**< Current transaction tag for data synchronizing of packets. */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * <b>may</b> be set to initial values, but may also be ignored to default to sane values when\r
+ * the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_MS_Host_t;\r
+\r
+ /** \brief SCSI Device LUN Capacity Structure.\r
+ *\r
+ * SCSI capacity structure, to hold the total capacity of the device in both the number\r
+ * of blocks in the current LUN, and the size of each block. This structure is filled by\r
+ * the device when the \ref MS_Host_ReadDeviceCapacity() function is called.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint32_t Blocks; /**< Number of blocks in the addressed LUN of the device. */\r
+ uint32_t BlockSize; /**< Number of bytes in each block in the addressed LUN. */\r
+ } SCSI_Capacity_t;\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error codes returned by the \ref MS_Host_ConfigurePipes() function. */\r
+ enum MS_Host_EnumerationFailure_ErrorCodes_t\r
+ {\r
+ MS_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */\r
+ MS_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */\r
+ MS_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Mass Storage interface was not found in the device's Configuration Descriptor. */\r
+ MS_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ /** Host interface configuration routine, to configure a given Mass Storage host interface instance using the\r
+ * Configuration Descriptor read from an attached USB device. This function automatically updates the given Mass\r
+ * Storage Host instance's state values and configures the pipes required to communicate with the interface if it\r
+ * is found within the device. This should be called once after the stack has enumerated the attached device, while\r
+ * the host state machine is in the Addressed state.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing an MS Class host configuration and state.\r
+ * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor.\r
+ * \param[in] DeviceConfigDescriptor Pointer to a buffer containing the attached device's Configuration Descriptor.\r
+ *\r
+ * \return A value from the \ref MS_Host_EnumerationFailure_ErrorCodes_t enum.\r
+ */\r
+ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* DeviceConfigDescriptor) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Sends a MASS STORAGE RESET control request to the attached device, resetting the Mass Storage Interface\r
+ * and readying it for the next Mass Storage command. This should be called after a failed SCSI request to\r
+ * ensure the attached Mass Storage device is ready to receive the next command.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+ */\r
+ uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sends a GET MAX LUN control request to the attached device, retrieving the index of the highest LUN (Logical\r
+ * UNit, a logical drive) in the device. This value can then be used in the other functions of the Mass Storage\r
+ * Host mode Class driver to address a specific LUN within the device.\r
+ *\r
+ * \note Some devices do not support this request, and will STALL it when issued. To get around this,\r
+ * on unsupported devices the max LUN index will be reported as zero and no error will be returned\r
+ * if the device STALLs the request.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state.\r
+ * \param[out] MaxLUNIndex Pointer to a location where the highest LUN index value should be stored.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+ */\r
+ uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ uint8_t* const MaxLUNIndex) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Retrieves the Mass Storage device's inquiry data for the specified LUN, indicating the device characteristics and\r
+ * properties.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state.\r
+ * \param[in] LUNIndex LUN index within the device the command is being issued to.\r
+ * \param[out] InquiryData Location where the read inquiry data should be stored.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED.\r
+ */\r
+ uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex,\r
+ SCSI_Inquiry_Response_t* const InquiryData) ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Sends a TEST UNIT READY command to the device, to determine if it is ready to accept other SCSI commands.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state.\r
+ * \param[in] LUNIndex LUN index within the device the command is being issued to.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED if not ready.\r
+ */\r
+ uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Retrieves the total capacity of the attached USB Mass Storage device, in blocks, and block size.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state.\r
+ * \param[in] LUNIndex LUN index within the device the command is being issued to.\r
+ * \param[out] DeviceCapacity Pointer to the location where the capacity information should be stored.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED if not ready.\r
+ */\r
+ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex,\r
+ SCSI_Capacity_t* const DeviceCapacity) ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Retrieves the device sense data, indicating the current device state and error codes for the previously\r
+ * issued command.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state.\r
+ * \param[in] LUNIndex LUN index within the device the command is being issued to.\r
+ * \param[out] SenseData Pointer to the location where the sense information should be stored.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED if not ready.\r
+ */\r
+ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex,\r
+ SCSI_Request_Sense_Response_t* const SenseData) ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Issues a PREVENT MEDIUM REMOVAL command, to logically (or, depending on the type of device, physically) lock\r
+ * the device from removal so that blocks of data on the medium can be read or altered.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state.\r
+ * \param[in] LUNIndex LUN index within the device the command is being issued to.\r
+ * \param[in] PreventRemoval Boolean \c true if the device should be locked from removal, \c false otherwise.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED if not ready.\r
+ */\r
+ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex,\r
+ const bool PreventRemoval) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads blocks of data from the attached Mass Storage device's medium.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state.\r
+ * \param[in] LUNIndex LUN index within the device the command is being issued to.\r
+ * \param[in] BlockAddress Starting block address within the device to read from.\r
+ * \param[in] Blocks Total number of blocks to read.\r
+ * \param[in] BlockSize Size in bytes of each block within the device.\r
+ * \param[out] BlockBuffer Pointer to where the read data from the device should be stored.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED if not ready.\r
+ */\r
+ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex,\r
+ const uint32_t BlockAddress,\r
+ const uint8_t Blocks,\r
+ const uint16_t BlockSize,\r
+ void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6);\r
+\r
+ /** Writes blocks of data to the attached Mass Storage device's medium.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state.\r
+ * \param[in] LUNIndex LUN index within the device the command is being issued to.\r
+ * \param[in] BlockAddress Starting block address within the device to write to.\r
+ * \param[in] Blocks Total number of blocks to read.\r
+ * \param[in] BlockSize Size in bytes of each block within the device.\r
+ * \param[in] BlockBuffer Pointer to where the data to write should be sourced from.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or \ref MS_ERROR_LOGICAL_CMD_FAILED if not ready.\r
+ */\r
+ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ const uint8_t LUNIndex,\r
+ const uint32_t BlockAddress,\r
+ const uint8_t Blocks,\r
+ const uint16_t BlockSize,\r
+ const void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6);\r
+\r
+ /* Inline Functions: */\r
+ /** General management task for a given Mass Storage host class interface, required for the correct operation of\r
+ * the interface. This should be called frequently in the main program loop, before the master USB management task\r
+ * \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing an Mass Storage Class host configuration and state.\r
+ */\r
+ static inline void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo)\r
+ {\r
+ (void)MSInterfaceInfo;\r
+ }\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define MS_COMMAND_DATA_TIMEOUT_MS 10000\r
+\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_MASSSTORAGE_HOST_C)\r
+ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ MS_CommandBlockWrapper_t* const SCSICommandBlock,\r
+ const void* const BufferPtr) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+ static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ MS_CommandBlockWrapper_t* const SCSICommandBlock,\r
+ void* BufferPtr) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+ static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ MS_CommandStatusWrapper_t* const SCSICommandStatus)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ static uint8_t DCOMP_MS_Host_NextMSInterface(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_MS_Host_NextMSInterfaceEndpoint(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_PRINTER_DRIVER\r
+#define __INCLUDE_FROM_PRINTER_HOST_C\r
+#include "PrinterClassHost.h"\r
+\r
+uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData)\r
+{\r
+ USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;\r
+ USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;\r
+ USB_Descriptor_Interface_t* PrinterInterface = NULL;\r
+\r
+ memset(&PRNTInterfaceInfo->State, 0x00, sizeof(PRNTInterfaceInfo->State));\r
+\r
+ if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)\r
+ return PRNT_ENUMERROR_InvalidConfigDescriptor;\r
+\r
+ while (!(DataINEndpoint) || !(DataOUTEndpoint))\r
+ {\r
+ if (!(PrinterInterface) ||\r
+ USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_PRNT_Host_NextPRNTInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return PRNT_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+\r
+ PrinterInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);\r
+\r
+ DataINEndpoint = NULL;\r
+ DataOUTEndpoint = NULL;\r
+\r
+ continue;\r
+ }\r
+\r
+ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);\r
+\r
+ if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN)\r
+ DataINEndpoint = EndpointData;\r
+ else\r
+ DataOUTEndpoint = EndpointData;\r
+ }\r
+\r
+ PRNTInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize);\r
+ PRNTInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress;\r
+ PRNTInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK;\r
+ \r
+ PRNTInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);\r
+ PRNTInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress;\r
+ PRNTInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&PRNTInterfaceInfo->Config.DataINPipe, 1)))\r
+ return false;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&PRNTInterfaceInfo->Config.DataOUTPipe, 1)))\r
+ return false; \r
+\r
+ PRNTInterfaceInfo->State.InterfaceNumber = PrinterInterface->InterfaceNumber;\r
+ PRNTInterfaceInfo->State.AlternateSetting = PrinterInterface->AlternateSetting;\r
+ PRNTInterfaceInfo->State.IsActive = true;\r
+\r
+ return PRNT_ENUMERROR_NoError;\r
+}\r
+\r
+static uint8_t DCOMP_PRNT_Host_NextPRNTInterface(void* CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Interface)\r
+ {\r
+ USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);\r
+\r
+ if ((Interface->Class == PRNT_CSCP_PrinterClass) &&\r
+ (Interface->SubClass == PRNT_CSCP_PrinterSubclass) &&\r
+ (Interface->Protocol == PRNT_CSCP_BidirectionalProtocol))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint(void* CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Endpoint)\r
+ {\r
+ USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);\r
+\r
+ uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);\r
+\r
+ if (EndpointType == EP_TYPE_BULK)\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ else if (Header->Type == DTYPE_Interface)\r
+ {\r
+ return DESCRIPTOR_SEARCH_Fail;\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+void PRNT_Host_USBTask(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive))\r
+ return;\r
+\r
+ #if !defined(NO_CLASS_DRIVER_AUTOFLUSH)\r
+ PRNT_Host_Flush(PRNTInterfaceInfo);\r
+ #endif\r
+}\r
+\r
+uint8_t PRNT_Host_SetBidirectionalMode(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo)\r
+{\r
+ if (PRNTInterfaceInfo->State.AlternateSetting)\r
+ {\r
+ uint8_t ErrorCode;\r
+\r
+ if ((ErrorCode = USB_Host_SetInterfaceAltSetting(PRNTInterfaceInfo->State.InterfaceNumber,\r
+ PRNTInterfaceInfo->State.AlternateSetting)) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+ }\r
+\r
+ return HOST_SENDCONTROL_Successful;\r
+}\r
+\r
+uint8_t PRNT_Host_GetPortStatus(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,\r
+ uint8_t* const PortStatus)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = PRNT_REQ_GetPortStatus,\r
+ .wValue = 0,\r
+ .wIndex = PRNTInterfaceInfo->State.InterfaceNumber,\r
+ .wLength = sizeof(uint8_t),\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+ return USB_Host_SendControlRequest(PortStatus);\r
+}\r
+\r
+uint8_t PRNT_Host_SoftReset(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = PRNT_REQ_SoftReset,\r
+ .wValue = 0,\r
+ .wIndex = PRNTInterfaceInfo->State.InterfaceNumber,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+ return USB_Host_SendControlRequest(NULL);\r
+}\r
+\r
+uint8_t PRNT_Host_Flush(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (!(Pipe_BytesInPipe()))\r
+ return PIPE_READYWAIT_NoError;\r
+\r
+ bool BankFull = !(Pipe_IsReadWriteAllowed());\r
+\r
+ Pipe_ClearOUT();\r
+\r
+ if (BankFull)\r
+ {\r
+ if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)\r
+ return ErrorCode;\r
+\r
+ Pipe_ClearOUT();\r
+ }\r
+\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_READYWAIT_NoError;\r
+}\r
+\r
+uint8_t PRNT_Host_SendByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,\r
+ const uint8_t Data)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ Pipe_ClearOUT();\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()) != PIPE_READYWAIT_NoError)\r
+ return ErrorCode;\r
+ }\r
+\r
+ Pipe_Write_8(Data);\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_READYWAIT_NoError;\r
+}\r
+\r
+uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,\r
+ const char* const String)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ErrorCode = Pipe_Write_Stream_LE(String, strlen(String), NULL)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ Pipe_ClearOUT();\r
+\r
+ ErrorCode = Pipe_WaitUntilReady();\r
+\r
+ Pipe_Freeze();\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+uint8_t PRNT_Host_SendData(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t Length)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ErrorCode = Pipe_Write_Stream_LE(Buffer, Length, NULL)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ Pipe_ClearOUT();\r
+\r
+ ErrorCode = Pipe_WaitUntilReady();\r
+\r
+ Pipe_Freeze();\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+uint16_t PRNT_Host_BytesReceived(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive))\r
+ return 0;\r
+\r
+ Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_IsINReceived())\r
+ {\r
+ if (!(Pipe_BytesInPipe()))\r
+ {\r
+ Pipe_ClearIN();\r
+ Pipe_Freeze();\r
+ return 0;\r
+ }\r
+ else\r
+ {\r
+ Pipe_Freeze();\r
+ return Pipe_BytesInPipe();\r
+ }\r
+ }\r
+ else\r
+ {\r
+ Pipe_Freeze();\r
+\r
+ return 0;\r
+ }\r
+}\r
+\r
+int16_t PRNT_Host_ReceiveByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(PRNTInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ int16_t ReceivedByte = -1;\r
+\r
+ Pipe_SelectPipe(PRNTInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_IsINReceived())\r
+ {\r
+ if (Pipe_BytesInPipe())\r
+ ReceivedByte = Pipe_Read_8();\r
+\r
+ if (!(Pipe_BytesInPipe()))\r
+ Pipe_ClearIN();\r
+ }\r
+\r
+ Pipe_Freeze();\r
+\r
+ return ReceivedByte;\r
+}\r
+\r
+uint8_t PRNT_Host_GetDeviceID(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,\r
+ char* const DeviceIDString,\r
+ const uint16_t BufferSize)\r
+{\r
+ uint8_t ErrorCode;\r
+ uint16_t DeviceIDStringLength = 0;\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = PRNT_REQ_GetDeviceID,\r
+ .wValue = 0,\r
+ .wIndex = PRNTInterfaceInfo->State.InterfaceNumber,\r
+ .wLength = sizeof(DeviceIDStringLength),\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ if ((ErrorCode = USB_Host_SendControlRequest(&DeviceIDStringLength)) != HOST_SENDCONTROL_Successful)\r
+ return ErrorCode;\r
+\r
+ if (!(DeviceIDStringLength))\r
+ {\r
+ DeviceIDString[0] = 0x00;\r
+ return HOST_SENDCONTROL_Successful;\r
+ }\r
+\r
+ DeviceIDStringLength = be16_to_cpu(DeviceIDStringLength);\r
+\r
+ if (DeviceIDStringLength > BufferSize)\r
+ DeviceIDStringLength = BufferSize;\r
+\r
+ USB_ControlRequest.wLength = DeviceIDStringLength;\r
+\r
+ if ((ErrorCode = USB_Host_SendControlRequest(DeviceIDString)) != HOST_SENDCONTROL_Successful)\r
+ return ErrorCode;\r
+\r
+ memmove(&DeviceIDString[0], &DeviceIDString[2], DeviceIDStringLength - 2);\r
+\r
+ DeviceIDString[DeviceIDStringLength - 2] = 0x00;\r
+\r
+ return HOST_SENDCONTROL_Successful;\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Host mode driver for the library USB Printer Class driver.\r
+ *\r
+ * Host mode driver for the library USB Printer Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassPrinter\r
+ * \defgroup Group_USBClassPrinterHost Printer Class Host Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/PrinterClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Host Mode USB Class driver framework interface, for the Printer USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __PRINTER_CLASS_HOST_H__\r
+#define __PRINTER_CLASS_HOST_H__\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/PrinterClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_PRINTER_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** \brief Printer Class Host Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made within the user application,\r
+ * and passed to each of the Printer class driver functions as the \c PRNTInterfaceInfo parameter. This\r
+ * stores each Printer interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */\r
+ USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+ * after \ref PRNT_Host_ConfigurePipes() is called and the Host state machine is in the\r
+ * Configured state.\r
+ */\r
+ uint8_t InterfaceNumber; /**< Interface index of the Printer interface within the attached device. */\r
+ uint8_t AlternateSetting; /**< Alternate setting within the Printer Interface in the attached device. */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * <b>may</b> be set to initial values, but may also be ignored to default to sane values when\r
+ * the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_PRNT_Host_t;\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error codes returned by the \ref PRNT_Host_ConfigurePipes() function. */\r
+ enum PRNT_Host_EnumerationFailure_ErrorCodes_t\r
+ {\r
+ PRNT_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */\r
+ PRNT_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */\r
+ PRNT_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Printer interface was not found in the device's Configuration Descriptor. */\r
+ PRNT_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ /** Host interface configuration routine, to configure a given Printer host interface instance using the\r
+ * Configuration Descriptor read from an attached USB device. This function automatically updates the given Printer\r
+ * instance's state values and configures the pipes required to communicate with the interface if it is found within\r
+ * the device. This should be called once after the stack has enumerated the attached device, while the host state\r
+ * machine is in the Addressed state.\r
+ *\r
+ * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state.\r
+ * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor.\r
+ * \param[in] ConfigDescriptorData Pointer to a buffer containing the attached device's Configuration Descriptor.\r
+ *\r
+ * \return A value from the \ref PRNT_Host_EnumerationFailure_ErrorCodes_t enum.\r
+ */\r
+ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** General management task for a given Printer host class interface, required for the correct operation of\r
+ * the interface. This should be called frequently in the main program loop, before the master USB management task\r
+ * \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state.\r
+ */\r
+ void PRNT_Host_USBTask(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Configures the printer to enable Bidirectional mode, if it is not already in this mode. This should be called\r
+ * once the connected device's configuration has been set, to ensure the printer is ready to accept commands.\r
+ *\r
+ * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+ */\r
+ uint8_t PRNT_Host_SetBidirectionalMode(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Retrieves the status of the virtual Printer port's inbound status lines. The result can then be masked against the\r
+ * \c PRNT_PORTSTATUS_* macros to determine the printer port's status.\r
+ *\r
+ * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state.\r
+ * \param[out] PortStatus Location where the retrieved port status should be stored.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+ */\r
+ uint8_t PRNT_Host_GetPortStatus(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,\r
+ uint8_t* const PortStatus)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Soft-resets the attached printer, readying it for new commands.\r
+ *\r
+ * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum.\r
+ */\r
+ uint8_t PRNT_Host_SoftReset(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Flushes any data waiting to be sent, ensuring that the send buffer is cleared.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t PRNT_Host_Flush(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sends the given null terminated string to the attached printer's input endpoint.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state.\r
+ * \param[in] String Pointer to a null terminated string to send.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,\r
+ const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Sends the given raw data stream to the attached printer's input endpoint. This should contain commands that the\r
+ * printer is able to understand - for example, PCL data. Not all printers accept all printer languages; see\r
+ * \ref PRNT_Host_GetDeviceID() for details on determining acceptable languages for an attached printer.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state.\r
+ * \param[in] Buffer Pointer to a buffer containing the raw command stream to send to the printer.\r
+ * \param[in] Length Size in bytes of the command stream to be sent.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t PRNT_Host_SendData(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Sends a given byte to the attached USB device, if connected. If a device is not connected when the function is called, the\r
+ * byte is discarded. Bytes will be queued for transmission to the device until either the pipe bank becomes full, or the\r
+ * \ref PRNT_Host_Flush() function is called to flush the pending data to the host. This allows for multiple bytes to be\r
+ * packed into a single pipe packet, increasing data throughput.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state.\r
+ * \param[in] Data Byte of data to send to the device.\r
+ *\r
+ * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t PRNT_Host_SendByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,\r
+ const uint8_t Data) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Determines the number of bytes received by the printer interface from the device, waiting to be read. This indicates the number\r
+ * of bytes in the IN pipe bank only, and thus the number of calls to \ref PRNT_Host_ReceiveByte() which are guaranteed to succeed\r
+ * immediately. If multiple bytes are to be received, they should be buffered by the user application, as the pipe bank will not be\r
+ * released back to the USB controller until all bytes are read.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state.\r
+ *\r
+ * \return Total number of buffered bytes received from the device.\r
+ */\r
+ uint16_t PRNT_Host_BytesReceived(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo);\r
+\r
+ /** Reads a byte of data from the device. If no data is waiting to be read of if a USB device is not connected, the function\r
+ * returns a negative value. The \ref PRNT_Host_BytesReceived() function may be queried in advance to determine how many bytes\r
+ * are currently buffered in the Printer interface's data receive pipe.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state.\r
+ *\r
+ * \return Next received byte from the device, or a negative value if no data received.\r
+ */\r
+ int16_t PRNT_Host_ReceiveByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo);\r
+\r
+ /** Retrieves the attached printer device's ID string, formatted according to IEEE 1284. This string is sent as a\r
+ * Unicode string from the device and is automatically converted to an ASCII encoded C string by this function, thus\r
+ * the maximum reportable string length is two less than the size given (to accommodate the Unicode string length\r
+ * bytes which are removed).\r
+ *\r
+ * This string, when supported, contains the model, manufacturer and acceptable printer languages for the attached device.\r
+ *\r
+ * \param[in,out] PRNTInterfaceInfo Pointer to a structure containing a Printer Class host configuration and state.\r
+ * \param[out] DeviceIDString Pointer to a buffer where the Device ID string should be stored, in ASCII format.\r
+ * \param[in] BufferSize Size in bytes of the buffer allocated for the Device ID string.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t PRNT_Host_GetDeviceID(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,\r
+ char* const DeviceIDString,\r
+ const uint16_t BufferSize) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_PRINTER_HOST_C)\r
+ static uint8_t DCOMP_PRNT_Host_NextPRNTInterface(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_PRNT_Host_NextPRNTInterfaceEndpoint(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_RNDIS_DRIVER\r
+#define __INCLUDE_FROM_RNDIS_HOST_C\r
+#include "RNDISClassHost.h"\r
+\r
+uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData)\r
+{\r
+ USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;\r
+ USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;\r
+ USB_Descriptor_Endpoint_t* NotificationEndpoint = NULL;\r
+ USB_Descriptor_Interface_t* RNDISControlInterface = NULL;\r
+\r
+ memset(&RNDISInterfaceInfo->State, 0x00, sizeof(RNDISInterfaceInfo->State));\r
+\r
+ if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)\r
+ return RNDIS_ENUMERROR_InvalidConfigDescriptor;\r
+\r
+ RNDISControlInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);\r
+\r
+ while (!(DataINEndpoint) || !(DataOUTEndpoint) || !(NotificationEndpoint))\r
+ {\r
+ if (!(RNDISControlInterface) ||\r
+ USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_RNDIS_Host_NextRNDISInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ if (NotificationEndpoint)\r
+ {\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_RNDIS_Host_NextRNDISDataInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return RNDIS_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+\r
+ DataINEndpoint = NULL;\r
+ DataOUTEndpoint = NULL;\r
+ }\r
+ else\r
+ {\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_RNDIS_Host_NextRNDISControlInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return RNDIS_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+\r
+ RNDISControlInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);\r
+\r
+ NotificationEndpoint = NULL;\r
+ }\r
+\r
+ continue;\r
+ }\r
+\r
+ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);\r
+\r
+ if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN)\r
+ {\r
+ if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT)\r
+ NotificationEndpoint = EndpointData;\r
+ else\r
+ DataINEndpoint = EndpointData;\r
+ }\r
+ else\r
+ {\r
+ DataOUTEndpoint = EndpointData;\r
+ }\r
+ }\r
+\r
+ RNDISInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize);\r
+ RNDISInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress;\r
+ RNDISInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK;\r
+ \r
+ RNDISInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);\r
+ RNDISInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress;\r
+ RNDISInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK;\r
+ \r
+ RNDISInterfaceInfo->Config.NotificationPipe.Size = le16_to_cpu(NotificationEndpoint->EndpointSize);\r
+ RNDISInterfaceInfo->Config.NotificationPipe.EndpointAddress = NotificationEndpoint->EndpointAddress;\r
+ RNDISInterfaceInfo->Config.NotificationPipe.Type = EP_TYPE_INTERRUPT;\r
+\r
+ if (!(Pipe_ConfigurePipeTable(&RNDISInterfaceInfo->Config.DataINPipe, 1)))\r
+ return false;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&RNDISInterfaceInfo->Config.DataOUTPipe, 1)))\r
+ return false;\r
+\r
+ if (!(Pipe_ConfigurePipeTable(&RNDISInterfaceInfo->Config.NotificationPipe, 1)))\r
+ return false;\r
+\r
+ RNDISInterfaceInfo->State.ControlInterfaceNumber = RNDISControlInterface->InterfaceNumber;\r
+ RNDISInterfaceInfo->State.IsActive = true;\r
+\r
+ return RNDIS_ENUMERROR_NoError;\r
+}\r
+\r
+static uint8_t DCOMP_RNDIS_Host_NextRNDISControlInterface(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Interface)\r
+ {\r
+ USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);\r
+\r
+ if ((Interface->Class == CDC_CSCP_CDCClass) &&\r
+ (Interface->SubClass == CDC_CSCP_ACMSubclass) &&\r
+ (Interface->Protocol == CDC_CSCP_VendorSpecificProtocol))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t DCOMP_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Interface)\r
+ {\r
+ USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor,\r
+ USB_Descriptor_Interface_t);\r
+\r
+ if ((Interface->Class == CDC_CSCP_CDCDataClass) &&\r
+ (Interface->SubClass == CDC_CSCP_NoDataSubclass) &&\r
+ (Interface->Protocol == CDC_CSCP_NoDataProtocol))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t DCOMP_RNDIS_Host_NextRNDISInterfaceEndpoint(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Endpoint)\r
+ {\r
+ USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);\r
+\r
+ uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);\r
+\r
+ if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&\r
+ !(Pipe_IsEndpointBound(Endpoint->EndpointAddress)))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+ else if (Header->Type == DTYPE_Interface)\r
+ {\r
+ return DESCRIPTOR_SEARCH_Fail;\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+static uint8_t RNDIS_SendEncapsulatedCommand(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t Length)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = RNDIS_REQ_SendEncapsulatedCommand,\r
+ .wValue = 0,\r
+ .wIndex = RNDISInterfaceInfo->State.ControlInterfaceNumber,\r
+ .wLength = Length,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(Buffer);\r
+}\r
+\r
+static uint8_t RNDIS_GetEncapsulatedResponse(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t Length)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),\r
+ .bRequest = RNDIS_REQ_GetEncapsulatedResponse,\r
+ .wValue = 0,\r
+ .wIndex = RNDISInterfaceInfo->State.ControlInterfaceNumber,\r
+ .wLength = Length,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(Buffer);\r
+}\r
+\r
+uint8_t RNDIS_Host_SendKeepAlive(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ RNDIS_KeepAlive_Message_t KeepAliveMessage;\r
+ RNDIS_KeepAlive_Complete_t KeepAliveMessageResponse;\r
+\r
+ KeepAliveMessage.MessageType = CPU_TO_LE32(REMOTE_NDIS_KEEPALIVE_MSG);\r
+ KeepAliveMessage.MessageLength = CPU_TO_LE32(sizeof(RNDIS_KeepAlive_Message_t));\r
+ KeepAliveMessage.RequestId = cpu_to_le32(RNDISInterfaceInfo->State.RequestID++);\r
+\r
+ if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &KeepAliveMessage,\r
+ sizeof(RNDIS_KeepAlive_Message_t))) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+\r
+ if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &KeepAliveMessageResponse,\r
+ sizeof(RNDIS_KeepAlive_Complete_t))) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+\r
+ return HOST_SENDCONTROL_Successful;\r
+}\r
+\r
+uint8_t RNDIS_Host_InitializeDevice(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ RNDIS_Initialize_Message_t InitMessage;\r
+ RNDIS_Initialize_Complete_t InitMessageResponse;\r
+\r
+ InitMessage.MessageType = CPU_TO_LE32(REMOTE_NDIS_INITIALIZE_MSG);\r
+ InitMessage.MessageLength = CPU_TO_LE32(sizeof(RNDIS_Initialize_Message_t));\r
+ InitMessage.RequestId = cpu_to_le32(RNDISInterfaceInfo->State.RequestID++);\r
+\r
+ InitMessage.MajorVersion = CPU_TO_LE32(REMOTE_NDIS_VERSION_MAJOR);\r
+ InitMessage.MinorVersion = CPU_TO_LE32(REMOTE_NDIS_VERSION_MINOR);\r
+ InitMessage.MaxTransferSize = cpu_to_le32(RNDISInterfaceInfo->Config.HostMaxPacketSize);\r
+\r
+ if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &InitMessage,\r
+ sizeof(RNDIS_Initialize_Message_t))) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+\r
+ if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &InitMessageResponse,\r
+ sizeof(RNDIS_Initialize_Complete_t))) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+\r
+ if (InitMessageResponse.Status != CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS))\r
+ return RNDIS_ERROR_LOGICAL_CMD_FAILED;\r
+\r
+ RNDISInterfaceInfo->State.DeviceMaxPacketSize = le32_to_cpu(InitMessageResponse.MaxTransferSize);\r
+\r
+ return HOST_SENDCONTROL_Successful;\r
+}\r
+\r
+uint8_t RNDIS_Host_SetRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ const uint32_t Oid,\r
+ void* Buffer,\r
+ const uint16_t Length)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ struct\r
+ {\r
+ RNDIS_Set_Message_t SetMessage;\r
+ uint8_t ContiguousBuffer[Length];\r
+ } SetMessageData;\r
+\r
+ RNDIS_Set_Complete_t SetMessageResponse;\r
+\r
+ SetMessageData.SetMessage.MessageType = CPU_TO_LE32(REMOTE_NDIS_SET_MSG);\r
+ SetMessageData.SetMessage.MessageLength = cpu_to_le32(sizeof(RNDIS_Set_Message_t) + Length);\r
+ SetMessageData.SetMessage.RequestId = cpu_to_le32(RNDISInterfaceInfo->State.RequestID++);\r
+\r
+ SetMessageData.SetMessage.Oid = cpu_to_le32(Oid);\r
+ SetMessageData.SetMessage.InformationBufferLength = cpu_to_le32(Length);\r
+ SetMessageData.SetMessage.InformationBufferOffset = CPU_TO_LE32(sizeof(RNDIS_Set_Message_t) - sizeof(RNDIS_Message_Header_t));\r
+ SetMessageData.SetMessage.DeviceVcHandle = CPU_TO_LE32(0);\r
+\r
+ memcpy(&SetMessageData.ContiguousBuffer, Buffer, Length);\r
+\r
+ if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &SetMessageData,\r
+ (sizeof(RNDIS_Set_Message_t) + Length))) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+\r
+ if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &SetMessageResponse,\r
+ sizeof(RNDIS_Set_Complete_t))) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+\r
+ if (SetMessageResponse.Status != CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS))\r
+ return RNDIS_ERROR_LOGICAL_CMD_FAILED;\r
+\r
+ return HOST_SENDCONTROL_Successful;\r
+}\r
+\r
+uint8_t RNDIS_Host_QueryRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ const uint32_t Oid,\r
+ void* Buffer,\r
+ const uint16_t MaxLength)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ RNDIS_Query_Message_t QueryMessage;\r
+\r
+ struct\r
+ {\r
+ RNDIS_Query_Complete_t QueryMessageResponse;\r
+ uint8_t ContiguousBuffer[MaxLength];\r
+ } QueryMessageResponseData;\r
+\r
+ QueryMessage.MessageType = CPU_TO_LE32(REMOTE_NDIS_QUERY_MSG);\r
+ QueryMessage.MessageLength = CPU_TO_LE32(sizeof(RNDIS_Query_Message_t));\r
+ QueryMessage.RequestId = cpu_to_le32(RNDISInterfaceInfo->State.RequestID++);\r
+\r
+ QueryMessage.Oid = cpu_to_le32(Oid);\r
+ QueryMessage.InformationBufferLength = CPU_TO_LE32(0);\r
+ QueryMessage.InformationBufferOffset = CPU_TO_LE32(0);\r
+ QueryMessage.DeviceVcHandle = CPU_TO_LE32(0);\r
+\r
+ if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &QueryMessage,\r
+ sizeof(RNDIS_Query_Message_t))) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+\r
+ if ((ErrorCode = RNDIS_GetEncapsulatedResponse(RNDISInterfaceInfo, &QueryMessageResponseData,\r
+ sizeof(QueryMessageResponseData))) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+\r
+ if (QueryMessageResponseData.QueryMessageResponse.Status != CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS))\r
+ return RNDIS_ERROR_LOGICAL_CMD_FAILED;\r
+\r
+ memcpy(Buffer, &QueryMessageResponseData.ContiguousBuffer, MaxLength);\r
+\r
+ return HOST_SENDCONTROL_Successful;\r
+}\r
+\r
+bool RNDIS_Host_IsPacketReceived(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo)\r
+{\r
+ bool PacketWaiting;\r
+\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(RNDISInterfaceInfo->State.IsActive))\r
+ return false;\r
+\r
+ Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataINPipe.Address);\r
+\r
+ Pipe_Unfreeze();\r
+ PacketWaiting = Pipe_IsINReceived();\r
+ Pipe_Freeze();\r
+\r
+ return PacketWaiting;\r
+}\r
+\r
+uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ void* Buffer,\r
+ uint16_t* const PacketLength)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(RNDISInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ if (Pipe_IsINReceived())\r
+ Pipe_ClearIN();\r
+\r
+ *PacketLength = 0;\r
+ Pipe_Freeze();\r
+ return PIPE_RWSTREAM_NoError;\r
+ }\r
+\r
+ RNDIS_Packet_Message_t DeviceMessage;\r
+\r
+ if ((ErrorCode = Pipe_Read_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t),\r
+ NULL)) != PIPE_RWSTREAM_NoError)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+\r
+ *PacketLength = (uint16_t)le32_to_cpu(DeviceMessage.DataLength);\r
+\r
+ Pipe_Discard_Stream(le32_to_cpu(DeviceMessage.DataOffset) -\r
+ (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)),\r
+ NULL);\r
+\r
+ Pipe_Read_Stream_LE(Buffer, *PacketLength, NULL);\r
+\r
+ if (!(Pipe_BytesInPipe()))\r
+ Pipe_ClearIN();\r
+\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t PacketLength)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(RNDISInterfaceInfo->State.IsActive))\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ RNDIS_Packet_Message_t DeviceMessage;\r
+\r
+ memset(&DeviceMessage, 0, sizeof(RNDIS_Packet_Message_t));\r
+ DeviceMessage.MessageType = CPU_TO_LE32(REMOTE_NDIS_PACKET_MSG);\r
+ DeviceMessage.MessageLength = CPU_TO_LE32(sizeof(RNDIS_Packet_Message_t) + PacketLength);\r
+ DeviceMessage.DataOffset = CPU_TO_LE32(sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t));\r
+ DeviceMessage.DataLength = cpu_to_le32(PacketLength);\r
+\r
+ Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ErrorCode = Pipe_Write_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t),\r
+ NULL)) != PIPE_RWSTREAM_NoError)\r
+ {\r
+ return ErrorCode;\r
+ }\r
+\r
+ Pipe_Write_Stream_LE(Buffer, PacketLength, NULL);\r
+ Pipe_ClearOUT();\r
+\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Host mode driver for the library USB RNDIS Class driver.\r
+ *\r
+ * Host mode driver for the library USB RNDIS Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassRNDIS\r
+ * \defgroup Group_USBClassRNDISHost RNDIS Class Host Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/RNDISClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Host Mode USB Class driver framework interface, for the Microsoft RNDIS Ethernet\r
+ * USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __RNDIS_CLASS_HOST_H__\r
+#define __RNDIS_CLASS_HOST_H__\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/RNDISClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_RNDIS_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** \brief RNDIS Class Host Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made within the user application,\r
+ * and passed to each of the RNDIS class driver functions as the \c RNDISInterfaceInfo parameter. This\r
+ * stores each RNDIS interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */\r
+ USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */\r
+ USB_Pipe_Table_t NotificationPipe; /**< Notification IN Pipe configuration table. */\r
+\r
+ uint32_t HostMaxPacketSize; /**< Maximum size of a packet which can be buffered by the host. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+ * after \ref RNDIS_Host_ConfigurePipes() is called and the Host state machine is in the\r
+ * Configured state.\r
+ */\r
+ uint8_t ControlInterfaceNumber; /**< Interface index of the RNDIS control interface within the attached device. */\r
+\r
+ uint32_t DeviceMaxPacketSize; /**< Maximum size of a packet which can be buffered by the attached RNDIS device. */\r
+\r
+ uint32_t RequestID; /**< Request ID counter to give a unique ID for each command/response pair. */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * <b>may</b> be set to initial values, but may also be ignored to default to sane values when\r
+ * the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_RNDIS_Host_t;\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error codes returned by the \ref RNDIS_Host_ConfigurePipes() function. */\r
+ enum RNDIS_Host_EnumerationFailure_ErrorCodes_t\r
+ {\r
+ RNDIS_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */\r
+ RNDIS_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */\r
+ RNDIS_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible RNDIS interface was not found in the device's Configuration Descriptor. */\r
+ RNDIS_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ /** Host interface configuration routine, to configure a given RNDIS host interface instance using the Configuration\r
+ * Descriptor read from an attached USB device. This function automatically updates the given RNDIS Host instance's\r
+ * state values and configures the pipes required to communicate with the interface if it is found within the device.\r
+ * This should be called once after the stack has enumerated the attached device, while the host state machine is in\r
+ * the Addressed state.\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state.\r
+ * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor.\r
+ * \param[in] ConfigDescriptorData Pointer to a buffer containing the attached device's Configuration Descriptor.\r
+ *\r
+ * \return A value from the \ref RNDIS_Host_EnumerationFailure_ErrorCodes_t enum.\r
+ */\r
+ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Sends a RNDIS KEEPALIVE command to the device, to ensure that it does not enter standby mode after periods\r
+ * of long inactivity.\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum or \ref RNDIS_ERROR_LOGICAL_CMD_FAILED if the device returned a\r
+ * logical command failure.\r
+ */\r
+ uint8_t RNDIS_Host_SendKeepAlive(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Initializes the attached RNDIS device's RNDIS interface. This should be called after the device's pipes have been\r
+ * configured via the call to \ref RNDIS_Host_ConfigurePipes().\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum or \ref RNDIS_ERROR_LOGICAL_CMD_FAILED if the\r
+ * device returned a logical command failure.\r
+ */\r
+ uint8_t RNDIS_Host_InitializeDevice(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sets a given RNDIS property of an attached RNDIS device.\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state.\r
+ * \param[in] Oid OID number of the parameter to set.\r
+ * \param[in] Buffer Pointer to where the property data is to be sourced from.\r
+ * \param[in] Length Length in bytes of the property data to sent to the device.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum or \ref RNDIS_ERROR_LOGICAL_CMD_FAILED if the\r
+ * device returned a logical command failure.\r
+ */\r
+ uint8_t RNDIS_Host_SetRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ const uint32_t Oid,\r
+ void* Buffer,\r
+ const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Gets a given RNDIS property of an attached RNDIS device.\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state.\r
+ * \param[in] Oid OID number of the parameter to get.\r
+ * \param[in] Buffer Pointer to where the property data is to be written to.\r
+ * \param[in] MaxLength Length in bytes of the destination buffer size.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum or \ref RNDIS_ERROR_LOGICAL_CMD_FAILED if the\r
+ * device returned a logical command failure.\r
+ */\r
+ uint8_t RNDIS_Host_QueryRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ const uint32_t Oid,\r
+ void* Buffer,\r
+ const uint16_t MaxLength) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Determines if a packet is currently waiting for the host to read in and process.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state.\r
+ *\r
+ * \return Boolean \c true if a packet is waiting to be read in by the host, \c false otherwise.\r
+ */\r
+ bool RNDIS_Host_IsPacketReceived(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Retrieves the next pending packet from the device, discarding the remainder of the RNDIS packet header to leave\r
+ * only the packet contents for processing by the host in the nominated buffer.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state.\r
+ * \param[out] Buffer Pointer to a buffer where the packer data is to be written to.\r
+ * \param[out] PacketLength Pointer to where the length in bytes of the read packet is to be stored.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ void* Buffer,\r
+ uint16_t* const PacketLength) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2)\r
+ ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Sends the given packet to the attached RNDIS device, after adding a RNDIS packet message header.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state.\r
+ * \param[in] Buffer Pointer to a buffer where the packer data is to be read from.\r
+ * \param[in] PacketLength Length in bytes of the packet to send.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t PacketLength) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /* Inline Functions: */\r
+ /** General management task for a given RNDIS host class interface, required for the correct operation of the interface. This should\r
+ * be called frequently in the main program loop, before the master USB management task \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] RNDISInterfaceInfo Pointer to a structure containing an RNDIS Class host configuration and state.\r
+ */\r
+ static inline void RNDIS_Host_USBTask(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline void RNDIS_Host_USBTask(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo)\r
+ {\r
+ (void)RNDISInterfaceInfo;\r
+ }\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_RNDIS_HOST_C)\r
+ static uint8_t RNDIS_SendEncapsulatedCommand(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_NON_NULL_PTR_ARG(2);\r
+ static uint8_t RNDIS_GetEncapsulatedResponse(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t Length) ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ static uint8_t DCOMP_RNDIS_Host_NextRNDISControlInterface(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_RNDIS_Host_NextRNDISDataInterface(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_RNDIS_Host_NextRNDISInterfaceEndpoint(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../../Core/USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_SI_DRIVER\r
+#define __INCLUDE_FROM_STILLIMAGE_HOST_C\r
+#include "StillImageClassHost.h"\r
+\r
+uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData)\r
+{\r
+ USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;\r
+ USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;\r
+ USB_Descriptor_Endpoint_t* EventsEndpoint = NULL;\r
+ USB_Descriptor_Interface_t* StillImageInterface = NULL;\r
+\r
+ memset(&SIInterfaceInfo->State, 0x00, sizeof(SIInterfaceInfo->State));\r
+\r
+ if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)\r
+ return SI_ENUMERROR_InvalidConfigDescriptor;\r
+\r
+ while (!(DataINEndpoint) || !(DataOUTEndpoint) || !(EventsEndpoint))\r
+ {\r
+ if (!(StillImageInterface) ||\r
+ USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_SI_Host_NextSIInterfaceEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,\r
+ DCOMP_SI_Host_NextSIInterface) != DESCRIPTOR_SEARCH_COMP_Found)\r
+ {\r
+ return SI_ENUMERROR_NoCompatibleInterfaceFound;\r
+ }\r
+\r
+ StillImageInterface = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Interface_t);\r
+\r
+ DataINEndpoint = NULL;\r
+ DataOUTEndpoint = NULL;\r
+ EventsEndpoint = NULL;\r
+\r
+ continue;\r
+ }\r
+\r
+ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);\r
+\r
+ if ((EndpointData->EndpointAddress & ENDPOINT_DIR_MASK) == ENDPOINT_DIR_IN)\r
+ {\r
+ if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT)\r
+ EventsEndpoint = EndpointData;\r
+ else\r
+ DataINEndpoint = EndpointData;\r
+ }\r
+ else\r
+ {\r
+ DataOUTEndpoint = EndpointData;\r
+ }\r
+ }\r
+\r
+ SIInterfaceInfo->Config.DataINPipe.Size = le16_to_cpu(DataINEndpoint->EndpointSize);\r
+ SIInterfaceInfo->Config.DataINPipe.EndpointAddress = DataINEndpoint->EndpointAddress;\r
+ SIInterfaceInfo->Config.DataINPipe.Type = EP_TYPE_BULK;\r
+ \r
+ SIInterfaceInfo->Config.DataOUTPipe.Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);\r
+ SIInterfaceInfo->Config.DataOUTPipe.EndpointAddress = DataOUTEndpoint->EndpointAddress;\r
+ SIInterfaceInfo->Config.DataOUTPipe.Type = EP_TYPE_BULK;\r
+ \r
+ SIInterfaceInfo->Config.EventsPipe.Size = le16_to_cpu(EventsEndpoint->EndpointSize);\r
+ SIInterfaceInfo->Config.EventsPipe.EndpointAddress = EventsEndpoint->EndpointAddress;\r
+ SIInterfaceInfo->Config.EventsPipe.Type = EP_TYPE_INTERRUPT;\r
+\r
+ if (!(Pipe_ConfigurePipeTable(&SIInterfaceInfo->Config.DataINPipe, 1)))\r
+ return false;\r
+ \r
+ if (!(Pipe_ConfigurePipeTable(&SIInterfaceInfo->Config.DataOUTPipe, 1)))\r
+ return false;\r
+\r
+ if (!(Pipe_ConfigurePipeTable(&SIInterfaceInfo->Config.EventsPipe, 1)))\r
+ return false;\r
+ \r
+ SIInterfaceInfo->State.InterfaceNumber = StillImageInterface->InterfaceNumber;\r
+ SIInterfaceInfo->State.IsActive = true;\r
+\r
+ return SI_ENUMERROR_NoError;\r
+}\r
+\r
+uint8_t DCOMP_SI_Host_NextSIInterface(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Interface)\r
+ {\r
+ USB_Descriptor_Interface_t* Interface = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Interface_t);\r
+\r
+ if ((Interface->Class == SI_CSCP_StillImageClass) &&\r
+ (Interface->SubClass == SI_CSCP_StillImageSubclass) &&\r
+ (Interface->Protocol == SI_CSCP_BulkOnlyProtocol))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+uint8_t DCOMP_SI_Host_NextSIInterfaceEndpoint(void* const CurrentDescriptor)\r
+{\r
+ USB_Descriptor_Header_t* Header = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Header_t);\r
+\r
+ if (Header->Type == DTYPE_Endpoint)\r
+ {\r
+ USB_Descriptor_Endpoint_t* Endpoint = DESCRIPTOR_PCAST(CurrentDescriptor, USB_Descriptor_Endpoint_t);\r
+\r
+ uint8_t EndpointType = (Endpoint->Attributes & EP_TYPE_MASK);\r
+\r
+ if (((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) &&\r
+ (!(Pipe_IsEndpointBound(Endpoint->EndpointAddress))))\r
+ {\r
+ return DESCRIPTOR_SEARCH_Found;\r
+ }\r
+ }\r
+ else if (Header->Type == DTYPE_Interface)\r
+ {\r
+ return DESCRIPTOR_SEARCH_Fail;\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_NotFound;\r
+}\r
+\r
+uint8_t SI_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ PIMA_Container_t* const PIMAHeader)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ if (SIInterfaceInfo->State.IsSessionOpen)\r
+ PIMAHeader->TransactionID = cpu_to_le32(SIInterfaceInfo->State.TransactionID++);\r
+\r
+ Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ErrorCode = Pipe_Write_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NULL)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ uint8_t ParamBytes = (PIMAHeader->DataLength - PIMA_COMMAND_SIZE(0));\r
+\r
+ if (ParamBytes)\r
+ {\r
+ if ((ErrorCode = Pipe_Write_Stream_LE(&PIMAHeader->Params, ParamBytes, NULL)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+ }\r
+\r
+ Pipe_ClearOUT();\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ PIMA_Container_t* const PIMAHeader)\r
+{\r
+ uint16_t TimeoutMSRem = SI_COMMAND_DATA_TIMEOUT_MS;\r
+ uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();\r
+\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ while (!(Pipe_IsINReceived()))\r
+ {\r
+ uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();\r
+\r
+ if (CurrentFrameNumber != PreviousFrameNumber)\r
+ {\r
+ PreviousFrameNumber = CurrentFrameNumber;\r
+\r
+ if (!(TimeoutMSRem--))\r
+ return PIPE_RWSTREAM_Timeout;\r
+ }\r
+\r
+ Pipe_Freeze();\r
+ Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_IsStalled())\r
+ {\r
+ USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress());\r
+ return PIPE_RWSTREAM_PipeStalled;\r
+ }\r
+\r
+ Pipe_Freeze();\r
+ Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_IsStalled())\r
+ {\r
+ USB_Host_ClearEndpointStall(Pipe_GetBoundEndpointAddress());\r
+ return PIPE_RWSTREAM_PipeStalled;\r
+ }\r
+\r
+ if (USB_HostState == HOST_STATE_Unattached)\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+ }\r
+\r
+ Pipe_Read_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NULL);\r
+\r
+ if (PIMAHeader->Type == CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock))\r
+ {\r
+ uint8_t ParamBytes = (PIMAHeader->DataLength - PIMA_COMMAND_SIZE(0));\r
+\r
+ if (ParamBytes)\r
+ Pipe_Read_Stream_LE(&PIMAHeader->Params, ParamBytes, NULL);\r
+\r
+ Pipe_ClearIN();\r
+ }\r
+\r
+ Pipe_Freeze();\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t SI_Host_SendData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t Bytes)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ ErrorCode = Pipe_Write_Stream_LE(Buffer, Bytes, NULL);\r
+\r
+ Pipe_ClearOUT();\r
+ Pipe_Freeze();\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+uint8_t SI_Host_ReadData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t Bytes)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ Pipe_SelectPipe(SIInterfaceInfo->Config.DataINPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ ErrorCode = Pipe_Read_Stream_LE(Buffer, Bytes, NULL);\r
+\r
+ Pipe_Freeze();\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+bool SI_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)\r
+{\r
+ bool IsEventReceived = false;\r
+\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))\r
+ return false;\r
+\r
+ Pipe_SelectPipe(SIInterfaceInfo->Config.EventsPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ if (Pipe_BytesInPipe())\r
+ IsEventReceived = true;\r
+\r
+ Pipe_Freeze();\r
+\r
+ return IsEventReceived;\r
+}\r
+\r
+uint8_t SI_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ PIMA_Container_t* const PIMAHeader)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ Pipe_SelectPipe(SIInterfaceInfo->Config.EventsPipe.Address);\r
+ Pipe_Unfreeze();\r
+\r
+ ErrorCode = Pipe_Read_Stream_LE(PIMAHeader, sizeof(PIMA_Container_t), NULL);\r
+\r
+ Pipe_ClearIN();\r
+ Pipe_Freeze();\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+uint8_t SI_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ SIInterfaceInfo->State.TransactionID = 0;\r
+ SIInterfaceInfo->State.IsSessionOpen = false;\r
+\r
+ PIMA_Container_t PIMABlock = (PIMA_Container_t)\r
+ {\r
+ .DataLength = CPU_TO_LE32(PIMA_COMMAND_SIZE(1)),\r
+ .Type = CPU_TO_LE16(PIMA_CONTAINER_CommandBlock),\r
+ .Code = CPU_TO_LE16(0x1002),\r
+ .Params = {CPU_TO_LE32(1)},\r
+ };\r
+\r
+ if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ if ((PIMABlock.Type != CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock)) || (PIMABlock.Code != CPU_TO_LE16(0x2001)))\r
+ return SI_ERROR_LOGICAL_CMD_FAILED;\r
+\r
+ SIInterfaceInfo->State.IsSessionOpen = true;\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t SI_Host_CloseSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ PIMA_Container_t PIMABlock = (PIMA_Container_t)\r
+ {\r
+ .DataLength = CPU_TO_LE32(PIMA_COMMAND_SIZE(1)),\r
+ .Type = CPU_TO_LE16(PIMA_CONTAINER_CommandBlock),\r
+ .Code = CPU_TO_LE16(0x1003),\r
+ .Params = {CPU_TO_LE32(1)},\r
+ };\r
+\r
+ if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ SIInterfaceInfo->State.IsSessionOpen = false;\r
+\r
+ if ((PIMABlock.Type != CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock)) || (PIMABlock.Code != CPU_TO_LE16(0x2001)))\r
+ return SI_ERROR_LOGICAL_CMD_FAILED;\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t SI_Host_SendCommand(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ const uint16_t Operation,\r
+ const uint8_t TotalParams,\r
+ uint32_t* const Params)\r
+{\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ uint8_t ErrorCode;\r
+\r
+ PIMA_Container_t PIMABlock = (PIMA_Container_t)\r
+ {\r
+ .DataLength = cpu_to_le32(PIMA_COMMAND_SIZE(TotalParams)),\r
+ .Type = CPU_TO_LE16(PIMA_CONTAINER_CommandBlock),\r
+ .Code = cpu_to_le16(Operation),\r
+ };\r
+\r
+ memcpy(&PIMABlock.Params, Params, sizeof(uint32_t) * TotalParams);\r
+\r
+ if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t SI_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)\r
+{\r
+ uint8_t ErrorCode;\r
+ PIMA_Container_t PIMABlock;\r
+\r
+ if ((USB_HostState != HOST_STATE_Configured) || !(SIInterfaceInfo->State.IsActive))\r
+ return PIPE_RWSTREAM_DeviceDisconnected;\r
+\r
+ if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)\r
+ return ErrorCode;\r
+\r
+ if ((PIMABlock.Type != CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock)) || (PIMABlock.Code != CPU_TO_LE16(0x2001)))\r
+ return SI_ERROR_LOGICAL_CMD_FAILED;\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Host mode driver for the library USB Still Image Class driver.\r
+ *\r
+ * Host mode driver for the library USB Still Image Class driver.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB module driver\r
+ * dispatch header located in LUFA/Drivers/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBClassSI\r
+ * \defgroup Group_USBClassStillImageHost Still Image Class Host Mode Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/StillImageClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Host Mode USB Class driver framework interface, for the Still Image USB Class driver.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __SI_CLASS_HOST_H__\r
+#define __SI_CLASS_HOST_H__\r
+\r
+ /* Includes: */\r
+ #include "../../USB.h"\r
+ #include "../Common/StillImageClassCommon.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_SI_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Error code for some Still Image Host functions, indicating a logical (and not hardware) error. */\r
+ #define SI_ERROR_LOGICAL_CMD_FAILED 0x80\r
+\r
+ /* Type Defines: */\r
+ /** \brief Still Image Class Host Mode Configuration and State Structure.\r
+ *\r
+ * Class state structure. An instance of this structure should be made within the user application,\r
+ * and passed to each of the Still Image class driver functions as the \c SIInterfaceInfo parameter. This\r
+ * stores each Still Image interface's configuration and state information.\r
+ */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ USB_Pipe_Table_t DataINPipe; /**< Data IN Pipe configuration table. */\r
+ USB_Pipe_Table_t DataOUTPipe; /**< Data OUT Pipe configuration table. */\r
+ USB_Pipe_Table_t EventsPipe; /**< Event notification IN Pipe configuration table. */\r
+ } Config; /**< Config data for the USB class interface within the device. All elements in this section\r
+ * <b>must</b> be set or the interface will fail to enumerate and operate correctly.\r
+ */\r
+ struct\r
+ {\r
+ bool IsActive; /**< Indicates if the current interface instance is connected to an attached device, valid\r
+ * after \ref SI_Host_ConfigurePipes() is called and the Host state machine is in the\r
+ * Configured state.\r
+ */\r
+ uint8_t InterfaceNumber; /**< Interface index of the Still Image interface within the attached device. */\r
+\r
+ bool IsSessionOpen; /**< Indicates if a PIMA session is currently open with the attached device. */\r
+ uint32_t TransactionID; /**< Transaction ID for the next transaction to send to the device. */\r
+ } State; /**< State data for the USB class interface within the device. All elements in this section\r
+ * <b>may</b> be set to initial values, but may also be ignored to default to sane values when\r
+ * the interface is enumerated.\r
+ */\r
+ } USB_ClassInfo_SI_Host_t;\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error codes returned by the \ref SI_Host_ConfigurePipes() function. */\r
+ enum SI_Host_EnumerationFailure_ErrorCodes_t\r
+ {\r
+ SI_ENUMERROR_NoError = 0, /**< Configuration Descriptor was processed successfully. */\r
+ SI_ENUMERROR_InvalidConfigDescriptor = 1, /**< The device returned an invalid Configuration Descriptor. */\r
+ SI_ENUMERROR_NoCompatibleInterfaceFound = 2, /**< A compatible Still Image interface was not found in the device's\r
+ * Configuration Descriptor.\r
+ */\r
+ SI_ENUMERROR_PipeConfigurationFailed = 3, /**< One or more pipes for the specified interface could not be configured correctly. */\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ /** Host interface configuration routine, to configure a given Still Image host interface instance using the\r
+ * Configuration Descriptor read from an attached USB device. This function automatically updates the given Still\r
+ * Image Host instance's state values and configures the pipes required to communicate with the interface if it is\r
+ * found within the device. This should be called once after the stack has enumerated the attached device, while\r
+ * the host state machine is in the Addressed state.\r
+ *\r
+ * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state.\r
+ * \param[in] ConfigDescriptorSize Length of the attached device's Configuration Descriptor.\r
+ * \param[in] ConfigDescriptorData Pointer to a buffer containing the attached device's Configuration Descriptor.\r
+ *\r
+ * \return A value from the \ref SI_Host_EnumerationFailure_ErrorCodes_t enum.\r
+ */\r
+ uint8_t SI_Host_ConfigurePipes(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ uint16_t ConfigDescriptorSize,\r
+ void* ConfigDescriptorData) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Opens a new PIMA session with the attached device. This should be used before any session-orientated PIMA commands\r
+ * are issued to the device. Only one session can be open at the one time.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device\r
+ * returned a logical command failure.\r
+ */\r
+ uint8_t SI_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Closes an already opened PIMA session with the attached device. This should be used after all session-orientated\r
+ * PIMA commands have been issued to the device.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device\r
+ * returned a logical command failure.\r
+ */\r
+ uint8_t SI_Host_CloseSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sends a raw PIMA block header to the device, filling out the transaction ID automatically. This can be used to send\r
+ * arbitrary PIMA blocks to the device with or without parameters.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state.\r
+ * \param[in] PIMAHeader Pointer to a PIMA container structure that is to be sent.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t SI_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ PIMA_Container_t* const PIMAHeader) ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Receives a raw PIMA block header from the device. This can be used to receive arbitrary PIMA blocks from the device with\r
+ * or without parameters.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state.\r
+ * \param[out] PIMAHeader Pointer to a PIMA container structure where the received block is to be stored.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ PIMA_Container_t* const PIMAHeader) ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Sends a given PIMA command to the attached device, filling out the PIMA command header's Transaction ID automatically.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state.\r
+ * \param[in] Operation PIMA operation code to issue to the device.\r
+ * \param[in] TotalParams Total number of 32-bit parameters to send to the device in the issued command block.\r
+ * \param[in] Params Pointer to an array of 32-bit values containing the parameters to send in the command block.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device\r
+ * returned a logical command failure.\r
+ */\r
+ uint8_t SI_Host_SendCommand(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ const uint16_t Operation,\r
+ const uint8_t TotalParams,\r
+ uint32_t* const Params) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Receives and checks a response block from the attached Still Image device, once a command has been issued and all data\r
+ * associated with the command has been transferred.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device\r
+ * returned a logical command failure.\r
+ */\r
+ uint8_t SI_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Indicates if the device has issued a PIMA event block to the host via the asynchronous events pipe.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state.\r
+ *\r
+ * \return Boolean \c true if an event is waiting to be read, \c false otherwise.\r
+ */\r
+ bool SI_Host_IsEventReceived(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Receives an asynchronous event block from the device via the asynchronous events pipe.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state.\r
+ * \param[out] PIMAHeader Pointer to a PIMA container structure where the event should be stored.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum, or \ref SI_ERROR_LOGICAL_CMD_FAILED if the device\r
+ * returned a logical command failure.\r
+ */\r
+ uint8_t SI_Host_ReceiveEventHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ PIMA_Container_t* const PIMAHeader) ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Sends arbitrary data to the attached device, for use in the data phase of PIMA commands which require data\r
+ * transfer beyond the regular PIMA command block parameters.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state.\r
+ * \param[in] Buffer Pointer to a buffer where the data to send has been stored.\r
+ * \param[in] Bytes Length in bytes of the data in the buffer to send to the attached device.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t SI_Host_SendData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t Bytes) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Receives arbitrary data from the attached device, for use in the data phase of PIMA commands which require data\r
+ * transfer beyond the regular PIMA command block parameters.\r
+ *\r
+ * \pre This function must only be called when the Host state machine is in the \ref HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state.\r
+ * \param[out] Buffer Pointer to a buffer where the received data is to be stored.\r
+ * \param[in] Bytes Length in bytes of the data to read.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t SI_Host_ReadData(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,\r
+ void* Buffer,\r
+ const uint16_t Bytes) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /* Inline Functions: */\r
+ /** General management task for a given Still Image host class interface, required for the correct operation of the\r
+ * interface. This should be called frequently in the main program loop, before the master USB management task\r
+ * \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] SIInterfaceInfo Pointer to a structure containing a Still Image Class host configuration and state.\r
+ */\r
+ static inline void SI_Host_USBTask(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;\r
+ static inline void SI_Host_USBTask(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)\r
+ {\r
+ (void)SIInterfaceInfo;\r
+ }\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define SI_COMMAND_DATA_TIMEOUT_MS 10000\r
+\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_STILLIMAGE_HOST_C)\r
+ static uint8_t DCOMP_SI_Host_NextSIInterface(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ static uint8_t DCOMP_SI_Host_NextSIInterfaceEndpoint(void* const CurrentDescriptor)\r
+ ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(1);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master include file for the library USB MIDI Class driver.\r
+ *\r
+ * Master include file for the library USB MIDI Class driver, for both host and device modes, where available.\r
+ *\r
+ * This file should be included in all user projects making use of this optional class driver, instead of\r
+ * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories.\r
+ */\r
+\r
+/** \ingroup Group_USBClassDrivers\r
+ * \defgroup Group_USBClassMIDI MIDI Class Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Device/MIDIClassDevice.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ * - LUFA/Drivers/USB/Class/Host/MIDIClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * MIDI Class Driver module. This module contains an internal implementation of the USB MIDI Class, for both Device\r
+ * and Host USB modes. User applications can use this class driver instead of implementing the MIDI class manually\r
+ * via the low-level LUFA APIs.\r
+ *\r
+ * This module is designed to simplify the user code by exposing only the required interface needed to interface with\r
+ * Hosts or Devices using the USB MIDI Class.\r
+ *\r
+ * \note The USB MIDI class is actually a special case of the regular Audio class, thus this module depends on\r
+ * structure definitions from the \ref Group_USBClassAudioDevice class driver module.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _MIDI_CLASS_H_\r
+#define _MIDI_CLASS_H_\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_USB_DRIVER\r
+ #define __INCLUDE_FROM_MIDI_DRIVER\r
+\r
+ /* Includes: */\r
+ #include "../Core/USBMode.h"\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #include "Device/MIDIClassDevice.h"\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #include "Host/MIDIClassHost.h"\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master include file for the library USB Mass Storage Class driver.\r
+ *\r
+ * Master include file for the library USB Mass Storage Class driver, for both host and device modes, where available.\r
+ *\r
+ * This file should be included in all user projects making use of this optional class driver, instead of\r
+ * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories.\r
+ */\r
+\r
+/** \ingroup Group_USBClassDrivers\r
+ * \defgroup Group_USBClassMS Mass Storage Class Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Device/MassStorageClassDevice.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ * - LUFA/Drivers/USB/Class/Host/MassStorageClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Mass Storage Class Driver module. This module contains an internal implementation of the USB Mass Storage Class, for both\r
+ * Device and Host USB modes. User applications can use this class driver instead of implementing the Mass Storage class\r
+ * manually via the low-level LUFA APIs.\r
+ *\r
+ * This module is designed to simplify the user code by exposing only the required interface needed to interface with\r
+ * Hosts or Devices using the USB Mass Storage Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _MS_CLASS_H_\r
+#define _MS_CLASS_H_\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_USB_DRIVER\r
+ #define __INCLUDE_FROM_MS_DRIVER\r
+\r
+ /* Includes: */\r
+ #include "../Core/USBMode.h"\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #include "Device/MassStorageClassDevice.h"\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #include "Host/MassStorageClassHost.h"\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master include file for the library USB Printer Class driver.\r
+ *\r
+ * Master include file for the library USB Printer Class driver, for both host and device modes, where available.\r
+ *\r
+ * This file should be included in all user projects making use of this optional class driver, instead of\r
+ * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories.\r
+ */\r
+\r
+/** \ingroup Group_USBClassDrivers\r
+ * \defgroup Group_USBClassPrinter Printer Class Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/PrinterClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Printer Class Driver module. This module contains an internal implementation of the USB Printer Class, for the base\r
+ * USB Printer transport layer for USB Host mode only. Note that printers are free to implement whatever printer language\r
+ * they choose on top of this (e.g. Postscript), and so this driver exposes low level data transport functions only rather\r
+ * than high level raster or text functions. User applications can use this class driver instead of implementing the Printer\r
+ * class manually via the low-level LUFA APIs.\r
+ *\r
+ * This module is designed to simplify the user code by exposing only the required interface needed to interface with\r
+ * Devices using the USB Printer Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _PRINTER_CLASS_H_\r
+#define _PRINTER_CLASS_H_\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_USB_DRIVER\r
+ #define __INCLUDE_FROM_PRINTER_DRIVER\r
+\r
+ /* Includes: */\r
+ #include "../Core/USBMode.h"\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #include "Host/PrinterClassHost.h"\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master include file for the library USB RNDIS Class driver.\r
+ *\r
+ * Master include file for the library USB RNDIS Class driver, for both host and device modes, where available.\r
+ *\r
+ * This file should be included in all user projects making use of this optional class driver, instead of\r
+ * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories.\r
+ */\r
+\r
+/** \ingroup Group_USBClassDrivers\r
+ * \defgroup Group_USBClassRNDIS RNDIS (Networking) Class Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Device/RNDISClassDevice.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ * - LUFA/Drivers/USB/Class/Host/RNDISClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * RNDIS Class Driver module. This module contains an internal implementation of the Microsoft USB RNDIS Networking\r
+ * Class, for both Device and Host USB modes. User applications can use this class driver instead of implementing the\r
+ * RNDIS class manually via the low-level LUFA APIs.\r
+ *\r
+ * This module is designed to simplify the user code by exposing only the required interface needed to interface with\r
+ * Hosts using the USB RNDIS Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _RNDIS_CLASS_H_\r
+#define _RNDIS_CLASS_H_\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_USB_DRIVER\r
+ #define __INCLUDE_FROM_RNDIS_DRIVER\r
+\r
+ /* Includes: */\r
+ #include "../Core/USBMode.h"\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #include "Device/RNDISClassDevice.h"\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #include "Host/RNDISClassHost.h"\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master include file for the library USB Still Image Class driver.\r
+ *\r
+ * Master include file for the library USB Still Image Class driver, for both host and device modes, where available.\r
+ *\r
+ * This file should be included in all user projects making use of this optional class driver, instead of\r
+ * including any headers in the USB/ClassDriver/Device, USB/ClassDriver/Host or USB/ClassDriver/Common subdirectories.\r
+ */\r
+\r
+/** \ingroup Group_USBClassDrivers\r
+ * \defgroup Group_USBClassSI Still Image Class Driver\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Class/Host/StillImageClassHost.c <i>(Makefile source module name: LUFA_SRC_USBCLASS)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Still Image Class Driver module. This module contains an internal implementation of the USB Still Image Class,\r
+ * for USB Host mode only. User applications can use this class driver instead of implementing the Still Image class\r
+ * manually via the low-level LUFA APIs.\r
+ *\r
+ * This module is designed to simplify the user code by exposing only the required interface needed to interface with\r
+ * Devices using the USB Still Image Class.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _SI_CLASS_H_\r
+#define _SI_CLASS_H_\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_USB_DRIVER\r
+ #define __INCLUDE_FROM_SI_DRIVER\r
+\r
+ /* Includes: */\r
+ #include "../Core/USBMode.h"\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #include "Host/StillImageClassHost.h"\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_AVR8)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#include "../Device.h"\r
+\r
+void USB_Device_SendRemoteWakeup(void)\r
+{\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ {\r
+ USB_PLL_On();\r
+ while (!(USB_PLL_IsReady()));\r
+ }\r
+\r
+ USB_CLK_Unfreeze();\r
+\r
+ UDCON |= (1 << RMWKUP);\r
+ while (UDCON & (1 << RMWKUP));\r
+}\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Device definitions for the AVR8 microcontrollers.\r
+ * \copydetails Group_Device_AVR8\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_Device\r
+ * \defgroup Group_Device_AVR8 Device Management (AVR8)\r
+ * \brief USB Device definitions for the AVR8 microcontrollers.\r
+ *\r
+ * Architecture specific USB Device definitions for the Atmel 8-bit AVR microcontrollers.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBDEVICE_AVR8_H__\r
+#define __USBDEVICE_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBController.h"\r
+ #include "../StdDescriptors.h"\r
+ #include "../USBInterrupt.h"\r
+ #include "../Endpoint.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))\r
+ #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.\r
+ #endif\r
+\r
+ #if (defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))\r
+ #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.\r
+ #endif\r
+\r
+ #if (defined(USE_FLASH_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS))\r
+ #error USE_FLASH_DESCRIPTORS and USE_RAM_DESCRIPTORS are mutually exclusive.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name USB Device Mode Option Masks */\r
+ //@{\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)\r
+ /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the\r
+ * USB interface should be initialized in low speed (1.5Mb/s) mode.\r
+ *\r
+ * \note Low Speed mode is not available on all USB AVR models.\r
+ * \n\r
+ *\r
+ * \note Restrictions apply on the number, size and type of endpoints which can be used\r
+ * when running in low speed mode - please refer to the USB 2.0 specification.\r
+ */\r
+ #define USB_DEVICE_OPT_LOWSPEED (1 << 0)\r
+ #endif\r
+\r
+ /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the\r
+ * USB interface should be initialized in full speed (12Mb/s) mode.\r
+ */\r
+ #define USB_DEVICE_OPT_FULLSPEED (0 << 0)\r
+ //@}\r
+\r
+ #if (!defined(NO_INTERNAL_SERIAL) && \\r
+ (defined(USB_SERIES_7_AVR) || defined(USB_SERIES_6_AVR) || \\r
+ defined(USB_SERIES_4_AVR) || defined(USB_SERIES_2_AVR) || \\r
+ defined(__DOXYGEN__)))\r
+ /** String descriptor index for the device's unique serial number string descriptor within the device.\r
+ * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port\r
+ * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain\r
+ * a unique serial number internally, and setting the device descriptors serial number string index to this value\r
+ * will cause it to use the internal serial number.\r
+ *\r
+ * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial\r
+ * number for the device.\r
+ */\r
+ #define USE_INTERNAL_SERIAL 0xDC\r
+\r
+ /** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller\r
+ * model.\r
+ */\r
+ #define INTERNAL_SERIAL_LENGTH_BITS 80\r
+\r
+ /** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller\r
+ * model.\r
+ */\r
+ #define INTERNAL_SERIAL_START_ADDRESS 0x0E\r
+ #else\r
+ #define USE_INTERNAL_SERIAL NO_DESCRIPTOR\r
+\r
+ #define INTERNAL_SERIAL_LENGTH_BITS 0\r
+ #define INTERNAL_SERIAL_START_ADDRESS 0\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ /** Sends a Remote Wakeup request to the host. This signals to the host that the device should\r
+ * be taken out of suspended mode, and communications should resume.\r
+ *\r
+ * Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the\r
+ * host computer when the host has suspended all USB devices to enter a low power state.\r
+ *\r
+ * \attention This function should only be used if the device has indicated to the host that it\r
+ * supports the Remote Wakeup feature in the device descriptors, and should only be\r
+ * issued if the host is currently allowing remote wakeup events from the device (i.e.,\r
+ * the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP\r
+ * compile time option is used, this function is unavailable.\r
+ * \n\n\r
+ *\r
+ * \attention The USB clock must be running for this function to operate. If the stack is initialized with\r
+ * the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running\r
+ * before attempting to call this function.\r
+ *\r
+ * \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors.\r
+ */\r
+ void USB_Device_SendRemoteWakeup(void);\r
+\r
+ /* Inline Functions: */\r
+ /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)\r
+ * the frame number is incremented by one.\r
+ *\r
+ * \return Current USB frame number from the USB controller.\r
+ */\r
+ static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint16_t USB_Device_GetFrameNumber(void)\r
+ {\r
+ return UDFNUM;\r
+ }\r
+\r
+ #if !defined(NO_SOF_EVENTS)\r
+ /** Enables the device mode Start Of Frame events. When enabled, this causes the\r
+ * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,\r
+ * at the start of each USB frame when enumerated in device mode.\r
+ *\r
+ * \note This function is not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_EnableSOFEvents(void)\r
+ {\r
+ USB_INT_Enable(USB_INT_SOFI);\r
+ }\r
+\r
+ /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the\r
+ * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.\r
+ *\r
+ * \note This function is not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_DisableSOFEvents(void)\r
+ {\r
+ USB_INT_Disable(USB_INT_SOFI);\r
+ }\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Inline Functions: */\r
+ #if defined(USB_DEVICE_OPT_LOWSPEED)\r
+ static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetLowSpeed(void)\r
+ {\r
+ UDCON |= (1 << LSM);\r
+ }\r
+\r
+ static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetFullSpeed(void)\r
+ {\r
+ UDCON &= ~(1 << LSM);\r
+ }\r
+ #endif\r
+\r
+ static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetDeviceAddress(const uint8_t Address)\r
+ {\r
+ uint8_t Temp = (UDADDR & (1 << ADDEN)) | (Address & 0x7F);\r
+\r
+ UDADDR = Temp;\r
+ UDADDR = Temp | (1 << ADDEN);\r
+ }\r
+\r
+ static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool USB_Device_IsAddressSet(void)\r
+ {\r
+ return (UDADDR & (1 << ADDEN));\r
+ }\r
+\r
+ #if (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)\r
+ static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString)\r
+ {\r
+ uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+ GlobalInterruptDisable();\r
+\r
+ uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS;\r
+\r
+ for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)\r
+ {\r
+ uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);\r
+\r
+ if (SerialCharNum & 0x01)\r
+ {\r
+ SerialByte >>= 4;\r
+ SigReadAddress++;\r
+ }\r
+\r
+ SerialByte &= 0x0F;\r
+\r
+ UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?\r
+ (('A' - 10) + SerialByte) : ('0' + SerialByte));\r
+ }\r
+\r
+ SetGlobalInterruptMask(CurrentGlobalInt);\r
+ }\r
+ #endif\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_AVR8)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#include "EndpointStream_AVR8.h"\r
+\r
+#if !defined(CONTROL_ONLY_DEVICE)\r
+uint8_t Endpoint_Discard_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t ErrorCode;\r
+ uint16_t BytesInTransfer = 0;\r
+ \r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ \r
+ if (BytesProcessed != NULL)\r
+ Length -= *BytesProcessed;\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ {\r
+ Endpoint_ClearOUT();\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return ENDPOINT_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ Endpoint_Discard_8();\r
+\r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+ \r
+ return ENDPOINT_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t Endpoint_Null_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t ErrorCode;\r
+ uint16_t BytesInTransfer = 0;\r
+ \r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ \r
+ if (BytesProcessed != NULL)\r
+ Length -= *BytesProcessed;\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ {\r
+ Endpoint_ClearIN();\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return ENDPOINT_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ Endpoint_Write_8(0);\r
+\r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+ \r
+ return ENDPOINT_RWSTREAM_NoError;\r
+}\r
+\r
+/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,\r
+ * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)\r
+#include "Template/Template_Endpoint_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)\r
+#include "Template/Template_Endpoint_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE\r
+#define TEMPLATE_BUFFER_TYPE void*\r
+#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()\r
+#include "Template/Template_Endpoint_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE\r
+#define TEMPLATE_BUFFER_TYPE void*\r
+#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()\r
+#include "Template/Template_Endpoint_RW.c"\r
+\r
+#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE\r
+ #define TEMPLATE_BUFFER_TYPE const void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_RW.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE\r
+ #define TEMPLATE_BUFFER_TYPE const void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_RW.c"\r
+#endif\r
+\r
+#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE\r
+ #define TEMPLATE_BUFFER_TYPE const void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_RW.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE\r
+ #define TEMPLATE_BUFFER_TYPE const void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_RW.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE\r
+ #define TEMPLATE_BUFFER_TYPE void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())\r
+ #include "Template/Template_Endpoint_RW.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE\r
+ #define TEMPLATE_BUFFER_TYPE void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())\r
+ #include "Template/Template_Endpoint_RW.c"\r
+#endif\r
+\r
+#endif\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)\r
+#include "Template/Template_Endpoint_Control_W.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)\r
+#include "Template/Template_Endpoint_Control_W.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()\r
+#include "Template/Template_Endpoint_Control_R.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()\r
+#include "Template/Template_Endpoint_Control_R.c"\r
+\r
+#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_LE\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_Control_W.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_BE\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_Control_W.c"\r
+#endif\r
+\r
+#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_Control_W.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_Control_W.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())\r
+ #include "Template/Template_Endpoint_Control_R.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())\r
+ #include "Template/Template_Endpoint_Control_R.c"\r
+#endif\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Endpoint data stream transmission and reception management for the AVR8 microcontrollers.\r
+ * \copydetails Group_EndpointStreamRW_AVR8\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_EndpointStreamRW\r
+ * \defgroup Group_EndpointStreamRW_AVR8 Read/Write of Multi-Byte Streams (AVR8)\r
+ * \brief Endpoint data stream transmission and reception management for the Atmel AVR8 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of data streams from\r
+ * and to endpoints.\r
+ *\r
+ * @{\r
+ */ \r
+\r
+#ifndef __ENDPOINT_STREAM_AVR8_H__\r
+#define __ENDPOINT_STREAM_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBMode.h" \r
+ #include "../USBTask.h"\r
+ \r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Function Prototypes: */\r
+ /** \name Stream functions for null data */\r
+ //@{\r
+\r
+ /** Reads and discards the given number of bytes from the currently selected endpoint's bank,\r
+ * discarding fully read packets from the host as needed. The last packet is not automatically\r
+ * discarded once the remaining bytes has been read; the user is responsible for manually\r
+ * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the endpoint bank becomes empty while there is still data to process (and after the current\r
+ * packet has been acknowledged) the BytesProcessed location will be updated with the total number\r
+ * of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[in] Length Number of bytes to discard via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Discard_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed);\r
+\r
+ /** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending\r
+ * full packets to the host as needed. The last packet is not automatically sent once the \r
+ * remaining bytes have been written; the user is responsible for manually sending the last\r
+ * packet to the host via the \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the endpoint bank becomes full while there is still data to process (and after the current\r
+ * packet transmission has been initiated) the BytesProcessed location will be updated with the\r
+ * total number of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[in] Length Number of zero bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Null_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed);\r
+\r
+ //@}\r
+\r
+ /** \name Stream functions for RAM source/destination data */\r
+ //@{\r
+ \r
+ /** Writes the given number of bytes to the endpoint from the given buffer in little endian,\r
+ * sending full packets to the host as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the endpoint bank becomes full while there is still data to process (and after the current\r
+ * packet transmission has been initiated) the BytesProcessed location will be updated with the\r
+ * total number of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),\r
+ * NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ *\r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),\r
+ * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ *\r
+ * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Stream_LE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the endpoint from the given buffer in big endian,\r
+ * sending full packets to the host as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Stream_BE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+ \r
+ /** Reads the given number of bytes from the endpoint from the given buffer in little endian,\r
+ * discarding fully read packets from the host as needed. The last packet is not automatically\r
+ * discarded once the remaining bytes has been read; the user is responsible for manually\r
+ * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the endpoint bank becomes empty while there is still data to process (and after the current\r
+ * packet has been acknowledged) the BytesProcessed location will be updated with the total number\r
+ * of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),\r
+ * NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),\r
+ * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Stream_LE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the endpoint from the given buffer in big endian,\r
+ * discarding fully read packets from the host as needed. The last packet is not automatically\r
+ * discarded once the remaining bytes has been read; the user is responsible for manually\r
+ * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Stream_BE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,\r
+ * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared\r
+ * in both failure and success states; the user is responsible for manually clearing the status OUT packet\r
+ * to finalize the transfer's status stage via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,\r
+ * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared\r
+ * in both failure and success states; the user is responsible for manually clearing the status OUT packet\r
+ * to finalize the transfer's status stage via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,\r
+ * discarding fully read packets from the host as needed. The device IN acknowledgement is not\r
+ * automatically sent after success or failure states; the user is responsible for manually sending the\r
+ * status IN packet to finalize the transfer's status stage via the \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,\r
+ * discarding fully read packets from the host as needed. The device IN acknowledgement is not\r
+ * automatically sent after success or failure states; the user is responsible for manually sending the\r
+ * status IN packet to finalize the transfer's status stage via the \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+ //@}\r
+\r
+ /** \name Stream functions for EEPROM source/destination data */\r
+ //@{\r
+\r
+ /** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE().\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_EStream_LE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE().\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_EStream_BE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer destination version of \ref Endpoint_Read_Stream_LE().\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_EStream_LE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer destination version of \ref Endpoint_Read_Stream_BE().\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_EStream_BE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer source version of Endpoint_Write_Control_Stream_LE.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ * \n\n\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_EStream_LE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE().\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ * \n\n\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_EStream_BE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE().\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ * \n\n\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Control_EStream_LE(void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE().\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ * \n\n\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Control_EStream_BE(void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+ //@}\r
+\r
+ /** \name Stream functions for PROGMEM source/destination data */\r
+ //@{\r
+\r
+ /** FLASH buffer source version of \ref Endpoint_Write_Stream_LE().\r
+ *\r
+ * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_PStream_LE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** FLASH buffer source version of \ref Endpoint_Write_Stream_BE().\r
+ *\r
+ * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_PStream_BE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE().\r
+ *\r
+ * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ * \n\n\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_PStream_LE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE().\r
+ *\r
+ * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ * \n\n\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_PStream_BE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+ //@}\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_AVR8)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#include "../Endpoint.h"\r
+\r
+#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)\r
+uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;\r
+#endif\r
+\r
+bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table,\r
+ const uint8_t Entries)\r
+{\r
+ for (uint8_t i = 0; i < Entries; i++)\r
+ {\r
+ if (!(Table[i].Address))\r
+ continue;\r
+ \r
+ if (!(Endpoint_ConfigureEndpoint(Table[i].Address, Table[i].Type, Table[i].Size, Table[i].Banks)))\r
+ return false;\r
+ }\r
+ \r
+ return true;\r
+}\r
+\r
+bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,\r
+ const uint8_t UECFG0XData,\r
+ const uint8_t UECFG1XData)\r
+{\r
+#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG)\r
+ Endpoint_SelectEndpoint(Number);\r
+ Endpoint_EnableEndpoint();\r
+\r
+ UECFG1X = 0;\r
+ UECFG0X = UECFG0XData;\r
+ UECFG1X = UECFG1XData;\r
+\r
+ return Endpoint_IsConfigured();\r
+#else\r
+ for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)\r
+ {\r
+ uint8_t UECFG0XTemp;\r
+ uint8_t UECFG1XTemp;\r
+ uint8_t UEIENXTemp;\r
+\r
+ Endpoint_SelectEndpoint(EPNum);\r
+\r
+ if (EPNum == Number)\r
+ {\r
+ UECFG0XTemp = UECFG0XData;\r
+ UECFG1XTemp = UECFG1XData;\r
+ UEIENXTemp = 0;\r
+ }\r
+ else\r
+ {\r
+ UECFG0XTemp = UECFG0X;\r
+ UECFG1XTemp = UECFG1X;\r
+ UEIENXTemp = UEIENX;\r
+ }\r
+\r
+ if (!(UECFG1XTemp & (1 << ALLOC)))\r
+ continue;\r
+\r
+ Endpoint_DisableEndpoint();\r
+ UECFG1X &= ~(1 << ALLOC);\r
+\r
+ Endpoint_EnableEndpoint();\r
+ UECFG0X = UECFG0XTemp;\r
+ UECFG1X = UECFG1XTemp;\r
+ UEIENX = UEIENXTemp;\r
+\r
+ if (!(Endpoint_IsConfigured()))\r
+ return false;\r
+ }\r
+\r
+ Endpoint_SelectEndpoint(Number);\r
+ return true;\r
+#endif\r
+}\r
+\r
+void Endpoint_ClearEndpoints(void)\r
+{\r
+ UEINT = 0;\r
+\r
+ for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)\r
+ {\r
+ Endpoint_SelectEndpoint(EPNum);\r
+ UEIENX = 0;\r
+ UEINTX = 0;\r
+ UECFG1X = 0;\r
+ Endpoint_DisableEndpoint();\r
+ }\r
+}\r
+\r
+void Endpoint_ClearStatusStage(void)\r
+{\r
+ if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST)\r
+ {\r
+ while (!(Endpoint_IsOUTReceived()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return;\r
+ }\r
+\r
+ Endpoint_ClearOUT();\r
+ }\r
+ else\r
+ {\r
+ while (!(Endpoint_IsINReady()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return;\r
+ }\r
+\r
+ Endpoint_ClearIN();\r
+ }\r
+}\r
+\r
+#if !defined(CONTROL_ONLY_DEVICE)\r
+uint8_t Endpoint_WaitUntilReady(void)\r
+{\r
+ #if (USB_STREAM_TIMEOUT_MS < 0xFF)\r
+ uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #else\r
+ uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #endif\r
+\r
+ uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber();\r
+\r
+ for (;;)\r
+ {\r
+ if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN)\r
+ {\r
+ if (Endpoint_IsINReady())\r
+ return ENDPOINT_READYWAIT_NoError;\r
+ }\r
+ else\r
+ {\r
+ if (Endpoint_IsOUTReceived())\r
+ return ENDPOINT_READYWAIT_NoError;\r
+ }\r
+\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_READYWAIT_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_READYWAIT_BusSuspended;\r
+ else if (Endpoint_IsStalled())\r
+ return ENDPOINT_READYWAIT_EndpointStalled;\r
+\r
+ uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber();\r
+\r
+ if (CurrentFrameNumber != PreviousFrameNumber)\r
+ {\r
+ PreviousFrameNumber = CurrentFrameNumber;\r
+\r
+ if (!(TimeoutMSRem--))\r
+ return ENDPOINT_READYWAIT_Timeout;\r
+ }\r
+ }\r
+}\r
+#endif\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Endpoint definitions for the AVR8 microcontrollers.\r
+ * \copydetails Group_EndpointManagement_AVR8\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_EndpointRW\r
+ * \defgroup Group_EndpointRW_AVR8 Endpoint Data Reading and Writing (AVR8)\r
+ * \brief Endpoint data read/write definitions for the Atmel AVR8 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointPrimitiveRW\r
+ * \defgroup Group_EndpointPrimitiveRW_AVR8 Read/Write of Primitive Data Types (AVR8)\r
+ * \brief Endpoint primitive read/write definitions for the Atmel AVR8 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of primitive data types\r
+ * from and to endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointPacketManagement\r
+ * \defgroup Group_EndpointPacketManagement_AVR8 Endpoint Packet Management (AVR8)\r
+ * \brief Endpoint packet management definitions for the Atmel AVR8 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to packet management of endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointManagement\r
+ * \defgroup Group_EndpointManagement_AVR8 Endpoint Management (AVR8)\r
+ * \brief Endpoint management definitions for the Atmel AVR8 architecture.\r
+ *\r
+ * Functions, macros and enums related to endpoint management when in USB Device mode. This\r
+ * module contains the endpoint management macros, as well as endpoint interrupt and data\r
+ * send/receive functions for various data types.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __ENDPOINT_AVR8_H__\r
+#define __ENDPOINT_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBTask.h"\r
+ #include "../USBInterrupt.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Inline Functions: */\r
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST\r
+ ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)\r
+ {\r
+ uint8_t MaskVal = 0;\r
+ uint16_t CheckBytes = 8;\r
+\r
+ while (CheckBytes < Bytes)\r
+ {\r
+ MaskVal++;\r
+ CheckBytes <<= 1;\r
+ }\r
+\r
+ return (MaskVal << EPSIZE0);\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ void Endpoint_ClearEndpoints(void);\r
+ bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,\r
+ const uint8_t UECFG0XData,\r
+ const uint8_t UECFG1XData);\r
+\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))\r
+ /** Default size of the default control endpoint's bank, until altered by the control endpoint bank size\r
+ * value in the device descriptor. Not available if the \c FIXED_CONTROL_ENDPOINT_SIZE token is defined.\r
+ */\r
+ #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8\r
+ #endif\r
+\r
+ #if !defined(CONTROL_ONLY_DEVICE) || defined(__DOXYGEN__)\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 7\r
+ #else\r
+ /** Total number of endpoints (including the default control endpoint at address 0) which may\r
+ * be used in the device. Different USB AVR models support different amounts of endpoints,\r
+ * this value reflects the maximum number of endpoints for the currently selected AVR model.\r
+ */\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 5\r
+ #endif\r
+ #else\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 1\r
+ #endif\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error return codes of the \ref Endpoint_WaitUntilReady() function.\r
+ *\r
+ * \ingroup Group_EndpointRW_AVR8\r
+ */\r
+ enum Endpoint_WaitUntilReady_ErrorCodes_t\r
+ {\r
+ ENDPOINT_READYWAIT_NoError = 0, /**< Endpoint is ready for next packet, no error. */\r
+ ENDPOINT_READYWAIT_EndpointStalled = 1, /**< The endpoint was stalled during the stream\r
+ * transfer by the host or device.\r
+ */\r
+ ENDPOINT_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while\r
+ * waiting for the endpoint to become ready.\r
+ */\r
+ ENDPOINT_READYWAIT_BusSuspended = 3, /**< The USB bus has been suspended by the host and\r
+ * no USB endpoint traffic can occur until the bus\r
+ * has resumed.\r
+ */\r
+ ENDPOINT_READYWAIT_Timeout = 4, /**< The host failed to accept or send the next packet\r
+ * within the software timeout period set by the\r
+ * \ref USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Configures the specified endpoint address with the given endpoint type, bank size and number of hardware\r
+ * banks. Once configured, the endpoint may be read from or written to, depending on its direction.\r
+ *\r
+ * \param[in] Address Endpoint address to configure.\r
+ *\r
+ * \param[in] Type Type of endpoint to configure, a \c EP_TYPE_* mask. Not all endpoint types\r
+ * are available on Low Speed USB devices - refer to the USB 2.0 specification.\r
+ *\r
+ * \param[in] Size Size of the endpoint's bank, where packets are stored before they are transmitted\r
+ * to the USB host, or after they have been received from the USB host (depending on\r
+ * the endpoint's data direction). The bank size must indicate the maximum packet size\r
+ * that the endpoint can handle.\r
+ *\r
+ * \param[in] Banks Number of banks to use for the endpoint being configured.\r
+ *\r
+ * \attention When the \c ORDERED_EP_CONFIG compile time option is used, Endpoints <b>must</b> be configured in\r
+ * ascending order, or bank corruption will occur.\r
+ *\r
+ * \note Different endpoints may have different maximum packet sizes based on the endpoint's index - please\r
+ * refer to the chosen microcontroller model's datasheet to determine the maximum bank size for each endpoint.\r
+ * \n\n\r
+ *\r
+ * \note The default control endpoint should not be manually configured by the user application, as\r
+ * it is automatically configured by the library internally.\r
+ * \n\n\r
+ *\r
+ * \note This routine will automatically select the specified endpoint upon success. Upon failure, the endpoint\r
+ * which failed to reconfigure correctly will be selected.\r
+ *\r
+ * \return Boolean \c true if the configuration succeeded, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address,\r
+ const uint8_t Type,\r
+ const uint16_t Size,\r
+ const uint8_t Banks) ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address,\r
+ const uint8_t Type,\r
+ const uint16_t Size,\r
+ const uint8_t Banks)\r
+ {\r
+ uint8_t Number = (Address & ENDPOINT_EPNUM_MASK);\r
+ \r
+ if (Number >= ENDPOINT_TOTAL_ENDPOINTS)\r
+ return false;\r
+ \r
+ return Endpoint_ConfigureEndpoint_Prv(Number,\r
+ ((Type << EPTYPE0) | ((Address & ENDPOINT_DIR_IN) ? (1 << EPDIR) : 0)),\r
+ ((1 << ALLOC) | ((Banks > 1) ? (1 << EPBK0) : 0) | Endpoint_BytesToEPSizeMask(Size)));\r
+ }\r
+\r
+ /** Indicates the number of bytes currently stored in the current endpoint's selected bank.\r
+ *\r
+ * \ingroup Group_EndpointRW_AVR8\r
+ *\r
+ * \return Total number of bytes in the currently selected Endpoint's FIFO buffer.\r
+ */\r
+ static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Endpoint_BytesInEndpoint(void)\r
+ {\r
+ #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)) && !defined(__AVR_ATmega32U6__)\r
+ return UEBCX;\r
+ #elif defined(USB_SERIES_4_AVR) || defined(__AVR_ATmega32U6__)\r
+ return (((uint16_t)UEBCHX << 8) | UEBCLX);\r
+ #elif defined(USB_SERIES_2_AVR)\r
+ return UEBCLX;\r
+ #endif\r
+ }\r
+\r
+ /** Determines the currently selected endpoint's direction.\r
+ *\r
+ * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask.\r
+ */\r
+ static inline uint8_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_GetEndpointDirection(void)\r
+ {\r
+ return (UECFG0X & (1 << EPDIR)) ? ENDPOINT_DIR_IN : ENDPOINT_DIR_OUT;\r
+ }\r
+\r
+ /** Get the endpoint address of the currently selected endpoint. This is typically used to save\r
+ * the currently selected endpoint so that it can be restored after another endpoint has been\r
+ * manipulated.\r
+ *\r
+ * \return Index of the currently selected endpoint.\r
+ */\r
+ static inline uint8_t Endpoint_GetCurrentEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_GetCurrentEndpoint(void)\r
+ {\r
+ #if !defined(CONTROL_ONLY_DEVICE)\r
+ return ((UENUM & ENDPOINT_EPNUM_MASK) | Endpoint_GetEndpointDirection());\r
+ #else\r
+ return ENDPOINT_CONTROLEP;\r
+ #endif\r
+ }\r
+\r
+ /** Selects the given endpoint address.\r
+ *\r
+ * Any endpoint operations which do not require the endpoint address to be indicated will operate on\r
+ * the currently selected endpoint.\r
+ *\r
+ * \param[in] Address Endpoint address to select.\r
+ */\r
+ static inline void Endpoint_SelectEndpoint(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_SelectEndpoint(const uint8_t Address)\r
+ {\r
+ #if !defined(CONTROL_ONLY_DEVICE)\r
+ UENUM = (Address & ENDPOINT_EPNUM_MASK);\r
+ #endif\r
+ }\r
+\r
+ /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's\r
+ * data In and Out pointers to the bank's contents.\r
+ *\r
+ * \param[in] Address Endpoint address whose FIFO buffers are to be reset.\r
+ */\r
+ static inline void Endpoint_ResetEndpoint(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ResetEndpoint(const uint8_t Address)\r
+ {\r
+ UERST = (1 << (Address & ENDPOINT_EPNUM_MASK));\r
+ UERST = 0;\r
+ }\r
+\r
+ /** Enables the currently selected endpoint so that data can be sent and received through it to\r
+ * and from a host.\r
+ *\r
+ * \note Endpoints must first be configured properly via \ref Endpoint_ConfigureEndpoint().\r
+ */\r
+ static inline void Endpoint_EnableEndpoint(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_EnableEndpoint(void)\r
+ {\r
+ UECONX |= (1 << EPEN);\r
+ }\r
+\r
+ /** Disables the currently selected endpoint so that data cannot be sent and received through it\r
+ * to and from a host.\r
+ */\r
+ static inline void Endpoint_DisableEndpoint(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_DisableEndpoint(void)\r
+ {\r
+ UECONX &= ~(1 << EPEN);\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint is enabled, but not necessarily configured.\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsEnabled(void)\r
+ {\r
+ return ((UECONX & (1 << EPEN)) ? true : false);\r
+ }\r
+\r
+ /** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for\r
+ * transmission via the \ref Endpoint_ClearIN() command, or are awaiting acknowledgement via the\r
+ * \ref Endpoint_ClearOUT() command.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \return Total number of busy banks in the selected endpoint.\r
+ */\r
+ static inline uint8_t Endpoint_GetBusyBanks(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Endpoint_GetBusyBanks(void)\r
+ {\r
+ return (UESTA0X & (0x03 << NBUSYBK0));\r
+ }\r
+\r
+ /** Aborts all pending IN transactions on the currently selected endpoint, once the bank\r
+ * has been queued for transmission to the host via \ref Endpoint_ClearIN(). This function\r
+ * will terminate all queued transactions, resetting the endpoint banks ready for a new\r
+ * packet.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ */\r
+ static inline void Endpoint_AbortPendingIN(void)\r
+ {\r
+ while (Endpoint_GetBusyBanks() != 0)\r
+ {\r
+ UEINTX |= (1 << RXOUTI);\r
+ while (UEINTX & (1 << RXOUTI));\r
+ }\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint may be read from (if data is waiting in the endpoint\r
+ * bank and the endpoint is an OUT direction, or if the bank is not yet full if the endpoint is an IN\r
+ * direction). This function will return false if an error has occurred in the endpoint, if the endpoint\r
+ * is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN\r
+ * direction and the endpoint bank is full.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint may be read from or written to, depending\r
+ * on its direction.\r
+ */\r
+ static inline bool Endpoint_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsReadWriteAllowed(void)\r
+ {\r
+ return ((UEINTX & (1 << RWAL)) ? true : false);\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint is configured.\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint has been configured, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsConfigured(void)\r
+ {\r
+ return ((UESTA0X & (1 << CFGOK)) ? true : false);\r
+ }\r
+\r
+ /** Returns a mask indicating which INTERRUPT type endpoints have interrupted - i.e. their\r
+ * interrupt duration has elapsed. Which endpoints have interrupted can be determined by\r
+ * masking the return value against <tt>(1 << <i>{Endpoint Number}</i>)</tt>.\r
+ *\r
+ * \return Mask whose bits indicate which endpoints have interrupted.\r
+ */\r
+ static inline uint8_t Endpoint_GetEndpointInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_GetEndpointInterrupts(void)\r
+ {\r
+ return UEINT;\r
+ }\r
+\r
+ /** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type\r
+ * endpoints).\r
+ *\r
+ * \param[in] Address Address of the endpoint whose interrupt flag should be tested.\r
+ *\r
+ * \return Boolean \c true if the specified endpoint has interrupted, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_HasEndpointInterrupted(const uint8_t Address) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_HasEndpointInterrupted(const uint8_t Address)\r
+ {\r
+ return ((Endpoint_GetEndpointInterrupts() & (1 << (Address & ENDPOINT_EPNUM_MASK))) ? true : false);\r
+ }\r
+\r
+ /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsINReady(void)\r
+ {\r
+ return ((UEINTX & (1 << TXINI)) ? true : false);\r
+ }\r
+\r
+ /** Determines if the selected OUT endpoint has received new packet from the host.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsOUTReceived(void)\r
+ {\r
+ return ((UEINTX & (1 << RXOUTI)) ? true : false);\r
+ }\r
+\r
+ /** Determines if the current CONTROL type endpoint has received a SETUP packet.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsSETUPReceived(void)\r
+ {\r
+ return ((UEINTX & (1 << RXSTPI)) ? true : false);\r
+ }\r
+\r
+ /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the\r
+ * endpoint for the next packet.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \note This is not applicable for non CONTROL type endpoints.\r
+ */\r
+ static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearSETUP(void)\r
+ {\r
+ UEINTX &= ~(1 << RXSTPI);\r
+ }\r
+\r
+ /** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the\r
+ * next packet and switching to the alternative endpoint bank if double banked.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ */\r
+ static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearIN(void)\r
+ {\r
+ #if !defined(CONTROL_ONLY_DEVICE)\r
+ UEINTX &= ~((1 << TXINI) | (1 << FIFOCON));\r
+ #else\r
+ UEINTX &= ~(1 << TXINI);\r
+ #endif\r
+ }\r
+\r
+ /** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint\r
+ * for the next packet and switching to the alternative endpoint bank if double banked.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ */\r
+ static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearOUT(void)\r
+ {\r
+ #if !defined(CONTROL_ONLY_DEVICE)\r
+ UEINTX &= ~((1 << RXOUTI) | (1 << FIFOCON));\r
+ #else\r
+ UEINTX &= ~(1 << RXOUTI);\r
+ #endif\r
+ }\r
+\r
+ /** Stalls the current endpoint, indicating to the host that a logical problem occurred with the\r
+ * indicated endpoint and that the current transfer sequence should be aborted. This provides a\r
+ * way for devices to indicate invalid commands to the host so that the current transfer can be\r
+ * aborted and the host can begin its own recovery sequence.\r
+ *\r
+ * The currently selected endpoint remains stalled until either the \ref Endpoint_ClearStall() macro\r
+ * is called, or the host issues a CLEAR FEATURE request to the device for the currently selected\r
+ * endpoint.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ */\r
+ static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_StallTransaction(void)\r
+ {\r
+ UECONX |= (1 << STALLRQ);\r
+ }\r
+\r
+ /** Clears the STALL condition on the currently selected endpoint.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ */\r
+ static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearStall(void)\r
+ {\r
+ UECONX |= (1 << STALLRQC);\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint is stalled, false otherwise.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsStalled(void)\r
+ {\r
+ return ((UECONX & (1 << STALLRQ)) ? true : false);\r
+ }\r
+\r
+ /** Resets the data toggle of the currently selected endpoint. */\r
+ static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ResetDataToggle(void)\r
+ {\r
+ UECONX |= (1 << RSTDT);\r
+ }\r
+\r
+ /** Sets the direction of the currently selected endpoint.\r
+ *\r
+ * \param[in] DirectionMask New endpoint direction, as a \c ENDPOINT_DIR_* mask.\r
+ */\r
+ static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_SetEndpointDirection(const uint8_t DirectionMask)\r
+ {\r
+ UECFG0X = ((UECFG0X & ~(1 << EPDIR)) | (DirectionMask ? (1 << EPDIR) : 0));\r
+ }\r
+\r
+ /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \return Next byte in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint8_t Endpoint_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_Read_8(void)\r
+ {\r
+ return UEDATX;\r
+ }\r
+\r
+ /** Writes one byte to the currently selected endpoint's bank, for IN direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Data Data to write into the the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_8(const uint8_t Data)\r
+ {\r
+ UEDATX = Data;\r
+ }\r
+\r
+ /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ */\r
+ static inline void Endpoint_Discard_8(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Discard_8(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = UEDATX;\r
+\r
+ (void)Dummy;\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \return Next two bytes in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint16_t Endpoint_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Endpoint_Read_16_LE(void)\r
+ {\r
+ union\r
+ {\r
+ uint16_t Value;\r
+ uint8_t Bytes[2];\r
+ } Data;\r
+\r
+ Data.Bytes[0] = UEDATX;\r
+ Data.Bytes[1] = UEDATX;\r
+\r
+ return Data.Value;\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \return Next two bytes in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint16_t Endpoint_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Endpoint_Read_16_BE(void)\r
+ {\r
+ union\r
+ {\r
+ uint16_t Value;\r
+ uint8_t Bytes[2];\r
+ } Data;\r
+\r
+ Data.Bytes[1] = UEDATX;\r
+ Data.Bytes[0] = UEDATX;\r
+\r
+ return Data.Value;\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_16_LE(const uint16_t Data)\r
+ {\r
+ UEDATX = (Data & 0xFF);\r
+ UEDATX = (Data >> 8);\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_16_BE(const uint16_t Data)\r
+ {\r
+ UEDATX = (Data >> 8);\r
+ UEDATX = (Data & 0xFF);\r
+ }\r
+\r
+ /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ */\r
+ static inline void Endpoint_Discard_16(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Discard_16(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = UEDATX;\r
+ Dummy = UEDATX;\r
+\r
+ (void)Dummy;\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \return Next four bytes in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint32_t Endpoint_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Endpoint_Read_32_LE(void)\r
+ {\r
+ union\r
+ {\r
+ uint32_t Value;\r
+ uint8_t Bytes[4];\r
+ } Data;\r
+\r
+ Data.Bytes[0] = UEDATX;\r
+ Data.Bytes[1] = UEDATX;\r
+ Data.Bytes[2] = UEDATX;\r
+ Data.Bytes[3] = UEDATX;\r
+\r
+ return Data.Value;\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \return Next four bytes in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint32_t Endpoint_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Endpoint_Read_32_BE(void)\r
+ {\r
+ union\r
+ {\r
+ uint32_t Value;\r
+ uint8_t Bytes[4];\r
+ } Data;\r
+\r
+ Data.Bytes[3] = UEDATX;\r
+ Data.Bytes[2] = UEDATX;\r
+ Data.Bytes[1] = UEDATX;\r
+ Data.Bytes[0] = UEDATX;\r
+\r
+ return Data.Value;\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_32_LE(const uint32_t Data)\r
+ {\r
+ UEDATX = (Data & 0xFF);\r
+ UEDATX = (Data >> 8);\r
+ UEDATX = (Data >> 16);\r
+ UEDATX = (Data >> 24);\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_32_BE(const uint32_t Data)\r
+ {\r
+ UEDATX = (Data >> 24);\r
+ UEDATX = (Data >> 16);\r
+ UEDATX = (Data >> 8);\r
+ UEDATX = (Data & 0xFF);\r
+ }\r
+\r
+ /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_AVR8\r
+ */\r
+ static inline void Endpoint_Discard_32(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Discard_32(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = UEDATX;\r
+ Dummy = UEDATX;\r
+ Dummy = UEDATX;\r
+ Dummy = UEDATX;\r
+\r
+ (void)Dummy;\r
+ }\r
+\r
+ /* External Variables: */\r
+ /** Global indicating the maximum packet size of the default control endpoint located at address\r
+ * 0 in the device. This value is set to the value indicated in the device descriptor in the user\r
+ * project once the USB interface is initialized into device mode.\r
+ *\r
+ * If space is an issue, it is possible to fix this to a static value by defining the control\r
+ * endpoint size in the \c FIXED_CONTROL_ENDPOINT_SIZE token passed to the compiler in the makefile\r
+ * via the -D switch. When a fixed control endpoint size is used, the size is no longer dynamically\r
+ * read from the descriptors at runtime and instead fixed to the given value. When used, it is\r
+ * important that the descriptor control endpoint size value matches the size given as the\r
+ * \c FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the \c FIXED_CONTROL_ENDPOINT_SIZE token\r
+ * be used in the device descriptors to ensure this.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))\r
+ extern uint8_t USB_Device_ControlEndpointSize;\r
+ #else\r
+ #define USB_Device_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures a table of endpoint descriptions, in sequence. This function can be used to configure multiple\r
+ * endpoints at the same time.\r
+ *\r
+ * \note Endpoints with a zero address will be ignored, thus this function cannot be used to configure the\r
+ * control endpoint.\r
+ *\r
+ * \param[in] Table Pointer to a table of endpoint descriptions.\r
+ * \param[in] Entries Number of entries in the endpoint table to configure.\r
+ *\r
+ * \return Boolean \c true if all endpoints configured successfully, \c false otherwise.\r
+ */\r
+ bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table,\r
+ const uint8_t Entries);\r
+\r
+ /** Completes the status stage of a control transfer on a CONTROL type endpoint automatically,\r
+ * with respect to the data direction. This is a convenience function which can be used to\r
+ * simplify user control request handling.\r
+ *\r
+ * \note This routine should not be called on non CONTROL type endpoints.\r
+ */\r
+ void Endpoint_ClearStatusStage(void);\r
+\r
+ /** Spin-loops until the currently selected non-control endpoint is ready for the next packet of data\r
+ * to be read or written to it.\r
+ *\r
+ * \note This routine should not be called on CONTROL type endpoints.\r
+ *\r
+ * \ingroup Group_EndpointRW_AVR8\r
+ *\r
+ * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_WaitUntilReady(void);\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_AVR8)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_HOST_C\r
+#include "../Host.h"\r
+\r
+void USB_Host_ProcessNextHostState(void)\r
+{\r
+ uint8_t ErrorCode = HOST_ENUMERROR_NoError;\r
+ uint8_t SubErrorCode = HOST_ENUMERROR_NoError;\r
+\r
+ static uint16_t WaitMSRemaining;\r
+ static uint8_t PostWaitState;\r
+\r
+ switch (USB_HostState)\r
+ {\r
+ case HOST_STATE_WaitForDevice:\r
+ if (WaitMSRemaining)\r
+ {\r
+ if ((SubErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)\r
+ {\r
+ USB_HostState = PostWaitState;\r
+ ErrorCode = HOST_ENUMERROR_WaitStage;\r
+ break;\r
+ }\r
+\r
+ if (!(--WaitMSRemaining))\r
+ USB_HostState = PostWaitState;\r
+ }\r
+\r
+ break;\r
+ case HOST_STATE_Powered:\r
+ WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS;\r
+\r
+ USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle;\r
+ break;\r
+ case HOST_STATE_Powered_WaitForDeviceSettle:\r
+ if (WaitMSRemaining--)\r
+ {\r
+ Delay_MS(1);\r
+ break;\r
+ }\r
+ else\r
+ {\r
+ USB_Host_VBUS_Manual_Off();\r
+\r
+ USB_OTGPAD_On();\r
+ USB_Host_VBUS_Auto_Enable();\r
+ USB_Host_VBUS_Auto_On();\r
+ \r
+ #if defined(NO_AUTO_VBUS_MANAGEMENT)\r
+ USB_Host_VBUS_Manual_Enable();\r
+ USB_Host_VBUS_Manual_On();\r
+ #endif\r
+\r
+ USB_HostState = HOST_STATE_Powered_WaitForConnect;\r
+ }\r
+\r
+ break;\r
+ case HOST_STATE_Powered_WaitForConnect:\r
+ if (USB_INT_HasOccurred(USB_INT_DCONNI))\r
+ {\r
+ USB_INT_Clear(USB_INT_DCONNI);\r
+ USB_INT_Clear(USB_INT_DDISCI);\r
+\r
+ USB_INT_Clear(USB_INT_VBERRI);\r
+ USB_INT_Enable(USB_INT_VBERRI);\r
+\r
+ USB_Host_ResumeBus();\r
+ Pipe_ClearPipes();\r
+\r
+ HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset);\r
+ }\r
+\r
+ break;\r
+ case HOST_STATE_Powered_DoReset:\r
+ USB_Host_ResetDevice();\r
+\r
+ HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe);\r
+ break;\r
+ case HOST_STATE_Powered_ConfigPipe:\r
+ if (!(Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, ENDPOINT_CONTROLEP, PIPE_CONTROLPIPE_DEFAULT_SIZE, 1)))\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_PipeConfigError;\r
+ SubErrorCode = 0;\r
+ break;\r
+ }\r
+\r
+ USB_HostState = HOST_STATE_Default;\r
+ break;\r
+ case HOST_STATE_Default:\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ .bRequest = REQ_GetDescriptor,\r
+ .wValue = (DTYPE_Device << 8),\r
+ .wIndex = 0,\r
+ .wLength = 8,\r
+ };\r
+\r
+ uint8_t DataBuffer[8];\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+ if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_ControlError;\r
+ break;\r
+ }\r
+\r
+ USB_Host_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)];\r
+\r
+ USB_Host_ResetDevice();\r
+\r
+ HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Default_PostReset);\r
+ break;\r
+ case HOST_STATE_Default_PostReset:\r
+ if (!(Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, ENDPOINT_CONTROLEP, USB_Host_ControlPipeSize, 1)))\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_PipeConfigError;\r
+ SubErrorCode = 0;\r
+ break;\r
+ }\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ .bRequest = REQ_SetAddress,\r
+ .wValue = USB_HOST_DEVICEADDRESS,\r
+ .wIndex = 0,\r
+ .wLength = 0,\r
+ };\r
+\r
+ if ((SubErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_ControlError;\r
+ break;\r
+ }\r
+\r
+ HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Default_PostAddressSet);\r
+ break;\r
+ case HOST_STATE_Default_PostAddressSet:\r
+ USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS);\r
+\r
+ USB_HostState = HOST_STATE_Addressed;\r
+\r
+ EVENT_USB_Host_DeviceEnumerationComplete();\r
+ break;\r
+ }\r
+\r
+ if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))\r
+ {\r
+ EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode);\r
+\r
+ USB_Host_VBUS_Auto_Off();\r
+\r
+ EVENT_USB_Host_DeviceUnattached();\r
+\r
+ USB_ResetInterface();\r
+ }\r
+}\r
+\r
+uint8_t USB_Host_WaitMS(uint8_t MS)\r
+{\r
+ bool BusSuspended = USB_Host_IsBusSuspended();\r
+ uint8_t ErrorCode = HOST_WAITERROR_Successful;\r
+ bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);\r
+\r
+ USB_INT_Disable(USB_INT_HSOFI);\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+\r
+ USB_Host_ResumeBus();\r
+\r
+ while (MS)\r
+ {\r
+ if (USB_INT_HasOccurred(USB_INT_HSOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+ MS--;\r
+ }\r
+\r
+ if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host))\r
+ {\r
+ ErrorCode = HOST_WAITERROR_DeviceDisconnect;\r
+\r
+ break;\r
+ }\r
+\r
+ if (Pipe_IsError())\r
+ {\r
+ Pipe_ClearError();\r
+ ErrorCode = HOST_WAITERROR_PipeError;\r
+\r
+ break;\r
+ }\r
+\r
+ if (Pipe_IsStalled())\r
+ {\r
+ Pipe_ClearStall();\r
+ ErrorCode = HOST_WAITERROR_SetupStalled;\r
+\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (BusSuspended)\r
+ USB_Host_SuspendBus();\r
+\r
+ if (HSOFIEnabled)\r
+ USB_INT_Enable(USB_INT_HSOFI);\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+static void USB_Host_ResetDevice(void)\r
+{\r
+ bool BusSuspended = USB_Host_IsBusSuspended();\r
+\r
+ USB_INT_Disable(USB_INT_DDISCI);\r
+\r
+ USB_Host_ResetBus();\r
+ while (!(USB_Host_IsBusResetComplete()));\r
+ USB_Host_ResumeBus();\r
+\r
+ USB_Host_ConfigurationNumber = 0;\r
+\r
+ bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);\r
+\r
+ USB_INT_Disable(USB_INT_HSOFI);\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+\r
+ for (uint8_t MSRem = 10; MSRem != 0; MSRem--)\r
+ {\r
+ /* Workaround for powerless-pull-up devices. After a USB bus reset,\r
+ all disconnection interrupts are suppressed while a USB frame is\r
+ looked for - if it is found within 10ms, the device is still\r
+ present. */\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_HSOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+ USB_INT_Clear(USB_INT_DDISCI);\r
+ break;\r
+ }\r
+\r
+ Delay_MS(1);\r
+ }\r
+\r
+ if (HSOFIEnabled)\r
+ USB_INT_Enable(USB_INT_HSOFI);\r
+\r
+ if (BusSuspended)\r
+ USB_Host_SuspendBus();\r
+\r
+ USB_INT_Enable(USB_INT_DDISCI);\r
+}\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Host definitions for the AVR8 microcontrollers.\r
+ * \copydetails Group_Host_AVR8\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_Host\r
+ * \defgroup Group_Host_AVR8 Host Management (AVR8)\r
+ * \brief USB Host definitions for the AVR8 microcontrollers.\r
+ *\r
+ * Architecture specific USB Host definitions for the Atmel 8-bit AVR microcontrollers.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBHOST_AVR8_H__\r
+#define __USBHOST_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../StdDescriptors.h"\r
+ #include "../Pipe.h"\r
+ #include "../USBInterrupt.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ #if defined(INVERTED_VBUS_ENABLE_LINE) && !defined(NO_AUTO_VBUS_MANAGEMENT)\r
+ #error The INVERTED_VBUS_ENABLE_LINE compile option requires NO_AUTO_VBUS_MANAGEMENT for the AVR8 architecture.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Indicates the fixed USB device address which any attached device is enumerated to when in\r
+ * host mode. As only one USB device may be attached to the AVR in host mode at any one time\r
+ * and that the address used is not important (other than the fact that it is non-zero), a\r
+ * fixed value is specified by the library.\r
+ */\r
+ #define USB_HOST_DEVICEADDRESS 1\r
+\r
+ #if !defined(HOST_DEVICE_SETTLE_DELAY_MS) || defined(__DOXYGEN__)\r
+ /** Constant for the delay in milliseconds after a device is connected before the library\r
+ * will start the enumeration process. Some devices require a delay of up to 5 seconds\r
+ * after connection before the enumeration process can start or incorrect operation will\r
+ * occur.\r
+ *\r
+ * The default delay value may be overridden in the user project makefile by defining the\r
+ * \c HOST_DEVICE_SETTLE_DELAY_MS token to the required delay in milliseconds, and passed to the\r
+ * compiler using the -D switch.\r
+ */\r
+ #define HOST_DEVICE_SETTLE_DELAY_MS 1000\r
+ #endif\r
+\r
+ /** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event.\r
+ *\r
+ * \see \ref Group_Events for more information on this event.\r
+ */\r
+ enum USB_Host_ErrorCodes_t\r
+ {\r
+ HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This\r
+ * error may be the result of an attached device drawing\r
+ * too much current from the VBUS line, or due to the\r
+ * AVR's power source being unable to supply sufficient\r
+ * current.\r
+ */\r
+ };\r
+\r
+ /** Enum for the error codes for the \ref EVENT_USB_Host_DeviceEnumerationFailed() event.\r
+ *\r
+ * \see \ref Group_Events for more information on this event.\r
+ */\r
+ enum USB_Host_EnumerationErrorCodes_t\r
+ {\r
+ HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid\r
+ * ErrorCode parameter value for the \ref EVENT_USB_Host_DeviceEnumerationFailed()\r
+ * event.\r
+ */\r
+ HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed\r
+ * to complete successfully, due to a timeout or other\r
+ * error.\r
+ */\r
+ HOST_ENUMERROR_NoDeviceDetected = 2, /**< No device was detected, despite the USB data lines\r
+ * indicating the attachment of a device.\r
+ */\r
+ HOST_ENUMERROR_ControlError = 3, /**< One of the enumeration control requests failed to\r
+ * complete successfully.\r
+ */\r
+ HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to\r
+ * configure correctly.\r
+ */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended)\r
+ * the frame number is incremented by one.\r
+ *\r
+ * \return Current USB frame number from the USB controller.\r
+ */\r
+ static inline uint16_t USB_Host_GetFrameNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t USB_Host_GetFrameNumber(void)\r
+ {\r
+ return UHFNUM;\r
+ }\r
+\r
+ #if !defined(NO_SOF_EVENTS)\r
+ /** Enables the host mode Start Of Frame events. When enabled, this causes the\r
+ * \ref EVENT_USB_Host_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,\r
+ * at the start of each USB frame when a device is enumerated while in host mode.\r
+ *\r
+ * \note This function is not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_EnableSOFEvents(void)\r
+ {\r
+ USB_INT_Enable(USB_INT_HSOFI);\r
+ }\r
+\r
+ /** Disables the host mode Start Of Frame events. When disabled, this stops the firing of the\r
+ * \ref EVENT_USB_Host_StartOfFrame() event when enumerated in host mode.\r
+ *\r
+ * \note This function is not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Host_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_DisableSOFEvents(void)\r
+ {\r
+ USB_INT_Disable(USB_INT_HSOFI);\r
+ }\r
+ #endif\r
+\r
+ /** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host.\r
+ * USB bus resets leave the default control pipe configured (if already configured).\r
+ *\r
+ * If the USB bus has been suspended prior to issuing a bus reset, the attached device will be\r
+ * woken up automatically and the bus resumed after the reset has been correctly issued.\r
+ */\r
+ static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_ResetBus(void)\r
+ {\r
+ UHCON |= (1 << RESET);\r
+ }\r
+\r
+ /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has\r
+ * completed.\r
+ *\r
+ * \return Boolean \c true if no bus reset is currently being sent, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsBusResetComplete(void)\r
+ {\r
+ return ((UHCON & (1 << RESET)) ? false : true);\r
+ }\r
+\r
+ /** Resumes USB communications with an attached and enumerated device, by resuming the transmission\r
+ * of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the\r
+ * host and attached device may occur.\r
+ */\r
+ static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_ResumeBus(void)\r
+ {\r
+ UHCON |= (1 << SOFEN);\r
+ }\r
+\r
+ /** Suspends the USB bus, preventing any communications from occurring between the host and attached\r
+ * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame\r
+ * messages to the device.\r
+ *\r
+ * \attention While the USB bus is suspended, all USB interrupt sources are also disabled; this means that\r
+ * some events (such as device disconnections) will not fire until the bus is resumed.\r
+ */\r
+ static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_SuspendBus(void)\r
+ {\r
+ UHCON &= ~(1 << SOFEN);\r
+ }\r
+\r
+ /** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro,\r
+ * false otherwise. While suspended, no USB communications can occur until the bus is resumed,\r
+ * except for the Remote Wakeup event from the device if supported.\r
+ *\r
+ * \return Boolean \c true if the bus is currently suspended, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsBusSuspended(void)\r
+ {\r
+ return ((UHCON & (1 << SOFEN)) ? false : true);\r
+ }\r
+\r
+ /** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or\r
+ * false if the attached device is enumerated in Low Speed mode (1.5Mb/s).\r
+ *\r
+ * \return Boolean \c true if the attached device is enumerated in Full Speed mode, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsDeviceFullSpeed(void)\r
+ {\r
+ return ((USBSTA & (1 << SPEED)) ? true : false);\r
+ }\r
+\r
+ /** Determines if the attached device is currently issuing a Remote Wakeup request, requesting\r
+ * that the host resume the USB bus and wake up the device, false otherwise.\r
+ *\r
+ * \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsRemoteWakeupSent(void)\r
+ {\r
+ return ((UHINT & (1 << RXRSMI)) ? true : false);\r
+ }\r
+\r
+ /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */\r
+ static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_ClearRemoteWakeupSent(void)\r
+ {\r
+ UHINT &= ~(1 << RXRSMI);\r
+ }\r
+\r
+ /** Accepts a Remote Wakeup request from an attached device. This must be issued in response to\r
+ * a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to\r
+ * be resumed.\r
+ */\r
+ static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_ResumeFromWakeupRequest(void)\r
+ {\r
+ UHCON |= (1 << RESUME);\r
+ }\r
+\r
+ /** Determines if a resume from Remote Wakeup request is currently being sent to an attached\r
+ * device.\r
+ *\r
+ * \return Boolean \c true if no resume request is currently being sent, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsResumeFromWakeupRequestSent(void)\r
+ {\r
+ return ((UHCON & (1 << RESUME)) ? false : true);\r
+ }\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_HostMode_On(void)\r
+ {\r
+ USBCON |= (1 << HOST);\r
+ }\r
+\r
+ static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_HostMode_Off(void)\r
+ {\r
+ USBCON &= ~(1 << HOST);\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Auto_Enable(void)\r
+ {\r
+ OTGCON &= ~(1 << VBUSHWC);\r
+ UHWCON |= (1 << UVCONE);\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Manual_Enable(void)\r
+ {\r
+ OTGCON |= (1 << VBUSHWC);\r
+ UHWCON &= ~(1 << UVCONE);\r
+\r
+ DDRE |= (1 << 7);\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Auto_On(void)\r
+ {\r
+ OTGCON |= (1 << VBUSREQ);\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Manual_On(void)\r
+ {\r
+ #if defined(INVERTED_VBUS_ENABLE_LINE)\r
+ PORTE &= ~(1 << 7);\r
+ #else\r
+ PORTE |= (1 << 7);\r
+ #endif\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Auto_Off(void)\r
+ {\r
+ OTGCON |= (1 << VBUSRQC);\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Manual_Off(void)\r
+ {\r
+ #if defined(INVERTED_VBUS_ENABLE_LINE)\r
+ PORTE |= (1 << 7);\r
+ #else\r
+ PORTE &= ~(1 << 7);\r
+ #endif\r
+ }\r
+\r
+ static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_SetDeviceAddress(const uint8_t Address)\r
+ {\r
+ UHADDR = (Address & 0x7F);\r
+ }\r
+\r
+ /* Enums: */\r
+ enum USB_Host_WaitMSErrorCodes_t\r
+ {\r
+ HOST_WAITERROR_Successful = 0,\r
+ HOST_WAITERROR_DeviceDisconnect = 1,\r
+ HOST_WAITERROR_PipeError = 2,\r
+ HOST_WAITERROR_SetupStalled = 3,\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ void USB_Host_ProcessNextHostState(void);\r
+ uint8_t USB_Host_WaitMS(uint8_t MS);\r
+\r
+ #if defined(__INCLUDE_FROM_HOST_C)\r
+ static void USB_Host_ResetDevice(void);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB OTG definitions for the AVR8 microcontrollers.\r
+ * \copydetails Group_OTG_AVR8\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_OTG\r
+ * \defgroup Group_OTG_AVR8 USB On The Go (OTG) Management (AVR8)\r
+ * \brief USB OTG definitions for the AVR8 microcontrollers.\r
+ *\r
+ * Architecture specific USB OTG definitions for the Atmel 8-bit AVR microcontrollers.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBOTG_AVR8_H__\r
+#define __USBOTG_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the VBUS pulsing method of SRP, supported by some OTG devices.\r
+ *\r
+ * \see \ref USB_OTG_Device_InitiateSRP().\r
+ */\r
+ #define USB_OTG_SRP_VBUS (1 << SRPSEL)\r
+\r
+ /** Mask for the Data + pulsing method of SRP, supported by some OTG devices.\r
+ *\r
+ * \see \ref USB_OTG_Device_InitiateSRP().\r
+ */\r
+ #define USB_OTG_STP_DATA 0\r
+\r
+ /* Inline Functions: */\r
+ /** Initiate a Host Negotiation Protocol request. This indicates to the other connected device\r
+ * that the device wishes to change device/host roles.\r
+ */\r
+ static inline void USB_OTG_Device_RequestHNP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTG_Device_RequestHNP(void)\r
+ {\r
+ OTGCON |= (1 << HNPREQ);\r
+ }\r
+\r
+ /** Cancel a Host Negotiation Protocol request. This stops a pending HNP request to the other\r
+ * connected device.\r
+ */\r
+ static inline void USB_OTG_Device_CancelHNPRequest(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTG_Device_CancelHNPRequest(void)\r
+ {\r
+ OTGCON &= ~(1 << HNPREQ);\r
+ }\r
+\r
+ /** Determines if the device is currently sending a HNP to an attached host.\r
+ *\r
+ * \return Boolean \c true if currently sending a HNP to the other connected device, \c false otherwise\r
+ */\r
+ static inline bool USB_OTG_Device_IsSendingHNP(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_OTG_Device_IsSendingHNP(void)\r
+ {\r
+ return ((OTGCON & (1 << HNPREQ)) ? true : false);\r
+ }\r
+\r
+ /** Initiates a Session Request Protocol request. Most OTG devices turn off VBUS when the USB\r
+ * interface is not in use, to conserve power. Sending a SRP to a USB OTG device running in\r
+ * host mode indicates that VBUS should be applied and a session started.\r
+ *\r
+ * There are two different methods of sending a SRP - either pulses on the VBUS line, or by\r
+ * pulsing the Data + line via the internal pull-up resistor.\r
+ *\r
+ * \param[in] SRPTypeMask Mask indicating the type of SRP to use, either \ref USB_OTG_SRP_VBUS or\r
+ * \ref USB_OTG_STP_DATA.\r
+ */\r
+ static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTG_Device_InitiateSRP(const uint8_t SRPTypeMask)\r
+ {\r
+ OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (SRPTypeMask | (1 << SRPREQ)));\r
+ }\r
+\r
+ /** Accepts a HNP from a connected device, indicating that both devices should exchange\r
+ * device/host roles.\r
+ */\r
+ static inline void USB_OTG_Host_AcceptHNP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTG_Host_AcceptHNP(void)\r
+ {\r
+ OTGCON |= (1 << HNPREQ);\r
+ }\r
+\r
+ /** Rejects a HNP from a connected device, indicating that both devices should remain in their\r
+ * current device/host roles.\r
+ */\r
+ static inline void USB_OTG_Host_RejectHNP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTG_Host_RejectHNP(void)\r
+ {\r
+ OTGCON &= ~(1 << HNPREQ);\r
+ }\r
+\r
+ /** Indicates if the connected device is currently sending a HNP request.\r
+ *\r
+ * \return Boolean \c true if a HNP is currently being issued by the connected device, \c false otherwise.\r
+ */\r
+ static inline bool USB_OTG_Host_IsHNPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_OTG_Host_IsHNPReceived(void)\r
+ {\r
+ return ((OTGCON & (1 << HNPREQ)) ? true : false);\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_AVR8)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#include "PipeStream_AVR8.h"\r
+\r
+uint8_t Pipe_Discard_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t ErrorCode;\r
+ uint16_t BytesInTransfer = 0;\r
+ \r
+ Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ if (BytesProcessed != NULL)\r
+ Length -= *BytesProcessed;\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ Pipe_ClearIN();\r
+ \r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return PIPE_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ Pipe_Discard_8();\r
+ \r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t Pipe_Null_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t ErrorCode;\r
+ uint16_t BytesInTransfer = 0;\r
+ \r
+ Pipe_SetPipeToken(PIPE_TOKEN_OUT);\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ if (BytesProcessed != NULL)\r
+ Length -= *BytesProcessed;\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ Pipe_ClearOUT();\r
+ \r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return PIPE_RWSTREAM_IncompleteTransfer;\r
+ }\r
+ \r
+ USB_USBTask();\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ Pipe_Write_8(0);\r
+ \r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,\r
+ * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_LE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_OUT\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr)\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_BE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_OUT\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr)\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_LE\r
+#define TEMPLATE_BUFFER_TYPE void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_IN\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8()\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_BE\r
+#define TEMPLATE_BUFFER_TYPE void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_IN\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8()\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Write_PStream_LE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_OUT\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(pgm_read_byte(BufferPtr))\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Write_PStream_BE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_OUT\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(pgm_read_byte(BufferPtr))\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_LE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_OUT\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(eeprom_read_byte(BufferPtr))\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Write_EStream_BE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_OUT\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(eeprom_read_byte(BufferPtr))\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_LE\r
+#define TEMPLATE_BUFFER_TYPE void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_IN\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Pipe_Read_8())\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Read_EStream_BE\r
+#define TEMPLATE_BUFFER_TYPE void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_IN\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Pipe_Read_8())\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+ \r
+/** \file\r
+ * \brief Pipe data stream transmission and reception management for the AVR8 microcontrollers\r
+ * \copydetails Group_PipeStreamRW_AVR8\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_PipeStreamRW\r
+ * \defgroup Group_PipeStreamRW_AVR8 Read/Write of Multi-Byte Streams (AVR8)\r
+ * \brief Pipe data stream transmission and reception management for the Atmel AVR8 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of data streams from\r
+ * and to pipes.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __PIPE_STREAM_AVR8_H__\r
+#define __PIPE_STREAM_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBMode.h" \r
+ #include "../USBTask.h"\r
+ \r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Function Prototypes: */\r
+ /** \name Stream functions for null data */\r
+ //@{\r
+\r
+ /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host\r
+ * as needed. The last packet is not automatically discarded once the remaining bytes has been read; the\r
+ * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearIN() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or\r
+ * succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer\r
+ * will instead be performed as a series of chunks. Each time the pipe bank becomes empty while there is still data\r
+ * to process (and after the current packet has been acknowledged) the BytesProcessed location will be updated with\r
+ * the total number of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to\r
+ * continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed\r
+ * value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Pipe_Discard_Stream(512, NULL)) != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Pipe_Discard_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \param[in] Length Number of bytes to discard via the currently selected pipe.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be processed at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Discard_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed);\r
+\r
+ /** Writes a given number of zeroed bytes to the pipe, sending full pipe packets from the host to the device\r
+ * as needed. The last packet is not automatically sent once the remaining bytes has been written; the\r
+ * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearOUT() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or\r
+ * succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer\r
+ * will instead be performed as a series of chunks. Each time the pipe bank becomes full while there is still data\r
+ * to process (and after the current packet transmission has been initiated) the BytesProcessed location will be\r
+ * updated with the total number of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to\r
+ * continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed\r
+ * value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Pipe_Null_Stream(512, NULL)) != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Pipe_Null_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \param[in] Length Number of zero bytes to write via the currently selected pipe.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be processed at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Null_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed);\r
+\r
+ //@}\r
+\r
+ /** \name Stream functions for RAM source/destination data */\r
+ //@{\r
+ \r
+ /** Writes the given number of bytes to the pipe from the given buffer in little endian,\r
+ * sending full packets to the device as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is\r
+ * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the pipe bank becomes full while there is still data to process (and after the current\r
+ * packet transmission has been initiated) the BytesProcessed location will be updated with the\r
+ * total number of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream),\r
+ * NULL)) != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream),\r
+ * &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_Stream_LE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the pipe from the given buffer in big endian,\r
+ * sending full packets to the device as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is\r
+ * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_Stream_BE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the pipe into the given buffer in little endian,\r
+ * sending full packets to the device as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is\r
+ * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the pipe bank becomes empty while there is still data to process (and after the current\r
+ * packet has been acknowledged) the BytesProcessed location will be updated with the total number\r
+ * of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream),\r
+ * NULL)) != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream),\r
+ * &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \param[out] Buffer Pointer to the source data buffer to write to.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe to read from.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Read_Stream_LE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the pipe into the given buffer in big endian,\r
+ * sending full packets to the device as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is\r
+ * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \param[out] Buffer Pointer to the source data buffer to write to.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe to read from.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Read_Stream_BE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+ //@}\r
+\r
+ /** \name Stream functions for EEPROM source/destination data */\r
+ //@{\r
+ \r
+ /** EEPROM buffer source version of \ref Pipe_Write_Stream_LE().\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_EStream_LE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+ \r
+ /** EEPROM buffer source version of \ref Pipe_Write_Stream_BE().\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_EStream_BE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer source version of \ref Pipe_Read_Stream_LE().\r
+ *\r
+ * \param[out] Buffer Pointer to the source data buffer to write to.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe to read from.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Read_EStream_LE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+ \r
+ /** EEPROM buffer source version of \ref Pipe_Read_Stream_BE().\r
+ *\r
+ * \param[out] Buffer Pointer to the source data buffer to write to.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe to read from.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Read_EStream_BE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+ //@}\r
+\r
+ /** \name Stream functions for PROGMEM source/destination data */\r
+ //@{\r
+ \r
+ /** FLASH buffer source version of \ref Pipe_Write_Stream_LE().\r
+ *\r
+ * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_PStream_LE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+ \r
+ /** FLASH buffer source version of \ref Pipe_Write_Stream_BE().\r
+ *\r
+ * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_PStream_BE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+ //@}\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_AVR8)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#include "../Pipe.h"\r
+\r
+uint8_t USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;\r
+\r
+bool Pipe_ConfigurePipeTable(const USB_Pipe_Table_t* const Table,\r
+ const uint8_t Entries)\r
+{\r
+ for (uint8_t i = 0; i < Entries; i++)\r
+ {\r
+ if (!(Table[i].Address))\r
+ continue;\r
+ \r
+ if (!(Pipe_ConfigurePipe(Table[i].Address, Table[i].Type, Table[i].EndpointAddress, Table[i].Size, Table[i].Banks)))\r
+ {\r
+ return false;\r
+ }\r
+ }\r
+ \r
+ return true;\r
+}\r
+\r
+bool Pipe_ConfigurePipe(const uint8_t Address,\r
+ const uint8_t Type,\r
+ const uint8_t EndpointAddress,\r
+ const uint16_t Size,\r
+ const uint8_t Banks)\r
+{\r
+ uint8_t Number = (Address & PIPE_EPNUM_MASK);\r
+ uint8_t Token = (Address & PIPE_DIR_IN) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT;\r
+ \r
+ if (Number >= PIPE_TOTAL_PIPES)\r
+ return false;\r
+\r
+ if (Type == EP_TYPE_CONTROL)\r
+ Token = PIPE_TOKEN_SETUP;\r
+\r
+#if defined(ORDERED_EP_CONFIG)\r
+ Pipe_SelectPipe(Number);\r
+ Pipe_EnablePipe();\r
+\r
+ UPCFG1X = 0;\r
+\r
+ UPCFG0X = ((Type << EPTYPE0) | Token | ((EndpointAddress & PIPE_EPNUM_MASK) << PEPNUM0));\r
+ UPCFG1X = ((1 << ALLOC) | ((Banks > 1) ? (1 << EPBK0) : 0) | Pipe_BytesToEPSizeMask(Size));\r
+\r
+ Pipe_SetInfiniteINRequests();\r
+\r
+ return Pipe_IsConfigured();\r
+#else\r
+ for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++)\r
+ {\r
+ uint8_t UPCFG0XTemp;\r
+ uint8_t UPCFG1XTemp;\r
+ uint8_t UPCFG2XTemp;\r
+ uint8_t UPIENXTemp;\r
+\r
+ Pipe_SelectPipe(PNum);\r
+\r
+ if (PNum == Number)\r
+ {\r
+ UPCFG0XTemp = ((Type << EPTYPE0) | Token | ((EndpointAddress & PIPE_EPNUM_MASK) << PEPNUM0));\r
+ UPCFG1XTemp = ((1 << ALLOC) | Banks | Pipe_BytesToEPSizeMask(Size));\r
+ UPCFG2XTemp = 0;\r
+ UPIENXTemp = 0;\r
+ }\r
+ else\r
+ {\r
+ UPCFG0XTemp = UPCFG0X;\r
+ UPCFG1XTemp = UPCFG1X;\r
+ UPCFG2XTemp = UPCFG2X;\r
+ UPIENXTemp = UPIENX;\r
+ }\r
+\r
+ if (!(UPCFG1XTemp & (1 << ALLOC)))\r
+ continue;\r
+\r
+ Pipe_DisablePipe();\r
+ UPCFG1X &= ~(1 << ALLOC);\r
+\r
+ Pipe_EnablePipe();\r
+ UPCFG0X = UPCFG0XTemp;\r
+ UPCFG1X = UPCFG1XTemp;\r
+ UPCFG2X = UPCFG2XTemp;\r
+ UPIENX = UPIENXTemp;\r
+\r
+ Pipe_SetInfiniteINRequests();\r
+\r
+ if (!(Pipe_IsConfigured()))\r
+ return false;\r
+ }\r
+\r
+ Pipe_SelectPipe(Number);\r
+ return true;\r
+#endif\r
+}\r
+\r
+void Pipe_ClearPipes(void)\r
+{\r
+ UPINT = 0;\r
+\r
+ for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)\r
+ {\r
+ Pipe_SelectPipe(PNum);\r
+ UPIENX = 0;\r
+ UPINTX = 0;\r
+ UPCFG1X = 0;\r
+ Pipe_DisablePipe();\r
+ }\r
+}\r
+\r
+bool Pipe_IsEndpointBound(const uint8_t EndpointAddress)\r
+{\r
+ uint8_t PrevPipeNumber = Pipe_GetCurrentPipe();\r
+\r
+ for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)\r
+ {\r
+ Pipe_SelectPipe(PNum);\r
+\r
+ if (!(Pipe_IsConfigured()))\r
+ continue;\r
+\r
+ if (Pipe_GetBoundEndpointAddress() == EndpointAddress)\r
+ return true;\r
+ }\r
+\r
+ Pipe_SelectPipe(PrevPipeNumber);\r
+ return false;\r
+}\r
+\r
+uint8_t Pipe_WaitUntilReady(void)\r
+{\r
+ #if (USB_STREAM_TIMEOUT_MS < 0xFF)\r
+ uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #else\r
+ uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #endif\r
+\r
+ uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();\r
+\r
+ for (;;)\r
+ {\r
+ if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)\r
+ {\r
+ if (Pipe_IsINReceived())\r
+ return PIPE_READYWAIT_NoError;\r
+ }\r
+ else\r
+ {\r
+ if (Pipe_IsOUTReady())\r
+ return PIPE_READYWAIT_NoError;\r
+ }\r
+\r
+ if (Pipe_IsStalled())\r
+ return PIPE_READYWAIT_PipeStalled;\r
+ else if (USB_HostState == HOST_STATE_Unattached)\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();\r
+\r
+ if (CurrentFrameNumber != PreviousFrameNumber)\r
+ {\r
+ PreviousFrameNumber = CurrentFrameNumber;\r
+\r
+ if (!(TimeoutMSRem--))\r
+ return PIPE_READYWAIT_Timeout;\r
+ }\r
+ }\r
+}\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Pipe definitions for the AVR8 microcontrollers.\r
+ * \copydetails Group_PipeManagement_AVR8\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_PipeRW\r
+ * \defgroup Group_PipeRW_AVR8 Pipe Data Reading and Writing (AVR8)\r
+ * \brief Pipe data read/write definitions for the Atmel AVR8 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing from and to pipes.\r
+ */\r
+\r
+/** \ingroup Group_PipePrimitiveRW\r
+ * \defgroup Group_PipePrimitiveRW_AVR8 Read/Write of Primitive Data Types (AVR8)\r
+ * \brief Pipe primitive data read/write definitions for the Atmel AVR8 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of primitive data types\r
+ * from and to pipes.\r
+ */\r
+\r
+/** \ingroup Group_PipePacketManagement\r
+ * \defgroup Group_PipePacketManagement_AVR8 Pipe Packet Management (AVR8)\r
+ * \brief Pipe packet management definitions for the Atmel AVR8 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to packet management of pipes.\r
+ */\r
+\r
+/** \ingroup Group_PipeControlReq\r
+ * \defgroup Group_PipeControlReq_AVR8 Pipe Control Request Management (AVR8)\r
+ * \brief Pipe control request management definitions for the Atmel AVR8 architecture.\r
+ *\r
+ * Module for host mode request processing. This module allows for the transmission of standard, class and\r
+ * vendor control requests to the default control endpoint of an attached device while in host mode.\r
+ *\r
+ * \see Chapter 9 of the USB 2.0 specification.\r
+ */\r
+\r
+/** \ingroup Group_PipeManagement\r
+ * \defgroup Group_PipeManagement_AVR8 Pipe Management (AVR8)\r
+ * \brief Pipe management definitions for the Atmel AVR8 architecture.\r
+ *\r
+ * This module contains functions, macros and enums related to pipe management when in USB Host mode. This\r
+ * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions\r
+ * for various data types.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __PIPE_AVR8_H__\r
+#define __PIPE_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBTask.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name Pipe Error Flag Masks */\r
+ //@{\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */\r
+ #define PIPE_ERRORFLAG_OVERFLOW (1 << 6)\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that an underflow error occurred in the pipe on the received data. */\r
+ #define PIPE_ERRORFLAG_UNDERFLOW (1 << 5)\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */\r
+ #define PIPE_ERRORFLAG_CRC16 (1 << 4)\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_TIMEOUT (1 << 3)\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_PID (1 << 2)\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_DATAPID (1 << 1)\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_DATATGL (1 << 0)\r
+ //@}\r
+\r
+ /** \name Pipe Token Masks */\r
+ //@{\r
+ /** Token mask for \ref Pipe_SetPipeToken() and \ref Pipe_GetPipeToken(). This sets the pipe as a SETUP token (for CONTROL type pipes),\r
+ * which will trigger a control request on the attached device when data is written to the pipe.\r
+ */\r
+ #define PIPE_TOKEN_SETUP (0 << PTOKEN0)\r
+\r
+ /** Token mask for \ref Pipe_SetPipeToken() and \ref Pipe_GetPipeToken(). This sets the pipe as a IN token (for non-CONTROL type pipes),\r
+ * indicating that the pipe data will flow from device to host.\r
+ */\r
+ #define PIPE_TOKEN_IN (1 << PTOKEN0)\r
+\r
+ /** Token mask for \ref Pipe_SetPipeToken() and \ref Pipe_GetPipeToken(). This sets the pipe as a OUT token (for non-CONTROL type pipes),\r
+ * indicating that the pipe data will flow from host to device.\r
+ */\r
+ #define PIPE_TOKEN_OUT (2 << PTOKEN0)\r
+ //@}\r
+\r
+ /** Default size of the default control pipe's bank, until altered by the Endpoint0Size value\r
+ * in the device descriptor of the attached device.\r
+ */\r
+ #define PIPE_CONTROLPIPE_DEFAULT_SIZE 64\r
+\r
+ /** Total number of pipes (including the default control pipe at address 0) which may be used in\r
+ * the device. Different USB AVR models support different amounts of pipes, this value reflects\r
+ * the maximum number of pipes for the currently selected AVR model.\r
+ */\r
+ #define PIPE_TOTAL_PIPES 7\r
+\r
+ /** Size in bytes of the largest pipe bank size possible in the device. Not all banks on each AVR\r
+ * model supports the largest bank size possible on the device; different pipe numbers support\r
+ * different maximum bank sizes. This value reflects the largest possible bank of any pipe on the\r
+ * currently selected USB AVR model.\r
+ */\r
+ #define PIPE_MAX_SIZE 256\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error return codes of the \ref Pipe_WaitUntilReady() function.\r
+ *\r
+ * \ingroup Group_PipeRW_AVR8\r
+ */\r
+ enum Pipe_WaitUntilReady_ErrorCodes_t\r
+ {\r
+ PIPE_READYWAIT_NoError = 0, /**< Pipe ready for next packet, no error. */\r
+ PIPE_READYWAIT_PipeStalled = 1, /**< The device stalled the pipe while waiting. */\r
+ PIPE_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while waiting. */\r
+ PIPE_READYWAIT_Timeout = 3, /**< The device failed to accept or send the next packet\r
+ * within the software timeout period set by the\r
+ * \ref USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Indicates the number of bytes currently stored in the current pipes's selected bank.\r
+ *\r
+ * \ingroup Group_PipeRW_AVR8\r
+ *\r
+ * \return Total number of bytes in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint16_t Pipe_BytesInPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Pipe_BytesInPipe(void)\r
+ {\r
+ return UPBCX;\r
+ }\r
+\r
+ /** Determines the currently selected pipe's direction.\r
+ *\r
+ * \return The currently selected pipe's direction, as a \c PIPE_DIR_* mask.\r
+ */\r
+ static inline uint8_t Pipe_GetPipeDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetPipeDirection(void)\r
+ {\r
+ return (UPCFG0X & (1 << EPDIR)) ? PIPE_DIR_IN : PIPE_DIR_OUT;\r
+ }\r
+ \r
+ /** Returns the pipe address of the currently selected pipe. This is typically used to save the\r
+ * currently selected pipe address so that it can be restored after another pipe has been manipulated.\r
+ *\r
+ * \return Index of the currently selected pipe.\r
+ */\r
+ static inline uint8_t Pipe_GetCurrentPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetCurrentPipe(void)\r
+ {\r
+ return ((UPNUM & PIPE_PIPENUM_MASK) | Pipe_GetPipeDirection());\r
+ }\r
+\r
+ /** Selects the given pipe address. Any pipe operations which do not require the pipe address to be\r
+ * indicated will operate on the currently selected pipe.\r
+ *\r
+ * \param[in] Address Address of the pipe to select.\r
+ */\r
+ static inline void Pipe_SelectPipe(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SelectPipe(const uint8_t Address)\r
+ {\r
+ UPNUM = (Address & PIPE_PIPENUM_MASK);\r
+ }\r
+\r
+ /** Resets the desired pipe, including the pipe banks and flags.\r
+ *\r
+ * \param[in] Address Address of the pipe to reset.\r
+ */\r
+ static inline void Pipe_ResetPipe(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ResetPipe(const uint8_t Address)\r
+ {\r
+ UPRST = (1 << (Address & PIPE_PIPENUM_MASK));\r
+ UPRST = 0;\r
+ }\r
+\r
+ /** Enables the currently selected pipe so that data can be sent and received through it to and from\r
+ * an attached device.\r
+ *\r
+ * \pre The currently selected pipe must first be configured properly via \ref Pipe_ConfigurePipe().\r
+ */\r
+ static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_EnablePipe(void)\r
+ {\r
+ UPCONX |= (1 << PEN);\r
+ }\r
+\r
+ /** Disables the currently selected pipe so that data cannot be sent and received through it to and\r
+ * from an attached device.\r
+ */\r
+ static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_DisablePipe(void)\r
+ {\r
+ UPCONX &= ~(1 << PEN);\r
+ }\r
+\r
+ /** Determines if the currently selected pipe is enabled, but not necessarily configured.\r
+ *\r
+ * \return Boolean \c true if the currently selected pipe is enabled, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsEnabled(void)\r
+ {\r
+ return ((UPCONX & (1 << PEN)) ? true : false);\r
+ }\r
+\r
+ /** Gets the current pipe token, indicating the pipe's data direction and type.\r
+ *\r
+ * \return The current pipe token, as a \c PIPE_TOKEN_* mask.\r
+ */\r
+ static inline uint8_t Pipe_GetPipeToken(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetPipeToken(void)\r
+ {\r
+ return (UPCFG0X & (0x03 << PTOKEN0));\r
+ }\r
+\r
+ /** Sets the token for the currently selected pipe to one of the tokens specified by the \c PIPE_TOKEN_*\r
+ * masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during\r
+ * control requests, or on regular pipes to allow for half-duplex bidirectional data transfer to devices\r
+ * which have two endpoints of opposite direction sharing the same endpoint address within the device.\r
+ *\r
+ * \param[in] Token New pipe token to set the selected pipe to, as a \c PIPE_TOKEN_* mask.\r
+ */\r
+ static inline void Pipe_SetPipeToken(const uint8_t Token) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SetPipeToken(const uint8_t Token)\r
+ {\r
+ UPCFG0X = ((UPCFG0X & ~(0x03 << PTOKEN0)) | Token);\r
+ }\r
+\r
+ /** Configures the currently selected pipe to allow for an unlimited number of IN requests. */\r
+ static inline void Pipe_SetInfiniteINRequests(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SetInfiniteINRequests(void)\r
+ {\r
+ UPCONX |= (1 << INMODE);\r
+ }\r
+\r
+ /** Configures the currently selected pipe to only allow the specified number of IN requests to be\r
+ * accepted by the pipe before it is automatically frozen.\r
+ *\r
+ * \param[in] TotalINRequests Total number of IN requests that the pipe may receive before freezing.\r
+ */\r
+ static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests)\r
+ {\r
+ UPCONX &= ~(1 << INMODE);\r
+ UPINRQX = TotalINRequests;\r
+ }\r
+\r
+ /** Determines if the currently selected pipe is configured.\r
+ *\r
+ * \return Boolean \c true if the selected pipe is configured, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsConfigured(void)\r
+ {\r
+ return ((UPSTAX & (1 << CFGOK)) ? true : false);\r
+ }\r
+\r
+ /** Retrieves the endpoint address of the endpoint within the attached device that the currently selected\r
+ * pipe is bound to.\r
+ *\r
+ * \return Endpoint address the currently selected pipe is bound to.\r
+ */\r
+ static inline uint8_t Pipe_GetBoundEndpointAddress(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetBoundEndpointAddress(void)\r
+ {\r
+ uint8_t UPCFG0X_Temp = UPCFG0X;\r
+ \r
+ return (((UPCFG0X_Temp >> PEPNUM0) & PIPE_EPNUM_MASK) | ((UPCFG0X_Temp & PEPNUM1) ? ENDPOINT_DIR_OUT : ENDPOINT_DIR_IN));\r
+ }\r
+\r
+ /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds.\r
+ *\r
+ * \param[in] Milliseconds Number of milliseconds between each pipe poll.\r
+ */\r
+ static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds)\r
+ {\r
+ UPCFG2X = Milliseconds;\r
+ }\r
+\r
+ /** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should\r
+ * be serviced.\r
+ *\r
+ * \return Mask whose bits indicate which pipes have interrupted.\r
+ */\r
+ static inline uint8_t Pipe_GetPipeInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetPipeInterrupts(void)\r
+ {\r
+ return UPINT;\r
+ }\r
+\r
+ /** Determines if the specified pipe address has interrupted (valid only for INTERRUPT type\r
+ * pipes).\r
+ *\r
+ * \param[in] Address Address of the pipe whose interrupt flag should be tested.\r
+ *\r
+ * \return Boolean \c true if the specified pipe has interrupted, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_HasPipeInterrupted(const uint8_t Address) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_HasPipeInterrupted(const uint8_t Address)\r
+ {\r
+ return ((UPINT & (1 << (Address & PIPE_PIPENUM_MASK))) ? true : false);\r
+ }\r
+\r
+ /** Unfreezes the selected pipe, allowing it to communicate with an attached device. */\r
+ static inline void Pipe_Unfreeze(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Unfreeze(void)\r
+ {\r
+ UPCONX &= ~(1 << PFREEZE);\r
+ }\r
+\r
+ /** Freezes the selected pipe, preventing it from communicating with an attached device. */\r
+ static inline void Pipe_Freeze(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Freeze(void)\r
+ {\r
+ UPCONX |= (1 << PFREEZE);\r
+ }\r
+\r
+ /** Determines if the currently selected pipe is frozen, and not able to accept data.\r
+ *\r
+ * \return Boolean \c true if the currently selected pipe is frozen, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsFrozen(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsFrozen(void)\r
+ {\r
+ return ((UPCONX & (1 << PFREEZE)) ? true : false);\r
+ }\r
+\r
+ /** Clears the error flags for the currently selected pipe. */\r
+ static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearError(void)\r
+ {\r
+ UPERRX = 0;\r
+ UPINTX &= ~(1 << PERRI);\r
+ }\r
+\r
+ /** Determines if the master pipe error flag is set for the currently selected pipe, indicating that\r
+ * some sort of hardware error has occurred on the pipe.\r
+ *\r
+ * \see \ref Pipe_GetErrorFlags() macro for information on retrieving the exact error flag.\r
+ *\r
+ * \return Boolean \c true if an error has occurred on the selected pipe, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsError(void)\r
+ {\r
+ return ((UPINTX & (1 << PERRI)) ? true : false);\r
+ }\r
+\r
+ /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This\r
+ * value can then be masked against the \c PIPE_ERRORFLAG_* masks to determine what error has occurred.\r
+ *\r
+ * \return Mask comprising of \c PIPE_ERRORFLAG_* bits indicating what error has occurred on the selected pipe.\r
+ */\r
+ static inline uint8_t Pipe_GetErrorFlags(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetErrorFlags(void)\r
+ {\r
+ return ((UPERRX & (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT |\r
+ PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID |\r
+ PIPE_ERRORFLAG_DATATGL)) |\r
+ (UPSTAX & (PIPE_ERRORFLAG_OVERFLOW | PIPE_ERRORFLAG_UNDERFLOW)));\r
+ }\r
+\r
+ /** Retrieves the number of busy banks in the currently selected pipe, which have been queued for\r
+ * transmission via the \ref Pipe_ClearOUT() command, or are awaiting acknowledgement via the\r
+ * \ref Pipe_ClearIN() command.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Total number of busy banks in the selected pipe.\r
+ */\r
+ static inline uint8_t Pipe_GetBusyBanks(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetBusyBanks(void)\r
+ {\r
+ return (UPSTAX & (0x03 << NBUSYBK0));\r
+ }\r
+\r
+ /** Determines if the currently selected pipe may be read from (if data is waiting in the pipe\r
+ * bank and the pipe is an IN direction, or if the bank is not yet full if the pipe is an OUT\r
+ * direction). This function will return false if an error has occurred in the pipe, or if the pipe\r
+ * is an IN direction and no packet (or an empty packet) has been received, or if the pipe is an OUT\r
+ * direction and the pipe bank is full.\r
+ *\r
+ * \note This function is not valid on CONTROL type pipes.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the currently selected pipe may be read from or written to, depending\r
+ * on its direction.\r
+ */\r
+ static inline bool Pipe_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsReadWriteAllowed(void)\r
+ {\r
+ return ((UPINTX & (1 << RWAL)) ? true : false);\r
+ }\r
+\r
+ /** Determines if a packet has been received on the currently selected IN pipe from the attached device.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the current pipe has received an IN packet, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsINReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsINReceived(void)\r
+ {\r
+ return ((UPINTX & (1 << RXINI)) ? true : false);\r
+ }\r
+\r
+ /** Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the current pipe is ready for an OUT packet, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsOUTReady(void)\r
+ {\r
+ return ((UPINTX & (1 << TXOUTI)) ? true : false);\r
+ }\r
+\r
+ /** Determines if no SETUP request is currently being sent to the attached device on the selected\r
+ * CONTROL type pipe.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the current pipe is ready for a SETUP packet, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsSETUPSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsSETUPSent(void)\r
+ {\r
+ return ((UPINTX & (1 << TXSTPI)) ? true : false);\r
+ }\r
+\r
+ /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ */\r
+ static inline void Pipe_ClearSETUP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearSETUP(void)\r
+ {\r
+ UPINTX &= ~((1 << TXSTPI) | (1 << FIFOCON));\r
+ }\r
+\r
+ /** Acknowledges the reception of a setup IN request from the attached device on the currently selected\r
+ * pipe, freeing the bank ready for the next packet.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ */\r
+ static inline void Pipe_ClearIN(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearIN(void)\r
+ {\r
+ UPINTX &= ~((1 << RXINI) | (1 << FIFOCON));\r
+ }\r
+\r
+ /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing\r
+ * the bank ready for the next packet.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ */\r
+ static inline void Pipe_ClearOUT(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearOUT(void)\r
+ {\r
+ UPINTX &= ~((1 << TXOUTI) | (1 << FIFOCON));\r
+ }\r
+\r
+ /** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on\r
+ * the currently selected pipe. This occurs when the host sends a packet to the device, but the device\r
+ * is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been\r
+ * received, it must be cleared using \ref Pipe_ClearNAKReceived() before the previous (or any other) packet\r
+ * can be re-sent.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if an NAK has been received on the current pipe, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsNAKReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsNAKReceived(void)\r
+ {\r
+ return ((UPINTX & (1 << NAKEDI)) ? true : false);\r
+ }\r
+\r
+ /** Clears the NAK condition on the currently selected pipe.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \see \ref Pipe_IsNAKReceived() for more details.\r
+ */\r
+ static inline void Pipe_ClearNAKReceived(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearNAKReceived(void)\r
+ {\r
+ UPINTX &= ~(1 << NAKEDI);\r
+ }\r
+\r
+ /** Determines if the currently selected pipe has had the STALL condition set by the attached device.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ *\r
+ * \return Boolean \c true if the current pipe has been stalled by the attached device, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsStalled(void)\r
+ {\r
+ return ((UPINTX & (1 << RXSTALLI)) ? true : false);\r
+ }\r
+\r
+ /** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the\r
+ * STALL condition itself (this must be done via a ClearFeature control request to the device).\r
+ *\r
+ * \ingroup Group_PipePacketManagement_AVR8\r
+ */\r
+ static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearStall(void)\r
+ {\r
+ UPINTX &= ~(1 << RXSTALLI);\r
+ }\r
+\r
+ /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \return Next byte in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint8_t Pipe_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_Read_8(void)\r
+ {\r
+ return UPDATX;\r
+ }\r
+\r
+ /** Writes one byte to the currently selected pipe's bank, for IN direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Data Data to write into the the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Write_8(const uint8_t Data)\r
+ {\r
+ UPDATX = Data;\r
+ }\r
+\r
+ /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ */\r
+ static inline void Pipe_Discard_8(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Discard_8(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = UPDATX;\r
+\r
+ (void)Dummy;\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \return Next two bytes in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint16_t Pipe_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Pipe_Read_16_LE(void)\r
+ {\r
+ union\r
+ {\r
+ uint16_t Value;\r
+ uint8_t Bytes[2];\r
+ } Data;\r
+\r
+ Data.Bytes[0] = UPDATX;\r
+ Data.Bytes[1] = UPDATX;\r
+\r
+ return Data.Value;\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \return Next two bytes in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint16_t Pipe_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Pipe_Read_16_BE(void)\r
+ {\r
+ union\r
+ {\r
+ uint16_t Value;\r
+ uint8_t Bytes[2];\r
+ } Data;\r
+\r
+ Data.Bytes[1] = UPDATX;\r
+ Data.Bytes[0] = UPDATX;\r
+\r
+ return Data.Value;\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Data Data to write to the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Write_16_LE(const uint16_t Data)\r
+ {\r
+ UPDATX = (Data & 0xFF);\r
+ UPDATX = (Data >> 8);\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Data Data to write to the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Write_16_BE(const uint16_t Data)\r
+ {\r
+ UPDATX = (Data >> 8);\r
+ UPDATX = (Data & 0xFF);\r
+ }\r
+\r
+ /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ */\r
+ static inline void Pipe_Discard_16(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Discard_16(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = UPDATX;\r
+ Dummy = UPDATX;\r
+\r
+ (void)Dummy;\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \return Next four bytes in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint32_t Pipe_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Pipe_Read_32_LE(void)\r
+ {\r
+ union\r
+ {\r
+ uint32_t Value;\r
+ uint8_t Bytes[4];\r
+ } Data;\r
+\r
+ Data.Bytes[0] = UPDATX;\r
+ Data.Bytes[1] = UPDATX;\r
+ Data.Bytes[2] = UPDATX;\r
+ Data.Bytes[3] = UPDATX;\r
+\r
+ return Data.Value;\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \return Next four bytes in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint32_t Pipe_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Pipe_Read_32_BE(void)\r
+ {\r
+ union\r
+ {\r
+ uint32_t DWord;\r
+ uint8_t Bytes[4];\r
+ } Data;\r
+\r
+ Data.Bytes[3] = UPDATX;\r
+ Data.Bytes[2] = UPDATX;\r
+ Data.Bytes[1] = UPDATX;\r
+ Data.Bytes[0] = UPDATX;\r
+\r
+ return Data.DWord;\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected pipe's bank in little endian format, for IN\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Data Data to write to the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Write_32_LE(const uint32_t Data)\r
+ {\r
+ UPDATX = (Data & 0xFF);\r
+ UPDATX = (Data >> 8);\r
+ UPDATX = (Data >> 16);\r
+ UPDATX = (Data >> 24);\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ *\r
+ * \param[in] Data Data to write to the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Write_32_BE(const uint32_t Data)\r
+ {\r
+ UPDATX = (Data >> 24);\r
+ UPDATX = (Data >> 16);\r
+ UPDATX = (Data >> 8);\r
+ UPDATX = (Data & 0xFF);\r
+ }\r
+\r
+ /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_AVR8\r
+ */\r
+ static inline void Pipe_Discard_32(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Discard_32(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = UPDATX;\r
+ Dummy = UPDATX;\r
+ Dummy = UPDATX;\r
+ Dummy = UPDATX;\r
+\r
+ (void)Dummy;\r
+ }\r
+\r
+ /* External Variables: */\r
+ /** Global indicating the maximum packet size of the default control pipe located at address\r
+ * 0 in the device. This value is set to the value indicated in the attached device's device\r
+ * descriptor once the USB interface is initialized into host mode and a device is attached\r
+ * to the USB bus.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ extern uint8_t USB_Host_ControlPipeSize;\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures a table of pipe descriptions, in sequence. This function can be used to configure multiple\r
+ * pipes at the same time.\r
+ *\r
+ * \note Pipe with a zero address will be ignored, thus this function cannot be used to configure the\r
+ * control pipe.\r
+ *\r
+ * \param[in] Table Pointer to a table of pipe descriptions.\r
+ * \param[in] Entries Number of entries in the pipe table to configure.\r
+ *\r
+ * \return Boolean \c true if all pipes configured successfully, \c false otherwise.\r
+ */ \r
+ bool Pipe_ConfigurePipeTable(const USB_Pipe_Table_t* const Table,\r
+ const uint8_t Entries);\r
+ \r
+ /** Configures the specified pipe address with the given pipe type, endpoint address within the attached device, bank size\r
+ * and number of hardware banks.\r
+ *\r
+ * A newly configured pipe is frozen by default, and must be unfrozen before use via the \ref Pipe_Unfreeze()\r
+ * before being used. Pipes should be kept frozen unless waiting for data from a device while in IN mode, or\r
+ * sending data to the device in OUT mode. IN type pipes are also automatically configured to accept infinite\r
+ * numbers of IN requests without automatic freezing - this can be overridden by a call to\r
+ * \ref Pipe_SetFiniteINRequests().\r
+ *\r
+ * \param[in] Address Pipe address to configure.\r
+ *\r
+ * \param[in] Type Type of pipe to configure, an \c EP_TYPE_* mask. Not all pipe types are available on Low\r
+ * Speed USB devices - refer to the USB 2.0 specification.\r
+ *\r
+ * \param[in] EndpointAddress Endpoint address within the attached device that the pipe should interface to.\r
+ *\r
+ * \param[in] Size Size of the pipe's bank, where packets are stored before they are transmitted to\r
+ * the USB device, or after they have been received from the USB device (depending on\r
+ * the pipe's data direction). The bank size must indicate the maximum packet size that\r
+ * the pipe can handle.\r
+ *\r
+ * \param[in] Banks Number of banks to use for the pipe being configured.\r
+ *\r
+ * \attention When the \c ORDERED_EP_CONFIG compile time option is used, Pipes <b>must</b> be configured in ascending order,\r
+ * or bank corruption will occur.\r
+ *\r
+ * \note Certain microcontroller model's pipes may have different maximum packet sizes based on the pipe's\r
+ * index - refer to the chosen microcontroller's datasheet to determine the maximum bank size for each pipe.\r
+ * \n\n\r
+ *\r
+ * \note The default control pipe should not be manually configured by the user application, as it is\r
+ * automatically configured by the library internally.\r
+ * \n\n\r
+ *\r
+ * \note This routine will automatically select the specified pipe upon success. Upon failure, the pipe which\r
+ * failed to reconfigure correctly will be selected.\r
+ *\r
+ * \return Boolean \c true if the configuration succeeded, \c false otherwise.\r
+ */\r
+ bool Pipe_ConfigurePipe(const uint8_t Address,\r
+ const uint8_t Type,\r
+ const uint8_t EndpointAddress,\r
+ const uint16_t Size,\r
+ const uint8_t Banks);\r
+\r
+ /** Spin-loops until the currently selected non-control pipe is ready for the next packet of data to be read\r
+ * or written to it, aborting in the case of an error condition (such as a timeout or device disconnect).\r
+ *\r
+ * \ingroup Group_PipeRW_AVR8\r
+ *\r
+ * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_WaitUntilReady(void);\r
+\r
+ /** Determines if a pipe has been bound to the given device endpoint address. If a pipe which is bound to the given\r
+ * endpoint is found, it is automatically selected.\r
+ *\r
+ * \param[in] EndpointAddress Address and direction mask of the endpoint within the attached device to check.\r
+ *\r
+ * \return Boolean \c true if a pipe bound to the given endpoint address of the specified direction is found,\r
+ * \c false otherwise.\r
+ */\r
+ bool Pipe_IsEndpointBound(const uint8_t EndpointAddress) ATTR_WARN_UNUSED_RESULT;\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #if !defined(ENDPOINT_CONTROLEP)\r
+ #define ENDPOINT_CONTROLEP 0\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes)\r
+ {\r
+ uint8_t MaskVal = 0;\r
+ uint16_t CheckBytes = 8;\r
+\r
+ while ((CheckBytes < Bytes) && (CheckBytes < PIPE_MAX_SIZE))\r
+ {\r
+ MaskVal++;\r
+ CheckBytes <<= 1;\r
+ }\r
+\r
+ return (MaskVal << EPSIZE0);\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ void Pipe_ClearPipes(void);\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#if defined(TEMPLATE_FUNC_NAME)\r
+\r
+// cppcheck-suppress unusedFunction\r
+uint8_t TEMPLATE_FUNC_NAME (void* const Buffer,\r
+ uint16_t Length)\r
+{\r
+ uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
+\r
+ if (!(Length))\r
+ Endpoint_ClearOUT();\r
+\r
+ while (Length)\r
+ {\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_RWCSTREAM_BusSuspended;\r
+ else if (Endpoint_IsSETUPReceived())\r
+ return ENDPOINT_RWCSTREAM_HostAborted;\r
+\r
+ if (Endpoint_IsOUTReceived())\r
+ {\r
+ while (Length && Endpoint_BytesInEndpoint())\r
+ {\r
+ TEMPLATE_TRANSFER_BYTE(DataStream);\r
+ TEMPLATE_BUFFER_MOVE(DataStream, 1);\r
+ Length--;\r
+ }\r
+\r
+ Endpoint_ClearOUT();\r
+ }\r
+ }\r
+\r
+ while (!(Endpoint_IsINReady()))\r
+ {\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_RWCSTREAM_BusSuspended;\r
+ }\r
+\r
+ return ENDPOINT_RWCSTREAM_NoError;\r
+}\r
+\r
+#undef TEMPLATE_BUFFER_OFFSET\r
+#undef TEMPLATE_BUFFER_MOVE\r
+#undef TEMPLATE_FUNC_NAME\r
+#undef TEMPLATE_TRANSFER_BYTE\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#if defined(TEMPLATE_FUNC_NAME)\r
+\r
+// cppcheck-suppress unusedFunction\r
+uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer,\r
+ uint16_t Length)\r
+{\r
+ uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
+ bool LastPacketFull = false;\r
+\r
+ if (Length > USB_ControlRequest.wLength)\r
+ Length = USB_ControlRequest.wLength;\r
+ else if (!(Length))\r
+ Endpoint_ClearIN();\r
+\r
+ while (Length || LastPacketFull)\r
+ {\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_RWCSTREAM_BusSuspended;\r
+ else if (Endpoint_IsSETUPReceived())\r
+ return ENDPOINT_RWCSTREAM_HostAborted;\r
+ else if (Endpoint_IsOUTReceived())\r
+ break;\r
+\r
+ if (Endpoint_IsINReady())\r
+ {\r
+ uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint();\r
+\r
+ while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize))\r
+ {\r
+ TEMPLATE_TRANSFER_BYTE(DataStream);\r
+ TEMPLATE_BUFFER_MOVE(DataStream, 1);\r
+ Length--;\r
+ BytesInEndpoint++;\r
+ }\r
+\r
+ LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize);\r
+ Endpoint_ClearIN();\r
+ }\r
+ }\r
+\r
+ while (!(Endpoint_IsOUTReceived()))\r
+ {\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_RWCSTREAM_BusSuspended;\r
+ }\r
+\r
+ return ENDPOINT_RWCSTREAM_NoError;\r
+}\r
+\r
+#undef TEMPLATE_BUFFER_OFFSET\r
+#undef TEMPLATE_BUFFER_MOVE\r
+#undef TEMPLATE_FUNC_NAME\r
+#undef TEMPLATE_TRANSFER_BYTE\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#if defined(TEMPLATE_FUNC_NAME)\r
+\r
+// cppcheck-suppress unusedFunction\r
+uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
+ uint16_t BytesInTransfer = 0;\r
+ uint8_t ErrorCode;\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ Length -= *BytesProcessed;\r
+ TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed);\r
+ }\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ {\r
+ TEMPLATE_CLEAR_ENDPOINT();\r
+\r
+ #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
+ USB_USBTask();\r
+ #endif\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return ENDPOINT_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ TEMPLATE_TRANSFER_BYTE(DataStream);\r
+ TEMPLATE_BUFFER_MOVE(DataStream, 1);\r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+\r
+ return ENDPOINT_RWSTREAM_NoError;\r
+}\r
+\r
+#undef TEMPLATE_FUNC_NAME\r
+#undef TEMPLATE_BUFFER_TYPE\r
+#undef TEMPLATE_TRANSFER_BYTE\r
+#undef TEMPLATE_CLEAR_ENDPOINT\r
+#undef TEMPLATE_BUFFER_OFFSET\r
+#undef TEMPLATE_BUFFER_MOVE\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#if defined(TEMPLATE_FUNC_NAME)\r
+\r
+// cppcheck-suppress unusedFunction\r
+uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
+ uint16_t BytesInTransfer = 0;\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SetPipeToken(TEMPLATE_TOKEN);\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ Length -= *BytesProcessed;\r
+ TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed);\r
+ }\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ TEMPLATE_CLEAR_PIPE();\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return PIPE_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ TEMPLATE_TRANSFER_BYTE(DataStream);\r
+ TEMPLATE_BUFFER_MOVE(DataStream, 1);\r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+#undef TEMPLATE_FUNC_NAME\r
+#undef TEMPLATE_BUFFER_TYPE\r
+#undef TEMPLATE_TOKEN\r
+#undef TEMPLATE_TRANSFER_BYTE\r
+#undef TEMPLATE_CLEAR_PIPE\r
+#undef TEMPLATE_BUFFER_OFFSET\r
+#undef TEMPLATE_BUFFER_MOVE\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_AVR8)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#define __INCLUDE_FROM_USB_CONTROLLER_C\r
+#include "../USBController.h"\r
+\r
+#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY))\r
+volatile uint8_t USB_CurrentMode = USB_MODE_None;\r
+#endif\r
+\r
+#if !defined(USE_STATIC_OPTIONS)\r
+volatile uint8_t USB_Options;\r
+#endif\r
+\r
+void USB_Init(\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ const uint8_t Mode\r
+ #endif\r
+\r
+ #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS))\r
+ ,\r
+ #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))\r
+ void\r
+ #endif\r
+\r
+ #if !defined(USE_STATIC_OPTIONS)\r
+ const uint8_t Options\r
+ #endif\r
+ )\r
+{\r
+ #if !defined(USE_STATIC_OPTIONS)\r
+ USB_Options = Options;\r
+ #endif\r
+\r
+ if (!(USB_Options & USB_OPT_REG_DISABLED))\r
+ USB_REG_On();\r
+ else\r
+ USB_REG_Off();\r
+\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ {\r
+ #if defined(USB_SERIES_4_AVR)\r
+ PLLFRQ = (1 << PDIV2);\r
+ #endif\r
+ }\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ if (Mode == USB_MODE_UID)\r
+ {\r
+ UHWCON |= (1 << UIDE);\r
+ USB_INT_Enable(USB_INT_IDTI);\r
+ USB_CurrentMode = USB_GetUSBModeFromUID();\r
+ }\r
+ else\r
+ {\r
+ UHWCON &= ~(1 << UIDE);\r
+ USB_CurrentMode = Mode;\r
+ }\r
+ #endif\r
+\r
+ USB_IsInitialized = true;\r
+\r
+ USB_ResetInterface();\r
+}\r
+\r
+void USB_Disable(void)\r
+{\r
+ USB_INT_DisableAllInterrupts();\r
+ USB_INT_ClearAllInterrupts();\r
+\r
+ USB_Detach();\r
+ USB_Controller_Disable();\r
+\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ USB_PLL_Off();\r
+\r
+ USB_REG_Off();\r
+\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ USB_OTGPAD_Off();\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ USB_CurrentMode = USB_MODE_None;\r
+ #endif\r
+\r
+ USB_IsInitialized = false;\r
+}\r
+\r
+void USB_ResetInterface(void)\r
+{\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ bool UIDModeSelectEnabled = ((UHWCON & (1 << UIDE)) != 0);\r
+ #endif\r
+\r
+ USB_INT_DisableAllInterrupts();\r
+ USB_INT_ClearAllInterrupts();\r
+\r
+ USB_Controller_Reset();\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ if (UIDModeSelectEnabled)\r
+ USB_INT_Enable(USB_INT_IDTI);\r
+ #endif\r
+\r
+ USB_CLK_Unfreeze();\r
+\r
+ if (USB_CurrentMode == USB_MODE_Device)\r
+ {\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #if (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
+ UHWCON |= (1 << UIMOD);\r
+ #endif\r
+\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ {\r
+ #if defined(USB_SERIES_2_AVR)\r
+ USB_PLL_On();\r
+ while (!(USB_PLL_IsReady()));\r
+ #else\r
+ USB_PLL_Off();\r
+ #endif\r
+ }\r
+\r
+ USB_Init_Device();\r
+ #endif\r
+ }\r
+ else if (USB_CurrentMode == USB_MODE_Host)\r
+ {\r
+ #if defined(USB_CAN_BE_HOST)\r
+ UHWCON &= ~(1 << UIMOD);\r
+\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ {\r
+ #if defined(USB_CAN_BE_HOST)\r
+ USB_PLL_On();\r
+ while (!(USB_PLL_IsReady()));\r
+ #endif\r
+ }\r
+\r
+ USB_Init_Host();\r
+ #endif\r
+ }\r
+\r
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
+ USB_OTGPAD_On();\r
+ #endif\r
+}\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+static void USB_Init_Device(void)\r
+{\r
+ USB_DeviceState = DEVICE_STATE_Unattached;\r
+ USB_Device_ConfigurationNumber = 0;\r
+\r
+ #if !defined(NO_DEVICE_REMOTE_WAKEUP)\r
+ USB_Device_RemoteWakeupEnabled = false;\r
+ #endif\r
+\r
+ #if !defined(NO_DEVICE_SELF_POWER)\r
+ USB_Device_CurrentlySelfPowered = false;\r
+ #endif\r
+\r
+ #if !defined(FIXED_CONTROL_ENDPOINT_SIZE)\r
+ USB_Descriptor_Device_t* DeviceDescriptorPtr;\r
+\r
+ #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \\r
+ !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS))\r
+ uint8_t DescriptorAddressSpace;\r
+\r
+ if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr, &DescriptorAddressSpace) != NO_DESCRIPTOR)\r
+ {\r
+ if (DescriptorAddressSpace == MEMSPACE_FLASH)\r
+ USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);\r
+ else if (DescriptorAddressSpace == MEMSPACE_EEPROM)\r
+ USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);\r
+ else\r
+ USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;\r
+ }\r
+ #else\r
+ if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)\r
+ {\r
+ #if defined(USE_RAM_DESCRIPTORS)\r
+ USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;\r
+ #elif defined(USE_EEPROM_DESCRIPTORS)\r
+ USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);\r
+ #else\r
+ USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);\r
+ #endif\r
+ }\r
+ #endif\r
+ #endif\r
+\r
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
+ if (USB_Options & USB_DEVICE_OPT_LOWSPEED)\r
+ USB_Device_SetLowSpeed();\r
+ else\r
+ USB_Device_SetFullSpeed();\r
+\r
+ USB_INT_Enable(USB_INT_VBUSTI);\r
+ #endif\r
+\r
+ Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,\r
+ USB_Device_ControlEndpointSize, 1);\r
+\r
+ USB_INT_Clear(USB_INT_SUSPI);\r
+ USB_INT_Enable(USB_INT_SUSPI);\r
+ USB_INT_Enable(USB_INT_EORSTI);\r
+\r
+ USB_Attach();\r
+}\r
+#endif\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+static void USB_Init_Host(void)\r
+{\r
+ USB_HostState = HOST_STATE_Unattached;\r
+ USB_Host_ConfigurationNumber = 0;\r
+ USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;\r
+\r
+ USB_Host_HostMode_On();\r
+\r
+ USB_Host_VBUS_Auto_Off();\r
+ USB_Host_VBUS_Manual_Enable();\r
+ USB_Host_VBUS_Manual_On();\r
+\r
+ USB_INT_Enable(USB_INT_SRPI);\r
+ USB_INT_Enable(USB_INT_BCERRI);\r
+\r
+ USB_Attach();\r
+}\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Controller definitions for the AVR8 microcontrollers.\r
+ * \copydetails Group_USBManagement_AVR8\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBManagement\r
+ * \defgroup Group_USBManagement_AVR8 USB Interface Management (AVR8)\r
+ * \brief USB Controller definitions for the AVR8 microcontrollers.\r
+ *\r
+ * Functions, macros, variables, enums and types related to the setup and management of the USB interface.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBCONTROLLER_AVR8_H__\r
+#define __USBCONTROLLER_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBMode.h"\r
+ #include "../Events.h"\r
+ #include "../USBTask.h"\r
+ #include "../USBInterrupt.h"\r
+\r
+ #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)\r
+ #include "../Host.h"\r
+ #include "../OTG.h"\r
+ #include "../Pipe.h"\r
+ #include "../HostStandardReq.h"\r
+ #include "../PipeStream.h"\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
+ #include "../Device.h"\r
+ #include "../Endpoint.h"\r
+ #include "../DeviceStandardReq.h"\r
+ #include "../EndpointStream.h"\r
+ #endif\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks and Defines: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ #if !defined(F_USB)\r
+ #error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile.\r
+ #endif\r
+\r
+ #if (F_USB == 8000000)\r
+ #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \\r
+ defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \\r
+ defined(__AVR_ATmega32U2__))\r
+ #define USB_PLL_PSC 0\r
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))\r
+ #define USB_PLL_PSC 0\r
+ #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__))\r
+ #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))\r
+ #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))\r
+ #define USB_PLL_PSC ((1 << PLLP1) | (1 << PLLP0))\r
+ #endif\r
+ #elif (F_USB == 16000000)\r
+ #if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__) || \\r
+ defined(__AVR_ATmega8U2__) || defined(__AVR_ATmega16U2__) || \\r
+ defined(__AVR_ATmega32U2__))\r
+ #define USB_PLL_PSC (1 << PLLP0)\r
+ #elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))\r
+ #define USB_PLL_PSC (1 << PINDIV)\r
+ #elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__))\r
+ #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP1))\r
+ #elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__))\r
+ #define USB_PLL_PSC ((1 << PLLP2) | (1 << PLLP0))\r
+ #endif\r
+ #endif\r
+\r
+ #if !defined(USB_PLL_PSC)\r
+ #error No PLL prescale value available for chosen F_USB value and AVR model.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name USB Controller Option Masks */\r
+ //@{\r
+ /** Regulator disable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad\r
+ * regulator should be disabled and the AVR's VCC level used for the data pads.\r
+ *\r
+ * \note See USB AVR data sheet for more information on the internal pad regulator.\r
+ */\r
+ #define USB_OPT_REG_DISABLED (1 << 1)\r
+\r
+ /** Regulator enable option mask for \ref USB_Init(). This indicates that the internal 3.3V USB data pad\r
+ * regulator should be enabled to regulate the data pin voltages from the VBUS level down to a level within\r
+ * the range allowable by the USB standard.\r
+ *\r
+ * \note See USB AVR data sheet for more information on the internal pad regulator.\r
+ */\r
+ #define USB_OPT_REG_ENABLED (0 << 1)\r
+\r
+ /** Manual PLL control option mask for \ref USB_Init(). This indicates to the library that the user application\r
+ * will take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock\r
+ * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations.\r
+ */\r
+ #define USB_OPT_MANUAL_PLL (1 << 2)\r
+\r
+ /** Automatic PLL control option mask for \ref USB_Init(). This indicates to the library that the library should\r
+ * take full responsibility for controlling the AVR's PLL (used to generate the high frequency clock\r
+ * that the USB controller requires) and ensuring that it is locked at the correct frequency for USB operations.\r
+ */\r
+ #define USB_OPT_AUTO_PLL (0 << 2)\r
+ //@}\r
+\r
+ #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)\r
+ /** Constant for the maximum software timeout period of the USB data stream transfer functions\r
+ * (both control and standard) when in either device or host mode. If the next packet of a stream\r
+ * is not received or acknowledged within this time period, the stream function will fail.\r
+ *\r
+ * This value may be overridden in the user project makefile as the value of the\r
+ * \ref USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch.\r
+ */\r
+ #define USB_STREAM_TIMEOUT_MS 100\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)\r
+ /** Determines if the VBUS line is currently high (i.e. the USB host is supplying power).\r
+ *\r
+ * \note This function is not available on some AVR models which do not support hardware VBUS monitoring.\r
+ *\r
+ * \return Boolean \c true if the VBUS line is currently detecting power from a host, \c false otherwise.\r
+ */\r
+ static inline bool USB_VBUS_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_VBUS_GetStatus(void)\r
+ {\r
+ return ((USBSTA & (1 << VBUS)) ? true : false);\r
+ }\r
+ #endif\r
+\r
+ /** Detaches the device from the USB bus. This has the effect of removing the device from any\r
+ * attached host, ceasing USB communications. If no host is present, this prevents any host from\r
+ * enumerating the device once attached until \ref USB_Attach() is called.\r
+ */\r
+ static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Detach(void)\r
+ {\r
+ UDCON |= (1 << DETACH);\r
+ }\r
+\r
+ /** Attaches the device to the USB bus. This announces the device's presence to any attached\r
+ * USB host, starting the enumeration process. If no host is present, attaching the device\r
+ * will allow for enumeration once a host is connected to the device.\r
+ *\r
+ * This is inexplicably also required for proper operation while in host mode, to enable the\r
+ * attachment of a device to the host. This is despite the bit being located in the device-mode\r
+ * register and despite the datasheet making no mention of its requirement in host mode.\r
+ */\r
+ static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Attach(void)\r
+ {\r
+ UDCON &= ~(1 << DETACH);\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ /** Main function to initialize and start the USB interface. Once active, the USB interface will\r
+ * allow for device connection to a host when in device mode, or for device enumeration while in\r
+ * host mode.\r
+ *\r
+ * As the USB library relies on interrupts for the device and host mode enumeration processes,\r
+ * the user must enable global interrupts before or shortly after this function is called. In\r
+ * device mode, interrupts must be enabled within 500ms of this function being called to ensure\r
+ * that the host does not time out whilst enumerating the device. In host mode, interrupts may be\r
+ * enabled at the application's leisure however enumeration will not begin of an attached device\r
+ * until after this has occurred.\r
+ *\r
+ * Calling this function when the USB interface is already initialized will cause a complete USB\r
+ * interface reset and re-enumeration.\r
+ *\r
+ * \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value\r
+ * from the \ref USB_Modes_t enum.\r
+ *\r
+ * \param[in] Options Mask indicating the options which should be used when initializing the USB\r
+ * interface to control the USB interface's behavior. This should be comprised of\r
+ * a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the\r
+ * PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device\r
+ * mode speed.\r
+ *\r
+ * \note To reduce the FLASH requirements of the library if only device or host mode is required,\r
+ * the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY\r
+ * (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler\r
+ * via the -D switch. If the mode is statically set, this parameter does not exist in the\r
+ * function prototype.\r
+ * \n\n\r
+ *\r
+ * \note To reduce the FLASH requirements of the library if only fixed settings are required,\r
+ * the options may be set statically in the same manner as the mode (see the Mode parameter of\r
+ * this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token,\r
+ * defined to the appropriate options masks. When the options are statically set, this\r
+ * parameter does not exist in the function prototype.\r
+ * \n\n\r
+ *\r
+ * \note The mode parameter does not exist on devices where only one mode is possible, such as USB\r
+ * AVR models which only implement the USB device mode in hardware.\r
+ *\r
+ * \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks.\r
+ */\r
+ void USB_Init(\r
+ #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)\r
+ const uint8_t Mode\r
+ #endif\r
+\r
+ #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__)\r
+ ,\r
+ #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))\r
+ void\r
+ #endif\r
+\r
+ #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)\r
+ const uint8_t Options\r
+ #endif\r
+ );\r
+\r
+ /** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO\r
+ * memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface\r
+ * is restarted with the \ref USB_Init() function.\r
+ */\r
+ void USB_Disable(void);\r
+\r
+ /** Resets the interface, when already initialized. This will re-enumerate the device if already connected\r
+ * to a host, or re-enumerate an already attached device when in host mode.\r
+ */\r
+ void USB_ResetInterface(void);\r
+\r
+ /* Global Variables: */\r
+ #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)\r
+ /** Indicates the mode that the USB interface is currently initialized to, a value from the\r
+ * \ref USB_Modes_t enum.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ *\r
+ * \note When the controller is initialized into UID auto-detection mode, this variable will hold the\r
+ * currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller\r
+ * is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time\r
+ * options, or a limitation of the USB controller in the chosen device model) this will evaluate to\r
+ * a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the\r
+ * USB interface is not initialized.\r
+ */\r
+ extern volatile uint8_t USB_CurrentMode;\r
+ #elif defined(USB_HOST_ONLY)\r
+ #define USB_CurrentMode USB_MODE_Host\r
+ #elif defined(USB_DEVICE_ONLY)\r
+ #define USB_CurrentMode USB_MODE_Device\r
+ #endif\r
+\r
+ #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)\r
+ /** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init()\r
+ * was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ extern volatile uint8_t USB_Options;\r
+ #elif defined(USE_STATIC_OPTIONS)\r
+ #define USB_Options USE_STATIC_OPTIONS\r
+ #endif\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the\r
+ * user application via \ref USB_CurrentMode.\r
+ */\r
+ enum USB_Modes_t\r
+ {\r
+ USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */\r
+ USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */\r
+ USB_MODE_Host = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */\r
+ USB_MODE_UID = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the\r
+ * USB connector.\r
+ */\r
+ };\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_USB_CONTROLLER_C)\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ static void USB_Init_Device(void);\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ static void USB_Init_Host(void);\r
+ #endif\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ static inline void USB_PLL_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_PLL_On(void)\r
+ {\r
+ PLLCSR = USB_PLL_PSC;\r
+ PLLCSR = (USB_PLL_PSC | (1 << PLLE));\r
+ }\r
+\r
+ static inline void USB_PLL_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_PLL_Off(void)\r
+ {\r
+ PLLCSR = 0;\r
+ }\r
+\r
+ static inline bool USB_PLL_IsReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_PLL_IsReady(void)\r
+ {\r
+ return ((PLLCSR & (1 << PLOCK)) ? true : false);\r
+ }\r
+\r
+ static inline void USB_REG_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_REG_On(void)\r
+ {\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ UHWCON |= (1 << UVREGE);\r
+ #else\r
+ REGCR &= ~(1 << REGDIS);\r
+ #endif\r
+ }\r
+\r
+ static inline void USB_REG_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_REG_Off(void)\r
+ {\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ UHWCON &= ~(1 << UVREGE);\r
+ #else\r
+ REGCR |= (1 << REGDIS);\r
+ #endif\r
+ }\r
+\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTGPAD_On(void)\r
+ {\r
+ USBCON |= (1 << OTGPADE);\r
+ }\r
+\r
+ static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTGPAD_Off(void)\r
+ {\r
+ USBCON &= ~(1 << OTGPADE);\r
+ }\r
+ #endif\r
+\r
+ static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_CLK_Freeze(void)\r
+ {\r
+ USBCON |= (1 << FRZCLK);\r
+ }\r
+\r
+ static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_CLK_Unfreeze(void)\r
+ {\r
+ USBCON &= ~(1 << FRZCLK);\r
+ }\r
+\r
+ static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Controller_Enable(void)\r
+ {\r
+ USBCON |= (1 << USBE);\r
+ }\r
+\r
+ static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Controller_Disable(void)\r
+ {\r
+ USBCON &= ~(1 << USBE);\r
+ }\r
+\r
+ static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Controller_Reset(void)\r
+ {\r
+ USBCON &= ~(1 << USBE);\r
+ USBCON |= (1 << USBE);\r
+ }\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t USB_GetUSBModeFromUID(void)\r
+ {\r
+ if (USBSTA & (1 << ID))\r
+ return USB_MODE_Device;\r
+ else\r
+ return USB_MODE_Host;\r
+ }\r
+ #endif\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_AVR8)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBInterrupt.h"\r
+\r
+void USB_INT_DisableAllInterrupts(void)\r
+{\r
+ #if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ USBCON &= ~((1 << VBUSTE) | (1 << IDTE));\r
+ #elif defined(USB_SERIES_4_AVR)\r
+ USBCON &= ~(1 << VBUSTE);\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ OTGIEN = 0;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ UHIEN = 0;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ UDIEN = 0;\r
+ #endif\r
+}\r
+\r
+void USB_INT_ClearAllInterrupts(void)\r
+{\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ USBINT = 0;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ OTGINT = 0;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ UHINT = 0;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ UDINT = 0;\r
+ #endif\r
+}\r
+\r
+ISR(USB_GEN_vect, ISR_BLOCK)\r
+{\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #if !defined(NO_SOF_EVENTS)\r
+ if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_SOFI);\r
+\r
+ EVENT_USB_Device_StartOfFrame();\r
+ }\r
+ #endif\r
+\r
+ #if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)\r
+ if (USB_INT_HasOccurred(USB_INT_VBUSTI) && USB_INT_IsEnabled(USB_INT_VBUSTI))\r
+ {\r
+ USB_INT_Clear(USB_INT_VBUSTI);\r
+\r
+ if (USB_VBUS_GetStatus())\r
+ {\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ {\r
+ USB_PLL_On();\r
+ while (!(USB_PLL_IsReady()));\r
+ }\r
+\r
+ USB_DeviceState = DEVICE_STATE_Powered;\r
+ EVENT_USB_Device_Connect();\r
+ }\r
+ else\r
+ {\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ USB_PLL_Off();\r
+\r
+ USB_DeviceState = DEVICE_STATE_Unattached;\r
+ EVENT_USB_Device_Disconnect();\r
+ }\r
+ }\r
+ #endif\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI))\r
+ {\r
+ USB_INT_Disable(USB_INT_SUSPI);\r
+ USB_INT_Enable(USB_INT_WAKEUPI);\r
+\r
+ USB_CLK_Freeze();\r
+\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ USB_PLL_Off();\r
+\r
+ #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)\r
+ USB_DeviceState = DEVICE_STATE_Unattached;\r
+ EVENT_USB_Device_Disconnect();\r
+ #else\r
+ USB_DeviceState = DEVICE_STATE_Suspended;\r
+ EVENT_USB_Device_Suspend();\r
+ #endif\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI))\r
+ {\r
+ if (!(USB_Options & USB_OPT_MANUAL_PLL))\r
+ {\r
+ USB_PLL_On();\r
+ while (!(USB_PLL_IsReady()));\r
+ }\r
+\r
+ USB_CLK_Unfreeze();\r
+\r
+ USB_INT_Clear(USB_INT_WAKEUPI);\r
+\r
+ USB_INT_Disable(USB_INT_WAKEUPI);\r
+ USB_INT_Enable(USB_INT_SUSPI);\r
+\r
+ if (USB_Device_ConfigurationNumber)\r
+ USB_DeviceState = DEVICE_STATE_Configured;\r
+ else\r
+ USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;\r
+\r
+ #if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)\r
+ EVENT_USB_Device_Connect();\r
+ #else\r
+ EVENT_USB_Device_WakeUp();\r
+ #endif\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI))\r
+ {\r
+ USB_INT_Clear(USB_INT_EORSTI);\r
+\r
+ USB_DeviceState = DEVICE_STATE_Default;\r
+ USB_Device_ConfigurationNumber = 0;\r
+\r
+ USB_INT_Clear(USB_INT_SUSPI);\r
+ USB_INT_Disable(USB_INT_SUSPI);\r
+ USB_INT_Enable(USB_INT_WAKEUPI);\r
+\r
+ Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,\r
+ USB_Device_ControlEndpointSize, 1);\r
+\r
+ #if defined(INTERRUPT_CONTROL_ENDPOINT)\r
+ USB_INT_Enable(USB_INT_RXSTPI);\r
+ #endif\r
+\r
+ EVENT_USB_Device_Reset();\r
+ }\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #if !defined(NO_SOF_EVENTS)\r
+ if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+\r
+ EVENT_USB_Host_StartOfFrame();\r
+ }\r
+ #endif\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI))\r
+ {\r
+ USB_INT_Clear(USB_INT_DDISCI);\r
+ USB_INT_Clear(USB_INT_DCONNI);\r
+ USB_INT_Disable(USB_INT_DDISCI);\r
+\r
+ EVENT_USB_Host_DeviceUnattached();\r
+\r
+ USB_ResetInterface();\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI))\r
+ {\r
+ USB_INT_Clear(USB_INT_VBERRI);\r
+\r
+ USB_Host_VBUS_Manual_Off();\r
+ USB_Host_VBUS_Auto_Off();\r
+\r
+ EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip);\r
+ EVENT_USB_Host_DeviceUnattached();\r
+\r
+ USB_HostState = HOST_STATE_Unattached;\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_SRPI) && USB_INT_IsEnabled(USB_INT_SRPI))\r
+ {\r
+ USB_INT_Clear(USB_INT_SRPI);\r
+ USB_INT_Disable(USB_INT_SRPI);\r
+\r
+ EVENT_USB_Host_DeviceAttached();\r
+\r
+ USB_INT_Enable(USB_INT_DDISCI);\r
+\r
+ USB_HostState = HOST_STATE_Powered;\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_BCERRI) && USB_INT_IsEnabled(USB_INT_BCERRI))\r
+ {\r
+ USB_INT_Clear(USB_INT_BCERRI);\r
+\r
+ EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0);\r
+ EVENT_USB_Host_DeviceUnattached();\r
+\r
+ USB_ResetInterface();\r
+ }\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ if (USB_INT_HasOccurred(USB_INT_IDTI) && USB_INT_IsEnabled(USB_INT_IDTI))\r
+ {\r
+ USB_INT_Clear(USB_INT_IDTI);\r
+\r
+ if (USB_DeviceState != DEVICE_STATE_Unattached)\r
+ EVENT_USB_Device_Disconnect();\r
+\r
+ if (USB_HostState != HOST_STATE_Unattached)\r
+ EVENT_USB_Host_DeviceUnattached();\r
+\r
+ USB_CurrentMode = USB_GetUSBModeFromUID();\r
+ USB_ResetInterface();\r
+\r
+ EVENT_USB_UIDChange();\r
+ }\r
+ #endif\r
+}\r
+\r
+#if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE)\r
+ISR(USB_COM_vect, ISR_BLOCK)\r
+{\r
+ uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();\r
+\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+ USB_INT_Disable(USB_INT_RXSTPI);\r
+\r
+ GlobalInterruptEnable();\r
+\r
+ USB_Device_ProcessControlRequest();\r
+\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+ USB_INT_Enable(USB_INT_RXSTPI);\r
+ Endpoint_SelectEndpoint(PrevSelectedEndpoint);\r
+}\r
+#endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Controller Interrupt definitions for the AVR8 microcontrollers.\r
+ *\r
+ * This file contains definitions required for the correct handling of low level USB service routine interrupts\r
+ * from the USB controller.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+#ifndef __USBINTERRUPT_AVR8_H__\r
+#define __USBINTERRUPT_AVR8_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Enums: */\r
+ enum USB_Interrupts_t\r
+ {\r
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__))\r
+ USB_INT_VBUSTI = 0,\r
+ #endif\r
+ #if (defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__))\r
+ USB_INT_IDTI = 1,\r
+ #endif\r
+ #if (defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__))\r
+ USB_INT_WAKEUPI = 2,\r
+ USB_INT_SUSPI = 3,\r
+ USB_INT_EORSTI = 4,\r
+ USB_INT_SOFI = 5,\r
+ USB_INT_RXSTPI = 6,\r
+ #endif\r
+ #if (defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__))\r
+ USB_INT_HSOFI = 7,\r
+ USB_INT_DCONNI = 8,\r
+ USB_INT_DDISCI = 9,\r
+ USB_INT_RSTI = 10,\r
+ USB_INT_BCERRI = 11,\r
+ USB_INT_VBERRI = 12,\r
+ USB_INT_SRPI = 13,\r
+ #endif\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_INT_Enable(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
+ case USB_INT_VBUSTI:\r
+ USBCON |= (1 << VBUSTE);\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ case USB_INT_IDTI:\r
+ USBCON |= (1 << IDTE);\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ case USB_INT_WAKEUPI:\r
+ UDIEN |= (1 << WAKEUPE);\r
+ break;\r
+ case USB_INT_SUSPI:\r
+ UDIEN |= (1 << SUSPE);\r
+ break;\r
+ case USB_INT_EORSTI:\r
+ UDIEN |= (1 << EORSTE);\r
+ break;\r
+ case USB_INT_SOFI:\r
+ UDIEN |= (1 << SOFE);\r
+ break;\r
+ case USB_INT_RXSTPI:\r
+ UEIENX |= (1 << RXSTPE);\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_HOST)\r
+ case USB_INT_HSOFI:\r
+ UHIEN |= (1 << HSOFE);\r
+ break;\r
+ case USB_INT_DCONNI:\r
+ UHIEN |= (1 << DCONNE);\r
+ break;\r
+ case USB_INT_DDISCI:\r
+ UHIEN |= (1 << DDISCE);\r
+ break;\r
+ case USB_INT_RSTI:\r
+ UHIEN |= (1 << RSTE);\r
+ break;\r
+ case USB_INT_BCERRI:\r
+ OTGIEN |= (1 << BCERRE);\r
+ break;\r
+ case USB_INT_VBERRI:\r
+ OTGIEN |= (1 << VBERRE);\r
+ break;\r
+ case USB_INT_SRPI:\r
+ OTGIEN |= (1 << SRPE);\r
+ break;\r
+ #endif\r
+ }\r
+ }\r
+\r
+ static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_INT_Disable(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
+ case USB_INT_VBUSTI:\r
+ USBCON &= ~(1 << VBUSTE);\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ case USB_INT_IDTI:\r
+ USBCON &= ~(1 << IDTE);\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ case USB_INT_WAKEUPI:\r
+ UDIEN &= ~(1 << WAKEUPE);\r
+ break;\r
+ case USB_INT_SUSPI:\r
+ UDIEN &= ~(1 << SUSPE);\r
+ break;\r
+ case USB_INT_EORSTI:\r
+ UDIEN &= ~(1 << EORSTE);\r
+ break;\r
+ case USB_INT_SOFI:\r
+ UDIEN &= ~(1 << SOFE);\r
+ break;\r
+ case USB_INT_RXSTPI:\r
+ UEIENX &= ~(1 << RXSTPE);\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_HOST)\r
+ case USB_INT_HSOFI:\r
+ UHIEN &= ~(1 << HSOFE);\r
+ break;\r
+ case USB_INT_DCONNI:\r
+ UHIEN &= ~(1 << DCONNE);\r
+ break;\r
+ case USB_INT_DDISCI:\r
+ UHIEN &= ~(1 << DDISCE);\r
+ break;\r
+ case USB_INT_RSTI:\r
+ UHIEN &= ~(1 << RSTE);\r
+ break;\r
+ case USB_INT_BCERRI:\r
+ OTGIEN &= ~(1 << BCERRE);\r
+ break;\r
+ case USB_INT_VBERRI:\r
+ OTGIEN &= ~(1 << VBERRE);\r
+ break;\r
+ case USB_INT_SRPI:\r
+ OTGIEN &= ~(1 << SRPE);\r
+ break;\r
+ #endif\r
+ }\r
+ }\r
+\r
+ static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_INT_Clear(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
+ case USB_INT_VBUSTI:\r
+ USBINT &= ~(1 << VBUSTI);\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ case USB_INT_IDTI:\r
+ USBINT &= ~(1 << IDTI);\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ case USB_INT_WAKEUPI:\r
+ UDINT &= ~(1 << WAKEUPI);\r
+ break;\r
+ case USB_INT_SUSPI:\r
+ UDINT &= ~(1 << SUSPI);\r
+ break;\r
+ case USB_INT_EORSTI:\r
+ UDINT &= ~(1 << EORSTI);\r
+ break;\r
+ case USB_INT_SOFI:\r
+ UDINT &= ~(1 << SOFI);\r
+ break;\r
+ case USB_INT_RXSTPI:\r
+ UEINTX &= ~(1 << RXSTPI);\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_HOST)\r
+ case USB_INT_HSOFI:\r
+ UHINT &= ~(1 << HSOFI);\r
+ break;\r
+ case USB_INT_DCONNI:\r
+ UHINT &= ~(1 << DCONNI);\r
+ break;\r
+ case USB_INT_DDISCI:\r
+ UHINT &= ~(1 << DDISCI);\r
+ break;\r
+ case USB_INT_RSTI:\r
+ UHINT &= ~(1 << RSTI);\r
+ break;\r
+ case USB_INT_BCERRI:\r
+ OTGINT &= ~(1 << BCERRI);\r
+ break;\r
+ case USB_INT_VBERRI:\r
+ OTGINT &= ~(1 << VBERRI);\r
+ break;\r
+ case USB_INT_SRPI:\r
+ OTGINT &= ~(1 << SRPI);\r
+ break;\r
+ #endif\r
+ }\r
+ }\r
+\r
+ static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool USB_INT_IsEnabled(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
+ case USB_INT_VBUSTI:\r
+ return (USBCON & (1 << VBUSTE));\r
+ #endif\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ case USB_INT_IDTI:\r
+ return (USBCON & (1 << IDTE));\r
+ #endif\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ case USB_INT_WAKEUPI:\r
+ return (UDIEN & (1 << WAKEUPE));\r
+ case USB_INT_SUSPI:\r
+ return (UDIEN & (1 << SUSPE));\r
+ case USB_INT_EORSTI:\r
+ return (UDIEN & (1 << EORSTE));\r
+ case USB_INT_SOFI:\r
+ return (UDIEN & (1 << SOFE));\r
+ case USB_INT_RXSTPI:\r
+ return (UEIENX & (1 << RXSTPE));\r
+ #endif\r
+ #if defined(USB_CAN_BE_HOST)\r
+ case USB_INT_HSOFI:\r
+ return (UHIEN & (1 << HSOFE));\r
+ case USB_INT_DCONNI:\r
+ return (UHIEN & (1 << DCONNE));\r
+ case USB_INT_DDISCI:\r
+ return (UHIEN & (1 << DDISCE));\r
+ case USB_INT_RSTI:\r
+ return (UHIEN & (1 << RSTE));\r
+ case USB_INT_BCERRI:\r
+ return (OTGIEN & (1 << BCERRE));\r
+ case USB_INT_VBERRI:\r
+ return (OTGIEN & (1 << VBERRE));\r
+ case USB_INT_SRPI:\r
+ return (OTGIEN & (1 << SRPE));\r
+ #endif\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool USB_INT_HasOccurred(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ #if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))\r
+ case USB_INT_VBUSTI:\r
+ return (USBINT & (1 << VBUSTI));\r
+ #endif\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ case USB_INT_IDTI:\r
+ return (USBINT & (1 << IDTI));\r
+ #endif\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ case USB_INT_WAKEUPI:\r
+ return (UDINT & (1 << WAKEUPI));\r
+ case USB_INT_SUSPI:\r
+ return (UDINT & (1 << SUSPI));\r
+ case USB_INT_EORSTI:\r
+ return (UDINT & (1 << EORSTI));\r
+ case USB_INT_SOFI:\r
+ return (UDINT & (1 << SOFI));\r
+ case USB_INT_RXSTPI:\r
+ return (UEINTX & (1 << RXSTPI));\r
+ #endif\r
+ #if defined(USB_CAN_BE_HOST)\r
+ case USB_INT_HSOFI:\r
+ return (UHINT & (1 << HSOFI));\r
+ case USB_INT_DCONNI:\r
+ return (UHINT & (1 << DCONNI));\r
+ case USB_INT_DDISCI:\r
+ return (UHINT & (1 << DDISCI));\r
+ case USB_INT_RSTI:\r
+ return (UHINT & (1 << RSTI));\r
+ case USB_INT_BCERRI:\r
+ return (OTGINT & (1 << BCERRI));\r
+ case USB_INT_VBERRI:\r
+ return (OTGINT & (1 << VBERRI));\r
+ case USB_INT_SRPI:\r
+ return (OTGINT & (1 << SRPI));\r
+ #endif\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ /* Includes: */\r
+ #include "../USBMode.h"\r
+ #include "../Events.h"\r
+ #include "../USBController.h"\r
+\r
+ /* Function Prototypes: */\r
+ void USB_INT_ClearAllInterrupts(void);\r
+ void USB_INT_DisableAllInterrupts(void);\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "ConfigDescriptors.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+uint8_t USB_Host_GetDeviceConfigDescriptor(const uint8_t ConfigNumber,\r
+ uint16_t* const ConfigSizePtr,\r
+ void* const BufferPtr,\r
+ const uint16_t BufferSize)\r
+{\r
+ uint8_t ErrorCode;\r
+ uint8_t ConfigHeader[sizeof(USB_Descriptor_Configuration_Header_t)];\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ .bRequest = REQ_GetDescriptor,\r
+ .wValue = ((DTYPE_Configuration << 8) | (ConfigNumber - 1)),\r
+ .wIndex = 0,\r
+ .wLength = sizeof(USB_Descriptor_Configuration_Header_t),\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ if ((ErrorCode = USB_Host_SendControlRequest(ConfigHeader)) != HOST_SENDCONTROL_Successful)\r
+ return ErrorCode;\r
+\r
+ *ConfigSizePtr = le16_to_cpu(DESCRIPTOR_PCAST(ConfigHeader, USB_Descriptor_Configuration_Header_t)->TotalConfigurationSize);\r
+\r
+ if (*ConfigSizePtr > BufferSize)\r
+ return HOST_GETCONFIG_BuffOverflow;\r
+\r
+ USB_ControlRequest.wLength = *ConfigSizePtr;\r
+\r
+ if ((ErrorCode = USB_Host_SendControlRequest(BufferPtr)) != HOST_SENDCONTROL_Successful)\r
+ return ErrorCode;\r
+\r
+ if (DESCRIPTOR_TYPE(BufferPtr) != DTYPE_Configuration)\r
+ return HOST_GETCONFIG_InvalidData;\r
+\r
+ return HOST_GETCONFIG_Successful;\r
+}\r
+#endif\r
+\r
+void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,\r
+ void** const CurrConfigLoc,\r
+ const uint8_t Type)\r
+{\r
+ while (*BytesRem)\r
+ {\r
+ USB_GetNextDescriptor(BytesRem, CurrConfigLoc);\r
+\r
+ if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type)\r
+ return;\r
+ }\r
+}\r
+\r
+void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,\r
+ void** const CurrConfigLoc,\r
+ const uint8_t Type,\r
+ const uint8_t BeforeType)\r
+{\r
+ while (*BytesRem)\r
+ {\r
+ USB_GetNextDescriptor(BytesRem, CurrConfigLoc);\r
+\r
+ if (DESCRIPTOR_TYPE(*CurrConfigLoc) == Type)\r
+ {\r
+ return;\r
+ }\r
+ else if (DESCRIPTOR_TYPE(*CurrConfigLoc) == BeforeType)\r
+ {\r
+ *BytesRem = 0;\r
+ return;\r
+ }\r
+ }\r
+}\r
+\r
+void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,\r
+ void** const CurrConfigLoc,\r
+ const uint8_t Type,\r
+ const uint8_t AfterType)\r
+{\r
+ USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, AfterType);\r
+\r
+ if (*BytesRem)\r
+ USB_GetNextDescriptorOfType(BytesRem, CurrConfigLoc, Type);\r
+}\r
+\r
+uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem,\r
+ void** const CurrConfigLoc,\r
+ ConfigComparatorPtr_t const ComparatorRoutine)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ while (*BytesRem)\r
+ {\r
+ uint8_t* PrevDescLoc = *CurrConfigLoc;\r
+ uint16_t PrevBytesRem = *BytesRem;\r
+\r
+ USB_GetNextDescriptor(BytesRem, CurrConfigLoc);\r
+\r
+ if ((ErrorCode = ComparatorRoutine(*CurrConfigLoc)) != DESCRIPTOR_SEARCH_NotFound)\r
+ {\r
+ if (ErrorCode == DESCRIPTOR_SEARCH_Fail)\r
+ {\r
+ *CurrConfigLoc = PrevDescLoc;\r
+ *BytesRem = PrevBytesRem;\r
+ }\r
+\r
+ return ErrorCode;\r
+ }\r
+ }\r
+\r
+ return DESCRIPTOR_SEARCH_COMP_EndOfDescriptor;\r
+}\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Configuration Descriptor definitions.\r
+ * \copydetails Group_ConfigDescriptorParser\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_StdDescriptors\r
+ * \defgroup Group_ConfigDescriptorParser Configuration Descriptor Parser\r
+ * \brief USB Configuration Descriptor definitions.\r
+ *\r
+ * This section of the library gives a friendly API which can be used in host applications to easily\r
+ * parse an attached device's configuration descriptor so that endpoint, interface and other descriptor\r
+ * data can be extracted and used as needed.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __CONFIGDESCRIPTOR_H__\r
+#define __CONFIGDESCRIPTOR_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+ #include "HostStandardReq.h"\r
+ #include "StdDescriptors.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Casts a pointer to a descriptor inside the configuration descriptor into a pointer to the given\r
+ * descriptor type.\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header\r
+ * USB_Descriptor_Configuration_Header_t* ConfigHeaderPtr = DESCRIPTOR_PCAST(CurrDescriptor,\r
+ * USB_Descriptor_Configuration_Header_t);\r
+ * \r
+ * // Can now access elements of the configuration header struct using the -> indirection operator\r
+ * \endcode\r
+ */\r
+ #define DESCRIPTOR_PCAST(DescriptorPtr, Type) ((Type*)(DescriptorPtr))\r
+\r
+ /** Casts a pointer to a descriptor inside the configuration descriptor into the given descriptor\r
+ * type (as an actual struct instance rather than a pointer to a struct).\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * uint8_t* CurrDescriptor = &ConfigDescriptor[0]; // Pointing to the configuration header\r
+ * USB_Descriptor_Configuration_Header_t ConfigHeader = DESCRIPTOR_CAST(CurrDescriptor,\r
+ * USB_Descriptor_Configuration_Header_t);\r
+ * \r
+ * // Can now access elements of the configuration header struct using the . operator\r
+ * \endcode\r
+ */\r
+ #define DESCRIPTOR_CAST(DescriptorPtr, Type) (*DESCRIPTOR_PCAST(DescriptorPtr, Type))\r
+\r
+ /** Returns the descriptor's type, expressed as the 8-bit type value in the header of the descriptor.\r
+ * This value's meaning depends on the descriptor's placement in the descriptor, but standard type\r
+ * values can be accessed in the \ref USB_DescriptorTypes_t enum.\r
+ */\r
+ #define DESCRIPTOR_TYPE(DescriptorPtr) DESCRIPTOR_PCAST(DescriptorPtr, USB_Descriptor_Header_t)->Type\r
+\r
+ /** Returns the descriptor's size, expressed as the 8-bit value indicating the number of bytes. */\r
+ #define DESCRIPTOR_SIZE(DescriptorPtr) DESCRIPTOR_PCAST(DescriptorPtr, USB_Descriptor_Header_t)->Size\r
+\r
+ /* Type Defines: */\r
+ /** Type define for a Configuration Descriptor comparator function (function taking a pointer to an array\r
+ * of type void, returning a uint8_t value).\r
+ *\r
+ * \see \ref USB_GetNextDescriptorComp function for more details.\r
+ */\r
+ typedef uint8_t (* ConfigComparatorPtr_t)(void*);\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible return codes of the \ref USB_Host_GetDeviceConfigDescriptor() function. */\r
+ enum USB_Host_GetConfigDescriptor_ErrorCodes_t\r
+ {\r
+ HOST_GETCONFIG_Successful = 0, /**< No error occurred while retrieving the configuration descriptor. */\r
+ HOST_GETCONFIG_DeviceDisconnect = 1, /**< The attached device was disconnected while retrieving the configuration\r
+ * descriptor.\r
+ */\r
+ HOST_GETCONFIG_PipeError = 2, /**< An error occurred in the pipe while sending the request. */\r
+ HOST_GETCONFIG_SetupStalled = 3, /**< The attached device stalled the request to retrieve the configuration\r
+ * descriptor.\r
+ */\r
+ HOST_GETCONFIG_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */\r
+ HOST_GETCONFIG_BuffOverflow = 5, /**< The device's configuration descriptor is too large to fit into the allocated\r
+ * buffer.\r
+ */\r
+ HOST_GETCONFIG_InvalidData = 6, /**< The device returned invalid configuration descriptor data. */\r
+ };\r
+\r
+ /** Enum for return values of a descriptor comparator function. */\r
+ enum DSearch_Return_ErrorCodes_t\r
+ {\r
+ DESCRIPTOR_SEARCH_Found = 0, /**< Current descriptor matches comparator criteria. */\r
+ DESCRIPTOR_SEARCH_Fail = 1, /**< No further descriptor could possibly match criteria, fail the search. */\r
+ DESCRIPTOR_SEARCH_NotFound = 2, /**< Current descriptor does not match comparator criteria. */\r
+ };\r
+\r
+ /** Enum for return values of \ref USB_GetNextDescriptorComp(). */\r
+ enum DSearch_Comp_Return_ErrorCodes_t\r
+ {\r
+ DESCRIPTOR_SEARCH_COMP_Found = 0, /**< Configuration descriptor now points to descriptor which matches\r
+ * search criteria of the given comparator function. */\r
+ DESCRIPTOR_SEARCH_COMP_Fail = 1, /**< Comparator function returned \ref DESCRIPTOR_SEARCH_Fail. */\r
+ DESCRIPTOR_SEARCH_COMP_EndOfDescriptor = 2, /**< End of configuration descriptor reached before match found. */\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ /** Retrieves the configuration descriptor data from an attached device via a standard request into a buffer,\r
+ * including validity and size checking to prevent a buffer overflow.\r
+ *\r
+ * \param[in] ConfigNumber Device configuration descriptor number to fetch from the device (usually set to 1 for\r
+ * single configuration devices).\r
+ * \param[in,out] ConfigSizePtr Pointer to a location for storing the retrieved configuration descriptor size.\r
+ * \param[out] BufferPtr Pointer to the buffer for storing the configuration descriptor data.\r
+ * \param[out] BufferSize Size of the allocated buffer where the configuration descriptor is to be stored.\r
+ *\r
+ * \return A value from the \ref USB_Host_GetConfigDescriptor_ErrorCodes_t enum.\r
+ */\r
+ uint8_t USB_Host_GetDeviceConfigDescriptor(const uint8_t ConfigNumber,\r
+ uint16_t* const ConfigSizePtr,\r
+ void* const BufferPtr,\r
+ const uint16_t BufferSize) ATTR_NON_NULL_PTR_ARG(2) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value.\r
+ * The bytes remaining value is automatically decremented.\r
+ *\r
+ * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor.\r
+ * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor.\r
+ * \param[in] Type Descriptor type value to search for.\r
+ */\r
+ void USB_GetNextDescriptorOfType(uint16_t* const BytesRem,\r
+ void** const CurrConfigLoc,\r
+ const uint8_t Type)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value,\r
+ * which must come before a descriptor of the second given type value. If the BeforeType type\r
+ * descriptor is reached first, the number of bytes remaining to process is set to zero and the\r
+ * function exits. The bytes remaining value is automatically decremented.\r
+ *\r
+ * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor.\r
+ * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor.\r
+ * \param[in] Type Descriptor type value to search for.\r
+ * \param[in] BeforeType Descriptor type value which must not be reached before the given Type descriptor.\r
+ */\r
+ void USB_GetNextDescriptorOfTypeBefore(uint16_t* const BytesRem,\r
+ void** const CurrConfigLoc,\r
+ const uint8_t Type,\r
+ const uint8_t BeforeType)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Skips to the next sub-descriptor inside the configuration descriptor of the specified type value,\r
+ * which must come after a descriptor of the second given type value. The bytes remaining value is\r
+ * automatically decremented.\r
+ *\r
+ * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor.\r
+ * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor.\r
+ * \param[in] Type Descriptor type value to search for.\r
+ * \param[in] AfterType Descriptor type value which must be reached before the given Type descriptor.\r
+ */\r
+ void USB_GetNextDescriptorOfTypeAfter(uint16_t* const BytesRem,\r
+ void** const CurrConfigLoc,\r
+ const uint8_t Type,\r
+ const uint8_t AfterType)\r
+ ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /** Searches for the next descriptor in the given configuration descriptor using a pre-made comparator\r
+ * function. The routine updates the position and remaining configuration descriptor bytes values\r
+ * automatically. If a comparator routine fails a search, the descriptor pointer is retreated back\r
+ * so that the next descriptor search invocation will start from the descriptor which first caused the\r
+ * original search to fail. This behavior allows for one comparator to be used immediately after another\r
+ * has failed, starting the second search from the descriptor which failed the first.\r
+ *\r
+ * Comparator functions should be standard functions which accept a pointer to the header of the current\r
+ * descriptor inside the configuration descriptor which is being compared, and should return a value from\r
+ * the \ref DSearch_Return_ErrorCodes_t enum as a uint8_t value.\r
+ *\r
+ * \note This function is available in USB Host mode only.\r
+ *\r
+ * \param[in,out] BytesRem Pointer to an int storing the remaining bytes in the configuration descriptor.\r
+ * \param[in,out] CurrConfigLoc Pointer to the current position in the configuration descriptor.\r
+ * \param[in] ComparatorRoutine Name of the comparator search function to use on the configuration descriptor.\r
+ *\r
+ * \return Value of one of the members of the \ref DSearch_Comp_Return_ErrorCodes_t enum.\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * uint8_t EndpointSearcher(void* CurrentDescriptor); // Comparator Prototype\r
+ * \r
+ * uint8_t EndpointSearcher(void* CurrentDescriptor)\r
+ * {\r
+ * if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)\r
+ * return DESCRIPTOR_SEARCH_Found;\r
+ * else\r
+ * return DESCRIPTOR_SEARCH_NotFound;\r
+ * }\r
+ * \r
+ * //...\r
+ * \r
+ * // After retrieving configuration descriptor:\r
+ * if (USB_Host_GetNextDescriptorComp(&BytesRemaining, &CurrentConfigLoc, EndpointSearcher) ==\r
+ * Descriptor_Search_Comp_Found)\r
+ * {\r
+ * // Do something with the endpoint descriptor\r
+ * }\r
+ * \endcode\r
+ */\r
+ uint8_t USB_GetNextDescriptorComp(uint16_t* const BytesRem,\r
+ void** const CurrConfigLoc,\r
+ ConfigComparatorPtr_t const ComparatorRoutine);\r
+\r
+ /* Inline Functions: */\r
+ /** Skips over the current sub-descriptor inside the configuration descriptor, so that the pointer then\r
+ points to the next sub-descriptor. The bytes remaining value is automatically decremented.\r
+ *\r
+ * \param[in,out] BytesRem Pointer to the number of bytes remaining of the configuration descriptor.\r
+ * \param[in,out] CurrConfigLoc Pointer to the current descriptor inside the configuration descriptor.\r
+ */\r
+ static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,\r
+ void** CurrConfigLoc) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);\r
+ static inline void USB_GetNextDescriptor(uint16_t* const BytesRem,\r
+ void** CurrConfigLoc)\r
+ {\r
+ uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size;\r
+\r
+ if (*BytesRem < CurrDescriptorSize)\r
+ CurrDescriptorSize = *BytesRem;\r
+\r
+ *CurrConfigLoc = (void*)((uintptr_t)*CurrConfigLoc + CurrDescriptorSize);\r
+ *BytesRem -= CurrDescriptorSize;\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common USB Device definitions for all architectures.\r
+ * \copydetails Group_Device\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USB\r
+ * \defgroup Group_Device Device Management\r
+ * \brief USB Device management definitions for USB device mode.\r
+ *\r
+ * USB Device mode related definitions common to all architectures. This module contains definitions which\r
+ * are used when the USB controller is initialized in device mode.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBDEVICE_H__\r
+#define __USBDEVICE_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+ #include "StdDescriptors.h"\r
+ #include "USBInterrupt.h"\r
+ #include "Endpoint.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Enums: */\r
+ /** Enum for the various states of the USB Device state machine. Only some states are\r
+ * implemented in the LUFA library - other states are left to the user to implement.\r
+ *\r
+ * For information on each possible USB device state, refer to the USB 2.0 specification.\r
+ *\r
+ * \see \ref USB_DeviceState, which stores the current device state machine state.\r
+ */\r
+ enum USB_Device_States_t\r
+ {\r
+ DEVICE_STATE_Unattached = 0, /**< Internally implemented by the library. This state indicates\r
+ * that the device is not currently connected to a host.\r
+ */\r
+ DEVICE_STATE_Powered = 1, /**< Internally implemented by the library. This state indicates\r
+ * that the device is connected to a host, but enumeration has not\r
+ * yet begun.\r
+ */\r
+ DEVICE_STATE_Default = 2, /**< Internally implemented by the library. This state indicates\r
+ * that the device's USB bus has been reset by the host and it is\r
+ * now waiting for the host to begin the enumeration process.\r
+ */\r
+ DEVICE_STATE_Addressed = 3, /**< Internally implemented by the library. This state indicates\r
+ * that the device has been addressed by the USB Host, but is not\r
+ * yet configured.\r
+ */\r
+ DEVICE_STATE_Configured = 4, /**< May be implemented by the user project. This state indicates\r
+ * that the device has been enumerated by the host and is ready\r
+ * for USB communications to begin.\r
+ */\r
+ DEVICE_STATE_Suspended = 5, /**< May be implemented by the user project. This state indicates\r
+ * that the USB bus has been suspended by the host, and the device\r
+ * should power down to a minimal power level until the bus is\r
+ * resumed.\r
+ */\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ /** Function to retrieve a given descriptor's size and memory location from the given descriptor type value,\r
+ * index and language ID. This function MUST be overridden in the user application (added with full, identical\r
+ * prototype and name so that the library can call it to retrieve descriptor data.\r
+ *\r
+ * \param[in] wValue The type of the descriptor to retrieve in the upper byte, and the index in the\r
+ * lower byte (when more than one descriptor of the given type exists, such as the\r
+ * case of string descriptors). The type may be one of the standard types defined\r
+ * in the DescriptorTypes_t enum, or may be a class-specific descriptor type value.\r
+ * \param[in] wIndex The language ID of the string to return if the \c wValue type indicates\r
+ * \ref DTYPE_String, otherwise zero for standard descriptors, or as defined in a\r
+ * class-specific standards.\r
+ * \param[out] DescriptorAddress Pointer to the descriptor in memory. This should be set by the routine to\r
+ * the address of the descriptor.\r
+ * \param[out] DescriptorMemorySpace A value from the \ref USB_DescriptorMemorySpaces_t enum to indicate the memory\r
+ * space in which the descriptor is stored. This parameter does not exist when one\r
+ * of the \c USE_*_DESCRIPTORS compile time options is used, or on architectures which\r
+ * use a unified address space.\r
+ *\r
+ * \note By default, the library expects all descriptors to be located in flash memory via the \c PROGMEM attribute.\r
+ * If descriptors should be located in RAM or EEPROM instead (to speed up access in the case of RAM, or to\r
+ * allow the descriptors to be changed dynamically at runtime) either the \c USE_RAM_DESCRIPTORS or the\r
+ * \c USE_EEPROM_DESCRIPTORS tokens may be defined in the project makefile and passed to the compiler by the -D\r
+ * switch.\r
+ *\r
+ * \return Size in bytes of the descriptor if it exists, zero or \ref NO_DESCRIPTOR otherwise.\r
+ */\r
+ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,\r
+ const uint8_t wIndex,\r
+ const void** const DescriptorAddress\r
+ #if (defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__)) && \\r
+ !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS))\r
+ , uint8_t* const DescriptorMemorySpace\r
+ #endif\r
+ ) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /* Architecture Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/Device_AVR8.h"\r
+ #elif (ARCH == ARCH_UC3)\r
+ #include "UC3/Device_UC3.h"\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ #include "XMEGA/Device_XMEGA.h"\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#define __INCLUDE_FROM_DEVICESTDREQ_C\r
+#include "DeviceStandardReq.h"\r
+\r
+uint8_t USB_Device_ConfigurationNumber;\r
+\r
+#if !defined(NO_DEVICE_SELF_POWER)\r
+bool USB_Device_CurrentlySelfPowered;\r
+#endif\r
+\r
+#if !defined(NO_DEVICE_REMOTE_WAKEUP)\r
+bool USB_Device_RemoteWakeupEnabled;\r
+#endif\r
+\r
+void USB_Device_ProcessControlRequest(void)\r
+{\r
+ #if defined(ARCH_BIG_ENDIAN)\r
+ USB_ControlRequest.bmRequestType = Endpoint_Read_8();\r
+ USB_ControlRequest.bRequest = Endpoint_Read_8();\r
+ USB_ControlRequest.wValue = Endpoint_Read_16_LE();\r
+ USB_ControlRequest.wIndex = Endpoint_Read_16_LE();\r
+ USB_ControlRequest.wLength = Endpoint_Read_16_LE();\r
+ #else\r
+ uint8_t* RequestHeader = (uint8_t*)&USB_ControlRequest;\r
+\r
+ for (uint8_t RequestHeaderByte = 0; RequestHeaderByte < sizeof(USB_Request_Header_t); RequestHeaderByte++)\r
+ *(RequestHeader++) = Endpoint_Read_8();\r
+ #endif\r
+\r
+ EVENT_USB_Device_ControlRequest();\r
+\r
+ if (Endpoint_IsSETUPReceived())\r
+ {\r
+ uint8_t bmRequestType = USB_ControlRequest.bmRequestType;\r
+\r
+ switch (USB_ControlRequest.bRequest)\r
+ {\r
+ case REQ_GetStatus:\r
+ if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||\r
+ (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT)))\r
+ {\r
+ USB_Device_GetStatus();\r
+ }\r
+\r
+ break;\r
+ case REQ_ClearFeature:\r
+ case REQ_SetFeature:\r
+ if ((bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE)) ||\r
+ (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT)))\r
+ {\r
+ USB_Device_ClearSetFeature();\r
+ }\r
+\r
+ break;\r
+ case REQ_SetAddress:\r
+ if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))\r
+ USB_Device_SetAddress();\r
+\r
+ break;\r
+ case REQ_GetDescriptor:\r
+ if ((bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE)) ||\r
+ (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE)))\r
+ {\r
+ USB_Device_GetDescriptor();\r
+ }\r
+\r
+ break;\r
+ case REQ_GetConfiguration:\r
+ if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE))\r
+ USB_Device_GetConfiguration();\r
+\r
+ break;\r
+ case REQ_SetConfiguration:\r
+ if (bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE))\r
+ USB_Device_SetConfiguration();\r
+\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (Endpoint_IsSETUPReceived())\r
+ {\r
+ Endpoint_StallTransaction();\r
+ Endpoint_ClearSETUP();\r
+ }\r
+}\r
+\r
+static void USB_Device_SetAddress(void)\r
+{\r
+ uint8_t DeviceAddress = (USB_ControlRequest.wValue & 0x7F);\r
+ uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+ GlobalInterruptDisable();\r
+\r
+ Endpoint_ClearSETUP();\r
+\r
+ Endpoint_ClearStatusStage();\r
+\r
+ while (!(Endpoint_IsINReady()));\r
+\r
+ USB_Device_SetDeviceAddress(DeviceAddress);\r
+ USB_DeviceState = (DeviceAddress) ? DEVICE_STATE_Addressed : DEVICE_STATE_Default;\r
+\r
+ SetGlobalInterruptMask(CurrentGlobalInt);\r
+}\r
+\r
+static void USB_Device_SetConfiguration(void)\r
+{\r
+ #if defined(FIXED_NUM_CONFIGURATIONS)\r
+ if ((uint8_t)USB_ControlRequest.wValue > FIXED_NUM_CONFIGURATIONS)\r
+ return;\r
+ #else\r
+ USB_Descriptor_Device_t* DevDescriptorPtr;\r
+\r
+ #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE)\r
+ #if defined(USE_FLASH_DESCRIPTORS)\r
+ #define MemoryAddressSpace MEMSPACE_FLASH\r
+ #elif defined(USE_EEPROM_DESCRIPTORS)\r
+ #define MemoryAddressSpace MEMSPACE_EEPROM\r
+ #elif defined(USE_SRAM_DESCRIPTORS)\r
+ #define MemoryAddressSpace MEMSPACE_SRAM\r
+ #else\r
+ uint8_t MemoryAddressSpace;\r
+ #endif\r
+ #endif\r
+\r
+ if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DevDescriptorPtr\r
+ #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \\r
+ !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS))\r
+ , &MemoryAddressSpace\r
+ #endif\r
+ ) == NO_DESCRIPTOR)\r
+ {\r
+ return;\r
+ }\r
+\r
+ #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE)\r
+ if (MemoryAddressSpace == MEMSPACE_FLASH)\r
+ {\r
+ if (((uint8_t)USB_ControlRequest.wValue > pgm_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))\r
+ return;\r
+ }\r
+ else if (MemoryAddressSpace == MEMSPACE_EEPROM)\r
+ {\r
+ if (((uint8_t)USB_ControlRequest.wValue > eeprom_read_byte(&DevDescriptorPtr->NumberOfConfigurations)))\r
+ return;\r
+ }\r
+ else\r
+ {\r
+ if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations)\r
+ return;\r
+ }\r
+ #else\r
+ if ((uint8_t)USB_ControlRequest.wValue > DevDescriptorPtr->NumberOfConfigurations)\r
+ return;\r
+ #endif\r
+ #endif\r
+\r
+ Endpoint_ClearSETUP();\r
+\r
+ USB_Device_ConfigurationNumber = (uint8_t)USB_ControlRequest.wValue;\r
+\r
+ Endpoint_ClearStatusStage();\r
+\r
+ if (USB_Device_ConfigurationNumber)\r
+ USB_DeviceState = DEVICE_STATE_Configured;\r
+ else\r
+ USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;\r
+\r
+ EVENT_USB_Device_ConfigurationChanged();\r
+}\r
+\r
+static void USB_Device_GetConfiguration(void)\r
+{\r
+ Endpoint_ClearSETUP();\r
+\r
+ Endpoint_Write_8(USB_Device_ConfigurationNumber);\r
+ Endpoint_ClearIN();\r
+\r
+ Endpoint_ClearStatusStage();\r
+}\r
+\r
+#if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)\r
+static void USB_Device_GetInternalSerialDescriptor(void)\r
+{\r
+ struct\r
+ {\r
+ USB_Descriptor_Header_t Header;\r
+ uint16_t UnicodeString[INTERNAL_SERIAL_LENGTH_BITS / 4];\r
+ } SignatureDescriptor;\r
+\r
+ SignatureDescriptor.Header.Type = DTYPE_String;\r
+ SignatureDescriptor.Header.Size = USB_STRING_LEN(INTERNAL_SERIAL_LENGTH_BITS / 4);\r
+\r
+ USB_Device_GetSerialString(SignatureDescriptor.UnicodeString);\r
+\r
+ Endpoint_ClearSETUP();\r
+\r
+ Endpoint_Write_Control_Stream_LE(&SignatureDescriptor, sizeof(SignatureDescriptor));\r
+ Endpoint_ClearOUT();\r
+}\r
+#endif\r
+\r
+static void USB_Device_GetDescriptor(void)\r
+{\r
+ const void* DescriptorPointer;\r
+ uint16_t DescriptorSize;\r
+\r
+ #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \\r
+ !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS))\r
+ uint8_t DescriptorAddressSpace;\r
+ #endif\r
+\r
+ #if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)\r
+ if (USB_ControlRequest.wValue == ((DTYPE_String << 8) | USE_INTERNAL_SERIAL))\r
+ {\r
+ USB_Device_GetInternalSerialDescriptor();\r
+ return;\r
+ }\r
+ #endif\r
+\r
+ if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex,\r
+ &DescriptorPointer\r
+ #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \\r
+ !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS))\r
+ , &DescriptorAddressSpace\r
+ #endif\r
+ )) == NO_DESCRIPTOR)\r
+ {\r
+ return;\r
+ }\r
+\r
+ Endpoint_ClearSETUP();\r
+\r
+ #if defined(USE_RAM_DESCRIPTORS) || !defined(ARCH_HAS_MULTI_ADDRESS_SPACE)\r
+ Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize);\r
+ #elif defined(USE_EEPROM_DESCRIPTORS)\r
+ Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize);\r
+ #elif defined(USE_FLASH_DESCRIPTORS)\r
+ Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize);\r
+ #else\r
+ if (DescriptorAddressSpace == MEMSPACE_FLASH)\r
+ Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize);\r
+ else if (DescriptorAddressSpace == MEMSPACE_EEPROM)\r
+ Endpoint_Write_Control_EStream_LE(DescriptorPointer, DescriptorSize);\r
+ else\r
+ Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize);\r
+ #endif\r
+\r
+ Endpoint_ClearOUT();\r
+}\r
+\r
+static void USB_Device_GetStatus(void)\r
+{\r
+ uint8_t CurrentStatus = 0;\r
+\r
+ switch (USB_ControlRequest.bmRequestType)\r
+ {\r
+ case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE):\r
+ #if !defined(NO_DEVICE_SELF_POWER)\r
+ if (USB_Device_CurrentlySelfPowered)\r
+ CurrentStatus |= FEATURE_SELFPOWERED_ENABLED;\r
+ #endif\r
+\r
+ #if !defined(NO_DEVICE_REMOTE_WAKEUP)\r
+ if (USB_Device_RemoteWakeupEnabled)\r
+ CurrentStatus |= FEATURE_REMOTE_WAKEUP_ENABLED;\r
+ #endif\r
+ break;\r
+ case (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_ENDPOINT):\r
+ #if !defined(CONTROL_ONLY_DEVICE)\r
+ Endpoint_SelectEndpoint((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK);\r
+\r
+ CurrentStatus = Endpoint_IsStalled();\r
+\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+ #endif\r
+\r
+ break;\r
+ default:\r
+ return;\r
+ }\r
+\r
+ Endpoint_ClearSETUP();\r
+\r
+ Endpoint_Write_16_LE(CurrentStatus);\r
+ Endpoint_ClearIN();\r
+\r
+ Endpoint_ClearStatusStage();\r
+}\r
+\r
+static void USB_Device_ClearSetFeature(void)\r
+{\r
+ switch (USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_RECIPIENT)\r
+ {\r
+ #if !defined(NO_DEVICE_REMOTE_WAKEUP)\r
+ case REQREC_DEVICE:\r
+ if ((uint8_t)USB_ControlRequest.wValue == FEATURE_SEL_DeviceRemoteWakeup)\r
+ USB_Device_RemoteWakeupEnabled = (USB_ControlRequest.bRequest == REQ_SetFeature);\r
+ else\r
+ return;\r
+\r
+ break;\r
+ #endif\r
+ #if !defined(CONTROL_ONLY_DEVICE)\r
+ case REQREC_ENDPOINT:\r
+ if ((uint8_t)USB_ControlRequest.wValue == FEATURE_SEL_EndpointHalt)\r
+ {\r
+ uint8_t EndpointIndex = ((uint8_t)USB_ControlRequest.wIndex & ENDPOINT_EPNUM_MASK);\r
+\r
+ if (EndpointIndex == ENDPOINT_CONTROLEP)\r
+ return;\r
+\r
+ Endpoint_SelectEndpoint(EndpointIndex);\r
+\r
+ if (Endpoint_IsEnabled())\r
+ {\r
+ if (USB_ControlRequest.bRequest == REQ_SetFeature)\r
+ {\r
+ Endpoint_StallTransaction();\r
+ }\r
+ else\r
+ {\r
+ Endpoint_ClearStall();\r
+ Endpoint_ResetEndpoint(EndpointIndex);\r
+ Endpoint_ResetDataToggle();\r
+ }\r
+ }\r
+ }\r
+\r
+ break;\r
+ #endif\r
+ default:\r
+ return;\r
+ }\r
+\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+\r
+ Endpoint_ClearSETUP();\r
+\r
+ Endpoint_ClearStatusStage();\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB device standard request management.\r
+ *\r
+ * This file contains the function prototypes necessary for the processing of incoming standard control requests\r
+ * when the library is in USB device mode.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+#ifndef __DEVICESTDREQ_H__\r
+#define __DEVICESTDREQ_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+ #include "StdDescriptors.h"\r
+ #include "Events.h"\r
+ #include "StdRequestType.h"\r
+ #include "USBTask.h"\r
+ #include "USBController.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Enums: */\r
+ #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) || defined(__DOXYGEN__)\r
+ /** Enum for the possible descriptor memory spaces, for the \c MemoryAddressSpace parameter of the\r
+ * \ref CALLBACK_USB_GetDescriptor() function. This can be used when none of the \c USE_*_DESCRIPTORS\r
+ * compile time options are used, to indicate in which memory space the descriptor is stored.\r
+ *\r
+ * \ingroup Group_Device\r
+ */\r
+ enum USB_DescriptorMemorySpaces_t\r
+ {\r
+ #if defined(ARCH_HAS_FLASH_ADDRESS_SPACE) || defined(__DOXYGEN__)\r
+ MEMSPACE_FLASH = 0, /**< Indicates the requested descriptor is located in FLASH memory. */\r
+ #endif\r
+ #if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE) || defined(__DOXYGEN__)\r
+ MEMSPACE_EEPROM = 1, /**< Indicates the requested descriptor is located in EEPROM memory. */\r
+ #endif\r
+ MEMSPACE_RAM = 2, /**< Indicates the requested descriptor is located in RAM memory. */\r
+ };\r
+ #endif\r
+\r
+ /* Global Variables: */\r
+ /** Indicates the currently set configuration number of the device. USB devices may have several\r
+ * different configurations which the host can select between; this indicates the currently selected\r
+ * value, or 0 if no configuration has been selected.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ *\r
+ * \ingroup Group_Device\r
+ */\r
+ extern uint8_t USB_Device_ConfigurationNumber;\r
+\r
+ #if !defined(NO_DEVICE_REMOTE_WAKEUP)\r
+ /** Indicates if the host is currently allowing the device to issue remote wakeup events. If this\r
+ * flag is cleared, the device should not issue remote wakeup events to the host.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ *\r
+ * \note To reduce FLASH usage of the compiled applications where Remote Wakeup is not supported,\r
+ * this global and the underlying management code can be disabled by defining the\r
+ * \c NO_DEVICE_REMOTE_WAKEUP token in the project makefile and passing it to the compiler via\r
+ * the -D switch.\r
+ *\r
+ * \ingroup Group_Device\r
+ */\r
+ extern bool USB_Device_RemoteWakeupEnabled;\r
+ #endif\r
+\r
+ #if !defined(NO_DEVICE_SELF_POWER)\r
+ /** Indicates if the device is currently being powered by its own power supply, rather than being\r
+ * powered by the host's USB supply. This flag should remain cleared if the device does not\r
+ * support self powered mode, as indicated in the device descriptors.\r
+ *\r
+ * \ingroup Group_Device\r
+ */\r
+ extern bool USB_Device_CurrentlySelfPowered;\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ #if defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)\r
+ #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.\r
+ #elif defined(USE_RAM_DESCRIPTORS) && defined(USE_FLASH_DESCRIPTORS)\r
+ #error USE_RAM_DESCRIPTORS and USE_FLASH_DESCRIPTORS are mutually exclusive.\r
+ #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS)\r
+ #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.\r
+ #elif defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS)\r
+ #error Only one of the USE_*_DESCRIPTORS modes should be selected.\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ void USB_Device_ProcessControlRequest(void);\r
+\r
+ #if defined(__INCLUDE_FROM_DEVICESTDREQ_C)\r
+ static void USB_Device_SetAddress(void);\r
+ static void USB_Device_SetConfiguration(void);\r
+ static void USB_Device_GetConfiguration(void);\r
+ static void USB_Device_GetDescriptor(void);\r
+ static void USB_Device_GetStatus(void);\r
+ static void USB_Device_ClearSetFeature(void);\r
+\r
+ #if !defined(NO_INTERNAL_SERIAL) && (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)\r
+ static void USB_Device_GetInternalSerialDescriptor(void);\r
+ #endif\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Endpoint definitions for all architectures.\r
+ * \copydetails Group_EndpointManagement\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_EndpointManagement\r
+ * \defgroup Group_EndpointRW Endpoint Data Reading and Writing\r
+ * \brief Endpoint data read/write definitions.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointRW\r
+ * \defgroup Group_EndpointPrimitiveRW Read/Write of Primitive Data Types\r
+ * \brief Endpoint data primitive read/write definitions.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of primitive data types\r
+ * from and to endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointManagement\r
+ * \defgroup Group_EndpointPacketManagement Endpoint Packet Management\r
+ * \brief USB Endpoint package management definitions.\r
+ *\r
+ * Functions, macros, variables, enums and types related to packet management of endpoints.\r
+ */\r
+\r
+/** \ingroup Group_USB\r
+ * \defgroup Group_EndpointManagement Endpoint Management\r
+ * \brief Endpoint management definitions.\r
+ *\r
+ * Functions, macros and enums related to endpoint management when in USB Device mode. This\r
+ * module contains the endpoint management macros, as well as endpoint interrupt and data\r
+ * send/receive functions for various data types.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __ENDPOINT_H__\r
+#define __ENDPOINT_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** Type define for a endpoint table entry, used to configure endpoints in groups via\r
+ * \ref Endpoint_ConfigureEndpointTable().\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t Address; /**< Address of the endpoint to configure, or zero if the table entry is to be unused. */\r
+ uint16_t Size; /**< Size of the endpoint bank, in bytes. */\r
+ uint8_t Type; /**< Type of the endpoint, a \c EP_TYPE_* mask. */\r
+ uint8_t Banks; /**< Number of hardware banks to use for the endpoint. */\r
+ } USB_Endpoint_Table_t;\r
+ \r
+ /* Macros: */\r
+ /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's\r
+ * numerical address in the device.\r
+ */\r
+ #define ENDPOINT_EPNUM_MASK 0x0F\r
+\r
+ /** Endpoint address for the default control endpoint, which always resides in address 0. This is\r
+ * defined for convenience to give more readable code when used with the endpoint macros.\r
+ */\r
+ #define ENDPOINT_CONTROLEP 0\r
+\r
+ /* Architecture Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/Endpoint_AVR8.h"\r
+ #elif (ARCH == ARCH_UC3)\r
+ #include "UC3/Endpoint_UC3.h"\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ #include "XMEGA/Endpoint_XMEGA.h"\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Endpoint data stream transmission and reception management.\r
+ * \copydetails Group_EndpointStreamRW\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_EndpointRW\r
+ * \defgroup Group_EndpointStreamRW Read/Write of Multi-Byte Streams\r
+ * \brief Endpoint data stream transmission and reception management.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of data streams from\r
+ * and to endpoints.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __ENDPOINT_STREAM_H__\r
+#define __ENDPOINT_STREAM_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Enums: */\r
+ /** Enum for the possible error return codes of the \c Endpoint_*_Stream_* functions. */\r
+ enum Endpoint_Stream_RW_ErrorCodes_t\r
+ {\r
+ ENDPOINT_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */\r
+ ENDPOINT_RWSTREAM_EndpointStalled = 1, /**< The endpoint was stalled during the stream\r
+ * transfer by the host or device.\r
+ */\r
+ ENDPOINT_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during\r
+ * the transfer.\r
+ */\r
+ ENDPOINT_RWSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and\r
+ * no USB endpoint traffic can occur until the bus\r
+ * has resumed.\r
+ */\r
+ ENDPOINT_RWSTREAM_Timeout = 4, /**< The host failed to accept or send the next packet\r
+ * within the software timeout period set by the\r
+ * \ref USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ ENDPOINT_RWSTREAM_IncompleteTransfer = 5, /**< Indicates that the endpoint bank became full or empty before\r
+ * the complete contents of the current stream could be\r
+ * transferred. The endpoint stream function should be called\r
+ * again to process the next chunk of data in the transfer.\r
+ */\r
+ };\r
+\r
+ /** Enum for the possible error return codes of the \c Endpoint_*_Control_Stream_* functions. */\r
+ enum Endpoint_ControlStream_RW_ErrorCodes_t\r
+ {\r
+ ENDPOINT_RWCSTREAM_NoError = 0, /**< Command completed successfully, no error. */\r
+ ENDPOINT_RWCSTREAM_HostAborted = 1, /**< The aborted the transfer prematurely. */\r
+ ENDPOINT_RWCSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during\r
+ * the transfer.\r
+ */\r
+ ENDPOINT_RWCSTREAM_BusSuspended = 3, /**< The USB bus has been suspended by the host and\r
+ * no USB endpoint traffic can occur until the bus\r
+ * has resumed.\r
+ */\r
+ };\r
+\r
+ /* Architecture Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/EndpointStream_AVR8.h"\r
+ #elif (ARCH == ARCH_UC3)\r
+ #include "UC3/EndpointStream_UC3.h"\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ #include "XMEGA/EndpointStream_XMEGA.h"\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_EVENTS_C\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "Events.h"\r
+\r
+// cppcheck-suppress unusedFunction\r
+void USB_Event_Stub(void)\r
+{\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Event management definitions.\r
+ * \copydetails Group_Events\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USB\r
+ * \defgroup Group_Events USB Events\r
+ * \brief USB Event management definitions.\r
+ *\r
+ * This module contains macros and functions relating to the management of library events, which are small\r
+ * pieces of code similar to ISRs which are run when a given condition is met. Each event can be fired from\r
+ * multiple places in the user or library code, which may or may not be inside an ISR, thus each handler\r
+ * should be written to be as small and fast as possible to prevent possible problems.\r
+ *\r
+ * Events can be hooked by the user application by declaring a handler function with the same name and parameters\r
+ * listed here. If an event with no user-associated handler is fired within the library, it by default maps to an\r
+ * internal empty stub function.\r
+ *\r
+ * Each event must only have one associated event handler, but can be raised by multiple sources by calling the\r
+ * event handler function (with any required event parameters).\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBEVENTS_H__\r
+#define __USBEVENTS_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Pseudo-Functions for Doxygen: */\r
+ #if !defined(__INCLUDE_FROM_EVENTS_C) || defined(__DOXYGEN__)\r
+ /** Event for USB mode pin level change. This event fires when the USB interface is set to dual role\r
+ * mode, and the UID pin level has changed to indicate a new mode (device or host). This event fires\r
+ * before the mode is switched to the newly indicated mode but after the \ref EVENT_USB_Device_Disconnect\r
+ * event has fired (if disconnected before the role change).\r
+ *\r
+ * \note This event only exists on microcontrollers that support dual role USB modes.\r
+ * \n\n\r
+ *\r
+ * \note This event does not exist if the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY tokens have been supplied\r
+ * to the compiler (see \ref Group_USBManagement documentation).\r
+ */\r
+ void EVENT_USB_UIDChange(void);\r
+\r
+ /** Event for USB host error. This event fires when a hardware fault has occurred whilst the USB\r
+ * interface is in host mode.\r
+ *\r
+ * \param[in] ErrorCode Error code indicating the failure reason, a value in \ref USB_Host_ErrorCodes_t.\r
+ *\r
+ * \note This event only exists on microcontrollers that supports USB host mode.\r
+ * \n\n\r
+ *\r
+ * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see\r
+ * \ref Group_USBManagement documentation).\r
+ */\r
+ void EVENT_USB_Host_HostError(const uint8_t ErrorCode);\r
+\r
+ /** Event for USB device attachment. This event fires when a the USB interface is in host mode, and\r
+ * a USB device has been connected to the USB interface. This is interrupt driven, thus fires before\r
+ * the standard \ref EVENT_USB_Device_Connect() event and so can be used to programmatically start the USB\r
+ * management task to reduce CPU consumption.\r
+ *\r
+ * \note This event only exists on microcontrollers that supports USB host mode.\r
+ * \n\n\r
+ *\r
+ * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see\r
+ * \ref Group_USBManagement documentation).\r
+ *\r
+ * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage.\r
+ */\r
+ void EVENT_USB_Host_DeviceAttached(void);\r
+\r
+ /** Event for USB device removal. This event fires when a the USB interface is in host mode, and\r
+ * a USB device has been removed the USB interface whether or not it has been enumerated. This\r
+ * can be used to programmatically stop the USB management task to reduce CPU consumption.\r
+ *\r
+ * \note This event only exists on microcontrollers that supports USB host mode.\r
+ * \n\n\r
+ *\r
+ * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see\r
+ * \ref Group_USBManagement documentation).\r
+ *\r
+ * \see \ref USB_USBTask() for more information on the USB management task and reducing CPU usage.\r
+ */\r
+ void EVENT_USB_Host_DeviceUnattached(void);\r
+\r
+ /** Event for USB device enumeration failure. This event fires when a the USB interface is\r
+ * in host mode, and an attached USB device has failed to enumerate completely.\r
+ *\r
+ * \param[in] ErrorCode Error code indicating the failure reason, a value in\r
+ * \ref USB_Host_EnumerationErrorCodes_t.\r
+ *\r
+ * \param[in] SubErrorCode Sub error code indicating the reason for failure - for example, if the\r
+ * ErrorCode parameter indicates a control error, this will give the error\r
+ * code returned by the \ref USB_Host_SendControlRequest() function.\r
+ *\r
+ * \note This event only exists on microcontrollers that supports USB host mode.\r
+ * \n\n\r
+ *\r
+ * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see\r
+ * \ref Group_USBManagement documentation).\r
+ */\r
+ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,\r
+ const uint8_t SubErrorCode);\r
+\r
+ /** Event for USB device enumeration completion. This event fires when a the USB interface is\r
+ * in host mode and an attached USB device has been completely enumerated and is ready to be\r
+ * controlled by the user application.\r
+ *\r
+ * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around\r
+ * 1 second) when a transaction is waiting to be processed by the device will prevent break communications\r
+ * and cause the host to reset the USB bus.\r
+ */\r
+ void EVENT_USB_Host_DeviceEnumerationComplete(void);\r
+\r
+ /** Event for USB Start Of Frame detection, when enabled. This event fires at the start of each USB\r
+ * frame, once per millisecond, and is synchronized to the USB bus. This can be used as an accurate\r
+ * millisecond timer source when the USB bus is not suspended while in host mode.\r
+ *\r
+ * This event is time-critical; it is run once per millisecond and thus long handlers will significantly\r
+ * degrade device performance. This event should only be enabled when needed to reduce device wake-ups.\r
+ *\r
+ * \note This event is not normally active - it must be manually enabled and disabled via the\r
+ * \ref USB_Host_EnableSOFEvents() and \ref USB_Host_DisableSOFEvents() commands after enumeration of\r
+ * a USB device.\r
+ * \n\n\r
+ *\r
+ * \note This event does not exist if the \c USB_DEVICE_ONLY token is supplied to the compiler (see\r
+ * \ref Group_USBManagement documentation).\r
+ */\r
+ void EVENT_USB_Host_StartOfFrame(void);\r
+\r
+ /** Event for USB device connection. This event fires when the microcontroller is in USB Device mode\r
+ * and the device is connected to a USB host, beginning the enumeration process measured by a rising\r
+ * level on the microcontroller's VBUS sense pin.\r
+ *\r
+ * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around\r
+ * two seconds) will prevent the device from enumerating correctly.\r
+ *\r
+ * \attention This event may fire multiple times during device enumeration on the microcontrollers with limited USB controllers\r
+ * if \c NO_LIMITED_CONTROLLER_CONNECT is not defined.\r
+ *\r
+ * \note For the microcontrollers with limited USB controller functionality, VBUS sensing is not available.\r
+ * this means that the current connection state is derived from the bus suspension and wake up events by default,\r
+ * which is not always accurate (host may suspend the bus while still connected). If the actual connection state\r
+ * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behavior turned off by\r
+ * passing the \c NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection\r
+ * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually.\r
+ * \n\n\r
+ *\r
+ * \see \ref Group_USBManagement for more information on the USB management task and reducing CPU usage.\r
+ */\r
+ void EVENT_USB_Device_Connect(void);\r
+\r
+ /** Event for USB device disconnection. This event fires when the microcontroller is in USB Device mode and the device is\r
+ * disconnected from a host, measured by a falling level on the microcontroller's VBUS sense pin.\r
+ *\r
+ * \attention This event may fire multiple times during device enumeration on the microcontrollers with limited USB controllers\r
+ * if \c NO_LIMITED_CONTROLLER_CONNECT is not defined.\r
+ *\r
+ * \note For the microcontrollers with limited USB controllers, VBUS sense is not available to the USB controller.\r
+ * this means that the current connection state is derived from the bus suspension and wake up events by default,\r
+ * which is not always accurate (host may suspend the bus while still connected). If the actual connection state\r
+ * needs to be determined, VBUS should be routed to an external pin, and the auto-detect behavior turned off by\r
+ * passing the \c NO_LIMITED_CONTROLLER_CONNECT token to the compiler via the -D switch at compile time. The connection\r
+ * and disconnection events may be manually fired, and the \ref USB_DeviceState global changed manually.\r
+ * \n\n\r
+ *\r
+ * \see \ref Group_USBManagement for more information on the USB management task and reducing CPU usage.\r
+ */\r
+ void EVENT_USB_Device_Disconnect(void);\r
+\r
+ /** Event for control requests. This event fires when a the USB host issues a control request\r
+ * to the mandatory device control endpoint (of address 0). This may either be a standard\r
+ * request that the library may have a handler code for internally, or a class specific request\r
+ * issued to the device which must be handled appropriately. If a request is not processed in the\r
+ * user application via this event, it will be passed to the library for processing internally\r
+ * if a suitable handler exists.\r
+ *\r
+ * This event is time-critical; each packet within the request transaction must be acknowledged or\r
+ * sent within 50ms or the host will abort the transfer.\r
+ *\r
+ * The library internally handles all standard control requests with the exceptions of SYNC FRAME,\r
+ * SET DESCRIPTOR and SET INTERFACE. These and all other non-standard control requests will be left\r
+ * for the user to process via this event if desired. If not handled in the user application or by\r
+ * the library internally, unknown requests are automatically STALLed.\r
+ *\r
+ * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see\r
+ * \ref Group_USBManagement documentation).\r
+ * \n\n\r
+ *\r
+ * \note Requests should be handled in the same manner as described in the USB 2.0 Specification,\r
+ * or appropriate class specification. In all instances, the library has already read the\r
+ * request SETUP parameters into the \ref USB_ControlRequest structure which should then be used\r
+ * by the application to determine how to handle the issued request.\r
+ */\r
+ void EVENT_USB_Device_ControlRequest(void);\r
+\r
+ /** Event for USB configuration number changed. This event fires when a the USB host changes the\r
+ * selected configuration number while in device mode. This event should be hooked in device\r
+ * applications to create the endpoints and configure the device for the selected configuration.\r
+ *\r
+ * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around\r
+ * one second) will prevent the device from enumerating correctly.\r
+ *\r
+ * This event fires after the value of \ref USB_Device_ConfigurationNumber has been changed.\r
+ *\r
+ * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see\r
+ * \ref Group_USBManagement documentation).\r
+ */\r
+ void EVENT_USB_Device_ConfigurationChanged(void);\r
+\r
+ /** Event for USB suspend. This event fires when a the USB host suspends the device by halting its\r
+ * transmission of Start Of Frame pulses to the device. This is generally hooked in order to move\r
+ * the device over to a low power state until the host wakes up the device. If the USB interface is\r
+ * enumerated with the \ref USB_OPT_AUTO_PLL option set, the library will automatically suspend the\r
+ * USB PLL before the event is fired to save power.\r
+ *\r
+ * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see\r
+ * \ref Group_USBManagement documentation).\r
+ * \n\n\r
+ *\r
+ * \note This event does not exist on the microcontrollers with limited USB VBUS sensing abilities\r
+ * when the \c NO_LIMITED_CONTROLLER_CONNECT compile time token is not set - see\r
+ * \ref EVENT_USB_Device_Disconnect.\r
+ *\r
+ * \see \ref EVENT_USB_Device_WakeUp() event for accompanying Wake Up event.\r
+ */\r
+ void EVENT_USB_Device_Suspend(void);\r
+\r
+ /** Event for USB wake up. This event fires when a the USB interface is suspended while in device\r
+ * mode, and the host wakes up the device by supplying Start Of Frame pulses. This is generally\r
+ * hooked to pull the user application out of a low power state and back into normal operating\r
+ * mode. If the USB interface is enumerated with the \ref USB_OPT_AUTO_PLL option set, the library\r
+ * will automatically restart the USB PLL before the event is fired.\r
+ *\r
+ * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see\r
+ * \ref Group_USBManagement documentation).\r
+ * \n\n\r
+ *\r
+ * \note This event does not exist on the microcontrollers with limited USB VBUS sensing abilities\r
+ * when the \c NO_LIMITED_CONTROLLER_CONNECT compile time token is not set - see\r
+ * \ref EVENT_USB_Device_Disconnect.\r
+ *\r
+ * \see \ref EVENT_USB_Device_Suspend() event for accompanying Suspend event.\r
+ */\r
+ void EVENT_USB_Device_WakeUp(void);\r
+\r
+ /** Event for USB interface reset. This event fires when the USB interface is in device mode, and\r
+ * a the USB host requests that the device reset its interface. This event fires after the control\r
+ * endpoint has been automatically configured by the library.\r
+ *\r
+ * This event is time-critical; exceeding OS-specific delays within this event handler (typically of around\r
+ * two seconds) will prevent the device from enumerating correctly.\r
+ *\r
+ * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see\r
+ * \ref Group_USBManagement documentation).\r
+ */\r
+ void EVENT_USB_Device_Reset(void);\r
+\r
+ /** Event for USB Start Of Frame detection, when enabled. This event fires at the start of each USB\r
+ * frame, once per millisecond, and is synchronized to the USB bus. This can be used as an accurate\r
+ * millisecond timer source when the USB bus is enumerated in device mode to a USB host.\r
+ *\r
+ * This event is time-critical; it is run once per millisecond and thus long handlers will significantly\r
+ * degrade device performance. This event should only be enabled when needed to reduce device wake-ups.\r
+ *\r
+ * \pre This event is not normally active - it must be manually enabled and disabled via the\r
+ * \ref USB_Device_EnableSOFEvents() and \ref USB_Device_DisableSOFEvents() commands after enumeration.\r
+ * \n\n\r
+ *\r
+ * \note This event does not exist if the \c USB_HOST_ONLY token is supplied to the compiler (see\r
+ * \ref Group_USBManagement documentation).\r
+ */\r
+ void EVENT_USB_Device_StartOfFrame(void);\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_EVENTS_C)\r
+ void USB_Event_Stub(void) ATTR_CONST;\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ void EVENT_USB_UIDChange(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ void EVENT_USB_Host_HostError(const uint8_t ErrorCode) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ void EVENT_USB_Host_DeviceAttached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ void EVENT_USB_Host_DeviceUnattached(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ void EVENT_USB_Host_DeviceEnumerationComplete(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,\r
+ const uint8_t SubErrorCode)\r
+ ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ void EVENT_USB_Host_StartOfFrame(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ void EVENT_USB_Device_Connect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ void EVENT_USB_Device_Disconnect(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ void EVENT_USB_Device_ControlRequest(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ void EVENT_USB_Device_ConfigurationChanged(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ void EVENT_USB_Device_Suspend(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ void EVENT_USB_Device_WakeUp(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ void EVENT_USB_Device_Reset(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ void EVENT_USB_Device_StartOfFrame(void) ATTR_WEAK ATTR_ALIAS(USB_Event_Stub);\r
+ #endif\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common USB Host definitions for all architectures.\r
+ * \copydetails Group_Host\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USB\r
+ * \defgroup Group_Host Host Management\r
+ * \brief USB Host management definitions for USB host mode.\r
+ *\r
+ * USB Host mode related macros and enums. This module contains macros and enums which are used when\r
+ * the USB controller is initialized in host mode.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBHOST_H__\r
+#define __USBHOST_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Enums: */\r
+ /** Enum for the various states of the USB Host state machine.\r
+ *\r
+ * For information on each possible USB host state, refer to the USB 2.0 specification.\r
+ * Several of the USB host states are broken up further into multiple smaller sub-states,\r
+ * so that they can be internally implemented inside the library in an efficient manner.\r
+ *\r
+ * \see \ref USB_HostState, which stores the current host state machine state.\r
+ */\r
+ enum USB_Host_States_t\r
+ {\r
+ HOST_STATE_WaitForDevice = 0, /**< This state indicates that the stack is waiting for an interval\r
+ * to elapse before continuing with the next step of the device\r
+ * enumeration process.\r
+ */\r
+ HOST_STATE_Unattached = 1, /**< This state indicates that the host state machine is waiting for\r
+ * a device to be attached so that it can start the enumeration process.\r
+ */\r
+ HOST_STATE_Powered = 2, /**< This state indicates that a device has been attached, and the\r
+ * library's internals are being configured to begin the enumeration\r
+ * process.\r
+ */\r
+ HOST_STATE_Powered_WaitForDeviceSettle = 3, /**< This state indicates that the stack is waiting for the initial\r
+ * settling period to elapse before beginning the enumeration process.\r
+ */\r
+ HOST_STATE_Powered_WaitForConnect = 4, /**< This state indicates that the stack is waiting for a connection event\r
+ * from the USB controller to indicate a valid USB device has been attached\r
+ * to the bus and is ready to be enumerated.\r
+ */\r
+ HOST_STATE_Powered_DoReset = 5, /**< This state indicates that a valid USB device has been attached, and that\r
+ * it will now be reset to ensure it is ready for enumeration.\r
+ */\r
+ HOST_STATE_Powered_ConfigPipe = 6, /**< This state indicates that the attached device is currently powered and\r
+ * reset, and that the control pipe is now being configured by the stack.\r
+ */\r
+ HOST_STATE_Default = 7, /**< This state indicates that the stack is currently retrieving the control\r
+ * endpoint's size from the device, so that the control pipe can be altered\r
+ * to match.\r
+ */\r
+ HOST_STATE_Default_PostReset = 8, /**< This state indicates that the control pipe is being reconfigured to match\r
+ * the retrieved control endpoint size from the device, and the device's USB\r
+ * bus address is being set.\r
+ */\r
+ HOST_STATE_Default_PostAddressSet = 9, /**< This state indicates that the device's address has now been set, and the\r
+ * stack is has now completed the device enumeration process. This state causes\r
+ * the stack to change the current USB device address to that set for the\r
+ * connected device, before progressing to the \ref HOST_STATE_Addressed state\r
+ * ready for use in the user application.\r
+ */\r
+ HOST_STATE_Addressed = 10, /**< Indicates that the device has been enumerated and addressed, and is now waiting\r
+ * for the user application to configure the device ready for use.\r
+ */\r
+ HOST_STATE_Configured = 11, /**< Indicates that the device has been configured into a valid device configuration,\r
+ * ready for general use by the user application.\r
+ */\r
+ };\r
+\r
+ /* Architecture Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/Host_AVR8.h"\r
+ #elif (ARCH == ARCH_UC3)\r
+ #include "UC3/Host_UC3.h"\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_HOSTSTDREQ_C\r
+#include "HostStandardReq.h"\r
+\r
+uint8_t USB_Host_ConfigurationNumber;\r
+\r
+static uint8_t USB_Host_SendControlRequest_PRV(void* const BufferPtr)\r
+{\r
+ uint8_t* DataStream = (uint8_t*)BufferPtr;\r
+ uint8_t ReturnStatus = HOST_SENDCONTROL_Successful;\r
+ uint16_t DataLen = USB_ControlRequest.wLength;\r
+\r
+ USB_Host_ResumeBus();\r
+\r
+ if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)\r
+ return ReturnStatus;\r
+\r
+ Pipe_SetPipeToken(PIPE_TOKEN_SETUP);\r
+ Pipe_ClearError();\r
+\r
+ Pipe_Unfreeze();\r
+\r
+ #if defined(ARCH_BIG_ENDIAN)\r
+ Pipe_Write_8(USB_ControlRequest.bmRequestType);\r
+ Pipe_Write_8(USB_ControlRequest.bRequest);\r
+ Pipe_Write_16_LE(USB_ControlRequest.wValue);\r
+ Pipe_Write_16_LE(USB_ControlRequest.wIndex);\r
+ Pipe_Write_16_LE(USB_ControlRequest.wLength);\r
+ #else\r
+ uint8_t* HeaderStream = (uint8_t*)&USB_ControlRequest;\r
+\r
+ for (uint8_t HeaderByte = 0; HeaderByte < sizeof(USB_Request_Header_t); HeaderByte++)\r
+ Pipe_Write_8(*(HeaderStream++));\r
+ #endif\r
+\r
+ Pipe_ClearSETUP();\r
+\r
+ if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_SetupSent)) != HOST_SENDCONTROL_Successful)\r
+ return ReturnStatus;\r
+\r
+ Pipe_Freeze();\r
+\r
+ if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)\r
+ return ReturnStatus;\r
+\r
+ if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_DIRECTION) == REQDIR_DEVICETOHOST)\r
+ {\r
+ Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
+\r
+ if (DataStream != NULL)\r
+ {\r
+ while (DataLen)\r
+ {\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_InReceived)) != HOST_SENDCONTROL_Successful)\r
+ return ReturnStatus;\r
+\r
+ if (!(Pipe_BytesInPipe()))\r
+ DataLen = 0;\r
+\r
+ while (Pipe_BytesInPipe() && DataLen)\r
+ {\r
+ *(DataStream++) = Pipe_Read_8();\r
+ DataLen--;\r
+ }\r
+\r
+ Pipe_Freeze();\r
+ Pipe_ClearIN();\r
+ }\r
+ }\r
+\r
+ Pipe_SetPipeToken(PIPE_TOKEN_OUT);\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)\r
+ return ReturnStatus;\r
+\r
+ Pipe_ClearOUT();\r
+\r
+ if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)\r
+ return ReturnStatus;\r
+ }\r
+ else\r
+ {\r
+ if (DataStream != NULL)\r
+ {\r
+ Pipe_SetPipeToken(PIPE_TOKEN_OUT);\r
+ Pipe_Unfreeze();\r
+\r
+ while (DataLen)\r
+ {\r
+ if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)\r
+ return ReturnStatus;\r
+\r
+ while (DataLen && (Pipe_BytesInPipe() < USB_Host_ControlPipeSize))\r
+ {\r
+ Pipe_Write_8(*(DataStream++));\r
+ DataLen--;\r
+ }\r
+\r
+ Pipe_ClearOUT();\r
+ }\r
+\r
+ if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)\r
+ return ReturnStatus;\r
+\r
+ Pipe_Freeze();\r
+ }\r
+\r
+ Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
+ Pipe_Unfreeze();\r
+\r
+ if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_InReceived)) != HOST_SENDCONTROL_Successful)\r
+ return ReturnStatus;\r
+\r
+ Pipe_ClearIN();\r
+ }\r
+ \r
+ return ReturnStatus;\r
+}\r
+\r
+static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType)\r
+{\r
+ #if (USB_HOST_TIMEOUT_MS < 0xFF)\r
+ uint8_t TimeoutCounter = USB_HOST_TIMEOUT_MS;\r
+ #else\r
+ uint16_t TimeoutCounter = USB_HOST_TIMEOUT_MS;\r
+ #endif\r
+\r
+ while (!(((WaitType == USB_HOST_WAITFOR_SetupSent) && Pipe_IsSETUPSent()) ||\r
+ ((WaitType == USB_HOST_WAITFOR_InReceived) && Pipe_IsINReceived()) ||\r
+ ((WaitType == USB_HOST_WAITFOR_OutReady) && Pipe_IsOUTReady())))\r
+ {\r
+ uint8_t ErrorCode;\r
+\r
+ if ((ErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)\r
+ return ErrorCode;\r
+\r
+ if (!(TimeoutCounter--))\r
+ return HOST_SENDCONTROL_SoftwareTimeOut;\r
+ }\r
+\r
+ return HOST_SENDCONTROL_Successful;\r
+}\r
+\r
+uint8_t USB_Host_SendControlRequest(void* const BufferPtr)\r
+{\r
+ bool BusSuspended = USB_Host_IsBusSuspended();\r
+ uint8_t ReturnStatus = USB_Host_SendControlRequest_PRV(BufferPtr);\r
+\r
+ Pipe_Freeze();\r
+\r
+ if (BusSuspended)\r
+ USB_Host_SuspendBus();\r
+\r
+ Pipe_ResetPipe(PIPE_CONTROLPIPE);\r
+\r
+ return ReturnStatus;\r
+}\r
+\r
+uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber)\r
+{\r
+ uint8_t ErrorCode;\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ .bRequest = REQ_SetConfiguration,\r
+ .wValue = ConfigNumber,\r
+ .wIndex = 0,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ if ((ErrorCode = USB_Host_SendControlRequest(NULL)) == HOST_SENDCONTROL_Successful)\r
+ {\r
+ USB_Host_ConfigurationNumber = ConfigNumber;\r
+ USB_HostState = (ConfigNumber) ? HOST_STATE_Configured : HOST_STATE_Addressed;\r
+ }\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+uint8_t USB_Host_GetDeviceConfiguration(uint8_t* const ConfigNumber)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ .bRequest = REQ_GetConfiguration,\r
+ .wValue = 0,\r
+ .wIndex = 0,\r
+ .wLength = sizeof(uint8_t),\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(ConfigNumber);\r
+}\r
+\r
+uint8_t USB_Host_GetDescriptor(const uint8_t Type,\r
+ const uint8_t Index,\r
+ void* const Buffer,\r
+ const uint8_t BufferLength)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ .bRequest = REQ_GetDescriptor,\r
+ .wValue = (((uint16_t)Type << 8) | Index),\r
+ .wIndex = 0,\r
+ .wLength = BufferLength,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(Buffer);\r
+}\r
+\r
+uint8_t USB_Host_GetDeviceStatus(uint8_t* const FeatureStatus)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ .bRequest = REQ_GetStatus,\r
+ .wValue = 0,\r
+ .wIndex = 0,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(FeatureStatus);\r
+}\r
+\r
+uint8_t USB_Host_ClearEndpointStall(const uint8_t EndpointAddress)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_ENDPOINT),\r
+ .bRequest = REQ_ClearFeature,\r
+ .wValue = FEATURE_SEL_EndpointHalt,\r
+ .wIndex = EndpointAddress,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(NULL);\r
+}\r
+\r
+uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex,\r
+ const uint8_t AltSetting)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE),\r
+ .bRequest = REQ_SetInterface,\r
+ .wValue = AltSetting,\r
+ .wIndex = InterfaceIndex,\r
+ .wLength = 0,\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(NULL);\r
+}\r
+\r
+uint8_t USB_Host_GetInterfaceAltSetting(const uint8_t InterfaceIndex,\r
+ uint8_t* const AltSetting)\r
+{\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE),\r
+ .bRequest = REQ_GetInterface,\r
+ .wValue = 0,\r
+ .wIndex = InterfaceIndex,\r
+ .wLength = sizeof(uint8_t),\r
+ };\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ return USB_Host_SendControlRequest(AltSetting);\r
+}\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB host standard request management.\r
+ *\r
+ * This file contains the function prototypes necessary for the issuing of outgoing standard control requests\r
+ * when the library is in USB host mode.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+#ifndef __HOSTSTDREQ_H__\r
+#define __HOSTSTDREQ_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+ #include "StdRequestType.h"\r
+ #include "USBController.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #if !defined(USB_HOST_TIMEOUT_MS) || defined(__DOXYGEN__)\r
+ /** Constant for the maximum software timeout period of sent USB control transactions to an attached\r
+ * device. If a device fails to respond to a sent control request within this period, the\r
+ * library will return a timeout error code.\r
+ *\r
+ * This value may be overridden in the user project makefile as the value of the\r
+ * \ref USB_HOST_TIMEOUT_MS token, and passed to the compiler using the -D switch.\r
+ */\r
+ #define USB_HOST_TIMEOUT_MS 1000\r
+ #endif\r
+\r
+ /* Enums: */\r
+ /** Enum for the \ref USB_Host_SendControlRequest() return code, indicating the reason for the error\r
+ * if the transfer of the request is unsuccessful.\r
+ *\r
+ * \ingroup Group_PipeControlReq\r
+ */\r
+ enum USB_Host_SendControlErrorCodes_t\r
+ {\r
+ HOST_SENDCONTROL_Successful = 0, /**< No error occurred in the request transfer. */\r
+ HOST_SENDCONTROL_DeviceDisconnected = 1, /**< The attached device was disconnected during the\r
+ * request transfer.\r
+ */\r
+ HOST_SENDCONTROL_PipeError = 2, /**< An error occurred in the pipe while sending the request. */\r
+ HOST_SENDCONTROL_SetupStalled = 3, /**< The attached device stalled the request, usually\r
+ * indicating that the request is unsupported on the device.\r
+ */\r
+ HOST_SENDCONTROL_SoftwareTimeOut = 4, /**< The request or data transfer timed out. */\r
+ };\r
+\r
+ /* Global Variables: */\r
+ /** Indicates the currently set configuration number of the attached device. This indicates the currently\r
+ * selected configuration value if one has been set successfully, or 0 if no configuration has been selected.\r
+ *\r
+ * To set a device configuration, call the \ref USB_Host_SetDeviceConfiguration() function.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ *\r
+ * \ingroup Group_Host\r
+ */\r
+ extern uint8_t USB_Host_ConfigurationNumber;\r
+\r
+ /* Function Prototypes: */\r
+ /** Sends the request stored in the \ref USB_ControlRequest global structure to the attached device,\r
+ * and transfers the data stored in the buffer to the device, or from the device to the buffer\r
+ * as requested. The transfer is made on the currently selected pipe.\r
+ *\r
+ * \ingroup Group_PipeControlReq\r
+ *\r
+ * \param[in] BufferPtr Pointer to the start of the data buffer if the request has a data stage, or\r
+ * \c NULL if the request transfers no data to or from the device.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_SendControlRequest(void* const BufferPtr);\r
+\r
+ /** Sends a SET CONFIGURATION standard request to the attached device, with the given configuration index.\r
+ *\r
+ * This routine will automatically update the \ref USB_HostState and \ref USB_Host_ConfigurationNumber\r
+ * state variables according to the given function parameters and the result of the request.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \ingroup Group_PipeControlReq\r
+ *\r
+ * \param[in] ConfigNumber Configuration index to send to the device.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber);\r
+\r
+ /** Sends a GET CONFIGURATION standard request to the attached device, to retrieve the currently selected\r
+ * device configuration index.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \ingroup Group_PipeControlReq\r
+ *\r
+ * \param[out] ConfigNumber Pointer to a location where the retrieved configuration index should be stored.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_GetDeviceConfiguration(uint8_t* const ConfigNumber) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the descriptor of the\r
+ * specified type and index.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \ingroup Group_PipeControlReq\r
+ *\r
+ * \param[in] Type Type of descriptor to retrieve, a value from the \ref USB_DescriptorTypes_t enum.\r
+ * \param[in] Index Index of the descriptor to retrieve.\r
+ * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is to be stored.\r
+ * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_GetDescriptor(const uint8_t Type,\r
+ const uint8_t Index,\r
+ void* const Buffer,\r
+ const uint8_t BufferLength) ATTR_NON_NULL_PTR_ARG(3);\r
+\r
+ /** Retrieves the current feature status of the attached device, via a GET STATUS standard request. The\r
+ * retrieved feature status can then be examined by masking the retrieved value with the various\r
+ * \c FEATURE_* masks for bus/self power information and remote wakeup support.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \ingroup Group_PipeControlReq\r
+ *\r
+ * \param[out] FeatureStatus Location where the retrieved feature status should be stored.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_GetDeviceStatus(uint8_t* const FeatureStatus) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Clears a stall condition on the given pipe, via a CLEAR FEATURE standard request to the attached device.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \ingroup Group_PipeControlReq\r
+ *\r
+ * \param[in] EndpointAddress Address of the endpoint to clear, including the endpoint's direction.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_ClearEndpointStall(const uint8_t EndpointAddress);\r
+\r
+ /** Selects a given alternative setting for the specified interface, via a SET INTERFACE standard request to\r
+ * the attached device.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \ingroup Group_PipeControlReq\r
+ *\r
+ * \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered.\r
+ * \param[in] AltSetting Index of the interface's alternative setting which is to be selected.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex,\r
+ const uint8_t AltSetting);\r
+\r
+\r
+ /** Retrieves the current alternative setting for the specified interface, via a GET INTERFACE standard request to\r
+ * the attached device.\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \ingroup Group_PipeControlReq\r
+ *\r
+ * \param[in] InterfaceIndex Index of the interface whose alternative setting is to be altered.\r
+ * \param[out] AltSetting Pointer to a location where the retrieved alternative setting value should be stored.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ uint8_t USB_Host_GetInterfaceAltSetting(const uint8_t InterfaceIndex,\r
+ uint8_t* const AltSetting) ATTR_NON_NULL_PTR_ARG(2);\r
+\r
+ /* Inline Functions: */\r
+ /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the device descriptor.\r
+ * This can be used to easily retrieve information about the device such as its VID, PID and power\r
+ * requirements. This is a convenience wrapper for \ref USB_Host_GetDescriptor().\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \ingroup Group_PipeControlReq\r
+ *\r
+ * \param[out] DeviceDescriptorPtr Pointer to the destination device descriptor structure where\r
+ * the read data is to be stored.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ static inline uint8_t USB_Host_GetDeviceDescriptor(USB_Descriptor_Device_t* const DeviceDescriptorPtr) ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline uint8_t USB_Host_GetDeviceDescriptor(USB_Descriptor_Device_t* const DeviceDescriptorPtr)\r
+ {\r
+ return USB_Host_GetDescriptor(DTYPE_Device, 0, DeviceDescriptorPtr, sizeof(USB_Descriptor_Device_t));\r
+ }\r
+\r
+ /** Sends a GET DESCRIPTOR standard request to the attached device, requesting the string descriptor\r
+ * of the specified index. This can be used to easily retrieve string descriptors from the device by\r
+ * index, after the index is obtained from the Device or Configuration descriptors. This is a convenience\r
+ * wrapper for \ref USB_Host_GetDescriptor().\r
+ *\r
+ * \note After this routine returns, the control pipe will be selected.\r
+ *\r
+ * \ingroup Group_PipeControlReq\r
+ *\r
+ * \param[in] Index Index of the string descriptor to retrieve.\r
+ * \param[out] Buffer Pointer to the destination buffer where the retrieved string descriptor is\r
+ * to be stored.\r
+ * \param[in] BufferLength Maximum size of the string descriptor which can be stored into the buffer.\r
+ *\r
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.\r
+ */\r
+ static inline uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,\r
+ void* const Buffer,\r
+ const uint8_t BufferLength) ATTR_NON_NULL_PTR_ARG(2);\r
+ static inline uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,\r
+ void* const Buffer,\r
+ const uint8_t BufferLength)\r
+ {\r
+ return USB_Host_GetDescriptor(DTYPE_String, Index, Buffer, BufferLength);\r
+ }\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Enums: */\r
+ enum USB_WaitForTypes_t\r
+ {\r
+ USB_HOST_WAITFOR_SetupSent,\r
+ USB_HOST_WAITFOR_InReceived,\r
+ USB_HOST_WAITFOR_OutReady,\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_HOSTSTDREQ_C)\r
+ static uint8_t USB_Host_SendControlRequest_PRV(void* const BufferPtr);\r
+ static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common USB OTG definitions for all architectures.\r
+ * \copydetails Group_OTG\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USB\r
+ * \defgroup Group_OTG USB On The Go (OTG) Management\r
+ * \brief USB OTG management definitions.\r
+ *\r
+ * This module contains macros for embedded USB hosts with dual role On The Go capabilities, for managing role\r
+ * exchange. OTG is a way for two USB dual role devices to talk to one another directly without fixed device/host\r
+ * roles.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBOTG_H__\r
+#define __USBOTG_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Architecture Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/OTG_AVR8.h"\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common USB Pipe definitions for all architectures.\r
+ * \copydetails Group_PipeManagement\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_PipeManagement\r
+ * \defgroup Group_PipeRW Pipe Data Reading and Writing\r
+ * \brief Pipe data read/write definitions.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing from and to pipes.\r
+ */\r
+\r
+/** \ingroup Group_PipeRW\r
+ * \defgroup Group_PipePrimitiveRW Read/Write of Primitive Data Types\r
+ * \brief Pipe data primitive read/write definitions.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of primitive data types\r
+ * from and to pipes.\r
+ */\r
+\r
+/** \ingroup Group_PipeManagement\r
+ * \defgroup Group_PipePacketManagement Pipe Packet Management\r
+ * \brief Pipe packet management definitions.\r
+ *\r
+ * Functions, macros, variables, enums and types related to packet management of pipes.\r
+ */\r
+\r
+/** \ingroup Group_PipeManagement\r
+ * \defgroup Group_PipeControlReq Pipe Control Request Management\r
+ * \brief Pipe control request definitions.\r
+ *\r
+ * Module for host mode request processing. This module allows for the transmission of standard, class and\r
+ * vendor control requests to the default control endpoint of an attached device while in host mode.\r
+ *\r
+ * \see Chapter 9 of the USB 2.0 specification.\r
+ */\r
+\r
+/** \ingroup Group_USB\r
+ * \defgroup Group_PipeManagement Pipe Management\r
+ * \brief Pipe management definitions.\r
+ *\r
+ * This module contains functions, macros and enums related to pipe management when in USB Host mode. This\r
+ * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions\r
+ * for various data types.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __PIPE_H__\r
+#define __PIPE_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Type Defines: */\r
+ /** Type define for a pipe table entry, used to configure pipes in groups via\r
+ * \ref Pipe_ConfigurePipeTable().\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t Address; /**< Address of the pipe to configure, or zero if the table entry is to be unused. */\r
+ uint16_t Size; /**< Size of the pipe bank, in bytes. */\r
+ uint8_t EndpointAddress; /** Address of the endpoint in the connected device. */\r
+ uint8_t Type; /**< Type of the endpoint, a \c EP_TYPE_* mask. */\r
+ uint8_t Banks; /**< Number of hardware banks to use for the pipe. */\r
+ } USB_Pipe_Table_t;\r
+\r
+ /* Macros: */\r
+ /** Pipe address for the default control pipe, which always resides in address 0. This is\r
+ * defined for convenience to give more readable code when used with the pipe macros.\r
+ */\r
+ #define PIPE_CONTROLPIPE 0\r
+\r
+ /** Pipe number mask, for masking against pipe addresses to retrieve the pipe's numerical address\r
+ * in the device.\r
+ */\r
+ #define PIPE_PIPENUM_MASK 0x0F\r
+\r
+ /** Endpoint number mask, for masking against endpoint addresses to retrieve the endpoint's\r
+ * numerical address in the attached device.\r
+ */\r
+ #define PIPE_EPNUM_MASK 0x0F\r
+\r
+ /* Architecture Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/Pipe_AVR8.h"\r
+ #elif (ARCH == ARCH_UC3)\r
+ #include "UC3/Pipe_UC3.h"\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Pipe data stream transmission and reception management.\r
+ * \copydetails Group_PipeStreamRW\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_PipeRW\r
+ * \defgroup Group_PipeStreamRW Read/Write of Multi-Byte Streams\r
+ * \brief Pipe data stream transmission and reception management.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of data streams from\r
+ * and to pipes.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __PIPE_STREAM_H__\r
+#define __PIPE_STREAM_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Enums: */\r
+ /** Enum for the possible error return codes of the Pipe_*_Stream_* functions. */\r
+ enum Pipe_Stream_RW_ErrorCodes_t\r
+ {\r
+ PIPE_RWSTREAM_NoError = 0, /**< Command completed successfully, no error. */\r
+ PIPE_RWSTREAM_PipeStalled = 1, /**< The device stalled the pipe during the transfer. */\r
+ PIPE_RWSTREAM_DeviceDisconnected = 2, /**< Device was disconnected from the host during\r
+ * the transfer.\r
+ */\r
+ PIPE_RWSTREAM_Timeout = 3, /**< The device failed to accept or send the next packet\r
+ * within the software timeout period set by the\r
+ * \ref USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ PIPE_RWSTREAM_IncompleteTransfer = 4, /**< Indicates that the pipe bank became full/empty before the\r
+ * complete contents of the stream could be transferred.\r
+ */\r
+ };\r
+\r
+ /* Architecture Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/PipeStream_AVR8.h"\r
+ #elif (ARCH == ARCH_UC3)\r
+ #include "UC3/PipeStream_UC3.h"\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common standard USB Descriptor definitions for all architectures.\r
+ * \copydetails Group_StdDescriptors\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USB\r
+ * \defgroup Group_StdDescriptors USB Descriptors\r
+ * \brief Standard USB Descriptor definitions.\r
+ *\r
+ * Standard USB device descriptor defines and retrieval routines, for USB devices. This module contains\r
+ * structures and macros for the easy creation of standard USB descriptors in USB device projects.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBDESCRIPTORS_H__\r
+#define __USBDESCRIPTORS_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+ #include "Events.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Indicates that a given descriptor does not exist in the device. This can be used inside descriptors\r
+ * for string descriptor indexes, or may be use as a return value for GetDescriptor when the specified\r
+ * descriptor does not exist.\r
+ */\r
+ #define NO_DESCRIPTOR 0\r
+\r
+ /** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes.\r
+ *\r
+ * \param[in] mA Maximum number of milliamps the device consumes when the given configuration is selected.\r
+ */\r
+ #define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)\r
+\r
+ /** Macro to calculate the Unicode length of a string with a given number of Unicode characters.\r
+ * Should be used in string descriptor's headers for giving the string descriptor's byte length.\r
+ *\r
+ * \param[in] UnicodeChars Number of Unicode characters in the string text.\r
+ */\r
+ #define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))\r
+\r
+ /** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded\r
+ * Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the\r
+ * standard device descriptor.\r
+ *\r
+ * \note This value is automatically converted into Little Endian, suitable for direct use inside device\r
+ * descriptors on all architectures without endianness conversion macros.\r
+ *\r
+ * \param[in] x Version number to encode as a 16-bit little-endian number, as a floating point number.\r
+ */\r
+ #define VERSION_BCD(x) CPU_TO_LE16((VERSION_TENS(x) << 12) | (VERSION_ONES(x) << 8) | \\r
+ (VERSION_TENTHS(x) << 4) | (VERSION_HUNDREDTHS(x) << 0) )\r
+\r
+ /** String language ID for the English language. Should be used in \ref USB_Descriptor_String_t descriptors\r
+ * to indicate that the English language is supported by the device in its string descriptors.\r
+ */\r
+ #define LANGUAGE_ID_ENG 0x0409\r
+\r
+ /** \name USB Configuration Descriptor Attribute Masks */\r
+ //@{\r
+ /** Mask for the reserved bit in the Configuration Descriptor's \c ConfigAttributes field, which must be set on all\r
+ * devices for historical purposes.\r
+ */\r
+ #define USB_CONFIG_ATTR_RESERVED 0x80\r
+\r
+ /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t\r
+ * descriptor's \c ConfigAttributes value to indicate that the specified configuration can draw its power\r
+ * from the device's own power source.\r
+ */\r
+ #define USB_CONFIG_ATTR_SELFPOWERED 0x40\r
+\r
+ /** Can be masked with other configuration descriptor attributes for a \ref USB_Descriptor_Configuration_Header_t\r
+ * descriptor's \c ConfigAttributes value to indicate that the specified configuration supports the\r
+ * remote wakeup feature of the USB standard, allowing a suspended USB device to wake up the host upon\r
+ * request.\r
+ */\r
+ #define USB_CONFIG_ATTR_REMOTEWAKEUP 0x20\r
+ //@}\r
+\r
+ /** \name Endpoint Descriptor Attribute Masks */\r
+ //@{\r
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's\r
+ * \c Attributes value to indicate that the specified endpoint is not synchronized.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint attributes.\r
+ */\r
+ #define ENDPOINT_ATTR_NO_SYNC (0 << 2)\r
+\r
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's\r
+ * \c Attributes value to indicate that the specified endpoint is asynchronous.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint attributes.\r
+ */\r
+ #define ENDPOINT_ATTR_ASYNC (1 << 2)\r
+\r
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's\r
+ * \c Attributes value to indicate that the specified endpoint is adaptive.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint attributes.\r
+ */\r
+ #define ENDPOINT_ATTR_ADAPTIVE (2 << 2)\r
+\r
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's\r
+ * \c Attributes value to indicate that the specified endpoint is synchronized.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint attributes.\r
+ */\r
+ #define ENDPOINT_ATTR_SYNC (3 << 2)\r
+ //@}\r
+\r
+ /** \name Endpoint Descriptor Usage Masks */\r
+ //@{\r
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's\r
+ * \c Attributes value to indicate that the specified endpoint is used for data transfers.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint usage attributes.\r
+ */\r
+ #define ENDPOINT_USAGE_DATA (0 << 4)\r
+\r
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's\r
+ * \c Attributes value to indicate that the specified endpoint is used for feedback.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint usage attributes.\r
+ */\r
+ #define ENDPOINT_USAGE_FEEDBACK (1 << 4)\r
+\r
+ /** Can be masked with other endpoint descriptor attributes for a \ref USB_Descriptor_Endpoint_t descriptor's\r
+ * \c Attributes value to indicate that the specified endpoint is used for implicit feedback.\r
+ *\r
+ * \see The USB specification for more details on the possible Endpoint usage attributes.\r
+ */\r
+ #define ENDPOINT_USAGE_IMPLICIT_FEEDBACK (2 << 4)\r
+ //@}\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible standard descriptor types, as given in each descriptor's header. */\r
+ enum USB_DescriptorTypes_t\r
+ {\r
+ DTYPE_Device = 0x01, /**< Indicates that the descriptor is a device descriptor. */\r
+ DTYPE_Configuration = 0x02, /**< Indicates that the descriptor is a configuration descriptor. */\r
+ DTYPE_String = 0x03, /**< Indicates that the descriptor is a string descriptor. */\r
+ DTYPE_Interface = 0x04, /**< Indicates that the descriptor is an interface descriptor. */\r
+ DTYPE_Endpoint = 0x05, /**< Indicates that the descriptor is an endpoint descriptor. */\r
+ DTYPE_DeviceQualifier = 0x06, /**< Indicates that the descriptor is a device qualifier descriptor. */\r
+ DTYPE_Other = 0x07, /**< Indicates that the descriptor is of other type. */\r
+ DTYPE_InterfacePower = 0x08, /**< Indicates that the descriptor is an interface power descriptor. */\r
+ DTYPE_InterfaceAssociation = 0x0B, /**< Indicates that the descriptor is an interface association descriptor. */\r
+ DTYPE_CSInterface = 0x24, /**< Indicates that the descriptor is a class specific interface descriptor. */\r
+ DTYPE_CSEndpoint = 0x25, /**< Indicates that the descriptor is a class specific endpoint descriptor. */\r
+ };\r
+\r
+ /** Enum for possible Class, Subclass and Protocol values of device and interface descriptors. */\r
+ enum USB_Descriptor_ClassSubclassProtocol_t\r
+ {\r
+ USB_CSCP_NoDeviceClass = 0x00, /**< Descriptor Class value indicating that the device does not belong\r
+ * to a particular class at the device level.\r
+ */\r
+ USB_CSCP_NoDeviceSubclass = 0x00, /**< Descriptor Subclass value indicating that the device does not belong\r
+ * to a particular subclass at the device level.\r
+ */\r
+ USB_CSCP_NoDeviceProtocol = 0x00, /**< Descriptor Protocol value indicating that the device does not belong\r
+ * to a particular protocol at the device level.\r
+ */\r
+ USB_CSCP_VendorSpecificClass = 0xFF, /**< Descriptor Class value indicating that the device/interface belongs\r
+ * to a vendor specific class.\r
+ */\r
+ USB_CSCP_VendorSpecificSubclass = 0xFF, /**< Descriptor Subclass value indicating that the device/interface belongs\r
+ * to a vendor specific subclass.\r
+ */\r
+ USB_CSCP_VendorSpecificProtocol = 0xFF, /**< Descriptor Protocol value indicating that the device/interface belongs\r
+ * to a vendor specific protocol.\r
+ */\r
+ USB_CSCP_IADDeviceClass = 0xEF, /**< Descriptor Class value indicating that the device belongs to the\r
+ * Interface Association Descriptor class.\r
+ */\r
+ USB_CSCP_IADDeviceSubclass = 0x02, /**< Descriptor Subclass value indicating that the device belongs to the\r
+ * Interface Association Descriptor subclass.\r
+ */\r
+ USB_CSCP_IADDeviceProtocol = 0x01, /**< Descriptor Protocol value indicating that the device belongs to the\r
+ * Interface Association Descriptor protocol.\r
+ */\r
+ };\r
+\r
+ /* Type Defines: */\r
+ /** \brief Standard USB Descriptor Header (LUFA naming conventions).\r
+ *\r
+ * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure\r
+ * uses LUFA-specific element names to make each element's purpose clearer.\r
+ *\r
+ * \see \ref USB_StdDescriptor_Header_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t Size; /**< Size of the descriptor, in bytes. */\r
+ uint8_t Type; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+ } ATTR_PACKED USB_Descriptor_Header_t;\r
+\r
+ /** \brief Standard USB Descriptor Header (USB-IF naming conventions).\r
+ *\r
+ * Type define for all descriptors' standard header, indicating the descriptor's length and type. This structure\r
+ * uses the relevant standard's given element names to ensure compatibility with the standard.\r
+ *\r
+ * \see \ref USB_Descriptor_Header_t for the version of this type with non-standard LUFA specific element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+ } ATTR_PACKED USB_StdDescriptor_Header_t;\r
+\r
+ /** \brief Standard USB Device Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard Device Descriptor. This structure uses LUFA-specific element names to make each\r
+ * element's purpose clearer.\r
+ *\r
+ * \see \ref USB_StdDescriptor_Device_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+\r
+ uint16_t USBSpecification; /**< BCD of the supported USB specification. */\r
+ uint8_t Class; /**< USB device class. */\r
+ uint8_t SubClass; /**< USB device subclass. */\r
+ uint8_t Protocol; /**< USB device protocol. */\r
+\r
+ uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */\r
+\r
+ uint16_t VendorID; /**< Vendor ID for the USB product. */\r
+ uint16_t ProductID; /**< Unique product ID for the USB product. */\r
+ uint16_t ReleaseNumber; /**< Product release (version) number. */\r
+\r
+ uint8_t ManufacturerStrIndex; /**< String index for the manufacturer's name. The\r
+ * host will request this string via a separate\r
+ * control request for the string descriptor.\r
+ *\r
+ * \note If no string supplied, use \ref NO_DESCRIPTOR.\r
+ */\r
+ uint8_t ProductStrIndex; /**< String index for the product name/details.\r
+ *\r
+ * \see ManufacturerStrIndex structure entry.\r
+ */\r
+ uint8_t SerialNumStrIndex; /**< String index for the product's globally unique hexadecimal\r
+ * serial number, in uppercase Unicode ASCII.\r
+ *\r
+ * \note On some microcontroller models, there is an embedded serial number\r
+ * in the chip which can be used for the device serial number.\r
+ * To use this serial number, set this to USE_INTERNAL_SERIAL.\r
+ * On unsupported devices, this will evaluate to 0 and will cause\r
+ * the host to generate a pseudo-unique value for the device upon\r
+ * insertion.\r
+ *\r
+ * \see ManufacturerStrIndex structure entry.\r
+ */\r
+ uint8_t NumberOfConfigurations; /**< Total number of configurations supported by\r
+ * the device.\r
+ */\r
+ } ATTR_PACKED USB_Descriptor_Device_t;\r
+\r
+ /** \brief Standard USB Device Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard Device Descriptor. This structure uses the relevant standard's given element names\r
+ * to ensure compatibility with the standard.\r
+ *\r
+ * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+ uint16_t bcdUSB; /**< BCD of the supported USB specification. */\r
+ uint8_t bDeviceClass; /**< USB device class. */\r
+ uint8_t bDeviceSubClass; /**< USB device subclass. */\r
+ uint8_t bDeviceProtocol; /**< USB device protocol. */\r
+ uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */\r
+ uint16_t idVendor; /**< Vendor ID for the USB product. */\r
+ uint16_t idProduct; /**< Unique product ID for the USB product. */\r
+ uint16_t bcdDevice; /**< Product release (version) number. */\r
+ uint8_t iManufacturer; /**< String index for the manufacturer's name. The\r
+ * host will request this string via a separate\r
+ * control request for the string descriptor.\r
+ *\r
+ * \note If no string supplied, use \ref NO_DESCRIPTOR.\r
+ */\r
+ uint8_t iProduct; /**< String index for the product name/details.\r
+ *\r
+ * \see ManufacturerStrIndex structure entry.\r
+ */\r
+ uint8_t iSerialNumber; /**< String index for the product's globally unique hexadecimal\r
+ * serial number, in uppercase Unicode ASCII.\r
+ *\r
+ * \note On some microcontroller models, there is an embedded serial number\r
+ * in the chip which can be used for the device serial number.\r
+ * To use this serial number, set this to USE_INTERNAL_SERIAL.\r
+ * On unsupported devices, this will evaluate to 0 and will cause\r
+ * the host to generate a pseudo-unique value for the device upon\r
+ * insertion.\r
+ *\r
+ * \see ManufacturerStrIndex structure entry.\r
+ */\r
+ uint8_t bNumConfigurations; /**< Total number of configurations supported by\r
+ * the device.\r
+ */\r
+ } ATTR_PACKED USB_StdDescriptor_Device_t;\r
+\r
+ /** \brief Standard USB Device Qualifier Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard Device Qualifier Descriptor. This structure uses LUFA-specific element names\r
+ * to make each element's purpose clearer.\r
+ *\r
+ * \see \ref USB_StdDescriptor_DeviceQualifier_t for the version of this type with standard element names.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+\r
+ uint16_t USBSpecification; /**< BCD of the supported USB specification. */\r
+ uint8_t Class; /**< USB device class. */\r
+ uint8_t SubClass; /**< USB device subclass. */\r
+ uint8_t Protocol; /**< USB device protocol. */\r
+\r
+ uint8_t Endpoint0Size; /**< Size of the control (address 0) endpoint's bank in bytes. */\r
+ uint8_t NumberOfConfigurations; /**< Total number of configurations supported by\r
+ * the device.\r
+ */\r
+ uint8_t Reserved; /**< Reserved for future use, must be 0. */\r
+ } ATTR_PACKED USB_Descriptor_DeviceQualifier_t;\r
+\r
+ /** \brief Standard USB Device Qualifier Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard Device Qualifier Descriptor. This structure uses the relevant standard's given element names\r
+ * to ensure compatibility with the standard.\r
+ *\r
+ * \see \ref USB_Descriptor_DeviceQualifier_t for the version of this type with non-standard LUFA specific element names.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+ uint16_t bcdUSB; /**< BCD of the supported USB specification. */\r
+ uint8_t bDeviceClass; /**< USB device class. */\r
+ uint8_t bDeviceSubClass; /**< USB device subclass. */\r
+ uint8_t bDeviceProtocol; /**< USB device protocol. */\r
+ uint8_t bMaxPacketSize0; /**< Size of the control (address 0) endpoint's bank in bytes. */\r
+ uint8_t bNumConfigurations; /**< Total number of configurations supported by\r
+ * the device.\r
+ */\r
+ uint8_t bReserved; /**< Reserved for future use, must be 0. */\r
+ } ATTR_PACKED USB_StdDescriptor_DeviceQualifier_t;\r
+\r
+ /** \brief Standard USB Configuration Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard Configuration Descriptor header. This structure uses LUFA-specific element names\r
+ * to make each element's purpose clearer.\r
+ *\r
+ * \see \ref USB_StdDescriptor_Configuration_Header_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+\r
+ uint16_t TotalConfigurationSize; /**< Size of the configuration descriptor header,\r
+ * and all sub descriptors inside the configuration.\r
+ */\r
+ uint8_t TotalInterfaces; /**< Total number of interfaces in the configuration. */\r
+\r
+ uint8_t ConfigurationNumber; /**< Configuration index of the current configuration. */\r
+ uint8_t ConfigurationStrIndex; /**< Index of a string descriptor describing the configuration. */\r
+\r
+ uint8_t ConfigAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.\r
+ * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.\r
+ */\r
+\r
+ uint8_t MaxPowerConsumption; /**< Maximum power consumption of the device while in the\r
+ * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()\r
+ * macro.\r
+ */\r
+ } ATTR_PACKED USB_Descriptor_Configuration_Header_t;\r
+\r
+ /** \brief Standard USB Configuration Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard Configuration Descriptor header. This structure uses the relevant standard's given element names\r
+ * to ensure compatibility with the standard.\r
+ *\r
+ * \see \ref USB_Descriptor_Device_t for the version of this type with non-standard LUFA specific element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+ uint16_t wTotalLength; /**< Size of the configuration descriptor header,\r
+ * and all sub descriptors inside the configuration.\r
+ */\r
+ uint8_t bNumInterfaces; /**< Total number of interfaces in the configuration. */\r
+ uint8_t bConfigurationValue; /**< Configuration index of the current configuration. */\r
+ uint8_t iConfiguration; /**< Index of a string descriptor describing the configuration. */\r
+ uint8_t bmAttributes; /**< Configuration attributes, comprised of a mask of \c USB_CONFIG_ATTR_* masks.\r
+ * On all devices, this should include USB_CONFIG_ATTR_RESERVED at a minimum.\r
+ */\r
+ uint8_t bMaxPower; /**< Maximum power consumption of the device while in the\r
+ * current configuration, calculated by the \ref USB_CONFIG_POWER_MA()\r
+ * macro.\r
+ */\r
+ } ATTR_PACKED USB_StdDescriptor_Configuration_Header_t;\r
+\r
+ /** \brief Standard USB Interface Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard Interface Descriptor. This structure uses LUFA-specific element names\r
+ * to make each element's purpose clearer.\r
+ *\r
+ * \see \ref USB_StdDescriptor_Interface_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+\r
+ uint8_t InterfaceNumber; /**< Index of the interface in the current configuration. */\r
+ uint8_t AlternateSetting; /**< Alternate setting for the interface number. The same\r
+ * interface number can have multiple alternate settings\r
+ * with different endpoint configurations, which can be\r
+ * selected by the host.\r
+ */\r
+ uint8_t TotalEndpoints; /**< Total number of endpoints in the interface. */\r
+\r
+ uint8_t Class; /**< Interface class ID. */\r
+ uint8_t SubClass; /**< Interface subclass ID. */\r
+ uint8_t Protocol; /**< Interface protocol ID. */\r
+\r
+ uint8_t InterfaceStrIndex; /**< Index of the string descriptor describing the interface. */\r
+ } ATTR_PACKED USB_Descriptor_Interface_t;\r
+\r
+ /** \brief Standard USB Interface Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard Interface Descriptor. This structure uses the relevant standard's given element names\r
+ * to ensure compatibility with the standard.\r
+ *\r
+ * \see \ref USB_Descriptor_Interface_t for the version of this type with non-standard LUFA specific element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+ uint8_t bInterfaceNumber; /**< Index of the interface in the current configuration. */\r
+ uint8_t bAlternateSetting; /**< Alternate setting for the interface number. The same\r
+ * interface number can have multiple alternate settings\r
+ * with different endpoint configurations, which can be\r
+ * selected by the host.\r
+ */\r
+ uint8_t bNumEndpoints; /**< Total number of endpoints in the interface. */\r
+ uint8_t bInterfaceClass; /**< Interface class ID. */\r
+ uint8_t bInterfaceSubClass; /**< Interface subclass ID. */\r
+ uint8_t bInterfaceProtocol; /**< Interface protocol ID. */\r
+ uint8_t iInterface; /**< Index of the string descriptor describing the\r
+ * interface.\r
+ */\r
+ } ATTR_PACKED USB_StdDescriptor_Interface_t;\r
+\r
+ /** \brief Standard USB Interface Association Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard Interface Association Descriptor. This structure uses LUFA-specific element names\r
+ * to make each element's purpose clearer.\r
+ *\r
+ * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at\r
+ * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite\r
+ * devices with multiple interfaces related to the same function to have the multiple interfaces bound\r
+ * together at the point of enumeration, loading one generic driver for all the interfaces in the single\r
+ * function. Read the ECN for more information.\r
+ *\r
+ * \see \ref USB_StdDescriptor_Interface_Association_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+\r
+ uint8_t FirstInterfaceIndex; /**< Index of the first associated interface. */\r
+ uint8_t TotalInterfaces; /**< Total number of associated interfaces. */\r
+\r
+ uint8_t Class; /**< Interface class ID. */\r
+ uint8_t SubClass; /**< Interface subclass ID. */\r
+ uint8_t Protocol; /**< Interface protocol ID. */\r
+\r
+ uint8_t IADStrIndex; /**< Index of the string descriptor describing the\r
+ * interface association.\r
+ */\r
+ } ATTR_PACKED USB_Descriptor_Interface_Association_t;\r
+\r
+ /** \brief Standard USB Interface Association Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard Interface Association Descriptor. This structure uses the relevant standard's given\r
+ * element names to ensure compatibility with the standard.\r
+ *\r
+ * This descriptor has been added as a supplement to the USB2.0 standard, in the ECN located at\r
+ * <a>http://www.usb.org/developers/docs/InterfaceAssociationDescriptor_ecn.pdf</a>. It allows composite\r
+ * devices with multiple interfaces related to the same function to have the multiple interfaces bound\r
+ * together at the point of enumeration, loading one generic driver for all the interfaces in the single\r
+ * function. Read the ECN for more information.\r
+ *\r
+ * \see \ref USB_Descriptor_Interface_Association_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a value\r
+ * given by the specific class.\r
+ */\r
+ uint8_t bFirstInterface; /**< Index of the first associated interface. */\r
+ uint8_t bInterfaceCount; /**< Total number of associated interfaces. */\r
+ uint8_t bFunctionClass; /**< Interface class ID. */\r
+ uint8_t bFunctionSubClass; /**< Interface subclass ID. */\r
+ uint8_t bFunctionProtocol; /**< Interface protocol ID. */\r
+ uint8_t iFunction; /**< Index of the string descriptor describing the\r
+ * interface association.\r
+ */\r
+ } ATTR_PACKED USB_StdDescriptor_Interface_Association_t;\r
+\r
+ /** \brief Standard USB Endpoint Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard Endpoint Descriptor. This structure uses LUFA-specific element names\r
+ * to make each element's purpose clearer.\r
+ *\r
+ * \see \ref USB_StdDescriptor_Endpoint_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+\r
+ uint8_t EndpointAddress; /**< Logical address of the endpoint within the device for the current\r
+ * configuration, including direction mask.\r
+ */\r
+ uint8_t Attributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)\r
+ * and attributes (ENDPOINT_ATTR_*) masks.\r
+ */\r
+ uint16_t EndpointSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet\r
+ * size that the endpoint can receive at a time.\r
+ */\r
+ uint8_t PollingIntervalMS; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT\r
+ * or ISOCHRONOUS type.\r
+ */\r
+ } ATTR_PACKED USB_Descriptor_Endpoint_t;\r
+\r
+ /** \brief Standard USB Endpoint Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard Endpoint Descriptor. This structure uses the relevant standard's given\r
+ * element names to ensure compatibility with the standard.\r
+ *\r
+ * \see \ref USB_Descriptor_Endpoint_t for the version of this type with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t or a\r
+ * value given by the specific class.\r
+ */\r
+ uint8_t bEndpointAddress; /**< Logical address of the endpoint within the device for the current\r
+ * configuration, including direction mask.\r
+ */\r
+ uint8_t bmAttributes; /**< Endpoint attributes, comprised of a mask of the endpoint type (EP_TYPE_*)\r
+ * and attributes (ENDPOINT_ATTR_*) masks.\r
+ */\r
+ uint16_t wMaxPacketSize; /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size\r
+ * that the endpoint can receive at a time.\r
+ */\r
+ uint8_t bInterval; /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or\r
+ * ISOCHRONOUS type.\r
+ */\r
+ } ATTR_PACKED USB_StdDescriptor_Endpoint_t;\r
+\r
+ /** \brief Standard USB String Descriptor (LUFA naming conventions).\r
+ *\r
+ * Type define for a standard string descriptor. Unlike other standard descriptors, the length\r
+ * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()\r
+ * macro rather than by the size of the descriptor structure, as the length is not fixed.\r
+ *\r
+ * This structure should also be used for string index 0, which contains the supported language IDs for\r
+ * the device as an array.\r
+ *\r
+ * This structure uses LUFA-specific element names to make each element's purpose clearer.\r
+ *\r
+ * \see \ref USB_StdDescriptor_String_t for the version of this type with standard element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ USB_Descriptor_Header_t Header; /**< Descriptor header, including type and size. */\r
+\r
+ #if (((ARCH == ARCH_AVR8) || (ARCH == ARCH_XMEGA)) && !defined(__DOXYGEN__))\r
+ wchar_t UnicodeString[];\r
+ #else\r
+ uint16_t UnicodeString[]; /**< String data, as unicode characters (alternatively,\r
+ * string language IDs). If normal ASCII characters are\r
+ * to be used, they must be added as an array of characters\r
+ * rather than a normal C string so that they are widened to\r
+ * Unicode size.\r
+ *\r
+ * Under GCC, strings prefixed with the "L" character (before\r
+ * the opening string quotation mark) are considered to be\r
+ * Unicode strings, and may be used instead of an explicit\r
+ * array of ASCII characters on little endian devices with\r
+ * UTF-16-LE \c wchar_t encoding.\r
+ */\r
+ #endif\r
+ } ATTR_PACKED USB_Descriptor_String_t;\r
+\r
+ /** \brief Standard USB String Descriptor (USB-IF naming conventions).\r
+ *\r
+ * Type define for a standard string descriptor. Unlike other standard descriptors, the length\r
+ * of the descriptor for placement in the descriptor header must be determined by the \ref USB_STRING_LEN()\r
+ * macro rather than by the size of the descriptor structure, as the length is not fixed.\r
+ *\r
+ * This structure should also be used for string index 0, which contains the supported language IDs for\r
+ * the device as an array.\r
+ *\r
+ * This structure uses the relevant standard's given element names to ensure compatibility with the standard.\r
+ *\r
+ * \see \ref USB_Descriptor_String_t for the version of this type with with non-standard LUFA specific\r
+ * element names.\r
+ *\r
+ * \note Regardless of CPU architecture, these values should be stored as little endian.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bLength; /**< Size of the descriptor, in bytes. */\r
+ uint8_t bDescriptorType; /**< Type of the descriptor, either a value in \ref USB_DescriptorTypes_t\r
+ * or a value given by the specific class.\r
+ */\r
+ uint16_t bString[]; /**< String data, as unicode characters (alternatively, string language IDs).\r
+ * If normal ASCII characters are to be used, they must be added as an array\r
+ * of characters rather than a normal C string so that they are widened to\r
+ * Unicode size.\r
+ *\r
+ * Under GCC, strings prefixed with the "L" character (before the opening string\r
+ * quotation mark) are considered to be Unicode strings, and may be used instead\r
+ * of an explicit array of ASCII characters.\r
+ */\r
+ } ATTR_PACKED USB_StdDescriptor_String_t;\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define VERSION_TENS(x) (int)((int)(x) / 10)\r
+ #define VERSION_ONES(x) (int)((int)(x) % 10)\r
+ #define VERSION_TENTHS(x) (int)(((x * 1) - ((int)(x * 1))) * 10)\r
+ #define VERSION_HUNDREDTHS(x) (int)(((x * 10) - ((int)(x * 10))) * 10)\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB control endpoint request definitions.\r
+ * \copydetails Group_StdRequest\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USB\r
+ * \defgroup Group_StdRequest Standard USB Requests\r
+ * \brief USB control endpoint request definitions.\r
+ *\r
+ * This module contains definitions for the various control request parameters, so that the request\r
+ * details (such as data direction, request recipient, etc.) can be extracted via masking.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __STDREQTYPE_H__\r
+#define __STDREQTYPE_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Mask for the request type parameter, to indicate the direction of the request data (Host to Device\r
+ * or Device to Host). The result of this mask should then be compared to the request direction masks.\r
+ *\r
+ * \see \c REQDIR_* macros for masks indicating the request data direction.\r
+ */\r
+ #define CONTROL_REQTYPE_DIRECTION 0x80\r
+\r
+ /** Mask for the request type parameter, to indicate the type of request (Device, Class or Vendor\r
+ * Specific). The result of this mask should then be compared to the request type masks.\r
+ *\r
+ * \see \c REQTYPE_* macros for masks indicating the request type.\r
+ */\r
+ #define CONTROL_REQTYPE_TYPE 0x60\r
+\r
+ /** Mask for the request type parameter, to indicate the recipient of the request (Device, Interface\r
+ * Endpoint or Other). The result of this mask should then be compared to the request recipient\r
+ * masks.\r
+ *\r
+ * \see \c REQREC_* macros for masks indicating the request recipient.\r
+ */\r
+ #define CONTROL_REQTYPE_RECIPIENT 0x1F\r
+\r
+ /** \name Control Request Data Direction Masks */\r
+ //@{\r
+ /** Request data direction mask, indicating that the request data will flow from host to device.\r
+ *\r
+ * \see \ref CONTROL_REQTYPE_DIRECTION macro.\r
+ */\r
+ #define REQDIR_HOSTTODEVICE (0 << 7)\r
+\r
+ /** Request data direction mask, indicating that the request data will flow from device to host.\r
+ *\r
+ * \see \ref CONTROL_REQTYPE_DIRECTION macro.\r
+ */\r
+ #define REQDIR_DEVICETOHOST (1 << 7)\r
+ //@}\r
+\r
+ /** \name Control Request Type Masks */\r
+ //@{\r
+ /** Request type mask, indicating that the request is a standard request.\r
+ *\r
+ * \see \ref CONTROL_REQTYPE_TYPE macro.\r
+ */\r
+ #define REQTYPE_STANDARD (0 << 5)\r
+\r
+ /** Request type mask, indicating that the request is a class-specific request.\r
+ *\r
+ * \see \ref CONTROL_REQTYPE_TYPE macro.\r
+ */\r
+ #define REQTYPE_CLASS (1 << 5)\r
+\r
+ /** Request type mask, indicating that the request is a vendor specific request.\r
+ *\r
+ * \see \ref CONTROL_REQTYPE_TYPE macro.\r
+ */\r
+ #define REQTYPE_VENDOR (2 << 5)\r
+ //@}\r
+\r
+ /** \name Control Request Recipient Masks */\r
+ //@{\r
+ /** Request recipient mask, indicating that the request is to be issued to the device as a whole.\r
+ *\r
+ * \see \ref CONTROL_REQTYPE_RECIPIENT macro.\r
+ */\r
+ #define REQREC_DEVICE (0 << 0)\r
+\r
+ /** Request recipient mask, indicating that the request is to be issued to an interface in the\r
+ * currently selected configuration.\r
+ *\r
+ * \see \ref CONTROL_REQTYPE_RECIPIENT macro.\r
+ */\r
+ #define REQREC_INTERFACE (1 << 0)\r
+\r
+ /** Request recipient mask, indicating that the request is to be issued to an endpoint in the\r
+ * currently selected configuration.\r
+ *\r
+ * \see \ref CONTROL_REQTYPE_RECIPIENT macro.\r
+ */\r
+ #define REQREC_ENDPOINT (2 << 0)\r
+\r
+ /** Request recipient mask, indicating that the request is to be issued to an unspecified element\r
+ * in the currently selected configuration.\r
+ *\r
+ * \see \ref CONTROL_REQTYPE_RECIPIENT macro.\r
+ */\r
+ #define REQREC_OTHER (3 << 0)\r
+ //@}\r
+\r
+ /* Type Defines: */\r
+ /** \brief Standard USB Control Request\r
+ *\r
+ * Type define for a standard USB control request.\r
+ *\r
+ * \see The USB 2.0 specification for more information on standard control requests.\r
+ */\r
+ typedef struct\r
+ {\r
+ uint8_t bmRequestType; /**< Type of the request. */\r
+ uint8_t bRequest; /**< Request command code. */\r
+ uint16_t wValue; /**< wValue parameter of the request. */\r
+ uint16_t wIndex; /**< wIndex parameter of the request. */\r
+ uint16_t wLength; /**< Length of the data to transfer in bytes. */\r
+ } ATTR_PACKED USB_Request_Header_t;\r
+\r
+ /* Enums: */\r
+ /** Enumeration for the various standard request commands. These commands are applicable when the\r
+ * request type is \ref REQTYPE_STANDARD (with the exception of \ref REQ_GetDescriptor, which is always\r
+ * handled regardless of the request type value).\r
+ *\r
+ * \see Chapter 9 of the USB 2.0 Specification.\r
+ */\r
+ enum USB_Control_Request_t\r
+ {\r
+ REQ_GetStatus = 0, /**< Implemented in the library for device and endpoint recipients. Passed\r
+ * to the user application for other recipients via the\r
+ * \ref EVENT_USB_Device_ControlRequest() event when received in\r
+ * device mode. */\r
+ REQ_ClearFeature = 1, /**< Implemented in the library for device and endpoint recipients. Passed\r
+ * to the user application for other recipients via the\r
+ * \ref EVENT_USB_Device_ControlRequest() event when received in\r
+ * device mode. */\r
+ REQ_SetFeature = 3, /**< Implemented in the library for device and endpoint recipients. Passed\r
+ * to the user application for other recipients via the\r
+ * \ref EVENT_USB_Device_ControlRequest() event when received in\r
+ * device mode. */\r
+ REQ_SetAddress = 5, /**< Implemented in the library for the device recipient. Passed\r
+ * to the user application for other recipients via the\r
+ * \ref EVENT_USB_Device_ControlRequest() event when received in\r
+ * device mode. */\r
+ REQ_GetDescriptor = 6, /**< Implemented in the library for device and interface recipients. Passed to the\r
+ * user application for other recipients via the\r
+ * \ref EVENT_USB_Device_ControlRequest() event when received in\r
+ * device mode. */\r
+ REQ_SetDescriptor = 7, /**< Not implemented in the library, passed to the user application\r
+ * via the \ref EVENT_USB_Device_ControlRequest() event when received in\r
+ * device mode. */\r
+ REQ_GetConfiguration = 8, /**< Implemented in the library for the device recipient. Passed\r
+ * to the user application for other recipients via the\r
+ * \ref EVENT_USB_Device_ControlRequest() event when received in\r
+ * device mode. */\r
+ REQ_SetConfiguration = 9, /**< Implemented in the library for the device recipient. Passed\r
+ * to the user application for other recipients via the\r
+ * \ref EVENT_USB_Device_ControlRequest() event when received in\r
+ * device mode. */\r
+ REQ_GetInterface = 10, /**< Not implemented in the library, passed to the user application\r
+ * via the \ref EVENT_USB_Device_ControlRequest() event when received in\r
+ * device mode. */\r
+ REQ_SetInterface = 11, /**< Not implemented in the library, passed to the user application\r
+ * via the \ref EVENT_USB_Device_ControlRequest() event when received in\r
+ * device mode. */\r
+ REQ_SynchFrame = 12, /**< Not implemented in the library, passed to the user application\r
+ * via the \ref EVENT_USB_Device_ControlRequest() event when received in\r
+ * device mode. */\r
+ };\r
+\r
+ /** Feature Selector values for Set Feature and Clear Feature standard control requests directed to the device, interface\r
+ * and endpoint recipients.\r
+ */\r
+ enum USB_Feature_Selectors_t\r
+ {\r
+ FEATURE_SEL_EndpointHalt = 0x00, /**< Feature selector for Clear Feature or Set Feature commands. When\r
+ * used in a Set Feature or Clear Feature request this indicates that an\r
+ * endpoint (whose address is given elsewhere in the request) should have\r
+ * its stall condition changed.\r
+ */\r
+ FEATURE_SEL_DeviceRemoteWakeup = 0x01, /**< Feature selector for Device level Remote Wakeup enable set or clear.\r
+ * This feature can be controlled by the host on devices which indicate\r
+ * remote wakeup support in their descriptors to selectively disable or\r
+ * enable remote wakeup.\r
+ */\r
+ FEATURE_SEL_TestMode = 0x02, /**< Feature selector for Test Mode features, used to test the USB controller\r
+ * to check for incorrect operation.\r
+ */\r
+ };\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define FEATURE_SELFPOWERED_ENABLED (1 << 0)\r
+ #define FEATURE_REMOTE_WAKEUP_ENABLED (1 << 1)\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_UC3)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#include "../Device.h"\r
+\r
+void USB_Device_SendRemoteWakeup(void)\r
+{\r
+ USB_CLK_Unfreeze();\r
+\r
+ AVR32_USBB.UDCON.rmwkup = true;\r
+ while (AVR32_USBB.UDCON.rmwkup);\r
+}\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Device definitions for the AVR32 UC3 microcontrollers.\r
+ * \copydetails Group_Device_UC3\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_Device\r
+ * \defgroup Group_Device_UC3 Device Management (UC3)\r
+ * \brief USB Device definitions for the AVR32 UC3 microcontrollers.\r
+ *\r
+ * Architecture specific USB Device definitions for the Atmel 32-bit UC3 AVR microcontrollers.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBDEVICE_UC3_H__\r
+#define __USBDEVICE_UC3_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBController.h"\r
+ #include "../StdDescriptors.h"\r
+ #include "../USBInterrupt.h"\r
+ #include "../Endpoint.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name USB Device Mode Option Masks */\r
+ //@{\r
+ /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the\r
+ * USB interface should be initialized in low speed (1.5Mb/s) mode.\r
+ *\r
+ * \note Restrictions apply on the number, size and type of endpoints which can be used\r
+ * when running in low speed mode - please refer to the USB 2.0 specification.\r
+ */\r
+ #define USB_DEVICE_OPT_LOWSPEED (1 << 0)\r
+\r
+ /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the\r
+ * USB interface should be initialized in full speed (12Mb/s) mode.\r
+ */\r
+ #define USB_DEVICE_OPT_FULLSPEED (0 << 0)\r
+\r
+ #if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) || defined(__DOXYGEN__)\r
+ /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the\r
+ * USB interface should be initialized in high speed (480Mb/s) mode.\r
+ */\r
+ #define USB_DEVICE_OPT_HIGHSPEED (1 << 1)\r
+ #endif\r
+ //@}\r
+\r
+ #if (!defined(NO_INTERNAL_SERIAL) && \\r
+ (defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) || \\r
+ defined(__DOXYGEN__)))\r
+ /** String descriptor index for the device's unique serial number string descriptor within the device.\r
+ * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port\r
+ * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain\r
+ * a unique serial number internally, and setting the device descriptors serial number string index to this value\r
+ * will cause it to use the internal serial number.\r
+ *\r
+ * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial\r
+ * number for the device.\r
+ */\r
+ #define USE_INTERNAL_SERIAL 0xDC\r
+\r
+ /** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller\r
+ * model.\r
+ */\r
+ #define INTERNAL_SERIAL_LENGTH_BITS 120\r
+\r
+ /** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller\r
+ * model.\r
+ */\r
+ #define INTERNAL_SERIAL_START_ADDRESS 0x80800204\r
+ #else\r
+ #define USE_INTERNAL_SERIAL NO_DESCRIPTOR\r
+\r
+ #define INTERNAL_SERIAL_LENGTH_BITS 0\r
+ #define INTERNAL_SERIAL_START_ADDRESS 0\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ /** Sends a Remote Wakeup request to the host. This signals to the host that the device should\r
+ * be taken out of suspended mode, and communications should resume.\r
+ *\r
+ * Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the\r
+ * host computer when the host has suspended all USB devices to enter a low power state.\r
+ *\r
+ * \note This function should only be used if the device has indicated to the host that it\r
+ * supports the Remote Wakeup feature in the device descriptors, and should only be\r
+ * issued if the host is currently allowing remote wakeup events from the device (i.e.,\r
+ * the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP\r
+ * compile time option is used, this function is unavailable.\r
+ *\r
+ * \note The USB clock must be running for this function to operate. If the stack is initialized with\r
+ * the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running\r
+ * before attempting to call this function.\r
+ *\r
+ * \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors.\r
+ */\r
+ void USB_Device_SendRemoteWakeup(void);\r
+\r
+ /* Inline Functions: */\r
+ /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)\r
+ * the frame number is incremented by one.\r
+ *\r
+ * \return Current USB frame number from the USB controller.\r
+ */\r
+ static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint16_t USB_Device_GetFrameNumber(void)\r
+ {\r
+ return AVR32_USBB.UDFNUM.fnum;\r
+ }\r
+\r
+ #if !defined(NO_SOF_EVENTS)\r
+ /** Enables the device mode Start Of Frame events. When enabled, this causes the\r
+ * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,\r
+ * at the start of each USB frame when enumerated in device mode.\r
+ *\r
+ * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_EnableSOFEvents(void)\r
+ {\r
+ USB_INT_Enable(USB_INT_SOFI);\r
+ }\r
+\r
+ /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the\r
+ * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.\r
+ *\r
+ * \note Not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_DisableSOFEvents(void)\r
+ {\r
+ USB_INT_Disable(USB_INT_SOFI);\r
+ }\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Inline Functions: */\r
+ static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetLowSpeed(void)\r
+ {\r
+ AVR32_USBB.UDCON.ls = true;\r
+ }\r
+\r
+ static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetFullSpeed(void)\r
+ {\r
+ AVR32_USBB.UDCON.ls = false;\r
+ #if defined(USB_DEVICE_OPT_HIGHSPEED)\r
+ AVR32_USBB.UDCON.spdconf = 3;\r
+ #endif\r
+ }\r
+\r
+ #if defined(USB_DEVICE_OPT_HIGHSPEED)\r
+ static inline void USB_Device_SetHighSpeed(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetHighSpeed(void)\r
+ {\r
+ AVR32_USBB.UDCON.ls = false;\r
+ AVR32_USBB.UDCON.spdconf = 0;\r
+ }\r
+ #endif\r
+\r
+ static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetDeviceAddress(const uint8_t Address)\r
+ {\r
+ AVR32_USBB.UDCON.uadd = Address;\r
+ AVR32_USBB.UDCON.adden = (Address ? true : false);\r
+ }\r
+\r
+ static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool USB_Device_IsAddressSet(void)\r
+ {\r
+ return AVR32_USBB.UDCON.adden;\r
+ }\r
+\r
+ #if (USE_INTERNAL_SERIAL != NO_DESCRIPTOR)\r
+ static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString)\r
+ {\r
+ uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+ GlobalInterruptDisable();\r
+\r
+ uint8_t* SigReadAddress = (uint8_t*)INTERNAL_SERIAL_START_ADDRESS;\r
+\r
+ for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)\r
+ {\r
+ uint8_t SerialByte = *SigReadAddress;\r
+\r
+ if (SerialCharNum & 0x01)\r
+ {\r
+ SerialByte >>= 4;\r
+ SigReadAddress++;\r
+ }\r
+\r
+ SerialByte &= 0x0F;\r
+\r
+ UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?\r
+ (('A' - 10) + SerialByte) : ('0' + SerialByte));\r
+ }\r
+\r
+ SetGlobalInterruptMask(CurrentGlobalInt);\r
+ }\r
+ #endif\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_UC3)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#include "EndpointStream_UC3.h"\r
+\r
+#if !defined(CONTROL_ONLY_DEVICE)\r
+uint8_t Endpoint_Discard_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t ErrorCode;\r
+ uint16_t BytesInTransfer = 0;\r
+ \r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ \r
+ if (BytesProcessed != NULL)\r
+ Length -= *BytesProcessed;\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ {\r
+ Endpoint_ClearOUT();\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return ENDPOINT_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ Endpoint_Discard_8();\r
+\r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+ \r
+ return ENDPOINT_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t Endpoint_Null_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t ErrorCode;\r
+ uint16_t BytesInTransfer = 0;\r
+ \r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ \r
+ if (BytesProcessed != NULL)\r
+ Length -= *BytesProcessed;\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ {\r
+ Endpoint_ClearIN();\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return ENDPOINT_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ Endpoint_Write_8(0);\r
+\r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+ \r
+ return ENDPOINT_RWSTREAM_NoError;\r
+}\r
+\r
+/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,\r
+ * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)\r
+#include "Template/Template_Endpoint_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)\r
+#include "Template/Template_Endpoint_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE\r
+#define TEMPLATE_BUFFER_TYPE void*\r
+#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()\r
+#include "Template/Template_Endpoint_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE\r
+#define TEMPLATE_BUFFER_TYPE void*\r
+#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()\r
+#include "Template/Template_Endpoint_RW.c"\r
+\r
+#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE\r
+ #define TEMPLATE_BUFFER_TYPE const void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_RW.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE\r
+ #define TEMPLATE_BUFFER_TYPE const void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_RW.c"\r
+#endif\r
+\r
+#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE\r
+ #define TEMPLATE_BUFFER_TYPE const void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_RW.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE\r
+ #define TEMPLATE_BUFFER_TYPE const void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_RW.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE\r
+ #define TEMPLATE_BUFFER_TYPE void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())\r
+ #include "Template/Template_Endpoint_RW.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE\r
+ #define TEMPLATE_BUFFER_TYPE void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())\r
+ #include "Template/Template_Endpoint_RW.c"\r
+#endif\r
+\r
+#endif\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)\r
+#include "Template/Template_Endpoint_Control_W.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)\r
+#include "Template/Template_Endpoint_Control_W.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()\r
+#include "Template/Template_Endpoint_Control_R.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()\r
+#include "Template/Template_Endpoint_Control_R.c"\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Endpoint data stream transmission and reception management for the AVR32 UC3 microcontrollers.\r
+ * \copydetails Group_EndpointStreamRW_UC3\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_EndpointStreamRW\r
+ * \defgroup Group_EndpointStreamRW_UC3 Read/Write of Multi-Byte Streams (UC3)\r
+ * \brief Endpoint data stream transmission and reception management for the Atmel AVR32 UC3 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of data streams from\r
+ * and to endpoints.\r
+ *\r
+ * @{\r
+ */ \r
+\r
+#ifndef __ENDPOINT_STREAM_UC3_H__\r
+#define __ENDPOINT_STREAM_UC3_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBMode.h"\r
+ #include "../USBTask.h"\r
+ \r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Function Prototypes: */\r
+ /** \name Stream functions for null data */\r
+ //@{\r
+\r
+ /** Reads and discards the given number of bytes from the currently selected endpoint's bank,\r
+ * discarding fully read packets from the host as needed. The last packet is not automatically\r
+ * discarded once the remaining bytes has been read; the user is responsible for manually\r
+ * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the endpoint bank becomes empty while there is still data to process (and after the current\r
+ * packet has been acknowledged) the BytesProcessed location will be updated with the total number\r
+ * of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[in] Length Number of bytes to discard via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Discard_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed);\r
+\r
+ /** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending\r
+ * full packets to the host as needed. The last packet is not automatically sent once the \r
+ * remaining bytes have been written; the user is responsible for manually sending the last\r
+ * packet to the host via the \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the endpoint bank becomes full while there is still data to process (and after the current\r
+ * packet transmission has been initiated) the BytesProcessed location will be updated with the\r
+ * total number of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[in] Length Number of zero bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Null_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed);\r
+\r
+ //@}\r
+\r
+ /** \name Stream functions for RAM source/destination data */\r
+ //@{\r
+ \r
+ /** Writes the given number of bytes to the endpoint from the given buffer in little endian,\r
+ * sending full packets to the host as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the endpoint bank becomes full while there is still data to process (and after the current\r
+ * packet transmission has been initiated) the BytesProcessed location will be updated with the\r
+ * total number of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),\r
+ * NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),\r
+ * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Stream_LE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the endpoint from the given buffer in big endian,\r
+ * sending full packets to the host as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Stream_BE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+ \r
+ /** Reads the given number of bytes from the endpoint from the given buffer in little endian,\r
+ * discarding fully read packets from the host as needed. The last packet is not automatically\r
+ * discarded once the remaining bytes has been read; the user is responsible for manually\r
+ * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the endpoint bank becomes empty while there is still data to process (and after the current\r
+ * packet has been acknowledged) the BytesProcessed location will be updated with the total number\r
+ * of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),\r
+ * NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),\r
+ * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Stream_LE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the endpoint from the given buffer in big endian,\r
+ * discarding fully read packets from the host as needed. The last packet is not automatically\r
+ * discarded once the remaining bytes has been read; the user is responsible for manually\r
+ * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Stream_BE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,\r
+ * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared\r
+ * in both failure and success states; the user is responsible for manually clearing the status OUT packet\r
+ * to finalize the transfer's status stage via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,\r
+ * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared\r
+ * in both failure and success states; the user is responsible for manually clearing the status OUT packet\r
+ * to finalize the transfer's status stage via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,\r
+ * discarding fully read packets from the host as needed. The device IN acknowledgement is not\r
+ * automatically sent after success or failure states; the user is responsible for manually sending the\r
+ * status IN packet to finalize the transfer's status stage via the \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,\r
+ * discarding fully read packets from the host as needed. The device IN acknowledgement is not\r
+ * automatically sent after success or failure states; the user is responsible for manually sending the\r
+ * status IN packet to finalize the transfer's status stage via the \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+ //@}\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_UC3)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#include "../Endpoint.h"\r
+\r
+#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)\r
+uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;\r
+#endif\r
+\r
+volatile uint32_t USB_Endpoint_SelectedEndpoint = ENDPOINT_CONTROLEP;\r
+volatile uint8_t* USB_Endpoint_FIFOPos[ENDPOINT_TOTAL_ENDPOINTS];\r
+\r
+bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table,\r
+ const uint8_t Entries)\r
+{\r
+ for (uint8_t i = 0; i < Entries; i++)\r
+ {\r
+ if (!(Table[i].Address))\r
+ continue;\r
+ \r
+ if (!(Endpoint_ConfigureEndpoint(Table[i].Address, Table[i].Type, Table[i].Size, Table[i].Banks)))\r
+ {\r
+ return false;\r
+ }\r
+ }\r
+ \r
+ return true;\r
+}\r
+\r
+bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,\r
+ const uint32_t UECFG0Data)\r
+{\r
+ USB_Endpoint_FIFOPos[Number] = &AVR32_USBB_SLAVE[Number * ENDPOINT_HSB_ADDRESS_SPACE_SIZE];\r
+\r
+#if defined(CONTROL_ONLY_DEVICE) || defined(ORDERED_EP_CONFIG)\r
+ Endpoint_SelectEndpoint(Number);\r
+ Endpoint_EnableEndpoint();\r
+\r
+ (&AVR32_USBB.uecfg0)[Number] = 0;\r
+ (&AVR32_USBB.uecfg0)[Number] = UECFG0Data;\r
+\r
+ return Endpoint_IsConfigured();\r
+#else\r
+ for (uint8_t EPNum = Number; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)\r
+ {\r
+ uint32_t UECFG0Temp;\r
+\r
+ Endpoint_SelectEndpoint(EPNum);\r
+\r
+ if (EPNum == Number)\r
+ {\r
+ UECFG0Temp = UECFG0Data;\r
+ }\r
+ else\r
+ {\r
+ UECFG0Temp = (&AVR32_USBB.uecfg0)[EPNum];\r
+ }\r
+\r
+ if (!(UECFG0Temp & AVR32_USBB_ALLOC_MASK))\r
+ continue;\r
+\r
+ Endpoint_DisableEndpoint();\r
+ (&AVR32_USBB.uecfg0)[EPNum] &= ~AVR32_USBB_ALLOC_MASK;\r
+\r
+ Endpoint_EnableEndpoint();\r
+ (&AVR32_USBB.uecfg0)[EPNum] = UECFG0Temp;\r
+\r
+ if (!(Endpoint_IsConfigured()))\r
+ return false;\r
+ }\r
+\r
+ Endpoint_SelectEndpoint(Number);\r
+ return true;\r
+#endif\r
+}\r
+\r
+void Endpoint_ClearEndpoints(void)\r
+{\r
+ for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)\r
+ {\r
+ Endpoint_SelectEndpoint(EPNum);\r
+ (&AVR32_USBB.uecfg0)[EPNum] = 0;\r
+ (&AVR32_USBB.uecon0clr)[EPNum] = -1;\r
+ USB_Endpoint_FIFOPos[EPNum] = &AVR32_USBB_SLAVE[EPNum * 0x10000];\r
+ Endpoint_DisableEndpoint();\r
+ }\r
+}\r
+\r
+void Endpoint_ClearStatusStage(void)\r
+{\r
+ if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST)\r
+ {\r
+ while (!(Endpoint_IsOUTReceived()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return;\r
+ }\r
+\r
+ Endpoint_ClearOUT();\r
+ }\r
+ else\r
+ {\r
+ while (!(Endpoint_IsINReady()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return;\r
+ }\r
+\r
+ Endpoint_ClearIN();\r
+ }\r
+}\r
+\r
+#if !defined(CONTROL_ONLY_DEVICE)\r
+uint8_t Endpoint_WaitUntilReady(void)\r
+{\r
+ #if (USB_STREAM_TIMEOUT_MS < 0xFF)\r
+ uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #else\r
+ uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #endif\r
+\r
+ uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber();\r
+\r
+ for (;;)\r
+ {\r
+ if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN)\r
+ {\r
+ if (Endpoint_IsINReady())\r
+ return ENDPOINT_READYWAIT_NoError;\r
+ }\r
+ else\r
+ {\r
+ if (Endpoint_IsOUTReceived())\r
+ return ENDPOINT_READYWAIT_NoError;\r
+ }\r
+\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_READYWAIT_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_READYWAIT_BusSuspended;\r
+ else if (Endpoint_IsStalled())\r
+ return ENDPOINT_READYWAIT_EndpointStalled;\r
+\r
+ uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber();\r
+\r
+ if (CurrentFrameNumber != PreviousFrameNumber)\r
+ {\r
+ PreviousFrameNumber = CurrentFrameNumber;\r
+\r
+ if (!(TimeoutMSRem--))\r
+ return ENDPOINT_READYWAIT_Timeout;\r
+ }\r
+ }\r
+}\r
+#endif\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Endpoint definitions for the AVR32 UC3 microcontrollers.\r
+ * \copydetails Group_EndpointManagement_UC3\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_EndpointRW\r
+ * \defgroup Group_EndpointRW_UC3 Endpoint Data Reading and Writing (UC3)\r
+ * \brief Endpoint data read/write definitions for the Atmel AVR32 UC3 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointPrimitiveRW\r
+ * \defgroup Group_EndpointPrimitiveRW_UC3 Read/Write of Primitive Data Types (UC3)\r
+ * \brief Endpoint primitive read/write definitions for the Atmel AVR32 UC3 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of primitive data types\r
+ * from and to endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointPacketManagement\r
+ * \defgroup Group_EndpointPacketManagement_UC3 Endpoint Packet Management (UC3)\r
+ * \brief Endpoint packet management definitions for the Atmel AVR32 UC3 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to packet management of endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointManagement\r
+ * \defgroup Group_EndpointManagement_UC3 Endpoint Management (UC3)\r
+ * \brief Endpoint management definitions for the Atmel AVR32 UC3 architecture.\r
+ *\r
+ * Functions, macros and enums related to endpoint management when in USB Device mode. This\r
+ * module contains the endpoint management macros, as well as endpoint interrupt and data\r
+ * send/receive functions for various data types.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __ENDPOINT_UC3_H__\r
+#define __ENDPOINT_UC3_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBTask.h"\r
+ #include "../USBInterrupt.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define ENDPOINT_HSB_ADDRESS_SPACE_SIZE (64 * 1024UL)\r
+\r
+ /* Inline Functions: */\r
+ static inline uint32_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST\r
+ ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)\r
+ {\r
+ uint8_t MaskVal = 0;\r
+ uint16_t CheckBytes = 8;\r
+\r
+ while (CheckBytes < Bytes)\r
+ {\r
+ MaskVal++;\r
+ CheckBytes <<= 1;\r
+ }\r
+\r
+ return (MaskVal << AVR32_USBB_EPSIZE_OFFSET);\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ void Endpoint_ClearEndpoints(void);\r
+ bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,\r
+ const uint32_t UECFGXData);\r
+\r
+ /* External Variables: */\r
+ extern volatile uint32_t USB_Endpoint_SelectedEndpoint;\r
+ extern volatile uint8_t* USB_Endpoint_FIFOPos[];\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))\r
+ /** Default size of the default control endpoint's bank, until altered by the control endpoint bank size\r
+ * value in the device descriptor. Not available if the \c FIXED_CONTROL_ENDPOINT_SIZE token is defined.\r
+ */\r
+ #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8\r
+ #endif\r
+\r
+ #if !defined(CONTROL_ONLY_DEVICE) || defined(__DOXYGEN__)\r
+ #if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32)\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 8\r
+ #else\r
+ /** Total number of endpoints (including the default control endpoint at address 0) which may\r
+ * be used in the device. Different AVR models support different amounts of endpoints,\r
+ * this value reflects the maximum number of endpoints for the currently selected AVR model.\r
+ */\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 7\r
+ #endif\r
+ #else\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 1\r
+ #endif\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error return codes of the \ref Endpoint_WaitUntilReady() function.\r
+ *\r
+ * \ingroup Group_EndpointRW_UC3\r
+ */\r
+ enum Endpoint_WaitUntilReady_ErrorCodes_t\r
+ {\r
+ ENDPOINT_READYWAIT_NoError = 0, /**< Endpoint is ready for next packet, no error. */\r
+ ENDPOINT_READYWAIT_EndpointStalled = 1, /**< The endpoint was stalled during the stream\r
+ * transfer by the host or device.\r
+ */\r
+ ENDPOINT_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while\r
+ * waiting for the endpoint to become ready.\r
+ */\r
+ ENDPOINT_READYWAIT_BusSuspended = 3, /**< The USB bus has been suspended by the host and\r
+ * no USB endpoint traffic can occur until the bus\r
+ * has resumed.\r
+ */\r
+ ENDPOINT_READYWAIT_Timeout = 4, /**< The host failed to accept or send the next packet\r
+ * within the software timeout period set by the\r
+ * \ref USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Configures the specified endpoint address with the given endpoint type, direction, bank size\r
+ * and banking mode. Once configured, the endpoint may be read from or written to, depending\r
+ * on its direction.\r
+ *\r
+ * \param[in] Address Endpoint address to configure.\r
+ *\r
+ * \param[in] Type Type of endpoint to configure, a \c EP_TYPE_* mask. Not all endpoint types\r
+ * are available on Low Speed USB devices - refer to the USB 2.0 specification.\r
+ *\r
+ * \param[in] Size Size of the endpoint's bank, where packets are stored before they are transmitted\r
+ * to the USB host, or after they have been received from the USB host (depending on\r
+ * the endpoint's data direction). The bank size must indicate the maximum packet size\r
+ * that the endpoint can handle.\r
+ *\r
+ * \param[in] Banks Number of hardware banks to use for the endpoint being configured.\r
+ *\r
+ * \attention When the \c ORDERED_EP_CONFIG compile time option is used, Endpoints <b>must</b> be configured in\r
+ * ascending order, or bank corruption will occur.\r
+ *\r
+ * \note Different endpoints may have different maximum packet sizes based on the endpoint's index - refer to\r
+ * the chosen microcontroller model's datasheet to determine the maximum bank size for each endpoint.\r
+ * \n\n\r
+ *\r
+ * \note The default control endpoint should not be manually configured by the user application, as\r
+ * it is automatically configured by the library internally.\r
+ * \n\n\r
+ *\r
+ * \note This routine will automatically select the specified endpoint upon success. Upon failure, the endpoint\r
+ * which failed to reconfigure correctly will be selected.\r
+ *\r
+ * \return Boolean \c true if the configuration succeeded, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address,\r
+ const uint8_t Type,\r
+ const uint16_t Size,\r
+ const uint8_t Banks) ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address,\r
+ const uint8_t Type,\r
+ const uint16_t Size,\r
+ const uint8_t Banks)\r
+ {\r
+ uint8_t Number = (Address & ENDPOINT_EPNUM_MASK);\r
+ \r
+ if (Number >= ENDPOINT_TOTAL_ENDPOINTS)\r
+ return false;\r
+\r
+ return Endpoint_ConfigureEndpoint_Prv(Number,\r
+ (AVR32_USBB_ALLOC_MASK |\r
+ ((uint32_t)Type << AVR32_USBB_EPTYPE_OFFSET) |\r
+ ((Address & ENDPOINT_DIR_IN) ? AVR32_USBB_UECFG0_EPDIR_MASK : 0) |\r
+ ((Banks > 1) ? AVR32_USBB_UECFG0_EPBK_SINGLE : AVR32_USBB_UECFG0_EPBK_DOUBLE) |\r
+ Endpoint_BytesToEPSizeMask(Size)));\r
+ }\r
+\r
+ /** Indicates the number of bytes currently stored in the current endpoint's selected bank.\r
+ *\r
+ * \ingroup Group_EndpointRW_UC3\r
+ *\r
+ * \return Total number of bytes in the currently selected Endpoint's FIFO buffer.\r
+ */\r
+ static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Endpoint_BytesInEndpoint(void)\r
+ {\r
+ return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].byct;\r
+ }\r
+\r
+ /** Determines the currently selected endpoint's direction.\r
+ *\r
+ * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask.\r
+ */\r
+ static inline uint32_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Endpoint_GetEndpointDirection(void)\r
+ {\r
+ return ((&AVR32_USBB.UECFG0)[USB_Endpoint_SelectedEndpoint].epdir ? ENDPOINT_DIR_IN : ENDPOINT_DIR_OUT);\r
+ }\r
+\r
+ /** Get the endpoint address of the currently selected endpoint. This is typically used to save\r
+ * the currently selected endpoint so that it can be restored after another endpoint has been\r
+ * manipulated.\r
+ *\r
+ * \return Index of the currently selected endpoint.\r
+ */\r
+ static inline uint8_t Endpoint_GetCurrentEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_GetCurrentEndpoint(void)\r
+ {\r
+ return (USB_Endpoint_SelectedEndpoint | Endpoint_GetEndpointDirection());\r
+ }\r
+\r
+ /** Selects the given endpoint address.\r
+ *\r
+ * Any endpoint operations which do not require the endpoint address to be indicated will operate on\r
+ * the currently selected endpoint.\r
+ *\r
+ * \param[in] Address Endpoint address to select.\r
+ */\r
+ static inline void Endpoint_SelectEndpoint(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_SelectEndpoint(const uint8_t Address)\r
+ {\r
+ USB_Endpoint_SelectedEndpoint = (Address & ENDPOINT_EPNUM_MASK);\r
+ }\r
+\r
+ /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's\r
+ * data In and Out pointers to the bank's contents.\r
+ *\r
+ * \param[in] Address Endpoint number whose FIFO buffers are to be reset.\r
+ */\r
+ static inline void Endpoint_ResetEndpoint(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ResetEndpoint(const uint8_t Address)\r
+ {\r
+ uint32_t EndpointNumber = (Address & ENDPOINT_EPNUM_MASK);\r
+ \r
+ AVR32_USBB.uerst |= (AVR32_USBB_EPRST0_MASK << EndpointNumber);\r
+ AVR32_USBB.uerst &= ~(AVR32_USBB_EPRST0_MASK << EndpointNumber);\r
+ USB_Endpoint_FIFOPos[EndpointNumber] = &AVR32_USBB_SLAVE[EndpointNumber * ENDPOINT_HSB_ADDRESS_SPACE_SIZE];\r
+ }\r
+\r
+ /** Enables the currently selected endpoint so that data can be sent and received through it to\r
+ * and from a host.\r
+ *\r
+ * \note Endpoints must first be configured properly via \ref Endpoint_ConfigureEndpoint().\r
+ */\r
+ static inline void Endpoint_EnableEndpoint(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_EnableEndpoint(void)\r
+ {\r
+ AVR32_USBB.uerst |= (AVR32_USBB_EPEN0_MASK << USB_Endpoint_SelectedEndpoint);\r
+ }\r
+\r
+ /** Disables the currently selected endpoint so that data cannot be sent and received through it\r
+ * to and from a host.\r
+ */\r
+ static inline void Endpoint_DisableEndpoint(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_DisableEndpoint(void)\r
+ {\r
+ AVR32_USBB.uerst &= ~(AVR32_USBB_EPEN0_MASK << USB_Endpoint_SelectedEndpoint);\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint is enabled, but not necessarily configured.\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsEnabled(void)\r
+ {\r
+ return ((AVR32_USBB.uerst & (AVR32_USBB_EPEN0_MASK << USB_Endpoint_SelectedEndpoint)) ? true : false);\r
+ }\r
+\r
+ /** Retrieves the number of busy banks in the currently selected endpoint, which have been queued for\r
+ * transmission via the \ref Endpoint_ClearIN() command, or are awaiting acknowledgement via the\r
+ * \ref Endpoint_ClearOUT() command.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_UC3\r
+ *\r
+ * \return Total number of busy banks in the selected endpoint.\r
+ */\r
+ static inline uint8_t Endpoint_GetBusyBanks(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint8_t Endpoint_GetBusyBanks(void)\r
+ {\r
+ return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].nbusybk;\r
+ }\r
+\r
+ /** Aborts all pending IN transactions on the currently selected endpoint, once the bank\r
+ * has been queued for transmission to the host via \ref Endpoint_ClearIN(). This function\r
+ * will terminate all queued transactions, resetting the endpoint banks ready for a new\r
+ * packet.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_UC3\r
+ */\r
+ static inline void Endpoint_AbortPendingIN(void)\r
+ {\r
+ while (Endpoint_GetBusyBanks() != 0)\r
+ {\r
+ (&AVR32_USBB.UECON0SET)[USB_Endpoint_SelectedEndpoint].killbks = true;\r
+ while ((&AVR32_USBB.UECON0)[USB_Endpoint_SelectedEndpoint].killbk);\r
+ }\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint may be read from (if data is waiting in the endpoint\r
+ * bank and the endpoint is an OUT direction, or if the bank is not yet full if the endpoint is an IN\r
+ * direction). This function will return false if an error has occurred in the endpoint, if the endpoint\r
+ * is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN\r
+ * direction and the endpoint bank is full.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_UC3\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint may be read from or written to, depending\r
+ * on its direction.\r
+ */\r
+ static inline bool Endpoint_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsReadWriteAllowed(void)\r
+ {\r
+ return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].rwall;\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint is configured.\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint has been configured, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsConfigured(void)\r
+ {\r
+ return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].cfgok;\r
+ }\r
+\r
+ /** Returns a mask indicating which INTERRUPT type endpoints have interrupted - i.e. their\r
+ * interrupt duration has elapsed. Which endpoints have interrupted can be determined by\r
+ * masking the return value against <tt>(1 << <i>{Endpoint Number}</i>)</tt>.\r
+ *\r
+ * \return Mask whose bits indicate which endpoints have interrupted.\r
+ */\r
+ static inline uint32_t Endpoint_GetEndpointInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Endpoint_GetEndpointInterrupts(void)\r
+ {\r
+ return ((AVR32_USBB.udint & (AVR32_USBB_EP6INT_MASK | AVR32_USBB_EP5INT_MASK |\r
+ AVR32_USBB_EP4INT_MASK | AVR32_USBB_EP3INT_MASK |\r
+ AVR32_USBB_EP2INT_MASK | AVR32_USBB_EP1INT_MASK |\r
+ AVR32_USBB_EP0INT_MASK)) >> AVR32_USBB_EP0INT_OFFSET);\r
+ }\r
+\r
+ /** Determines if the specified endpoint number has interrupted (valid only for INTERRUPT type\r
+ * endpoints).\r
+ *\r
+ * \param[in] Address Address of the endpoint whose interrupt flag should be tested.\r
+ *\r
+ * \return Boolean \c true if the specified endpoint has interrupted, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_HasEndpointInterrupted(const uint8_t Address) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_HasEndpointInterrupted(const uint8_t Address)\r
+ {\r
+ return ((Endpoint_GetEndpointInterrupts() & (AVR32_USBB_EP0INT_MASK << (Address & ENDPOINT_EPNUM_MASK))) ? true : false);\r
+ }\r
+\r
+ /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_UC3\r
+ *\r
+ * \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsINReady(void)\r
+ {\r
+ return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].txini;\r
+ }\r
+\r
+ /** Determines if the selected OUT endpoint has received new packet from the host.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_UC3\r
+ *\r
+ * \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsOUTReceived(void)\r
+ {\r
+ return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].rxouti;\r
+ }\r
+\r
+ /** Determines if the current CONTROL type endpoint has received a SETUP packet.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_UC3\r
+ *\r
+ * \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsSETUPReceived(void)\r
+ {\r
+ return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].rxstpi;\r
+ }\r
+\r
+ /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the\r
+ * endpoint for the next packet.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_UC3\r
+ *\r
+ * \note This is not applicable for non CONTROL type endpoints.\r
+ */\r
+ static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearSETUP(void)\r
+ {\r
+ (&AVR32_USBB.UESTA0CLR)[USB_Endpoint_SelectedEndpoint].rxstpic = true;\r
+ USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint] = &AVR32_USBB_SLAVE[USB_Endpoint_SelectedEndpoint * ENDPOINT_HSB_ADDRESS_SPACE_SIZE];\r
+ }\r
+\r
+ /** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the\r
+ * next packet and switching to the alternative endpoint bank if double banked.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_UC3\r
+ */\r
+ static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearIN(void)\r
+ {\r
+ (&AVR32_USBB.UESTA0CLR)[USB_Endpoint_SelectedEndpoint].txinic = true;\r
+ (&AVR32_USBB.UECON0CLR)[USB_Endpoint_SelectedEndpoint].fifoconc = true;\r
+ USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint] = &AVR32_USBB_SLAVE[USB_Endpoint_SelectedEndpoint * ENDPOINT_HSB_ADDRESS_SPACE_SIZE];\r
+ }\r
+\r
+ /** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint\r
+ * for the next packet and switching to the alternative endpoint bank if double banked.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_UC3\r
+ */\r
+ static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearOUT(void)\r
+ {\r
+ (&AVR32_USBB.UESTA0CLR)[USB_Endpoint_SelectedEndpoint].rxoutic = true;\r
+ (&AVR32_USBB.UECON0CLR)[USB_Endpoint_SelectedEndpoint].fifoconc = true;\r
+ USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint] = &AVR32_USBB_SLAVE[USB_Endpoint_SelectedEndpoint * ENDPOINT_HSB_ADDRESS_SPACE_SIZE];\r
+ }\r
+\r
+ /** Stalls the current endpoint, indicating to the host that a logical problem occurred with the\r
+ * indicated endpoint and that the current transfer sequence should be aborted. This provides a\r
+ * way for devices to indicate invalid commands to the host so that the current transfer can be\r
+ * aborted and the host can begin its own recovery sequence.\r
+ *\r
+ * The currently selected endpoint remains stalled until either the \ref Endpoint_ClearStall() macro\r
+ * is called, or the host issues a CLEAR FEATURE request to the device for the currently selected\r
+ * endpoint.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_UC3\r
+ */\r
+ static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_StallTransaction(void)\r
+ {\r
+ (&AVR32_USBB.UECON0SET)[USB_Endpoint_SelectedEndpoint].stallrqs = true;\r
+ }\r
+\r
+ /** Clears the STALL condition on the currently selected endpoint.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_UC3\r
+ */\r
+ static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearStall(void)\r
+ {\r
+ (&AVR32_USBB.UECON0CLR)[USB_Endpoint_SelectedEndpoint].stallrqc = true;\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint is stalled, false otherwise.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_UC3\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsStalled(void)\r
+ {\r
+ return (&AVR32_USBB.UECON0)[USB_Endpoint_SelectedEndpoint].stallrq;\r
+ }\r
+\r
+ /** Resets the data toggle of the currently selected endpoint. */\r
+ static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ResetDataToggle(void)\r
+ {\r
+ (&AVR32_USBB.UECON0SET)[USB_Endpoint_SelectedEndpoint].rstdts = true;\r
+ }\r
+\r
+ /** Sets the direction of the currently selected endpoint.\r
+ *\r
+ * \param[in] DirectionMask New endpoint direction, as a \c ENDPOINT_DIR_* mask.\r
+ */\r
+ static inline void Endpoint_SetEndpointDirection(const uint32_t DirectionMask) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_SetEndpointDirection(const uint32_t DirectionMask)\r
+ {\r
+ (&AVR32_USBB.UECFG0)[USB_Endpoint_SelectedEndpoint].epdir = (DirectionMask == ENDPOINT_DIR_IN);\r
+ }\r
+\r
+ /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ *\r
+ * \return Next byte in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint8_t Endpoint_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_Read_8(void)\r
+ {\r
+ return *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ }\r
+\r
+ /** Writes one byte to the currently selected endpoint's bank, for IN direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ *\r
+ * \param[in] Data Data to write into the the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_8(const uint8_t Data)\r
+ {\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = Data;\r
+ }\r
+\r
+ /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ */\r
+ static inline void Endpoint_Discard_8(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Discard_8(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+\r
+ (void)Dummy;\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ *\r
+ * \return Next two bytes in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint16_t Endpoint_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Endpoint_Read_16_LE(void)\r
+ {\r
+ uint16_t Byte0 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ uint16_t Byte1 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+\r
+ return ((Byte1 << 8) | Byte0);\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ *\r
+ * \return Next two bytes in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint16_t Endpoint_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Endpoint_Read_16_BE(void)\r
+ {\r
+ uint16_t Byte0 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ uint16_t Byte1 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+\r
+ return ((Byte0 << 8) | Byte1);\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ *\r
+ * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_16_LE(const uint16_t Data)\r
+ {\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data & 0xFF);\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 8);\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ *\r
+ * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_16_BE(const uint16_t Data)\r
+ {\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 8);\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data & 0xFF);\r
+ }\r
+\r
+ /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ */\r
+ static inline void Endpoint_Discard_16(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Discard_16(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+\r
+ (void)Dummy;\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ *\r
+ * \return Next four bytes in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint32_t Endpoint_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Endpoint_Read_32_LE(void)\r
+ {\r
+ uint32_t Byte0 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ uint32_t Byte1 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ uint32_t Byte2 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ uint32_t Byte3 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+\r
+ return ((Byte3 << 24) | (Byte2 << 16) | (Byte1 << 8) | Byte0);\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ *\r
+ * \return Next four bytes in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint32_t Endpoint_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Endpoint_Read_32_BE(void)\r
+ {\r
+ uint32_t Byte0 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ uint32_t Byte1 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ uint32_t Byte2 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ uint32_t Byte3 = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+\r
+ return ((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3);\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ *\r
+ * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_32_LE(const uint32_t Data)\r
+ {\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data & 0xFF);\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 8);\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 16);\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 24);\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ *\r
+ * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_32_BE(const uint32_t Data)\r
+ {\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 24);\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 16);\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data >> 8);\r
+ *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++) = (Data & 0xFF);\r
+ }\r
+\r
+ /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_UC3\r
+ */\r
+ static inline void Endpoint_Discard_32(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Discard_32(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+ Dummy = *(USB_Endpoint_FIFOPos[USB_Endpoint_SelectedEndpoint]++);\r
+\r
+ (void)Dummy;\r
+ }\r
+\r
+ /* External Variables: */\r
+ /** Global indicating the maximum packet size of the default control endpoint located at address\r
+ * 0 in the device. This value is set to the value indicated in the device descriptor in the user\r
+ * project once the USB interface is initialized into device mode.\r
+ *\r
+ * If space is an issue, it is possible to fix this to a static value by defining the control\r
+ * endpoint size in the \c FIXED_CONTROL_ENDPOINT_SIZE token passed to the compiler in the makefile\r
+ * via the -D switch. When a fixed control endpoint size is used, the size is no longer dynamically\r
+ * read from the descriptors at runtime and instead fixed to the given value. When used, it is\r
+ * important that the descriptor control endpoint size value matches the size given as the\r
+ * \c FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the \c FIXED_CONTROL_ENDPOINT_SIZE token\r
+ * be used in the device descriptors to ensure this.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))\r
+ extern uint8_t USB_Device_ControlEndpointSize;\r
+ #else\r
+ #define USB_Device_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures a table of endpoint descriptions, in sequence. This function can be used to configure multiple\r
+ * endpoints at the same time.\r
+ *\r
+ * \note Endpoints with a zero address will be ignored, thus this function cannot be used to configure the\r
+ * control endpoint.\r
+ *\r
+ * \param[in] Table Pointer to a table of endpoint descriptions.\r
+ * \param[in] Entries Number of entries in the endpoint table to configure.\r
+ *\r
+ * \return Boolean \c true if all endpoints configured successfully, \c false otherwise.\r
+ */\r
+ bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table,\r
+ const uint8_t Entries);\r
+\r
+ /** Completes the status stage of a control transfer on a CONTROL type endpoint automatically,\r
+ * with respect to the data direction. This is a convenience function which can be used to\r
+ * simplify user control request handling.\r
+ *\r
+ * \note This routine should not be called on non CONTROL type endpoints.\r
+ */\r
+ void Endpoint_ClearStatusStage(void);\r
+\r
+ /** Spin-loops until the currently selected non-control endpoint is ready for the next packet of data\r
+ * to be read or written to it.\r
+ *\r
+ * \note This routine should not be called on CONTROL type endpoints.\r
+ *\r
+ * \ingroup Group_EndpointRW_UC3\r
+ *\r
+ * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_WaitUntilReady(void);\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_UC3)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#define __INCLUDE_FROM_HOST_C\r
+#include "../Host.h"\r
+\r
+void USB_Host_ProcessNextHostState(void)\r
+{\r
+ uint8_t ErrorCode = HOST_ENUMERROR_NoError;\r
+ uint8_t SubErrorCode = HOST_ENUMERROR_NoError;\r
+\r
+ static uint16_t WaitMSRemaining;\r
+ static uint8_t PostWaitState;\r
+\r
+ switch (USB_HostState)\r
+ {\r
+ case HOST_STATE_WaitForDevice:\r
+ if (WaitMSRemaining)\r
+ {\r
+ if ((SubErrorCode = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)\r
+ {\r
+ USB_HostState = PostWaitState;\r
+ ErrorCode = HOST_ENUMERROR_WaitStage;\r
+ break;\r
+ }\r
+\r
+ if (!(--WaitMSRemaining))\r
+ USB_HostState = PostWaitState;\r
+ }\r
+\r
+ break;\r
+ case HOST_STATE_Powered:\r
+ WaitMSRemaining = HOST_DEVICE_SETTLE_DELAY_MS;\r
+\r
+ USB_HostState = HOST_STATE_Powered_WaitForDeviceSettle;\r
+ break;\r
+ case HOST_STATE_Powered_WaitForDeviceSettle:\r
+ if (WaitMSRemaining--)\r
+ {\r
+ Delay_MS(1);\r
+ break;\r
+ }\r
+ else\r
+ {\r
+ USB_Host_VBUS_Manual_Off();\r
+\r
+ USB_OTGPAD_On();\r
+ USB_Host_VBUS_Auto_Enable();\r
+ USB_Host_VBUS_Auto_On();\r
+\r
+ #if defined(NO_AUTO_VBUS_MANAGEMENT)\r
+ USB_Host_VBUS_Manual_Enable();\r
+ USB_Host_VBUS_Manual_On();\r
+ #endif\r
+\r
+ USB_HostState = HOST_STATE_Powered_WaitForConnect;\r
+ }\r
+\r
+ break;\r
+ case HOST_STATE_Powered_WaitForConnect:\r
+ if (USB_INT_HasOccurred(USB_INT_DCONNI))\r
+ {\r
+ USB_INT_Clear(USB_INT_DCONNI);\r
+ USB_INT_Clear(USB_INT_DDISCI);\r
+\r
+ USB_INT_Clear(USB_INT_VBERRI);\r
+ USB_INT_Enable(USB_INT_VBERRI);\r
+\r
+ USB_Host_ResumeBus();\r
+ Pipe_ClearPipes();\r
+\r
+ HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Powered_DoReset);\r
+ }\r
+\r
+ break;\r
+ case HOST_STATE_Powered_DoReset:\r
+ USB_Host_ResetDevice();\r
+\r
+ HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Powered_ConfigPipe);\r
+ break;\r
+ case HOST_STATE_Powered_ConfigPipe:\r
+ if (!(Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, ENDPOINT_CONTROLEP, PIPE_CONTROLPIPE_DEFAULT_SIZE, 1)))\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_PipeConfigError;\r
+ SubErrorCode = 0;\r
+ break;\r
+ }\r
+\r
+ USB_HostState = HOST_STATE_Default;\r
+ break;\r
+ case HOST_STATE_Default:\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ .bRequest = REQ_GetDescriptor,\r
+ .wValue = (DTYPE_Device << 8),\r
+ .wIndex = 0,\r
+ .wLength = 8,\r
+ };\r
+\r
+ uint8_t DataBuffer[8];\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+ if ((SubErrorCode = USB_Host_SendControlRequest(DataBuffer)) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_ControlError;\r
+ break;\r
+ }\r
+\r
+ USB_Host_ControlPipeSize = DataBuffer[offsetof(USB_Descriptor_Device_t, Endpoint0Size)];\r
+\r
+ USB_Host_ResetDevice();\r
+\r
+ HOST_TASK_NONBLOCK_WAIT(200, HOST_STATE_Default_PostReset);\r
+ break;\r
+ case HOST_STATE_Default_PostReset:\r
+ if (!(Pipe_ConfigurePipe(PIPE_CONTROLPIPE, EP_TYPE_CONTROL, ENDPOINT_CONTROLEP, USB_Host_ControlPipeSize, 1)))\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_PipeConfigError;\r
+ SubErrorCode = 0;\r
+ break;\r
+ }\r
+\r
+ USB_ControlRequest = (USB_Request_Header_t)\r
+ {\r
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_DEVICE),\r
+ .bRequest = REQ_SetAddress,\r
+ .wValue = USB_HOST_DEVICEADDRESS,\r
+ .wIndex = 0,\r
+ .wLength = 0,\r
+ };\r
+\r
+ if ((SubErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)\r
+ {\r
+ ErrorCode = HOST_ENUMERROR_ControlError;\r
+ break;\r
+ }\r
+\r
+ HOST_TASK_NONBLOCK_WAIT(100, HOST_STATE_Default_PostAddressSet);\r
+ break;\r
+ case HOST_STATE_Default_PostAddressSet:\r
+ USB_Host_SetDeviceAddress(USB_HOST_DEVICEADDRESS);\r
+\r
+ USB_HostState = HOST_STATE_Addressed;\r
+\r
+ EVENT_USB_Host_DeviceEnumerationComplete();\r
+ break;\r
+ }\r
+\r
+ if ((ErrorCode != HOST_ENUMERROR_NoError) && (USB_HostState != HOST_STATE_Unattached))\r
+ {\r
+ EVENT_USB_Host_DeviceEnumerationFailed(ErrorCode, SubErrorCode);\r
+\r
+ USB_Host_VBUS_Auto_Off();\r
+\r
+ EVENT_USB_Host_DeviceUnattached();\r
+\r
+ USB_ResetInterface();\r
+ }\r
+}\r
+\r
+uint8_t USB_Host_WaitMS(uint8_t MS)\r
+{\r
+ bool BusSuspended = USB_Host_IsBusSuspended();\r
+ uint8_t ErrorCode = HOST_WAITERROR_Successful;\r
+ bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);\r
+\r
+ USB_INT_Disable(USB_INT_HSOFI);\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+\r
+ USB_Host_ResumeBus();\r
+\r
+ while (MS)\r
+ {\r
+ if (USB_INT_HasOccurred(USB_INT_HSOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+ MS--;\r
+ }\r
+\r
+ if ((USB_HostState == HOST_STATE_Unattached) || (USB_CurrentMode != USB_MODE_Host))\r
+ {\r
+ ErrorCode = HOST_WAITERROR_DeviceDisconnect;\r
+\r
+ break;\r
+ }\r
+\r
+ if (Pipe_IsError())\r
+ {\r
+ Pipe_ClearError();\r
+ ErrorCode = HOST_WAITERROR_PipeError;\r
+\r
+ break;\r
+ }\r
+\r
+ if (Pipe_IsStalled())\r
+ {\r
+ Pipe_ClearStall();\r
+ ErrorCode = HOST_WAITERROR_SetupStalled;\r
+\r
+ break;\r
+ }\r
+ }\r
+\r
+ if (BusSuspended)\r
+ USB_Host_SuspendBus();\r
+\r
+ if (HSOFIEnabled)\r
+ USB_INT_Enable(USB_INT_HSOFI);\r
+\r
+ return ErrorCode;\r
+}\r
+\r
+static void USB_Host_ResetDevice(void)\r
+{\r
+ bool BusSuspended = USB_Host_IsBusSuspended();\r
+\r
+ USB_INT_Disable(USB_INT_DDISCI);\r
+\r
+ USB_Host_ResetBus();\r
+ while (!(USB_Host_IsBusResetComplete()));\r
+ USB_Host_ResumeBus();\r
+\r
+ USB_Host_ConfigurationNumber = 0;\r
+\r
+ bool HSOFIEnabled = USB_INT_IsEnabled(USB_INT_HSOFI);\r
+\r
+ USB_INT_Disable(USB_INT_HSOFI);\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+\r
+ for (uint8_t MSRem = 10; MSRem != 0; MSRem--)\r
+ {\r
+ /* Workaround for powerless-pull-up devices. After a USB bus reset,\r
+ all disconnection interrupts are suppressed while a USB frame is\r
+ looked for - if it is found within 10ms, the device is still\r
+ present. */\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_HSOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+ USB_INT_Clear(USB_INT_DDISCI);\r
+ break;\r
+ }\r
+\r
+ Delay_MS(1);\r
+ }\r
+\r
+ if (HSOFIEnabled)\r
+ USB_INT_Enable(USB_INT_HSOFI);\r
+\r
+ if (BusSuspended)\r
+ USB_Host_SuspendBus();\r
+\r
+ USB_INT_Enable(USB_INT_DDISCI);\r
+}\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Host definitions for the AVR32 UC3B microcontrollers.\r
+ * \copydetails Group_Host_UC3B\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_Host\r
+ * \defgroup Group_Host_UC3B Host Management (UC3B)\r
+ * \brief USB Host definitions for the AVR32 UC3B microcontrollers.\r
+ *\r
+ * Architecture specific USB Host definitions for the Atmel 32-bit AVR UC3B microcontrollers.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBHOST_UC3B_H__\r
+#define __USBHOST_UC3B_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../StdDescriptors.h"\r
+ #include "../Pipe.h"\r
+ #include "../USBInterrupt.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Indicates the fixed USB device address which any attached device is enumerated to when in\r
+ * host mode. As only one USB device may be attached to the AVR in host mode at any one time\r
+ * and that the address used is not important (other than the fact that it is non-zero), a\r
+ * fixed value is specified by the library.\r
+ */\r
+ #define USB_HOST_DEVICEADDRESS 1\r
+\r
+ #if !defined(HOST_DEVICE_SETTLE_DELAY_MS) || defined(__DOXYGEN__)\r
+ /** Constant for the delay in milliseconds after a device is connected before the library\r
+ * will start the enumeration process. Some devices require a delay of up to 5 seconds\r
+ * after connection before the enumeration process can start or incorrect operation will\r
+ * occur.\r
+ *\r
+ * The default delay value may be overridden in the user project makefile by defining the\r
+ * \c HOST_DEVICE_SETTLE_DELAY_MS token to the required delay in milliseconds, and passed to the\r
+ * compiler using the -D switch.\r
+ */\r
+ #define HOST_DEVICE_SETTLE_DELAY_MS 1000\r
+ #endif\r
+\r
+ /* Enums: */\r
+ /** Enum for the error codes for the \ref EVENT_USB_Host_HostError() event.\r
+ *\r
+ * \see \ref Group_Events for more information on this event.\r
+ */\r
+ enum USB_Host_ErrorCodes_t\r
+ {\r
+ HOST_ERROR_VBusVoltageDip = 0, /**< VBUS voltage dipped to an unacceptable level. This\r
+ * error may be the result of an attached device drawing\r
+ * too much current from the VBUS line, or due to the\r
+ * AVR's power source being unable to supply sufficient\r
+ * current.\r
+ */\r
+ };\r
+\r
+ /** Enum for the error codes for the \ref EVENT_USB_Host_DeviceEnumerationFailed() event.\r
+ *\r
+ * \see \ref Group_Events for more information on this event.\r
+ */\r
+ enum USB_Host_EnumerationErrorCodes_t\r
+ {\r
+ HOST_ENUMERROR_NoError = 0, /**< No error occurred. Used internally, this is not a valid\r
+ * ErrorCode parameter value for the \ref EVENT_USB_Host_DeviceEnumerationFailed()\r
+ * event.\r
+ */\r
+ HOST_ENUMERROR_WaitStage = 1, /**< One of the delays between enumeration steps failed\r
+ * to complete successfully, due to a timeout or other\r
+ * error.\r
+ */\r
+ HOST_ENUMERROR_NoDeviceDetected = 2, /**< No device was detected, despite the USB data lines\r
+ * indicating the attachment of a device.\r
+ */\r
+ HOST_ENUMERROR_ControlError = 3, /**< One of the enumeration control requests failed to\r
+ * complete successfully.\r
+ */\r
+ HOST_ENUMERROR_PipeConfigError = 4, /**< The default control pipe (address 0) failed to\r
+ * configure correctly.\r
+ */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Returns the current USB frame number, when in host mode. Every millisecond the USB bus is active (i.e. not suspended)\r
+ * the frame number is incremented by one.\r
+ *\r
+ * \return Current USB frame number from the USB controller.\r
+ */\r
+ static inline uint16_t USB_Host_GetFrameNumber(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t USB_Host_GetFrameNumber(void)\r
+ {\r
+ return AVR32_USBB_UHFNUM;\r
+ }\r
+\r
+ #if !defined(NO_SOF_EVENTS)\r
+ /** Enables the host mode Start Of Frame events. When enabled, this causes the\r
+ * \ref EVENT_USB_Host_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,\r
+ * at the start of each USB frame when a device is enumerated while in host mode.\r
+ *\r
+ * \note This function is not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Host_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_EnableSOFEvents(void)\r
+ {\r
+ USB_INT_Enable(USB_INT_HSOFI);\r
+ }\r
+\r
+ /** Disables the host mode Start Of Frame events. When disabled, this stops the firing of the\r
+ * \ref EVENT_USB_Host_StartOfFrame() event when enumerated in host mode.\r
+ *\r
+ * \note This function is not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Host_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_DisableSOFEvents(void)\r
+ {\r
+ USB_INT_Disable(USB_INT_HSOFI);\r
+ }\r
+ #endif\r
+\r
+ /** Resets the USB bus, including the endpoints in any attached device and pipes on the AVR host.\r
+ * USB bus resets leave the default control pipe configured (if already configured).\r
+ *\r
+ * If the USB bus has been suspended prior to issuing a bus reset, the attached device will be\r
+ * woken up automatically and the bus resumed after the reset has been correctly issued.\r
+ */\r
+ static inline void USB_Host_ResetBus(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_ResetBus(void)\r
+ {\r
+ AVR32_USBB.UHCON.reset = true;\r
+ }\r
+\r
+ /** Determines if a previously issued bus reset (via the \ref USB_Host_ResetBus() macro) has\r
+ * completed.\r
+ *\r
+ * \return Boolean \c true if no bus reset is currently being sent, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsBusResetComplete(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsBusResetComplete(void)\r
+ {\r
+ return AVR32_USBB.UHCON.reset;\r
+ }\r
+\r
+ /** Resumes USB communications with an attached and enumerated device, by resuming the transmission\r
+ * of the 1MS Start Of Frame messages to the device. When resumed, USB communications between the\r
+ * host and attached device may occur.\r
+ */\r
+ static inline void USB_Host_ResumeBus(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_ResumeBus(void)\r
+ {\r
+ AVR32_USBB.UHCON.sofe = true;\r
+ }\r
+\r
+ /** Suspends the USB bus, preventing any communications from occurring between the host and attached\r
+ * device until the bus has been resumed. This stops the transmission of the 1MS Start Of Frame\r
+ * messages to the device.\r
+ *\r
+ * \note While the USB bus is suspended, all USB interrupt sources are also disabled; this means that\r
+ * some events (such as device disconnections) will not fire until the bus is resumed.\r
+ */\r
+ static inline void USB_Host_SuspendBus(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_SuspendBus(void)\r
+ {\r
+ AVR32_USBB.UHCON.sofe = false;\r
+ }\r
+\r
+ /** Determines if the USB bus has been suspended via the use of the \ref USB_Host_SuspendBus() macro,\r
+ * false otherwise. While suspended, no USB communications can occur until the bus is resumed,\r
+ * except for the Remote Wakeup event from the device if supported.\r
+ *\r
+ * \return Boolean \c true if the bus is currently suspended, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsBusSuspended(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsBusSuspended(void)\r
+ {\r
+ return AVR32_USBB.UHCON.sofe;\r
+ }\r
+\r
+ /** Determines if the attached device is currently enumerated in Full Speed mode (12Mb/s), or\r
+ * false if the attached device is enumerated in Low Speed mode (1.5Mb/s).\r
+ *\r
+ * \return Boolean \c true if the attached device is enumerated in Full Speed mode, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsDeviceFullSpeed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsDeviceFullSpeed(void)\r
+ {\r
+ return (AVR32_USBB.USBSTA.speed == AVR32_USBB_SPEED_FULL);\r
+ }\r
+\r
+ /** Determines if the attached device is currently issuing a Remote Wakeup request, requesting\r
+ * that the host resume the USB bus and wake up the device, false otherwise.\r
+ *\r
+ * \return Boolean \c true if the attached device has sent a Remote Wakeup request, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsRemoteWakeupSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsRemoteWakeupSent(void)\r
+ {\r
+ return AVR32_USBB.UHINT.rxrsmi;\r
+ }\r
+\r
+ /** Clears the flag indicating that a Remote Wakeup request has been issued by an attached device. */\r
+ static inline void USB_Host_ClearRemoteWakeupSent(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_ClearRemoteWakeupSent(void)\r
+ {\r
+ AVR32_USBB.UHINTCLR.rxrsmic = true;\r
+ }\r
+\r
+ /** Accepts a Remote Wakeup request from an attached device. This must be issued in response to\r
+ * a device's Remote Wakeup request within 2ms for the request to be accepted and the bus to\r
+ * be resumed.\r
+ */\r
+ static inline void USB_Host_ResumeFromWakeupRequest(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_ResumeFromWakeupRequest(void)\r
+ {\r
+ AVR32_USBB.UHCON.resume = true;\r
+ }\r
+\r
+ /** Determines if a resume from Remote Wakeup request is currently being sent to an attached\r
+ * device.\r
+ *\r
+ * \return Boolean \c true if no resume request is currently being sent, \c false otherwise.\r
+ */\r
+ static inline bool USB_Host_IsResumeFromWakeupRequestSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_Host_IsResumeFromWakeupRequestSent(void)\r
+ {\r
+ return AVR32_USBB.UHCON.resume;\r
+ }\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ static inline void USB_Host_HostMode_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_HostMode_On(void)\r
+ {\r
+ // Not required for UC3B\r
+ }\r
+\r
+ static inline void USB_Host_HostMode_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_HostMode_Off(void)\r
+ {\r
+ // Not required for UC3B\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Auto_Enable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Auto_Enable(void)\r
+ {\r
+ AVR32_USBB.USBCON.vbushwc = false;\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Manual_Enable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Manual_Enable(void)\r
+ {\r
+ AVR32_USBB.USBCON.vbushwc = true;\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Auto_On(void)\r
+ {\r
+ AVR32_USBB.USBSTASET.vbusrqs = true;\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Manual_On(void)\r
+ {\r
+ AVR32_USBB.USBSTASET.vbusrqs = true;\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Auto_Off(void)\r
+ {\r
+ AVR32_USBB.USBSTACLR.vbusrqc = true;\r
+ }\r
+\r
+ static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_VBUS_Manual_Off(void)\r
+ {\r
+ AVR32_USBB.USBSTACLR.vbusrqc = true;\r
+ }\r
+\r
+ static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Host_SetDeviceAddress(const uint8_t Address)\r
+ {\r
+ AVR32_USBB.UHADDR1.uhaddr_p0 = Address;\r
+ AVR32_USBB.UHADDR1.uhaddr_p1 = Address;\r
+ AVR32_USBB.UHADDR1.uhaddr_p2 = Address;\r
+ AVR32_USBB.UHADDR1.uhaddr_p3 = Address;\r
+ AVR32_USBB.UHADDR2.uhaddr_p4 = Address;\r
+ AVR32_USBB.UHADDR2.uhaddr_p5 = Address;\r
+ AVR32_USBB.UHADDR2.uhaddr_p6 = Address;\r
+ }\r
+\r
+ /* Enums: */\r
+ enum USB_Host_WaitMSErrorCodes_t\r
+ {\r
+ HOST_WAITERROR_Successful = 0,\r
+ HOST_WAITERROR_DeviceDisconnect = 1,\r
+ HOST_WAITERROR_PipeError = 2,\r
+ HOST_WAITERROR_SetupStalled = 3,\r
+ };\r
+\r
+ /* Function Prototypes: */\r
+ void USB_Host_ProcessNextHostState(void);\r
+ uint8_t USB_Host_WaitMS(uint8_t MS);\r
+\r
+ #if defined(__INCLUDE_FROM_HOST_C)\r
+ static void USB_Host_ResetDevice(void);\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_UC3)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#include "PipeStream_UC3.h"\r
+\r
+uint8_t Pipe_Discard_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t ErrorCode;\r
+ uint16_t BytesInTransfer = 0;\r
+ \r
+ Pipe_SetPipeToken(PIPE_TOKEN_IN);\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ if (BytesProcessed != NULL)\r
+ Length -= *BytesProcessed;\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ Pipe_ClearIN();\r
+ \r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return PIPE_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ Pipe_Discard_8();\r
+ \r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t Pipe_Null_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t ErrorCode;\r
+ uint16_t BytesInTransfer = 0;\r
+ \r
+ Pipe_SetPipeToken(PIPE_TOKEN_OUT);\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ if (BytesProcessed != NULL)\r
+ Length -= *BytesProcessed;\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ Pipe_ClearOUT();\r
+ \r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return PIPE_RWSTREAM_IncompleteTransfer;\r
+ }\r
+ \r
+ USB_USBTask();\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ Pipe_Write_8(0);\r
+ \r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,\r
+ * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_LE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_OUT\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr)\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Write_Stream_BE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_OUT\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Pipe_Write_8(*BufferPtr)\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_LE\r
+#define TEMPLATE_BUFFER_TYPE void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_IN\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8()\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Pipe_Read_Stream_BE\r
+#define TEMPLATE_BUFFER_TYPE void*\r
+#define TEMPLATE_TOKEN PIPE_TOKEN_IN\r
+#define TEMPLATE_CLEAR_PIPE() Pipe_ClearIN()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) DataStream -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Pipe_Read_8()\r
+#include "Template/Template_Pipe_RW.c"\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+ \r
+/** \file\r
+ * \brief Pipe data stream transmission and reception management for the AVR32 UC3 microcontrollers.\r
+ * \copydetails Group_PipeStreamRW_UC3\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_PipeStreamRW\r
+ * \defgroup Group_PipeStreamRW_UC3 Read/Write of Multi-Byte Streams (UC3)\r
+ * \brief Pipe data stream transmission and reception management for the Atmel AVR32 UC3 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of data streams from\r
+ * and to pipes.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __PIPE_STREAM_UC3_H__\r
+#define __PIPE_STREAM_UC3_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBMode.h"\r
+ #include "../USBTask.h"\r
+ \r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Function Prototypes: */\r
+ /** \name Stream functions for null data */\r
+ //@{\r
+\r
+ /** Reads and discards the given number of bytes from the pipe, discarding fully read packets from the host\r
+ * as needed. The last packet is not automatically discarded once the remaining bytes has been read; the\r
+ * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearIN() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or\r
+ * succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer\r
+ * will instead be performed as a series of chunks. Each time the pipe bank becomes empty while there is still data\r
+ * to process (and after the current packet has been acknowledged) the BytesProcessed location will be updated with\r
+ * the total number of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to\r
+ * continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed\r
+ * value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Pipe_Discard_Stream(512, NULL)) != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ * \r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Pipe_Discard_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \param[in] Length Number of bytes to discard via the currently selected pipe.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be processed at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Discard_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed);\r
+\r
+ /** Writes a given number of zeroed bytes to the pipe, sending full pipe packets from the host to the device\r
+ * as needed. The last packet is not automatically sent once the remaining bytes has been written; the\r
+ * user is responsible for manually discarding the last packet from the device via the \ref Pipe_ClearOUT() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once, failing or\r
+ * succeeding as a single unit. If the BytesProcessed parameter points to a valid storage location, the transfer\r
+ * will instead be performed as a series of chunks. Each time the pipe bank becomes full while there is still data\r
+ * to process (and after the current packet transmission has been initiated) the BytesProcessed location will be\r
+ * updated with the total number of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed in the user code - to\r
+ * continue the transfer, call the function again with identical parameters and it will resume until the BytesProcessed\r
+ * value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Pipe_Null_Stream(512, NULL)) != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Pipe_Null_Stream(512, &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \param[in] Length Number of zero bytes to write via the currently selected pipe.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be processed at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Null_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed);\r
+\r
+ //@}\r
+\r
+ /** \name Stream functions for RAM source/destination data */\r
+ //@{\r
+ \r
+ /** Writes the given number of bytes to the pipe from the given buffer in little endian,\r
+ * sending full packets to the device as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is\r
+ * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the pipe bank becomes full while there is still data to process (and after the current\r
+ * packet transmission has been initiated) the BytesProcessed location will be updated with the\r
+ * total number of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream),\r
+ * NULL)) != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Pipe_Write_Stream_LE(DataStream, sizeof(DataStream),\r
+ * &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_Stream_LE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the pipe from the given buffer in big endian,\r
+ * sending full packets to the device as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Pipe_ClearOUT() macro. Between each USB packet, the given stream callback function is\r
+ * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Write_Stream_BE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the pipe into the given buffer in little endian,\r
+ * sending full packets to the device as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is\r
+ * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the pipe bank becomes empty while there is still data to process (and after the current\r
+ * packet has been acknowledged) the BytesProcessed location will be updated with the total number\r
+ * of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref PIPE_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream),\r
+ * NULL)) != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Pipe_Read_Stream_LE(DataStream, sizeof(DataStream),\r
+ * &BytesProcessed)) == PIPE_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != PIPE_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \param[out] Buffer Pointer to the source data buffer to write to.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe to read from.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Read_Stream_LE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the pipe into the given buffer in big endian,\r
+ * sending full packets to the device as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Pipe_ClearIN() macro. Between each USB packet, the given stream callback function is\r
+ * executed repeatedly until the next packet is ready, allowing for early aborts of stream transfers.\r
+ *\r
+ * \note The pipe token is set automatically, thus this can be used on bi-directional pipes directly without\r
+ * having to explicitly change the data direction with a call to \ref Pipe_SetPipeToken().\r
+ *\r
+ * \param[out] Buffer Pointer to the source data buffer to write to.\r
+ * \param[in] Length Number of bytes to read for the currently selected pipe to read from.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes already processed should\r
+ * updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_Read_Stream_BE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+ //@}\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_UC3)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#include "../Pipe.h"\r
+\r
+uint8_t USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;\r
+\r
+volatile uint32_t USB_Pipe_SelectedPipe = PIPE_CONTROLPIPE;\r
+volatile uint8_t* USB_Pipe_FIFOPos[PIPE_TOTAL_PIPES];\r
+\r
+bool Pipe_ConfigurePipeTable(const USB_Pipe_Table_t* const Table,\r
+ const uint8_t Entries)\r
+{\r
+ for (uint8_t i = 0; i < Entries; i++)\r
+ {\r
+ if (!(Table[i].Address))\r
+ continue;\r
+ \r
+ if (!(Pipe_ConfigurePipe(Table[i].Address, Table[i].Type, Table[i].EndpointAddress, Table[i].Size, Table[i].Banks)))\r
+ {\r
+ return false;\r
+ }\r
+ }\r
+ \r
+ return true;\r
+}\r
+\r
+bool Pipe_ConfigurePipe(const uint8_t Address,\r
+ const uint8_t Type,\r
+ const uint8_t EndpointAddress,\r
+ const uint16_t Size,\r
+ const uint8_t Banks)\r
+{\r
+ uint8_t Number = (Address & PIPE_EPNUM_MASK);\r
+ uint8_t Token = (Address & PIPE_DIR_IN) ? PIPE_TOKEN_IN : PIPE_TOKEN_OUT;\r
+ \r
+ if (Number >= PIPE_TOTAL_PIPES)\r
+ return false;\r
+\r
+ if (Type == EP_TYPE_CONTROL)\r
+ Token = PIPE_TOKEN_SETUP;\r
+\r
+ USB_Pipe_FIFOPos[Number] = &AVR32_USBB_SLAVE[Number * PIPE_HSB_ADDRESS_SPACE_SIZE];\r
+\r
+#if defined(ORDERED_EP_CONFIG)\r
+ Pipe_SelectPipe(Number);\r
+ Pipe_EnablePipe();\r
+\r
+ (&AVR32_USBB.upcfg0)[Number] = 0;\r
+ (&AVR32_USBB.upcfg0)[Number] = (AVR32_USBB_ALLOC_MASK |\r
+ ((uint32_t)Type << AVR32_USBB_PTYPE_OFFSET) |\r
+ ((uint32_t)Token << AVR32_USBB_PTOKEN_OFFSET) |\r
+ ((Banks > 1) ? AVR32_USBB_PBK_MASK : 0) |\r
+ Pipe_BytesToEPSizeMask(Size) |\r
+ ((uint32_t)Number << AVR32_USBB_PEPNUM_OFFSET));\r
+\r
+ Pipe_SetInfiniteINRequests();\r
+\r
+ return Pipe_IsConfigured();\r
+#else\r
+ for (uint8_t PNum = Number; PNum < PIPE_TOTAL_PIPES; PNum++)\r
+ {\r
+ uint32_t UPCFG0Temp;\r
+\r
+ Pipe_SelectPipe(PNum);\r
+\r
+ if (PNum == Number)\r
+ {\r
+ UPCFG0Temp = (AVR32_USBB_ALLOC_MASK |\r
+ ((uint32_t)Type << AVR32_USBB_PTYPE_OFFSET) |\r
+ ((uint32_t)Token << AVR32_USBB_PTOKEN_OFFSET) |\r
+ ((Banks > 1) ? AVR32_USBB_PBK_MASK : 0) |\r
+ Pipe_BytesToEPSizeMask(Size) |\r
+ ((EndpointAddress & PIPE_EPNUM_MASK) << AVR32_USBB_PEPNUM_OFFSET));\r
+ }\r
+ else\r
+ {\r
+ UPCFG0Temp = (&AVR32_USBB.upcfg0)[PNum];\r
+ }\r
+\r
+ if (!(UPCFG0Temp & AVR32_USBB_ALLOC_MASK))\r
+ continue;\r
+\r
+ Pipe_DisablePipe();\r
+ (&AVR32_USBB.upcfg0)[PNum] &= ~AVR32_USBB_ALLOC_MASK;\r
+\r
+ Pipe_EnablePipe();\r
+ (&AVR32_USBB.upcfg0)[PNum] = UPCFG0Temp;\r
+\r
+ Pipe_SetInfiniteINRequests();\r
+\r
+ if (!(Pipe_IsConfigured()))\r
+ return false;\r
+ }\r
+\r
+ Pipe_SelectPipe(Number);\r
+ return true;\r
+#endif\r
+}\r
+\r
+void Pipe_ClearPipes(void)\r
+{\r
+ for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)\r
+ {\r
+ Pipe_SelectPipe(PNum);\r
+ (&AVR32_USBB.upcfg0)[PNum] = 0;\r
+ (&AVR32_USBB.upcon0clr)[PNum] = -1;\r
+ USB_Pipe_FIFOPos[PNum] = &AVR32_USBB_SLAVE[PNum * 0x10000];\r
+ Pipe_DisablePipe();\r
+ }\r
+}\r
+\r
+bool Pipe_IsEndpointBound(const uint8_t EndpointAddress)\r
+{\r
+ uint8_t PrevPipeNumber = Pipe_GetCurrentPipe();\r
+\r
+ for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)\r
+ {\r
+ Pipe_SelectPipe(PNum);\r
+\r
+ if (!(Pipe_IsConfigured()))\r
+ continue;\r
+\r
+ if (Pipe_GetBoundEndpointAddress() == EndpointAddress)\r
+ return true;\r
+ }\r
+\r
+ Pipe_SelectPipe(PrevPipeNumber);\r
+ return false;\r
+}\r
+\r
+uint8_t Pipe_WaitUntilReady(void)\r
+{\r
+ #if (USB_STREAM_TIMEOUT_MS < 0xFF)\r
+ uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #else\r
+ uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #endif\r
+\r
+ uint16_t PreviousFrameNumber = USB_Host_GetFrameNumber();\r
+\r
+ for (;;)\r
+ {\r
+ if (Pipe_GetPipeToken() == PIPE_TOKEN_IN)\r
+ {\r
+ if (Pipe_IsINReceived())\r
+ return PIPE_READYWAIT_NoError;\r
+ }\r
+ else\r
+ {\r
+ if (Pipe_IsOUTReady())\r
+ return PIPE_READYWAIT_NoError;\r
+ }\r
+\r
+ if (Pipe_IsStalled())\r
+ return PIPE_READYWAIT_PipeStalled;\r
+ else if (USB_HostState == HOST_STATE_Unattached)\r
+ return PIPE_READYWAIT_DeviceDisconnected;\r
+\r
+ uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber();\r
+\r
+ if (CurrentFrameNumber != PreviousFrameNumber)\r
+ {\r
+ PreviousFrameNumber = CurrentFrameNumber;\r
+\r
+ if (!(TimeoutMSRem--))\r
+ return PIPE_READYWAIT_Timeout;\r
+ }\r
+ }\r
+}\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Pipe definitions for the AVR32 UC3 microcontrollers.\r
+ * \copydetails Group_PipeManagement_UC3\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_PipeRW\r
+ * \defgroup Group_PipeRW_UC3 Pipe Data Reading and Writing (UC3)\r
+ * \brief Pipe data read/write definitions for the Atmel AVR32 UC3 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing from and to pipes.\r
+ */\r
+\r
+/** \ingroup Group_PipePrimitiveRW\r
+ * \defgroup Group_PipePrimitiveRW_UC3 Read/Write of Primitive Data Types (UC3)\r
+ * \brief Pipe primitive data read/write definitions for the Atmel AVR32 UC3 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of primitive data types\r
+ * from and to pipes.\r
+ */\r
+\r
+/** \ingroup Group_PipePacketManagement\r
+ * \defgroup Group_PipePacketManagement_UC3 Pipe Packet Management (UC3)\r
+ * \brief Pipe packet management definitions for the Atmel AVR32 UC3 architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to packet management of pipes.\r
+ */\r
+\r
+/** \ingroup Group_PipeControlReq\r
+ * \defgroup Group_PipeControlReq_UC3 Pipe Control Request Management (UC3)\r
+ * \brief Pipe control request management definitions for the Atmel AVR32 UC3 architecture.\r
+ *\r
+ * Module for host mode request processing. This module allows for the transmission of standard, class and\r
+ * vendor control requests to the default control endpoint of an attached device while in host mode.\r
+ *\r
+ * \see Chapter 9 of the USB 2.0 specification.\r
+ */\r
+\r
+/** \ingroup Group_PipeManagement\r
+ * \defgroup Group_PipeManagement_UC3 Pipe Management (UC3)\r
+ * \brief Pipe management definitions for the Atmel AVR32 UC3 architecture.\r
+ *\r
+ * This module contains functions, macros and enums related to pipe management when in USB Host mode. This\r
+ * module contains the pipe management macros, as well as pipe interrupt and data send/receive functions\r
+ * for various data types.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __PIPE_UC3_H__\r
+#define __PIPE_UC3_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBTask.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define PIPE_HSB_ADDRESS_SPACE_SIZE (64 * 1024UL)\r
+\r
+ /* External Variables: */\r
+ extern volatile uint32_t USB_Pipe_SelectedPipe;\r
+ extern volatile uint8_t* USB_Pipe_FIFOPos[];\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name Pipe Error Flag Masks */\r
+ //@{\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that an overflow error occurred in the pipe on the received data. */\r
+ #define PIPE_ERRORFLAG_OVERFLOW (AVR32_USBB_UPSTA0_OVERFI_MASK << 8)\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a CRC error occurred in the pipe on the received data. */\r
+ #define PIPE_ERRORFLAG_CRC16 AVR32_USBB_UPERR0_CRC16_MASK\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware timeout error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_TIMEOUT AVR32_USBB_UPERR0_TIMEOUT_MASK\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware PID error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_PID AVR32_USBB_UPERR0_PID_MASK\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data PID error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_DATAPID AVR32_USBB_UPERR0_DATAPID_MASK\r
+\r
+ /** Mask for \ref Pipe_GetErrorFlags(), indicating that a hardware data toggle error occurred in the pipe. */\r
+ #define PIPE_ERRORFLAG_DATATGL AVR32_USBB_UPERR0_DATATGL_MASK\r
+ //@}\r
+\r
+ /** \name Pipe Token Masks */\r
+ //@{\r
+ /** Token mask for \ref Pipe_SetPipeToken() and \ref Pipe_GetPipeToken(). This sets the pipe as a SETUP token (for CONTROL type pipes),\r
+ * which will trigger a control request on the attached device when data is written to the pipe.\r
+ */\r
+ #define PIPE_TOKEN_SETUP AVR32_USBB_UPCFG0_PTOKEN_SETUP\r
+\r
+ /** Token mask for \ref Pipe_SetPipeToken() and \ref Pipe_GetPipeToken(). This sets the pipe as a IN token (for non-CONTROL type pipes),\r
+ * indicating that the pipe data will flow from device to host.\r
+ */\r
+ #define PIPE_TOKEN_IN AVR32_USBB_UPCFG0_PTOKEN_IN\r
+\r
+ /** Token mask for \ref Pipe_SetPipeToken() and \ref Pipe_GetPipeToken(). This sets the pipe as a OUT token (for non-CONTROL type pipes),\r
+ * indicating that the pipe data will flow from host to device.\r
+ */\r
+ #define PIPE_TOKEN_OUT AVR32_USBB_UPCFG0_PTOKEN_OUT\r
+ //@}\r
+\r
+ /** Default size of the default control pipe's bank, until altered by the Endpoint0Size value\r
+ * in the device descriptor of the attached device.\r
+ */\r
+ #define PIPE_CONTROLPIPE_DEFAULT_SIZE 64\r
+\r
+ #if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32) || defined(__DOXYGEN__)\r
+ /** Total number of pipes (including the default control pipe at address 0) which may be used in\r
+ * the device.\r
+ */\r
+ #define PIPE_TOTAL_PIPES 8\r
+ #else\r
+ #define PIPE_TOTAL_PIPES 7\r
+ #endif\r
+\r
+ /** Size in bytes of the largest pipe bank size possible in the device. Not all banks on each AVR\r
+ * model supports the largest bank size possible on the device; different pipe numbers support\r
+ * different maximum bank sizes. This value reflects the largest possible bank of any pipe on the\r
+ * currently selected UC3 AVR model.\r
+ */\r
+ #define PIPE_MAX_SIZE 256\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error return codes of the \ref Pipe_WaitUntilReady() function.\r
+ *\r
+ * \ingroup Group_PipeRW_UC3\r
+ */\r
+ enum Pipe_WaitUntilReady_ErrorCodes_t\r
+ {\r
+ PIPE_READYWAIT_NoError = 0, /**< Pipe ready for next packet, no error. */\r
+ PIPE_READYWAIT_PipeStalled = 1, /**< The device stalled the pipe while waiting. */\r
+ PIPE_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while waiting. */\r
+ PIPE_READYWAIT_Timeout = 3, /**< The device failed to accept or send the next packet\r
+ * within the software timeout period set by the\r
+ * \ref USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Indicates the number of bytes currently stored in the current pipes's selected bank.\r
+ *\r
+ * \ingroup Group_PipeRW_UC3\r
+ *\r
+ * \return Total number of bytes in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint16_t Pipe_BytesInPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Pipe_BytesInPipe(void)\r
+ {\r
+ return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].pbyct;\r
+ }\r
+\r
+ /** Determines the currently selected pipe's direction.\r
+ *\r
+ * \return The currently selected pipe's direction, as a \c PIPE_DIR_* mask.\r
+ */\r
+ static inline uint8_t Pipe_GetPipeDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetPipeDirection(void)\r
+ {\r
+ return (((&AVR32_USBB.UPCFG0)[USB_Pipe_SelectedPipe].ptoken == PIPE_TOKEN_OUT) ? PIPE_DIR_OUT : PIPE_DIR_IN);\r
+ }\r
+ \r
+ /** Returns the pipe address of the currently selected pipe. This is typically used to save the\r
+ * currently selected pipe number so that it can be restored after another pipe has been manipulated.\r
+ *\r
+ * \return Index of the currently selected pipe.\r
+ */\r
+ static inline uint8_t Pipe_GetCurrentPipe(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetCurrentPipe(void)\r
+ {\r
+ return (USB_Pipe_SelectedPipe | Pipe_GetPipeDirection());\r
+ }\r
+\r
+ /** Selects the given pipe address. Any pipe operations which do not require the pipe address to be\r
+ * indicated will operate on the currently selected pipe.\r
+ *\r
+ * \param[in] Address Address of the pipe to select.\r
+ */\r
+ static inline void Pipe_SelectPipe(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SelectPipe(const uint8_t Address)\r
+ {\r
+ USB_Pipe_SelectedPipe = (Address & PIPE_EPNUM_MASK);\r
+ }\r
+\r
+ /** Resets the desired pipe, including the pipe banks and flags.\r
+ *\r
+ * \param[in] Address Index of the pipe to reset.\r
+ */\r
+ static inline void Pipe_ResetPipe(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ResetPipe(const uint8_t Address)\r
+ {\r
+ uint32_t PipeNumber = (Address & PIPE_EPNUM_MASK);\r
+\r
+ AVR32_USBB.uprst |= (AVR32_USBB_PRST0_MASK << PipeNumber);\r
+ AVR32_USBB.uprst &= ~(AVR32_USBB_PRST0_MASK << PipeNumber);\r
+ USB_Pipe_FIFOPos[PipeNumber] = &AVR32_USBB_SLAVE[PipeNumber * PIPE_HSB_ADDRESS_SPACE_SIZE];\r
+ }\r
+\r
+ /** Enables the currently selected pipe so that data can be sent and received through it to and from\r
+ * an attached device.\r
+ *\r
+ * \pre The currently selected pipe must first be configured properly via \ref Pipe_ConfigurePipe().\r
+ */\r
+ static inline void Pipe_EnablePipe(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_EnablePipe(void)\r
+ {\r
+ AVR32_USBB.uprst |= (AVR32_USBB_PEN0_MASK << USB_Pipe_SelectedPipe);\r
+ }\r
+\r
+ /** Disables the currently selected pipe so that data cannot be sent and received through it to and\r
+ * from an attached device.\r
+ */\r
+ static inline void Pipe_DisablePipe(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_DisablePipe(void)\r
+ {\r
+ AVR32_USBB.uprst &= ~(AVR32_USBB_PEN0_MASK << USB_Pipe_SelectedPipe);\r
+ }\r
+\r
+ /** Determines if the currently selected pipe is enabled, but not necessarily configured.\r
+ *\r
+ * \return Boolean \c true if the currently selected pipe is enabled, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsEnabled(void)\r
+ {\r
+ return ((AVR32_USBB.uprst & (AVR32_USBB_PEN0_MASK << USB_Pipe_SelectedPipe)) ? true : false);\r
+ }\r
+\r
+ /** Gets the current pipe token, indicating the pipe's data direction and type.\r
+ *\r
+ * \return The current pipe token, as a \c PIPE_TOKEN_* mask.\r
+ */\r
+ static inline uint8_t Pipe_GetPipeToken(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetPipeToken(void)\r
+ {\r
+ return (&AVR32_USBB.UPCFG0)[USB_Pipe_SelectedPipe].ptoken;\r
+ }\r
+\r
+ /** Sets the token for the currently selected pipe to one of the tokens specified by the \c PIPE_TOKEN_*\r
+ * masks. This can be used on CONTROL type pipes, to allow for bidirectional transfer of data during\r
+ * control requests, or on regular pipes to allow for half-duplex bidirectional data transfer to devices\r
+ * which have two endpoints of opposite direction sharing the same endpoint address within the device.\r
+ *\r
+ * \param[in] Token New pipe token to set the selected pipe to, as a \c PIPE_TOKEN_* mask.\r
+ */\r
+ static inline void Pipe_SetPipeToken(const uint8_t Token) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SetPipeToken(const uint8_t Token)\r
+ {\r
+ (&AVR32_USBB.UPCFG0)[USB_Pipe_SelectedPipe].ptoken = Token;\r
+ }\r
+\r
+ /** Configures the currently selected pipe to allow for an unlimited number of IN requests. */\r
+ static inline void Pipe_SetInfiniteINRequests(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SetInfiniteINRequests(void)\r
+ {\r
+ (&AVR32_USBB.UPINRQ0)[USB_Pipe_SelectedPipe].inmode = true;\r
+ }\r
+\r
+ /** Configures the currently selected pipe to only allow the specified number of IN requests to be\r
+ * accepted by the pipe before it is automatically frozen.\r
+ *\r
+ * \param[in] TotalINRequests Total number of IN requests that the pipe may receive before freezing.\r
+ */\r
+ static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SetFiniteINRequests(const uint8_t TotalINRequests)\r
+ {\r
+ (&AVR32_USBB.UPINRQ0)[USB_Pipe_SelectedPipe].inmode = false;\r
+ (&AVR32_USBB.UPINRQ0)[USB_Pipe_SelectedPipe].inrq = TotalINRequests;\r
+ }\r
+\r
+ /** Determines if the currently selected pipe is configured.\r
+ *\r
+ * \return Boolean \c true if the selected pipe is configured, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsConfigured(void)\r
+ {\r
+ return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].cfgok;\r
+ }\r
+\r
+ /** Retrieves the endpoint address of the endpoint within the attached device that the currently selected\r
+ * pipe is bound to.\r
+ *\r
+ * \return Endpoint address the currently selected pipe is bound to.\r
+ */\r
+ static inline uint8_t Pipe_GetBoundEndpointAddress(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetBoundEndpointAddress(void)\r
+ {\r
+ return ((&AVR32_USBB.UPCFG0)[USB_Pipe_SelectedPipe].pepnum |\r
+ ((Pipe_GetPipeToken() == PIPE_TOKEN_IN) ? PIPE_DIR_IN : PIPE_DIR_OUT));\r
+ }\r
+\r
+ /** Sets the period between interrupts for an INTERRUPT type pipe to a specified number of milliseconds.\r
+ *\r
+ * \param[in] Milliseconds Number of milliseconds between each pipe poll.\r
+ */\r
+ static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_SetInterruptPeriod(const uint8_t Milliseconds)\r
+ {\r
+ (&AVR32_USBB.UPCFG0)[USB_Pipe_SelectedPipe].intfrq = Milliseconds;\r
+ }\r
+\r
+ /** Returns a mask indicating which pipe's interrupt periods have elapsed, indicating that the pipe should\r
+ * be serviced.\r
+ *\r
+ * \return Mask whose bits indicate which pipes have interrupted.\r
+ */\r
+ static inline uint8_t Pipe_GetPipeInterrupts(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetPipeInterrupts(void)\r
+ {\r
+ return ((AVR32_USBB.uhint & (AVR32_USBB_P6INT_MASK | AVR32_USBB_P5INT_MASK |\r
+ AVR32_USBB_P4INT_MASK | AVR32_USBB_P3INT_MASK |\r
+ AVR32_USBB_P2INT_MASK | AVR32_USBB_P1INT_MASK |\r
+ AVR32_USBB_P0INT_MASK)) >> AVR32_USBB_P0INT_OFFSET);\r
+ }\r
+\r
+ /** Determines if the specified pipe address has interrupted (valid only for INTERRUPT type\r
+ * pipes).\r
+ *\r
+ * \param[in] Address Address of the pipe whose interrupt flag should be tested.\r
+ *\r
+ * \return Boolean \c true if the specified pipe has interrupted, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_HasPipeInterrupted(const uint8_t Address) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_HasPipeInterrupted(const uint8_t Address)\r
+ {\r
+ return ((AVR32_USBB.uhint & (AVR32_USBB_P0INTES_MASK << (Address & PIPE_EPNUM_MASK))) ? true : false);\r
+ }\r
+\r
+ /** Unfreezes the selected pipe, allowing it to communicate with an attached device. */\r
+ static inline void Pipe_Unfreeze(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Unfreeze(void)\r
+ {\r
+ (&AVR32_USBB.UPCON0CLR)[USB_Pipe_SelectedPipe].pfreezec = true;\r
+ }\r
+\r
+ /** Freezes the selected pipe, preventing it from communicating with an attached device. */\r
+ static inline void Pipe_Freeze(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Freeze(void)\r
+ {\r
+ (&AVR32_USBB.UPCON0SET)[USB_Pipe_SelectedPipe].pfreezes = true;\r
+ }\r
+\r
+ /** Determines if the currently selected pipe is frozen, and not able to accept data.\r
+ *\r
+ * \return Boolean \c true if the currently selected pipe is frozen, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsFrozen(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsFrozen(void)\r
+ {\r
+ return (((&AVR32_USBB.UPCON0)[USB_Pipe_SelectedPipe].pfreeze) ? true : false);\r
+ }\r
+\r
+ /** Clears the error flags for the currently selected pipe. */\r
+ static inline void Pipe_ClearError(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearError(void)\r
+ {\r
+ (&AVR32_USBB.uperr0)[USB_Pipe_SelectedPipe] = 0;\r
+ (&AVR32_USBB.UPSTA0CLR)[USB_Pipe_SelectedPipe].overfic = true;\r
+ }\r
+\r
+ /** Determines if the master pipe error flag is set for the currently selected pipe, indicating that\r
+ * some sort of hardware error has occurred on the pipe.\r
+ *\r
+ * \see \ref Pipe_GetErrorFlags() macro for information on retrieving the exact error flag.\r
+ *\r
+ * \return Boolean \c true if an error has occurred on the selected pipe, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsError(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsError(void)\r
+ {\r
+ return (((&AVR32_USBB.upsta0)[USB_Pipe_SelectedPipe] &\r
+ (AVR32_USBB_PERRI_MASK | AVR32_USBB_OVERFI_MASK)) ? true : false);\r
+ }\r
+\r
+ /** Gets a mask of the hardware error flags which have occurred on the currently selected pipe. This\r
+ * value can then be masked against the \c PIPE_ERRORFLAG_* masks to determine what error has occurred.\r
+ *\r
+ * \return Mask comprising of \c PIPE_ERRORFLAG_* bits indicating what error has occurred on the selected pipe.\r
+ */\r
+ static inline uint8_t Pipe_GetErrorFlags(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetErrorFlags(void)\r
+ {\r
+\r
+ return (((&AVR32_USBB.uperr0)[USB_Pipe_SelectedPipe] &\r
+ (PIPE_ERRORFLAG_CRC16 | PIPE_ERRORFLAG_TIMEOUT |\r
+ PIPE_ERRORFLAG_PID | PIPE_ERRORFLAG_DATAPID |\r
+ PIPE_ERRORFLAG_DATATGL)) |\r
+ (((&AVR32_USBB.upsta0)[USB_Pipe_SelectedPipe] << 8) &\r
+ PIPE_ERRORFLAG_OVERFLOW));\r
+ }\r
+\r
+ /** Retrieves the number of busy banks in the currently selected pipe, which have been queued for\r
+ * transmission via the \ref Pipe_ClearOUT() command, or are awaiting acknowledgement via the\r
+ * \ref Pipe_ClearIN() command.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_UC3\r
+ *\r
+ * \return Total number of busy banks in the selected pipe.\r
+ */\r
+ static inline uint8_t Pipe_GetBusyBanks(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_GetBusyBanks(void)\r
+ {\r
+ return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].nbusybk;\r
+ }\r
+\r
+ /** Determines if the currently selected pipe may be read from (if data is waiting in the pipe\r
+ * bank and the pipe is an IN direction, or if the bank is not yet full if the pipe is an OUT\r
+ * direction). This function will return false if an error has occurred in the pipe, or if the pipe\r
+ * is an IN direction and no packet (or an empty packet) has been received, or if the pipe is an OUT\r
+ * direction and the pipe bank is full.\r
+ *\r
+ * \note This function is not valid on CONTROL type pipes.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_UC3\r
+ *\r
+ * \return Boolean \c true if the currently selected pipe may be read from or written to, depending\r
+ * on its direction.\r
+ */\r
+ static inline bool Pipe_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsReadWriteAllowed(void)\r
+ {\r
+ return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].rwall;\r
+ }\r
+\r
+ /** Determines if a packet has been received on the currently selected IN pipe from the attached device.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_UC3\r
+ *\r
+ * \return Boolean \c true if the current pipe has received an IN packet, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsINReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsINReceived(void)\r
+ {\r
+ return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].rxini;\r
+ }\r
+\r
+ /** Determines if the currently selected OUT pipe is ready to send an OUT packet to the attached device.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_UC3\r
+ *\r
+ * \return Boolean \c true if the current pipe is ready for an OUT packet, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsOUTReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsOUTReady(void)\r
+ {\r
+ return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].txouti;\r
+ }\r
+\r
+ /** Determines if no SETUP request is currently being sent to the attached device on the selected\r
+ * CONTROL type pipe.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_UC3\r
+ *\r
+ * \return Boolean \c true if the current pipe is ready for a SETUP packet, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsSETUPSent(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsSETUPSent(void)\r
+ {\r
+ return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].txstpi;\r
+ }\r
+\r
+ /** Sends the currently selected CONTROL type pipe's contents to the device as a SETUP packet.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_UC3\r
+ */\r
+ static inline void Pipe_ClearSETUP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearSETUP(void)\r
+ {\r
+ (&AVR32_USBB.UPSTA0CLR)[USB_Pipe_SelectedPipe].txstpic = true;\r
+ (&AVR32_USBB.UPCON0CLR)[USB_Pipe_SelectedPipe].fifoconc = true;\r
+ USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[USB_Pipe_SelectedPipe * PIPE_HSB_ADDRESS_SPACE_SIZE];\r
+ }\r
+\r
+ /** Acknowledges the reception of a setup IN request from the attached device on the currently selected\r
+ * pipe, freeing the bank ready for the next packet.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_UC3\r
+ */\r
+ static inline void Pipe_ClearIN(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearIN(void)\r
+ {\r
+ (&AVR32_USBB.UPSTA0CLR)[USB_Pipe_SelectedPipe].rxinic = true;\r
+ (&AVR32_USBB.UPCON0CLR)[USB_Pipe_SelectedPipe].fifoconc = true;\r
+ USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[USB_Pipe_SelectedPipe * PIPE_HSB_ADDRESS_SPACE_SIZE];\r
+ }\r
+\r
+ /** Sends the currently selected pipe's contents to the device as an OUT packet on the selected pipe, freeing\r
+ * the bank ready for the next packet.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_UC3\r
+ */\r
+ static inline void Pipe_ClearOUT(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearOUT(void)\r
+ {\r
+ (&AVR32_USBB.UPSTA0CLR)[USB_Pipe_SelectedPipe].txoutic = true;\r
+ (&AVR32_USBB.UPCON0CLR)[USB_Pipe_SelectedPipe].fifoconc = true;\r
+ USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[USB_Pipe_SelectedPipe * PIPE_HSB_ADDRESS_SPACE_SIZE];\r
+ }\r
+\r
+ /** Determines if the device sent a NAK (Negative Acknowledge) in response to the last sent packet on\r
+ * the currently selected pipe. This occurs when the host sends a packet to the device, but the device\r
+ * is not currently ready to handle the packet (i.e. its endpoint banks are full). Once a NAK has been\r
+ * received, it must be cleared using \ref Pipe_ClearNAKReceived() before the previous (or any other) packet\r
+ * can be re-sent.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_UC3\r
+ *\r
+ * \return Boolean \c true if an NAK has been received on the current pipe, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsNAKReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsNAKReceived(void)\r
+ {\r
+ return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].nakedi;\r
+ }\r
+\r
+ /** Clears the NAK condition on the currently selected pipe.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_UC3\r
+ *\r
+ * \see \ref Pipe_IsNAKReceived() for more details.\r
+ */\r
+ static inline void Pipe_ClearNAKReceived(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearNAKReceived(void)\r
+ {\r
+ (&AVR32_USBB.UPSTA0CLR)[USB_Pipe_SelectedPipe].nakedic = true;\r
+ }\r
+\r
+ /** Determines if the currently selected pipe has had the STALL condition set by the attached device.\r
+ *\r
+ * \ingroup Group_PipePacketManagement_UC3\r
+ *\r
+ * \return Boolean \c true if the current pipe has been stalled by the attached device, \c false otherwise.\r
+ */\r
+ static inline bool Pipe_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Pipe_IsStalled(void)\r
+ {\r
+ return (&AVR32_USBB.UPSTA0)[USB_Pipe_SelectedPipe].rxstalldi;\r
+ }\r
+\r
+ /** Clears the STALL condition detection flag on the currently selected pipe, but does not clear the\r
+ * STALL condition itself (this must be done via a ClearFeature control request to the device).\r
+ *\r
+ * \ingroup Group_PipePacketManagement_UC3\r
+ */\r
+ static inline void Pipe_ClearStall(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_ClearStall(void)\r
+ {\r
+ (&AVR32_USBB.UPSTA0CLR)[USB_Pipe_SelectedPipe].rxstalldic = true;\r
+ USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe] = &AVR32_USBB_SLAVE[USB_Pipe_SelectedPipe * PIPE_HSB_ADDRESS_SPACE_SIZE];\r
+ }\r
+\r
+ /** Reads one byte from the currently selected pipe's bank, for OUT direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ *\r
+ * \return Next byte in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint8_t Pipe_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_Read_8(void)\r
+ {\r
+ return *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ }\r
+\r
+ /** Writes one byte to the currently selected pipe's bank, for IN direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ *\r
+ * \param[in] Data Data to write into the the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Write_8(const uint8_t Data)\r
+ {\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = Data;\r
+ }\r
+\r
+ /** Discards one byte from the currently selected pipe's bank, for OUT direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ */\r
+ static inline void Pipe_Discard_8(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Discard_8(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+\r
+ (void)Dummy;\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected pipe's bank in little endian format, for OUT\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ *\r
+ * \return Next two bytes in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint16_t Pipe_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Pipe_Read_16_LE(void)\r
+ {\r
+ uint16_t Byte0 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ uint16_t Byte1 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+\r
+ return ((Byte1 << 8) | Byte0);\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ *\r
+ * \return Next two bytes in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint16_t Pipe_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Pipe_Read_16_BE(void)\r
+ {\r
+ uint16_t Byte0 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ uint16_t Byte1 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+\r
+ return ((Byte0 << 8) | Byte1);\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected pipe's bank in little endian format, for IN\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ *\r
+ * \param[in] Data Data to write to the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Write_16_LE(const uint16_t Data)\r
+ {\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data & 0xFF);\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 8);\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected pipe's bank in big endian format, for IN\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ *\r
+ * \param[in] Data Data to write to the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Write_16_BE(const uint16_t Data)\r
+ {\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 8);\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data & 0xFF);\r
+ }\r
+\r
+ /** Discards two bytes from the currently selected pipe's bank, for OUT direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ */\r
+ static inline void Pipe_Discard_16(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Discard_16(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+\r
+ (void)Dummy;\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected pipe's bank in little endian format, for OUT\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ *\r
+ * \return Next four bytes in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint32_t Pipe_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Pipe_Read_32_LE(void)\r
+ {\r
+ uint32_t Byte0 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ uint32_t Byte1 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ uint32_t Byte2 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ uint32_t Byte3 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+\r
+ return ((Byte3 << 24) | (Byte2 << 16) | (Byte1 << 8) | Byte0);\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ *\r
+ * \return Next four bytes in the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline uint32_t Pipe_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Pipe_Read_32_BE(void)\r
+ {\r
+ uint32_t Byte0 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ uint32_t Byte1 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ uint32_t Byte2 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ uint32_t Byte3 = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+\r
+ return ((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3);\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected pipe's bank in little endian format, for IN\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ *\r
+ * \param[in] Data Data to write to the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Write_32_LE(const uint32_t Data)\r
+ {\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data & 0xFF);\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 8);\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 16);\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 24);\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected pipe's bank in big endian format, for IN\r
+ * direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ *\r
+ * \param[in] Data Data to write to the currently selected pipe's FIFO buffer.\r
+ */\r
+ static inline void Pipe_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Write_32_BE(const uint32_t Data)\r
+ {\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 24);\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 16);\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data >> 8);\r
+ *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++) = (Data & 0xFF);\r
+ }\r
+\r
+ /** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes.\r
+ *\r
+ * \ingroup Group_PipePrimitiveRW_UC3\r
+ */\r
+ static inline void Pipe_Discard_32(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Pipe_Discard_32(void)\r
+ {\r
+ uint8_t Dummy;\r
+\r
+ Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+ Dummy = *(USB_Pipe_FIFOPos[USB_Pipe_SelectedPipe]++);\r
+\r
+ (void)Dummy;\r
+ }\r
+\r
+ /* External Variables: */\r
+ /** Global indicating the maximum packet size of the default control pipe located at address\r
+ * 0 in the device. This value is set to the value indicated in the attached device's device\r
+ * descriptor once the USB interface is initialized into host mode and a device is attached\r
+ * to the USB bus.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ extern uint8_t USB_Host_ControlPipeSize;\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures a table of pipe descriptions, in sequence. This function can be used to configure multiple\r
+ * pipes at the same time.\r
+ *\r
+ * \note Pipe with a zero address will be ignored, thus this function cannot be used to configure the\r
+ * control pipe.\r
+ *\r
+ * \param[in] Table Pointer to a table of pipe descriptions.\r
+ * \param[in] Entries Number of entries in the pipe table to configure.\r
+ *\r
+ * \return Boolean \c true if all pipes configured successfully, \c false otherwise.\r
+ */ \r
+ bool Pipe_ConfigurePipeTable(const USB_Pipe_Table_t* const Table,\r
+ const uint8_t Entries);\r
+\r
+ /** Configures the specified pipe address with the given pipe type, endpoint address within the attached device, bank size\r
+ * and number of hardware banks.\r
+ *\r
+ * A newly configured pipe is frozen by default, and must be unfrozen before use via the \ref Pipe_Unfreeze()\r
+ * before being used. Pipes should be kept frozen unless waiting for data from a device while in IN mode, or\r
+ * sending data to the device in OUT mode. IN type pipes are also automatically configured to accept infinite\r
+ * numbers of IN requests without automatic freezing - this can be overridden by a call to\r
+ * \ref Pipe_SetFiniteINRequests().\r
+ *\r
+ * \param[in] Address Pipe address to configure.\r
+ *\r
+ * \param[in] Type Type of pipe to configure, an \c EP_TYPE_* mask. Not all pipe types are available on Low\r
+ * Speed USB devices - refer to the USB 2.0 specification.\r
+ *\r
+ * \param[in] EndpointAddress Endpoint address within the attached device that the pipe should interface to.\r
+ *\r
+ * \param[in] Size Size of the pipe's bank, where packets are stored before they are transmitted to\r
+ * the USB device, or after they have been received from the USB device (depending on\r
+ * the pipe's data direction). The bank size must indicate the maximum packet size that\r
+ * the pipe can handle.\r
+ *\r
+ * \param[in] Banks Number of banks to use for the pipe being configured.\r
+ *\r
+ * \note When the \c ORDERED_EP_CONFIG compile time option is used, Pipes <b>must</b> be configured in ascending order,\r
+ * or bank corruption will occur.\r
+ * \n\n\r
+ *\r
+ * \note Certain microcontroller model's pipes may have different maximum packet sizes based on the pipe's\r
+ * index - refer to the chosen microcontroller's datasheet to determine the maximum bank size for each pipe.\r
+ * \n\n\r
+ *\r
+ * \note The default control pipe should not be manually configured by the user application, as it is\r
+ * automatically configured by the library internally.\r
+ * \n\n\r
+ *\r
+ * \note This routine will automatically select the specified pipe upon success. Upon failure, the pipe which\r
+ * failed to reconfigure correctly will be selected.\r
+ *\r
+ * \return Boolean \c true if the configuration succeeded, \c false otherwise.\r
+ */\r
+ bool Pipe_ConfigurePipe(const uint8_t Address,\r
+ const uint8_t Type,\r
+ const uint8_t EndpointAddress,\r
+ const uint16_t Size,\r
+ const uint8_t Banks);\r
+\r
+ /** Spin-loops until the currently selected non-control pipe is ready for the next packet of data to be read\r
+ * or written to it, aborting in the case of an error condition (such as a timeout or device disconnect).\r
+ *\r
+ * \ingroup Group_PipeRW_UC3\r
+ *\r
+ * \return A value from the \ref Pipe_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Pipe_WaitUntilReady(void);\r
+\r
+ /** Determines if a pipe has been bound to the given device endpoint address. If a pipe which is bound to the given\r
+ * endpoint is found, it is automatically selected.\r
+ *\r
+ * \param[in] EndpointAddress Address and direction mask of the endpoint within the attached device to check.\r
+ *\r
+ * \return Boolean \c true if a pipe bound to the given endpoint address of the specified direction is found,\r
+ * \c false otherwise.\r
+ */\r
+ bool Pipe_IsEndpointBound(const uint8_t EndpointAddress) ATTR_WARN_UNUSED_RESULT;\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #if !defined(ENDPOINT_CONTROLEP)\r
+ #define ENDPOINT_CONTROLEP 0\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Pipe_BytesToEPSizeMask(const uint16_t Bytes)\r
+ {\r
+ uint8_t MaskVal = 0;\r
+ uint16_t CheckBytes = 8;\r
+\r
+ while ((CheckBytes < Bytes) && (CheckBytes < PIPE_MAX_SIZE))\r
+ {\r
+ MaskVal++;\r
+ CheckBytes <<= 1;\r
+ }\r
+\r
+ return (MaskVal << AVR32_USBB_PSIZE_OFFSET);\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ void Pipe_ClearPipes(void);\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#if defined(TEMPLATE_FUNC_NAME)\r
+\r
+// cppcheck-suppress unusedFunction\r
+uint8_t TEMPLATE_FUNC_NAME (void* const Buffer,\r
+ uint16_t Length)\r
+{\r
+ uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
+\r
+ if (!(Length))\r
+ Endpoint_ClearOUT();\r
+\r
+ while (Length)\r
+ {\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_RWCSTREAM_BusSuspended;\r
+ else if (Endpoint_IsSETUPReceived())\r
+ return ENDPOINT_RWCSTREAM_HostAborted;\r
+\r
+ if (Endpoint_IsOUTReceived())\r
+ {\r
+ while (Length && Endpoint_BytesInEndpoint())\r
+ {\r
+ TEMPLATE_TRANSFER_BYTE(DataStream);\r
+ TEMPLATE_BUFFER_MOVE(DataStream, 1);\r
+ Length--;\r
+ }\r
+\r
+ Endpoint_ClearOUT();\r
+ }\r
+ }\r
+\r
+ while (!(Endpoint_IsINReady()))\r
+ {\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_RWCSTREAM_BusSuspended;\r
+ }\r
+\r
+ return ENDPOINT_RWCSTREAM_NoError;\r
+}\r
+\r
+#undef TEMPLATE_BUFFER_OFFSET\r
+#undef TEMPLATE_BUFFER_MOVE\r
+#undef TEMPLATE_FUNC_NAME\r
+#undef TEMPLATE_TRANSFER_BYTE\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#if defined(TEMPLATE_FUNC_NAME)\r
+\r
+// cppcheck-suppress unusedFunction\r
+uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer,\r
+ uint16_t Length)\r
+{\r
+ uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
+ bool LastPacketFull = false;\r
+\r
+ if (Length > USB_ControlRequest.wLength)\r
+ Length = USB_ControlRequest.wLength;\r
+ else if (!(Length))\r
+ Endpoint_ClearIN();\r
+\r
+ while (Length || LastPacketFull)\r
+ {\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_RWCSTREAM_BusSuspended;\r
+ else if (Endpoint_IsSETUPReceived())\r
+ return ENDPOINT_RWCSTREAM_HostAborted;\r
+ else if (Endpoint_IsOUTReceived())\r
+ break;\r
+\r
+ if (Endpoint_IsINReady())\r
+ {\r
+ uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint();\r
+\r
+ while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize))\r
+ {\r
+ TEMPLATE_TRANSFER_BYTE(DataStream);\r
+ TEMPLATE_BUFFER_MOVE(DataStream, 1);\r
+ Length--;\r
+ BytesInEndpoint++;\r
+ }\r
+\r
+ LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize);\r
+ Endpoint_ClearIN();\r
+ }\r
+ }\r
+\r
+ while (!(Endpoint_IsOUTReceived()))\r
+ {\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_RWCSTREAM_BusSuspended;\r
+ }\r
+\r
+ return ENDPOINT_RWCSTREAM_NoError;\r
+}\r
+\r
+#undef TEMPLATE_BUFFER_OFFSET\r
+#undef TEMPLATE_BUFFER_MOVE\r
+#undef TEMPLATE_FUNC_NAME\r
+#undef TEMPLATE_TRANSFER_BYTE\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#if defined(TEMPLATE_FUNC_NAME)\r
+\r
+// cppcheck-suppress unusedFunction\r
+uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
+ uint16_t BytesInTransfer = 0;\r
+ uint8_t ErrorCode;\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ Length -= *BytesProcessed;\r
+ TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed);\r
+ }\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ {\r
+ TEMPLATE_CLEAR_ENDPOINT();\r
+\r
+ #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
+ USB_USBTask();\r
+ #endif\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return ENDPOINT_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ TEMPLATE_TRANSFER_BYTE(DataStream);\r
+ TEMPLATE_BUFFER_MOVE(DataStream, 1);\r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+\r
+ return ENDPOINT_RWSTREAM_NoError;\r
+}\r
+\r
+#undef TEMPLATE_FUNC_NAME\r
+#undef TEMPLATE_BUFFER_TYPE\r
+#undef TEMPLATE_TRANSFER_BYTE\r
+#undef TEMPLATE_CLEAR_ENDPOINT\r
+#undef TEMPLATE_BUFFER_OFFSET\r
+#undef TEMPLATE_BUFFER_MOVE\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#if defined(TEMPLATE_FUNC_NAME)\r
+\r
+// cppcheck-suppress unusedFunction\r
+uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
+ uint16_t BytesInTransfer = 0;\r
+ uint8_t ErrorCode;\r
+\r
+ Pipe_SetPipeToken(TEMPLATE_TOKEN);\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ Length -= *BytesProcessed;\r
+ TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed);\r
+ }\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Pipe_IsReadWriteAllowed()))\r
+ {\r
+ TEMPLATE_CLEAR_PIPE();\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return PIPE_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Pipe_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ TEMPLATE_TRANSFER_BYTE(DataStream);\r
+ TEMPLATE_BUFFER_MOVE(DataStream, 1);\r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+\r
+ return PIPE_RWSTREAM_NoError;\r
+}\r
+\r
+#undef TEMPLATE_FUNC_NAME\r
+#undef TEMPLATE_BUFFER_TYPE\r
+#undef TEMPLATE_TOKEN\r
+#undef TEMPLATE_TRANSFER_BYTE\r
+#undef TEMPLATE_CLEAR_PIPE\r
+#undef TEMPLATE_BUFFER_OFFSET\r
+#undef TEMPLATE_BUFFER_MOVE\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_UC3)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#define __INCLUDE_FROM_USB_CONTROLLER_C\r
+#include "../USBController.h"\r
+\r
+#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY))\r
+volatile uint8_t USB_CurrentMode = USB_MODE_None;\r
+#endif\r
+\r
+#if !defined(USE_STATIC_OPTIONS)\r
+volatile uint8_t USB_Options;\r
+#endif\r
+\r
+void USB_Init(\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ const uint8_t Mode\r
+ #endif\r
+\r
+ #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS))\r
+ ,\r
+ #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))\r
+ void\r
+ #endif\r
+\r
+ #if !defined(USE_STATIC_OPTIONS)\r
+ const uint8_t Options\r
+ #endif\r
+ )\r
+{\r
+ #if !defined(USE_STATIC_OPTIONS)\r
+ USB_Options = Options;\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ if (Mode == USB_MODE_UID)\r
+ {\r
+ AVR32_USBB.USBCON.uide = true;\r
+ USB_INT_Enable(USB_INT_IDTI);\r
+ USB_CurrentMode = USB_GetUSBModeFromUID();\r
+ }\r
+ else\r
+ {\r
+ AVR32_USBB.USBCON.uide = false;\r
+ USB_CurrentMode = Mode;\r
+ }\r
+ #else\r
+ AVR32_USBB.USBCON.uide = false;\r
+ #endif\r
+\r
+ USB_IsInitialized = true;\r
+\r
+ USB_ResetInterface();\r
+}\r
+\r
+void USB_Disable(void)\r
+{\r
+ USB_INT_DisableAllInterrupts();\r
+ USB_INT_ClearAllInterrupts();\r
+\r
+ USB_Detach();\r
+ USB_Controller_Disable();\r
+\r
+ USB_OTGPAD_Off();\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ USB_CurrentMode = USB_MODE_None;\r
+ #endif\r
+\r
+ AVR32_PM.GCCTRL[3].cen = false;\r
+\r
+ USB_IsInitialized = false;\r
+}\r
+\r
+void USB_ResetInterface(void)\r
+{\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ bool UIDModeSelectEnabled = AVR32_USBB.USBCON.uide;\r
+ #endif\r
+\r
+ AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].pllsel = !(USB_Options & USB_OPT_GCLK_SRC_OSC);\r
+ AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].oscsel = !(USB_Options & USB_OPT_GCLK_CHANNEL_0);\r
+ AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].diven = (F_USB != USB_CLOCK_REQUIRED_FREQ);\r
+ AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].div = (F_USB == USB_CLOCK_REQUIRED_FREQ) ? 0 : (uint32_t)((F_USB / USB_CLOCK_REQUIRED_FREQ / 2) - 1);\r
+ AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].cen = true;\r
+\r
+ USB_INT_DisableAllInterrupts();\r
+ USB_INT_ClearAllInterrupts();\r
+\r
+ USB_Controller_Reset();\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ if (UIDModeSelectEnabled)\r
+ USB_INT_Enable(USB_INT_IDTI);\r
+ #endif\r
+\r
+ USB_CLK_Unfreeze();\r
+\r
+ if (USB_CurrentMode == USB_MODE_Device)\r
+ {\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ AVR32_USBB.USBCON.uimod = true;\r
+\r
+ USB_Init_Device();\r
+ #endif\r
+ }\r
+ else if (USB_CurrentMode == USB_MODE_Host)\r
+ {\r
+ #if defined(INVERTED_VBUS_ENABLE_LINE)\r
+ AVR32_USBB.USBCON.vbuspo = true;\r
+ #endif\r
+ \r
+ #if defined(USB_CAN_BE_HOST)\r
+ AVR32_USBB.USBCON.uimod = false;\r
+\r
+ USB_Init_Host();\r
+ #endif\r
+ }\r
+\r
+ USB_OTGPAD_On();\r
+}\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+static void USB_Init_Device(void)\r
+{\r
+ USB_DeviceState = DEVICE_STATE_Unattached;\r
+ USB_Device_ConfigurationNumber = 0;\r
+\r
+ #if !defined(NO_DEVICE_REMOTE_WAKEUP)\r
+ USB_Device_RemoteWakeupEnabled = false;\r
+ #endif\r
+\r
+ #if !defined(NO_DEVICE_SELF_POWER)\r
+ USB_Device_CurrentlySelfPowered = false;\r
+ #endif\r
+\r
+ #if !defined(FIXED_CONTROL_ENDPOINT_SIZE)\r
+ USB_Descriptor_Device_t* DeviceDescriptorPtr;\r
+\r
+ if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)\r
+ USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;\r
+ #endif\r
+\r
+ if (USB_Options & USB_DEVICE_OPT_LOWSPEED)\r
+ {\r
+ USB_Device_SetLowSpeed();\r
+ }\r
+ else\r
+ {\r
+ #if defined(USB_DEVICE_OPT_HIGHSPEED)\r
+ if (USB_Options & USB_DEVICE_OPT_HIGHSPEED)\r
+ USB_Device_SetHighSpeed();\r
+ else\r
+ USB_Device_SetFullSpeed();\r
+ #else\r
+ USB_Device_SetFullSpeed();\r
+ #endif\r
+ }\r
+\r
+ USB_INT_Enable(USB_INT_VBUSTI);\r
+\r
+ Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,\r
+ USB_Device_ControlEndpointSize, 1);\r
+\r
+ USB_INT_Clear(USB_INT_SUSPI);\r
+ USB_INT_Enable(USB_INT_SUSPI);\r
+ USB_INT_Enable(USB_INT_EORSTI);\r
+\r
+ USB_Attach();\r
+}\r
+#endif\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+static void USB_Init_Host(void)\r
+{\r
+ USB_HostState = HOST_STATE_Unattached;\r
+ USB_Host_ConfigurationNumber = 0;\r
+ USB_Host_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;\r
+\r
+ USB_Host_HostMode_On();\r
+\r
+ USB_Host_VBUS_Auto_On();\r
+\r
+ USB_INT_Enable(USB_INT_DCONNI);\r
+ USB_INT_Enable(USB_INT_BCERRI);\r
+\r
+ USB_Attach();\r
+}\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Controller definitions for the AVR32 UC3 microcontrollers.\r
+ * \copydetails Group_USBManagement_UC3\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBManagement\r
+ * \defgroup Group_USBManagement_UC3 USB Interface Management (UC3)\r
+ * \brief USB Controller definitions for the AVR32 UC3 microcontrollers.\r
+ *\r
+ * Functions, macros, variables, enums and types related to the setup and management of the USB interface.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBCONTROLLER_UC3_H__\r
+#define __USBCONTROLLER_UC3_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBMode.h"\r
+ #include "../Events.h"\r
+ #include "../USBTask.h"\r
+ #include "../USBInterrupt.h"\r
+\r
+ #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)\r
+ #include "../Host.h"\r
+ #include "../OTG.h"\r
+ #include "../Pipe.h"\r
+ #include "../HostStandardReq.h"\r
+ #include "../PipeStream.h"\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
+ #include "../Device.h"\r
+ #include "../Endpoint.h"\r
+ #include "../DeviceStandardReq.h"\r
+ #include "../EndpointStream.h"\r
+ #endif\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks and Defines: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ #if !defined(F_USB)\r
+ #error F_USB is not defined. You must define F_USB to the frequency of the clock input to the USB module.\r
+ #endif\r
+\r
+ #if (defined(USB_SERIES_UC3A3_AVR) || defined(USB_SERIES_UC3A4_AVR))\r
+ #if ((F_USB < 12000000) || (F_USB % 12000000))\r
+ #error Invalid F_USB specified. F_USB must be a multiple of 12MHz for UC3A3 and UC3A4 devices.\r
+ #endif \r
+ #else\r
+ #if ((F_USB < 48000000) || (F_USB % 48000000))\r
+ #error Invalid F_USB specified. F_USB must be a multiple of 48MHz for UC3A and UC3B devices.\r
+ #endif \r
+ #endif\r
+ \r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name USB Controller Option Masks */\r
+ //@{\r
+ /** Selects one of the system's main clock oscillators as the input clock to the USB Generic Clock source\r
+ * generation module. This indicates that an external oscillator should be used directly instead of an\r
+ * internal PLL clock source.\r
+ */\r
+ #define USB_OPT_GCLK_SRC_OSC (1 << 2)\r
+\r
+ /** Selects one of the system's PLL oscillators as the input clock to the USB Generic Clock source\r
+ * generation module. This indicates that one of the device's PLL outputs should be used instead of an\r
+ * external oscillator source.\r
+ */\r
+ #define USB_OPT_GCLK_SRC_PLL (0 << 2)\r
+\r
+ /** Selects PLL or External Oscillator 0 as the USB Generic Clock source module input clock. */\r
+ #define USB_OPT_GCLK_CHANNEL_0 (1 << 3)\r
+\r
+ /** Selects PLL or External Oscillator 1 as the USB Generic Clock source module input clock. */\r
+ #define USB_OPT_GCLK_CHANNEL_1 (0 << 3)\r
+ //@}\r
+\r
+ #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)\r
+ /** Constant for the maximum software timeout period of the USB data stream transfer functions\r
+ * (both control and standard) when in either device or host mode. If the next packet of a stream\r
+ * is not received or acknowledged within this time period, the stream function will fail.\r
+ *\r
+ * This value may be overridden in the user project makefile as the value of the\r
+ * \ref USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch.\r
+ */\r
+ #define USB_STREAM_TIMEOUT_MS 100\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ /** Determines if the VBUS line is currently high (i.e. the USB host is supplying power).\r
+ *\r
+ * \return Boolean \c true if the VBUS line is currently detecting power from a host, \c false otherwise.\r
+ */\r
+ static inline bool USB_VBUS_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool USB_VBUS_GetStatus(void)\r
+ {\r
+ return AVR32_USBB.USBSTA.vbus;\r
+ }\r
+\r
+ /** Detaches the device from the USB bus. This has the effect of removing the device from any\r
+ * attached host, ceasing USB communications. If no host is present, this prevents any host from\r
+ * enumerating the device once attached until \ref USB_Attach() is called.\r
+ */\r
+ static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Detach(void)\r
+ {\r
+ AVR32_USBB.UDCON.detach = true;\r
+ }\r
+\r
+ /** Attaches the device to the USB bus. This announces the device's presence to any attached\r
+ * USB host, starting the enumeration process. If no host is present, attaching the device\r
+ * will allow for enumeration once a host is connected to the device.\r
+ *\r
+ * This is inexplicably also required for proper operation while in host mode, to enable the\r
+ * attachment of a device to the host. This is despite the bit being located in the device-mode\r
+ * register and despite the datasheet making no mention of its requirement in host mode.\r
+ */\r
+ static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Attach(void)\r
+ {\r
+ AVR32_USBB.UDCON.detach = false;\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ /** Main function to initialize and start the USB interface. Once active, the USB interface will\r
+ * allow for device connection to a host when in device mode, or for device enumeration while in\r
+ * host mode.\r
+ *\r
+ * As the USB library relies on interrupts for the device and host mode enumeration processes,\r
+ * the user must enable global interrupts before or shortly after this function is called. In\r
+ * device mode, interrupts must be enabled within 500ms of this function being called to ensure\r
+ * that the host does not time out whilst enumerating the device. In host mode, interrupts may be\r
+ * enabled at the application's leisure however enumeration will not begin of an attached device\r
+ * until after this has occurred.\r
+ *\r
+ * Calling this function when the USB interface is already initialized will cause a complete USB\r
+ * interface reset and re-enumeration.\r
+ *\r
+ * \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value\r
+ * from the \ref USB_Modes_t enum.\r
+ *\r
+ * \param[in] Options Mask indicating the options which should be used when initializing the USB\r
+ * interface to control the USB interface's behavior. This should be comprised of\r
+ * a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the\r
+ * PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device\r
+ * mode speed.\r
+ *\r
+ * \note To reduce the FLASH requirements of the library if only device or host mode is required,\r
+ * the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY\r
+ * (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler\r
+ * via the -D switch. If the mode is statically set, this parameter does not exist in the\r
+ * function prototype.\r
+ * \n\n\r
+ *\r
+ * \note To reduce the FLASH requirements of the library if only fixed settings are required,\r
+ * the options may be set statically in the same manner as the mode (see the Mode parameter of\r
+ * this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token,\r
+ * defined to the appropriate options masks. When the options are statically set, this\r
+ * parameter does not exist in the function prototype.\r
+ *\r
+ * \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks.\r
+ */\r
+ void USB_Init(\r
+ #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)\r
+ const uint8_t Mode\r
+ #endif\r
+\r
+ #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__)\r
+ ,\r
+ #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))\r
+ void\r
+ #endif\r
+\r
+ #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)\r
+ const uint8_t Options\r
+ #endif\r
+ );\r
+\r
+ /** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO\r
+ * memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface\r
+ * is restarted with the \ref USB_Init() function.\r
+ */\r
+ void USB_Disable(void);\r
+\r
+ /** Resets the interface, when already initialized. This will re-enumerate the device if already connected\r
+ * to a host, or re-enumerate an already attached device when in host mode.\r
+ */\r
+ void USB_ResetInterface(void);\r
+\r
+ /* Global Variables: */\r
+ #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)\r
+ /** Indicates the mode that the USB interface is currently initialized to, a value from the\r
+ * \ref USB_Modes_t enum.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ *\r
+ * \note When the controller is initialized into UID auto-detection mode, this variable will hold the\r
+ * currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller\r
+ * is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time\r
+ * options, or a limitation of the USB controller in the chosen device model) this will evaluate to\r
+ * a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the\r
+ * USB interface is not initialized.\r
+ */\r
+ extern volatile uint8_t USB_CurrentMode;\r
+ #elif defined(USB_HOST_ONLY)\r
+ #define USB_CurrentMode USB_MODE_Host\r
+ #elif defined(USB_DEVICE_ONLY)\r
+ #define USB_CurrentMode USB_MODE_Device\r
+ #endif\r
+\r
+ #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)\r
+ /** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init()\r
+ * was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ extern volatile uint8_t USB_Options;\r
+ #elif defined(USE_STATIC_OPTIONS)\r
+ #define USB_Options USE_STATIC_OPTIONS\r
+ #endif\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the\r
+ * user application via \ref USB_CurrentMode.\r
+ */\r
+ enum USB_Modes_t\r
+ {\r
+ USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */\r
+ USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */\r
+ USB_MODE_Host = 2, /**< Indicates that the controller is currently initialized in USB Host mode. */\r
+ USB_MODE_UID = 3, /**< Indicates that the controller should determine the USB mode from the UID pin of the\r
+ * USB connector.\r
+ */\r
+ };\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #if defined(USB_SERIES_UC3A3_AVR32) || defined(USB_SERIES_UC3A4_AVR32)\r
+ #define USB_CLOCK_REQUIRED_FREQ 12000000UL\r
+ #else\r
+ #define USB_CLOCK_REQUIRED_FREQ 48000000UL\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_USB_CONTROLLER_C)\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ static void USB_Init_Device(void);\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ static void USB_Init_Host(void);\r
+ #endif\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTGPAD_On(void)\r
+ {\r
+ AVR32_USBB.USBCON.otgpade = true;\r
+ }\r
+\r
+ static inline void USB_OTGPAD_Off(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_OTGPAD_Off(void)\r
+ {\r
+ AVR32_USBB.USBCON.otgpade = false;\r
+ }\r
+\r
+ static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_CLK_Freeze(void)\r
+ {\r
+ AVR32_USBB.USBCON.frzclk = true;\r
+ }\r
+\r
+ static inline void USB_CLK_Unfreeze(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_CLK_Unfreeze(void)\r
+ {\r
+ AVR32_USBB.USBCON.frzclk = false;\r
+ }\r
+\r
+ static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Controller_Enable(void)\r
+ {\r
+ AVR32_USBB.USBCON.usbe = true;\r
+ }\r
+\r
+ static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Controller_Disable(void)\r
+ {\r
+ AVR32_USBB.USBCON.usbe = false;\r
+ }\r
+\r
+ static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Controller_Reset(void)\r
+ {\r
+ AVR32_USBB.USBCON.usbe = false;\r
+ AVR32_USBB.USBCON.usbe = true;\r
+ }\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ static inline uint8_t USB_GetUSBModeFromUID(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t USB_GetUSBModeFromUID(void)\r
+ {\r
+ if (AVR32_USBB.USBSTA.id)\r
+ return USB_MODE_Device;\r
+ else\r
+ return USB_MODE_Host;\r
+ }\r
+ #endif\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_UC3)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBInterrupt.h"\r
+\r
+void USB_INT_DisableAllInterrupts(void)\r
+{\r
+ AVR32_USBB.USBCON.vbuste = false;\r
+ AVR32_USBB.USBCON.idte = false;\r
+\r
+ AVR32_USBB.uhinteclr = -1;\r
+ AVR32_USBB.udinteclr = -1;\r
+}\r
+\r
+void USB_INT_ClearAllInterrupts(void)\r
+{\r
+ AVR32_USBB.USBSTACLR.vbustic = true;\r
+ AVR32_USBB.USBSTACLR.idtic = true;\r
+\r
+ AVR32_USBB.uhintclr = -1;\r
+ AVR32_USBB.udintclr = -1;\r
+}\r
+\r
+ISR(USB_GEN_vect)\r
+{\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #if !defined(NO_SOF_EVENTS)\r
+ if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_SOFI);\r
+\r
+ EVENT_USB_Device_StartOfFrame();\r
+ }\r
+ #endif\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_VBUSTI) && USB_INT_IsEnabled(USB_INT_VBUSTI))\r
+ {\r
+ USB_INT_Clear(USB_INT_VBUSTI);\r
+\r
+ if (USB_VBUS_GetStatus())\r
+ {\r
+ USB_DeviceState = DEVICE_STATE_Powered;\r
+ EVENT_USB_Device_Connect();\r
+ }\r
+ else\r
+ {\r
+ USB_DeviceState = DEVICE_STATE_Unattached;\r
+ EVENT_USB_Device_Disconnect();\r
+ }\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI))\r
+ {\r
+ USB_INT_Disable(USB_INT_SUSPI);\r
+ USB_INT_Enable(USB_INT_WAKEUPI);\r
+\r
+ USB_CLK_Freeze();\r
+\r
+ USB_DeviceState = DEVICE_STATE_Suspended;\r
+ EVENT_USB_Device_Suspend();\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI))\r
+ {\r
+ USB_CLK_Unfreeze();\r
+\r
+ USB_INT_Clear(USB_INT_WAKEUPI);\r
+\r
+ USB_INT_Disable(USB_INT_WAKEUPI);\r
+ USB_INT_Enable(USB_INT_SUSPI);\r
+\r
+ if (USB_Device_ConfigurationNumber)\r
+ USB_DeviceState = DEVICE_STATE_Configured;\r
+ else\r
+ USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;\r
+\r
+ EVENT_USB_Device_WakeUp();\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI))\r
+ {\r
+ USB_INT_Clear(USB_INT_EORSTI);\r
+\r
+ USB_DeviceState = DEVICE_STATE_Default;\r
+ USB_Device_ConfigurationNumber = 0;\r
+\r
+ USB_INT_Clear(USB_INT_SUSPI);\r
+ USB_INT_Disable(USB_INT_SUSPI);\r
+ USB_INT_Enable(USB_INT_WAKEUPI);\r
+\r
+ USB_Device_SetDeviceAddress(0);\r
+ Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,\r
+ USB_Device_ControlEndpointSize, 1);\r
+\r
+ #if defined(INTERRUPT_CONTROL_ENDPOINT)\r
+ USB_INT_Enable(USB_INT_RXSTPI);\r
+ #endif\r
+\r
+ EVENT_USB_Device_Reset();\r
+ }\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #if !defined(NO_SOF_EVENTS)\r
+ if (USB_INT_HasOccurred(USB_INT_HSOFI) && USB_INT_IsEnabled(USB_INT_HSOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_HSOFI);\r
+\r
+ EVENT_USB_Host_StartOfFrame();\r
+ }\r
+ #endif\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_DDISCI) && USB_INT_IsEnabled(USB_INT_DDISCI))\r
+ {\r
+ USB_INT_Clear(USB_INT_DDISCI);\r
+ USB_INT_Clear(USB_INT_DCONNI);\r
+ USB_INT_Disable(USB_INT_DDISCI);\r
+\r
+ EVENT_USB_Host_DeviceUnattached();\r
+\r
+ USB_ResetInterface();\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_VBERRI) && USB_INT_IsEnabled(USB_INT_VBERRI))\r
+ {\r
+ USB_INT_Clear(USB_INT_VBERRI);\r
+\r
+ USB_Host_VBUS_Manual_Off();\r
+ USB_Host_VBUS_Auto_Off();\r
+\r
+ EVENT_USB_Host_HostError(HOST_ERROR_VBusVoltageDip);\r
+ EVENT_USB_Host_DeviceUnattached();\r
+\r
+ USB_HostState = HOST_STATE_Unattached;\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_DCONNI) && USB_INT_IsEnabled(USB_INT_DCONNI))\r
+ {\r
+ USB_INT_Clear(USB_INT_DCONNI);\r
+ USB_INT_Disable(USB_INT_DCONNI);\r
+\r
+ EVENT_USB_Host_DeviceAttached();\r
+\r
+ USB_INT_Enable(USB_INT_DDISCI);\r
+\r
+ USB_HostState = HOST_STATE_Powered;\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_BCERRI) && USB_INT_IsEnabled(USB_INT_BCERRI))\r
+ {\r
+ USB_INT_Clear(USB_INT_BCERRI);\r
+\r
+ EVENT_USB_Host_DeviceEnumerationFailed(HOST_ENUMERROR_NoDeviceDetected, 0);\r
+ EVENT_USB_Host_DeviceUnattached();\r
+\r
+ USB_ResetInterface();\r
+ }\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ if (USB_INT_HasOccurred(USB_INT_IDTI) && USB_INT_IsEnabled(USB_INT_IDTI))\r
+ {\r
+ USB_INT_Clear(USB_INT_IDTI);\r
+\r
+ if (USB_DeviceState != DEVICE_STATE_Unattached)\r
+ EVENT_USB_Device_Disconnect();\r
+\r
+ if (USB_HostState != HOST_STATE_Unattached)\r
+ EVENT_USB_Host_DeviceUnattached();\r
+\r
+ USB_CurrentMode = USB_GetUSBModeFromUID();\r
+ USB_ResetInterface();\r
+\r
+ EVENT_USB_UIDChange();\r
+ }\r
+ #endif\r
+}\r
+\r
+#if defined(INTERRUPT_CONTROL_ENDPOINT) && defined(USB_CAN_BE_DEVICE)\r
+ISR(USB_COM_vect)\r
+{\r
+ uint8_t PrevSelectedEndpoint = Endpoint_GetCurrentEndpoint();\r
+\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+ USB_INT_Disable(USB_INT_RXSTPI);\r
+\r
+ GlobalInterruptEnable();\r
+\r
+ USB_Device_ProcessControlRequest();\r
+\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+ USB_INT_Enable(USB_INT_RXSTPI);\r
+ Endpoint_SelectEndpoint(PrevSelectedEndpoint);\r
+}\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Controller Interrupt definitions for the AVR32 UC3 microcontrollers.\r
+ *\r
+ * This file contains definitions required for the correct handling of low level USB service routine interrupts\r
+ * from the USB controller.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+#ifndef __USBINTERRUPT_UC3_H__\r
+#define __USBINTERRUPT_UC3_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* External Variables: */\r
+ extern volatile uint32_t USB_Endpoint_SelectedEndpoint;\r
+\r
+ /* Enums: */\r
+ enum USB_Interrupts_t\r
+ {\r
+ USB_INT_VBUSTI = 0,\r
+ #if (defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__))\r
+ USB_INT_IDTI = 1,\r
+ #endif\r
+ #if (defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__))\r
+ USB_INT_WAKEUPI = 2,\r
+ USB_INT_SUSPI = 3,\r
+ USB_INT_EORSTI = 4,\r
+ USB_INT_SOFI = 5,\r
+ USB_INT_RXSTPI = 6,\r
+ #endif\r
+ #if (defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__))\r
+ USB_INT_HSOFI = 7,\r
+ USB_INT_DCONNI = 8,\r
+ USB_INT_DDISCI = 9,\r
+ USB_INT_RSTI = 10,\r
+ USB_INT_BCERRI = 11,\r
+ USB_INT_VBERRI = 12,\r
+ #endif\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_INT_Enable(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ case USB_INT_VBUSTI:\r
+ AVR32_USBB.USBCON.vbuste = true;\r
+ break;\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ case USB_INT_IDTI:\r
+ AVR32_USBB.USBCON.idte = true;\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ case USB_INT_WAKEUPI:\r
+ AVR32_USBB.UDINTESET.wakeupes = true;\r
+ break;\r
+ case USB_INT_SUSPI:\r
+ AVR32_USBB.UDINTESET.suspes = true;\r
+ break;\r
+ case USB_INT_EORSTI:\r
+ AVR32_USBB.UDINTESET.eorstes = true;\r
+ break;\r
+ case USB_INT_SOFI:\r
+ AVR32_USBB.UDINTESET.sofes = true;\r
+ break;\r
+ case USB_INT_RXSTPI:\r
+ (&AVR32_USBB.UECON0SET)[USB_Endpoint_SelectedEndpoint].rxstpes = true;\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_HOST)\r
+ case USB_INT_HSOFI:\r
+ AVR32_USBB.UHINTESET.hsofies = true;\r
+ break;\r
+ case USB_INT_DCONNI:\r
+ AVR32_USBB.UHINTESET.dconnies = true;\r
+ break;\r
+ case USB_INT_DDISCI:\r
+ AVR32_USBB.UHINTESET.ddiscies = true;\r
+ break;\r
+ case USB_INT_RSTI:\r
+ AVR32_USBB.UHINTESET.rsties = true;\r
+ break;\r
+ case USB_INT_BCERRI:\r
+ AVR32_USBB.USBCON.bcerre = true;\r
+ break;\r
+ case USB_INT_VBERRI:\r
+ AVR32_USBB.USBCON.vberre = true;\r
+ break;\r
+ #endif\r
+ }\r
+ }\r
+\r
+ static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_INT_Disable(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ case USB_INT_VBUSTI:\r
+ AVR32_USBB.USBCON.vbuste = false;\r
+ break;\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ case USB_INT_IDTI:\r
+ AVR32_USBB.USBCON.idte = false;\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ case USB_INT_WAKEUPI:\r
+ AVR32_USBB.UDINTECLR.wakeupec = true;\r
+ break;\r
+ case USB_INT_SUSPI:\r
+ AVR32_USBB.UDINTECLR.suspec = true;\r
+ break;\r
+ case USB_INT_EORSTI:\r
+ AVR32_USBB.UDINTECLR.eorstec = true;\r
+ break;\r
+ case USB_INT_SOFI:\r
+ AVR32_USBB.UDINTECLR.sofec = true;\r
+ break;\r
+ case USB_INT_RXSTPI:\r
+ (&AVR32_USBB.UECON0CLR)[USB_Endpoint_SelectedEndpoint].rxstpec = true;\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_HOST)\r
+ case USB_INT_HSOFI:\r
+ AVR32_USBB.UHINTECLR.hsofiec = true;\r
+ break;\r
+ case USB_INT_DCONNI:\r
+ AVR32_USBB.UHINTECLR.dconniec = true;\r
+ break;\r
+ case USB_INT_DDISCI:\r
+ AVR32_USBB.UHINTECLR.ddisciec = true;\r
+ break;\r
+ case USB_INT_RSTI:\r
+ AVR32_USBB.UHINTECLR.rstiec = true;\r
+ break;\r
+ case USB_INT_BCERRI:\r
+ AVR32_USBB.USBCON.bcerre = false;\r
+ break;\r
+ case USB_INT_VBERRI:\r
+ AVR32_USBB.USBCON.vberre = false;\r
+ break;\r
+ #endif\r
+ }\r
+ }\r
+\r
+ static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_INT_Clear(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ case USB_INT_VBUSTI:\r
+ AVR32_USBB.USBSTACLR.vbustic = true;\r
+ (void)AVR32_USBB.USBSTACLR;\r
+ break;\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ case USB_INT_IDTI:\r
+ AVR32_USBB.USBSTACLR.idtic = true;\r
+ (void)AVR32_USBB.USBSTACLR;\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ case USB_INT_WAKEUPI:\r
+ AVR32_USBB.UDINTCLR.wakeupc = true;\r
+ (void)AVR32_USBB.UDINTCLR;\r
+ break;\r
+ case USB_INT_SUSPI:\r
+ AVR32_USBB.UDINTCLR.suspc = true;\r
+ (void)AVR32_USBB.UDINTCLR;\r
+ break;\r
+ case USB_INT_EORSTI:\r
+ AVR32_USBB.UDINTCLR.eorstc = true;\r
+ (void)AVR32_USBB.UDINTCLR;\r
+ break;\r
+ case USB_INT_SOFI:\r
+ AVR32_USBB.UDINTCLR.sofc = true;\r
+ (void)AVR32_USBB.UDINTCLR;\r
+ break;\r
+ case USB_INT_RXSTPI:\r
+ (&AVR32_USBB.UESTA0CLR)[USB_Endpoint_SelectedEndpoint].rxstpic = true;\r
+ break;\r
+ #endif\r
+ #if defined(USB_CAN_BE_HOST)\r
+ case USB_INT_HSOFI:\r
+ AVR32_USBB.UHINTCLR.hsofic = true;\r
+ (void)AVR32_USBB.UHINTCLR;\r
+ break;\r
+ case USB_INT_DCONNI:\r
+ AVR32_USBB.UHINTCLR.dconnic = true;\r
+ (void)AVR32_USBB.UHINTCLR;\r
+ break;\r
+ case USB_INT_DDISCI:\r
+ AVR32_USBB.UHINTCLR.ddiscic = true;\r
+ (void)AVR32_USBB.UHINTCLR;\r
+ break;\r
+ case USB_INT_RSTI:\r
+ AVR32_USBB.UHINTCLR.rstic = true;\r
+ (void)AVR32_USBB.UHINTCLR;\r
+ break;\r
+ case USB_INT_BCERRI:\r
+ AVR32_USBB.USBSTACLR.bcerric = true;\r
+ (void)AVR32_USBB.USBSTACLR;\r
+ break;\r
+ case USB_INT_VBERRI:\r
+ AVR32_USBB.USBSTACLR.vberric = true;\r
+ (void)AVR32_USBB.USBSTACLR;\r
+ break;\r
+ #endif\r
+ }\r
+ }\r
+\r
+ static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool USB_INT_IsEnabled(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ case USB_INT_VBUSTI:\r
+ return AVR32_USBB.USBCON.vbuste;\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ case USB_INT_IDTI:\r
+ return AVR32_USBB.USBCON.idte;\r
+ #endif\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ case USB_INT_WAKEUPI:\r
+ return AVR32_USBB.UDINTE.wakeupe;\r
+ case USB_INT_SUSPI:\r
+ return AVR32_USBB.UDINTE.suspe;\r
+ case USB_INT_EORSTI:\r
+ return AVR32_USBB.UDINTE.eorste;\r
+ case USB_INT_SOFI:\r
+ return AVR32_USBB.UDINTE.sofe;\r
+ case USB_INT_RXSTPI:\r
+ return (&AVR32_USBB.UECON0)[USB_Endpoint_SelectedEndpoint].rxstpe;\r
+ #endif\r
+ #if defined(USB_CAN_BE_HOST)\r
+ case USB_INT_HSOFI:\r
+ return AVR32_USBB.UHINTE.hsofie;\r
+ case USB_INT_DCONNI:\r
+ return AVR32_USBB.UHINTE.dconnie;\r
+ case USB_INT_DDISCI:\r
+ return AVR32_USBB.UHINTE.ddiscie;\r
+ case USB_INT_RSTI:\r
+ return AVR32_USBB.UHINTE.rstie;\r
+ case USB_INT_BCERRI:\r
+ return AVR32_USBB.USBCON.bcerre;\r
+ case USB_INT_VBERRI:\r
+ return AVR32_USBB.USBCON.vberre;\r
+ #endif\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool USB_INT_HasOccurred(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ case USB_INT_VBUSTI:\r
+ return AVR32_USBB.USBSTA.vbusti;\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ case USB_INT_IDTI:\r
+ return AVR32_USBB.USBSTA.idti;\r
+ #endif\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ case USB_INT_WAKEUPI:\r
+ return AVR32_USBB.UDINT.wakeup;\r
+ case USB_INT_SUSPI:\r
+ return AVR32_USBB.UDINT.susp;\r
+ case USB_INT_EORSTI:\r
+ return AVR32_USBB.UDINT.eorst;\r
+ case USB_INT_SOFI:\r
+ return AVR32_USBB.UDINT.sof;\r
+ case USB_INT_RXSTPI:\r
+ return (&AVR32_USBB.UESTA0)[USB_Endpoint_SelectedEndpoint].rxstpi;\r
+ #endif\r
+ #if defined(USB_CAN_BE_HOST)\r
+ case USB_INT_HSOFI:\r
+ return AVR32_USBB.UHINT.hsofi;\r
+ case USB_INT_DCONNI:\r
+ return AVR32_USBB.UHINT.dconni;\r
+ case USB_INT_DDISCI:\r
+ return AVR32_USBB.UHINT.ddisci;\r
+ case USB_INT_RSTI:\r
+ return AVR32_USBB.UHINT.rsti;\r
+ case USB_INT_BCERRI:\r
+ return AVR32_USBB.USBSTA.bcerri;\r
+ case USB_INT_VBERRI:\r
+ return AVR32_USBB.USBSTA.vberri;\r
+ #endif\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ /* Includes: */\r
+ #include "../USBMode.h"\r
+ #include "../Events.h"\r
+ #include "../USBController.h"\r
+\r
+ /* Function Prototypes: */\r
+ void USB_INT_ClearAllInterrupts(void);\r
+ void USB_INT_DisableAllInterrupts(void);\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Function Prototypes: */\r
+ #if defined(__DOXYGEN__)\r
+ /** Interrupt service routine handler for the USB controller ISR group. This interrupt routine <b>must</b> be\r
+ * linked to the entire USB controller ISR vector group inside the AVR32's interrupt controller peripheral,\r
+ * using the user application's preferred USB controller driver.\r
+ */\r
+ void USB_GEN_vect(void);\r
+ #else\r
+ ISR(USB_GEN_vect);\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Common USB Controller definitions for all architectures.\r
+ * \copydetails Group_USBManagement\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USB\r
+ * \defgroup Group_USBManagement USB Interface Management\r
+ * \brief USB Controller definitions for general USB controller management.\r
+ *\r
+ * Functions, macros, variables, enums and types related to the setup and management of the USB interface.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBCONTROLLER_H__\r
+#define __USBCONTROLLER_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks and Defines: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Defines: */\r
+ /** \name Endpoint Direction Masks */\r
+ //@{\r
+ /** Endpoint direction mask, for masking against endpoint addresses to retrieve the endpoint's\r
+ * direction for comparing with the \c ENDPOINT_DIR_* masks.\r
+ */\r
+ #define ENDPOINT_DIR_MASK 0x80\r
+\r
+ /** Endpoint address direction mask for an OUT direction (Host to Device) endpoint. This may be ORed with\r
+ * the index of the address within a device to obtain the full endpoint address.\r
+ */\r
+ #define ENDPOINT_DIR_OUT 0x00\r
+\r
+ /** Endpoint address direction mask for an IN direction (Device to Host) endpoint. This may be ORed with\r
+ * the index of the address within a device to obtain the full endpoint address.\r
+ */\r
+ #define ENDPOINT_DIR_IN 0x80\r
+ //@}\r
+\r
+ /** \name Pipe Direction Masks */\r
+ //@{\r
+ /** Pipe direction mask, for masking against pipe addresses to retrieve the pipe's\r
+ * direction for comparing with the \c PIPE_DIR_* masks.\r
+ */\r
+ #define PIPE_DIR_MASK 0x80\r
+\r
+ /** Endpoint address direction mask for an OUT direction (Host to Device) endpoint. This may be ORed with\r
+ * the index of the address within a device to obtain the full endpoint address.\r
+ */\r
+ #define PIPE_DIR_OUT 0x00\r
+\r
+ /** Endpoint address direction mask for an IN direction (Device to Host) endpoint. This may be ORed with\r
+ * the index of the address within a device to obtain the full endpoint address.\r
+ */\r
+ #define PIPE_DIR_IN 0x80\r
+ //@}\r
+\r
+ /** \name Endpoint/Pipe Type Masks */\r
+ //@{\r
+ /** Mask for determining the type of an endpoint from an endpoint descriptor. This should then be compared\r
+ * with the \c EP_TYPE_* masks to determine the exact type of the endpoint.\r
+ */\r
+ #define EP_TYPE_MASK 0x03\r
+\r
+ /** Mask for a CONTROL type endpoint or pipe.\r
+ *\r
+ * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_CONTROL 0x00\r
+\r
+ /** Mask for an ISOCHRONOUS type endpoint or pipe.\r
+ *\r
+ * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_ISOCHRONOUS 0x01\r
+\r
+ /** Mask for a BULK type endpoint or pipe.\r
+ *\r
+ * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_BULK 0x02\r
+\r
+ /** Mask for an INTERRUPT type endpoint or pipe.\r
+ *\r
+ * \note See \ref Group_EndpointManagement and \ref Group_PipeManagement for endpoint/pipe functions.\r
+ */\r
+ #define EP_TYPE_INTERRUPT 0x03\r
+ //@}\r
+\r
+ /* Architecture Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/USBController_AVR8.h"\r
+ #elif (ARCH == ARCH_UC3)\r
+ #include "UC3/USBController_UC3.h"\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ #include "XMEGA/USBController_XMEGA.h"\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB controller interrupt service routine management.\r
+ *\r
+ * This file contains definitions required for the correct handling of low level USB service routine interrupts\r
+ * from the USB controller.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+#ifndef __USBINTERRUPT_H__\r
+#define __USBINTERRUPT_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Architecture Includes: */\r
+ #if (ARCH == ARCH_AVR8)\r
+ #include "AVR8/USBInterrupt_AVR8.h"\r
+ #elif (ARCH == ARCH_UC3)\r
+ #include "UC3/USBInterrupt_UC3.h"\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ #include "XMEGA/USBInterrupt_XMEGA.h"\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB mode and feature support definitions.\r
+ * \copydetails Group_USBMode\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USB\r
+ * \defgroup Group_USBMode USB Mode Tokens\r
+ * \brief USB mode and feature support definitions.\r
+ *\r
+ * This file defines macros indicating the type of USB controller the library is being compiled for, and its\r
+ * capabilities. These macros may then be referenced in the user application to selectively enable or disable\r
+ * code sections depending on if they are defined or not.\r
+ *\r
+ * After the inclusion of the master USB driver header, one or more of the following tokens may be defined, to\r
+ * allow the user code to conditionally enable or disable code based on the USB controller family and allowable\r
+ * USB modes. These tokens may be tested against to eliminate code relating to a USB mode which is not enabled for\r
+ * the given compilation.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBMODE_H__\r
+#define __USBMODE_H__\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ #if defined(__DOXYGEN__)\r
+ /** Indicates that the target AVR microcontroller belongs to the Series 2 AVR8 USB controller\r
+ * (i.e. AT90USBxxx2 or ATMEGAxxU2) when defined.\r
+ */\r
+ #define USB_SERIES_2_AVR\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the Series 4 AVR8 USB controller\r
+ * (i.e. ATMEGAxxU4) when defined.\r
+ */\r
+ #define USB_SERIES_4_AVR\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the Series 6 AVR8 USB controller\r
+ * (i.e. AT90USBxxx6) when defined.\r
+ */\r
+ #define USB_SERIES_6_AVR\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the Series 7 AVR8 USB controller\r
+ * (i.e. AT90USBxxx7) when defined.\r
+ */\r
+ #define USB_SERIES_7_AVR\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A0 Series USB controller\r
+ * (i.e. AT32UC3A0*) when defined.\r
+ */\r
+ #define USB_SERIES_UC3A0_AVR\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A1 Series USB controller\r
+ * (i.e. AT32UC3A1*) when defined.\r
+ */\r
+ #define USB_SERIES_UC3A1_AVR\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A3 Series USB controller\r
+ * (i.e. AT32UC3A3*) when defined.\r
+ */\r
+ #define USB_SERIES_UC3A3_AVR\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A4 Series USB controller\r
+ * (i.e. AT32UC3A4*) when defined.\r
+ */\r
+ #define USB_SERIES_UC3A4_AVR\r
+ \r
+ /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B0 Series USB controller\r
+ * (i.e. AT32UC3B0*) when defined.\r
+ */\r
+ #define USB_SERIES_UC3B0_AVR\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B1 Series USB controller\r
+ * (i.e. AT32UC3B1*) when defined.\r
+ */\r
+ #define USB_SERIES_UC3B1_AVR\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the XMEGA A1U Series USB controller\r
+ * (i.e. ATXMEGA*A1U) when defined.\r
+ */\r
+ #define USB_SERIES_A1U_XMEGA\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the XMEGA A3U Series USB controller\r
+ * (i.e. ATXMEGA*A3U) when defined.\r
+ */\r
+ #define USB_SERIES_A3U_XMEGA\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the XMEGA A4U Series USB controller\r
+ * (i.e. ATXMEGA*A4U) when defined.\r
+ */\r
+ #define USB_SERIES_A4U_XMEGA\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the XMEGA B1 Series USB controller\r
+ * (i.e. ATXMEGA*B1) when defined.\r
+ */\r
+ #define USB_SERIES_B1_XMEGA\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the XMEGA B3 Series USB controller\r
+ * (i.e. ATXMEGA*B3) when defined.\r
+ */\r
+ #define USB_SERIES_B3_XMEGA\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the XMEGA C3 Series USB controller\r
+ * (i.e. ATXMEGA*C3) when defined.\r
+ */\r
+ #define USB_SERIES_C3_XMEGA\r
+\r
+ /** Indicates that the target AVR microcontroller belongs to the XMEGA C4 Series USB controller\r
+ * (i.e. ATXMEGA*C4) when defined.\r
+ */\r
+ #define USB_SERIES_C4_XMEGA\r
+\r
+ /** Indicates that the target microcontroller and compilation settings allow for the\r
+ * target to be configured in USB Device mode when defined.\r
+ */\r
+ #define USB_CAN_BE_DEVICE\r
+\r
+ /** Indicates that the target microcontroller and compilation settings allow for the\r
+ * target to be configured in USB Host mode when defined.\r
+ */\r
+ #define USB_CAN_BE_HOST\r
+\r
+ /** Indicates that the target microcontroller and compilation settings allow for the\r
+ * target to be configured in either USB Device or Host mode when defined.\r
+ */\r
+ #define USB_CAN_BE_BOTH\r
+ #else\r
+ /* Macros: */\r
+ #if (defined(__AVR_AT90USB162__) || defined(__AVR_AT90USB82__) || \\r
+ defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__))\r
+ #define USB_SERIES_2_AVR\r
+ #define USB_CAN_BE_DEVICE\r
+ #elif (defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__))\r
+ #define USB_SERIES_4_AVR\r
+ #define USB_CAN_BE_DEVICE\r
+ #elif (defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__))\r
+ #define USB_SERIES_6_AVR\r
+ #define USB_CAN_BE_DEVICE\r
+ #elif (defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__))\r
+ #define USB_SERIES_7_AVR\r
+ #define USB_CAN_BE_DEVICE\r
+ #define USB_CAN_BE_HOST\r
+ #elif (defined(__AVR32_UC3A0512__) || defined(__AVR32_UC3A0256__) || \\r
+ defined(__AVR32_UC3A0128__) || defined(__AVR32_UC3A064__))\r
+ #define USB_SERIES_UC3A0_AVR32\r
+ #define USB_CAN_BE_DEVICE\r
+ #define USB_CAN_BE_HOST\r
+ #elif (defined(__AVR32_UC3A1512__) || defined(__AVR32_UC3A1256__) || \\r
+ defined(__AVR32_UC3A1128__) || defined(__AVR32_UC3A164__))\r
+ #define USB_SERIES_UC3A1_AVR32\r
+ #define USB_CAN_BE_DEVICE\r
+ #define USB_CAN_BE_HOST\r
+ #elif (defined(__AVR32_UC3A3256__) || defined(__AVR32_UC3A3256S__) || \\r
+ defined(__AVR32_UC3A3128__) || defined(__AVR32_UC3A3128S__) || \\r
+ defined(__AVR32_UC3A364__) || defined(__AVR32_UC3A364S__))\r
+ #define USB_SERIES_UC3A3_AVR32\r
+ #define USB_CAN_BE_DEVICE\r
+ #define USB_CAN_BE_HOST\r
+ #elif (defined(__AVR32_UC3A4256__) || defined(__AVR32_UC3A4256S__) || \\r
+ defined(__AVR32_UC3A4128__) || defined(__AVR32_UC3A4128S__) || \\r
+ defined(__AVR32_UC3A464__) || defined(__AVR32_UC3A464S__))\r
+ #define USB_SERIES_UC3A4_AVR32\r
+ #define USB_CAN_BE_DEVICE\r
+ #define USB_CAN_BE_HOST\r
+ #elif (defined(__AVR32_UC3B0512__) || defined(__AVR32_UC3B0256__) || \\r
+ defined(__AVR32_UC3B0128__) || defined(__AVR32_UC3B064__))\r
+ #define USB_SERIES_UC3B0_AVR32\r
+ #define USB_CAN_BE_DEVICE\r
+ #define USB_CAN_BE_HOST\r
+ #elif (defined(__AVR32_UC3B1512__) || defined(__AVR32_UC3B1256__) || \\r
+ defined(__AVR32_UC3B1128__) || defined(__AVR32_UC3B164__))\r
+ #define USB_SERIES_UC3B1_AVR32\r
+ #define USB_CAN_BE_DEVICE\r
+ #define USB_CAN_BE_HOST\r
+ #elif (defined(__AVR_ATxmega128A1U__) || defined(__AVR_ATxmega64A1U__))\r
+ #define USB_SERIES_A1U_XMEGA\r
+ #define USB_CAN_BE_DEVICE\r
+ #elif (defined(__AVR_ATxmega64A3U__) || defined(__AVR_ATxmega128A3U__) || \\r
+ defined(__AVR_ATxmega192A3U__) || defined(__AVR_ATxmega256A3U__))\r
+ #define USB_SERIES_A3U_XMEGA\r
+ #define USB_CAN_BE_DEVICE\r
+ #elif (defined(__AVR_ATxmega256A3BU__))\r
+ #define USB_SERIES_A3BU_XMEGA\r
+ #define USB_CAN_BE_DEVICE\r
+ #elif (defined(__AVR_ATxmega16A4U__) || defined(__AVR_ATxmega32A4U__) || \\r
+ defined(__AVR_ATxmega64A4U__) || defined(__AVR_ATxmega128A4U__))\r
+ #define USB_SERIES_A4U_XMEGA\r
+ #define USB_CAN_BE_DEVICE\r
+ #elif (defined(__AVR_ATxmega128B1__) || defined(__AVR_ATxmega64B1__))\r
+ #define USB_SERIES_B1_XMEGA\r
+ #define USB_CAN_BE_DEVICE\r
+ #elif (defined(__AVR_ATxmega128B3__) || defined(__AVR_ATxmega64B3__))\r
+ #define USB_SERIES_B3_XMEGA\r
+ #define USB_CAN_BE_DEVICE\r
+ #elif (defined(__AVR_ATxmega128C3__) || defined(__AVR_ATxmega64C3__) || \\r
+ defined(__AVR_ATxmega192C3__) || defined(__AVR_ATxmega256C3__) || \\r
+ defined(__AVR_ATxmega384C3__))\r
+ #define USB_SERIES_C3_XMEGA\r
+ #define USB_CAN_BE_DEVICE\r
+ #elif (defined(__AVR_ATxmega16C4__) || defined(__AVR_ATxmega32C4__))\r
+ #define USB_SERIES_C4_XMEGA\r
+ #define USB_CAN_BE_DEVICE\r
+ #endif\r
+\r
+ #if (defined(USB_CAN_BE_DEVICE) && defined(USB_CAN_BE_HOST))\r
+ #define USB_CAN_BE_BOTH\r
+ #endif\r
+\r
+ #if defined(USB_HOST_ONLY)\r
+ #if !defined(USB_CAN_BE_HOST)\r
+ #error USB_HOST_ONLY is not available for the currently selected microcontroller model.\r
+ #else\r
+ #undef USB_CAN_BE_DEVICE\r
+ #undef USB_CAN_BE_BOTH\r
+ #endif\r
+ #endif\r
+\r
+ #if defined(USB_DEVICE_ONLY)\r
+ #if !defined(USB_CAN_BE_DEVICE)\r
+ #error USB_DEVICE_ONLY is not available for the currently selected microcontroller model.\r
+ #else\r
+ #undef USB_CAN_BE_HOST\r
+ #undef USB_CAN_BE_BOTH\r
+ #endif\r
+ #endif\r
+\r
+ #if (defined(USB_HOST_ONLY) && defined(USB_DEVICE_ONLY))\r
+ #error USB_HOST_ONLY and USB_DEVICE_ONLY are mutually exclusive.\r
+ #endif\r
+\r
+ #if (!defined(USB_CAN_BE_DEVICE) && !defined(USB_CAN_BE_HOST))\r
+ #error The currently selected device or architecture is not supported under the USB component of the library.\r
+ #endif\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USBTASK_C\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "USBTask.h"\r
+\r
+volatile bool USB_IsInitialized;\r
+USB_Request_Header_t USB_ControlRequest;\r
+\r
+#if defined(USB_CAN_BE_HOST) && !defined(HOST_STATE_AS_GPIOR)\r
+volatile uint8_t USB_HostState;\r
+#endif\r
+\r
+#if defined(USB_CAN_BE_DEVICE) && !defined(DEVICE_STATE_AS_GPIOR)\r
+volatile uint8_t USB_DeviceState;\r
+#endif\r
+\r
+void USB_USBTask(void)\r
+{\r
+ #if defined(USB_HOST_ONLY)\r
+ USB_HostTask();\r
+ #elif defined(USB_DEVICE_ONLY)\r
+ USB_DeviceTask();\r
+ #else\r
+ if (USB_CurrentMode == USB_MODE_Device)\r
+ USB_DeviceTask();\r
+ #if defined(USB_CAN_BE_HOST)\r
+ else if (USB_CurrentMode == USB_MODE_Host)\r
+ USB_HostTask();\r
+ #endif\r
+ #endif\r
+}\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+static void USB_DeviceTask(void)\r
+{\r
+ if (USB_DeviceState != DEVICE_STATE_Unattached)\r
+ {\r
+ uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint();\r
+\r
+ Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);\r
+\r
+ if (Endpoint_IsSETUPReceived())\r
+ USB_Device_ProcessControlRequest();\r
+\r
+ Endpoint_SelectEndpoint(PrevEndpoint);\r
+ }\r
+}\r
+#endif\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+static void USB_HostTask(void)\r
+{\r
+ uint8_t PrevPipe = Pipe_GetCurrentPipe();\r
+\r
+ Pipe_SelectPipe(PIPE_CONTROLPIPE);\r
+\r
+ USB_Host_ProcessNextHostState();\r
+\r
+ Pipe_SelectPipe(PrevPipe);\r
+}\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Main USB service task management.\r
+ *\r
+ * This file contains the function definitions required for the main USB service task, which must be called\r
+ * from the user application to ensure that the USB connection to or from a connected USB device is maintained.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+#ifndef __USBTASK_H__\r
+#define __USBTASK_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../Common/Common.h"\r
+ #include "USBMode.h"\r
+ #include "USBController.h"\r
+ #include "Events.h"\r
+ #include "StdRequestType.h"\r
+ #include "StdDescriptors.h"\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ #include "DeviceStandardReq.h"\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_HOST)\r
+ #include "HostStandardReq.h"\r
+ #endif\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Global Variables: */\r
+ /** Indicates if the USB interface is currently initialized but not necessarily connected to a host\r
+ * or device (i.e. if \ref USB_Init() has been run). If this is false, all other library globals related\r
+ * to the USB driver are invalid.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ *\r
+ * \ingroup Group_USBManagement\r
+ */\r
+ extern volatile bool USB_IsInitialized;\r
+\r
+ /** Structure containing the last received Control request when in Device mode (for use in user-applications\r
+ * inside of the \ref EVENT_USB_Device_ControlRequest() event, or for filling up with a control request to\r
+ * issue when in Host mode before calling \ref USB_Host_SendControlRequest().\r
+ *\r
+ * \note The contents of this structure is automatically endian-corrected for the current CPU architecture.\r
+ *\r
+ * \ingroup Group_USBManagement\r
+ */\r
+ extern USB_Request_Header_t USB_ControlRequest;\r
+\r
+ #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)\r
+ #if !defined(HOST_STATE_AS_GPIOR) || defined(__DOXYGEN__)\r
+ /** Indicates the current host state machine state. When in host mode, this indicates the state\r
+ * via one of the values of the \ref USB_Host_States_t enum values.\r
+ *\r
+ * This value should not be altered by the user application as it is handled automatically by the\r
+ * library.\r
+ *\r
+ * To reduce program size and speed up checks of this global on the AVR8 architecture, it can be\r
+ * placed into one of the AVR's \c GPIOR hardware registers instead of RAM by defining the\r
+ * \c HOST_STATE_AS_GPIOR token to a value between 0 and 2 in the project makefile and passing it to\r
+ * the compiler via the -D switch. When defined, the corresponding GPIOR register should not be used\r
+ * in the user application except implicitly via the library APIs.\r
+ *\r
+ * \note This global is only present if the user application can be a USB host.\r
+ *\r
+ * \see \ref USB_Host_States_t for a list of possible device states.\r
+ *\r
+ * \ingroup Group_Host\r
+ */\r
+ extern volatile uint8_t USB_HostState;\r
+ #else\r
+ #define _GET_HOST_GPIOR_NAME2(y) GPIOR ## y\r
+ #define _GET_HOST_GPIOR_NAME(x) _GET_HOST_GPIOR_NAME2(x)\r
+ #define USB_HostState _GET_HOST_GPIOR_NAME(HOST_STATE_AS_GPIOR)\r
+ #endif\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
+ #if !defined(DEVICE_STATE_AS_GPIOR) || defined(__DOXYGEN__)\r
+ /** Indicates the current device state machine state. When in device mode, this indicates the state\r
+ * via one of the values of the \ref USB_Device_States_t enum values.\r
+ *\r
+ * This value should not be altered by the user application as it is handled automatically by the\r
+ * library. The only exception to this rule is if the NO_LIMITED_CONTROLLER_CONNECT token is used\r
+ * (see \ref EVENT_USB_Device_Connect() and \ref EVENT_USB_Device_Disconnect() events).\r
+ *\r
+ * To reduce program size and speed up checks of this global on the AVR8 architecture, it can be\r
+ * placed into one of the AVR's \c GPIOR hardware registers instead of RAM by defining the\r
+ * \c DEVICE_STATE_AS_GPIOR token to a value between 0 and 2 in the project makefile and passing it to\r
+ * the compiler via the -D switch. When defined, the corresponding GPIOR register should not be used\r
+ * in the user application except implicitly via the library APIs.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value except in the circumstances outlined above.\r
+ *\r
+ * \note This global is only present if the user application can be a USB device.\r
+ * \n\n\r
+ *\r
+ * \see \ref USB_Device_States_t for a list of possible device states.\r
+ *\r
+ * \ingroup Group_Device\r
+ */\r
+ extern volatile uint8_t USB_DeviceState;\r
+ #else\r
+ #define _GET_DEVICE_GPIOR_NAME2(y) GPIOR ## y\r
+ #define _GET_DEVICE_GPIOR_NAME(x) _GET_DEVICE_GPIOR_NAME2(x)\r
+ #define USB_DeviceState _GET_DEVICE_GPIOR_NAME(DEVICE_STATE_AS_GPIOR)\r
+ #endif\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ /** This is the main USB management task. The USB driver requires this task to be executed\r
+ * continuously when the USB system is active (device attached in host mode, or attached to a host\r
+ * in device mode) in order to manage USB communications. This task may be executed inside an RTOS,\r
+ * fast timer ISR or the main user application loop.\r
+ *\r
+ * The USB task must be serviced within 30ms while in device mode, or within 1ms while in host mode.\r
+ * The task may be serviced at all times, or (for minimum CPU consumption):\r
+ *\r
+ * - In device mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Device_Connect()\r
+ * event and disabled again on the firing of the \ref EVENT_USB_Device_Disconnect() event.\r
+ *\r
+ * - In host mode, it may be disabled at start-up, enabled on the firing of the \ref EVENT_USB_Host_DeviceAttached()\r
+ * event and disabled again on the firing of the \ref EVENT_USB_Host_DeviceEnumerationComplete() or\r
+ * \ref EVENT_USB_Host_DeviceEnumerationFailed() events.\r
+ *\r
+ * If in device mode (only), the control endpoint can instead be managed via interrupts entirely by the library\r
+ * by defining the INTERRUPT_CONTROL_ENDPOINT token and passing it to the compiler via the -D switch.\r
+ *\r
+ * \see \ref Group_Events for more information on the USB events.\r
+ *\r
+ * \ingroup Group_USBManagement\r
+ */\r
+ void USB_USBTask(void);\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_USBTASK_C)\r
+ #if defined(USB_CAN_BE_HOST)\r
+ static void USB_HostTask(void);\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE)\r
+ static void USB_DeviceTask(void);\r
+ #endif\r
+ #endif\r
+\r
+ /* Macros: */\r
+ #define HOST_TASK_NONBLOCK_WAIT(Duration, NextState) MACROS{ USB_HostState = HOST_STATE_WaitForDevice; \\r
+ WaitMSRemaining = (Duration); \\r
+ PostWaitState = (NextState); }MACROE\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_XMEGA)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#include "../Device.h"\r
+\r
+void USB_Device_SendRemoteWakeup(void)\r
+{\r
+ USB.CTRLB |= USB_RWAKEUP_bm;\r
+}\r
+\r
+#endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Device definitions for the AVR XMEGA microcontrollers.\r
+ * \copydetails Group_Device_XMEGA\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_Device\r
+ * \defgroup Group_Device_XMEGA Device Management (XMEGA)\r
+ * \brief USB Device definitions for the AVR XMEGA microcontrollers.\r
+ *\r
+ * Architecture specific USB Device definitions for the Atmel AVR XMEGA microcontrollers.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBDEVICE_XMEGA_H__\r
+#define __USBDEVICE_XMEGA_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBController.h"\r
+ #include "../StdDescriptors.h"\r
+ #include "../USBInterrupt.h"\r
+ #include "../Endpoint.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ #if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))\r
+ #error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.\r
+ #endif\r
+\r
+ #if (defined(USE_FLASH_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))\r
+ #error USE_FLASH_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.\r
+ #endif\r
+\r
+ #if (defined(USE_FLASH_DESCRIPTORS) && defined(USE_RAM_DESCRIPTORS))\r
+ #error USE_FLASH_DESCRIPTORS and USE_RAM_DESCRIPTORS are mutually exclusive.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name USB Device Mode Option Masks */\r
+ //@{\r
+ /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the\r
+ * USB interface should be initialized in low speed (1.5Mb/s) mode.\r
+ *\r
+ * \note Low Speed mode is not available on all USB AVR models.\r
+ * \n\r
+ *\r
+ * \note Restrictions apply on the number, size and type of endpoints which can be used\r
+ * when running in low speed mode - refer to the USB 2.0 specification.\r
+ */\r
+ #define USB_DEVICE_OPT_LOWSPEED (1 << 0)\r
+\r
+ #if (F_USB > 6000000)\r
+ /** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the\r
+ * USB interface should be initialized in full speed (12Mb/s) mode.\r
+ */\r
+ #define USB_DEVICE_OPT_FULLSPEED (0 << 0)\r
+ #endif\r
+ //@}\r
+\r
+ #if (!defined(NO_INTERNAL_SERIAL) || defined(__DOXYGEN__))\r
+ /** String descriptor index for the device's unique serial number string descriptor within the device.\r
+ * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port\r
+ * number allocations) to a device regardless of the port it is plugged in to on the host. Some microcontrollers contain\r
+ * a unique serial number internally, and setting the device descriptors serial number string index to this value\r
+ * will cause it to use the internal serial number.\r
+ *\r
+ * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial\r
+ * number for the device.\r
+ */\r
+ #define USE_INTERNAL_SERIAL 0xDC\r
+\r
+ /** Length of the device's unique internal serial number, in bits, if present on the selected microcontroller\r
+ * model.\r
+ */\r
+ #define INTERNAL_SERIAL_LENGTH_BITS (8 * (1 + (offsetof(NVM_PROD_SIGNATURES_t, COORDY1) - offsetof(NVM_PROD_SIGNATURES_t, LOTNUM0))))\r
+\r
+ /** Start address of the internal serial number, in the appropriate address space, if present on the selected microcontroller\r
+ * model.\r
+ */\r
+ #define INTERNAL_SERIAL_START_ADDRESS offsetof(NVM_PROD_SIGNATURES_t, LOTNUM0)\r
+ #else\r
+ #define USE_INTERNAL_SERIAL NO_DESCRIPTOR\r
+\r
+ #define INTERNAL_SERIAL_LENGTH_BITS 0\r
+ #define INTERNAL_SERIAL_START_ADDRESS 0\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ /** Sends a Remote Wakeup request to the host. This signals to the host that the device should\r
+ * be taken out of suspended mode, and communications should resume.\r
+ *\r
+ * Typically, this is implemented so that HID devices (mice, keyboards, etc.) can wake up the\r
+ * host computer when the host has suspended all USB devices to enter a low power state.\r
+ *\r
+ * \note This function should only be used if the device has indicated to the host that it\r
+ * supports the Remote Wakeup feature in the device descriptors, and should only be\r
+ * issued if the host is currently allowing remote wakeup events from the device (i.e.,\r
+ * the \ref USB_Device_RemoteWakeupEnabled flag is set). When the \c NO_DEVICE_REMOTE_WAKEUP\r
+ * compile time option is used, this function is unavailable.\r
+ * \n\n\r
+ *\r
+ * \note The USB clock must be running for this function to operate. If the stack is initialized with\r
+ * the \ref USB_OPT_MANUAL_PLL option enabled, the user must ensure that the PLL is running\r
+ * before attempting to call this function.\r
+ *\r
+ * \see \ref Group_StdDescriptors for more information on the RMWAKEUP feature and device descriptors.\r
+ */\r
+ void USB_Device_SendRemoteWakeup(void);\r
+\r
+ /* Inline Functions: */\r
+ /** Returns the current USB frame number, when in device mode. Every millisecond the USB bus is active (i.e. enumerated to a host)\r
+ * the frame number is incremented by one.\r
+ *\r
+ * \return Current USB frame number from the USB controller.\r
+ */\r
+ static inline uint16_t USB_Device_GetFrameNumber(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline uint16_t USB_Device_GetFrameNumber(void)\r
+ {\r
+ return ((USB_EndpointTable_t*)USB.EPPTR)->FrameNum;\r
+ }\r
+\r
+ #if !defined(NO_SOF_EVENTS)\r
+ /** Enables the device mode Start Of Frame events. When enabled, this causes the\r
+ * \ref EVENT_USB_Device_StartOfFrame() event to fire once per millisecond, synchronized to the USB bus,\r
+ * at the start of each USB frame when enumerated in device mode.\r
+ *\r
+ * \note This function is not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Device_EnableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_EnableSOFEvents(void)\r
+ {\r
+ USB.INTCTRLA |= USB_SOFIE_bm;\r
+ }\r
+\r
+ /** Disables the device mode Start Of Frame events. When disabled, this stops the firing of the\r
+ * \ref EVENT_USB_Device_StartOfFrame() event when enumerated in device mode.\r
+ *\r
+ * \note This function is not available when the \c NO_SOF_EVENTS compile time token is defined.\r
+ */\r
+ static inline void USB_Device_DisableSOFEvents(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_DisableSOFEvents(void)\r
+ {\r
+ USB.INTCTRLA &= ~USB_SOFIE_bm;\r
+ }\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Inline Functions: */\r
+ static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetLowSpeed(void)\r
+ {\r
+ USB.CTRLA &= ~USB_SPEED_bm;\r
+ }\r
+\r
+ static inline void USB_Device_SetFullSpeed(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetFullSpeed(void)\r
+ {\r
+ USB.CTRLA |= USB_SPEED_bm;\r
+ }\r
+\r
+ static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Device_SetDeviceAddress(const uint8_t Address)\r
+ {\r
+ USB.ADDR = Address;\r
+ }\r
+\r
+ static inline bool USB_Device_IsAddressSet(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool USB_Device_IsAddressSet(void)\r
+ {\r
+ return ((USB.ADDR != 0) ? true : false);\r
+ }\r
+\r
+ static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString) ATTR_NON_NULL_PTR_ARG(1);\r
+ static inline void USB_Device_GetSerialString(uint16_t* const UnicodeString)\r
+ {\r
+ uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+ GlobalInterruptDisable();\r
+\r
+ uint8_t SigReadAddress = INTERNAL_SERIAL_START_ADDRESS;\r
+\r
+ for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)\r
+ {\r
+ uint8_t SerialByte;\r
+\r
+ NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc;\r
+ SerialByte = pgm_read_byte(SigReadAddress);\r
+ NVM.CMD = 0;\r
+\r
+ if (SerialCharNum & 0x01)\r
+ {\r
+ SerialByte >>= 4;\r
+ SigReadAddress++;\r
+ }\r
+\r
+ SerialByte &= 0x0F;\r
+\r
+ UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?\r
+ (('A' - 10) + SerialByte) : ('0' + SerialByte));\r
+ }\r
+\r
+ SetGlobalInterruptMask(CurrentGlobalInt);\r
+ }\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_XMEGA)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#include "EndpointStream_XMEGA.h"\r
+\r
+#if !defined(CONTROL_ONLY_DEVICE)\r
+uint8_t Endpoint_Discard_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t ErrorCode;\r
+ uint16_t BytesInTransfer = 0;\r
+ \r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ \r
+ if (BytesProcessed != NULL)\r
+ Length -= *BytesProcessed;\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ {\r
+ Endpoint_ClearOUT();\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return ENDPOINT_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ Endpoint_Discard_8();\r
+\r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+ \r
+ return ENDPOINT_RWSTREAM_NoError;\r
+}\r
+\r
+uint8_t Endpoint_Null_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t ErrorCode;\r
+ uint16_t BytesInTransfer = 0;\r
+ \r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ \r
+ if (BytesProcessed != NULL)\r
+ Length -= *BytesProcessed;\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ {\r
+ Endpoint_ClearIN();\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return ENDPOINT_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ Endpoint_Write_8(0);\r
+\r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+ \r
+ return ENDPOINT_RWSTREAM_NoError;\r
+}\r
+\r
+/* The following abuses the C preprocessor in order to copy-paste common code with slight alterations,\r
+ * so that the code needs to be written once. It is a crude form of templating to reduce code maintenance. */\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_LE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)\r
+#include "Template/Template_Endpoint_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Write_Stream_BE\r
+#define TEMPLATE_BUFFER_TYPE const void*\r
+#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)\r
+#include "Template/Template_Endpoint_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_LE\r
+#define TEMPLATE_BUFFER_TYPE void*\r
+#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()\r
+#include "Template/Template_Endpoint_RW.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Read_Stream_BE\r
+#define TEMPLATE_BUFFER_TYPE void*\r
+#define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()\r
+#include "Template/Template_Endpoint_RW.c"\r
+\r
+#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_LE\r
+ #define TEMPLATE_BUFFER_TYPE const void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_RW.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_PStream_BE\r
+ #define TEMPLATE_BUFFER_TYPE const void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_RW.c"\r
+#endif\r
+\r
+#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_LE\r
+ #define TEMPLATE_BUFFER_TYPE const void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_RW.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_EStream_BE\r
+ #define TEMPLATE_BUFFER_TYPE const void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearIN()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_RW.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_LE\r
+ #define TEMPLATE_BUFFER_TYPE void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())\r
+ #include "Template/Template_Endpoint_RW.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Read_EStream_BE\r
+ #define TEMPLATE_BUFFER_TYPE void*\r
+ #define TEMPLATE_CLEAR_ENDPOINT() Endpoint_ClearOUT()\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())\r
+ #include "Template/Template_Endpoint_RW.c"\r
+#endif\r
+\r
+#endif\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_LE\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)\r
+#include "Template/Template_Endpoint_Control_W.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Write_Control_Stream_BE\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(*BufferPtr)\r
+#include "Template/Template_Endpoint_Control_W.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_LE\r
+#define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()\r
+#include "Template/Template_Endpoint_Control_R.c"\r
+\r
+#define TEMPLATE_FUNC_NAME Endpoint_Read_Control_Stream_BE\r
+#define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+#define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+#define TEMPLATE_TRANSFER_BYTE(BufferPtr) *BufferPtr = Endpoint_Read_8()\r
+#include "Template/Template_Endpoint_Control_R.c"\r
+\r
+#if defined(ARCH_HAS_FLASH_ADDRESS_SPACE)\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_LE\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_Control_W.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_PStream_BE\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(pgm_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_Control_W.c"\r
+#endif\r
+\r
+#if defined(ARCH_HAS_EEPROM_ADDRESS_SPACE)\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_LE\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_Control_W.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Write_Control_EStream_BE\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) Endpoint_Write_8(eeprom_read_byte(BufferPtr))\r
+ #include "Template/Template_Endpoint_Control_W.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_LE\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) 0\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr += Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())\r
+ #include "Template/Template_Endpoint_Control_R.c"\r
+\r
+ #define TEMPLATE_FUNC_NAME Endpoint_Read_Control_EStream_BE\r
+ #define TEMPLATE_BUFFER_OFFSET(Length) (Length - 1)\r
+ #define TEMPLATE_BUFFER_MOVE(BufferPtr, Amount) BufferPtr -= Amount\r
+ #define TEMPLATE_TRANSFER_BYTE(BufferPtr) eeprom_update_byte(BufferPtr, Endpoint_Read_8())\r
+ #include "Template/Template_Endpoint_Control_R.c"\r
+#endif\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+ \r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this \r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in \r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting \r
+ documentation, and that the name of the author not be used in \r
+ advertising or publicity pertaining to distribution of the \r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Endpoint data stream transmission and reception management for the AVR XMEGA microcontrollers.\r
+ * \copydetails Group_EndpointStreamRW_XMEGA\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_EndpointStreamRW\r
+ * \defgroup Group_EndpointStreamRW_XMEGA Read/Write of Multi-Byte Streams (XMEGA)\r
+ * \brief Endpoint data stream transmission and reception management for the Atmel AVR XMEGA architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of data streams from\r
+ * and to endpoints.\r
+ *\r
+ * @{\r
+ */ \r
+\r
+#ifndef __ENDPOINT_STREAM_XMEGA_H__\r
+#define __ENDPOINT_STREAM_XMEGA_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBMode.h" \r
+ #include "../USBTask.h"\r
+ \r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Function Prototypes: */\r
+ /** \name Stream functions for null data */\r
+ //@{\r
+\r
+ /** Reads and discards the given number of bytes from the currently selected endpoint's bank,\r
+ * discarding fully read packets from the host as needed. The last packet is not automatically\r
+ * discarded once the remaining bytes has been read; the user is responsible for manually\r
+ * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the endpoint bank becomes empty while there is still data to process (and after the current\r
+ * packet has been acknowledged) the BytesProcessed location will be updated with the total number\r
+ * of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Endpoint_Discard_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Endpoint_Discard_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[in] Length Number of bytes to discard via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Discard_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed);\r
+\r
+ /** Writes a given number of zeroed bytes to the currently selected endpoint's bank, sending\r
+ * full packets to the host as needed. The last packet is not automatically sent once the \r
+ * remaining bytes have been written; the user is responsible for manually sending the last\r
+ * packet to the host via the \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the endpoint bank becomes full while there is still data to process (and after the current\r
+ * packet transmission has been initiated) the BytesProcessed location will be updated with the\r
+ * total number of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Endpoint_Null_Stream(512, NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Endpoint_Null_Stream(512, &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[in] Length Number of zero bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Null_Stream(uint16_t Length,\r
+ uint16_t* const BytesProcessed);\r
+\r
+ //@}\r
+\r
+ /** \name Stream functions for RAM source/destination data */\r
+ //@{\r
+ \r
+ /** Writes the given number of bytes to the endpoint from the given buffer in little endian,\r
+ * sending full packets to the host as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the endpoint bank becomes full while there is still data to process (and after the current\r
+ * packet transmission has been initiated) the BytesProcessed location will be updated with the\r
+ * total number of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),\r
+ * NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Endpoint_Write_Stream_LE(DataStream, sizeof(DataStream),\r
+ * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Stream_LE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the endpoint from the given buffer in big endian,\r
+ * sending full packets to the host as needed. The last packet filled is not automatically sent;\r
+ * the user is responsible for manually sending the last written packet to the host via the\r
+ * \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Stream_BE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+ \r
+ /** Reads the given number of bytes from the endpoint from the given buffer in little endian,\r
+ * discarding fully read packets from the host as needed. The last packet is not automatically\r
+ * discarded once the remaining bytes has been read; the user is responsible for manually\r
+ * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * If the BytesProcessed parameter is \c NULL, the entire stream transfer is attempted at once,\r
+ * failing or succeeding as a single unit. If the BytesProcessed parameter points to a valid\r
+ * storage location, the transfer will instead be performed as a series of chunks. Each time\r
+ * the endpoint bank becomes empty while there is still data to process (and after the current\r
+ * packet has been acknowledged) the BytesProcessed location will be updated with the total number\r
+ * of bytes processed in the stream, and the function will exit with an error code of\r
+ * \ref ENDPOINT_RWSTREAM_IncompleteTransfer. This allows for any abort checking to be performed\r
+ * in the user code - to continue the transfer, call the function again with identical parameters\r
+ * and it will resume until the BytesProcessed value reaches the total transfer length.\r
+ *\r
+ * <b>Single Stream Transfer Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * \r
+ * if ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),\r
+ * NULL)) != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * <b>Partial Stream Transfers Example:</b>\r
+ * \code\r
+ * uint8_t DataStream[512];\r
+ * uint8_t ErrorCode;\r
+ * uint16_t BytesProcessed;\r
+ * \r
+ * BytesProcessed = 0;\r
+ * while ((ErrorCode = Endpoint_Read_Stream_LE(DataStream, sizeof(DataStream),\r
+ * &BytesProcessed)) == ENDPOINT_RWSTREAM_IncompleteTransfer)\r
+ * {\r
+ * // Stream not yet complete - do other actions here, abort if required\r
+ * }\r
+ * \r
+ * if (ErrorCode != ENDPOINT_RWSTREAM_NoError)\r
+ * {\r
+ * // Stream failed to complete - check ErrorCode here\r
+ * }\r
+ * \endcode\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Stream_LE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the endpoint from the given buffer in big endian,\r
+ * discarding fully read packets from the host as needed. The last packet is not automatically\r
+ * discarded once the remaining bytes has been read; the user is responsible for manually\r
+ * discarding the last packet from the host via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * \note This routine should not be used on CONTROL type endpoints.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Stream_BE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in little endian,\r
+ * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared\r
+ * in both failure and success states; the user is responsible for manually clearing the status OUT packet\r
+ * to finalize the transfer's status stage via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_Stream_LE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Writes the given number of bytes to the CONTROL type endpoint from the given buffer in big endian,\r
+ * sending full packets to the host as needed. The host OUT acknowledgement is not automatically cleared\r
+ * in both failure and success states; the user is responsible for manually clearing the status OUT packet\r
+ * to finalize the transfer's status stage via the \ref Endpoint_ClearOUT() macro.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_Stream_BE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in little endian,\r
+ * discarding fully read packets from the host as needed. The device IN acknowledgement is not\r
+ * automatically sent after success or failure states; the user is responsible for manually sending the\r
+ * status IN packet to finalize the transfer's status stage via the \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Control_Stream_LE(void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** Reads the given number of bytes from the CONTROL endpoint from the given buffer in big endian,\r
+ * discarding fully read packets from the host as needed. The device IN acknowledgement is not\r
+ * automatically sent after success or failure states; the user is responsible for manually sending the\r
+ * status IN packet to finalize the transfer's status stage via the \ref Endpoint_ClearIN() macro.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Control_Stream_BE(void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+ //@}\r
+\r
+ /** \name Stream functions for EEPROM source/destination data */\r
+ //@{\r
+\r
+ /** EEPROM buffer source version of \ref Endpoint_Write_Stream_LE().\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_EStream_LE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer source version of \ref Endpoint_Write_Stream_BE().\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_EStream_BE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer destination version of \ref Endpoint_Read_Stream_LE().\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_EStream_LE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer destination version of \ref Endpoint_Read_Stream_BE().\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to, located in EEPROM memory space.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be read at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_EStream_BE(void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer source version of Endpoint_Write_Control_Stream_LE.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ * \n\n\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_EStream_LE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer source version of \ref Endpoint_Write_Control_Stream_BE().\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ * \n\n\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_EStream_BE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_LE().\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ * \n\n\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Control_EStream_LE(void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** EEPROM buffer source version of \ref Endpoint_Read_Control_Stream_BE().\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ * \n\n\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[out] Buffer Pointer to the destination data buffer to write to.\r
+ * \param[in] Length Number of bytes to send via the currently selected endpoint.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Read_Control_EStream_BE(void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+ //@}\r
+\r
+ /** \name Stream functions for PROGMEM source/destination data */\r
+ //@{\r
+\r
+ /** FLASH buffer source version of \ref Endpoint_Write_Stream_LE().\r
+ *\r
+ * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_PStream_LE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** FLASH buffer source version of \ref Endpoint_Write_Stream_BE().\r
+ *\r
+ * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ * \param[in] BytesProcessed Pointer to a location where the total number of bytes processed in the current\r
+ * transaction should be updated, \c NULL if the entire stream should be written at once.\r
+ *\r
+ * \return A value from the \ref Endpoint_Stream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_PStream_BE(const void* const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_LE().\r
+ *\r
+ * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ * \n\n\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_PStream_LE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+\r
+ /** FLASH buffer source version of \ref Endpoint_Write_Control_Stream_BE().\r
+ *\r
+ * \pre The FLASH data must be located in the first 64KB of FLASH for this function to work correctly.\r
+ *\r
+ * \note This function automatically clears the control transfer's status stage. Do not manually attempt\r
+ * to clear the status stage when using this routine in a control transaction.\r
+ * \n\n\r
+ *\r
+ * \note This routine should only be used on CONTROL type endpoints.\r
+ * \n\n\r
+ *\r
+ * \warning Unlike the standard stream read/write commands, the control stream commands cannot be chained\r
+ * together; i.e. the entire stream data must be read or written at the one time.\r
+ *\r
+ * \param[in] Buffer Pointer to the source data buffer to read from.\r
+ * \param[in] Length Number of bytes to read for the currently selected endpoint into the buffer.\r
+ *\r
+ * \return A value from the \ref Endpoint_ControlStream_RW_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_Write_Control_PStream_BE(const void* const Buffer,\r
+ uint16_t Length) ATTR_NON_NULL_PTR_ARG(1);\r
+ //@}\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+ \r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_XMEGA)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+\r
+#include "../Endpoint.h"\r
+\r
+#if !defined(FIXED_CONTROL_ENDPOINT_SIZE)\r
+uint8_t USB_Device_ControlEndpointSize = ENDPOINT_CONTROLEP_DEFAULT_SIZE;\r
+#endif\r
+\r
+Endpoint_FIFOPair_t USB_Endpoint_FIFOs[ENDPOINT_TOTAL_ENDPOINTS];\r
+\r
+volatile uint8_t USB_Endpoint_SelectedEndpoint;\r
+volatile USB_EP_t* USB_Endpoint_SelectedHandle;\r
+volatile Endpoint_FIFO_t* USB_Endpoint_SelectedFIFO;\r
+\r
+bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table,\r
+ const uint8_t Entries)\r
+{\r
+ for (uint8_t i = 0; i < Entries; i++)\r
+ {\r
+ if (!(Table[i].Address))\r
+ continue;\r
+ \r
+ if (!(Endpoint_ConfigureEndpoint(Table[i].Address, Table[i].Type, Table[i].Size, Table[i].Banks)))\r
+ {\r
+ return false;\r
+ }\r
+ }\r
+ \r
+ return true;\r
+}\r
+\r
+bool Endpoint_ConfigureEndpoint_PRV(const uint8_t Address,\r
+ const uint8_t Config,\r
+ const uint8_t Size)\r
+{\r
+ Endpoint_SelectEndpoint(Address);\r
+\r
+ USB_Endpoint_SelectedHandle->CTRL = 0;\r
+ USB_Endpoint_SelectedHandle->STATUS = (Address & ENDPOINT_DIR_IN) ? USB_EP_BUSNACK0_bm : 0;\r
+ USB_Endpoint_SelectedHandle->CTRL = Config;\r
+ USB_Endpoint_SelectedHandle->CNT = 0;\r
+ USB_Endpoint_SelectedHandle->DATAPTR = (intptr_t)USB_Endpoint_SelectedFIFO->Data;\r
+\r
+ USB_Endpoint_SelectedFIFO->Length = (Address & ENDPOINT_DIR_IN) ? Size : 0;\r
+ USB_Endpoint_SelectedFIFO->Position = 0;\r
+\r
+ return true;\r
+}\r
+\r
+void Endpoint_ClearEndpoints(void)\r
+{\r
+ for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)\r
+ {\r
+ ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].IN.CTRL = 0;\r
+ ((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EPNum].OUT.CTRL = 0;\r
+ }\r
+}\r
+\r
+void Endpoint_ClearStatusStage(void)\r
+{\r
+ if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST)\r
+ {\r
+ while (!(Endpoint_IsOUTReceived()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return;\r
+ }\r
+\r
+ Endpoint_ClearOUT();\r
+ }\r
+ else\r
+ {\r
+ while (!(Endpoint_IsINReady()))\r
+ {\r
+ if (USB_DeviceState == DEVICE_STATE_Unattached)\r
+ return;\r
+ }\r
+\r
+ Endpoint_ClearIN();\r
+ }\r
+}\r
+\r
+#if !defined(CONTROL_ONLY_DEVICE)\r
+uint8_t Endpoint_WaitUntilReady(void)\r
+{\r
+ #if (USB_STREAM_TIMEOUT_MS < 0xFF)\r
+ uint8_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #else\r
+ uint16_t TimeoutMSRem = USB_STREAM_TIMEOUT_MS;\r
+ #endif\r
+\r
+ uint16_t PreviousFrameNumber = USB_Device_GetFrameNumber();\r
+\r
+ for (;;)\r
+ {\r
+ if (Endpoint_GetEndpointDirection() == ENDPOINT_DIR_IN)\r
+ {\r
+ if (Endpoint_IsINReady())\r
+ return ENDPOINT_READYWAIT_NoError;\r
+ }\r
+ else\r
+ {\r
+ if (Endpoint_IsOUTReceived())\r
+ return ENDPOINT_READYWAIT_NoError;\r
+ }\r
+\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_READYWAIT_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_READYWAIT_BusSuspended;\r
+ else if (Endpoint_IsStalled())\r
+ return ENDPOINT_READYWAIT_EndpointStalled;\r
+\r
+ uint16_t CurrentFrameNumber = USB_Device_GetFrameNumber();\r
+\r
+ if (CurrentFrameNumber != PreviousFrameNumber)\r
+ {\r
+ PreviousFrameNumber = CurrentFrameNumber;\r
+\r
+ if (!(TimeoutMSRem--))\r
+ return ENDPOINT_READYWAIT_Timeout;\r
+ }\r
+ }\r
+}\r
+#endif\r
+\r
+#endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Endpoint definitions for the AVR XMEGA microcontrollers.\r
+ * \copydetails Group_EndpointManagement_XMEGA\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_EndpointRW\r
+ * \defgroup Group_EndpointRW_XMEGA Endpoint Data Reading and Writing (XMEGA)\r
+ * \brief Endpoint data read/write definitions for the Atmel AVR XMEGA architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing from and to endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointPrimitiveRW\r
+ * \defgroup Group_EndpointPrimitiveRW_XMEGA Read/Write of Primitive Data Types (XMEGA)\r
+ * \brief Endpoint primitive read/write definitions for the Atmel AVR XMEGA architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to data reading and writing of primitive data types\r
+ * from and to endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointPacketManagement\r
+ * \defgroup Group_EndpointPacketManagement_XMEGA Endpoint Packet Management (XMEGA)\r
+ * \brief Endpoint packet management definitions for the Atmel AVR XMEGA architecture.\r
+ *\r
+ * Functions, macros, variables, enums and types related to packet management of endpoints.\r
+ */\r
+\r
+/** \ingroup Group_EndpointManagement\r
+ * \defgroup Group_EndpointManagement_XMEGA Endpoint Management (XMEGA)\r
+ * \brief Endpoint management definitions for the Atmel AVR XMEGA architecture.\r
+ *\r
+ * Functions, macros and enums related to endpoint management when in USB Device mode. This\r
+ * module contains the endpoint management macros, as well as endpoint interrupt and data\r
+ * send/receive functions for various data types.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __ENDPOINT_XMEGA_H__\r
+#define __ENDPOINT_XMEGA_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBTask.h"\r
+ #include "../USBInterrupt.h"\r
+ #include "../USBController.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #if (!defined(MAX_ENDPOINT_INDEX) && !defined(CONTROL_ONLY_DEVICE)) || defined(__DOXYGEN__)\r
+ /** Total number of endpoints (including the default control endpoint at address 0) which may\r
+ * be used in the device. Different USB AVR models support different amounts of endpoints,\r
+ * this value reflects the maximum number of endpoints for the currently selected AVR model.\r
+ */\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 16\r
+ #else\r
+ #if defined(CONTROL_ONLY_DEVICE)\r
+ #define ENDPOINT_TOTAL_ENDPOINTS 1\r
+ #else\r
+ #define ENDPOINT_TOTAL_ENDPOINTS (MAX_ENDPOINT_INDEX + 1)\r
+ #endif\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Type Defines: */\r
+ typedef struct\r
+ {\r
+ uint8_t Data[64];\r
+\r
+ uint8_t Length;\r
+ uint8_t Position;\r
+ } Endpoint_FIFO_t;\r
+\r
+ typedef struct\r
+ {\r
+ Endpoint_FIFO_t OUT;\r
+ Endpoint_FIFO_t IN;\r
+ } Endpoint_FIFOPair_t;\r
+\r
+ /* External Variables: */\r
+ extern Endpoint_FIFOPair_t USB_Endpoint_FIFOs[ENDPOINT_TOTAL_ENDPOINTS];\r
+ extern volatile uint8_t USB_Endpoint_SelectedEndpoint;\r
+ extern volatile USB_EP_t* USB_Endpoint_SelectedHandle;\r
+ extern volatile Endpoint_FIFO_t* USB_Endpoint_SelectedFIFO;\r
+\r
+ /* Inline Functions: */\r
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST\r
+ ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes)\r
+ {\r
+ uint8_t MaskVal = 0;\r
+ uint16_t CheckBytes = 8;\r
+\r
+ while (CheckBytes < Bytes)\r
+ {\r
+ MaskVal++;\r
+ CheckBytes <<= 1;\r
+ }\r
+\r
+ return (MaskVal << USB_EP_BUFSIZE_gp);\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ bool Endpoint_ConfigureEndpoint_PRV(const uint8_t Address,\r
+ const uint8_t Config,\r
+ const uint8_t Size);\r
+ void Endpoint_ClearEndpoints(void);\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))\r
+ /** Default size of the default control endpoint's bank, until altered by the control endpoint bank size\r
+ * value in the device descriptor. Not available if the \c FIXED_CONTROL_ENDPOINT_SIZE token is defined.\r
+ */\r
+ #define ENDPOINT_CONTROLEP_DEFAULT_SIZE 8\r
+ #endif\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible error return codes of the \ref Endpoint_WaitUntilReady() function.\r
+ *\r
+ * \ingroup Group_EndpointRW_XMEGA\r
+ */\r
+ enum Endpoint_WaitUntilReady_ErrorCodes_t\r
+ {\r
+ ENDPOINT_READYWAIT_NoError = 0, /**< Endpoint is ready for next packet, no error. */\r
+ ENDPOINT_READYWAIT_EndpointStalled = 1, /**< The endpoint was stalled during the stream\r
+ * transfer by the host or device.\r
+ */\r
+ ENDPOINT_READYWAIT_DeviceDisconnected = 2, /**< Device was disconnected from the host while\r
+ * waiting for the endpoint to become ready.\r
+ */\r
+ ENDPOINT_READYWAIT_BusSuspended = 3, /**< The USB bus has been suspended by the host and\r
+ * no USB endpoint traffic can occur until the bus\r
+ * has resumed.\r
+ */\r
+ ENDPOINT_READYWAIT_Timeout = 4, /**< The host failed to accept or send the next packet\r
+ * within the software timeout period set by the\r
+ * \ref USB_STREAM_TIMEOUT_MS macro.\r
+ */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Selects the given endpoint address.\r
+ *\r
+ * Any endpoint operations which do not require the endpoint address to be indicated will operate on\r
+ * the currently selected endpoint.\r
+ *\r
+ * \param[in] Address Endpoint address to select.\r
+ */\r
+ static inline void Endpoint_SelectEndpoint(const uint8_t Address);\r
+ static inline void Endpoint_SelectEndpoint(const uint8_t Address)\r
+ {\r
+ uint8_t EndpointNumber = (Address & ENDPOINT_EPNUM_MASK);\r
+\r
+ USB_Endpoint_SelectedEndpoint = Address;\r
+\r
+ if (Address & ENDPOINT_DIR_IN)\r
+ {\r
+ USB_Endpoint_SelectedFIFO = &USB_Endpoint_FIFOs[EndpointNumber].IN;\r
+ USB_Endpoint_SelectedHandle = &((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EndpointNumber].IN;\r
+ }\r
+ else\r
+ {\r
+ USB_Endpoint_SelectedFIFO = &USB_Endpoint_FIFOs[EndpointNumber].OUT;\r
+ USB_Endpoint_SelectedHandle = &((USB_EndpointTable_t*)USB.EPPTR)->Endpoints[EndpointNumber].OUT;\r
+ }\r
+ }\r
+\r
+ /** Configures the specified endpoint address with the given endpoint type, direction, bank size\r
+ * and banking mode. Once configured, the endpoint may be read from or written to, depending\r
+ * on its direction.\r
+ *\r
+ * \param[in] Address Endpoint address to configure.\r
+ *\r
+ * \param[in] Type Type of endpoint to configure, a \c EP_TYPE_* mask. Not all endpoint types\r
+ * are available on Low Speed USB devices - refer to the USB 2.0 specification.\r
+ *\r
+ * \param[in] Size Size of the endpoint's bank, where packets are stored before they are transmitted\r
+ * to the USB host, or after they have been received from the USB host (depending on\r
+ * the endpoint's data direction). The bank size must indicate the maximum packet size\r
+ * that the endpoint can handle.\r
+ *\r
+ * \param[in] Banks Number of hardware banks to use for the endpoint being configured.\r
+ *\r
+ * \note The default control endpoint should not be manually configured by the user application, as\r
+ * it is automatically configured by the library internally.\r
+ * \n\n\r
+ *\r
+ * \note This routine will automatically select the specified endpoint.\r
+ *\r
+ * \return Boolean \c true if the configuration succeeded, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address,\r
+ const uint8_t Type,\r
+ const uint16_t Size,\r
+ const uint8_t Banks) ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_ConfigureEndpoint(const uint8_t Address,\r
+ const uint8_t Type,\r
+ const uint16_t Size,\r
+ const uint8_t Banks)\r
+ {\r
+ uint8_t EPConfigMask = (USB_EP_INTDSBL_bm | ((Banks > 1) ? USB_EP_PINGPONG_bm : 0) | Endpoint_BytesToEPSizeMask(Size));\r
+\r
+ if ((Address & ENDPOINT_EPNUM_MASK) >= ENDPOINT_TOTAL_ENDPOINTS)\r
+ return false;\r
+\r
+ // TODO - Fix once limitations are lifted\r
+ EPConfigMask &= ~USB_EP_PINGPONG_bm;\r
+ if (Size > 64)\r
+ return false;\r
+\r
+ switch (Type)\r
+ {\r
+ case EP_TYPE_CONTROL:\r
+ EPConfigMask |= USB_EP_TYPE_CONTROL_gc;\r
+ break;\r
+ case EP_TYPE_ISOCHRONOUS:\r
+ EPConfigMask |= USB_EP_TYPE_ISOCHRONOUS_gc;\r
+ break;\r
+ default:\r
+ EPConfigMask |= USB_EP_TYPE_BULK_gc;\r
+ break;\r
+ }\r
+\r
+ if (Type == EP_TYPE_CONTROL)\r
+ Endpoint_ConfigureEndpoint_PRV(Address ^ ENDPOINT_DIR_IN, EPConfigMask, Size);\r
+\r
+ return Endpoint_ConfigureEndpoint_PRV(Address, EPConfigMask, Size);\r
+ }\r
+\r
+ /** Indicates the number of bytes currently stored in the current endpoint's selected bank.\r
+ *\r
+ * \ingroup Group_EndpointRW_XMEGA\r
+ *\r
+ * \return Total number of bytes in the currently selected Endpoint's FIFO buffer.\r
+ */\r
+ static inline uint16_t Endpoint_BytesInEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Endpoint_BytesInEndpoint(void)\r
+ {\r
+ if (USB_Endpoint_SelectedEndpoint & ENDPOINT_DIR_IN)\r
+ return USB_Endpoint_SelectedFIFO->Position;\r
+ else\r
+ return (USB_Endpoint_SelectedFIFO->Length - USB_Endpoint_SelectedFIFO->Position);\r
+ }\r
+\r
+ /** Get the endpoint address of the currently selected endpoint. This is typically used to save\r
+ * the currently selected endpoint so that it can be restored after another endpoint has been\r
+ * manipulated.\r
+ *\r
+ * \return Index of the currently selected endpoint.\r
+ */\r
+ static inline uint8_t Endpoint_GetCurrentEndpoint(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_GetCurrentEndpoint(void)\r
+ {\r
+ return USB_Endpoint_SelectedEndpoint;\r
+ }\r
+\r
+ /** Resets the endpoint bank FIFO. This clears all the endpoint banks and resets the USB controller's\r
+ * data In and Out pointers to the bank's contents.\r
+ *\r
+ * \param[in] Address Endpoint address whose FIFO buffers are to be reset.\r
+ */\r
+ static inline void Endpoint_ResetEndpoint(const uint8_t Address) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ResetEndpoint(const uint8_t Address)\r
+ {\r
+ if (Address & ENDPOINT_DIR_IN)\r
+ USB_Endpoint_FIFOs[Address & ENDPOINT_EPNUM_MASK].IN.Position = 0;\r
+ else\r
+ USB_Endpoint_FIFOs[Address & ENDPOINT_EPNUM_MASK].OUT.Position = 0;\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint is enabled, but not necessarily configured.\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint is enabled, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsEnabled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsEnabled(void)\r
+ {\r
+ return true;\r
+ }\r
+\r
+ /** Aborts all pending IN transactions on the currently selected endpoint, once the bank\r
+ * has been queued for transmission to the host via \ref Endpoint_ClearIN(). This function\r
+ * will terminate all queued transactions, resetting the endpoint banks ready for a new\r
+ * packet.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_XMEGA\r
+ */\r
+ static inline void Endpoint_AbortPendingIN(void)\r
+ {\r
+ USB_Endpoint_SelectedHandle->STATUS |= USB_EP_BUSNACK0_bm;\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint may be read from (if data is waiting in the endpoint\r
+ * bank and the endpoint is an OUT direction, or if the bank is not yet full if the endpoint is an IN\r
+ * direction). This function will return false if an error has occurred in the endpoint, if the endpoint\r
+ * is an OUT direction and no packet (or an empty packet) has been received, or if the endpoint is an IN\r
+ * direction and the endpoint bank is full.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_XMEGA\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint may be read from or written to, depending\r
+ * on its direction.\r
+ */\r
+ static inline bool Endpoint_IsReadWriteAllowed(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsReadWriteAllowed(void)\r
+ {\r
+ return (USB_Endpoint_SelectedFIFO->Position < USB_Endpoint_SelectedFIFO->Length);\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint is configured.\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint has been configured, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsConfigured(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsConfigured(void)\r
+ {\r
+ return ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_TYPE_gm) ? true : false);\r
+ }\r
+\r
+ /** Determines if the selected IN endpoint is ready for a new packet to be sent to the host.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_XMEGA\r
+ *\r
+ * \return Boolean \c true if the current endpoint is ready for an IN packet, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsINReady(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsINReady(void)\r
+ {\r
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN);\r
+\r
+ return ((USB_Endpoint_SelectedHandle->STATUS & USB_EP_BUSNACK0_bm) ? true : false);\r
+ }\r
+\r
+ /** Determines if the selected OUT endpoint has received new packet from the host.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_XMEGA\r
+ *\r
+ * \return Boolean \c true if current endpoint is has received an OUT packet, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsOUTReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsOUTReceived(void)\r
+ {\r
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);\r
+\r
+ if (USB_Endpoint_SelectedHandle->STATUS & USB_EP_TRNCOMPL0_bm)\r
+ {\r
+ USB_Endpoint_SelectedFIFO->Length = USB_Endpoint_SelectedHandle->CNT;\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ /** Determines if the current CONTROL type endpoint has received a SETUP packet.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_XMEGA\r
+ *\r
+ * \return Boolean \c true if the selected endpoint has received a SETUP packet, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsSETUPReceived(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsSETUPReceived(void)\r
+ {\r
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);\r
+\r
+ if (USB_Endpoint_SelectedHandle->STATUS & USB_EP_SETUP_bm)\r
+ {\r
+ USB_Endpoint_SelectedFIFO->Length = USB_Endpoint_SelectedHandle->CNT;\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ /** Clears a received SETUP packet on the currently selected CONTROL type endpoint, freeing up the\r
+ * endpoint for the next packet.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_XMEGA\r
+ *\r
+ * \note This is not applicable for non CONTROL type endpoints.\r
+ */\r
+ static inline void Endpoint_ClearSETUP(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearSETUP(void)\r
+ {\r
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);\r
+ USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_SETUP_bm | USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm);\r
+ USB_Endpoint_SelectedHandle->STATUS |= USB_EP_TOGGLE_bm;\r
+ USB_Endpoint_SelectedFIFO->Position = 0;\r
+\r
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN);\r
+ USB_Endpoint_SelectedHandle->STATUS |= USB_EP_TOGGLE_bm;\r
+ USB_Endpoint_SelectedFIFO->Position = 0;\r
+ }\r
+\r
+ /** Sends an IN packet to the host on the currently selected endpoint, freeing up the endpoint for the\r
+ * next packet and switching to the alternative endpoint bank if double banked.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_XMEGA\r
+ */\r
+ static inline void Endpoint_ClearIN(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearIN(void)\r
+ {\r
+ USB_Endpoint_SelectedHandle->CNT = USB_Endpoint_SelectedFIFO->Position;\r
+ USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm);\r
+ USB_Endpoint_SelectedFIFO->Position = 0;\r
+ }\r
+\r
+ /** Acknowledges an OUT packet to the host on the currently selected endpoint, freeing up the endpoint\r
+ * for the next packet and switching to the alternative endpoint bank if double banked.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_XMEGA\r
+ */\r
+ static inline void Endpoint_ClearOUT(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearOUT(void)\r
+ {\r
+ USB_Endpoint_SelectedHandle->STATUS &= ~(USB_EP_TRNCOMPL0_bm | USB_EP_BUSNACK0_bm | USB_EP_OVF_bm);\r
+ USB_Endpoint_SelectedFIFO->Position = 0;\r
+ }\r
+\r
+ /** Stalls the current endpoint, indicating to the host that a logical problem occurred with the\r
+ * indicated endpoint and that the current transfer sequence should be aborted. This provides a\r
+ * way for devices to indicate invalid commands to the host so that the current transfer can be\r
+ * aborted and the host can begin its own recovery sequence.\r
+ *\r
+ * The currently selected endpoint remains stalled until either the \ref Endpoint_ClearStall() macro\r
+ * is called, or the host issues a CLEAR FEATURE request to the device for the currently selected\r
+ * endpoint.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_XMEGA\r
+ */\r
+ static inline void Endpoint_StallTransaction(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_StallTransaction(void)\r
+ {\r
+ USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm;\r
+\r
+ if ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_TYPE_gm) == USB_EP_TYPE_CONTROL_gc)\r
+ {\r
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint ^ ENDPOINT_DIR_IN);\r
+ USB_Endpoint_SelectedHandle->CTRL |= USB_EP_STALL_bm;\r
+ }\r
+ }\r
+\r
+ /** Clears the STALL condition on the currently selected endpoint.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_XMEGA\r
+ */\r
+ static inline void Endpoint_ClearStall(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ClearStall(void)\r
+ {\r
+ USB_Endpoint_SelectedHandle->CTRL &= ~USB_EP_STALL_bm;\r
+ }\r
+\r
+ /** Determines if the currently selected endpoint is stalled, false otherwise.\r
+ *\r
+ * \ingroup Group_EndpointPacketManagement_XMEGA\r
+ *\r
+ * \return Boolean \c true if the currently selected endpoint is stalled, \c false otherwise.\r
+ */\r
+ static inline bool Endpoint_IsStalled(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline bool Endpoint_IsStalled(void)\r
+ {\r
+ return ((USB_Endpoint_SelectedHandle->CTRL & USB_EP_STALL_bm) ? true : false);\r
+ }\r
+\r
+ /** Resets the data toggle of the currently selected endpoint. */\r
+ static inline void Endpoint_ResetDataToggle(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_ResetDataToggle(void)\r
+ {\r
+ USB_Endpoint_SelectedHandle->STATUS &= ~USB_EP_TOGGLE_bm;\r
+ }\r
+\r
+ /** Determines the currently selected endpoint's direction.\r
+ *\r
+ * \return The currently selected endpoint's direction, as a \c ENDPOINT_DIR_* mask.\r
+ */\r
+ static inline uint8_t Endpoint_GetEndpointDirection(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_GetEndpointDirection(void)\r
+ {\r
+ return (USB_Endpoint_SelectedEndpoint & ENDPOINT_DIR_IN);\r
+ }\r
+\r
+ /** Reads one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ *\r
+ * \return Next byte in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint8_t Endpoint_Read_8(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t Endpoint_Read_8(void)\r
+ {\r
+ return USB_Endpoint_SelectedFIFO->Data[USB_Endpoint_SelectedFIFO->Position++];\r
+ }\r
+\r
+ /** Writes one byte to the currently selected endpoint's bank, for IN direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ *\r
+ * \param[in] Data Data to write into the the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_8(const uint8_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_8(const uint8_t Data)\r
+ {\r
+ USB_Endpoint_SelectedFIFO->Data[USB_Endpoint_SelectedFIFO->Position++] = Data;\r
+ }\r
+\r
+ /** Discards one byte from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ */\r
+ static inline void Endpoint_Discard_8(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Discard_8(void)\r
+ {\r
+ USB_Endpoint_SelectedFIFO->Position++;\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected endpoint's bank in little endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ *\r
+ * \return Next two bytes in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint16_t Endpoint_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Endpoint_Read_16_LE(void)\r
+ {\r
+ uint16_t Byte0 = Endpoint_Read_8();\r
+ uint16_t Byte1 = Endpoint_Read_8();\r
+\r
+ return ((Byte1 << 8) | Byte0);\r
+ }\r
+\r
+ /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ *\r
+ * \return Next two bytes in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint16_t Endpoint_Read_16_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint16_t Endpoint_Read_16_BE(void)\r
+ {\r
+ uint16_t Byte0 = Endpoint_Read_8();\r
+ uint16_t Byte1 = Endpoint_Read_8();\r
+\r
+ return ((Byte0 << 8) | Byte1);\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected endpoint's bank in little endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ *\r
+ * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_16_LE(const uint16_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_16_LE(const uint16_t Data)\r
+ {\r
+ Endpoint_Write_8(Data & 0xFF);\r
+ Endpoint_Write_8(Data >> 8);\r
+ }\r
+\r
+ /** Writes two bytes to the currently selected endpoint's bank in big endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ *\r
+ * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_16_BE(const uint16_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_16_BE(const uint16_t Data)\r
+ {\r
+ Endpoint_Write_8(Data >> 8);\r
+ Endpoint_Write_8(Data & 0xFF);\r
+ }\r
+\r
+ /** Discards two bytes from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ */\r
+ static inline void Endpoint_Discard_16(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Discard_16(void)\r
+ {\r
+ Endpoint_Discard_8();\r
+ Endpoint_Discard_8();\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected endpoint's bank in little endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ *\r
+ * \return Next four bytes in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint32_t Endpoint_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Endpoint_Read_32_LE(void)\r
+ {\r
+ uint32_t Byte0 = Endpoint_Read_8();\r
+ uint32_t Byte1 = Endpoint_Read_8();\r
+ uint32_t Byte2 = Endpoint_Read_8();\r
+ uint32_t Byte3 = Endpoint_Read_8();\r
+\r
+ return ((Byte3 << 24) | (Byte2 << 16) | (Byte1 << 8) | Byte0);\r
+ }\r
+\r
+ /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ *\r
+ * \return Next four bytes in the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline uint32_t Endpoint_Read_32_BE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;\r
+ static inline uint32_t Endpoint_Read_32_BE(void)\r
+ {\r
+ uint32_t Byte0 = Endpoint_Read_8();\r
+ uint32_t Byte1 = Endpoint_Read_8();\r
+ uint32_t Byte2 = Endpoint_Read_8();\r
+ uint32_t Byte3 = Endpoint_Read_8();\r
+\r
+ return ((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3);\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected endpoint's bank in little endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ *\r
+ * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_32_LE(const uint32_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_32_LE(const uint32_t Data)\r
+ {\r
+ Endpoint_Write_8(Data & 0xFF);\r
+ Endpoint_Write_8(Data >> 8);\r
+ Endpoint_Write_8(Data >> 16);\r
+ Endpoint_Write_8(Data >> 24);\r
+ }\r
+\r
+ /** Writes four bytes to the currently selected endpoint's bank in big endian format, for IN\r
+ * direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ *\r
+ * \param[in] Data Data to write to the currently selected endpoint's FIFO buffer.\r
+ */\r
+ static inline void Endpoint_Write_32_BE(const uint32_t Data) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Write_32_BE(const uint32_t Data)\r
+ {\r
+ Endpoint_Write_8(Data >> 24);\r
+ Endpoint_Write_8(Data >> 16);\r
+ Endpoint_Write_8(Data >> 8);\r
+ Endpoint_Write_8(Data & 0xFF);\r
+ }\r
+\r
+ /** Discards four bytes from the currently selected endpoint's bank, for OUT direction endpoints.\r
+ *\r
+ * \ingroup Group_EndpointPrimitiveRW_XMEGA\r
+ */\r
+ static inline void Endpoint_Discard_32(void) ATTR_ALWAYS_INLINE;\r
+ static inline void Endpoint_Discard_32(void)\r
+ {\r
+ Endpoint_Discard_8();\r
+ Endpoint_Discard_8();\r
+ Endpoint_Discard_8();\r
+ Endpoint_Discard_8();\r
+ }\r
+\r
+ /* External Variables: */\r
+ /** Global indicating the maximum packet size of the default control endpoint located at address\r
+ * 0 in the device. This value is set to the value indicated in the device descriptor in the user\r
+ * project once the USB interface is initialized into device mode.\r
+ *\r
+ * If space is an issue, it is possible to fix this to a static value by defining the control\r
+ * endpoint size in the \c FIXED_CONTROL_ENDPOINT_SIZE token passed to the compiler in the makefile\r
+ * via the -D switch. When a fixed control endpoint size is used, the size is no longer dynamically\r
+ * read from the descriptors at runtime and instead fixed to the given value. When used, it is\r
+ * important that the descriptor control endpoint size value matches the size given as the\r
+ * \c FIXED_CONTROL_ENDPOINT_SIZE token - it is recommended that the \c FIXED_CONTROL_ENDPOINT_SIZE token\r
+ * be used in the device descriptors to ensure this.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ #if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))\r
+ extern uint8_t USB_Device_ControlEndpointSize;\r
+ #else\r
+ #define USB_Device_ControlEndpointSize FIXED_CONTROL_ENDPOINT_SIZE\r
+ #endif\r
+\r
+ /* Function Prototypes: */\r
+ /** Configures a table of endpoint descriptions, in sequence. This function can be used to configure multiple\r
+ * endpoints at the same time.\r
+ *\r
+ * \note Endpoints with a zero address will be ignored, thus this function cannot be used to configure the\r
+ * control endpoint.\r
+ *\r
+ * \param[in] Table Pointer to a table of endpoint descriptions.\r
+ * \param[in] Entries Number of entries in the endpoint table to configure.\r
+ *\r
+ * \return Boolean \c true if all endpoints configured successfully, \c false otherwise.\r
+ */\r
+ bool Endpoint_ConfigureEndpointTable(const USB_Endpoint_Table_t* const Table,\r
+ const uint8_t Entries);\r
+\r
+ /** Completes the status stage of a control transfer on a CONTROL type endpoint automatically,\r
+ * with respect to the data direction. This is a convenience function which can be used to\r
+ * simplify user control request handling.\r
+ *\r
+ * \note This routine should not be called on non CONTROL type endpoints.\r
+ */\r
+ void Endpoint_ClearStatusStage(void);\r
+\r
+ /** Spin-loops until the currently selected non-control endpoint is ready for the next packet of data\r
+ * to be read or written to it.\r
+ *\r
+ * \note This routine should not be called on CONTROL type endpoints.\r
+ *\r
+ * \ingroup Group_EndpointRW_XMEGA\r
+ *\r
+ * \return A value from the \ref Endpoint_WaitUntilReady_ErrorCodes_t enum.\r
+ */\r
+ uint8_t Endpoint_WaitUntilReady(void);\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_XMEGA)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_XMEGA)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBMode.h"\r
+\r
+#if defined(USB_CAN_BE_HOST)\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#if defined(TEMPLATE_FUNC_NAME)\r
+\r
+// cppcheck-suppress unusedFunction\r
+uint8_t TEMPLATE_FUNC_NAME (void* const Buffer,\r
+ uint16_t Length)\r
+{\r
+ uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
+\r
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint & ~ENDPOINT_DIR_IN);\r
+\r
+ if (!(Length))\r
+ Endpoint_ClearOUT();\r
+\r
+ while (Length)\r
+ {\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_RWCSTREAM_BusSuspended;\r
+ else if (Endpoint_IsSETUPReceived())\r
+ return ENDPOINT_RWCSTREAM_HostAborted;\r
+\r
+ if (Endpoint_IsOUTReceived())\r
+ {\r
+ while (Length && Endpoint_BytesInEndpoint())\r
+ {\r
+ TEMPLATE_TRANSFER_BYTE(DataStream);\r
+ TEMPLATE_BUFFER_MOVE(DataStream, 1);\r
+ Length--;\r
+ }\r
+\r
+ Endpoint_ClearOUT();\r
+ }\r
+ }\r
+\r
+ while (!(Endpoint_IsINReady()))\r
+ {\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_RWCSTREAM_BusSuspended;\r
+ }\r
+\r
+ return ENDPOINT_RWCSTREAM_NoError;\r
+}\r
+\r
+#undef TEMPLATE_BUFFER_OFFSET\r
+#undef TEMPLATE_BUFFER_MOVE\r
+#undef TEMPLATE_FUNC_NAME\r
+#undef TEMPLATE_TRANSFER_BYTE\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#if defined(TEMPLATE_FUNC_NAME)\r
+\r
+// cppcheck-suppress unusedFunction\r
+uint8_t TEMPLATE_FUNC_NAME (const void* const Buffer,\r
+ uint16_t Length)\r
+{\r
+ uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
+ bool LastPacketFull = false;\r
+\r
+ Endpoint_SelectEndpoint(USB_Endpoint_SelectedEndpoint | ENDPOINT_DIR_IN);\r
+\r
+ if (Length > USB_ControlRequest.wLength)\r
+ Length = USB_ControlRequest.wLength;\r
+ else if (!(Length))\r
+ Endpoint_ClearIN();\r
+\r
+ while (Length || LastPacketFull)\r
+ {\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_RWCSTREAM_BusSuspended;\r
+ else if (Endpoint_IsSETUPReceived())\r
+ return ENDPOINT_RWCSTREAM_HostAborted;\r
+ else if (Endpoint_IsOUTReceived())\r
+ break;\r
+\r
+ if (Endpoint_IsINReady())\r
+ {\r
+ uint16_t BytesInEndpoint = Endpoint_BytesInEndpoint();\r
+\r
+ while (Length && (BytesInEndpoint < USB_Device_ControlEndpointSize))\r
+ {\r
+ TEMPLATE_TRANSFER_BYTE(DataStream);\r
+ TEMPLATE_BUFFER_MOVE(DataStream, 1);\r
+ Length--;\r
+ BytesInEndpoint++;\r
+ }\r
+\r
+ LastPacketFull = (BytesInEndpoint == USB_Device_ControlEndpointSize);\r
+ Endpoint_ClearIN();\r
+ }\r
+ }\r
+\r
+ while (!(Endpoint_IsOUTReceived()))\r
+ {\r
+ uint8_t USB_DeviceState_LCL = USB_DeviceState;\r
+\r
+ if (USB_DeviceState_LCL == DEVICE_STATE_Unattached)\r
+ return ENDPOINT_RWCSTREAM_DeviceDisconnected;\r
+ else if (USB_DeviceState_LCL == DEVICE_STATE_Suspended)\r
+ return ENDPOINT_RWCSTREAM_BusSuspended;\r
+ }\r
+\r
+ return ENDPOINT_RWCSTREAM_NoError;\r
+}\r
+\r
+#undef TEMPLATE_BUFFER_OFFSET\r
+#undef TEMPLATE_BUFFER_MOVE\r
+#undef TEMPLATE_FUNC_NAME\r
+#undef TEMPLATE_TRANSFER_BYTE\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#if defined(TEMPLATE_FUNC_NAME)\r
+\r
+// cppcheck-suppress unusedFunction\r
+uint8_t TEMPLATE_FUNC_NAME (TEMPLATE_BUFFER_TYPE const Buffer,\r
+ uint16_t Length,\r
+ uint16_t* const BytesProcessed)\r
+{\r
+ uint8_t* DataStream = ((uint8_t*)Buffer + TEMPLATE_BUFFER_OFFSET(Length));\r
+ uint16_t BytesInTransfer = 0;\r
+ uint8_t ErrorCode;\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ Length -= *BytesProcessed;\r
+ TEMPLATE_BUFFER_MOVE(DataStream, *BytesProcessed);\r
+ }\r
+\r
+ while (Length)\r
+ {\r
+ if (!(Endpoint_IsReadWriteAllowed()))\r
+ {\r
+ TEMPLATE_CLEAR_ENDPOINT();\r
+\r
+ #if !defined(INTERRUPT_CONTROL_ENDPOINT)\r
+ USB_USBTask();\r
+ #endif\r
+\r
+ if (BytesProcessed != NULL)\r
+ {\r
+ *BytesProcessed += BytesInTransfer;\r
+ return ENDPOINT_RWSTREAM_IncompleteTransfer;\r
+ }\r
+\r
+ if ((ErrorCode = Endpoint_WaitUntilReady()))\r
+ return ErrorCode;\r
+ }\r
+ else\r
+ {\r
+ TEMPLATE_TRANSFER_BYTE(DataStream);\r
+ TEMPLATE_BUFFER_MOVE(DataStream, 1);\r
+ Length--;\r
+ BytesInTransfer++;\r
+ }\r
+ }\r
+\r
+ return ENDPOINT_RWSTREAM_NoError;\r
+}\r
+\r
+#undef TEMPLATE_FUNC_NAME\r
+#undef TEMPLATE_BUFFER_TYPE\r
+#undef TEMPLATE_TRANSFER_BYTE\r
+#undef TEMPLATE_CLEAR_ENDPOINT\r
+#undef TEMPLATE_BUFFER_OFFSET\r
+#undef TEMPLATE_BUFFER_MOVE\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_XMEGA)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#define __INCLUDE_FROM_USB_CONTROLLER_C\r
+#include "../USBController.h"\r
+\r
+#if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY))\r
+volatile uint8_t USB_CurrentMode = USB_MODE_None;\r
+#endif\r
+\r
+#if !defined(USE_STATIC_OPTIONS)\r
+volatile uint8_t USB_Options;\r
+#endif\r
+\r
+/* Ugly workaround to ensure an aligned table, since __BIGGEST_ALIGNMENT__ == 1 for 8-bit AVR-GCC */\r
+uint8_t USB_EndpointTable[sizeof(USB_EndpointTable_t) + 1];\r
+\r
+void USB_Init(\r
+ #if defined(USB_CAN_BE_BOTH)\r
+ const uint8_t Mode\r
+ #endif\r
+\r
+ #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS))\r
+ ,\r
+ #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))\r
+ void\r
+ #endif\r
+\r
+ #if !defined(USE_STATIC_OPTIONS)\r
+ const uint8_t Options\r
+ #endif\r
+ )\r
+{\r
+ #if !defined(USE_STATIC_OPTIONS)\r
+ USB_Options = Options;\r
+ #endif\r
+\r
+ USB_IsInitialized = true;\r
+\r
+ uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+ GlobalInterruptDisable();\r
+\r
+ NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc;\r
+ USB.CAL0 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL0));\r
+ USB.CAL1 = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBCAL1));\r
+ NVM.CMD = 0;\r
+\r
+ /* Ugly workaround to ensure an aligned table, since __BIGGEST_ALIGNMENT__ == 1 for the 8-bit AVR-GCC toochain */\r
+ USB.EPPTR = ((intptr_t)&USB_EndpointTable[1] & ~(1 << 0));\r
+ USB.CTRLA = (USB_STFRNUM_bm | ((ENDPOINT_TOTAL_ENDPOINTS - 1) << USB_MAXEP_gp));\r
+\r
+ if ((USB_Options & USB_OPT_BUSEVENT_PRIHIGH) == USB_OPT_BUSEVENT_PRIHIGH)\r
+ USB.INTCTRLA = (3 << USB_INTLVL_gp);\r
+ else if ((USB_Options & USB_OPT_BUSEVENT_PRIMED) == USB_OPT_BUSEVENT_PRIMED)\r
+ USB.INTCTRLA = (2 << USB_INTLVL_gp);\r
+ else\r
+ USB.INTCTRLA = (1 << USB_INTLVL_gp);\r
+\r
+ SetGlobalInterruptMask(CurrentGlobalInt);\r
+\r
+ USB_ResetInterface();\r
+}\r
+\r
+void USB_Disable(void)\r
+{\r
+ USB_INT_DisableAllInterrupts();\r
+ USB_INT_ClearAllInterrupts();\r
+\r
+ USB_Detach();\r
+ USB_Controller_Disable();\r
+\r
+ USB_IsInitialized = false;\r
+}\r
+\r
+void USB_ResetInterface(void)\r
+{\r
+ #if defined(USB_DEVICE_OPT_FULLSPEED)\r
+ if (USB_Options & USB_DEVICE_OPT_LOWSPEED)\r
+ CLK.USBCTRL = (((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp);\r
+ else\r
+ CLK.USBCTRL = (((F_USB / 48000000) - 1) << CLK_USBPSDIV_gp);\r
+ #else\r
+ CLK.USBCTRL = (((F_USB / 6000000) - 1) << CLK_USBPSDIV_gp);\r
+ #endif\r
+ \r
+ if (USB_Options & USB_OPT_PLLCLKSRC)\r
+ CLK.USBCTRL |= (CLK_USBSRC_PLL_gc | CLK_USBSEN_bm);\r
+ else\r
+ CLK.USBCTRL |= (CLK_USBSRC_RC32M_gc | CLK_USBSEN_bm);\r
+\r
+ USB_Device_SetDeviceAddress(0);\r
+\r
+ USB_INT_DisableAllInterrupts();\r
+ USB_INT_ClearAllInterrupts();\r
+\r
+ USB_Controller_Reset();\r
+ USB_Init_Device();\r
+}\r
+\r
+#if defined(USB_CAN_BE_DEVICE)\r
+static void USB_Init_Device(void)\r
+{\r
+ USB_DeviceState = DEVICE_STATE_Unattached;\r
+ USB_Device_ConfigurationNumber = 0;\r
+\r
+ #if !defined(NO_DEVICE_REMOTE_WAKEUP)\r
+ USB_Device_RemoteWakeupEnabled = false;\r
+ #endif\r
+\r
+ #if !defined(NO_DEVICE_SELF_POWER)\r
+ USB_Device_CurrentlySelfPowered = false;\r
+ #endif\r
+\r
+ #if !defined(FIXED_CONTROL_ENDPOINT_SIZE)\r
+ USB_Descriptor_Device_t* DeviceDescriptorPtr;\r
+\r
+ #if defined(ARCH_HAS_MULTI_ADDRESS_SPACE) && \\r
+ !(defined(USE_FLASH_DESCRIPTORS) || defined(USE_EEPROM_DESCRIPTORS) || defined(USE_RAM_DESCRIPTORS))\r
+ uint8_t DescriptorAddressSpace;\r
+\r
+ if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr, &DescriptorAddressSpace) != NO_DESCRIPTOR)\r
+ {\r
+ if (DescriptorAddressSpace == MEMSPACE_FLASH)\r
+ USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);\r
+ else if (DescriptorAddressSpace == MEMSPACE_EEPROM)\r
+ USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);\r
+ else\r
+ USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;\r
+ }\r
+ #else\r
+ if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)\r
+ {\r
+ #if defined(USE_RAM_DESCRIPTORS)\r
+ USB_Device_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;\r
+ #elif defined(USE_EEPROM_DESCRIPTORS)\r
+ USB_Device_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);\r
+ #else\r
+ USB_Device_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);\r
+ #endif\r
+ }\r
+ #endif\r
+ #endif\r
+\r
+ if (USB_Options & USB_DEVICE_OPT_LOWSPEED)\r
+ USB_Device_SetLowSpeed();\r
+ else\r
+ USB_Device_SetFullSpeed();\r
+\r
+ Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,\r
+ USB_Device_ControlEndpointSize, 1);\r
+\r
+ USB_INT_Enable(USB_INT_BUSEVENTI);\r
+\r
+ USB_Attach();\r
+}\r
+#endif\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Controller definitions for the AVR XMEGA microcontrollers.\r
+ * \copydetails Group_USBManagement_XMEGA\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+/** \ingroup Group_USBManagement\r
+ * \defgroup Group_USBManagement_XMEGA USB Interface Management (XMEGA)\r
+ * \brief USB Controller definitions for the AVR XMEGA microcontrollers.\r
+ *\r
+ * Functions, macros, variables, enums and types related to the setup and management of the USB interface.\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef __USBCONTROLLER_XMEGA_H__\r
+#define __USBCONTROLLER_XMEGA_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+ #include "../USBMode.h"\r
+ #include "../Events.h"\r
+ #include "../USBTask.h"\r
+ #include "../USBInterrupt.h"\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Type Defines: */\r
+ typedef struct\r
+ {\r
+ struct\r
+ {\r
+ USB_EP_t OUT;\r
+ USB_EP_t IN;\r
+ } Endpoints[16];\r
+ uint16_t FrameNum;\r
+ } ATTR_PACKED USB_EndpointTable_t;\r
+\r
+ /* External Variables: */\r
+ extern uint8_t USB_EndpointTable[];\r
+\r
+ #endif\r
+\r
+ /* Includes: */\r
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
+ #include "../Device.h"\r
+ #include "../Endpoint.h"\r
+ #include "../DeviceStandardReq.h"\r
+ #include "../EndpointStream.h"\r
+ #endif\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks and Defines: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ #if !defined(F_USB)\r
+ #error F_USB is not defined. You must define F_USB to the frequency of the unprescaled USB controller clock in your project makefile.\r
+ #endif\r
+\r
+ #if ((F_USB % 6000000) || (F_USB < 6000000))\r
+ #error Invalid F_USB specified. F_USB must be a multiple of 6MHz for USB Low Speed operation, and a multiple of 48MHz for Full Speed operation.\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** \name USB Controller Option Masks */\r
+ //@{\r
+ /** Sets the USB bus interrupt priority level to be low priority. The USB bus interrupt is used for Start of Frame events, bus suspend\r
+ * and resume events, bus reset events and other events related to the management of the USB bus.\r
+ */\r
+ #define USB_OPT_BUSEVENT_PRILOW ((0 << 2) | (0 << 1))\r
+\r
+ /** Sets the USB bus interrupt priority level to be medium priority. The USB bus interrupt is used for Start of Frame events, bus suspend\r
+ * and resume events, bus reset events and other events related to the management of the USB bus.\r
+ */\r
+ #define USB_OPT_BUSEVENT_PRIMED ((0 << 2) | (1 << 1))\r
+\r
+ /** Sets the USB bus interrupt priority level to be high priority. The USB bus interrupt is used for Start of Frame events, bus suspend\r
+ * and resume events, bus reset events and other events related to the management of the USB bus.\r
+ */\r
+ #define USB_OPT_BUSEVENT_PRIHIGH ((1 << 2) | (0 << 1))\r
+\r
+ /** Sets the USB controller to source its clock from the internal RC 32MHz clock, once it has been DFLL calibrated to 48MHz. */\r
+ #define USB_OPT_RC32MCLKSRC (0 << 3)\r
+\r
+ /** Sets the USB controller to source its clock from the internal PLL. */\r
+ #define USB_OPT_PLLCLKSRC (1 << 3)\r
+ //@}\r
+\r
+ #if !defined(USB_STREAM_TIMEOUT_MS) || defined(__DOXYGEN__)\r
+ /** Constant for the maximum software timeout period of the USB data stream transfer functions\r
+ * (both control and standard) when in either device or host mode. If the next packet of a stream\r
+ * is not received or acknowledged within this time period, the stream function will fail.\r
+ *\r
+ * This value may be overridden in the user project makefile as the value of the\r
+ * \ref USB_STREAM_TIMEOUT_MS token, and passed to the compiler using the -D switch.\r
+ */\r
+ #define USB_STREAM_TIMEOUT_MS 100\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ /** Detaches the device from the USB bus. This has the effect of removing the device from any\r
+ * attached host, ceasing USB communications. If no host is present, this prevents any host from\r
+ * enumerating the device once attached until \ref USB_Attach() is called.\r
+ */\r
+ static inline void USB_Detach(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Detach(void)\r
+ {\r
+ USB.CTRLB &= ~USB_ATTACH_bm;\r
+ }\r
+\r
+ /** Attaches the device to the USB bus. This announces the device's presence to any attached\r
+ * USB host, starting the enumeration process. If no host is present, attaching the device\r
+ * will allow for enumeration once a host is connected to the device.\r
+ *\r
+ * This is inexplicably also required for proper operation while in host mode, to enable the\r
+ * attachment of a device to the host. This is despite the bit being located in the device-mode\r
+ * register and despite the datasheet making no mention of its requirement in host mode.\r
+ */\r
+ static inline void USB_Attach(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Attach(void)\r
+ {\r
+ USB.CTRLB |= USB_ATTACH_bm;\r
+ }\r
+\r
+ /* Function Prototypes: */\r
+ /** Main function to initialize and start the USB interface. Once active, the USB interface will\r
+ * allow for device connection to a host when in device mode, or for device enumeration while in\r
+ * host mode.\r
+ *\r
+ * As the USB library relies on interrupts for the device and host mode enumeration processes,\r
+ * the user must enable global interrupts before or shortly after this function is called. In\r
+ * device mode, interrupts must be enabled within 500ms of this function being called to ensure\r
+ * that the host does not time out whilst enumerating the device. In host mode, interrupts may be\r
+ * enabled at the application's leisure however enumeration will not begin of an attached device\r
+ * until after this has occurred.\r
+ *\r
+ * Calling this function when the USB interface is already initialized will cause a complete USB\r
+ * interface reset and re-enumeration.\r
+ *\r
+ * \param[in] Mode This is a mask indicating what mode the USB interface is to be initialized to, a value\r
+ * from the \ref USB_Modes_t enum.\r
+ *\r
+ * \param[in] Options Mask indicating the options which should be used when initializing the USB\r
+ * interface to control the USB interface's behavior. This should be comprised of\r
+ * a \c USB_OPT_REG_* mask to control the regulator, a \c USB_OPT_*_PLL mask to control the\r
+ * PLL, and a \c USB_DEVICE_OPT_* mask (when the device mode is enabled) to set the device\r
+ * mode speed.\r
+ *\r
+ * \note To reduce the FLASH requirements of the library if only device or host mode is required,\r
+ * the mode can be statically set in the project makefile by defining the token \c USB_DEVICE_ONLY\r
+ * (for device mode) or \c USB_HOST_ONLY (for host mode), passing the token to the compiler\r
+ * via the -D switch. If the mode is statically set, this parameter does not exist in the\r
+ * function prototype.\r
+ * \n\n\r
+ *\r
+ * \note To reduce the FLASH requirements of the library if only fixed settings are required,\r
+ * the options may be set statically in the same manner as the mode (see the Mode parameter of\r
+ * this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token,\r
+ * defined to the appropriate options masks. When the options are statically set, this\r
+ * parameter does not exist in the function prototype.\r
+ * \n\n\r
+ *\r
+ * \note The mode parameter does not exist on devices where only one mode is possible, such as USB\r
+ * AVR models which only implement the USB device mode in hardware.\r
+ *\r
+ * \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks.\r
+ */\r
+ void USB_Init(\r
+ #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)\r
+ const uint8_t Mode\r
+ #endif\r
+\r
+ #if (defined(USB_CAN_BE_BOTH) && !defined(USE_STATIC_OPTIONS)) || defined(__DOXYGEN__)\r
+ ,\r
+ #elif (!defined(USB_CAN_BE_BOTH) && defined(USE_STATIC_OPTIONS))\r
+ void\r
+ #endif\r
+\r
+ #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)\r
+ const uint8_t Options\r
+ #endif\r
+ );\r
+\r
+ /** Shuts down the USB interface. This turns off the USB interface after deallocating all USB FIFO\r
+ * memory, endpoints and pipes. When turned off, no USB functionality can be used until the interface\r
+ * is restarted with the \ref USB_Init() function.\r
+ */\r
+ void USB_Disable(void);\r
+\r
+ /** Resets the interface, when already initialized. This will re-enumerate the device if already connected\r
+ * to a host, or re-enumerate an already attached device when in host mode.\r
+ */\r
+ void USB_ResetInterface(void);\r
+\r
+ /* Global Variables: */\r
+ #if (!defined(USB_HOST_ONLY) && !defined(USB_DEVICE_ONLY)) || defined(__DOXYGEN__)\r
+ /** Indicates the mode that the USB interface is currently initialized to, a value from the\r
+ * \ref USB_Modes_t enum.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ *\r
+ * \note When the controller is initialized into UID auto-detection mode, this variable will hold the\r
+ * currently selected USB mode (i.e. \ref USB_MODE_Device or \ref USB_MODE_Host). If the controller\r
+ * is fixed into a specific mode (either through the \c USB_DEVICE_ONLY or \c USB_HOST_ONLY compile time\r
+ * options, or a limitation of the USB controller in the chosen device model) this will evaluate to\r
+ * a constant of the appropriate value and will never evaluate to \ref USB_MODE_None even when the\r
+ * USB interface is not initialized.\r
+ */\r
+ extern volatile uint8_t USB_CurrentMode;\r
+ #elif defined(USB_DEVICE_ONLY)\r
+ #define USB_CurrentMode USB_MODE_Device\r
+ #endif\r
+\r
+ #if !defined(USE_STATIC_OPTIONS) || defined(__DOXYGEN__)\r
+ /** Indicates the current USB options that the USB interface was initialized with when \ref USB_Init()\r
+ * was called. This value will be one of the \c USB_MODE_* masks defined elsewhere in this module.\r
+ *\r
+ * \attention This variable should be treated as read-only in the user application, and never manually\r
+ * changed in value.\r
+ */\r
+ extern volatile uint8_t USB_Options;\r
+ #elif defined(USE_STATIC_OPTIONS)\r
+ #define USB_Options USE_STATIC_OPTIONS\r
+ #endif\r
+\r
+ /* Enums: */\r
+ /** Enum for the possible USB controller modes, for initialization via \ref USB_Init() and indication back to the\r
+ * user application via \ref USB_CurrentMode.\r
+ */\r
+ enum USB_Modes_t\r
+ {\r
+ USB_MODE_None = 0, /**< Indicates that the controller is currently not initialized in any specific USB mode. */\r
+ USB_MODE_Device = 1, /**< Indicates that the controller is currently initialized in USB Device mode. */\r
+ };\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Function Prototypes: */\r
+ #if defined(__INCLUDE_FROM_USB_CONTROLLER_C)\r
+ static void USB_Init_Device(void);\r
+ #endif\r
+\r
+ /* Inline Functions: */\r
+ static inline void USB_Controller_Enable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Controller_Enable(void)\r
+ {\r
+ USB.CTRLA |= USB_ENABLE_bm;\r
+ }\r
+\r
+ static inline void USB_Controller_Disable(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Controller_Disable(void)\r
+ {\r
+ USB.CTRLA &= ~USB_ENABLE_bm;\r
+ }\r
+\r
+ static inline void USB_Controller_Reset(void) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_Controller_Reset(void)\r
+ {\r
+ USB.CTRLA &= ~USB_ENABLE_bm;\r
+ USB.CTRLA |= USB_ENABLE_bm;\r
+ }\r
+\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../../../Common/Common.h"\r
+#if (ARCH == ARCH_XMEGA)\r
+\r
+#define __INCLUDE_FROM_USB_DRIVER\r
+#include "../USBInterrupt.h"\r
+\r
+void USB_INT_DisableAllInterrupts(void)\r
+{\r
+ USB.INTCTRLA &= USB_INTLVL_gm;\r
+ USB.INTCTRLB = 0;\r
+}\r
+\r
+void USB_INT_ClearAllInterrupts(void)\r
+{\r
+ USB.INTFLAGSACLR = 0xFF;\r
+ USB.INTFLAGSBCLR = 0xFF;\r
+}\r
+\r
+ISR(USB_BUSEVENT_vect)\r
+{\r
+ #if !defined(NO_SOF_EVENTS)\r
+ if (USB_INT_HasOccurred(USB_INT_SOFI) && USB_INT_IsEnabled(USB_INT_SOFI))\r
+ {\r
+ USB_INT_Clear(USB_INT_SOFI);\r
+\r
+ EVENT_USB_Device_StartOfFrame();\r
+ }\r
+ #endif\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Suspend))\r
+ {\r
+ USB_INT_Clear(USB_INT_BUSEVENTI_Suspend);\r
+\r
+ #if !defined(NO_LIMITED_CONTROLLER_CONNECT)\r
+ USB_DeviceState = DEVICE_STATE_Unattached;\r
+ EVENT_USB_Device_Disconnect();\r
+ #else\r
+ USB_DeviceState = DEVICE_STATE_Suspended;\r
+ EVENT_USB_Device_Suspend();\r
+ #endif\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Resume))\r
+ {\r
+ USB_INT_Clear(USB_INT_BUSEVENTI_Resume);\r
+\r
+ if (USB_Device_ConfigurationNumber)\r
+ USB_DeviceState = DEVICE_STATE_Configured;\r
+ else\r
+ USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;\r
+\r
+ #if !defined(NO_LIMITED_CONTROLLER_CONNECT)\r
+ EVENT_USB_Device_Connect();\r
+ #else\r
+ EVENT_USB_Device_WakeUp();\r
+ #endif\r
+ }\r
+\r
+ if (USB_INT_HasOccurred(USB_INT_BUSEVENTI_Reset))\r
+ {\r
+ USB_INT_Clear(USB_INT_BUSEVENTI_Reset);\r
+\r
+ USB_DeviceState = DEVICE_STATE_Default;\r
+ USB_Device_ConfigurationNumber = 0;\r
+\r
+ USB_Device_SetDeviceAddress(0);\r
+\r
+ Endpoint_ClearEndpoints();\r
+ Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,\r
+ USB_Device_ControlEndpointSize, 1);\r
+\r
+ EVENT_USB_Device_Reset();\r
+ }\r
+}\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief USB Controller Interrupt definitions for the AVR XMEGA microcontrollers.\r
+ *\r
+ * This file contains definitions required for the correct handling of low level USB service routine interrupts\r
+ * from the USB controller.\r
+ *\r
+ * \note This file should not be included directly. It is automatically included as needed by the USB driver\r
+ * dispatch header located in LUFA/Drivers/USB/USB.h.\r
+ */\r
+\r
+#ifndef __USBINTERRUPT_XMEGA_H__\r
+#define __USBINTERRUPT_XMEGA_H__\r
+\r
+ /* Includes: */\r
+ #include "../../../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Preprocessor Checks: */\r
+ #if !defined(__INCLUDE_FROM_USB_DRIVER)\r
+ #error Do not include this file directly. Include LUFA/Drivers/USB/USB.h instead.\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Enums: */\r
+ enum USB_Interrupts_t\r
+ {\r
+ USB_INT_BUSEVENTI = 1,\r
+ USB_INT_BUSEVENTI_Suspend = 2,\r
+ USB_INT_BUSEVENTI_Resume = 3,\r
+ USB_INT_BUSEVENTI_Reset = 4,\r
+ USB_INT_SOFI = 5,\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_INT_Enable(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ case USB_INT_BUSEVENTI:\r
+ USB.INTCTRLA |= USB_BUSEVIE_bm;\r
+ return;\r
+ case USB_INT_SOFI:\r
+ USB.INTCTRLA |= USB_SOFIE_bm;\r
+ return;\r
+ }\r
+ }\r
+\r
+ static inline void USB_INT_Disable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_INT_Disable(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ case USB_INT_BUSEVENTI:\r
+ USB.INTCTRLA &= ~USB_BUSEVIE_bm;\r
+ return;\r
+ case USB_INT_SOFI:\r
+ USB.INTCTRLA &= ~USB_SOFIE_bm;\r
+ return;\r
+ }\r
+ }\r
+\r
+ static inline void USB_INT_Clear(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;\r
+ static inline void USB_INT_Clear(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ case USB_INT_BUSEVENTI_Suspend:\r
+ USB.INTFLAGSACLR = USB_SUSPENDIF_bm;\r
+ return;\r
+ case USB_INT_BUSEVENTI_Resume:\r
+ USB.INTFLAGSACLR = USB_RESUMEIF_bm;\r
+ return;\r
+ case USB_INT_BUSEVENTI_Reset:\r
+ USB.INTFLAGSACLR = USB_RSTIF_bm;\r
+ return;\r
+ case USB_INT_SOFI:\r
+ USB.INTFLAGSACLR = USB_SOFIF_bm;\r
+ return;\r
+ }\r
+ }\r
+\r
+ static inline bool USB_INT_IsEnabled(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool USB_INT_IsEnabled(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ case USB_INT_BUSEVENTI:\r
+ return ((USB.INTCTRLA & USB_BUSEVIE_bm) ? true : false);\r
+ case USB_INT_SOFI:\r
+ return ((USB.INTCTRLA & USB_SOFIE_bm) ? true : false);\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ static inline bool USB_INT_HasOccurred(const uint8_t Interrupt) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;\r
+ static inline bool USB_INT_HasOccurred(const uint8_t Interrupt)\r
+ {\r
+ switch (Interrupt)\r
+ {\r
+ case USB_INT_BUSEVENTI_Suspend:\r
+ return ((USB.INTFLAGSACLR & USB_SUSPENDIF_bm) ? true : false);\r
+ case USB_INT_BUSEVENTI_Resume:\r
+ return ((USB.INTFLAGSACLR & USB_RESUMEIF_bm) ? true : false);\r
+ case USB_INT_BUSEVENTI_Reset:\r
+ return ((USB.INTFLAGSACLR & USB_RSTIF_bm) ? true : false);\r
+ case USB_INT_SOFI:\r
+ return ((USB.INTFLAGSACLR & USB_SOFIF_bm) ? true : false);\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ /* Includes: */\r
+ #include "../USBMode.h"\r
+ #include "../Events.h"\r
+ #include "../USBController.h"\r
+\r
+ /* Function Prototypes: */\r
+ void USB_INT_ClearAllInterrupts(void);\r
+ void USB_INT_DisableAllInterrupts(void);\r
+ #endif\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Master include file for the library USB functionality.\r
+ *\r
+ * Master include file for the library USB functionality.\r
+ *\r
+ * This file should be included in all user projects making use of the USB portions of the library, instead of\r
+ * the individual USB driver submodule headers.\r
+ */\r
+\r
+/** \defgroup Group_USB USB Core - LUFA/Drivers/USB/USB.h\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Drivers/USB/Core/ConfigDescriptors.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Core/DeviceStandardReq.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Core/Events.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Core/HostStandardReq.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Core/USBTask.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/Device_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/Endpoint_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/EndpointStream_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/Host_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/Pipe_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/PipeStream_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/USBController_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Core/<i>ARCH</i>/USBInterrupt_<i>ARCH</i>.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ * - LUFA/Drivers/USB/Class/Common/HIDParser.c <i>(Makefile source module name: LUFA_SRC_USB)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Driver and framework for the USB controller of the selected architecture and microcontroller model. This module\r
+ * consists of many submodules, and is designed to provide an easy way to configure and control USB host, device\r
+ * or OTG mode USB applications.\r
+ *\r
+ * The USB stack requires the sole control over the USB controller in the microcontroller only; i.e. it does not\r
+ * require any additional timers or other peripherals to operate. This ensures that the USB stack requires as few\r
+ * resources as possible.\r
+ *\r
+ * The USB stack can be used in Device Mode for connections to USB Hosts (see \ref Group_Device), in Host mode for\r
+ * hosting of other USB devices (see \ref Group_Host), or as a dual role device which can either act as a USB host\r
+ * or device depending on what peripheral is connected (see \ref Group_OTG). Both modes also require a common set\r
+ * of USB management functions found \ref Group_USBManagement.\r
+ */\r
+\r
+/** \defgroup Group_USBClassDrivers USB Class Drivers\r
+ *\r
+ * Drivers for both host and device mode of the standard USB classes, for rapid application development.\r
+ * Class drivers give a framework which sits on top of the low level library API, allowing for standard\r
+ * USB classes to be implemented in a project with minimal user code. These drivers can be used in\r
+ * conjunction with the library low level APIs to implement interfaces both via the class drivers and via\r
+ * the standard library APIs.\r
+ *\r
+ * Multiple device mode class drivers can be used within a project, including multiple instances of the\r
+ * same class driver. In this way, USB Hosts and Devices can be made quickly using the internal class drivers\r
+ * so that more time and effort can be put into the end application instead of the USB protocol.\r
+ *\r
+ * The available class drivers and their modes are listed below.\r
+ *\r
+ * <table>\r
+ * <tr>\r
+ * <th width="200px">USB Class</th>\r
+ * <th width="90px">Device Mode</th>\r
+ * <th width="90px">Host Mode</th>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>Android Open Accessory</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>Audio 1.0</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>CDC-ACM</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>HID</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>MIDI</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>Mass Storage</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>Printer</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+* <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>RNDIS</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * <tr>\r
+ * <td>Still Image</td>\r
+ * <td bgcolor="#EE0000">No</td>\r
+ * <td bgcolor="#00EE00">Yes</td>\r
+ * </tr>\r
+ * </table>\r
+ *\r
+ *\r
+ * \section Sec_UsingClassDrivers Using the Class Drivers\r
+ * To make the Class drivers easy to integrate into a user application, they all implement a standardized\r
+ * design with similarly named/used function, enums, defines and types. The two different modes are implemented\r
+ * slightly differently, and thus will be explained separately. For information on a specific class driver, read\r
+ * the class driver's module documentation.\r
+ *\r
+ * \subsection Sec_ClassDriverDevice Device Mode Class Drivers\r
+ * Implementing a Device Mode Class Driver in a user application requires a number of steps to be followed. Firstly,\r
+ * the module configuration and state structure must be added to the project source. These structures are named in a\r
+ * similar manner between classes, that of <tt>USB_ClassInfo_<i>{Class Name}</i>_Device_t</tt>, and are used to hold the\r
+ * complete state and configuration for each class instance. Multiple class instances is where the power of the class\r
+ * drivers lie; multiple interfaces of the same class simply require more instances of the Class Driver's \c USB_ClassInfo_*\r
+ * structure.\r
+ *\r
+ * Inside the ClassInfo structure lies two sections, a \c Config section, and a \c State section. The \c Config\r
+ * section contains the instance's configuration parameters, and <b>must have all fields set by the user application</b>\r
+ * before the class driver is used. Each Device mode Class driver typically contains a set of configuration parameters\r
+ * for the endpoint size/number of the associated logical USB interface, plus any class-specific configuration parameters.\r
+ *\r
+ * The following is an example of a properly initialized instance of the Audio Class Driver structure:\r
+ *\r
+ * \code\r
+ * USB_ClassInfo_Audio_Device_t My_Audio_Interface =\r
+ * {\r
+ * .Config =\r
+ * {\r
+ * .StreamingInterfaceNumber = 1,\r
+ * .DataINEndpoint =\r
+ * {\r
+ * .Address = (ENDPOINT_DIR_IN | 1),\r
+ * .Size = 64,\r
+ * .Banks = 1,\r
+ * },\r
+ * },\r
+ * };\r
+ * \endcode\r
+ *\r
+ * \note The class driver's configuration parameters should match those used in the device's descriptors that are\r
+ * sent to the host.\r
+ *\r
+ * To initialize the Class driver instance, the driver's <tt><i>{Class Name}</i>_Device_ConfigureEndpoints()</tt> function\r
+ * should be called in response to the \ref EVENT_USB_Device_ConfigurationChanged() event. This function will return a\r
+ * boolean true value if the driver successfully initialized the instance. Like all the class driver functions, this function\r
+ * takes in the address of the specific instance you wish to initialize - in this manner, multiple separate instances of\r
+ * the same class type can be initialized like this:\r
+ *\r
+ * \code\r
+ * void EVENT_USB_Device_ConfigurationChanged(void)\r
+ * {\r
+ * LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
+ * \r
+ * if (!(Audio_Device_ConfigureEndpoints(&My_Audio_Interface)))\r
+ * LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
+ * }\r
+ * \endcode\r
+ *\r
+ * Once initialized, it is important to maintain the class driver's state by repeatedly calling the Class Driver's\r
+ * <tt><i>{Class Name}</i>_Device_USBTask()</tt> function in the main program loop. The exact implementation of this\r
+ * function varies between class drivers, and can be used for any internal class driver purpose to maintain each\r
+ * instance. Again, this function uses the address of the instance to operate on, and thus needs to be called for each\r
+ * separate instance, just like the main USB maintenance routine \ref USB_USBTask():\r
+ *\r
+ * \code\r
+ * int main(void)\r
+ * {\r
+ * SetupHardware();\r
+ * \r
+ * LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
+ * \r
+ * for (;;)\r
+ * {\r
+ * if (USB_DeviceState != DEVICE_STATE_Configured)\r
+ * Create_And_Process_Samples();\r
+ * \r
+ * Audio_Device_USBTask(&My_Audio_Interface);\r
+ * USB_USBTask();\r
+ * }\r
+ * }\r
+ * \endcode\r
+ *\r
+ * The final standardized Device Class Driver function is the Control Request handler function\r
+ * <tt><i>{Class Name}</i>_Device_ProcessControlRequest()</tt>, which should be called when the\r
+ * \ref EVENT_USB_Device_ControlRequest() event fires. This function should also be called for\r
+ * each class driver instance, using the address of the instance to operate on as the function's\r
+ * parameter. The request handler will abort if it is determined that the current request is not\r
+ * targeted at the given class driver instance, thus these methods can safely be called\r
+ * one-after-another in the event handler with no form of error checking:\r
+ *\r
+ * \code\r
+ * void EVENT_USB_Device_ControlRequest(void)\r
+ * {\r
+ * Audio_Device_ProcessControlRequest(&My_Audio_Interface);\r
+ * }\r
+ * \endcode\r
+ *\r
+ * Each class driver may also define a set of callback functions (which are prefixed by \c CALLBACK_*\r
+ * in the function's name) which <b>must</b> also be added to the user application - refer to each\r
+ * individual class driver's documentation for mandatory callbacks. In addition, each class driver may\r
+ * also define a set of events (identifiable by their prefix of \c EVENT_* in the function's name), which\r
+ * the user application <b>may</b> choose to implement, or ignore if not needed.\r
+ *\r
+ * The individual Device Mode Class Driver documentation contains more information on the non-standardized,\r
+ * class-specific functions which the user application can then use on the driver instances, such as data\r
+ * read and write routines. See each driver's individual documentation for more information on the\r
+ * class-specific functions.\r
+ *\r
+ * \subsection Sec_ClassDriverHost Host Mode Class Drivers\r
+ * Implementing a Host Mode Class Driver in a user application requires a number of steps to be followed. Firstly,\r
+ * the module configuration and state structure must be added to the project source. These structures are named in a\r
+ * similar manner between classes, that of <tt>USB_ClassInfo_<b>{Class Name}</b>_Host_t</tt>, and are used to hold the\r
+ * complete state and configuration for each class instance. Multiple class instances is where the power of the class\r
+ * drivers lie; multiple interfaces of the same class simply require more instances of the Class Driver's \c USB_ClassInfo_*\r
+ * structure.\r
+ *\r
+ * Inside the \c USB_ClassInfo_* structure lies two sections, a \c Config section, and a \c State section. The \c Config\r
+ * section contains the instance's configuration parameters, and <b>must have all fields set by the user application</b>\r
+ * before the class driver is used. Each Device mode Class driver typically contains a set of configuration parameters\r
+ * for the endpoint size/number of the associated logical USB interface, plus any class-specific configuration parameters.\r
+ *\r
+ * The following is an example of a properly initialized instance of the MIDI Host Class Driver structure:\r
+ *\r
+ * \code\r
+ * USB_ClassInfo_MIDI_Host_t My_MIDI_Interface =\r
+ * {\r
+ * .Config =\r
+ * {\r
+ * .DataINPipe =\r
+ * {\r
+ * .Address = (PIPE_DIR_IN | 1),\r
+ * .Size = 64,\r
+ * .Banks = 1,\r
+ * },\r
+ * .DataOUTPipe =\r
+ * {\r
+ * .Address = (PIPE_DIR_OUT | 2),\r
+ * .Size = 64,\r
+ * .Banks = 1,\r
+ * },\r
+ * },\r
+ * };\r
+ * \endcode\r
+ *\r
+ * To initialize the Class driver instance, the driver's <tt><b>{Class Name}</b>_Host_ConfigurePipes()</tt> function\r
+ * should be called in response to the \c EVENT_USB_Host_DeviceEnumerationComplete() event firing. This function will\r
+ * will return an error code from the class driver's <tt><b>{Class Name}</b>_EnumerationFailure_ErrorCodes_t</tt> enum\r
+ * to indicate if the driver successfully initialized the instance and bound it to an interface in the attached device.\r
+ * Like all the class driver functions, this function takes in the address of the specific instance you wish to initialize -\r
+ * in this manner, multiple separate instances of the same class type can be initialized. A fragment of a Class Driver\r
+ * based Host mode application may look like the following:\r
+ *\r
+ * \code\r
+ * void EVENT_USB_Host_DeviceEnumerationComplete(void)\r
+ * {\r
+ * LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);\r
+ * \r
+ * uint16_t ConfigDescriptorSize;\r
+ * uint8_t ConfigDescriptorData[512];\r
+ * \r
+ * if (USB_Host_GetDeviceConfigDescriptor(1, &ConfigDescriptorSize, ConfigDescriptorData,\r
+ * sizeof(ConfigDescriptorData)) != HOST_GETCONFIG_Successful)\r
+ * {\r
+ * LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
+ * return;\r
+ * }\r
+ * \r
+ * if (MIDI_Host_ConfigurePipes(&Keyboard_MIDI_Interface,\r
+ * ConfigDescriptorSize, ConfigDescriptorData) != MIDI_ENUMERROR_NoError)\r
+ * {\r
+ * LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
+ * return;\r
+ * }\r
+ * \r
+ * if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)\r
+ * {\r
+ * LEDs_SetAllLEDs(LEDMASK_USB_ERROR);\r
+ * return;\r
+ * }\r
+ * \r
+ * LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
+ * }\r
+ * \endcode\r
+ *\r
+ * Note that the function also requires the device's configuration descriptor so that it can determine which interface\r
+ * in the device to bind to - this can be retrieved as shown in the above fragment using the\r
+ * \ref USB_Host_GetDeviceConfigDescriptor() function. If the device does not implement the interface the class driver\r
+ * is looking for, if all the matching interfaces are already bound to class driver instances or if an error occurs while\r
+ * binding to a device interface (for example, a device endpoint bank larger that the maximum supported bank size is used)\r
+ * the configuration will fail.\r
+ *\r
+ * To complete the device enumeration after binding the host mode Class Drivers to the attached device, a call to\r
+ * \c USB_Host_SetDeviceConfiguration() must be made. If the device configuration is not set within the \r
+ * \c EVENT_USB_Host_DeviceEnumerationComplete() event, the host still will assume the device enumeration has failed.\r
+ *\r
+ * Once initialized, it is important to maintain the class driver's state by repeatedly calling the Class Driver's\r
+ * <tt><b>{Class Name}</b>_Host_USBTask()</tt> function in the main program loop. The exact implementation of this\r
+ * function varies between class drivers, and can be used for any internal class driver purpose to maintain each\r
+ * instance. Again, this function uses the address of the instance to operate on, and thus needs to be called for each\r
+ * separate instance, just like the main USB maintenance routine \ref USB_USBTask():\r
+ *\r
+ * \code\r
+ * int main(void)\r
+ * {\r
+ * SetupHardware();\r
+ * \r
+ * LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
+ * \r
+ * for (;;)\r
+ * {\r
+ * if (USB_HostState != HOST_STATE_Configured)\r
+ * Create_And_Process_Samples();\r
+ * \r
+ * MIDI_Host_USBTask(&My_Audio_Interface);\r
+ * USB_USBTask();\r
+ * }\r
+ * }\r
+ * \endcode\r
+ *\r
+ * Each class driver may also define a set of callback functions (which are prefixed by \c CALLBACK_*\r
+ * in the function's name) which <b>must</b> also be added to the user application - refer to each\r
+ * individual class driver's documentation for mandatory callbacks. In addition, each class driver may\r
+ * also define a set of events (identifiable by their prefix of \c EVENT_* in the function's name), which\r
+ * the user application <b>may</b> choose to implement, or ignore if not needed.\r
+ *\r
+ * The individual Host Mode Class Driver documentation contains more information on the non-standardized,\r
+ * class-specific functions which the user application can then use on the driver instances, such as data\r
+ * read and write routines. See each driver's individual documentation for more information on the\r
+ * class-specific functions.\r
+ */\r
+\r
+#ifndef __USB_H__\r
+#define __USB_H__\r
+\r
+ /* Macros: */\r
+ #define __INCLUDE_FROM_USB_DRIVER\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+ #include "Core/USBMode.h"\r
+\r
+ /* Includes: */\r
+ #include "Core/USBTask.h"\r
+ #include "Core/Events.h"\r
+ #include "Core/StdDescriptors.h"\r
+ #include "Core/ConfigDescriptors.h"\r
+ #include "Core/USBController.h"\r
+ #include "Core/USBInterrupt.h"\r
+\r
+ #if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)\r
+ #include "Core/Host.h"\r
+ #include "Core/Pipe.h"\r
+ #include "Core/HostStandardReq.h"\r
+ #include "Core/PipeStream.h"\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)\r
+ #include "Core/Device.h"\r
+ #include "Core/Endpoint.h"\r
+ #include "Core/DeviceStandardReq.h"\r
+ #include "Core/EndpointStream.h"\r
+ #endif\r
+\r
+ #if defined(USB_CAN_BE_BOTH) || defined(__DOXYGEN__)\r
+ #include "Core/OTG.h"\r
+ #endif\r
+\r
+ #include "Class/AndroidAccessoryClass.h"\r
+ #include "Class/AudioClass.h"\r
+ #include "Class/CDCClass.h"\r
+ #include "Class/HIDClass.h"\r
+ #include "Class/MassStorageClass.h"\r
+ #include "Class/MIDIClass.h"\r
+ #include "Class/PrinterClass.h"\r
+ #include "Class/RNDISClass.h"\r
+ #include "Class/StillImageClass.h"\r
+\r
+#endif\r
+\r
--- /dev/null
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+\r
+\r
+Permission to use, copy, modify, and distribute this software\r
+and its documentation for any purpose is hereby granted without\r
+fee, provided that the above copyright notice appear in all\r
+copies and that both that the copyright notice and this\r
+permission notice and warranty disclaimer appear in supporting\r
+documentation, and that the name of the author not be used in\r
+advertising or publicity pertaining to distribution of the\r
+software without specific, written prior permission.\r
+\r
+The author disclaim all warranties with regard to this\r
+software, including all implied warranties of merchantability\r
+and fitness. In no event shall the author be liable for any\r
+special, indirect or consequential damages or any damages\r
+whatsoever resulting from loss of use, data or profits, whether\r
+in an action of contract, negligence or other tortious action,\r
+arising out of or in connection with the use or performance of\r
+this software.
\ No newline at end of file
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Architecture Specific Hardware Platform Drivers.\r
+ *\r
+ * This file is the master dispatch header file for the device-specific hardware platform drivers, for low level\r
+ * hardware configuration and management. The platform drivers are a set of drivers which are designed to provide\r
+ * a high level management layer for the various low level system functions such as clock control and interrupt\r
+ * management.\r
+ *\r
+ * User code may choose to either include this master dispatch header file to include all available platform\r
+ * driver header files for the current architecture, or may choose to only include the specific platform driver\r
+ * modules required for a particular application.\r
+ */\r
+\r
+/** \defgroup Group_PlatformDrivers System Platform Drivers - LUFA/Platform/Platform.h\r
+ * \brief Hardware platform drivers.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - <b>UC3 Architecture Only:</b> LUFA/Platform/UC3/InterruptManagement.c <i>(Makefile source module name: LUFA_SRC_PLATFORM)</i> \r
+ * - <b>UC3 Architecture Only:</b> LUFA/Platform/UC3/Exception.S <i>(Makefile source module name: LUFA_SRC_PLATFORM)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Device-specific hardware platform drivers, for low level hardware configuration and management. The platform\r
+ * drivers are a set of drivers which are designed to provide a high level management layer for the various low level\r
+ * system functions such as clock control and interrupt management.\r
+ *\r
+ * User code may choose to either include this master dispatch header file to include all available platform\r
+ * driver header files for the current architecture, or may choose to only include the specific platform driver\r
+ * modules required for a particular application.\r
+ *\r
+ * \note The exact APIs and availability of sub-modules within the platform driver group may vary depending on the\r
+ * target used - see individual target module documentation for the API specific to your target processor.\r
+ */\r
+\r
+#ifndef __LUFA_PLATFORM_H__\r
+#define __LUFA_PLATFORM_H__\r
+\r
+ /* Includes: */\r
+ #include "../Common/Common.h"\r
+\r
+ /* Includes: */\r
+ #if (ARCH == ARCH_UC3)\r
+ #include "UC3/ClockManagement.h"\r
+ #include "UC3/InterruptManagement.h"\r
+ #elif (ARCH == ARCH_XMEGA)\r
+ #include "XMEGA/ClockManagement.h"\r
+ #endif\r
+\r
+#endif\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Module Clock Driver for the AVR32 UC3 microcontrollers.\r
+ *\r
+ * Clock management driver for the AVR32 UC3 microcontrollers. This driver allows for the configuration\r
+ * of the various clocks within the device to clock the various peripherals.\r
+ */\r
+\r
+/** \ingroup Group_PlatformDrivers_UC3\r
+ * \defgroup Group_PlatformDrivers_UC3Clocks Clock Management Driver - LUFA/Platform/UC3/ClockManagement.h\r
+ * \brief Module Clock Driver for the AVR32 UC3 microcontrollers.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Clock management driver for the AVR32 UC3 microcontrollers. This driver allows for the configuration\r
+ * of the various clocks within the device to clock the various peripherals.\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * #include <LUFA/Platform/UC3/ClockManagement.h>\r
+ * \r
+ * void main(void)\r
+ * {\r
+ * // Start the master external oscillator which will be used as the main clock reference\r
+ * AVR32CLK_StartExternalOscillator(0, EXOSC_MODE_8MHZ_OR_MORE, EXOSC_START_0CLK);\r
+ * \r
+ * // Start the PLL for the CPU clock, switch CPU to it\r
+ * AVR32CLK_StartPLL(0, CLOCK_SRC_OSC0, 12000000, F_CPU);\r
+ * AVR32CLK_SetCPUClockSource(CLOCK_SRC_PLL0, F_CPU);\r
+ * \r
+ * // Start the PLL for the USB Generic Clock module\r
+ * AVR32CLK_StartPLL(1, CLOCK_SRC_OSC0, 12000000, 48000000);\r
+ * }\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _UC3_CLOCK_MANAGEMENT_H_\r
+#define _UC3_CLOCK_MANAGEMENT_H_\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Enum for the possible external oscillator types. */\r
+ enum UC3_Extern_OSC_ClockTypes_t\r
+ {\r
+ EXOSC_MODE_CLOCK = AVR32_PM_OSCCTRL0_MODE_EXT_CLOCK, /**< External clock (non-crystal) mode. */\r
+ EXOSC_MODE_900KHZ_MAX = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G0, /**< External crystal oscillator equal to or slower than 900KHz. */\r
+ EXOSC_MODE_3MHZ_MAX = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G1, /**< External crystal oscillator equal to or slower than 3MHz. */\r
+ EXOSC_MODE_8MHZ_MAX = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G2, /**< External crystal oscillator equal to or slower than 8MHz. */\r
+ EXOSC_MODE_8MHZ_OR_MORE = AVR32_PM_OSCCTRL0_MODE_CRYSTAL_G3, /**< External crystal oscillator equal to or faster than 8MHz. */\r
+ };\r
+\r
+ /** Enum for the possible external oscillator startup times. */\r
+ enum UC3_Extern_OSC_ClockStartup_t\r
+ {\r
+ EXOSC_START_0CLK = AVR32_PM_OSCCTRL0_STARTUP_0_RCOSC, /**< Immediate startup, no delay. */\r
+ EXOSC_START_64CLK = AVR32_PM_OSCCTRL0_STARTUP_64_RCOSC, /**< Wait 64 clock cycles before startup for stability. */\r
+ EXOSC_START_128CLK = AVR32_PM_OSCCTRL0_STARTUP_128_RCOSC, /**< Wait 128 clock cycles before startup for stability. */\r
+ EXOSC_START_2048CLK = AVR32_PM_OSCCTRL0_STARTUP_2048_RCOSC, /**< Wait 2048 clock cycles before startup for stability. */\r
+ EXOSC_START_4096CLK = AVR32_PM_OSCCTRL0_STARTUP_4096_RCOSC, /**< Wait 4096 clock cycles before startup for stability. */\r
+ EXOSC_START_8192CLK = AVR32_PM_OSCCTRL0_STARTUP_8192_RCOSC, /**< Wait 8192 clock cycles before startup for stability. */\r
+ EXOSC_START_16384CLK = AVR32_PM_OSCCTRL0_STARTUP_16384_RCOSC, /**< Wait 16384 clock cycles before startup for stability. */\r
+ };\r
+\r
+ /** Enum for the possible module clock sources. */\r
+ enum UC3_System_ClockSource_t\r
+ {\r
+ CLOCK_SRC_SLOW_CLK = 0, /**< Clock sourced from the internal slow clock. */\r
+ CLOCK_SRC_OSC0 = 1, /**< Clock sourced from the Oscillator 0 clock. */\r
+ CLOCK_SRC_OSC1 = 2, /**< Clock sourced from the Oscillator 1 clock. */\r
+ CLOCK_SRC_PLL0 = 3, /**< Clock sourced from the PLL 0 clock. */\r
+ CLOCK_SRC_PLL1 = 4, /**< Clock sourced from the PLL 1 clock. */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Starts the given external oscillator of the UC3 microcontroller, with the given options. This routine blocks until\r
+ * the oscillator is ready for use.\r
+ *\r
+ * \param[in] Channel Index of the external oscillator to start.\r
+ * \param[in] Type Type of clock attached to the given oscillator channel, a value from \ref UC3_Extern_OSC_ClockTypes_t.\r
+ * \param[in] Startup Statup time of the external oscillator, a value from \ref UC3_Extern_OSC_ClockStartup_t.\r
+ *\r
+ * \return Boolean \c true if the external oscillator was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool AVR32CLK_StartExternalOscillator(const uint8_t Channel,\r
+ const uint8_t Type,\r
+ const uint8_t Startup) ATTR_ALWAYS_INLINE;\r
+ static inline bool AVR32CLK_StartExternalOscillator(const uint8_t Channel,\r
+ const uint8_t Type,\r
+ const uint8_t Startup)\r
+ {\r
+ switch (Channel)\r
+ {\r
+ case 0:\r
+ AVR32_PM.OSCCTRL0.startup = Startup;\r
+ AVR32_PM.OSCCTRL0.mode = Type;\r
+ break;\r
+ case 1:\r
+ AVR32_PM.OSCCTRL1.startup = Startup;\r
+ AVR32_PM.OSCCTRL1.mode = Type;\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+\r
+ AVR32_PM.mcctrl |= (1 << (AVR32_PM_MCCTRL_OSC0EN_OFFSET + Channel));\r
+\r
+ while (!(AVR32_PM.poscsr & (1 << (AVR32_PM_POSCSR_OSC0RDY_OFFSET + Channel))));\r
+ return true;\r
+ }\r
+\r
+ /** Stops the given external oscillator of the UC3 microcontroller.\r
+ *\r
+ * \param[in] Channel Index of the external oscillator to stop.\r
+ */\r
+ static inline void AVR32CLK_StopExternalOscillator(const uint8_t Channel) ATTR_ALWAYS_INLINE;\r
+ static inline void AVR32CLK_StopExternalOscillator(const uint8_t Channel)\r
+ {\r
+ AVR32_PM.mcctrl &= ~(1 << (AVR32_PM_MCCTRL_OSC0EN_OFFSET + Channel));\r
+ }\r
+\r
+ /** Starts the given PLL of the UC3 microcontroller, with the given options. This routine blocks until the PLL is ready for use.\r
+ *\r
+ * \attention The output frequency must be equal to or greater than the source frequency.\r
+ *\r
+ * \param[in] Channel Index of the PLL to start.\r
+ * \param[in] Source Clock source for the PLL, a value from \ref UC3_System_ClockSource_t.\r
+ * \param[in] SourceFreq Frequency of the PLL's clock source, in Hz.\r
+ * \param[in] Frequency Target frequency of the PLL's output.\r
+ *\r
+ * \return Boolean \c true if the PLL was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool AVR32CLK_StartPLL(const uint8_t Channel,\r
+ const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency) ATTR_ALWAYS_INLINE;\r
+ static inline bool AVR32CLK_StartPLL(const uint8_t Channel,\r
+ const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency)\r
+ {\r
+ if (SourceFreq > Frequency)\r
+ return false;\r
+\r
+ switch (Source)\r
+ {\r
+ case CLOCK_SRC_OSC0:\r
+ AVR32_PM.PLL[Channel].pllosc = 0;\r
+ break;\r
+ case CLOCK_SRC_OSC1:\r
+ AVR32_PM.PLL[Channel].pllosc = 1;\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+\r
+ AVR32_PM.PLL[Channel].pllmul = (Frequency / SourceFreq) ? (((Frequency / SourceFreq) - 1) / 2) : 0;\r
+ AVR32_PM.PLL[Channel].plldiv = 0;\r
+ AVR32_PM.PLL[Channel].pllen = true;\r
+\r
+ while (!(AVR32_PM.poscsr & (1 << (AVR32_PM_POSCSR_LOCK0_OFFSET + Channel))));\r
+ return true;\r
+ }\r
+\r
+ /** Stops the given PLL of the UC3 microcontroller.\r
+ *\r
+ * \param[in] Channel Index of the PLL to stop.\r
+ */\r
+ static inline void AVR32CLK_StopPLL(const uint8_t Channel) ATTR_ALWAYS_INLINE;\r
+ static inline void AVR32CLK_StopPLL(const uint8_t Channel)\r
+ {\r
+ AVR32_PM.PLL[Channel].pllen = false;\r
+ }\r
+\r
+ /** Starts the given Generic Clock of the UC3 microcontroller, with the given options.\r
+ *\r
+ * \param[in] Channel Index of the Generic Clock to start.\r
+ * \param[in] Source Clock source for the Generic Clock, a value from \ref UC3_System_ClockSource_t.\r
+ * \param[in] SourceFreq Frequency of the Generic Clock's clock source, in Hz.\r
+ * \param[in] Frequency Target frequency of the Generic Clock's output.\r
+ *\r
+ * \return Boolean \c true if the Generic Clock was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool AVR32CLK_StartGenericClock(const uint8_t Channel,\r
+ const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency) ATTR_ALWAYS_INLINE;\r
+ static inline bool AVR32CLK_StartGenericClock(const uint8_t Channel,\r
+ const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency)\r
+ {\r
+ if (Channel >= AVR32_PM_GCLK_NUM)\r
+ return false;\r
+\r
+ if (SourceFreq < Frequency)\r
+ return false;\r
+\r
+ switch (Source)\r
+ {\r
+ case CLOCK_SRC_OSC0:\r
+ AVR32_PM.GCCTRL[Channel].pllsel = false;\r
+ AVR32_PM.GCCTRL[Channel].oscsel = 0;\r
+ break;\r
+ case CLOCK_SRC_OSC1:\r
+ AVR32_PM.GCCTRL[Channel].pllsel = false;\r
+ AVR32_PM.GCCTRL[Channel].oscsel = 1;\r
+ break;\r
+ case CLOCK_SRC_PLL0:\r
+ AVR32_PM.GCCTRL[Channel].pllsel = true;\r
+ AVR32_PM.GCCTRL[Channel].oscsel = 0;\r
+ break;\r
+ case CLOCK_SRC_PLL1:\r
+ AVR32_PM.GCCTRL[Channel].pllsel = true;\r
+ AVR32_PM.GCCTRL[Channel].oscsel = 1;\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+\r
+ AVR32_PM.GCCTRL[Channel].diven = (SourceFreq > Frequency) ? true : false;\r
+ AVR32_PM.GCCTRL[Channel].div = (((SourceFreq / Frequency) - 1) / 2);\r
+ AVR32_PM.GCCTRL[Channel].cen = true;\r
+\r
+ return true;\r
+ }\r
+\r
+ /** Stops the given generic clock of the UC3 microcontroller.\r
+ *\r
+ * \param[in] Channel Index of the generic clock to stop.\r
+ *\r
+ * \return Boolean \c true if the generic clock was sucessfully stopped, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool AVR32CLK_StopGenericClock(const uint8_t Channel) ATTR_ALWAYS_INLINE;\r
+ static inline bool AVR32CLK_StopGenericClock(const uint8_t Channel)\r
+ {\r
+ if (Channel >= AVR32_PM_GCLK_NUM)\r
+ return false;\r
+ \r
+ AVR32_PM.GCCTRL[Channel].cen = false;\r
+ \r
+ return true;\r
+ }\r
+\r
+ /** Sets the clock source for the main microcontroller core. The given clock source should be configured\r
+ * and ready for use before this function is called.\r
+ *\r
+ * This function will configure the FLASH controller's wait states automatically to suit the given clock source.\r
+ *\r
+ * \param[in] Source Clock source for the CPU core, a value from \ref UC3_System_ClockSource_t.\r
+ * \param[in] SourceFreq Frequency of the CPU core's clock source, in Hz.\r
+ *\r
+ * \return Boolean \c true if the CPU core clock was sucessfully altered, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool AVR32CLK_SetCPUClockSource(const uint8_t Source,\r
+ const uint32_t SourceFreq) ATTR_ALWAYS_INLINE;\r
+ static inline bool AVR32CLK_SetCPUClockSource(const uint8_t Source,\r
+ const uint32_t SourceFreq)\r
+ {\r
+ if (SourceFreq > AVR32_PM_CPU_MAX_FREQ)\r
+ return false;\r
+\r
+ AVR32_FLASHC.FCR.fws = (SourceFreq > AVR32_FLASHC_FWS_0_MAX_FREQ) ? true : false;\r
+ \r
+ switch (Source)\r
+ {\r
+ #if defined(AVR32_PM_MCCTRL_MCSEL_SLOW)\r
+ case CLOCK_SRC_SLOW_CLK:\r
+ AVR32_PM.MCCTRL.mcsel = AVR32_PM_MCCTRL_MCSEL_SLOW;\r
+ break;\r
+ #endif\r
+ #if defined(AVR32_PM_MCCTRL_MCSEL_OSC0)\r
+ case CLOCK_SRC_OSC0:\r
+ AVR32_PM.MCCTRL.mcsel = AVR32_PM_MCCTRL_MCSEL_OSC0;\r
+ break;\r
+ #endif\r
+ #if defined(AVR32_PM_MCCTRL_MCSEL_PLL0)\r
+ case CLOCK_SRC_PLL0:\r
+ AVR32_PM.MCCTRL.mcsel = AVR32_PM_MCCTRL_MCSEL_PLL0;\r
+ break;\r
+ #endif\r
+ default:\r
+ return false;\r
+ }\r
+\r
+ return true;\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2011.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#if defined(__AVR32__)\r
+#include <avr32/io.h>\r
+\r
+.section .exception_handlers, "ax", @progbits\r
+\r
+// ================= EXCEPTION TABLE ================\r
+.balign 0x200\r
+.global EVBA_Table\r
+EVBA_Table:\r
+\r
+.org 0x000\r
+Exception_Unrecoverable_Exception:\r
+ rjmp $\r
+.org 0x004\r
+Exception_TLB_Multiple_Hit:\r
+ rjmp $\r
+.org 0x008\r
+Exception_Bus_Error_Data_Fetch:\r
+ rjmp $\r
+.org 0x00C\r
+Exception_Bus_Error_Instruction_Fetch:\r
+ rjmp $\r
+.org 0x010\r
+Exception_NMI:\r
+ rjmp $\r
+.org 0x014\r
+Exception_Instruction_Address:\r
+ rjmp $\r
+.org 0x018\r
+Exception_ITLB_Protection:\r
+ rjmp $\r
+.org 0x01C\r
+Exception_OCD_Breakpoint:\r
+ rjmp $\r
+.org 0x020\r
+Exception_Illegal_Opcode:\r
+ rjmp $\r
+.org 0x024\r
+Exception_Unimplemented_Instruction:\r
+ rjmp $\r
+.org 0x028\r
+Exception_Privilege_Violation:\r
+ rjmp $\r
+.org 0x02C\r
+Exception_Floating_Point:\r
+ rjmp $\r
+.org 0x030\r
+Exception_Coprocessor_Absent:\r
+ rjmp $\r
+.org 0x034\r
+Exception_Data_Address_Read:\r
+ rjmp $\r
+.org 0x038\r
+Exception_Data_Address_Write:\r
+ rjmp $\r
+.org 0x03C\r
+Exception_DTLB_Protection_Read:\r
+ rjmp $\r
+.org 0x040\r
+Exception_DTLB_Protection_Write:\r
+ rjmp $\r
+.org 0x044\r
+Exception_DTLB_Modified:\r
+ rjmp $\r
+.org 0x050\r
+Exception_ITLB_Miss:\r
+ rjmp $\r
+.org 0x060\r
+Exception_DTLB_Miss_Read:\r
+ rjmp $\r
+.org 0x070\r
+Exception_DTLB_Miss_Write:\r
+ rjmp $\r
+.org 0x100\r
+Exception_Supervisor_Call:\r
+ rjmp $\r
+// ============== END OF EXCEPTION TABLE =============\r
+\r
+// ============= GENERAL INTERRUPT HANDLER ===========\r
+.balign 4\r
+.irp Level, 0, 1, 2, 3\r
+Exception_INT\Level:\r
+ mov r12, \Level\r
+ call INTC_GetInterruptHandler\r
+ mov pc, r12\r
+.endr\r
+// ========= END OF GENERAL INTERRUPT HANDLER ========\r
+\r
+// ====== GENERAL INTERRUPT HANDLER OFFSET TABLE ======\r
+.balign 4\r
+.global Autovector_Table\r
+Autovector_Table:\r
+.irp Level, 0, 1, 2, 3\r
+ .word ((AVR32_INTC_INT0 + \Level) << AVR32_INTC_IPR_INTLEVEL_OFFSET) | (Exception_INT\Level - EVBA_Table)\r
+.endr\r
+// === END OF GENERAL INTERRUPT HANDLER OFFSET TABLE ===\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+#include "../../Common/Common.h"\r
+#if (ARCH == ARCH_UC3)\r
+\r
+#define __INCLUDE_FROM_INTMANAGEMENT_C\r
+#include "InterruptManagement.h"\r
+\r
+/** Interrupt vector table, containing the ISR to call for each interrupt group */\r
+InterruptHandlerPtr_t InterruptHandlers[AVR32_INTC_NUM_INT_GRPS];\r
+\r
+/** ISR for unhandled interrupt groups */\r
+ISR(Unhandled_Interrupt)\r
+{\r
+ for (;;);\r
+}\r
+\r
+/** Retrieves the associated interrupt handler for the interrupt group currently being fired. This\r
+ * is called directly from the exception handler routine before dispatching to the ISR.\r
+ */\r
+InterruptHandlerPtr_t INTC_GetInterruptHandler(const uint_reg_t InterruptLevel)\r
+{\r
+ return InterruptHandlers[AVR32_INTC.icr[AVR32_INTC_INT3 - InterruptLevel]];\r
+}\r
+\r
+/** Initializes the interrupt controller ready to handle interrupts. This must be called at the\r
+ * start of the user program before any interrupts are registered or enabled.\r
+ */\r
+void INTC_Init(void)\r
+{\r
+ for (uint8_t InterruptGroup = 0; InterruptGroup < AVR32_INTC_NUM_INT_GRPS; InterruptGroup++)\r
+ {\r
+ InterruptHandlers[InterruptGroup] = Unhandled_Interrupt;\r
+ AVR32_INTC.ipr[InterruptGroup] = Autovector_Table[AVR32_INTC_INT0];\r
+ }\r
+\r
+ __builtin_mtsr(AVR32_EVBA, (uintptr_t)&EVBA_Table);\r
+}\r
+\r
+#endif\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Interrupt Controller Driver for the AVR32 UC3 microcontrollers.\r
+ *\r
+ * Interrupt controller driver for the AVR32 UC3 microcontrollers, for the configuration of interrupt\r
+ * handlers within the device.\r
+ */\r
+\r
+/** \ingroup Group_PlatformDrivers_UC3\r
+ * \defgroup Group_PlatformDrivers_UC3Interrupts Interrupt Controller Driver - LUFA/Platform/UC3/InterruptManagement.h\r
+ * \brief Interrupt Controller Driver for the AVR32 UC3 microcontrollers.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - LUFA/Platform/UC3/InterruptManagement.c <i>(Makefile source module name: LUFA_SRC_PLATFORM)</i>\r
+ * - LUFA/Platform/UC3/Exception.S <i>(Makefile source module name: LUFA_SRC_PLATFORM)</i>\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Interrupt controller driver for the AVR32 UC3 microcontrollers, for the configuration of interrupt\r
+ * handlers within the device.\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * #include <LUFA/Platform/UC3/InterruptManagement.h>\r
+ * \r
+ * ISR(USB_Group_IRQ_Handler)\r
+ * {\r
+ * // USB group handler code here\r
+ * }\r
+ * \r
+ * void main(void)\r
+ * {\r
+ * INTC_Init();\r
+ * INTC_RegisterGroupHandler(INTC_IRQ_GROUP(AVR32_USBB_IRQ), AVR32_INTC_INT0, USB_Group_IRQ_Handler);\r
+ * }\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _UC3_INTERRUPT_MANAGEMENT_H_\r
+#define _UC3_INTERRUPT_MANAGEMENT_H_\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Type Defines: */\r
+ typedef void (*InterruptHandlerPtr_t)(void);\r
+\r
+ /* External Variables: */\r
+ #if defined(__INCLUDE_FROM_INTMANAGEMENT_C)\r
+ extern const void EVBA_Table;\r
+ #endif\r
+ extern InterruptHandlerPtr_t InterruptHandlers[AVR32_INTC_NUM_INT_GRPS];\r
+ extern const uint32_t Autovector_Table[];\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Converts a given interrupt index into its associated interrupt group.\r
+ *\r
+ * \param[in] IRQIndex Index of the interrupt request to convert.\r
+ *\r
+ * \return Interrupt group number associated with the interrupt index.\r
+ */\r
+ #define INTC_IRQ_GROUP(IRQIndex) (IRQIndex / 32)\r
+\r
+ /** Converts a given interrupt index into its associated interrupt line.\r
+ *\r
+ * \param[in] IRQIndex Index of the interrupt request to convert.\r
+ *\r
+ * \return Interrupt line number associated with the interrupt index.\r
+ */\r
+ #define INTC_IRQ_LINE(IRQIndex) (IRQIndex % 32)\r
+\r
+ /* Function Prototypes: */\r
+ void INTC_Init(void); \r
+ InterruptHandlerPtr_t INTC_GetInterruptHandler(const uint_reg_t InterruptLevel);\r
+\r
+ /* Inline Functions: */\r
+ /** Registers a handler for a given interrupt group. On the AVR32 UC3 devices, interrupts are grouped by\r
+ * peripheral. To save on SRAM used, a single ISR handles all interrupt lines within a single group - to\r
+ * determine the exact line that has interrupted within the group ISR handler, use \ref INTC_GetGroupInterrupts().\r
+ *\r
+ * If multiple interrupts with the same group are registered, the last registered handler will become the\r
+ * handler called for interrupts raised within that group.\r
+ *\r
+ * To obtain the group number of a specific interrupt index, use the \ref INTC_IRQ_GROUP() macro.\r
+ *\r
+ * \param[in] GroupNumber Group number of the interrupt group to register a handler for.\r
+ * \param[in] InterruptLevel Priority level for the specified interrupt, a \c AVR32_INTC_INT* mask.\r
+ * \param[in] Handler Address of the ISR handler for the interrupt group.\r
+ */\r
+ static inline void INTC_RegisterGroupHandler(const uint16_t GroupNumber,\r
+ const uint8_t InterruptLevel,\r
+ const InterruptHandlerPtr_t Handler) ATTR_ALWAYS_INLINE;\r
+ static inline void INTC_RegisterGroupHandler(const uint16_t GroupNumber,\r
+ const uint8_t InterruptLevel,\r
+ const InterruptHandlerPtr_t Handler)\r
+ {\r
+ InterruptHandlers[GroupNumber] = Handler;\r
+ AVR32_INTC.ipr[GroupNumber] = Autovector_Table[InterruptLevel];\r
+ }\r
+\r
+ /** Retrieves the pending interrupts for a given interrupt group. The result of this function should be masked\r
+ * against interrupt request indexes converted to a request line number via the \ref INTC_IRQ_LINE() macro. To\r
+ * obtain the group number of a given interrupt request, use the \ref INTC_IRQ_GROUP() macro.\r
+ *\r
+ * \param[in] GroupNumber Group number of the interrupt group to check.\r
+ *\r
+ * \return Mask of pending interrupt lines for the given interrupt group.\r
+ */\r
+ static inline uint_reg_t INTC_GetGroupInterrupts(const uint16_t GroupNumber) ATTR_ALWAYS_INLINE;\r
+ static inline uint_reg_t INTC_GetGroupInterrupts(const uint16_t GroupNumber)\r
+ {\r
+ return AVR32_INTC.irr[GroupNumber];\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ * \brief Module Clock Driver for the AVR USB XMEGA microcontrollers.\r
+ *\r
+ * Clock management driver for the AVR USB XMEGA microcontrollers. This driver allows for the configuration\r
+ * of the various clocks within the device to clock the various peripherals.\r
+ */\r
+\r
+/** \ingroup Group_PlatformDrivers_XMEGA\r
+ * \defgroup Group_PlatformDrivers_XMEGAClocks Clock Management Driver - LUFA/Platform/XMEGA/ClockManagement.h\r
+ * \brief Module Clock Driver for the AVR USB XMEGA microcontrollers.\r
+ *\r
+ * \section Sec_Dependencies Module Source Dependencies\r
+ * The following files must be built with any user project that uses this module:\r
+ * - None\r
+ *\r
+ * \section Sec_ModDescription Module Description\r
+ * Clock management driver for the AVR USB XMEGA microcontrollers. This driver allows for the configuration\r
+ * of the various clocks within the device to clock the various peripherals.\r
+ *\r
+ * Usage Example:\r
+ * \code\r
+ * #include <LUFA/Platform/XMEGA/ClockManagement.h>\r
+ * \r
+ * void main(void)\r
+ * {\r
+ * // Start the PLL to multiply the 2MHz RC oscillator to F_CPU and switch the CPU core to run from it\r
+ * XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, F_CPU);\r
+ * XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL);\r
+ * \r
+ * // Start the 32MHz internal RC oscillator and start the DFLL to increase it to F_USB using the USB SOF as a reference\r
+ * XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ);\r
+ * XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, F_USB);\r
+ * }\r
+ * \endcode\r
+ *\r
+ * @{\r
+ */\r
+\r
+#ifndef _XMEGA_CLOCK_MANAGEMENT_H_\r
+#define _XMEGA_CLOCK_MANAGEMENT_H_\r
+\r
+ /* Includes: */\r
+ #include "../../Common/Common.h"\r
+\r
+ /* Enable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ extern "C" {\r
+ #endif\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Enum for the possible external oscillator frequency ranges. */\r
+ enum XMEGA_Extern_OSC_ClockFrequency_t\r
+ {\r
+ EXOSC_FREQ_2MHZ_MAX = OSC_FRQRANGE_04TO2_gc, /**< External crystal oscillator equal to or slower than 2MHz. */\r
+ EXOSC_FREQ_9MHZ_MAX = OSC_FRQRANGE_2TO9_gc, /**< External crystal oscillator equal to or slower than 9MHz. */\r
+ EXOSC_FREQ_12MHZ_MAX = OSC_FRQRANGE_9TO12_gc, /**< External crystal oscillator equal to or slower than 12MHz. */\r
+ EXOSC_FREQ_16MHZ_MAX = OSC_FRQRANGE_12TO16_gc, /**< External crystal oscillator equal to or slower than 16MHz. */\r
+ };\r
+\r
+ /** Enum for the possible external oscillator startup times. */\r
+ enum XMEGA_Extern_OSC_ClockStartup_t\r
+ {\r
+ EXOSC_START_6CLK = OSC_XOSCSEL_EXTCLK_gc, /**< Wait 6 clock cycles before startup (external clock). */\r
+ EXOSC_START_32KCLK = OSC_XOSCSEL_32KHz_gc, /**< Wait 32K clock cycles before startup (32.768KHz crystal). */\r
+ EXOSC_START_256CLK = OSC_XOSCSEL_XTAL_256CLK_gc, /**< Wait 256 clock cycles before startup. */\r
+ EXOSC_START_1KCLK = OSC_XOSCSEL_XTAL_1KCLK_gc, /**< Wait 1K clock cycles before startup. */\r
+ EXOSC_START_16KCLK = OSC_XOSCSEL_XTAL_16KCLK_gc, /**< Wait 16K clock cycles before startup. */\r
+ };\r
+\r
+ /** Enum for the possible module clock sources. */\r
+ enum XMEGA_System_ClockSource_t\r
+ {\r
+ CLOCK_SRC_INT_RC2MHZ = 0, /**< Clock sourced from the Internal 2MHz RC Oscillator clock. */\r
+ CLOCK_SRC_INT_RC32MHZ = 1, /**< Clock sourced from the Internal 32MHz RC Oscillator clock. */\r
+ CLOCK_SRC_INT_RC32KHZ = 2, /**< Clock sourced from the Internal 32KHz RC Oscillator clock. */\r
+ CLOCK_SRC_XOSC = 3, /**< Clock sourced from the External Oscillator clock. */\r
+ CLOCK_SRC_PLL = 4, /**< Clock sourced from the Internal PLL clock. */\r
+ };\r
+\r
+ /** Enum for the possible DFLL clock reference sources. */\r
+ enum XMEGA_System_DFLLReference_t\r
+ {\r
+ DFLL_REF_INT_RC32KHZ = 0, /**< Reference clock sourced from the Internal 32KHz RC Oscillator clock. */\r
+ DFLL_REF_EXT_RC32KHZ = 1, /**< Reference clock sourced from the External 32KHz RC Oscillator clock connected to TOSC pins. */\r
+ DFLL_REF_INT_USBSOF = 2, /**< Reference clock sourced from the USB Start Of Frame packets. */\r
+ };\r
+\r
+ /* Inline Functions: */\r
+ /** Write a value to a location protected by the XMEGA CCP protection mechanism. This function uses inline assembly to ensure that\r
+ * the protected address is written to within four clock cycles of the CCP key being written.\r
+ *\r
+ * \param[in] Address Address to write to, a memory address protected by the CCP mechanism\r
+ * \param[in] Value Value to write to the protected location\r
+ */\r
+ static inline void XMEGACLK_CCP_Write(volatile void* Address, const uint8_t Value) ATTR_ALWAYS_INLINE;\r
+ static inline void XMEGACLK_CCP_Write(volatile void* Address, const uint8_t Value)\r
+ {\r
+ __asm__ __volatile__ (\r
+ "out %0, __zero_reg__" "\n\t" /* Zero RAMPZ using fixed zero value register */\r
+ "movw r30, %1" "\n\t" /* Copy address to Z register pair */\r
+ "out %2, %3" "\n\t" /* Write key to CCP register */\r
+ "st Z, %4" "\n\t" /* Indirectly write value to address */\r
+ : /* No output operands */\r
+ : /* Input operands: */ "m" (RAMPZ), "e" (Address), "m" (CCP), "r" (CCP_IOREG_gc), "r" (Value)\r
+ : /* Clobbered registers: */ "r30", "r31"\r
+ ); \r
+ }\r
+\r
+ /** Starts the external oscillator of the XMEGA microcontroller, with the given options. This routine blocks until\r
+ * the oscillator is ready for use.\r
+ *\r
+ * \param[in] FreqRange Frequency range of the external oscillator, a value from \ref XMEGA_Extern_OSC_ClockFrequency_t.\r
+ * \param[in] Startup Startup time of the external oscillator, a value from \ref XMEGA_Extern_OSC_ClockStartup_t.\r
+ *\r
+ * \return Boolean \c true if the external oscillator was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool XMEGACLK_StartExternalOscillator(const uint8_t FreqRange,\r
+ const uint8_t Startup) ATTR_ALWAYS_INLINE;\r
+ static inline bool XMEGACLK_StartExternalOscillator(const uint8_t FreqRange,\r
+ const uint8_t Startup)\r
+ {\r
+ OSC.XOSCCTRL = (FreqRange | ((Startup == EXOSC_START_32KCLK) ? OSC_X32KLPM_bm : 0) | Startup);\r
+ OSC.CTRL |= OSC_XOSCEN_bm;\r
+\r
+ while (!(OSC.STATUS & OSC_XOSCRDY_bm));\r
+ return true;\r
+ }\r
+\r
+ /** Stops the external oscillator of the XMEGA microcontroller. */\r
+ static inline void XMEGACLK_StopExternalOscillator(void) ATTR_ALWAYS_INLINE;\r
+ static inline void XMEGACLK_StopExternalOscillator(void)\r
+ {\r
+ OSC.CTRL &= ~OSC_XOSCEN_bm;\r
+ }\r
+\r
+ /** Starts the given internal oscillator of the XMEGA microcontroller, with the given options. This routine blocks until\r
+ * the oscillator is ready for use.\r
+ *\r
+ * \param[in] Source Internal oscillator to start, a value from \ref XMEGA_System_ClockSource_t.\r
+ *\r
+ * \return Boolean \c true if the internal oscillator was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline uint8_t XMEGACLK_StartInternalOscillator(const uint8_t Source) ATTR_ALWAYS_INLINE;\r
+ static inline uint8_t XMEGACLK_StartInternalOscillator(const uint8_t Source)\r
+ {\r
+ switch (Source)\r
+ {\r
+ case CLOCK_SRC_INT_RC2MHZ:\r
+ OSC.CTRL |= OSC_RC2MEN_bm;\r
+ while (!(OSC.STATUS & OSC_RC2MRDY_bm));\r
+ return true;\r
+ case CLOCK_SRC_INT_RC32MHZ:\r
+ OSC.CTRL |= OSC_RC32MEN_bm;\r
+ while (!(OSC.STATUS & OSC_RC32MRDY_bm));\r
+ return true;\r
+ case CLOCK_SRC_INT_RC32KHZ:\r
+ OSC.CTRL |= OSC_RC32KEN_bm;\r
+ while (!(OSC.STATUS & OSC_RC32KRDY_bm));\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ /** Stops the given internal oscillator of the XMEGA microcontroller.\r
+ *\r
+ * \param[in] Source Internal oscillator to stop, a value from \ref XMEGA_System_ClockSource_t.\r
+ *\r
+ * \return Boolean \c true if the internal oscillator was successfully stopped, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool XMEGACLK_StopInternalOscillator(const uint8_t Source) ATTR_ALWAYS_INLINE;\r
+ static inline bool XMEGACLK_StopInternalOscillator(const uint8_t Source)\r
+ {\r
+ switch (Source)\r
+ {\r
+ case CLOCK_SRC_INT_RC2MHZ:\r
+ OSC.CTRL &= ~OSC_RC2MEN_bm;\r
+ return true;\r
+ case CLOCK_SRC_INT_RC32MHZ:\r
+ OSC.CTRL &= ~OSC_RC32MEN_bm;\r
+ return true;\r
+ case CLOCK_SRC_INT_RC32KHZ:\r
+ OSC.CTRL &= ~OSC_RC32KEN_bm;\r
+ return true;\r
+ }\r
+\r
+ return false;\r
+ }\r
+\r
+ /** Starts the PLL of the XMEGA microcontroller, with the given options. This routine blocks until the PLL is ready for use.\r
+ *\r
+ * \attention The output frequency must be equal to or greater than the source frequency.\r
+ *\r
+ * \param[in] Source Clock source for the PLL, a value from \ref XMEGA_System_ClockSource_t.\r
+ * \param[in] SourceFreq Frequency of the PLL's clock source, in Hz.\r
+ * \param[in] Frequency Target frequency of the PLL's output.\r
+ *\r
+ * \return Boolean \c true if the PLL was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool XMEGACLK_StartPLL(const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency) ATTR_ALWAYS_INLINE;\r
+ static inline bool XMEGACLK_StartPLL(const uint8_t Source,\r
+ const uint32_t SourceFreq,\r
+ const uint32_t Frequency)\r
+ {\r
+ uint8_t MulFactor = (Frequency / SourceFreq);\r
+\r
+ if (SourceFreq > Frequency)\r
+ return false;\r
+ \r
+ if (MulFactor > 31)\r
+ return false;\r
+\r
+ switch (Source)\r
+ {\r
+ case CLOCK_SRC_INT_RC2MHZ:\r
+ OSC.PLLCTRL = (OSC_PLLSRC_RC2M_gc | MulFactor);\r
+ break;\r
+ case CLOCK_SRC_INT_RC32MHZ:\r
+ OSC.PLLCTRL = (OSC_PLLSRC_RC32M_gc | MulFactor);\r
+ break;\r
+ case CLOCK_SRC_XOSC:\r
+ OSC.PLLCTRL = (OSC_PLLSRC_XOSC_gc | MulFactor);\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+\r
+ OSC.CTRL |= OSC_PLLEN_bm;\r
+\r
+ while (!(OSC.STATUS & OSC_PLLRDY_bm));\r
+ return true;\r
+ }\r
+\r
+ /** Stops the PLL of the XMEGA microcontroller. */\r
+ static inline void XMEGACLK_StopPLL(void) ATTR_ALWAYS_INLINE;\r
+ static inline void XMEGACLK_StopPLL(void)\r
+ {\r
+ OSC.CTRL &= ~OSC_PLLEN_bm;\r
+ }\r
+\r
+ /** Starts the DFLL of the XMEGA microcontroller, with the given options.\r
+ *\r
+ * \param[in] Source RC Clock source for the DFLL, a value from \ref XMEGA_System_ClockSource_t.\r
+ * \param[in] Reference Reference clock source for the DFLL, an value from \ref XMEGA_System_DFLLReference_t.\r
+ * \param[in] Frequency Target frequency of the DFLL's output.\r
+ *\r
+ * \return Boolean \c true if the DFLL was successfully started, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool XMEGACLK_StartDFLL(const uint8_t Source,\r
+ const uint8_t Reference,\r
+ const uint32_t Frequency) ATTR_ALWAYS_INLINE;\r
+ static inline bool XMEGACLK_StartDFLL(const uint8_t Source,\r
+ const uint8_t Reference,\r
+ const uint32_t Frequency)\r
+ {\r
+ uint16_t DFLLCompare = (Frequency / 1000);\r
+\r
+ switch (Source)\r
+ {\r
+ case CLOCK_SRC_INT_RC2MHZ:\r
+ OSC.DFLLCTRL |= (Reference << OSC_RC2MCREF_bp);\r
+ DFLLRC2M.COMP1 = (DFLLCompare & 0xFF);\r
+ DFLLRC2M.COMP2 = (DFLLCompare >> 8);\r
+ DFLLRC2M.CTRL = DFLL_ENABLE_bm;\r
+ break;\r
+ case CLOCK_SRC_INT_RC32MHZ:\r
+ OSC.DFLLCTRL |= (Reference << OSC_RC32MCREF_gp);\r
+ DFLLRC32M.COMP1 = (DFLLCompare & 0xFF);\r
+ DFLLRC32M.COMP2 = (DFLLCompare >> 8);\r
+\r
+ if (Reference == DFLL_REF_INT_USBSOF)\r
+ {\r
+ NVM.CMD = NVM_CMD_READ_CALIB_ROW_gc;\r
+ DFLLRC32M.CALA = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBRCOSCA));\r
+ DFLLRC32M.CALB = pgm_read_byte(offsetof(NVM_PROD_SIGNATURES_t, USBRCOSC));\r
+ NVM.CMD = 0;\r
+ }\r
+\r
+ DFLLRC32M.CTRL = DFLL_ENABLE_bm;\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+\r
+ return true;\r
+ }\r
+\r
+ /** Stops the given DFLL of the XMEGA microcontroller.\r
+ *\r
+ * \param[in] Source RC Clock source for the DFLL to be stopped, a value from \ref XMEGA_System_ClockSource_t.\r
+ *\r
+ * \return Boolean \c true if the DFLL was successfully stopped, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool XMEGACLK_StopDFLL(const uint8_t Source) ATTR_ALWAYS_INLINE;\r
+ static inline bool XMEGACLK_StopDFLL(const uint8_t Source)\r
+ {\r
+ switch (Source)\r
+ {\r
+ case CLOCK_SRC_INT_RC2MHZ:\r
+ DFLLRC2M.CTRL = 0;\r
+ break;\r
+ case CLOCK_SRC_INT_RC32MHZ:\r
+ DFLLRC32M.CTRL = 0;\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+\r
+ return true;\r
+ }\r
+\r
+ /** Sets the clock source for the main microcontroller core. The given clock source should be configured\r
+ * and ready for use before this function is called.\r
+ *\r
+ * \param[in] Source Clock source for the CPU core, a value from \ref XMEGA_System_ClockSource_t.\r
+ *\r
+ * \return Boolean \c true if the CPU core clock was successfully altered, \c false if invalid parameters specified.\r
+ */\r
+ static inline bool XMEGACLK_SetCPUClockSource(const uint8_t Source) ATTR_ALWAYS_INLINE;\r
+ static inline bool XMEGACLK_SetCPUClockSource(const uint8_t Source)\r
+ {\r
+ uint8_t ClockSourceMask = 0;\r
+\r
+ switch (Source)\r
+ {\r
+ case CLOCK_SRC_INT_RC2MHZ:\r
+ ClockSourceMask = CLK_SCLKSEL_RC2M_gc;\r
+ break;\r
+ case CLOCK_SRC_INT_RC32MHZ:\r
+ ClockSourceMask = CLK_SCLKSEL_RC32M_gc;\r
+ break;\r
+ case CLOCK_SRC_INT_RC32KHZ:\r
+ ClockSourceMask = CLK_SCLKSEL_RC32K_gc;\r
+ break;\r
+ case CLOCK_SRC_XOSC:\r
+ ClockSourceMask = CLK_SCLKSEL_XOSC_gc;\r
+ break;\r
+ case CLOCK_SRC_PLL:\r
+ ClockSourceMask = CLK_SCLKSEL_PLL_gc;\r
+ break;\r
+ default:\r
+ return false;\r
+ }\r
+\r
+ uint_reg_t CurrentGlobalInt = GetGlobalInterruptMask();\r
+ GlobalInterruptDisable();\r
+\r
+ XMEGACLK_CCP_Write(&CLK.CTRL, ClockSourceMask);\r
+\r
+ SetGlobalInterruptMask(CurrentGlobalInt);\r
+\r
+ Delay_MS(1);\r
+ return (CLK.CTRL == ClockSourceMask);\r
+ }\r
+\r
+ /* Disable C linkage for C++ Compilers: */\r
+ #if defined(__cplusplus)\r
+ }\r
+ #endif\r
+\r
+#endif\r
+\r
+/** @} */\r
+\r
--- /dev/null
+/*\r
+ LUFA Library\r
+ Copyright (C) Dean Camera, 2012.\r
+\r
+ dean [at] fourwalledcubicle [dot] com\r
+ www.lufa-lib.org\r
+*/\r
+\r
+/*\r
+ Copyright 2012 Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+ Permission to use, copy, modify, distribute, and sell this\r
+ software and its documentation for any purpose is hereby granted\r
+ without fee, provided that the above copyright notice appear in\r
+ all copies and that both that the copyright notice and this\r
+ permission notice and warranty disclaimer appear in supporting\r
+ documentation, and that the name of the author not be used in\r
+ advertising or publicity pertaining to distribution of the\r
+ software without specific, written prior permission.\r
+\r
+ The author disclaim all warranties with regard to this\r
+ software, including all implied warranties of merchantability\r
+ and fitness. In no event shall the author be liable for any\r
+ special, indirect or consequential damages or any damages\r
+ whatsoever resulting from loss of use, data or profits, whether\r
+ in an action of contract, negligence or other tortious action,\r
+ arising out of or in connection with the use or performance of\r
+ this software.\r
+*/\r
+\r
+/** \file\r
+ *\r
+ * \brief LUFA library version constants.\r
+ *\r
+ * Version constants for informational purposes and version-specific macro creation. This header file contains the\r
+ * current LUFA version number in several forms, for use in the user-application (for example, for printing out\r
+ * whilst debugging, or for testing for version compatibility).\r
+ */\r
+\r
+#ifndef __LUFA_VERSION_H__\r
+#define __LUFA_VERSION_H__\r
+\r
+ /* Public Interface - May be used in end-application: */\r
+ /* Macros: */\r
+ /** Indicates the version number of the library, as an integer. */\r
+ #define LUFA_VERSION_INTEGER 0x120730\r
+\r
+ /** Indicates the version number of the library, as a string. */\r
+ #define LUFA_VERSION_STRING "120730"\r
+\r
+#endif\r
+\r
--- /dev/null
+#\r
+# LUFA Library\r
+# Copyright (C) Dean Camera, 2012.\r
+#\r
+# dean [at] fourwalledcubicle [dot] com\r
+# www.lufa-lib.org\r
+#\r
+# ---------------------------------------\r
+# Makefile for the LUFA library itself.\r
+# ---------------------------------------\r
+\r
+LUFA_VERSION_NUM := $(shell grep LUFA_VERSION_STRING Version.h | cut -d'"' -f2)\r
+EXCLUDE_FROM_EXPORT := Documentation DoxygenPages CodeTemplates Build *.conf *.tar *.o *.d *.lss *.lst *.hex *.elf *.hex *.eep *.map *.bin\r
+\r
+all:\r
+\r
+export_tar:\r
+ @echo Exporting LUFA library to a TAR archive...\r
+ @tar -cf LUFA_$(LUFA_VERSION_NUM).tar --directory=. $(EXCLUDE_FROM_EXPORT:%=--exclude=%) *\r
+ @tar -cf LUFA_$(LUFA_VERSION_NUM)_Code_Templates.tar CodeTemplates\r
+ @echo Export LUFA_$(LUFA_VERSION_NUM).tar complete.\r
+\r
+version:\r
+ @echo "LUFA $(LUFA_VERSION_NUM)"\r
+\r
+# Check if this is being included from a legacy or non LUFA build system makefile\r
+ifneq ($(LUFA_PATH),)\r
+ LUFA_ROOT_PATH = $(patsubst %/,%,$(LUFA_PATH))/LUFA/\r
+ \r
+ include $(patsubst %/,%,$(LUFA_PATH))/LUFA/Build/lufa.sources.in\r
+else\r
+ LUFA_BUILD_MODULES += MASTER\r
+ LUFA_BUILD_TARGETS += export_tar version\r
+\r
+ LUFA_PATH = .\r
+ ARCH = {AVR8,UC3,XMEGA}\r
+ DOXYGEN_OVERRIDE_PARAMS = QUIET=YES PROJECT_NUMBER=$(LUFA_VERSION_NUM)\r
+ \r
+ clean:\r
+ rm -f $(LUFA_SRC_ALL_FILES:%.c=%.o)\r
+ rm -f $(LUFA_SRC_ALL_FILES:%.c=%.d)\r
+ rm -f $(LUFA_SRC_ALL_FILES:%.c=%.lst)\r
+\r
+ include Build/lufa_core.mk\r
+ include Build/lufa_sources.mk\r
+ include Build/lufa_doxygen.mk\r
+endif\r
+\r
+\r
+.PHONY: all export_tar version clean
\ No newline at end of file
--- /dev/null
+\r
+ _ _ _ ___ _\r
+ | | | | | __/ \\r
+ | |_| U | _| o | - The Lightweight USB\r
+ |___|___|_||_n_| Framework for AVRs\r
+ =========================================\r
+ Written by Dean Camera\r
+ dean [at] fourwalledcubicle [dot] com\r
+\r
+ http://www.lufa-lib.org\r
+ =========================================\r
+\r
+ LUFA is donation supported. To support LUFA,\r
+ please donate at http://www.lufa-lib.org/donate\r
+\r
+ Released under a modified MIT license - see\r
+ LUFA/License.txt for license details.\r
+\r
+ For Commercial Licensing information, see\r
+ http://www.lufa-lib.org/license\r
+\r
+\r
+This package contains the complete LUFA library, demos, user-submitted\r
+projects and bootloaders for use with compatible microcontroller models.\r
+LUFA is a simple to use, lightweight framework which sits atop the hardware\r
+USB controller in specific AVR microcontroller models, and allows for the\r
+quick and easy creation of complex USB devices and hosts.\r
+\r
+To get started, you will need to install the "Doxygen" documentation\r
+generation tool. If you use Linux, this can be installed via the "doxygen"\r
+package in your chosen package management tool - under Ubuntu, this can be\r
+achieved by running the following command in the terminal:\r
+\r
+ sudo apt-get install doxygen\r
+\r
+Other package managers and distributions will have similar methods to\r
+install Doxygen. In Windows, you can download a prebuilt installer for\r
+Doxygen from its website, www.doxygen.org.\r
+\r
+Once installed, you can then use the Doxygen tool to generate the library\r
+documentation from the command line or terminal of your operating system. To\r
+do this, open your terminal or command line to the root directory of the\r
+LUFA package, and type the following command:\r
+\r
+ make doxygen\r
+\r
+Which will recursively generate documentation for all elements in the\r
+library - the core, plus all demos, projects and bootloaders. Generated\r
+documentation will then be available by opening the file "index.html" of the\r
+created Documentation/html/ subdirectories inside each project folder.\r
+\r
+The documentation for the library itself (but not the documentation for the\r
+individual demos, projects or bootloaders) is also available as a separate\r
+package from the project webpage for convenience if Doxygen cannot be\r
+installed.\r
+\r