diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2010-10-13 14:05:35 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2010-10-13 14:05:35 +0000 |
commit | 5a4def747897c1c6ffbe465506d846c7c686d3e9 (patch) | |
tree | e5a9ca31ab554e993f1a9041e44976cf7b253921 /Demos/Host | |
parent | a8871c7fba73307226bd13e2cad4c840c850e6f1 (diff) | |
download | lufa-5a4def747897c1c6ffbe465506d846c7c686d3e9.tar.gz lufa-5a4def747897c1c6ffbe465506d846c7c686d3e9.tar.bz2 lufa-5a4def747897c1c6ffbe465506d846c7c686d3e9.zip |
Clean up excessive whitespace at the end of each line using the wspurify tool made by Laszlo Monda
Diffstat (limited to 'Demos/Host')
160 files changed, 2611 insertions, 2456 deletions
diff --git a/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c b/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c index fb48c2b17..8d87e88c2 100644 --- a/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c +++ b/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the JoystickHostWithParser demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "JoystickHostWithParser.h" /** Processed HID report descriptor items structure, containing information on each HID report element */ @@ -52,14 +52,14 @@ USB_ClassInfo_HID_Host_t Joystick_HID_Interface = .DataOUTPipeNumber = 2, .DataOUTPipeDoubleBank = false, - + .HIDInterfaceProtocol = HID_BOOTP_NonBootProtocol, - + .HIDParserData = &HIDReportInfo }, }; - + /** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ @@ -78,7 +78,7 @@ int main(void) { case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - + uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; @@ -99,7 +99,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Device Configuration.\r\n")); @@ -115,7 +115,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("Joystick Enumerated.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; @@ -131,7 +131,7 @@ int main(void) for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++) { HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber]; - + /* Update the report item value if it is contained within the current report */ if (!(USB_GetHIDReportItemInfo(JoystickReport, ReportItem))) continue; @@ -149,7 +149,7 @@ int main(void) (ReportItem->ItemType == HID_REPORT_ITEM_In)) { int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t); - + if (DeltaMovement) { if (ReportItem->Attributes.Usage.Usage == USAGE_X) @@ -159,13 +159,13 @@ int main(void) } } } - + LEDs_SetAllLEDs(LEDMask); } - + break; } - + HID_Host_USBTask(&Joystick_HID_Interface); USB_USBTask(); } @@ -235,7 +235,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } @@ -277,3 +277,4 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem) return ((CurrentItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) || (CurrentItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL)); } + diff --git a/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.h b/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.h index 1cebb924c..51f641dd4 100644 --- a/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.h +++ b/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/HID.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -78,17 +78,18 @@ /** HID Report Descriptor Usage value for a Y axis movement. */ #define USAGE_Y 0x31 - + /* Function Prototypes: */ void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem); - + #endif + diff --git a/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.txt b/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.txt index 055890b70..0fa97f868 100644 --- a/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.txt +++ b/Demos/Host/ClassDriver/JoystickHostWithParser/JoystickHostWithParser.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Joystick Host With HID Descriptor Parser Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Human Interface Device (HID)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -41,19 +41,19 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Joystick host demonstration application. This gives a simple reference * application for implementing a USB Joystick host, for USB joysticks using * the standard joystick HID profile. It uses a HID parser for the HID * reports, allowing for correct operation across all USB joysticks. This * demo supports joysticks with a single HID report. - * + * * Joystick movement and button presses are displayed on the board LEDs. * On connection to a USB joystick, the report items will be processed and * printed as a formatted list through the USART before the joystick is * fully enumerated. - * + * * Currently only single interface joysticks are supported. * * \section SSec_Options Project Options @@ -68,3 +68,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/ClassDriver/JoystickHostWithParser/makefile b/Demos/Host/ClassDriver/JoystickHostWithParser/makefile index a82f4e29c..a585f3f9f 100644 --- a/Demos/Host/ClassDriver/JoystickHostWithParser/makefile +++ b/Demos/Host/ClassDriver/JoystickHostWithParser/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -133,7 +133,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -146,7 +146,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -297,7 +297,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -320,7 +320,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -417,7 +417,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -504,11 +504,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -635,14 +635,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c index ddce64c24..9b7941e5f 100644 --- a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c +++ b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the KeyboardHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "KeyboardHost.h" /** LUFA HID Class driver interface configuration and state information. This structure is @@ -49,12 +49,12 @@ USB_ClassInfo_HID_Host_t Keyboard_HID_Interface = .DataOUTPipeNumber = 2, .DataOUTPipeDoubleBank = false, - + .HIDInterfaceProtocol = HID_BOOTP_KeyboardBootProtocol, }, }; - + /** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ @@ -66,14 +66,14 @@ int main(void) LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); - + for (;;) { switch (USB_HostState) { case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - + uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; @@ -94,7 +94,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Device Configuration.\r\n")); @@ -110,7 +110,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("Keyboard Enumerated.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; @@ -118,11 +118,11 @@ int main(void) case HOST_STATE_Configured: if (HID_Host_IsReportReceived(&Keyboard_HID_Interface)) { - USB_KeyboardReport_Data_t KeyboardReport; + USB_KeyboardReport_Data_t KeyboardReport; HID_Host_ReceiveReport(&Keyboard_HID_Interface, &KeyboardReport); LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0); - + uint8_t PressedKeyCode = KeyboardReport.KeyCode[0]; if (PressedKeyCode) @@ -130,25 +130,25 @@ int main(void) char PressedKey = 0; LEDs_ToggleLEDs(LEDS_LED2); - + /* Retrieve pressed key character if alphanumeric */ if ((PressedKeyCode >= 0x04) && (PressedKeyCode <= 0x1D)) PressedKey = (PressedKeyCode - 0x04) + 'A'; else if ((PressedKeyCode >= 0x1E) && (PressedKeyCode <= 0x27)) PressedKey = (PressedKeyCode - 0x1E) + '0'; else if (PressedKeyCode == 0x2C) - PressedKey = ' '; + PressedKey = ' '; else if (PressedKeyCode == 0x28) PressedKey = '\n'; - + if (PressedKey) putchar(PressedKey); } } - + break; } - + HID_Host_USBTask(&Keyboard_HID_Interface); USB_USBTask(); } @@ -218,6 +218,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } + diff --git a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.h b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.h index fd6b83882..a569162e5 100644 --- a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.h +++ b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/HID.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -63,15 +63,16 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /* Function Prototypes: */ void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + #endif + diff --git a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.txt b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.txt index 5f2969d28..752807e5a 100644 --- a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.txt +++ b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Keyboard Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Human Interface Device (HID)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -39,21 +39,21 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Keyboard host demonstration application. This gives a simple reference * application for implementing a USB keyboard, for USB keyboards using * the standard keyboard HID profile. - * + * * Pressed alpha-numeric, enter or space key is transmitted through the serial * USART at serial settings 9600, 8, N, 1. - * + * * This uses a naive method where the keyboard is set to Boot Protocol mode, so * that the report structure is fixed and known. A better implementation * uses the HID report parser for correct report data processing across * all compatible mice with advanced characteristics, as shown in the * KeyboardHostWithParser demo application. - * + * * Currently only single interface keyboards are supported. * * \section SSec_Options Project Options @@ -68,3 +68,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/ClassDriver/KeyboardHost/makefile b/Demos/Host/ClassDriver/KeyboardHost/makefile index fa7f60717..8dc1791bc 100644 --- a/Demos/Host/ClassDriver/KeyboardHost/makefile +++ b/Demos/Host/ClassDriver/KeyboardHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -133,7 +133,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -146,7 +146,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -297,7 +297,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -320,7 +320,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -417,7 +417,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -504,11 +504,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -635,14 +635,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c index 3fd23f051..5f10d8bf7 100644 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c +++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the KeyboardHostWithParser demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "KeyboardHostWithParser.h" /** Processed HID report descriptor items structure, containing information on each HID report element */ @@ -52,14 +52,14 @@ USB_ClassInfo_HID_Host_t Keyboard_HID_Interface = .DataOUTPipeNumber = 2, .DataOUTPipeDoubleBank = false, - + .HIDInterfaceProtocol = HID_BOOTP_NonBootProtocol, - + .HIDParserData = &HIDReportInfo }, }; - + /** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ @@ -78,7 +78,7 @@ int main(void) { case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - + uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; @@ -99,7 +99,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Device Configuration.\r\n")); @@ -115,7 +115,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("Keyboard Enumerated.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; @@ -125,7 +125,7 @@ int main(void) { uint8_t KeyboardReport[Keyboard_HID_Interface.State.LargestReportSize]; HID_Host_ReceiveReport(&Keyboard_HID_Interface, &KeyboardReport); - + for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++) { HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber]; @@ -157,24 +157,24 @@ int main(void) else if ((KeyCode >= 0x1E) && (KeyCode <= 0x27)) PressedKey = (KeyCode - 0x1E) + '0'; else if (KeyCode == 0x2C) - PressedKey = ' '; + PressedKey = ' '; else if (KeyCode == 0x28) PressedKey = '\n'; - + /* Print the pressed key character out through the serial port if valid */ if (PressedKey) putchar(PressedKey); } - + /* Once a scan-code is found, stop scanning through the report items */ break; } } } - + break; } - + HID_Host_USBTask(&Keyboard_HID_Interface); USB_USBTask(); } @@ -244,7 +244,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } @@ -265,3 +265,4 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem) */ return (CurrentItem->Attributes.Usage.Page == USAGE_PAGE_KEYBOARD); } + diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h index 5ecfdf458..b31d5cb66 100644 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h +++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/HID.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -63,20 +63,21 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /** HID Report Descriptor Usage Page value for a desktop keyboard. */ #define USAGE_PAGE_KEYBOARD 0x07 /* Function Prototypes: */ void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem); - + #endif + diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.txt b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.txt index 5e122a38f..50f6c861d 100644 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.txt +++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Keyboard Host With HID Descriptor Parser Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Human Interface Device (HID)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -41,20 +41,20 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Keyboard host demonstration application. This gives a simple reference * application for implementing a USB Keyboard host, for USB keyboards using * the standard Keyboard HID profile. It uses a HID parser for the HID reports, * allowing for correct operation across all USB keyboards. This demo supports * keyboards with a single HID report. - * + * * Pressed alpha-numeric, enter or space key is transmitted through the serial * USART at serial settings 9600, 8, N, 1. On connection to a USB keyboard, the * report items will be processed and printed as a formatted list through the * USART before the keyboard is fully enumerated. - * - * Currently only single interface keyboards are supported. + * + * Currently only single interface keyboards are supported. * * \section SSec_Options Project Options * @@ -68,3 +68,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/makefile b/Demos/Host/ClassDriver/KeyboardHostWithParser/makefile index a3c1aab0c..90ec16242 100644 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/makefile +++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -133,7 +133,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -146,7 +146,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -297,7 +297,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -320,7 +320,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -417,7 +417,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -504,11 +504,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -635,14 +635,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/ClassDriver/MIDIHost/MIDIHost.c b/Demos/Host/ClassDriver/MIDIHost/MIDIHost.c index faaebdd7c..a4d00cef7 100644 --- a/Demos/Host/ClassDriver/MIDIHost/MIDIHost.c +++ b/Demos/Host/ClassDriver/MIDIHost/MIDIHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the MIDIHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "MIDIHost.h" /** LUFA MIDI Class driver interface configuration and state information. This structure is @@ -46,13 +46,13 @@ USB_ClassInfo_MIDI_Host_t Keyboard_MIDI_Interface = { .DataINPipeNumber = 1, .DataINPipeDoubleBank = false, - + .DataOUTPipeNumber = 2, .DataOUTPipeDoubleBank = false, }, }; - + /** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ @@ -71,7 +71,7 @@ int main(void) { case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - + uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; @@ -92,7 +92,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Device Configuration.\r\n")); @@ -100,20 +100,20 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("MIDI Device Enumerated.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: CheckJoystickMovement(); - + MIDI_EventPacket_t MIDIEvent; if (MIDI_Host_ReceiveEventPacket(&Keyboard_MIDI_Interface, &MIDIEvent)) { bool NoteOnEvent = ((MIDIEvent.Command & 0x0F) == (MIDI_COMMAND_NOTE_ON >> 4)); bool NoteOffEvent = ((MIDIEvent.Command & 0x0F) == (MIDI_COMMAND_NOTE_OFF >> 4)); - + if (NoteOnEvent || NoteOffEvent) { printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d\r\n"), NoteOnEvent ? "On" : "Off", @@ -121,10 +121,10 @@ int main(void) MIDIEvent.Data2, MIDIEvent.Data3); } } - + break; } - + MIDI_Host_USBTask(&Keyboard_MIDI_Interface); USB_USBTask(); } @@ -154,11 +154,11 @@ void CheckJoystickMovement(void) uint8_t MIDICommand = 0; uint8_t MIDIPitch; - + /* Get current joystick mask, XOR with previous to detect joystick changes */ uint8_t JoystickStatus = Joystick_GetStatus(); uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus); - + /* Get board button status - if pressed use channel 10 (percussion), otherwise use channel 1 */ uint8_t Channel = ((Buttons_GetStatus() & BUTTONS_BUTTON1) ? MIDI_CHANNEL(10) : MIDI_CHANNEL(1)); @@ -179,7 +179,7 @@ void CheckJoystickMovement(void) MIDICommand = ((JoystickStatus & JOY_RIGHT)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF); MIDIPitch = 0x3E; } - + if (JoystickChanges & JOY_DOWN) { MIDICommand = ((JoystickStatus & JOY_DOWN)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF); @@ -191,19 +191,19 @@ void CheckJoystickMovement(void) MIDICommand = ((JoystickStatus & JOY_PRESS)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF); MIDIPitch = 0x3B; } - + if (MIDICommand) { MIDI_EventPacket_t MIDIEvent = (MIDI_EventPacket_t) { .CableNumber = 0, .Command = (MIDICommand >> 4), - + .Data1 = MIDICommand | Channel, .Data2 = MIDIPitch, - .Data3 = MIDI_STANDARD_VELOCITY, + .Data3 = MIDI_STANDARD_VELOCITY, }; - + MIDI_Host_SendEventPacket(&Keyboard_MIDI_Interface, &MIDIEvent); MIDI_Host_Flush(&Keyboard_MIDI_Interface); } @@ -259,6 +259,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } + diff --git a/Demos/Host/ClassDriver/MIDIHost/MIDIHost.h b/Demos/Host/ClassDriver/MIDIHost/MIDIHost.h index 84e7680f3..977eabbd3 100644 --- a/Demos/Host/ClassDriver/MIDIHost/MIDIHost.h +++ b/Demos/Host/ClassDriver/MIDIHost/MIDIHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -52,7 +52,7 @@ #include <LUFA/Drivers/Board/Joystick.h> #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/MIDI.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -65,16 +65,17 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /* Function Prototypes: */ void SetupHardware(void); void CheckJoystickMovement(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + #endif + diff --git a/Demos/Host/ClassDriver/MIDIHost/MIDIHost.txt b/Demos/Host/ClassDriver/MIDIHost/MIDIHost.txt index a90ae04d3..337dba72e 100644 --- a/Demos/Host/ClassDriver/MIDIHost/MIDIHost.txt +++ b/Demos/Host/ClassDriver/MIDIHost/MIDIHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage MIDI Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Audio Class Device</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>MIDI Subclass</td> * </tr> @@ -39,7 +39,7 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * MIDI host demonstration application. This demo will enumerate an attached USB-MIDI device, and print incoming MIDI note * on and off messages on any channel to the serial port. Pressing the board joystick will send note on and off messages to @@ -57,3 +57,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/ClassDriver/MIDIHost/makefile b/Demos/Host/ClassDriver/MIDIHost/makefile index 6de81be84..64a05e1e6 100644 --- a/Demos/Host/ClassDriver/MIDIHost/makefile +++ b/Demos/Host/ClassDriver/MIDIHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -133,7 +133,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -146,7 +146,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -297,7 +297,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -320,7 +320,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -417,7 +417,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -504,11 +504,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -635,14 +635,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c index 40cf2a48d..7f8ba9544 100644 --- a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c +++ b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the MassStorageHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "MassStorageHost.h" /** LUFA Mass Storage Class driver interface configuration and state information. This structure is @@ -46,13 +46,13 @@ USB_ClassInfo_MS_Host_t FlashDisk_MS_Interface = { .DataINPipeNumber = 1, .DataINPipeDoubleBank = false, - + .DataOUTPipeNumber = 2, .DataOUTPipeDoubleBank = false, }, }; - + /** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ @@ -71,7 +71,7 @@ int main(void) { case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - + uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; @@ -92,7 +92,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Device Configuration.\r\n")); @@ -100,14 +100,14 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("Mass Storage Device Enumerated.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: LEDs_SetAllLEDs(LEDMASK_USB_BUSY); - + uint8_t MaxLUNIndex; if (MS_Host_GetMaxLUN(&FlashDisk_MS_Interface, &MaxLUNIndex)) { @@ -116,9 +116,9 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + printf_P(PSTR("Total LUNs: %d - Using first LUN in device.\r\n"), (MaxLUNIndex + 1)); - + if (MS_Host_ResetMSInterface(&FlashDisk_MS_Interface)) { puts_P(PSTR("Error resetting Mass Storage interface.\r\n")); @@ -126,7 +126,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + SCSI_Request_Sense_Response_t SenseData; if (MS_Host_RequestSense(&FlashDisk_MS_Interface, 0, &SenseData) != 0) { @@ -135,7 +135,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (MS_Host_PreventAllowMediumRemoval(&FlashDisk_MS_Interface, 0, true)) { puts_P(PSTR("Error setting Prevent Device Removal bit.\r\n")); @@ -150,17 +150,17 @@ int main(void) puts_P(PSTR("Error retrieving device Inquiry data.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; - break; + break; } printf_P(PSTR("Vendor \"%.8s\", Product \"%.16s\"\r\n"), InquiryData.VendorID, InquiryData.ProductID); - + puts_P(PSTR("Waiting until ready...\r\n")); for (;;) { uint8_t ErrorCode = MS_Host_TestUnitReady(&FlashDisk_MS_Interface, 0); - + if (!(ErrorCode)) break; @@ -184,7 +184,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + printf_P(PSTR("%lu blocks of %lu bytes.\r\n"), DiskCapacity.Blocks, DiskCapacity.BlockSize); uint8_t BlockBuffer[DiskCapacity.BlockSize]; @@ -196,20 +196,20 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("\r\nContents of first block:\r\n")); for (uint16_t Chunk = 0; Chunk < (DiskCapacity.BlockSize >> 4); Chunk++) { uint8_t* ChunkPtr = &BlockBuffer[Chunk << 4]; - + /* Print out the 16 bytes of the chunk in HEX format */ for (uint8_t ByteOffset = 0; ByteOffset < (1 << 4); ByteOffset++) { char CurrByte = *(ChunkPtr + ByteOffset); printf_P(PSTR("%.2X "), CurrByte); } - + printf_P(PSTR(" ")); /* Print out the 16 bytes of the chunk in ASCII format */ @@ -218,7 +218,7 @@ int main(void) char CurrByte = *(ChunkPtr + ByteOffset); putchar(isprint(CurrByte) ? CurrByte : '.'); } - + printf_P(PSTR("\r\n")); } @@ -226,7 +226,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + MS_Host_USBTask(&FlashDisk_MS_Interface); USB_USBTask(); } @@ -296,6 +296,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } + diff --git a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h index b99471205..af8470cf0 100644 --- a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h +++ b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -51,7 +51,7 @@ #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/MassStorage.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -64,18 +64,19 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ #define LEDMASK_USB_BUSY LEDS_LED2 /* Function Prototypes: */ void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + #endif + diff --git a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.txt b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.txt index 23f083dea..45d78c43b 100644 --- a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.txt +++ b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Mass Storage Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Mass Storage Device</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>Bulk Only</td> * </tr> @@ -42,12 +42,12 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Mass Storage host demonstration application. This gives a simple reference * application for implementing a USB Mass Storage host, for USB storage devices * using the standard Mass Storage USB profile. - * + * * The first 512 bytes (boot sector) of an attached disk's memory will be dumped * out of the serial port in HEX and ASCII form when it is attached to the AT90USB1287 * AVR. The device will then wait for HWB to be pressed, whereupon the entire ASCII contents @@ -65,3 +65,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/ClassDriver/MassStorageHost/makefile b/Demos/Host/ClassDriver/MassStorageHost/makefile index 3e947f2c0..a3b7ff178 100644 --- a/Demos/Host/ClassDriver/MassStorageHost/makefile +++ b/Demos/Host/ClassDriver/MassStorageHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -134,7 +134,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -147,7 +147,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -261,7 +261,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -274,7 +274,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -286,7 +286,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -298,7 +298,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -321,7 +321,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -355,7 +355,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -389,7 +389,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -418,7 +418,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -437,10 +437,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -505,11 +505,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -536,9 +536,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -636,14 +636,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -665,7 +665,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -709,3 +709,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/ClassDriver/MouseHost/MouseHost.c b/Demos/Host/ClassDriver/MouseHost/MouseHost.c index d76f048d9..c34a2fcb6 100644 --- a/Demos/Host/ClassDriver/MouseHost/MouseHost.c +++ b/Demos/Host/ClassDriver/MouseHost/MouseHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the MouseHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "MouseHost.h" /** LUFA HID Class driver interface configuration and state information. This structure is @@ -46,15 +46,15 @@ USB_ClassInfo_HID_Host_t Mouse_HID_Interface = { .DataINPipeNumber = 1, .DataINPipeDoubleBank = false, - + .DataOUTPipeNumber = 2, .DataOUTPipeDoubleBank = false, - + .HIDInterfaceProtocol = HID_BOOTP_MouseBootProtocol, }, }; - + /** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ @@ -73,7 +73,7 @@ int main(void) { case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - + uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; @@ -94,7 +94,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Device Configuration.\r\n")); @@ -110,7 +110,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("Mouse Enumerated.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; @@ -119,10 +119,10 @@ int main(void) if (HID_Host_IsReportReceived(&Mouse_HID_Interface)) { uint8_t LEDMask = LEDS_NO_LEDS; - + USB_MouseReport_Data_t MouseReport; HID_Host_ReceiveReport(&Mouse_HID_Interface, &MouseReport); - + printf_P(PSTR("dX:%2d dY:%2d Button:%d\r\n"), MouseReport.X, MouseReport.Y, MouseReport.Button); @@ -130,7 +130,7 @@ int main(void) LEDMask |= LEDS_LED1; else if (MouseReport.X < 0) LEDMask |= LEDS_LED2; - + if (MouseReport.Y > 0) LEDMask |= LEDS_LED3; else if (MouseReport.Y < 0) @@ -141,10 +141,10 @@ int main(void) LEDs_SetAllLEDs(LEDMask); } - + break; } - + HID_Host_USBTask(&Mouse_HID_Interface); USB_USBTask(); } @@ -214,6 +214,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } + diff --git a/Demos/Host/ClassDriver/MouseHost/MouseHost.h b/Demos/Host/ClassDriver/MouseHost/MouseHost.h index 7664580cb..c5567ed38 100644 --- a/Demos/Host/ClassDriver/MouseHost/MouseHost.h +++ b/Demos/Host/ClassDriver/MouseHost/MouseHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/HID.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -63,15 +63,16 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /* Function Prototypes: */ void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + #endif + diff --git a/Demos/Host/ClassDriver/MouseHost/MouseHost.txt b/Demos/Host/ClassDriver/MouseHost/MouseHost.txt index be608db2f..b659abada 100644 --- a/Demos/Host/ClassDriver/MouseHost/MouseHost.txt +++ b/Demos/Host/ClassDriver/MouseHost/MouseHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Mouse Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Human Interface Device (HID)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -41,23 +41,23 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Mouse host demonstration application. This gives a simple reference * application for implementing a USB Mouse host, for USB mice using * the standard mouse HID profile. - * + * * Mouse movement and button presses are displayed on the board LEDs, * as well as printed out the serial terminal as formatted dY, dY and * button status information. - * + * * This uses a naive method where the mouse is set to Boot Protocol mode, so * that the report structure is fixed and known. A better implementation * uses the HID report parser for correct report data processing across * all compatible mice with advanced characteristics, as shown in the * MouseHostWithParser demo application. - * - * Currently only single interface mice are supported. + * + * Currently only single interface mice are supported. * * \section SSec_Options Project Options * @@ -71,3 +71,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/ClassDriver/MouseHost/makefile b/Demos/Host/ClassDriver/MouseHost/makefile index 6d8ea3a8d..0812c5cb1 100644 --- a/Demos/Host/ClassDriver/MouseHost/makefile +++ b/Demos/Host/ClassDriver/MouseHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -133,7 +133,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -146,7 +146,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -297,7 +297,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -320,7 +320,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -417,7 +417,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -504,11 +504,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -635,14 +635,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c index d02424c7b..7948e2c49 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the MouseHostWithParser demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "MouseHostWithParser.h" /** Processed HID report descriptor items structure, containing information on each HID report element */ @@ -52,14 +52,14 @@ USB_ClassInfo_HID_Host_t Mouse_HID_Interface = .DataOUTPipeNumber = 2, .DataOUTPipeDoubleBank = false, - + .HIDInterfaceProtocol = HID_BOOTP_NonBootProtocol, - + .HIDParserData = &HIDReportInfo }, }; - + /** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ @@ -78,7 +78,7 @@ int main(void) { case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - + uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; @@ -99,7 +99,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Device Configuration.\r\n")); @@ -115,7 +115,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("Mouse Enumerated.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; @@ -131,11 +131,11 @@ int main(void) for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++) { HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber]; - + /* Update the report item value if it is contained within the current report */ if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem))) continue; - + /* Determine what report item is being tested, process updated value as needed */ if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) && (ReportItem->ItemType == HID_REPORT_ITEM_In)) @@ -148,7 +148,7 @@ int main(void) (ReportItem->ItemType == HID_REPORT_ITEM_In)) { int16_t WheelDelta = HID_ALIGN_DATA(ReportItem, int16_t); - + if (WheelDelta) LEDMask = (LEDS_LED1 | LEDS_LED2 | ((WheelDelta > 0) ? LEDS_LED3 : LEDS_LED4)); } @@ -158,7 +158,7 @@ int main(void) (ReportItem->ItemType == HID_REPORT_ITEM_In)) { int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t); - + if (DeltaMovement) { if (ReportItem->Attributes.Usage.Usage == USAGE_X) @@ -168,13 +168,13 @@ int main(void) } } } - + LEDs_SetAllLEDs(LEDMask); } - + break; } - + HID_Host_USBTask(&Mouse_HID_Interface); USB_USBTask(); } @@ -244,7 +244,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } @@ -286,3 +286,4 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem) return ((CurrentItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) || (CurrentItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL)); } + diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h index 3b26cead5..e4958b7c5 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h +++ b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/HID.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -78,20 +78,21 @@ /** HID Report Descriptor Usage value for a Y axis movement. */ #define USAGE_Y 0x31 - + /** HID Report Descriptor Usage value for a Scroll Wheel movement. */ #define USAGE_SCROLL_WHEEL 0x38 /* Function Prototypes: */ void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem); - + #endif + diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.txt b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.txt index febd4a939..fdcdb6153 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.txt +++ b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Mouse Host With HID Descriptor Parser Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Human Interface Device (HID)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -41,19 +41,19 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Mouse host demonstration application. This gives a simple reference * application for implementing a USB Mouse host, for USB mice using * the standard mouse HID profile. It uses a HID parser for the HID * reports, allowing for correct operation across all USB mice. This * demo supports mice with a single HID report. - * + * * Mouse and scroll wheel movement and button presses are displayed * on the board LEDs. On connection to a USB mouse, the report items * will be processed and printed as a formatted list through the USART * before the mouse is fully enumerated. - * + * * Currently only single interface mice are supported. * * \section SSec_Options Project Options @@ -68,3 +68,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/makefile b/Demos/Host/ClassDriver/MouseHostWithParser/makefile index aacce7a04..48923b2de 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/makefile +++ b/Demos/Host/ClassDriver/MouseHostWithParser/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -133,7 +133,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -146,7 +146,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -297,7 +297,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -320,7 +320,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -417,7 +417,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -504,11 +504,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -635,14 +635,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c b/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c index 66c4f1302..2d776fd5d 100644 --- a/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c +++ b/Demos/Host/ClassDriver/PrinterHost/PrinterHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the PrinterHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "PrinterHost.h" /** LUFA Printer Class driver interface configuration and state information. This structure is @@ -46,7 +46,7 @@ USB_ClassInfo_PRNT_Host_t Printer_PRNT_Interface = { .DataINPipeNumber = 1, .DataINPipeDoubleBank = false, - + .DataOUTPipeNumber = 2, .DataOUTPipeDoubleBank = false, }, @@ -70,7 +70,7 @@ int main(void) { case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - + uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; @@ -91,7 +91,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Device Configuration.\r\n")); @@ -99,7 +99,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (PRNT_Host_SetBidirectionalMode(&Printer_PRNT_Interface) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Bidirectional Mode.\r\n")); @@ -107,16 +107,16 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("Printer Device Enumerated.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: LEDs_SetAllLEDs(LEDMASK_USB_BUSY); - + puts_P(PSTR("Retrieving Device ID...\r\n")); - + char DeviceIDString[300]; if (PRNT_Host_GetDeviceID(&Printer_PRNT_Interface, DeviceIDString, sizeof(DeviceIDString)) != HOST_SENDCONTROL_Successful) @@ -126,12 +126,12 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + printf_P(PSTR("Device ID: %s.\r\n"), DeviceIDString); - + char TestPageData[] = "\033%-12345X\033E" "LUFA PCL Test Page" "\033E\033%-12345X"; uint16_t TestPageLength = strlen(TestPageData); - + printf_P(PSTR("Sending Test Page (%d bytes)...\r\n"), TestPageLength); if (PRNT_Host_SendString(&Printer_PRNT_Interface, &TestPageData, TestPageLength) != PIPE_RWSTREAM_NoError) @@ -148,7 +148,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + PRNT_Host_USBTask(&Printer_PRNT_Interface); USB_USBTask(); } @@ -218,6 +218,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } + diff --git a/Demos/Host/ClassDriver/PrinterHost/PrinterHost.h b/Demos/Host/ClassDriver/PrinterHost/PrinterHost.h index a2b90a69d..120dec40f 100644 --- a/Demos/Host/ClassDriver/PrinterHost/PrinterHost.h +++ b/Demos/Host/ClassDriver/PrinterHost/PrinterHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/Printer.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -63,18 +63,19 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ #define LEDMASK_USB_BUSY LEDS_LED2 /* Function Prototypes: */ void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + #endif + diff --git a/Demos/Host/ClassDriver/PrinterHost/PrinterHost.txt b/Demos/Host/ClassDriver/PrinterHost/PrinterHost.txt index fab6a5b84..21780998e 100644 --- a/Demos/Host/ClassDriver/PrinterHost/PrinterHost.txt +++ b/Demos/Host/ClassDriver/PrinterHost/PrinterHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Printer Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Printer Device</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>Bidirectional Protocol</td> * </tr> @@ -41,16 +41,16 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Printer host demonstration application. This gives a simple reference * application for implementing a USB Printer host, for USB printers using * the bidirectional data encapsulation protocol and PCL language. - * + * * Upon connection of a compatible printer, the printer's device ID is sent * to the AVR's serial port, and a simple test page is printed using the PCL * printer language. - * + * * \section SSec_Options Project Options * * The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. @@ -63,3 +63,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/ClassDriver/PrinterHost/makefile b/Demos/Host/ClassDriver/PrinterHost/makefile index b98ec7796..15c267882 100644 --- a/Demos/Host/ClassDriver/PrinterHost/makefile +++ b/Demos/Host/ClassDriver/PrinterHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -133,7 +133,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -146,7 +146,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -297,7 +297,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -320,7 +320,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -417,7 +417,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -504,11 +504,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -635,14 +635,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c b/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c index b793db928..69fa25cd7 100644 --- a/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c +++ b/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the RNDISEthernetHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "RNDISEthernetHost.h" /** Buffer to hold incoming and outgoing Ethernet packets. */ @@ -55,11 +55,11 @@ USB_ClassInfo_RNDIS_Host_t Ethernet_RNDIS_Interface = .NotificationPipeNumber = 3, .NotificationPipeDoubleBank = false, - + .HostMaxPacketSize = sizeof(PacketBuffer), }, }; - + /** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ @@ -78,7 +78,7 @@ int main(void) { case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - + uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; @@ -99,7 +99,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Device Configuration.\r\n")); @@ -107,18 +107,18 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (RNDIS_Host_InitializeDevice(&Ethernet_RNDIS_Interface) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Initializing Device.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_ERROR); USB_HostState = HOST_STATE_WaitForDeviceRemoval; - break; + break; } - + printf_P(PSTR("Device Max Transfer Size: %lu bytes.\r\n"), Ethernet_RNDIS_Interface.State.DeviceMaxPacketSize); - + uint32_t PacketFilter = (REMOTE_NDIS_PACKET_DIRECTED | REMOTE_NDIS_PACKET_BROADCAST | REMOTE_NDIS_PACKET_ALL_MULTICAST); if (RNDIS_Host_SetRNDISProperty(&Ethernet_RNDIS_Interface, OID_GEN_CURRENT_PACKET_FILTER, &PacketFilter, sizeof(PacketFilter)) != HOST_SENDCONTROL_Successful) @@ -129,7 +129,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + uint32_t VendorID; if (RNDIS_Host_QueryRNDISProperty(&Ethernet_RNDIS_Interface, OID_GEN_VENDOR_ID, &VendorID, sizeof(VendorID)) != HOST_SENDCONTROL_Successful) @@ -140,7 +140,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + printf_P(PSTR("Device Vendor ID: 0x%08lX\r\n"), VendorID); puts_P(PSTR("RNDIS Device Enumerated.\r\n")); @@ -149,10 +149,10 @@ int main(void) break; case HOST_STATE_Configured: PrintIncomingPackets(); - + break; } - + RNDIS_Host_USBTask(&Ethernet_RNDIS_Interface); USB_USBTask(); } @@ -167,14 +167,14 @@ void PrintIncomingPackets(void) uint16_t PacketLength; RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, &PacketBuffer, &PacketLength); - + printf_P(PSTR("***PACKET (Size %d)***\r\n"), PacketLength); - + for (uint16_t i = 0; i < PacketLength; i++) printf("0x%02x ", PacketBuffer[i]); printf_P(PSTR("\r\n\r\n")); - + LEDs_SetAllLEDs(LEDMASK_USB_READY); } } @@ -243,6 +243,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } + diff --git a/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.h b/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.h index f3c04f593..56a6fe94e 100644 --- a/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.h +++ b/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/RNDIS.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -63,19 +63,20 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ #define LEDMASK_USB_BUSY LEDS_LED2 /* Function Prototypes: */ void SetupHardware(void); void PrintIncomingPackets(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + #endif + diff --git a/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.txt b/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.txt index 9fec00bec..a989bc51a 100644 --- a/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.txt +++ b/Demos/Host/ClassDriver/RNDISEthernetHost/RNDISEthernetHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage RNDIS Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Communications Device Class (CDC)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>Remote NDIS (Microsoft Proprietary CDC Class Networking Standard)</td> * </tr> @@ -39,12 +39,12 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * RNDIS host demonstration application. This gives a simple reference * application for implementing a RNDIS Ethernet host, for USB devices such as * modems. - * + * * This demo will enumerate an attached USB RNDIS device, print out its vendor ID * and any received packets in raw form through the serial USART. * @@ -60,3 +60,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/ClassDriver/RNDISEthernetHost/makefile b/Demos/Host/ClassDriver/RNDISEthernetHost/makefile index ff783f0b7..8453a491d 100644 --- a/Demos/Host/ClassDriver/RNDISEthernetHost/makefile +++ b/Demos/Host/ClassDriver/RNDISEthernetHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -133,7 +133,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -146,7 +146,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -297,7 +297,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -320,7 +320,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -417,7 +417,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -504,11 +504,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -635,14 +635,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c b/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c index f5d1b23fd..35d41d4c4 100644 --- a/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c +++ b/Demos/Host/ClassDriver/StillImageHost/StillImageHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the StillImageHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "StillImageHost.h" /** LUFA Still Image Class driver interface configuration and state information. This structure is @@ -46,10 +46,10 @@ USB_ClassInfo_SI_Host_t DigitalCamera_SI_Interface = { .DataINPipeNumber = 1, .DataINPipeDoubleBank = false, - + .DataOUTPipeNumber = 2, .DataOUTPipeDoubleBank = false, - + .EventsPipeNumber = 3, .EventsPipeDoubleBank = false, }, @@ -73,7 +73,7 @@ int main(void) { case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - + uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; @@ -94,7 +94,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Device Configuration.\r\n")); @@ -102,14 +102,14 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("Still Image Device Enumerated.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: puts_P(PSTR("Opening Session...\r\n")); - + if (SI_Host_OpenSession(&DigitalCamera_SI_Interface) != PIPE_RWSTREAM_NoError) { puts_P(PSTR("Could not open PIMA session.\r\n")); @@ -124,7 +124,7 @@ int main(void) { puts_P(PSTR("Could not turn off device.\r\n")); USB_HostState = HOST_STATE_WaitForDeviceRemoval; - break; + break; } puts_P(PSTR("Device Off.\r\n")); @@ -137,12 +137,12 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + SI_Host_USBTask(&DigitalCamera_SI_Interface); USB_USBTask(); } @@ -212,6 +212,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } + diff --git a/Demos/Host/ClassDriver/StillImageHost/StillImageHost.h b/Demos/Host/ClassDriver/StillImageHost/StillImageHost.h index 1b776596b..3f4375dc7 100644 --- a/Demos/Host/ClassDriver/StillImageHost/StillImageHost.h +++ b/Demos/Host/ClassDriver/StillImageHost/StillImageHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/StillImage.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -63,15 +63,16 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /* Function Prototypes: */ void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + #endif + diff --git a/Demos/Host/ClassDriver/StillImageHost/StillImageHost.txt b/Demos/Host/ClassDriver/StillImageHost/StillImageHost.txt index 95a2e14b5..2dc3b662b 100644 --- a/Demos/Host/ClassDriver/StillImageHost/StillImageHost.txt +++ b/Demos/Host/ClassDriver/StillImageHost/StillImageHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Still Image Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Still Image Device</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -40,12 +40,12 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Still Image host demonstration application. This gives a simple reference * application for implementing a Still Image host, for USB devices such as * digital cameras. - * + * * This demo will enumerate an attached USB Still Image device, print out its * information structure, open a session with the device and finally close the * session. @@ -62,3 +62,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/ClassDriver/StillImageHost/makefile b/Demos/Host/ClassDriver/StillImageHost/makefile index 6c36513b2..8c6cdb53e 100644 --- a/Demos/Host/ClassDriver/StillImageHost/makefile +++ b/Demos/Host/ClassDriver/StillImageHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -133,7 +133,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -146,7 +146,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -297,7 +297,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -320,7 +320,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -417,7 +417,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -504,11 +504,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -635,14 +635,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.c b/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.c index c48694274..bca146e35 100644 --- a/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.c +++ b/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the VirtualSerialHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "VirtualSerialHost.h" /** LUFA CDC Class driver interface configuration and state information. This structure is @@ -54,7 +54,7 @@ USB_ClassInfo_CDC_Host_t VirtualSerial_CDC_Interface = .NotificationPipeDoubleBank = false, }, }; - + /** Main program entry point. This routine configures the hardware required by the application, then * enters a loop to run the application tasks in sequence. */ @@ -73,7 +73,7 @@ int main(void) { case HOST_STATE_Addressed: LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); - + uint16_t ConfigDescriptorSize; uint8_t ConfigDescriptorData[512]; @@ -94,7 +94,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful) { puts_P(PSTR("Error Setting Device Configuration.\r\n")); @@ -102,7 +102,7 @@ int main(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("CDC Device Enumerated.\r\n")); LEDs_SetAllLEDs(LEDMASK_USB_READY); USB_HostState = HOST_STATE_Configured; @@ -115,10 +115,10 @@ int main(void) if (!(ReceivedByte < 0)) putchar(ReceivedByte); } - + break; } - + CDC_Host_USBTask(&VirtualSerial_CDC_Interface); USB_USBTask(); } @@ -188,6 +188,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } + diff --git a/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.h b/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.h index ed4ffcef7..e873f539f 100644 --- a/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.h +++ b/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/CDC.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -63,15 +63,16 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /* Function Prototypes: */ void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + #endif + diff --git a/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.txt b/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.txt index d771b7976..80a470818 100644 --- a/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.txt +++ b/Demos/Host/ClassDriver/VirtualSerialHost/VirtualSerialHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage CDC Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Communications Device Class (CDC)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>Abstract Control Model (ACM)</td> * </tr> @@ -39,13 +39,13 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * CDC host demonstration application. This gives a simple reference application * for implementing a USB CDC host, for CDC devices using the standard ACM profile. - * + * * This demo prints out received CDC data through the serial port. - * + * * Not that this demo is only compatible with devices which report the correct CDC * and ACM class, subclass and protocol values. Most USB-Serial cables have vendor * specific features, thus use vendor-specific class/subclass/protocol codes to force @@ -63,3 +63,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/ClassDriver/VirtualSerialHost/makefile b/Demos/Host/ClassDriver/VirtualSerialHost/makefile index 8bd6949db..38ac416b8 100644 --- a/Demos/Host/ClassDriver/VirtualSerialHost/makefile +++ b/Demos/Host/ClassDriver/VirtualSerialHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -133,7 +133,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -146,7 +146,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -297,7 +297,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -320,7 +320,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -417,7 +417,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -504,11 +504,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -635,14 +635,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/ClassDriver/makefile b/Demos/Host/ClassDriver/makefile index e1c22d35e..95f8634dc 100644 --- a/Demos/Host/ClassDriver/makefile +++ b/Demos/Host/ClassDriver/makefile @@ -1,7 +1,7 @@ # # LUFA Library # Copyright (C) Dean Camera, 2010. -# +# # dean [at] fourwalledcubicle [dot] com # www.fourwalledcubicle.com # @@ -15,7 +15,7 @@ all: $(MAKE) -C JoystickHostWithParser clean - $(MAKE) -C JoystickHostWithParser all + $(MAKE) -C JoystickHostWithParser all $(MAKE) -C KeyboardHost clean $(MAKE) -C KeyboardHost all @@ -45,8 +45,8 @@ all: $(MAKE) -C StillImageHost all $(MAKE) -C VirtualSerialHost clean - $(MAKE) -C VirtualSerialHost all - + $(MAKE) -C VirtualSerialHost all + %: $(MAKE) -C JoystickHostWithParser $@ $(MAKE) -C KeyboardHost $@ @@ -59,3 +59,4 @@ all: $(MAKE) -C RNDISEthernetHost $@ $(MAKE) -C StillImageHost $@ $(MAKE) -C VirtualSerialHost $@ + diff --git a/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c b/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c index 543e1b879..de4db0c50 100644 --- a/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c +++ b/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.c @@ -191,3 +191,4 @@ void RFCOMM_ChannelSignalsReceived(RFCOMM_Channel_t* const RFCOMMChannel) {
// Currently do nothing in response to the remote device sending new terminal control signals
}
+ diff --git a/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.h b/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.h index 336f61d5e..3e1b70457 100644 --- a/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.h +++ b/Demos/Host/Incomplete/BluetoothHost/BluetoothEvents.h @@ -69,3 +69,4 @@ extern RFCOMM_Channel_t* SerialChannel_RFCOMM;
#endif
+ diff --git a/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c b/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c index 8301e85bd..c2139154c 100644 --- a/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c +++ b/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -52,14 +52,14 @@ int main(void) SetupHardware(); puts_P(PSTR(ESC_FG_CYAN "Bluetooth Host Demo running.\r\n" ESC_FG_WHITE)); - + LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); sei(); for (;;) { RFCOMM_ServiceChannels(SerialChannel_ACL); - + Bluetooth_Host_Task(); Bluetooth_Stack_USBTask(); USB_USBTask(); @@ -130,7 +130,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } @@ -143,7 +143,7 @@ void Bluetooth_Host_Task(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Device Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessDeviceDescriptor()) != SuccessfulDeviceRead) { @@ -153,7 +153,7 @@ void Bluetooth_Host_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDS_LED1); @@ -177,9 +177,9 @@ void Bluetooth_Host_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("Getting Config Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -189,7 +189,7 @@ void Bluetooth_Host_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDS_LED1); @@ -199,7 +199,7 @@ void Bluetooth_Host_Task(void) } puts_P(PSTR("Bluetooth Dongle Enumerated.\r\n")); - + /* Initialize the Bluetooth stack */ Bluetooth_Stack_Init(); @@ -207,3 +207,4 @@ void Bluetooth_Host_Task(void) break; } } + diff --git a/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.h b/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.h index 0814845a0..a5148900f 100644 --- a/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.h +++ b/Demos/Host/Incomplete/BluetoothHost/BluetoothHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -54,7 +54,7 @@ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Board/LEDs.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -73,7 +73,7 @@ /* Task Definitions: */ void Bluetooth_Host_Task(void); - + /* Event Handlers: */ void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); @@ -84,5 +84,6 @@ /* Function Prototypes: */ void SetupHardware(void); - + #endif + diff --git a/Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.c b/Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.c index cc7570387..447bf00a4 100644 --- a/Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.c +++ b/Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; USB_Descriptor_Endpoint_t* EventsEndpoint = NULL; @@ -67,11 +67,11 @@ uint8_t ProcessConfigurationDescriptor(void) default: return DevControlError; } - + /* The Bluetooth USB transport addendum mandates that the data (not streaming voice) endpoints be in the first interface descriptor (interface 0) */ USB_GetNextDescriptorOfType(&CurrConfigBytesRem, &CurrConfigLocation, DTYPE_Interface); - + /* Ensure that an interface was found, and the end of the descriptor was not reached */ if (!(CurrConfigBytesRem)) return NoCompatibleInterfaceFound; @@ -103,7 +103,7 @@ uint8_t ProcessConfigurationDescriptor(void) DataOUTEndpoint = EndpointData; } } - + /* Configure the Bluetooth data IN pipe */ Pipe_ConfigurePipe(BLUETOOTH_DATA_IN_PIPE, EP_TYPE_BULK, PIPE_TOKEN_IN, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE); @@ -125,7 +125,7 @@ uint8_t ProcessConfigurationDescriptor(void) * configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration * descriptor processing if an incompatible descriptor configuration is found. * - * This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the + * This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the * search if another interface descriptor is found before the required endpoint. * * \return A value from the DSEARCH_Return_ErrorCodes_t enum diff --git a/Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.h b/Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.h index 25442b87b..6d1ec2d49 100644 --- a/Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.h +++ b/Demos/Host/Incomplete/BluetoothHost/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,7 +38,7 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + /* Macros: */ #define BLUETOOTH_DATA_IN_PIPE 1 #define BLUETOOTH_DATA_OUT_PIPE 2 @@ -54,10 +54,11 @@ InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */ NoCompatibleInterfaceFound = 4, /**< A compatible interface with the required endpoints was not found */ }; - + /* Function Prototypes: */ uint8_t ProcessConfigurationDescriptor(void); - + uint8_t DComp_NextInterfaceBluetoothDataEndpoint(void* CurrentDescriptor); #endif + diff --git a/Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.c b/Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.c index 22a9c3506..707180023 100644 --- a/Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.c +++ b/Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -30,7 +30,7 @@ /** \file * - * USB Device Descriptor processing routines, to determine the overall device parameters. Descriptors are special + * USB Device Descriptor processing routines, to determine the overall device parameters. Descriptors are special * computer-readable structures which the host requests upon device enumeration, to determine information about * the attached device. */ @@ -50,11 +50,11 @@ uint8_t ProcessDeviceDescriptor(void) /* Send the request to retrieve the device descriptor */ if (USB_Host_GetDeviceDescriptor(&DeviceDescriptor) != HOST_SENDCONTROL_Successful) return DevControlError; - + /* Validate returned data - ensure the returned data is a device descriptor */ if (DeviceDescriptor.Header.Type != DTYPE_Device) return InvalidDeviceDataReturned; - + /* Validate returned device Class, SubClass and Protocol values against the Bluetooth spec values */ if ((DeviceDescriptor.Class != BLUETOOTH_DEVICE_CLASS) || (DeviceDescriptor.SubClass != BLUETOOTH_DEVICE_SUBCLASS) || @@ -62,6 +62,7 @@ uint8_t ProcessDeviceDescriptor(void) { return IncorrectBTDevice; } - + return SuccessfulDeviceRead; } + diff --git a/Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.h b/Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.h index 06bbc8526..1c017d386 100644 --- a/Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.h +++ b/Demos/Host/Incomplete/BluetoothHost/DeviceDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,9 +38,9 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "BluetoothHost.h" - + /* Macros: */ /** Device Class value for the Bluetooth Device class. */ #define BLUETOOTH_DEVICE_CLASS 0xE0 @@ -62,6 +62,7 @@ }; /* Function Prototypes: */ - uint8_t ProcessDeviceDescriptor(void); + uint8_t ProcessDeviceDescriptor(void); #endif + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c index 939b2ae5f..35b1e920d 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,14 +50,14 @@ void Bluetooth_ACLTask(void) { /* Process incoming ACL packets, if any */ Bluetooth_ProcessIncomingACLPackets(); - + /* Check for any half-open channels, send configuration details to the remote device if found */ for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++) { Bluetooth_Channel_t* ChannelData = &Bluetooth_Connection.Channels[i]; - + bool MustSendConfigReq = true; - + /* Check if we are in a channel state which requires a configuration request to be sent */ switch (ChannelData->State) { @@ -71,7 +71,7 @@ void Bluetooth_ACLTask(void) MustSendConfigReq = false; break; } - + /* Only send a configuration request if it the channel was in a state which required it */ if (MustSendConfigReq) { @@ -79,14 +79,14 @@ void Bluetooth_ACLTask(void) { BT_Signal_Header_t SignalCommandHeader; BT_Signal_ConfigurationReq_t ConfigurationRequest; - + struct { BT_Config_Option_Header_t Header; uint16_t Value; } Option_LocalMTU; } PacketData; - + /* Fill out the Signal Command header in the response packet */ PacketData.SignalCommandHeader.Code = BT_SIGNAL_CONFIGURATION_REQUEST; PacketData.SignalCommandHeader.Identifier = ++Bluetooth_Connection.SignalingIdentifier; @@ -101,7 +101,7 @@ void Bluetooth_ACLTask(void) PacketData.Option_LocalMTU.Value = ChannelData->LocalMTU; Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL); - + BT_ACL_DEBUG(1, ">> L2CAP Configuration Request"); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.ConfigurationRequest.DestinationChannel); } @@ -119,13 +119,13 @@ static void Bluetooth_ProcessIncomingACLPackets(void) Pipe_SelectPipe(BLUETOOTH_DATA_IN_PIPE); Pipe_Unfreeze(); - + if (!(Pipe_IsReadWriteAllowed())) { Pipe_Freeze(); return; } - + /* Read in the received ACL packet headers when it has been discovered that a packet has been received */ Pipe_Read_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader)); Pipe_Read_Stream_LE(&DataHeader, sizeof(DataHeader)); @@ -143,7 +143,7 @@ static void Bluetooth_ProcessIncomingACLPackets(void) /* Read in the Signal Command header of the incoming packet */ BT_Signal_Header_t SignalCommandHeader; Pipe_Read_Stream_LE(&SignalCommandHeader, sizeof(SignalCommandHeader)); - + /* Dispatch to the appropriate handler function based on the Signal message code */ switch (SignalCommandHeader.Code) { @@ -173,20 +173,20 @@ static void Bluetooth_ProcessIncomingACLPackets(void) break; case BT_SIGNAL_COMMAND_REJECT: BT_ACL_DEBUG(1, "<< Command Reject"); - + uint16_t RejectReason; Pipe_Read_Stream_LE(&RejectReason, sizeof(RejectReason)); Pipe_Discard_Stream(ACLPacketHeader.DataLength - sizeof(RejectReason)); Pipe_ClearIN(); - Pipe_Freeze(); - + Pipe_Freeze(); + BT_ACL_DEBUG(2, "-- Reason: %d", RejectReason); break; default: BT_ACL_DEBUG(1, "<< Unknown Signaling Command 0x%02X", SignalCommandHeader.Code); - + Pipe_Discard_Stream(ACLPacketHeader.DataLength); - Pipe_ClearIN(); + Pipe_ClearIN(); Pipe_Freeze(); break; } @@ -198,7 +198,7 @@ static void Bluetooth_ProcessIncomingACLPackets(void) Pipe_Read_Stream_LE(PacketData, DataHeader.PayloadLength); Pipe_ClearIN(); Pipe_Freeze(); - + Bluetooth_PacketReceived(PacketData, DataHeader.PayloadLength, Bluetooth_GetChannelData(DataHeader.DestinationChannel, CHANNEL_SEARCH_LOCALNUMBER)); } @@ -221,9 +221,9 @@ Bluetooth_Channel_t* Bluetooth_GetChannelData(const uint16_t SearchValue, /* Closed channels should be ignored as they are not considered valid data */ if (ChannelData->State == BT_Channel_Closed) continue; - + bool FoundMatch = false; - + /* Search the current channel for the search key to see if it matches */ switch (SearchKey) { @@ -237,7 +237,7 @@ Bluetooth_Channel_t* Bluetooth_GetChannelData(const uint16_t SearchValue, FoundMatch = (SearchValue == ChannelData->PSM); break; } - + if (FoundMatch) return ChannelData; } @@ -285,9 +285,9 @@ uint8_t Bluetooth_SendPacket(void* Data, Pipe_Write_Stream_LE(&DataHeader, sizeof(DataHeader)); Pipe_Write_Stream_LE(Data, DataLen); Pipe_ClearOUT(); - + Pipe_Freeze(); - + BT_ACL_DEBUG(2, ""); BT_ACL_DEBUG(2, "Packet Sent"); BT_ACL_DEBUG(2, "-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF)); @@ -319,7 +319,7 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM) if (Bluetooth_Connection.Channels[i].State == BT_Channel_Closed) { ChannelData = &Bluetooth_Connection.Channels[i]; - + /* Set the new channel structure's local channel number to a unique value within the connection orientated channel address space */ ChannelData->LocalNumber = (BT_CHANNELNUMBER_BASEOFFSET + i); @@ -336,7 +336,7 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM) ChannelData->PSM = PSM; ChannelData->LocalMTU = MAXIMUM_CHANNEL_MTU; ChannelData->State = BT_Channel_WaitConnectRsp; - + struct { BT_Signal_Header_t SignalCommandHeader; @@ -347,11 +347,11 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM) PacketData.SignalCommandHeader.Code = BT_SIGNAL_CONNECTION_REQUEST; PacketData.SignalCommandHeader.Identifier = ++Bluetooth_Connection.SignalingIdentifier; PacketData.SignalCommandHeader.Length = sizeof(PacketData.ConnectionRequest); - + /* Fill out the Connection Request in the response packet */ PacketData.ConnectionRequest.PSM = PSM; PacketData.ConnectionRequest.SourceChannel = ChannelData->LocalNumber; - + Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL); BT_ACL_DEBUG(1, ">> L2CAP Connection Request"); @@ -385,7 +385,7 @@ void Bluetooth_CloseChannel(Bluetooth_Channel_t* const ACLChannel) BT_Signal_Header_t SignalCommandHeader; BT_Signal_DisconnectionReq_t DisconnectionRequest; } PacketData; - + /* Fill out the Signal Command header in the response packet */ PacketData.SignalCommandHeader.Code = BT_SIGNAL_DISCONNECTION_REQUEST; PacketData.SignalCommandHeader.Identifier = ++Bluetooth_Connection.SignalingIdentifier; @@ -396,10 +396,10 @@ void Bluetooth_CloseChannel(Bluetooth_Channel_t* const ACLChannel) PacketData.DisconnectionRequest.SourceChannel = ACLChannel->LocalNumber; Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL); - + BT_ACL_DEBUG(1, ">> L2CAP Disconnection Request"); - BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.DisconnectionRequest.DestinationChannel); - BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", PacketData.DisconnectionRequest.SourceChannel); + BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.DisconnectionRequest.DestinationChannel); + BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", PacketData.DisconnectionRequest.SourceChannel); } /** Internal Bluetooth stack Signal Command processing routine for a Connection Request command. @@ -409,12 +409,12 @@ void Bluetooth_CloseChannel(Bluetooth_Channel_t* const ACLChannel) static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* const SignalCommandHeader) { BT_Signal_ConnectionReq_t ConnectionRequest; - + Pipe_Read_Stream_LE(&ConnectionRequest, sizeof(ConnectionRequest)); Pipe_ClearIN(); Pipe_Freeze(); - + BT_ACL_DEBUG(1, "<< L2CAP Connection Request"); BT_ACL_DEBUG(2, "-- PSM: 0x%04X", ConnectionRequest.PSM); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionRequest.SourceChannel); @@ -439,7 +439,7 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons } } } - + uint8_t ChannelStatus = BT_CONNECTION_REFUSED_RESOURCES; /* Reset the channel item contents only if a channel entry was found for it */ @@ -452,15 +452,15 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons ChannelData->PSM = ConnectionRequest.PSM; ChannelData->LocalMTU = MAXIMUM_CHANNEL_MTU; ChannelData->State = BT_Channel_Config_WaitConfig; - + ChannelStatus = BT_CONNECTION_SUCCESSFUL; } else { - ChannelStatus = BT_CONNECTION_REFUSED_PSM; + ChannelStatus = BT_CONNECTION_REFUSED_PSM; } } - + struct { BT_Signal_Header_t SignalCommandHeader; @@ -477,7 +477,7 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons ResponsePacket.ConnectionResponse.SourceChannel = ChannelData->RemoteNumber; ResponsePacket.ConnectionResponse.Result = ChannelStatus; ResponsePacket.ConnectionResponse.Status = 0x00; - + Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL); BT_ACL_DEBUG(1, ">> L2CAP Connection Response"); @@ -493,16 +493,16 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons static inline void Bluetooth_Signal_ConnectionResp(const BT_Signal_Header_t* const SignalCommandHeader) { BT_Signal_ConnectionResp_t ConnectionResponse; - + Pipe_Read_Stream_LE(&ConnectionResponse, sizeof(ConnectionResponse)); Pipe_ClearIN(); Pipe_Freeze(); BT_ACL_DEBUG(1, "<< L2CAP Connection Response"); - BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConnectionResponse.Result); - BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel); - BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel); + BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConnectionResponse.Result); + BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel); + BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel); /* Search for the referenced channel in the channel information list */ Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConnectionResponse.SourceChannel, CHANNEL_SEARCH_LOCALNUMBER); @@ -524,12 +524,12 @@ static inline void Bluetooth_Signal_ConnectionResp(const BT_Signal_Header_t* con static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* const SignalCommandHeader) { BT_Signal_ConfigurationReq_t ConfigurationRequest; - + /* Allocate a buffer large enough to hold the variable number of configuration options in the request */ uint8_t OptionsLen = (SignalCommandHeader->Length - sizeof(ConfigurationRequest)); uint8_t Options[OptionsLen]; - Pipe_Read_Stream_LE(&ConfigurationRequest, sizeof(ConfigurationRequest)); + Pipe_Read_Stream_LE(&ConfigurationRequest, sizeof(ConfigurationRequest)); Pipe_Read_Stream_LE(&Options, sizeof(Options)); Pipe_ClearIN(); @@ -554,7 +554,7 @@ static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* c BT_ACL_DEBUG(2, "-- Option Type: 0x%04X", OptionHeader->Type); BT_ACL_DEBUG(2, "-- Option Length: 0x%04X", (sizeof(BT_Config_Option_Header_t) + OptionHeader->Length)); - + /* Store the remote MTU option's value if present */ if (OptionHeader->Type == BT_CONFIG_OPTION_MTU) ChannelData->RemoteMTU = *((uint16_t*)OptionData); @@ -563,7 +563,7 @@ static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* c OptionPos += (sizeof(BT_Config_Option_Header_t) + OptionHeader->Length); } } - + struct { BT_Signal_Header_t SignalCommandHeader; @@ -616,14 +616,14 @@ static inline void Bluetooth_Signal_ConfigurationResp(const BT_Signal_Header_t* Pipe_ClearIN(); Pipe_Freeze(); - + BT_ACL_DEBUG(1, "<< L2CAP Configuration Response"); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConfigurationResponse.SourceChannel); BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConfigurationResponse.Result); /* Search for the referenced channel in the channel information list */ Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConfigurationResponse.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER); - + /* Only update the channel's state if it was found in the channel list */ if (ChannelData != NULL) { @@ -639,7 +639,7 @@ static inline void Bluetooth_Signal_ConfigurationResp(const BT_Signal_Header_t* ChannelData->State = BT_Channel_Open; Bluetooth_ChannelOpened(ChannelData); break; - } + } } else { @@ -656,16 +656,16 @@ static inline void Bluetooth_Signal_ConfigurationResp(const BT_Signal_Header_t* static inline void Bluetooth_Signal_DisconnectionReq(const BT_Signal_Header_t* const SignalCommandHeader) { BT_Signal_DisconnectionReq_t DisconnectionRequest; - + Pipe_Read_Stream_LE(&DisconnectionRequest, sizeof(DisconnectionRequest)); BT_ACL_DEBUG(1, "<< L2CAP Disconnection Request"); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionRequest.DestinationChannel); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionRequest.SourceChannel); - + Pipe_ClearIN(); Pipe_Freeze(); - + /* Search for the referenced channel in the channel information list */ Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(DisconnectionRequest.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER); @@ -702,20 +702,20 @@ static inline void Bluetooth_Signal_DisconnectionReq(const BT_Signal_Header_t* c static inline void Bluetooth_Signal_DisconnectionResp(const BT_Signal_Header_t* const SignalCommandHeader) { BT_Signal_DisconnectionResp_t DisconnectionResponse; - + Pipe_Read_Stream_LE(&DisconnectionResponse, sizeof(DisconnectionResponse)); BT_ACL_DEBUG(1, "<< L2CAP Disconnection Response"); BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionResponse.DestinationChannel); BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionResponse.SourceChannel); - + Pipe_ClearIN(); Pipe_Freeze(); - + /* Search for the referenced channel in the channel information list */ Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(DisconnectionResponse.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER); - - /* If the channel was found in the channel list, close it */ + + /* If the channel was found in the channel list, close it */ if (ChannelData != NULL) ChannelData->State = BT_Channel_Closed; } @@ -727,10 +727,10 @@ static inline void Bluetooth_Signal_DisconnectionResp(const BT_Signal_Header_t* static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const SignalCommandHeader) { BT_ACL_DEBUG(1, "<< L2CAP Echo Request"); - + Pipe_ClearIN(); Pipe_Freeze(); - + struct { BT_Signal_Header_t SignalCommandHeader; @@ -740,7 +740,7 @@ static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const Sign ResponsePacket.SignalCommandHeader.Code = BT_SIGNAL_ECHO_RESPONSE; ResponsePacket.SignalCommandHeader.Identifier = SignalCommandHeader->Identifier; ResponsePacket.SignalCommandHeader.Length = 0; - + Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL); BT_ACL_DEBUG(1, ">> L2CAP Echo Response"); @@ -758,7 +758,7 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con BT_ACL_DEBUG(1, "<< L2CAP Information Request"); BT_ACL_DEBUG(2, "-- Info Type: 0x%04X", InformationRequest.InfoType); - + Pipe_ClearIN(); Pipe_Freeze(); @@ -766,25 +766,25 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con { BT_Signal_Header_t SignalCommandHeader; BT_Signal_InformationResp_t InformationResponse; - + uint8_t Data[4]; } ResponsePacket; - + uint8_t DataLen = 0; - + /* Retrieve the requested information and store it in the outgoing packet, if found */ switch (InformationRequest.InfoType) { - case BT_INFOREQ_MTU: + case BT_INFOREQ_MTU: ResponsePacket.InformationResponse.Result = BT_INFORMATION_SUCCESSFUL; DataLen = 2; - + *((uint16_t*)&ResponsePacket.Data) = MAXIMUM_CHANNEL_MTU; break; case BT_INFOREQ_EXTENDEDFEATURES: ResponsePacket.InformationResponse.Result = BT_INFORMATION_SUCCESSFUL; DataLen = 4; - + *((uint32_t*)&ResponsePacket.Data) = 0; break; default: @@ -792,7 +792,7 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con DataLen = 0; break; } - + /* Fill out the Signal Command header in the response packet */ ResponsePacket.SignalCommandHeader.Code = BT_SIGNAL_INFORMATION_RESPONSE; ResponsePacket.SignalCommandHeader.Identifier = SignalCommandHeader->Identifier; @@ -800,9 +800,10 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con /* Fill out the Information Response in the response packet */ ResponsePacket.InformationResponse.InfoType = InformationRequest.InfoType; - + Bluetooth_SendPacket(&ResponsePacket, (sizeof(ResponsePacket) - sizeof(ResponsePacket.Data) + DataLen), NULL); - BT_ACL_DEBUG(1, ">> L2CAP Information Response"); + BT_ACL_DEBUG(1, ">> L2CAP Information Response"); BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.InformationResponse.Result); } + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h index efe9d39f6..4c587d597 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothACLPackets.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -44,13 +44,13 @@ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/Peripheral/SerialStream.h> - + #include "BluetoothStack.h" - + /* Macros: */ #define BT_ACL_DEBUG(l, s, ...) do { if (ACL_DEBUG_LEVEL >= l) printf_P(PSTR("(ACL) " s "\r\n"), ##__VA_ARGS__); } while (0) #define ACL_DEBUG_LEVEL 0 - + /** Lowest possible channel number for L2CAP data channels. */ #define BT_CHANNELNUMBER_BASEOFFSET 0x0040 @@ -59,7 +59,7 @@ /** Bluetooth specification defined channel number for connectionless data. */ #define BT_CHANNEL_CONNECTIONLESS 0x0002 - + #define BT_ACL_FIRST_AUTOFLUSH (1 << 13) #define BT_SIGNAL_COMMAND_REJECT 0x01 @@ -73,23 +73,23 @@ #define BT_SIGNAL_ECHO_RESPONSE 0x09 #define BT_SIGNAL_INFORMATION_REQUEST 0x0A #define BT_SIGNAL_INFORMATION_RESPONSE 0x0B - + #define BT_INFOREQ_MTU 0x0001 #define BT_INFOREQ_EXTENDEDFEATURES 0x0002 - + #define BT_INFORMATION_SUCCESSFUL 0x0000 #define BT_INFORMATION_NOTSUPPORTED 0x0001 - + #define BT_CONNECTION_SUCCESSFUL 0x0000 #define BT_CONNECTION_REFUSED_PSM 0x0002 #define BT_CONNECTION_REFUSED_RESOURCES 0x0004 - + #define BT_CONFIGURATION_SUCCESSFUL 0x0000 #define BT_CONFIGURATION_REJECTED 0x0002 #define BT_CONFIGURATION_UNKNOWNOPTIONS 0x0003 - + #define BT_CONFIG_OPTION_MTU 1 - + /* Type Defines: */ /** Bluetooth ACL header structure, common to all ACL data packets. */ typedef struct @@ -104,7 +104,7 @@ uint16_t PayloadLength; /**< Size of the data payload, in bytes */ uint16_t DestinationChannel; /**< Destination channel in the device the data is directed to */ } BT_DataPacket_Header_t; - + /** Bluetooth signaling command header structure, for all ACL packets containing a signaling command. */ typedef struct { @@ -112,7 +112,7 @@ uint8_t Identifier; /**< Unique signal command identifier to link requests and responses */ uint16_t Length; /**< Length of the signaling command data, in bytes */ } BT_Signal_Header_t; - + /** Connection Request signaling command structure, for channel connection requests. */ typedef struct { @@ -135,13 +135,13 @@ uint16_t DestinationChannel; /**< Destination channel address which is to be disconnected */ uint16_t SourceChannel; /**< Source channel address which is to be disconnected */ } BT_Signal_DisconnectionReq_t; - + /** Disconnection response signaling command structure, for responses to channel disconnection requests. */ typedef struct { uint16_t DestinationChannel; /**< Destination channel address which was disconnected */ uint16_t SourceChannel; /**< Source channel address which was disconnected */ - } BT_Signal_DisconnectionResp_t; + } BT_Signal_DisconnectionResp_t; /** Configuration Request signaling command structure, for channel configuration requests. */ typedef struct @@ -163,14 +163,14 @@ { uint16_t InfoType; /**< Data type that is being requested, a BT_INFOREQ_* mask value */ } BT_Signal_InformationReq_t; - + /** Information Response signaling command structure, for responses to information requests. */ typedef struct { uint16_t InfoType; /**< Data type that was requested, a BT_INFOREQ_* mask value */ uint16_t Result; /**< Result of the request, a BT_INFORMATION_* mask value */ } BT_Signal_InformationResp_t; - + /** Configuration Option header structure, placed at the start of each option in a Channel Configuration * request's options list. */ @@ -182,7 +182,7 @@ /* Function Prototypes: */ void Bluetooth_ACLTask(void); - + #if defined(INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C) static void Bluetooth_ProcessIncomingACLPackets(void); @@ -195,5 +195,6 @@ static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const SignalCommandHeader); static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* const SignalCommandHeader); #endif - + #endif + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothClassCodes.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothClassCodes.h index c4690f4a8..f0699373d 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothClassCodes.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothClassCodes.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -46,7 +46,7 @@ #define DEVICE_CLASS_SERVICE_AUDIO (1UL << 21) #define DEVICE_CLASS_SERVICE_TELEPHONY (1UL << 22) #define DEVICE_CLASS_SERVICE_INFORMATION (1UL << 23) - + #define DEVICE_CLASS_MAJOR_MISC (0x00 << 8) #define DEVICE_CLASS_MAJOR_COMPUTER (0x01 << 8) #define DEVICE_CLASS_MAJOR_PHONE (0x02 << 8) @@ -63,7 +63,7 @@ #define DEVICE_CLASS_MINOR_COMPUTER_HANDHELD (0x04 << 2) #define DEVICE_CLASS_MINOR_COMPUTER_PALM (0x05 << 2) #define DEVICE_CLASS_MINOR_COMPUTER_WEARABLE (0x06 << 2) - + #define DEVICE_CLASS_MINOR_PHONE_UNCATEGORIZED (0x00 << 2) #define DEVICE_CLASS_MINOR_PHONE_CELLULAR (0x01 << 2) #define DEVICE_CLASS_MINOR_PHONE_CORDLESS (0x02 << 2) @@ -79,7 +79,7 @@ #define DEVICE_CLASS_MINOR_LAN_67_TO_83_PC_UTILIZED (0x05 << 5) #define DEVICE_CLASS_MINOR_LAN_83_TO_99_PC_UTILIZED (0x06 << 5) #define DEVICE_CLASS_MINOR_LAN_NO_SERVICE_AVAILABLE (0x07 << 5) - + #define DEVICE_CLASS_MINOR_AV_UNCATEGORIZED (0x00 << 2) #define DEVICE_CLASS_MINOR_AV_HEADSET (0x01 << 2) #define DEVICE_CLASS_MINOR_AV_HANDSFREE (0x02 << 2) @@ -97,7 +97,7 @@ #define DEVICE_CLASS_MINOR_AV_DISPLAY_AND_LOUDSPEAKER (0x0F << 2) #define DEVICE_CLASS_MINOR_AV_VIDEO_CONFERENCING (0x10 << 2) #define DEVICE_CLASS_MINOR_AV_GAMING_TOY (0x12 << 2) - + #define DEVICE_CLASS_MINOR_PERIPHERAL_KEYBOARD (0x01 << 6) #define DEVICE_CLASS_MINOR_PERIPHERAL_POINTING (0x02 << 6) #define DEVICE_CLASS_MINOR_PERIPHERAL_COMBO (0x03 << 6) @@ -115,3 +115,4 @@ #define DEVICE_CLASS_MINOR_IMAGING_PRINTER (1 << 7) #endif + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c index 7f6f8b78d..0cf18f21c 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -59,28 +59,28 @@ void Bluetooth_HCITask(void) case Bluetooth_ProcessEvents: Pipe_SelectPipe(BLUETOOTH_EVENTS_PIPE); Pipe_Unfreeze(); - + if (Pipe_IsReadWriteAllowed()) { BT_HCIEvent_Header_t HCIEventHeader; /* Read in the event header to fetch the event code and payload length */ Pipe_Read_Stream_LE(&HCIEventHeader, sizeof(HCIEventHeader)); - + /* Create a temporary buffer for the event parameters */ uint8_t EventParams[HCIEventHeader.ParameterLength]; /* Read in the event parameters into the temporary buffer */ Pipe_Read_Stream_LE(&EventParams, HCIEventHeader.ParameterLength); Pipe_ClearIN(); - + BT_HCI_DEBUG(1, "Event Received (0x%02X)", HCIEventHeader.EventCode); switch (HCIEventHeader.EventCode) { case EVENT_COMMAND_COMPLETE: BT_HCI_DEBUG(1, "<< Command Complete"); - + /* Check which operation was completed in case we need to process the even parameters */ switch (((BT_HCIEvent_CommandComplete_t*)&EventParams)->Opcode) { @@ -91,7 +91,7 @@ void Bluetooth_HCITask(void) sizeof(Bluetooth_State.LocalBDADDR)); break; } - + Bluetooth_State.CurrentHCIState = Bluetooth_State.NextHCIState; break; case EVENT_COMMAND_STATUS: @@ -110,7 +110,7 @@ void Bluetooth_HCITask(void) memcpy(Bluetooth_TempDeviceAddress, &((BT_HCIEvent_ConnectionRequest_t*)&EventParams)->RemoteAddress, sizeof(Bluetooth_TempDeviceAddress)); - + bool IsACLConnection = (((BT_HCIEvent_ConnectionRequest_t*)&EventParams)->LinkType == 0x01); /* Only accept the connection if it is a ACL (data) connection, a device is not already connected @@ -135,12 +135,12 @@ void Bluetooth_HCITask(void) break; case EVENT_LINK_KEY_REQUEST: BT_HCI_DEBUG(1, "<< Link Key Request"); - + /* Need to store the remote device's BT address in a temporary buffer for later use */ memcpy(Bluetooth_TempDeviceAddress, &((BT_HCIEvent_LinkKeyReq_t*)&EventParams)->RemoteAddress, - sizeof(Bluetooth_TempDeviceAddress)); - + sizeof(Bluetooth_TempDeviceAddress)); + Bluetooth_State.CurrentHCIState = Bluetooth_Conn_SendLinkKeyNAK; break; case EVENT_CONNECTION_COMPLETE: @@ -155,22 +155,22 @@ void Bluetooth_HCITask(void) /* Store the created connection handle and indicate that the connection has been established */ Bluetooth_Connection.ConnectionHandle = ((BT_HCIEvent_ConnectionComplete_t*)&EventParams)->ConnectionHandle; Bluetooth_Connection.IsConnected = true; - - Bluetooth_ConnectionComplete(); + + Bluetooth_ConnectionComplete(); break; case EVENT_DISCONNECTION_COMPLETE: BT_HCI_DEBUG(1, "<< Disconnection Complete"); /* Device disconnected, indicate connection information no longer valid */ Bluetooth_Connection.IsConnected = false; - + Bluetooth_DisconnectionComplete(); break; } } - + Pipe_Freeze(); - + break; case Bluetooth_Init: BT_HCI_DEBUG(1, "# Init"); @@ -180,7 +180,7 @@ void Bluetooth_HCITask(void) /* Reset the connection information structure to destroy any previous connection state */ memset(&Bluetooth_Connection, 0x00, sizeof(Bluetooth_Connection)); - Bluetooth_State.CurrentHCIState = Bluetooth_Init_Reset; + Bluetooth_State.CurrentHCIState = Bluetooth_Init_Reset; break; case Bluetooth_Init_Reset: BT_HCI_DEBUG(1, "# Reset"); @@ -193,13 +193,13 @@ void Bluetooth_HCITask(void) /* Send the command to reset the Bluetooth dongle controller */ Bluetooth_SendHCICommand(&HCICommandHeader, NULL, 0); - + Bluetooth_State.NextHCIState = Bluetooth_Init_ReadBufferSize; Bluetooth_State.CurrentHCIState = Bluetooth_ProcessEvents; break; case Bluetooth_Init_ReadBufferSize: BT_HCI_DEBUG(1, "# Read Buffer Size"); - + HCICommandHeader = (BT_HCICommand_Header_t) { OpCode: (OGF_CTRLR_INFORMATIONAL | OCF_CTRLR_INFORMATIONAL_READBUFFERSIZE), @@ -214,7 +214,7 @@ void Bluetooth_HCITask(void) break; case Bluetooth_Init_GetBDADDR: BT_HCI_DEBUG(1, "# Get BDADDR"); - + HCICommandHeader = (BT_HCICommand_Header_t) { OpCode: (OGF_CTRLR_INFORMATIONAL | OCF_CTRLR_INFORMATIONAL_READBDADDR), @@ -267,10 +267,10 @@ void Bluetooth_HCITask(void) }; uint8_t Interval = BT_SCANMODE_InquiryAndPageScans; - + /* Send the command to set the remote device scanning mode */ Bluetooth_SendHCICommand(&HCICommandHeader, &Interval, 1); - + Bluetooth_State.NextHCIState = Bluetooth_Init_FinalizeInit; Bluetooth_State.CurrentHCIState = Bluetooth_ProcessEvents; break; @@ -301,7 +301,7 @@ void Bluetooth_HCITask(void) /* Send the command to accept the remote connection request */ Bluetooth_SendHCICommand(&HCICommandHeader, &AcceptConnectionParams, sizeof(BT_HCICommand_AcceptConnectionReq_t)); - + Bluetooth_State.CurrentHCIState = Bluetooth_ProcessEvents; break; case Bluetooth_Conn_RejectConnection: @@ -321,7 +321,7 @@ void Bluetooth_HCITask(void) /* Send the command to reject the remote connection request */ Bluetooth_SendHCICommand(&HCICommandHeader, &RejectConnectionParams, sizeof(BT_HCICommand_RejectConnectionReq_t)); - + Bluetooth_State.CurrentHCIState = Bluetooth_ProcessEvents; break; case Bluetooth_Conn_SendPINCode: @@ -339,7 +339,7 @@ void Bluetooth_HCITask(void) memcpy(PINCodeRequestParams.RemoteAddress, Bluetooth_TempDeviceAddress, sizeof(PINCodeRequestParams.RemoteAddress)); PINCodeRequestParams.PINCodeLength = strlen(Bluetooth_DeviceConfiguration.PINCode); memcpy(PINCodeRequestParams.PINCode, Bluetooth_DeviceConfiguration.PINCode, sizeof(PINCodeRequestParams.PINCode)); - + /* Send the command to transmit the device's local PIN number for authentication */ Bluetooth_SendHCICommand(&HCICommandHeader, &PINCodeRequestParams, sizeof(BT_HCICommand_PinCodeResp_t)); @@ -392,14 +392,15 @@ static uint8_t Bluetooth_SendHCICommand(const BT_HCICommand_Header_t* const HCIC /* Copy over the HCI command header to the allocated buffer */ memcpy(CommandBuffer, HCICommandHeader, sizeof(BT_HCICommand_Header_t)); - + /* Zero out the parameter section of the response so that all padding bytes are known to be zero */ memset(&CommandBuffer[sizeof(BT_HCICommand_Header_t)], 0x00, HCICommandHeader->ParameterLength); /* Copy over the command parameters (if any) to the command buffer - note, the number of actual source parameter bytes may differ to those in the header; any difference in length is filled with 0x00 padding bytes */ memcpy(&CommandBuffer[sizeof(BT_HCICommand_Header_t)], Parameters, ParameterLength); - + Pipe_SelectPipe(PIPE_CONTROLPIPE); return USB_Host_SendControlRequest(CommandBuffer); } + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h index 9476446f6..90074e841 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -82,7 +82,7 @@ #define OCF_CTRLR_BASEBAND_WRITE_AUTHENTICATION_ENABLE 0x0020 #define OCF_CTRLR_INFORMATIONAL_READBUFFERSIZE 0x0005 #define OCF_CTRLR_INFORMATIONAL_READBDADDR 0x0009 - + #define EVENT_COMMAND_STATUS 0x0F #define EVENT_COMMAND_COMPLETE 0x0E #define EVENT_CONNECTION_COMPLETE 0x03 @@ -91,10 +91,10 @@ #define EVENT_REMOTE_NAME_REQUEST_COMPLETE 0x07 #define EVENT_PIN_CODE_REQUEST 0x16 #define EVENT_LINK_KEY_REQUEST 0x17 - + #define ERROR_LIMITED_RESOURCES 0x0D #define ERROR_UNACCEPTABLE_BDADDR 0x0F - + /* Type Defines: */ typedef struct { @@ -115,7 +115,7 @@ uint8_t Packets; uint16_t OpCode; } BT_HCIEvent_CommandStatus_t; - + typedef struct { uint8_t HCIPacketsAllowable; @@ -139,7 +139,7 @@ uint8_t LinkType; uint8_t EncryptionEnabled; } BT_HCIEvent_ConnectionComplete_t; - + typedef struct { uint8_t RemoteAddress[6]; @@ -149,7 +149,7 @@ { uint8_t RemoteAddress[6]; } BT_HCIEvent_LinkKeyReq_t; - + typedef struct { uint8_t RemoteAddress[6]; @@ -161,18 +161,18 @@ uint8_t PINCodeLength; char PINCode[16]; } BT_HCICommand_PinCodeResp_t; - + typedef struct { uint8_t RemoteAddress[6]; uint8_t SlaveRole; } BT_HCICommand_AcceptConnectionReq_t; - + typedef struct { uint8_t RemoteAddress[6]; uint8_t Reason; - } BT_HCICommand_RejectConnectionReq_t; + } BT_HCICommand_RejectConnectionReq_t; /* Enums: */ enum BT_ScanEnable_Modes_t @@ -199,14 +199,15 @@ Bluetooth_Conn_SendPINCode = 11, Bluetooth_Conn_SendLinkKeyNAK = 12, }; - + /* Function Prototypes: */ void Bluetooth_HCITask(void); - + #if defined(INCLUDE_FROM_BLUETOOTHHCICOMMANDS_C) static uint8_t Bluetooth_SendHCICommand(const BT_HCICommand_Header_t* const HCICommandHeader, const void* Parameters, const uint16_t ParameterLength); #endif - + #endif + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.c b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.c index 1fa8079f3..d85b1f983 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -71,3 +71,4 @@ void Bluetooth_Stack_USBTask(void) Bluetooth_HCITask(); Bluetooth_ACLTask(); } + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h index e434e6c4f..9483198c7 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothStack.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,12 +38,12 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "../ConfigDescriptor.h" - + /* Macros: */ #define BLUETOOTH_MAX_OPEN_CHANNELS 6 - + #define CHANNEL_PSM_SDP 0x0001 #define CHANNEL_PSM_UDP 0x0002 #define CHANNEL_PSM_RFCOMM 0x0003 @@ -53,13 +53,13 @@ #define CHANNEL_PSM_HTTP 0x000C #define CHANNEL_PSM_UPNP 0x0010 #define CHANNEL_PSM_HIDP 0x0011 - + #define CHANNEL_SEARCH_LOCALNUMBER 0 #define CHANNEL_SEARCH_REMOTENUMBER 1 #define CHANNEL_SEARCH_PSM 2 - + #define MAXIMUM_CHANNEL_MTU 255 - + /* Enums: */ /** Enum for the possible states for a Bluetooth ACL channel. */ enum BT_ChannelStates_t @@ -117,7 +117,7 @@ Bluetooth_Channel_t Channels[BLUETOOTH_MAX_OPEN_CHANNELS]; /**< Channel information structures for the connection. */ uint8_t SignalingIdentifier; /**< Next Signaling Channel unique command sequence identifier. */ } Bluetooth_Connection_t; - + /** Local Bluetooth device information structure, for the defining of local device characteristics for the Bluetooth stack. */ typedef struct { @@ -125,7 +125,7 @@ char PINCode[16]; /**< Pin code required to send or receive in order to authenticate with a remote device. */ char Name[]; /**< Name of the local Bluetooth device, up to 248 characters. */ } Bluetooth_Device_t; - + /** Bluetooth stack state information structure, for the containment of the Bluetooth stack state. The values in * this structure are set by the Bluetooth stack internally, and should all be treated as read only by the user * application. @@ -139,12 +139,12 @@ */ uint8_t LocalBDADDR[6]; /**< Local Bluetooth adapter's BDADDR, valid when the stack is fully initialized. */ } Bluetooth_Stack_State_t; - + /* Includes: */ #include "BluetoothHCICommands.h" - #include "BluetoothACLPackets.h" - - /* Function Prototypes: */ + #include "BluetoothACLPackets.h" + + /* Function Prototypes: */ void Bluetooth_Stack_Init(void); void Bluetooth_Stack_USBTask(void); @@ -171,3 +171,4 @@ extern Bluetooth_Stack_State_t Bluetooth_State; #endif + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c index 2638dee35..636b5a454 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -124,7 +124,7 @@ void RFCOMM_ProcessPacket(void* Data, const RFCOMM_Header_t* FrameHeader = (const RFCOMM_Header_t*)Data; const uint8_t* FrameData = (const uint8_t*)Data + sizeof(RFCOMM_Header_t); uint16_t FrameDataLen = RFCOMM_GetVariableFieldValue(&FrameData); - + /* Decode the RFCOMM frame type from the header */ switch (FrameHeader->Control & ~FRAME_POLL_FINAL) { @@ -167,7 +167,7 @@ void RFCOMM_SendChannelSignals(const RFCOMM_Channel_t* const RFCOMMChannel, uint8_t Length; RFCOMM_MSC_Parameters_t Params; } MSCommand; - + MSCommand.CommandHeader = (RFCOMM_Command_t){.Command = RFCOMM_Control_ModemStatus, .EA = true, .CR = true}; MSCommand.Length = (sizeof(MSCommand.Params) << 1) | 0x01; MSCommand.Params.Channel = (RFCOMM_Address_t){.DLCI = RFCOMMChannel->DLCI, .EA = true, .CR = true}; @@ -175,7 +175,7 @@ void RFCOMM_SendChannelSignals(const RFCOMM_Channel_t* const RFCOMMChannel, MSCommand.Params.BreakSignal = RFCOMMChannel->Local.BreakSignal; /* Send the MSC command to the remote device */ - RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, true, RFCOMM_Frame_UIH, sizeof(MSCommand), &MSCommand, ACLChannel); + RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, true, RFCOMM_Frame_UIH, sizeof(MSCommand), &MSCommand, ACLChannel); } /** Sends new data through an open logical RFCOMM channel. This should be used to transmit data through a @@ -193,12 +193,12 @@ void RFCOMM_SendData(const uint16_t DataLen, { if (RFCOMMChannel->State != RFCOMM_Channel_Open) return; - + BT_RFCOMM_DEBUG(1, ">> UIH Frame"); BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", RFCOMMChannel->DLCI); /* Send the MSC command to the remote device */ - RFCOMM_SendFrame(RFCOMMChannel->DLCI, false, RFCOMM_Frame_UIH, DataLen, Data, ACLChannel); + RFCOMM_SendFrame(RFCOMMChannel->DLCI, false, RFCOMM_Frame_UIH, DataLen, Data, ACLChannel); } RFCOMM_Channel_t* RFCOMM_GetFreeChannelEntry(const uint8_t DLCI) @@ -220,11 +220,11 @@ RFCOMM_Channel_t* RFCOMM_GetFreeChannelEntry(const uint8_t DLCI) RFCOMMChannel->Local.Signals = RFCOMM_SIGNAL_RTC | RFCOMM_SIGNAL_RTR | RFCOMM_SIGNAL_DV | (1 << 0); RFCOMMChannel->Local.BreakSignal = 0 | (1 << 0); RFCOMMChannel->ConfigFlags = 0; - + return RFCOMMChannel; } } - + return NULL; } @@ -234,7 +234,7 @@ RFCOMM_Channel_t* RFCOMM_GetChannelData(const uint8_t DLCI) for (uint8_t i = 0; i < RFCOMM_MAX_OPEN_CHANNELS; i++) { RFCOMM_Channel_t* CurrRFCOMMChannel = &RFCOMM_Channels[i]; - + /* If the current non-closed channel's DLCI matches the search DLCI, return it to the caller */ if ((CurrRFCOMMChannel->State != RFCOMM_Channel_Closed) && (CurrRFCOMMChannel->DLCI == DLCI)) return CurrRFCOMMChannel; @@ -248,10 +248,10 @@ uint16_t RFCOMM_GetVariableFieldValue(const uint8_t** BufferPos) { uint8_t FirstOctet; uint8_t SecondOctet = 0; - + FirstOctet = **BufferPos; (*BufferPos)++; - + /* If the field size is more than a single byte, fetch the next byte in the variable length field */ if (!(FirstOctet & 0x01)) { @@ -281,30 +281,30 @@ void RFCOMM_SendFrame(const uint8_t DLCI, uint8_t Data[DataLen]; uint8_t FCS; } ResponsePacket; - + /* Set the frame header values to the specified address and frame type */ ResponsePacket.FrameHeader.Control = Control; ResponsePacket.FrameHeader.Address = (RFCOMM_Address_t){.DLCI = DLCI, .EA = true, .CR = CommandResponse}; - + /* Set the lower 7 bits of the packet length */ ResponsePacket.Size[0] = (DataLen << 1); - + /* Terminate the size field if size is 7 bits or lower, otherwise set the upper 8 bits of the length */ if (DataLen < 128) ResponsePacket.Size[0] |= 0x01; else ResponsePacket.Size[1] = (DataLen >> 7); - + /* Copy over the packet data from the source buffer to the response packet buffer */ memcpy(ResponsePacket.Data, Data, DataLen); - + /* Determine the length of the frame which is to be used to calculate the CRC value */ uint8_t CRCLength = sizeof(ResponsePacket.FrameHeader); /* UIH frames do not have the CRC calculated on the Size field in the response, all other frames do */ if ((Control & ~FRAME_POLL_FINAL) != RFCOMM_Frame_UIH) CRCLength += sizeof(ResponsePacket.Size); - + /* Calculate the frame checksum from the appropriate fields */ ResponsePacket.FCS = RFCOMM_GetFCSValue(&ResponsePacket, CRCLength); @@ -316,7 +316,7 @@ static uint8_t RFCOMM_GetFCSValue(const void* FrameStart, uint8_t Length) { uint8_t FCS = 0xFF; - + /* Calculate new Frame CRC value via the given data bytes and the CRC table */ for (uint8_t i = 0; i < Length; i++) FCS = pgm_read_byte(&CRC8_Table[FCS ^ ((const uint8_t*)FrameStart)[i]]); @@ -338,7 +338,7 @@ static void RFCOMM_ProcessDISC(const RFCOMM_Address_t* const FrameAddress, BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI); RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(FrameAddress->DLCI); - + /* If the requested channel is currently open, destroy it */ if (RFCOMMChannel != NULL) RFCOMMChannel->State = RFCOMM_Channel_Closed; @@ -356,7 +356,7 @@ static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress, if (FrameAddress->DLCI == RFCOMM_CONTROL_DLCI) { BT_RFCOMM_DEBUG(1, ">> UA Sent"); - + /* Free channel found, or request was to the control channel - accept SABM by sending a UA frame */ RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, ACLChannel); @@ -365,7 +365,7 @@ static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress, /* Find the existing channel's entry in the channel table */ RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(FrameAddress->DLCI); - + /* Existing entry not found, create a new entry for the channel */ if (RFCOMMChannel == NULL) RFCOMMChannel = RFCOMM_GetFreeChannelEntry(FrameAddress->DLCI); @@ -374,7 +374,7 @@ static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress, if (RFCOMMChannel != NULL) { BT_RFCOMM_DEBUG(1, ">> UA Sent"); - + /* Free channel found, or request was to the control channel - accept SABM by sending a UA frame */ RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, ACLChannel); } @@ -395,7 +395,7 @@ static void RFCOMM_ProcessUA(const RFCOMM_Address_t* const FrameAddress, } static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress, - const uint16_t FrameLength, + const uint16_t FrameLength, const uint8_t* FrameData, Bluetooth_Channel_t* const ACLChannel) { @@ -408,9 +408,10 @@ static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress, BT_RFCOMM_DEBUG(1, "<< UIH Received"); BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI); BT_RFCOMM_DEBUG(2, "-- Length 0x%02X", FrameLength); - + RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(FrameAddress->DLCI); - + if (RFCOMMChannel != NULL) RFCOMM_DataReceived(RFCOMMChannel, FrameLength, FrameData); } + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h index 7b74f4fab..be862a2b3 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMM.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -48,13 +48,13 @@ #include "BluetoothStack.h" #include "RFCOMMControl.h" - + /* Macros: */ #define BT_RFCOMM_DEBUG(l, s, ...) do { if (RFCOMM_DEBUG_LEVEL >= l) printf_P(PSTR("(RFCOMM) " s "\r\n"), ##__VA_ARGS__); } while (0) #define RFCOMM_DEBUG_LEVEL 0 - + #define FRAME_POLL_FINAL (1 << 4) - + #define RFCOMM_CONTROL_DLCI 0 #define RFCOMM_MAX_OPEN_CHANNELS 5 @@ -68,14 +68,14 @@ RFCOMM_Frame_UA = 0x63, /**< Unnumbered Acknowledgement Field */ RFCOMM_Frame_UIH = 0xEF, /**< Unnumbered Information with Header check Field */ }; - + enum RFCOMM_Channel_States_t { RFCOMM_Channel_Closed = 0, RFCOMM_Channel_Configure = 1, RFCOMM_Channel_Open = 2, }; - + /* Type Defines: */ typedef struct { @@ -95,7 +95,7 @@ uint8_t BreakSignal; } Local; } RFCOMM_Channel_t; - + /* External Variables: */ extern RFCOMM_Channel_t RFCOMM_Channels[RFCOMM_MAX_OPEN_CHANNELS]; @@ -104,7 +104,7 @@ void RFCOMM_ServiceChannels(Bluetooth_Channel_t* const ACLChannel); void RFCOMM_ProcessPacket(void* Data, Bluetooth_Channel_t* const ACLChannel); - + void RFCOMM_SendChannelSignals(const RFCOMM_Channel_t* const RFCOMMChannel, Bluetooth_Channel_t* const ACLChannel); void RFCOMM_SendData(const uint16_t DataLen, @@ -141,9 +141,10 @@ static void RFCOMM_ProcessUA(const RFCOMM_Address_t* const FrameAddress, Bluetooth_Channel_t* const ACLChannel); static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress, - const uint16_t FrameLength, + const uint16_t FrameLength, const uint8_t* FrameData, Bluetooth_Channel_t* const ACLChannel); #endif - + #endif + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMMControl.c b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMMControl.c index 5bd884572..871d3627f 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMMControl.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMMControl.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -69,7 +69,7 @@ void RFCOMM_ProcessControlCommand(const uint8_t* Command, RFCOMM_ProcessDPNCommand(CommandHeader, CommandData, ACLChannel); break; default: - BT_RFCOMM_DEBUG(1, "<< Unknown Command"); + BT_RFCOMM_DEBUG(1, "<< Unknown Command"); break; } } @@ -82,7 +82,7 @@ static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeade const uint8_t* Params = (const uint8_t*)CommandData; BT_RFCOMM_DEBUG(1, "<< TEST Command"); - + struct { RFCOMM_Command_t CommandHeader; @@ -94,7 +94,7 @@ static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeade TestResponse.CommandHeader = (RFCOMM_Command_t){.Command = RFCOMM_Control_Test, .EA = true, .CR = false}; TestResponse.Length = (CommandDataLen << 1) | 0x01; memcpy(TestResponse.TestData, Params, CommandDataLen); - + BT_RFCOMM_DEBUG(1, ">> TEST Response"); /* Send the PDN response to acknowledge the command */ @@ -124,14 +124,14 @@ static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader BT_RFCOMM_DEBUG(1, "<< MSC %s", (CommandHeader->CR) ? "Command" : "Response"); BT_RFCOMM_DEBUG(2, "-- DLCI: 0x%02X", Params->Channel.DLCI); - + /* Ignore status flags sent to the control channel */ if (Params->Channel.DLCI == RFCOMM_CONTROL_DLCI) return; - + /* Retrieve existing channel configuration data, if already opened */ - RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(Params->Channel.DLCI); - + RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(Params->Channel.DLCI); + /* If the channel does not exist, abort */ if (RFCOMMChannel == NULL) return; @@ -140,16 +140,16 @@ static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader if (CommandHeader->CR) { /* Save the new channel signals to the channel state structure */ - RFCOMMChannel->Remote.Signals = Params->Signals; + RFCOMMChannel->Remote.Signals = Params->Signals; RFCOMMChannel->ConfigFlags |= RFCOMM_CONFIG_REMOTESIGNALS; - + /* If the command contains the optional break signals field, store the value */ if (CommandDataLen == sizeof(RFCOMM_MSC_Parameters_t)) RFCOMMChannel->Remote.BreakSignal = Params->BreakSignal; /* Notify the user application that the signals have been received */ RFCOMM_ChannelSignalsReceived(RFCOMMChannel); - + struct { RFCOMM_Command_t CommandHeader; @@ -172,7 +172,7 @@ static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader { /* Indicate that the remote device has acknowledged the sent signals */ RFCOMMChannel->ConfigFlags |= RFCOMM_CONFIG_LOCALSIGNALS; - } + } } static void RFCOMM_ProcessRPNCommand(const RFCOMM_Command_t* const CommandHeader, @@ -197,20 +197,20 @@ static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader BT_RFCOMM_DEBUG(1, "<< DPN Command"); BT_RFCOMM_DEBUG(2, "-- DLCI: 0x%02X", Params->DLCI); - + /* Ignore parameter negotiations to the control channel */ if (Params->DLCI == RFCOMM_CONTROL_DLCI) return; - + /* Retrieve existing channel configuration data, if already opened */ RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(Params->DLCI); - + /* Check if the channel has no corresponding entry - remote did not open it first */ if (RFCOMMChannel == NULL) { /* Create a new entry in the channel table for the new channel */ RFCOMMChannel = RFCOMM_GetFreeChannelEntry(Params->DLCI); - + /* No free entry was found, discard the request */ if (RFCOMMChannel == NULL) { @@ -218,27 +218,28 @@ static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader return; } } - + /* Save the new channel configuration */ RFCOMMChannel->State = RFCOMM_Channel_Configure; RFCOMMChannel->Priority = Params->Priority; RFCOMMChannel->MTU = Params->MaximumFrameSize; - + struct { RFCOMM_Command_t CommandHeader; uint8_t Length; RFCOMM_DPN_Parameters_t Params; } DPNResponse; - + /* Fill out the DPN response data */ DPNResponse.CommandHeader = (RFCOMM_Command_t){.Command = RFCOMM_Control_DLCParameterNegotiation, .EA = true, .CR = false}; DPNResponse.Length = (sizeof(DPNResponse.Params) << 1) | 0x01; memcpy(&DPNResponse.Params, Params, sizeof(RFCOMM_DPN_Parameters_t)); DPNResponse.Params.ConvergenceLayer = 0x00; // TODO: Enable credit based transaction support - + BT_RFCOMM_DEBUG(1, ">> DPN Response"); /* Send the DPN response to acknowledge the command */ RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, false, RFCOMM_Frame_UIH, sizeof(DPNResponse), &DPNResponse, ACLChannel); } + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMMControl.h b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMMControl.h index b527bfa7c..b65e0d5a0 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMMControl.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/RFCOMMControl.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -48,14 +48,14 @@ #include "BluetoothStack.h" #include "RFCOMM.h" - + /* Macros: */ #define RFCOMM_SIGNAL_FC (1 << 1) #define RFCOMM_SIGNAL_RTC (1 << 2) #define RFCOMM_SIGNAL_RTR (1 << 3) #define RFCOMM_SIGNAL_IC (1 << 6) #define RFCOMM_SIGNAL_DV (1 << 7) - + #define RFCOMM_CONFIG_REMOTESIGNALS (1 << 0) #define RFCOMM_CONFIG_LOCALSIGNALS (1 << 1) #define RFCOMM_CONFIG_LOCALSIGNALSSENT (1 << 2) @@ -73,7 +73,7 @@ RFCOMM_Control_DLCParameterNegotiation = (0x80 >> 2), RFCOMM_Control_NonSupportedCommand = (0x10 >> 2), }; - + /* Type Defines: */ typedef struct { @@ -94,7 +94,7 @@ unsigned char CR : 1; unsigned char Command : 6; } RFCOMM_Command_t; - + typedef struct { uint8_t DLCI; @@ -104,9 +104,9 @@ uint8_t ACKTimerTicks; uint16_t MaximumFrameSize; uint8_t MaxRetransmissions; - uint8_t RecoveryWindowSize; + uint8_t RecoveryWindowSize; } RFCOMM_DPN_Parameters_t; - + typedef struct { RFCOMM_Address_t Channel; @@ -120,7 +120,7 @@ #if defined(INCLUDE_FROM_RFCOMM_CONTROL_C) static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeader, - const uint8_t CommandDataLen, + const uint8_t CommandDataLen, const uint8_t* CommandData, Bluetooth_Channel_t* const ACLChannel); static void RFCOMM_ProcessFCECommand(const RFCOMM_Command_t* const CommandHeader, @@ -143,5 +143,6 @@ const uint8_t* CommandData, Bluetooth_Channel_t* const ACLChannel); #endif - + #endif + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.c b/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.c index 19d42e264..3c1acfe28 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -73,7 +73,7 @@ void SDP_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel) { case SDP_PDU_SERVICESEARCHREQUEST: SDP_ProcessServiceSearch(SDPHeader, Channel); - break; + break; case SDP_PDU_SERVICEATTRIBUTEREQUEST: SDP_ProcessServiceAttribute(SDPHeader, Channel); break; @@ -99,11 +99,11 @@ static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, uint8_t UUIDList[12][UUID_SIZE_BYTES]; uint8_t TotalUUIDs = SDP_GetUUIDList(UUIDList, &CurrentParameter); BT_SDP_DEBUG(2, "-- Total UUIDs: %d", TotalUUIDs); - + /* Retrieve the maximum service record response count from the request */ uint16_t MaxServiceRecordCount = SDP_ReadData16(&CurrentParameter); BT_SDP_DEBUG(2, "-- Max Return Service Count: 0x%04X", MaxServiceRecordCount); - + struct { SDP_PDUHeader_t SDPHeader; @@ -111,7 +111,7 @@ static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, uint16_t CurrentServiceRecordCount; uint8_t ResponseData[100]; } ResponsePacket; - + uint8_t AddedServiceHandles = 0; /* Create a pointer to the buffer to indicate the current location for response data to be added */ @@ -136,7 +136,7 @@ static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader, uint8_t AttrSize = SDP_GetLocalAttributeContainerSize(AttributeValue, &AttrHeaderSize); memcpy_P(CurrResponsePos, AttributeValue + AttrHeaderSize, AttrSize); CurrResponsePos += AttrHeaderSize + AttrSize; - + AddedServiceHandles++; } @@ -180,11 +180,11 @@ static void SDP_ProcessServiceAttribute(const SDP_PDUHeader_t* const SDPHeader, /* Retrieve the service handle whose attributes are to be examined */ uint32_t ServiceHandle = SDP_ReadData32(&CurrentParameter); BT_SDP_DEBUG(2, "-- Service Handle: 0x%08lX", ServiceHandle); - + /* Retrieve the maximum Attribute response size from the request */ uint16_t MaxAttributeSize = SDP_ReadData16(&CurrentParameter); BT_SDP_DEBUG(2, "-- Max Return Attribute Bytes: 0x%04X", MaxAttributeSize); - + /* Retrieve the list of Attributes from the request */ uint16_t AttributeList[8][2]; uint8_t TotalAttributes = SDP_GetAttributeList(AttributeList, &CurrentParameter); @@ -211,24 +211,24 @@ static void SDP_ProcessServiceAttribute(const SDP_PDUHeader_t* const SDPHeader, { /* Read in a pointer to the current UUID table entry's Attribute table */ ServiceAttributeTable_t* CurrAttributeTable = pgm_read_ptr(&SDP_Services_Table[CurrTableItem]); - + /* Retrieve a PROGMEM pointer to the value of the Service Record Handle */ const void* ServiceRecord = SDP_GetAttributeValue(CurrAttributeTable, SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE); - + /* Get the size of the header for the Service Record Handle */ uint8_t AttrHeaderSize; SDP_GetLocalAttributeContainerSize(ServiceRecord, &AttrHeaderSize); - + /* Retrieve the endian-swapped service handle of the current service being examined */ uint32_t CurrServiceHandle = SwapEndian_32(pgm_read_dword(ServiceRecord + AttrHeaderSize)); - + /* Check if the current service in the service table has the requested service handle */ if (ServiceHandle == CurrServiceHandle) { /* Add the listed attributes for the found UUID to the response */ TotalResponseSize = SDP_AddListedAttributesToResponse(CurrAttributeTable, AttributeList, TotalAttributes, &CurrResponsePos); - + /* Requested service found, abort the search through the service table */ break; } @@ -243,7 +243,7 @@ static void SDP_ProcessServiceAttribute(const SDP_PDUHeader_t* const SDPHeader, /* Calculate the total parameter length that is to be sent, including the fixed return parameters, the created attribute value list and the SDP continuation state */ uint16_t ParamLength = (sizeof(ResponsePacket.AttributeListByteCount) + TotalResponseSize + sizeof(uint8_t)); - + /* Fill in the response packet's header */ ResponsePacket.SDPHeader.PDU = SDP_PDU_SERVICEATTRIBUTERESPONSE; ResponsePacket.SDPHeader.TransactionID = SDPHeader->TransactionID; @@ -265,30 +265,30 @@ static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHe Bluetooth_Channel_t* const Channel) { const void* CurrentParameter = ((const void*)SDPHeader + sizeof(SDP_PDUHeader_t)); - + BT_SDP_DEBUG(1, "<< Service Search Attribute"); /* Retrieve the list of search UUIDs from the request */ uint8_t UUIDList[12][UUID_SIZE_BYTES]; uint8_t TotalUUIDs = SDP_GetUUIDList(UUIDList, &CurrentParameter); BT_SDP_DEBUG(2, "-- Total UUIDs: %d", TotalUUIDs); - + /* Retrieve the maximum Attribute response size from the request */ uint16_t MaxAttributeSize = SDP_ReadData16(&CurrentParameter); BT_SDP_DEBUG(2, "-- Max Return Attribute Bytes: 0x%04X", MaxAttributeSize); - + /* Retrieve the list of Attributes from the request */ uint16_t AttributeList[8][2]; uint8_t TotalAttributes = SDP_GetAttributeList(AttributeList, &CurrentParameter); BT_SDP_DEBUG(2, "-- Total Attributes: %d", TotalAttributes); - + struct { SDP_PDUHeader_t SDPHeader; uint16_t AttributeListByteCount; uint8_t ResponseData[100]; } ResponsePacket; - + /* Create a pointer to the buffer to indicate the current location for response data to be added */ void* CurrResponsePos = ResponsePacket.ResponseData; @@ -298,7 +298,7 @@ static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHe /* Add the outer Data Element Sequence header for all of the retrieved Attributes */ uint16_t* TotalResponseSize = SDP_AddSequence16(&CurrResponsePos); - + /* Search through the global service list an item at a time */ for (uint8_t CurrTableItem = 0; CurrTableItem < (sizeof(SDP_Services_Table) / sizeof(void*)); CurrTableItem++) { @@ -307,14 +307,14 @@ static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHe if (!(SDP_SearchServiceTable(UUIDList, TotalUUIDs, CurrAttributeTable))) continue; - + BT_SDP_DEBUG(2, " -- Found search match in table"); /* Add the listed attributes for the found UUID to the response */ - *TotalResponseSize += SDP_AddListedAttributesToResponse(CurrAttributeTable, AttributeList, TotalAttributes, + *TotalResponseSize += SDP_AddListedAttributesToResponse(CurrAttributeTable, AttributeList, TotalAttributes, &CurrResponsePos); } - + /* Continuation state - always zero */ SDP_WriteData8(&CurrResponsePos, 0); @@ -323,7 +323,7 @@ static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHe /* Calculate the total parameter length that is to be sent, including the fixed return parameters, the created attribute value list and the SDP continuation state */ - uint16_t ParamLength = (sizeof(ResponsePacket.AttributeListByteCount) + + uint16_t ParamLength = (sizeof(ResponsePacket.AttributeListByteCount) + (3 + *TotalResponseSize) + sizeof(uint8_t)); @@ -366,7 +366,7 @@ static uint16_t SDP_AddListedAttributesToResponse(const ServiceAttributeTable_t* { uint16_t* AttributeIDRange = AttributeList[CurrAttribute]; void* AttributeValue; - + /* Look through the current service's attribute list, examining all the attributes */ while ((AttributeValue = pgm_read_ptr(&AttributeTable->Data)) != NULL) { @@ -377,9 +377,9 @@ static uint16_t SDP_AddListedAttributesToResponse(const ServiceAttributeTable_t* if ((CurrAttributeID >= AttributeIDRange[0]) && (CurrAttributeID <= AttributeIDRange[1])) { /* Increment the current UUID's returned Attribute container size by the number of added bytes */ - *AttributeListSize += SDP_AddAttributeToResponse(CurrAttributeID, AttributeValue, BufferPos); + *AttributeListSize += SDP_AddAttributeToResponse(CurrAttributeID, AttributeValue, BufferPos); } - + AttributeTable++; } } @@ -408,19 +408,19 @@ static uint16_t SDP_AddAttributeToResponse(const uint16_t AttributeID, /* Retrieve the size of the attribute value from its container header */ uint8_t AttributeHeaderLength; uint16_t AttributeValueLength = SDP_GetLocalAttributeContainerSize(AttributeValue, &AttributeHeaderLength); - + BT_SDP_DEBUG(2, " -- Add Attribute (0x%04X) 0x%04X", (AttributeHeaderLength + AttributeValueLength), AttributeID); /* Add a Data Element header to the response for the Attribute ID */ SDP_WriteData8(ResponseBuffer, (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit)); - + /* Add the Attribute ID to the created Data Element */ SDP_WriteData16(ResponseBuffer, AttributeID); - + /* Copy over the Attribute value Data Element container to the response */ memcpy_P(*ResponseBuffer, AttributeValue, AttributeHeaderLength + AttributeValueLength); *ResponseBuffer += AttributeHeaderLength + AttributeValueLength; - + return (sizeof(uint8_t) + sizeof(uint16_t) + AttributeHeaderLength + AttributeValueLength); } @@ -435,17 +435,17 @@ static void* SDP_GetAttributeValue(const ServiceAttributeTable_t* AttributeTable const uint16_t AttributeID) { void* CurrTableItemData; - + /* Search through the current Attribute table, abort when the terminator item has been reached */ while ((CurrTableItemData = pgm_read_ptr(&AttributeTable->Data)) != NULL) { /* Check if the current Attribute ID matches the search ID - if so return a pointer to it */ if (pgm_read_word(&AttributeTable->AttributeID) == AttributeID) return CurrTableItemData; - + AttributeTable++; } - + return NULL; } @@ -463,7 +463,7 @@ static bool SDP_SearchServiceTable(uint8_t UUIDList[][UUID_SIZE_BYTES], { const void* CurrAttribute; uint16_t UUIDMatchFlags = 0; - + /* Search through the current attribute table, checking each attribute value for UUID matches */ while ((CurrAttribute = pgm_read_ptr(&CurrAttributeTable->Data)) != NULL) { @@ -475,7 +475,7 @@ static bool SDP_SearchServiceTable(uint8_t UUIDList[][UUID_SIZE_BYTES], uint8_t UUIDMatches; for (UUIDMatches = 0; UUIDMatchFlags; UUIDMatches++) UUIDMatchFlags &= (UUIDMatchFlags - 1); - + /* If all UUIDs have been matched to the current service, return true */ return (UUIDMatches == TotalUUIDs); } @@ -501,7 +501,7 @@ static void SDP_CheckUUIDMatch(uint8_t UUIDList[][UUID_SIZE_BYTES], if (CurrAttributeType == SDP_DATATYPE_UUID) { uint16_t CurrUUIDMatchMask = (1 << 0); - + /* Look for matches in the UUID list against the current attribute UUID value */ for (uint8_t i = 0; i < TotalUUIDs; i++) { @@ -512,7 +512,7 @@ static void SDP_CheckUUIDMatch(uint8_t UUIDList[][UUID_SIZE_BYTES], *UUIDMatchFlags |= CurrUUIDMatchMask; break; } - + CurrUUIDMatchMask <<= 1; } } @@ -520,15 +520,15 @@ static void SDP_CheckUUIDMatch(uint8_t UUIDList[][UUID_SIZE_BYTES], { uint8_t SequenceHeaderSize; uint16_t SequenceSize = SDP_GetLocalAttributeContainerSize(CurrAttribute, &SequenceHeaderSize); - + CurrAttribute += SequenceHeaderSize; - + /* Recursively unwrap the sequence container, and re-search its contents for UUIDs */ while (SequenceSize) { uint8_t InnerHeaderSize; uint16_t InnerSize = SDP_GetLocalAttributeContainerSize(CurrAttribute, &InnerHeaderSize); - + /* Recursively search of the next element in the sequence, trying to match UUIDs with the UUID list */ SDP_CheckUUIDMatch(UUIDList, TotalUUIDs, UUIDMatchFlags, CurrAttribute); @@ -536,10 +536,10 @@ static void SDP_CheckUUIDMatch(uint8_t UUIDList[][UUID_SIZE_BYTES], SequenceSize -= InnerHeaderSize + InnerSize; CurrAttribute += InnerHeaderSize + InnerSize; } - } + } } -/** Reads in the collection of Attribute ranges from the input buffer's Data Element Sequence container, into the given +/** Reads in the collection of Attribute ranges from the input buffer's Data Element Sequence container, into the given * Attribute list for later use. Once complete, the input buffer pointer is advanced to the end of the Attribute container. * * \param[out] AttributeList Pointer to a buffer where the list of Attribute ranges are to be stored @@ -561,10 +561,10 @@ static uint8_t SDP_GetAttributeList(uint16_t AttributeList[][2], /* Retrieve the size of the next Attribute in the container and get a pointer to the next free Attribute element in the list */ uint16_t* CurrentAttributeRange = AttributeList[TotalAttributes++]; uint8_t AttributeLength = SDP_GetDataElementSize(CurrentParameter, &ElementHeaderSize); - + /* Copy over the starting Attribute ID and (if it the current element is a range) the ending Attribute ID */ memcpy(&CurrentAttributeRange[0], *CurrentParameter, AttributeLength); - + /* If the element is not an Attribute Range, copy over the starting ID to the ending ID to make a range of 1 */ if (AttributeLength == 2) CurrentAttributeRange[1] = CurrentAttributeRange[0]; @@ -574,15 +574,15 @@ static uint8_t SDP_GetAttributeList(uint16_t AttributeList[][2], CurrentAttributeRange[1] = SwapEndian_16(CurrentAttributeRange[1]); BT_SDP_DEBUG(2, "-- Attribute: 0x%04X-0x%04X", CurrentAttributeRange[0], CurrentAttributeRange[1]); - + AttributeIDListLength -= (AttributeLength + ElementHeaderSize); *CurrentParameter += AttributeLength; } - + return TotalAttributes; } -/** Reads in the collection of UUIDs from the input buffer's Data Element Sequence container, into the given +/** Reads in the collection of UUIDs from the input buffer's Data Element Sequence container, into the given * UUID list for later use. Once complete, the input buffer pointer is advanced to the end of the UUID container. * * \param[out] UUIDList Pointer to a buffer where the list of UUIDs are to be stored @@ -604,7 +604,7 @@ static uint8_t SDP_GetUUIDList(uint8_t UUIDList[][UUID_SIZE_BYTES], /* Retrieve the size of the next UUID in the container and get a pointer to the next free UUID element in the list */ uint8_t* CurrentUUID = UUIDList[TotalUUIDs++]; uint8_t UUIDLength = SDP_GetDataElementSize(CurrentParameter, &ElementHeaderSize); - + /* Copy over UUID from the container to the free slot */ if (UUIDLength <= 4) { @@ -617,9 +617,9 @@ static uint8_t SDP_GetUUIDList(uint8_t UUIDList[][UUID_SIZE_BYTES], else { /* Copy over full UUID */ - memcpy(CurrentUUID, *CurrentParameter, UUIDLength); + memcpy(CurrentUUID, *CurrentParameter, UUIDLength); } - + BT_SDP_DEBUG(2, "-- UUID (%d): %02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X", UUIDLength, CurrentUUID[0], CurrentUUID[1], CurrentUUID[2], CurrentUUID[3], @@ -631,7 +631,7 @@ static uint8_t SDP_GetUUIDList(uint8_t UUIDList[][UUID_SIZE_BYTES], ServicePatternLength -= (UUIDLength + ElementHeaderSize); *CurrentParameter += UUIDLength; } - + return TotalUUIDs; } @@ -647,7 +647,7 @@ static uint32_t SDP_GetLocalAttributeContainerSize(const void* const AttributeDa { /* Fetch the size of the Data Element structure from the header */ uint8_t SizeIndex = (pgm_read_byte(AttributeData) & 0x07); - + uint32_t ElementValueSize; /* Convert the Data Element size index into a size in bytes */ @@ -686,7 +686,7 @@ static uint32_t SDP_GetDataElementSize(const void** const DataElementHeader, uint8_t* const ElementHeaderSize) { /* Fetch the size of the Data Element structure from the header, increment the current buffer pos */ - uint8_t SizeIndex = (SDP_ReadData8(DataElementHeader) & 0x07); + uint8_t SizeIndex = (SDP_ReadData8(DataElementHeader) & 0x07); uint32_t ElementValueSize; @@ -710,6 +710,7 @@ static uint32_t SDP_GetDataElementSize(const void** const DataElementHeader, ElementValueSize = (1 << SizeIndex); break; } - + return ElementValueSize; } + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.h b/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.h index 2df8c225d..733889a4d 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/SDP.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -48,11 +48,11 @@ #include "BluetoothStack.h" #include "SDPServices.h" - + /* Macros: */ #define BT_SDP_DEBUG(l, s, ...) do { if (SDP_DEBUG_LEVEL >= l) printf_P(PSTR("(SDP) " s "\r\n"), ##__VA_ARGS__); } while (0) #define SDP_DEBUG_LEVEL 0 - + #define SDP_PDU_ERRORRESPONSE 0x01 #define SDP_PDU_SERVICESEARCHREQUEST 0x02 #define SDP_PDU_SERVICESEARCHRESPONSE 0x03 @@ -103,7 +103,7 @@ uint16_t TransactionID; /**< Unique transaction ID number to associate requests and responses */ uint16_t ParameterLength; /**< Length of the data following the SDP header */ } SDP_PDUHeader_t; - + /* Inline Functions: */ /** Writes 8 bits of raw data to the given buffer, incrementing the buffer position afterwards. * @@ -116,7 +116,7 @@ *((uint8_t*)*BufferPos) = Data; *BufferPos += sizeof(uint8_t); } - + /** Writes 16 bits of raw data to the given buffer, incrementing the buffer position afterwards. * * \param[in, out] BufferPos Current position in the buffer where the data is to be written to @@ -127,7 +127,7 @@ { *((uint16_t*)*BufferPos) = SwapEndian_16(Data); *BufferPos += sizeof(uint16_t); - } + } /** Writes 32 bits of raw data to the given buffer, incrementing the buffer position afterwards. * @@ -151,7 +151,7 @@ { uint8_t Data = *((const uint8_t*)*BufferPos); *BufferPos += sizeof(uint8_t); - + return Data; } @@ -165,7 +165,7 @@ { uint16_t Data = SwapEndian_16(*((const uint16_t*)*BufferPos)); *BufferPos += sizeof(uint16_t); - + return Data; } @@ -179,13 +179,13 @@ { uint32_t Data = SwapEndian_32(*((const uint32_t*)*BufferPos)); *BufferPos += sizeof(uint32_t); - + return Data; } - /** Adds a new Data Element Sequence container with a 16-bit size header to the buffer. The buffer + /** Adds a new Data Element Sequence container with a 16-bit size header to the buffer. The buffer * pointer's position is advanced past the added header once the element has been added. The returned - * size header value is pre-zeroed out so that it can be incremented as data is placed into the Data + * size header value is pre-zeroed out so that it can be incremented as data is placed into the Data * Element Sequence container. * * The total added size of the container header is three bytes, regardless of the size of its contents @@ -199,12 +199,12 @@ { SDP_WriteData8(BufferPos, (SDP_DATASIZE_Variable16Bit | SDP_DATATYPE_Sequence)); - uint16_t* SizePos = *BufferPos; + uint16_t* SizePos = *BufferPos; SDP_WriteData16(BufferPos, 0); return SizePos; } - + /* Function Prototypes: */ void SDP_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel); @@ -247,3 +247,4 @@ #endif #endif + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c b/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c index 93f5519fe..9f7855e63 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -181,3 +181,4 @@ const ServiceAttributeTable_t PROGMEM SerialPort_Attribute_Table[] = SERVICE_ATTRIBUTE_TABLE_TERMINATOR }; + diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.h b/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.h index afa8e0024..3ec95c4d1 100644 --- a/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.h +++ b/Demos/Host/Incomplete/BluetoothHost/Lib/SDPServices.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -35,22 +35,22 @@ #ifndef _SDPSERVICES_H_ #define _SDPSERVICES_H_ - + /* Includes: */ #include "SDP.h" /* Macros: */ /** Size of a full 128 bit UUID, in bytes. */ #define UUID_SIZE_BYTES 16 - + /** First 80 bits common to all standardized Bluetooth services. */ #define BASE_80BIT_UUID 0x0000, 0x0010, 0x0080, {0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB} - + #define RFCOMM_UUID {SWAPENDIAN_32(0x00000003), BASE_80BIT_UUID} #define L2CAP_UUID {SWAPENDIAN_32(0x00000100), BASE_80BIT_UUID} #define SP_CLASS_UUID {SWAPENDIAN_32(0x00001101), BASE_80BIT_UUID} #define PUBLICBROWSEGROUP_CLASS_UUID {SWAPENDIAN_32(0x00001002), BASE_80BIT_UUID} - + #define SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE 0x0000 #define SDP_ATTRIBUTE_ID_SERVICECLASSIDS 0x0001 #define SDP_ATTRIBUTE_ID_PROTOCOLDESCRIPTORLIST 0x0004 @@ -58,10 +58,10 @@ #define SDP_ATTRIBUTE_ID_LANGUAGEBASEATTROFFSET 0x0006 #define SDP_ATTRIBUTE_ID_SERVICENAME 0x0100 #define SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION 0x0101 - + /** Terminator for a service attribute table of type \ref ServiceAttributeTable_t. */ #define SERVICE_ATTRIBUTE_TABLE_TERMINATOR {.Data = NULL} - + /* Type Defines: */ /** Type define for a UUID value structure. This struct can be used to hold full 128-bit UUIDs. */ typedef struct @@ -72,7 +72,7 @@ uint16_t D; /**< Bits 64-79 of the UUID. */ uint8_t E[6]; /**< Bits 80-128 of the UUID. */ } UUID_t; - + /** Structure for the association of attribute ID values to an attribute value in FLASH. A table of these * structures can then be built up for each supported UUID service within the device. * @@ -111,7 +111,7 @@ uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit) */ UUID_t UUID; /**< UUID to store in the list Data Element */ } ItemUUID_t; - + /** Structure for a list of Data Elements Sequences containing UUID Data Elements, for service attributes requiring * protocol lists. */ @@ -119,7 +119,7 @@ { uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit) */ uint8_t Size; /**< Size of the inner Data Element sequence */ - + struct { ItemUUID_t UUID; /**< UUID to store in the protocol list Data Element sequence */ @@ -133,14 +133,14 @@ { uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit) */ uint8_t Size; /**< Size of the inner Data Element sequence */ - + struct { ItemUUID_t UUID; /**< UUID to store in the protocol list Data Element sequence */ Item8Bit_t Param; /**< 8-Bit Parameter associated with the service */ } Protocol; } ItemProtocol_8BitParam_t; - + /** Structure for a list of Data Elements Sequences containing UUID Data Elements and an 16-bit param value, for service * attributes requiring extended protocol lists containing an 16-bit value. */ @@ -148,7 +148,7 @@ { uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit) */ uint8_t Size; /**< Size of the inner Data Element sequence */ - + struct { ItemUUID_t UUID; /**< UUID to store in the protocol list Data Element sequence */ @@ -165,9 +165,10 @@ Item16Bit_t EncodingID; /**< Encoding used for the current language */ Item16Bit_t OffsetID; /**< Attribute offset added to all strings using this language within the service */ } ItemLangEncoding_t; - + /* External Variables: */ extern const ServiceAttributeTable_t SerialPort_Attribute_Table[]; extern const ServiceAttributeTable_t PnP_Attribute_Table[]; - + #endif + diff --git a/Demos/Host/Incomplete/BluetoothHost/makefile b/Demos/Host/Incomplete/BluetoothHost/makefile index 21f7d5a57..c8fd05907 100644 --- a/Demos/Host/Incomplete/BluetoothHost/makefile +++ b/Demos/Host/Incomplete/BluetoothHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -143,7 +143,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -156,7 +156,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -270,7 +270,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -283,7 +283,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -295,7 +295,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -307,7 +307,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -330,7 +330,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -364,7 +364,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -398,7 +398,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -427,7 +427,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -446,10 +446,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -514,11 +514,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -545,9 +545,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -645,14 +645,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -674,7 +674,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -718,3 +718,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c b/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c index 093c7db65..83eb30101 100644 --- a/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Interface_t* HIDInterface = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; @@ -79,7 +79,7 @@ uint8_t ProcessConfigurationDescriptor(void) * but only found the mandatory IN endpoint, it's safe to continue with the device enumeration */ if (DataINEndpoint) break; - + /* Get the next HID interface from the configuration descriptor */ if (USB_GetNextDescriptorComp(&CurrConfigBytesRem, &CurrConfigLocation, DComp_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found) @@ -87,17 +87,17 @@ uint8_t ProcessConfigurationDescriptor(void) /* Descriptor not found, error out */ return NoCompatibleInterfaceFound; } - + /* Save the interface in case we need to refer back to it later */ HIDInterface = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Interface_t); /* Clear any found endpoints */ DataOUTEndpoint = NULL; - + /* Skip the remainder of the loop as we have not found an endpoint yet */ continue; } - + /* Retrieve the endpoint address from the endpoint descriptor */ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t); @@ -107,20 +107,20 @@ uint8_t ProcessConfigurationDescriptor(void) else DataOUTEndpoint = EndpointData; } - + /* Configure the HID data IN pipe */ Pipe_ConfigurePipe(HID_DATA_IN_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE); Pipe_SetInterruptPeriod(DataINEndpoint->PollingIntervalMS); - + /* Check if the HID interface contained an optional OUT data endpoint */ if (DataOUTEndpoint) { /* Configure the HID data OUT pipe */ Pipe_ConfigurePipe(HID_DATA_OUT_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_OUT, DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, PIPE_BANK_SINGLE); - } - + } + /* Valid data found, return success */ return SuccessfulConfigRead; } @@ -145,7 +145,7 @@ uint8_t DComp_NextHIDInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + /* Current descriptor does not match what this comparator is looking for */ return DESCRIPTOR_SEARCH_NotFound; } @@ -176,3 +176,4 @@ uint8_t DComp_NextHIDInterfaceDataEndpoint(void* CurrentDescriptor) /* Current descriptor does not match what this comparator is looking for */ return DESCRIPTOR_SEARCH_NotFound; } + diff --git a/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.h b/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.h index e5a39479d..bde951439 100644 --- a/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.h +++ b/Demos/Host/LowLevel/GenericHIDHost/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,19 +38,19 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "GenericHIDHost.h" - + /* Macros: */ /** Interface Class value for the Human Interface Device class. */ #define HID_CLASS 0x03 /** Pipe number for the HID data IN pipe. */ #define HID_DATA_IN_PIPE 1 - + /** Pipe number for the HID data OUT pipe. */ #define HID_DATA_OUT_PIPE 2 - + /* Enums: */ /** Enum for the possible return codes of the \ref ProcessConfigurationDescriptor() function. */ enum GenericHIDHost_GetConfigDescriptorDataCodes_t @@ -60,7 +60,7 @@ DescriptorTooLarge = 2, /**< The device's Configuration Descriptor is too large to process */ InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */ NoCompatibleInterfaceFound = 4, /**< A compatible interface with the required endpoints was not found */ - }; + }; /* Function Prototypes: */ uint8_t ProcessConfigurationDescriptor(void); @@ -69,3 +69,4 @@ uint8_t DComp_NextHIDInterfaceDataEndpoint(void* CurrentDescriptor); #endif + diff --git a/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.c b/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.c index 66a5b8e7e..ba182607b 100644 --- a/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.c +++ b/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the GenericHIDHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "GenericHIDHost.h" /** Main program entry point. This routine configures the hardware required by the application, then @@ -137,10 +137,10 @@ void ReadNextReport(void) { /* Refreeze HID data IN pipe */ Pipe_Freeze(); - + return; } - + /* Ensure pipe contains data before trying to read from it */ if (Pipe_IsReadWriteAllowed()) { @@ -148,17 +148,17 @@ void ReadNextReport(void) /* Read in HID report data */ Pipe_Read_Stream_LE(&ReportINData, sizeof(ReportINData)); - + /* Print report data through the serial port */ for (uint16_t CurrByte = 0; CurrByte < sizeof(ReportINData); CurrByte++) printf_P(PSTR("0x%02X "), ReportINData[CurrByte]); - + puts_P(PSTR("\r\n")); } - + /* Clear the IN endpoint, ready for next data packet */ Pipe_ClearIN(); - + /* Refreeze HID data IN pipe */ Pipe_Freeze(); } @@ -177,7 +177,7 @@ void WriteNextReport(uint8_t* ReportOUTData, { /* Select the HID data OUT pipe */ Pipe_SelectPipe(HID_DATA_OUT_PIPE); - + /* Not all HID devices have an OUT endpoint (some require OUT reports to be sent over the * control endpoint instead) - check to see if the OUT endpoint has been initialized */ if (Pipe_IsConfigured() && (ReportType == REPORT_TYPE_OUT)) @@ -189,17 +189,17 @@ void WriteNextReport(uint8_t* ReportOUTData, { /* Refreeze the data OUT pipe */ Pipe_Freeze(); - + return; } - + /* If the report index is used, send it before the report data */ if (ReportIndex) Pipe_Write_Byte(ReportIndex); /* Write out HID report data */ - Pipe_Write_Stream_LE(ReportOUTData, ReportLength); - + Pipe_Write_Stream_LE(ReportOUTData, ReportLength); + /* Clear the OUT endpoint, send last data packet */ Pipe_ClearOUT(); @@ -238,7 +238,7 @@ void HID_Host_Task(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -248,7 +248,7 @@ void HID_Host_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error status */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -265,12 +265,12 @@ void HID_Host_Task(void) /* Indicate error status */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - + /* Wait until USB device disconnected */ USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("HID Device Enumerated.\r\n")); USB_HostState = HOST_STATE_Configured; @@ -281,3 +281,4 @@ void HID_Host_Task(void) break; } } + diff --git a/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.h b/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.h index 489fba896..e3fc32135 100644 --- a/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.h +++ b/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -49,9 +49,9 @@ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Board/LEDs.h> - + #include "ConfigDescriptor.h" - + /* Macros: */ /** HID Class specific request to send a HID report to the device. */ #define REQ_SetReport 0x09 @@ -67,7 +67,7 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /** HID Report Type to indicate an IN report. */ #define REPORT_TYPE_IN 1 @@ -76,11 +76,11 @@ /** HID Report Type to indicate a FEATURE report. */ #define REPORT_TYPE_FEATURE 3 - + /* Function Prototypes: */ void SetupHardware(void); void HID_Host_Task(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); @@ -93,5 +93,6 @@ const uint8_t ReportIndex, const uint8_t ReportType, uint16_t ReportLength); - + #endif + diff --git a/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.txt b/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.txt index e176507de..a82a77830 100644 --- a/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.txt +++ b/Demos/Host/LowLevel/GenericHIDHost/GenericHIDHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Generic HID Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Human Interface Device (HID)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -41,14 +41,14 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Generic HID host demonstration application. This gives a simple reference * application for implementing a Generic HID USB host, for any device implementing * the HID profile. * * Received reports from the attached device are printed to the serial port. - * + * * \section SSec_Options Project Options * * The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. @@ -61,3 +61,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/LowLevel/GenericHIDHost/makefile b/Demos/Host/LowLevel/GenericHIDHost/makefile index b7342e007..d39f7e6d4 100644 --- a/Demos/Host/LowLevel/GenericHIDHost/makefile +++ b/Demos/Host/LowLevel/GenericHIDHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -134,7 +134,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -147,7 +147,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -261,7 +261,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -274,7 +274,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -286,7 +286,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -298,7 +298,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -321,7 +321,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -355,7 +355,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -389,7 +389,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -418,7 +418,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -437,10 +437,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -505,11 +505,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -536,9 +536,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -636,14 +636,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -665,7 +665,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -709,3 +709,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c b/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c index 3eaf7d960..20eaec7c9 100644 --- a/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Interface_t* HIDInterface = NULL; USB_Descriptor_HID_t* HIDDescriptor = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; @@ -95,12 +95,12 @@ uint8_t ProcessConfigurationDescriptor(void) } /* Save the HID descriptor for later use */ - HIDDescriptor = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t); + HIDDescriptor = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t); /* Skip the remainder of the loop as we have not found an endpoint yet */ continue; } - + /* Retrieve the endpoint address from the endpoint descriptor */ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t); @@ -108,7 +108,7 @@ uint8_t ProcessConfigurationDescriptor(void) if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) DataINEndpoint = EndpointData; } - + /* Configure the HID data IN pipe */ Pipe_ConfigurePipe(JOYSTICK_DATA_IN_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE); @@ -140,7 +140,7 @@ uint8_t DComp_NextJoystickInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + return DESCRIPTOR_SEARCH_NotFound; } @@ -181,5 +181,6 @@ uint8_t DComp_NextHID(void* CurrentDescriptor) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID) return DESCRIPTOR_SEARCH_Found; else - return DESCRIPTOR_SEARCH_NotFound; + return DESCRIPTOR_SEARCH_NotFound; } + diff --git a/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.h b/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.h index 58c63f9e5..5aafe7d39 100644 --- a/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.h +++ b/Demos/Host/LowLevel/JoystickHostWithParser/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,9 +38,9 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "HIDReport.h" - + /* Macros: */ /** Interface Class value for the Human Interface Device class. */ #define JOYSTICK_CLASS 0x03 @@ -53,7 +53,7 @@ /** Descriptor header type constant for a HID report descriptor. */ #define DTYPE_Report 0x22 - + /** Pipe number for the joystick report data pipe. */ #define JOYSTICK_DATA_IN_PIPE 1 @@ -78,3 +78,4 @@ uint8_t DComp_NextHID(void* CurrentDescriptor); #endif + diff --git a/Demos/Host/LowLevel/JoystickHostWithParser/HIDReport.c b/Demos/Host/LowLevel/JoystickHostWithParser/HIDReport.c index bda99bdd0..76e26a0d5 100644 --- a/Demos/Host/LowLevel/JoystickHostWithParser/HIDReport.c +++ b/Demos/Host/LowLevel/JoystickHostWithParser/HIDReport.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -46,7 +46,7 @@ uint8_t GetHIDReportData(void) { /* Create a buffer big enough to hold the entire returned HID report */ uint8_t HIDReportData[HIDReportSize]; - + USB_ControlRequest = (USB_Request_Header_t) { .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE), @@ -66,7 +66,7 @@ uint8_t GetHIDReportData(void) /* Send the HID report to the parser for processing */ if (USB_ProcessHIDReport(HIDReportData, HIDReportSize, &HIDReportInfo) != HID_PARSE_Successful) return ParseError; - + return ParseSuccessful; } @@ -100,7 +100,7 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem) /* If a collection with the joystick usage was not found, indicate that we are not interested in this item */ if (!IsJoystick) return false; - + /* Check the attributes of the current joystick item - see if we are interested in it or not; * only store BUTTON and GENERIC_DESKTOP_CONTROL items into the Processed HID Report * structure to save RAM and ignore the rest @@ -108,3 +108,4 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem) return ((CurrentItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) || (CurrentItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL)); } + diff --git a/Demos/Host/LowLevel/JoystickHostWithParser/HIDReport.h b/Demos/Host/LowLevel/JoystickHostWithParser/HIDReport.h index da73ff823..0808806f7 100644 --- a/Demos/Host/LowLevel/JoystickHostWithParser/HIDReport.h +++ b/Demos/Host/LowLevel/JoystickHostWithParser/HIDReport.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -39,7 +39,7 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/Host/HIDParser.h> - + #include "JoystickHostWithParser.h" /* Macros: */ @@ -66,16 +66,16 @@ ParseError = 1, /**< Failed to fully process the HID report descriptor */ ParseControlError = 2, /**< Control error occurred while trying to read the device HID descriptor */ }; - + /* Type Defines: */ /** Type define for a HID descriptor. */ typedef struct { USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */ - + uint16_t HIDSpec; /**< Implemented HID class specification, in BCD encoded format */ uint8_t CountryCode; /**< Country code value for localized hardware */ - + uint8_t TotalHIDDescriptors; /**< Total number of HID report descriptors in the current interface */ uint8_t HIDReportType; /**< HID report type of the first HID report descriptor */ @@ -88,7 +88,8 @@ /* Function Prototypes: */ uint8_t GetHIDReportData(void); - + bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem); - + #endif + diff --git a/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.c b/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.c index c7739e97f..3bd27da11 100644 --- a/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.c +++ b/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the JoystickHostWithParser demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "JoystickHostWithParser.h" /** Main program entry point. This routine configures the hardware required by the application, then @@ -64,7 +64,7 @@ void SetupHardware(void) /* Disable clock division */ clock_prescale_set(clock_div_1); - + /* Hardware Initialization */ SerialStream_Init(9600, false); LEDs_Init(); @@ -118,7 +118,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8 " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } @@ -134,7 +134,7 @@ void Joystick_HID_Task(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -144,7 +144,7 @@ void Joystick_HID_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -152,7 +152,7 @@ void Joystick_HID_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */ if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful) { @@ -161,12 +161,12 @@ void Joystick_HID_Task(void) /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - + /* Wait until USB device disconnected */ USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + printf_P(PSTR("Processing HID Report (Size %d Bytes).\r\n"), HIDReportSize); /* Get and process the device's first HID report descriptor */ @@ -178,21 +178,21 @@ void Joystick_HID_Task(void) puts_P(PSTR("Not a valid Joystick." ESC_FG_WHITE)); else printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - + /* Wait until USB device disconnected */ USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + printf("Total Reports: %d\r\n", HIDReportInfo.TotalDeviceReports); for (uint8_t i = 0; i < HIDReportInfo.TotalDeviceReports; i++) { HID_ReportSizeInfo_t* CurrReportIDInfo = &HIDReportInfo.ReportIDSizes[i]; - + uint8_t ReportSizeInBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_In]; uint8_t ReportSizeOutBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Out]; uint8_t ReportSizeFeatureBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Feature]; @@ -211,9 +211,9 @@ void Joystick_HID_Task(void) break; case HOST_STATE_Configured: /* Select and unfreeze joystick data pipe */ - Pipe_SelectPipe(JOYSTICK_DATA_IN_PIPE); + Pipe_SelectPipe(JOYSTICK_DATA_IN_PIPE); Pipe_Unfreeze(); - + /* Check to see if a packet has been received */ if (Pipe_IsINReceived()) { @@ -225,11 +225,11 @@ void Joystick_HID_Task(void) /* Load in the joystick report */ Pipe_Read_Stream_LE(JoystickReport, Pipe_BytesInPipe()); - + /* Process the read in joystick report from the device */ ProcessJoystickReport(JoystickReport); } - + /* Clear the IN endpoint, ready for next data packet */ Pipe_ClearIN(); } @@ -254,7 +254,7 @@ void ProcessJoystickReport(uint8_t* JoystickReport) { /* Create a temporary item pointer to the next report item */ HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber]; - + bool FoundData; if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) && @@ -262,7 +262,7 @@ void ProcessJoystickReport(uint8_t* JoystickReport) { /* Get the joystick button value */ FoundData = USB_GetHIDReportItemInfo(JoystickReport, ReportItem); - + /* For multi-report devices - if the requested data was not in the issued report, continue */ if (!(FoundData)) continue; @@ -278,13 +278,13 @@ void ProcessJoystickReport(uint8_t* JoystickReport) { /* Get the joystick relative position value */ FoundData = USB_GetHIDReportItemInfo(JoystickReport, ReportItem); - + /* For multi-report devices - if the requested data was not in the issued report, continue */ if (!(FoundData)) continue; - + int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t); - + /* Check to see if a (non-zero) delta movement has been indicated */ if (DeltaMovement) { @@ -296,7 +296,7 @@ void ProcessJoystickReport(uint8_t* JoystickReport) } } } - + /* Display the button information on the board LEDs */ LEDs_SetAllLEDs(LEDMask); -}
\ No newline at end of file +} diff --git a/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.h b/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.h index 5f34dba03..403465fbe 100644 --- a/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.h +++ b/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -49,7 +49,7 @@ #include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/USB/USB.h> - + #include "ConfigDescriptor.h" #include "HIDReport.h" @@ -69,7 +69,7 @@ /* Function Prototypes: */ void Joystick_HID_Task(void); void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); @@ -80,3 +80,4 @@ void ProcessJoystickReport(uint8_t* JoystickReport); #endif + diff --git a/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.txt b/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.txt index 055890b70..0fa97f868 100644 --- a/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.txt +++ b/Demos/Host/LowLevel/JoystickHostWithParser/JoystickHostWithParser.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Joystick Host With HID Descriptor Parser Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Human Interface Device (HID)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -41,19 +41,19 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Joystick host demonstration application. This gives a simple reference * application for implementing a USB Joystick host, for USB joysticks using * the standard joystick HID profile. It uses a HID parser for the HID * reports, allowing for correct operation across all USB joysticks. This * demo supports joysticks with a single HID report. - * + * * Joystick movement and button presses are displayed on the board LEDs. * On connection to a USB joystick, the report items will be processed and * printed as a formatted list through the USART before the joystick is * fully enumerated. - * + * * Currently only single interface joysticks are supported. * * \section SSec_Options Project Options @@ -68,3 +68,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/LowLevel/JoystickHostWithParser/makefile b/Demos/Host/LowLevel/JoystickHostWithParser/makefile index 39b13ed36..ec35eeb38 100644 --- a/Demos/Host/LowLevel/JoystickHostWithParser/makefile +++ b/Demos/Host/LowLevel/JoystickHostWithParser/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -135,7 +135,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -148,7 +148,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -299,7 +299,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -322,7 +322,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -419,7 +419,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -506,11 +506,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -637,14 +637,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c b/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c index e1e32ed7c..ea42a28ab 100644 --- a/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Interface_t* HIDInterface = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; @@ -66,7 +66,7 @@ uint8_t ProcessConfigurationDescriptor(void) default: return ControlError; } - + while (!(DataINEndpoint)) { /* See if we've found a likely compatible interface, and if there is an endpoint within that interface */ @@ -88,7 +88,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Skip the remainder of the loop as we have not found an endpoint yet */ continue; } - + /* Retrieve the endpoint address from the endpoint descriptor */ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t); @@ -96,7 +96,7 @@ uint8_t ProcessConfigurationDescriptor(void) if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) DataINEndpoint = EndpointData; } - + /* Configure the HID data IN pipe */ Pipe_ConfigurePipe(KEYBOARD_DATA_IN_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE); @@ -125,7 +125,7 @@ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + return DESCRIPTOR_SEARCH_NotFound; } @@ -152,3 +152,4 @@ uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } + diff --git a/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.h b/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.h index f8fed3e58..14f691b68 100644 --- a/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.h +++ b/Demos/Host/LowLevel/KeyboardHost/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,16 +38,16 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "KeyboardHost.h" - + /* Macros: */ /** Interface Class value for the Human Interface Device class. */ #define KEYBOARD_CLASS 0x03 /** Interface Protocol value for a Boot Protocol Keyboard compliant device. */ #define KEYBOARD_PROTOCOL 0x01 - + /** Pipe number for the keyboard data IN pipe. */ #define KEYBOARD_DATA_IN_PIPE 1 @@ -64,8 +64,9 @@ /* Function Prototypes: */ uint8_t ProcessConfigurationDescriptor(void); - + uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor); uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor); #endif + diff --git a/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c b/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c index 0c24bc9e2..269fe2779 100644 --- a/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c +++ b/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the KeyboardHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "KeyboardHost.h" /** Main program entry point. This routine configures the hardware required by the application, then @@ -129,9 +129,9 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, void ReadNextReport(void) { USB_KeyboardReport_Data_t KeyboardReport; - + /* Select keyboard data pipe */ - Pipe_SelectPipe(KEYBOARD_DATA_IN_PIPE); + Pipe_SelectPipe(KEYBOARD_DATA_IN_PIPE); /* Unfreeze keyboard data pipe */ Pipe_Unfreeze(); @@ -141,10 +141,10 @@ void ReadNextReport(void) { /* Refreeze HID data IN pipe */ Pipe_Freeze(); - + return; } - + /* Ensure pipe contains data before trying to read from it */ if (Pipe_IsReadWriteAllowed()) { @@ -153,13 +153,13 @@ void ReadNextReport(void) /* Indicate if the modifier byte is non-zero (special key such as shift is being pressed) */ LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0); - + /* Check if a key has been pressed */ if (KeyboardReport.KeyCode) { /* Toggle status LED to indicate keypress */ LEDs_ToggleLEDs(LEDS_LED2); - + char PressedKey = 0; /* Retrieve pressed key character if alphanumeric */ @@ -168,16 +168,16 @@ void ReadNextReport(void) else if ((KeyboardReport.KeyCode[0] >= 0x1E) && (KeyboardReport.KeyCode[0] <= 0x27)) PressedKey = (KeyboardReport.KeyCode[0] - 0x1E) + '0'; else if (KeyboardReport.KeyCode[0] == 0x2C) - PressedKey = ' '; + PressedKey = ' '; else if (KeyboardReport.KeyCode[0] == 0x28) PressedKey = '\n'; - + /* Print the pressed key character out through the serial port if valid */ if (PressedKey) putchar(PressedKey); } } - + /* Clear the IN endpoint, ready for next data packet */ Pipe_ClearIN(); @@ -196,7 +196,7 @@ void Keyboard_HID_Task(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -206,7 +206,7 @@ void Keyboard_HID_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error status */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -214,7 +214,7 @@ void Keyboard_HID_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */ if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful) { @@ -228,7 +228,7 @@ void Keyboard_HID_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* HID class request to set the keyboard protocol to the Boot Protocol */ USB_ControlRequest = (USB_Request_Header_t) { @@ -250,7 +250,7 @@ void Keyboard_HID_Task(void) /* Indicate error status */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - + /* Wait until USB device disconnected */ USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -267,3 +267,4 @@ void Keyboard_HID_Task(void) break; } } + diff --git a/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.h b/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.h index 0c6075330..63d6c06b5 100644 --- a/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.h +++ b/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -49,9 +49,9 @@ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Board/LEDs.h> - + #include "ConfigDescriptor.h" - + /* Macros: */ /** HID Class Specific request to set the report protocol mode. */ #define REQ_SetProtocol 0x0B @@ -76,11 +76,11 @@ uint8_t Reserved; /**< Reserved for OEM use, always set to 0 */ uint8_t KeyCode[6]; /**< Key codes of the currently pressed keys */ } USB_KeyboardReport_Data_t; - + /* Function Prototypes: */ void Keyboard_HID_Task(void); void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); @@ -89,5 +89,6 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void); void ReadNextReport(void); - + #endif + diff --git a/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.txt b/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.txt index 397150175..810634dcd 100644 --- a/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.txt +++ b/Demos/Host/LowLevel/KeyboardHost/KeyboardHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Keyboard Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Human Interface Device (HID)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -41,21 +41,21 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Keyboard host demonstration application. This gives a simple reference * application for implementing a USB keyboard, for USB keyboards using * the standard keyboard HID profile. - * + * * Pressed alpha-numeric, enter or space key is transmitted through the serial * USART at serial settings 9600, 8, N, 1. - * + * * This uses a naive method where the keyboard is set to Boot Protocol mode, so * that the report structure is fixed and known. A better implementation * uses the HID report parser for correct report data processing across * all compatible mice with advanced characteristics, as shown in the * KeyboardHostWithParser demo application. - * + * * Currently only single interface keyboards are supported. * * \section SSec_Options Project Options @@ -70,3 +70,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/LowLevel/KeyboardHost/makefile b/Demos/Host/LowLevel/KeyboardHost/makefile index 6d8634ce1..13bf64d63 100644 --- a/Demos/Host/LowLevel/KeyboardHost/makefile +++ b/Demos/Host/LowLevel/KeyboardHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -134,7 +134,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -147,7 +147,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -261,7 +261,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -274,7 +274,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -286,7 +286,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -298,7 +298,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -321,7 +321,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -355,7 +355,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -389,7 +389,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -418,7 +418,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -437,10 +437,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -505,11 +505,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -536,9 +536,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -636,14 +636,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -665,7 +665,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -709,3 +709,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c b/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c index 74817a2f1..fe35d95b7 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Interface_t* HIDInterface = NULL; USB_Descriptor_HID_t* HIDDescriptor = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; @@ -82,7 +82,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Descriptor not found, error out */ return NoCompatibleInterfaceFound; } - + /* Save the interface in case we need to refer back to it later */ HIDInterface = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Interface_t); @@ -93,14 +93,14 @@ uint8_t ProcessConfigurationDescriptor(void) /* Descriptor not found, error out */ return NoCompatibleInterfaceFound; } - + /* Save the HID descriptor for later use */ - HIDDescriptor = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t); - + HIDDescriptor = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t); + /* Skip the remainder of the loop as we have not found an endpoint yet */ continue; } - + /* Retrieve the endpoint address from the endpoint descriptor */ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t); @@ -108,7 +108,7 @@ uint8_t ProcessConfigurationDescriptor(void) if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) DataINEndpoint = EndpointData; } - + /* Configure the HID data IN pipe */ Pipe_ConfigurePipe(KEYBOARD_DATA_IN_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE); @@ -140,7 +140,7 @@ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + return DESCRIPTOR_SEARCH_NotFound; } @@ -183,5 +183,6 @@ uint8_t DComp_NextHID(void* CurrentDescriptor) else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) return DESCRIPTOR_SEARCH_Fail; else - return DESCRIPTOR_SEARCH_NotFound; + return DESCRIPTOR_SEARCH_NotFound; } + diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.h b/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.h index a7bc1d34c..d23c89dd0 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.h +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,9 +38,9 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "HIDReport.h" - + /* Macros: */ /** Interface Class value for the Human Interface Device class. */ #define KEYBOARD_CLASS 0x03 @@ -53,7 +53,7 @@ /** Descriptor header type constant for a HID report descriptor. */ #define DTYPE_Report 0x22 - + /** Pipe number for the keyboard report data pipe. */ #define KEYBOARD_DATA_IN_PIPE 1 @@ -74,5 +74,6 @@ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor); uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor); uint8_t DComp_NextHID(void* CurrentDescriptor); - + #endif + diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.c b/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.c index 6b4df377d..d2dde64bd 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.c +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -46,7 +46,7 @@ uint8_t GetHIDReportData(void) { /* Create a buffer big enough to hold the entire returned HID report */ uint8_t HIDReportData[HIDReportSize]; - + USB_ControlRequest = (USB_Request_Header_t) { .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE), @@ -66,7 +66,7 @@ uint8_t GetHIDReportData(void) /* Send the HID report to the parser for processing */ if (USB_ProcessHIDReport(HIDReportData, HIDReportSize, &HIDReportInfo) != HID_PARSE_Successful) return ParseError; - + return ParseSuccessful; } @@ -87,3 +87,4 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem) */ return (CurrentItem->Attributes.Usage.Page == USAGE_PAGE_KEYBOARD); } + diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.h b/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.h index 09cace965..e18ad3aae 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.h +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/HIDReport.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -39,7 +39,7 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/Host/HIDParser.h> - + #include "KeyboardHostWithParser.h" /* Macros: */ @@ -54,16 +54,16 @@ ParseError = 1, /**< Failed to fully process the HID report descriptor */ ParseControlError = 2, /**< Control error occurred while trying to read the device HID descriptor */ }; - + /* Type Defines: */ /** Type define for a HID descriptor. */ typedef struct { USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */ - + uint16_t HIDSpec; /**< Implemented HID class specification, in BCD encoded format */ uint8_t CountryCode; /**< Country code value for localized hardware */ - + uint8_t TotalHIDDescriptors; /**< Total number of HID report descriptors in the current interface */ uint8_t HIDReportType; /**< HID report type of the first HID report descriptor */ @@ -78,5 +78,6 @@ uint8_t GetHIDReportData(void); bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem); - + #endif + diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c b/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c index 15bc94061..bdf4a2830 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the KeyboardHostWithParser demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "KeyboardHostWithParser.h" /** Main program entry point. This routine configures the hardware required by the application, then @@ -119,7 +119,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } @@ -134,7 +134,7 @@ void Keyboard_HID_Task(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -144,7 +144,7 @@ void Keyboard_HID_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -167,9 +167,9 @@ void Keyboard_HID_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + printf_P(PSTR("Processing HID Report (Size %d Bytes).\r\n"), HIDReportSize); - + /* Get and process the device's first HID report descriptor */ if ((ErrorCode = GetHIDReportData()) != ParseSuccessful) { @@ -179,13 +179,13 @@ void Keyboard_HID_Task(void) puts_P(PSTR("Not a valid Keyboard." ESC_FG_WHITE)); else printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - + /* Wait until USB device disconnected */ USB_HostState = HOST_STATE_WaitForDeviceRemoval; - break; + break; } printf("Total Reports: %d\r\n", HIDReportInfo.TotalDeviceReports); @@ -193,7 +193,7 @@ void Keyboard_HID_Task(void) for (uint8_t i = 0; i < HIDReportInfo.TotalDeviceReports; i++) { HID_ReportSizeInfo_t* CurrReportIDInfo = &HIDReportInfo.ReportIDSizes[i]; - + uint8_t ReportSizeInBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_In]; uint8_t ReportSizeOutBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Out]; uint8_t ReportSizeFeatureBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Feature]; @@ -212,7 +212,7 @@ void Keyboard_HID_Task(void) break; case HOST_STATE_Configured: /* Select and unfreeze keyboard data pipe */ - Pipe_SelectPipe(KEYBOARD_DATA_IN_PIPE); + Pipe_SelectPipe(KEYBOARD_DATA_IN_PIPE); Pipe_Unfreeze(); /* Check to see if a packet has been received */ @@ -226,11 +226,11 @@ void Keyboard_HID_Task(void) /* Load in the keyboard report */ Pipe_Read_Stream_LE(KeyboardReport, Pipe_BytesInPipe()); - + /* Process the read in keyboard report from the device */ ProcessKeyboardReport(KeyboardReport); } - + /* Clear the IN endpoint, ready for next data packet */ Pipe_ClearIN(); } @@ -262,11 +262,11 @@ void ProcessKeyboardReport(uint8_t* KeyboardReport) { /* Retrieve the keyboard scan-code from the report data retrieved from the device */ bool FoundData = USB_GetHIDReportItemInfo(KeyboardReport, ReportItem); - + /* For multi-report devices - if the requested data was not in the issued report, continue */ if (!(FoundData)) continue; - + /* Key code is an unsigned char in length, cast to the appropriate type */ uint8_t KeyCode = (uint8_t)ReportItem->Value; @@ -284,17 +284,18 @@ void ProcessKeyboardReport(uint8_t* KeyboardReport) else if ((KeyCode >= 0x1E) && (KeyCode <= 0x27)) PressedKey = (KeyCode - 0x1E) + '0'; else if (KeyCode == 0x2C) - PressedKey = ' '; + PressedKey = ' '; else if (KeyCode == 0x28) PressedKey = '\n'; - + /* Print the pressed key character out through the serial port if valid */ if (PressedKey) putchar(PressedKey); } - + /* Once a scan-code is found, stop scanning through the report items */ break; } } } + diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.h b/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.h index 4aaea382f..3a5f138a1 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.h +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -44,7 +44,7 @@ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Board/LEDs.h> - + #include "ConfigDescriptor.h" #include "HIDReport.h" @@ -60,7 +60,7 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /* Function Prototypes: */ void Keyboard_HID_Task(void); void SetupHardware(void); @@ -73,5 +73,6 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void); void ProcessKeyboardReport(uint8_t* KeyboardReport); - + #endif + diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.txt b/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.txt index 5e122a38f..50f6c861d 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.txt +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/KeyboardHostWithParser.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Keyboard Host With HID Descriptor Parser Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Human Interface Device (HID)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -41,20 +41,20 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Keyboard host demonstration application. This gives a simple reference * application for implementing a USB Keyboard host, for USB keyboards using * the standard Keyboard HID profile. It uses a HID parser for the HID reports, * allowing for correct operation across all USB keyboards. This demo supports * keyboards with a single HID report. - * + * * Pressed alpha-numeric, enter or space key is transmitted through the serial * USART at serial settings 9600, 8, N, 1. On connection to a USB keyboard, the * report items will be processed and printed as a formatted list through the * USART before the keyboard is fully enumerated. - * - * Currently only single interface keyboards are supported. + * + * Currently only single interface keyboards are supported. * * \section SSec_Options Project Options * @@ -68,3 +68,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/LowLevel/KeyboardHostWithParser/makefile b/Demos/Host/LowLevel/KeyboardHostWithParser/makefile index db8f91911..04bb9ab79 100644 --- a/Demos/Host/LowLevel/KeyboardHostWithParser/makefile +++ b/Demos/Host/LowLevel/KeyboardHostWithParser/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -135,7 +135,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -148,7 +148,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -299,7 +299,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -322,7 +322,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -419,7 +419,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -506,11 +506,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -637,14 +637,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c b/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c index 7feb31251..874fa7a3a 100644 --- a/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -34,7 +34,7 @@ * needed to communication with an attached USB device. Descriptors are special computer-readable structures * which the host requests upon device enumeration, to determine the device's capabilities and functions. */ - + #include "ConfigDescriptor.h" /** Reads and processes an attached device's descriptors, to determine compatibility and pipe configurations. This @@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Interface_t* MIDIInterface = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; @@ -67,7 +67,7 @@ uint8_t ProcessConfigurationDescriptor(void) default: return ControlError; } - + while (!(DataINEndpoint) || !(DataOUTEndpoint)) { /* See if we've found a likely compatible interface, and if there is an endpoint within that interface */ @@ -93,7 +93,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Skip the remainder of the loop as we have not found an endpoint yet */ continue; } - + /* Retrieve the endpoint address from the endpoint descriptor */ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t); @@ -103,7 +103,7 @@ uint8_t ProcessConfigurationDescriptor(void) else DataOUTEndpoint = EndpointData; } - + /* Configure the MIDI data IN pipe */ Pipe_ConfigurePipe(MIDI_DATA_IN_PIPE, EP_TYPE_BULK, PIPE_TOKEN_IN, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE); @@ -136,7 +136,7 @@ uint8_t DComp_NextMIDIStreamingInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + return DESCRIPTOR_SEARCH_NotFound; } @@ -155,7 +155,7 @@ uint8_t DComp_NextMIDIStreamingDataEndpoint(void* CurrentDescriptor) { uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK); - + /* Check the endpoint type, break out if correct BULK type endpoint found */ if (EndpointType == EP_TYPE_BULK) return DESCRIPTOR_SEARCH_Found; @@ -167,3 +167,4 @@ uint8_t DComp_NextMIDIStreamingDataEndpoint(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } + diff --git a/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.h b/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.h index 80a05667d..57a36d924 100644 --- a/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.h +++ b/Demos/Host/LowLevel/MIDIHost/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,19 +38,19 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "MIDIHost.h" - + /* Macros: */ /** Interface Class value for the MIDI Audio class. */ #define MIDI_STREAMING_CLASS 0x01 - + /** Interface Class value for the MIDI Audio Streaming subclass. */ #define MIDI_STREAMING_SUBCLASS 0x03 /** Interface Class value for the MIDI Audio Streaming protocol. */ #define MIDI_STREAMING_PROTOCOL 0x00 - + /** Pipe number for the MIDI data IN pipe. */ #define MIDI_DATA_IN_PIPE 1 @@ -69,9 +69,10 @@ }; /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); - + uint8_t ProcessConfigurationDescriptor(void); + uint8_t DComp_NextMIDIStreamingInterface(void* CurrentDescriptor); uint8_t DComp_NextMIDIStreamingDataEndpoint(void* CurrentDescriptor); - + #endif + diff --git a/Demos/Host/LowLevel/MIDIHost/MIDIHost.c b/Demos/Host/LowLevel/MIDIHost/MIDIHost.c index 7725f5d8a..63ed6da25 100644 --- a/Demos/Host/LowLevel/MIDIHost/MIDIHost.c +++ b/Demos/Host/LowLevel/MIDIHost/MIDIHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the MIDIHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "MIDIHost.h" /** Main program entry point. This routine configures the hardware required by the application, then @@ -121,7 +121,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } @@ -137,7 +137,7 @@ void MIDI_Host_Task(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -147,7 +147,7 @@ void MIDI_Host_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -155,7 +155,7 @@ void MIDI_Host_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */ if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful) { @@ -176,16 +176,16 @@ void MIDI_Host_Task(void) break; case HOST_STATE_Configured: Pipe_SelectPipe(MIDI_DATA_IN_PIPE); - + if (Pipe_IsINReceived()) { USB_MIDI_EventPacket_t MIDIEvent; - + Pipe_Read_Stream_LE(&MIDIEvent, sizeof(MIDIEvent)); - + bool NoteOnEvent = ((MIDIEvent.Command & 0x0F) == (MIDI_COMMAND_NOTE_ON >> 4)); bool NoteOffEvent = ((MIDIEvent.Command & 0x0F) == (MIDI_COMMAND_NOTE_OFF >> 4)); - + if (NoteOnEvent || NoteOffEvent) { printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d\r\n"), NoteOnEvent ? "On" : "Off", @@ -195,19 +195,19 @@ void MIDI_Host_Task(void) Pipe_ClearIN(); } - + Pipe_SelectPipe(MIDI_DATA_OUT_PIPE); - + static uint8_t PrevJoystickStatus; if (Pipe_IsOUTReady()) { uint8_t MIDICommand = 0; uint8_t MIDIPitch; - + uint8_t JoystickStatus = Joystick_GetStatus(); uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus); - + /* Get board button status - if pressed use channel 10 (percussion), otherwise use channel 1 */ uint8_t Channel = ((Buttons_GetStatus() & BUTTONS_BUTTON1) ? MIDI_CHANNEL(10) : MIDI_CHANNEL(1)); @@ -228,7 +228,7 @@ void MIDI_Host_Task(void) MIDICommand = ((JoystickStatus & JOY_RIGHT)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF); MIDIPitch = 0x3E; } - + if (JoystickChanges & JOY_DOWN) { MIDICommand = ((JoystickStatus & JOY_DOWN)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF); @@ -248,19 +248,19 @@ void MIDI_Host_Task(void) { .CableNumber = 0, .Command = (MIDICommand >> 4), - + .Data1 = MIDICommand | Channel, .Data2 = MIDIPitch, - .Data3 = MIDI_STANDARD_VELOCITY, + .Data3 = MIDI_STANDARD_VELOCITY, }; - + /* Write the MIDI event packet to the pipe */ Pipe_Write_Stream_LE(&MIDIEvent, sizeof(MIDIEvent)); - + /* Send the data in the pipe to the device */ Pipe_ClearOUT(); } - + /* Save previous joystick value for next joystick change detection */ PrevJoystickStatus = JoystickStatus; } @@ -268,3 +268,4 @@ void MIDI_Host_Task(void) break; } } + diff --git a/Demos/Host/LowLevel/MIDIHost/MIDIHost.h b/Demos/Host/LowLevel/MIDIHost/MIDIHost.h index 507f0787c..f7fb57a91 100644 --- a/Demos/Host/LowLevel/MIDIHost/MIDIHost.h +++ b/Demos/Host/LowLevel/MIDIHost/MIDIHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -51,19 +51,19 @@ #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/Board/Buttons.h> #include <LUFA/Drivers/Board/Joystick.h> - + #include "ConfigDescriptor.h" - + /* Macros: */ /** MIDI command for a note on (activation) event. */ #define MIDI_COMMAND_NOTE_ON 0x90 /** MIDI command for a note off (deactivation) event. */ #define MIDI_COMMAND_NOTE_OFF 0x80 - + /** Standard key press velocity value used for all note events, as no pressure sensor is mounted. */ #define MIDI_STANDARD_VELOCITY 64 - + /** Convenience macro. MIDI channels are numbered from 1-10 (natural numbers) however the logical channel * addresses are zero-indexed. This converts a natural MIDI channel number into the logical channel address. * @@ -89,21 +89,22 @@ { unsigned char Command : 4; /**< MIDI command being sent or received in the event packet */ unsigned char CableNumber : 4; /**< Virtual cable number of the event being sent or received in the given MIDI interface */ - + uint8_t Data1; /**< First byte of data in the MIDI event */ uint8_t Data2; /**< Second byte of data in the MIDI event */ - uint8_t Data3; /**< Third byte of data in the MIDI event */ + uint8_t Data3; /**< Third byte of data in the MIDI event */ } USB_MIDI_EventPacket_t; /* Function Prototypes: */ void SetupHardware(void); void MIDI_Host_Task(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + #endif + diff --git a/Demos/Host/LowLevel/MIDIHost/MIDIHost.txt b/Demos/Host/LowLevel/MIDIHost/MIDIHost.txt index a90ae04d3..337dba72e 100644 --- a/Demos/Host/LowLevel/MIDIHost/MIDIHost.txt +++ b/Demos/Host/LowLevel/MIDIHost/MIDIHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage MIDI Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Audio Class Device</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>MIDI Subclass</td> * </tr> @@ -39,7 +39,7 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * MIDI host demonstration application. This demo will enumerate an attached USB-MIDI device, and print incoming MIDI note * on and off messages on any channel to the serial port. Pressing the board joystick will send note on and off messages to @@ -57,3 +57,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/LowLevel/MIDIHost/makefile b/Demos/Host/LowLevel/MIDIHost/makefile index 36b231598..2940c5468 100644 --- a/Demos/Host/LowLevel/MIDIHost/makefile +++ b/Demos/Host/LowLevel/MIDIHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -134,7 +134,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -147,7 +147,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -261,7 +261,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -274,7 +274,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -286,7 +286,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -298,7 +298,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -321,7 +321,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -355,7 +355,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -389,7 +389,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -418,7 +418,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -437,10 +437,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -505,11 +505,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -536,9 +536,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -636,14 +636,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -665,7 +665,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -709,3 +709,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c b/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c index 3468e0db9..f336d62bf 100644 --- a/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -34,7 +34,7 @@ * needed to communication with an attached USB device. Descriptors are special computer-readable structures * which the host requests upon device enumeration, to determine the device's capabilities and functions. */ - + #include "ConfigDescriptor.h" /** Reads and processes an attached device's descriptors, to determine compatibility and pipe configurations. This @@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Interface_t* MSInterface = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; @@ -93,7 +93,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Skip the remainder of the loop as we have not found an endpoint yet */ continue; } - + /* Retrieve the endpoint address from the endpoint descriptor */ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t); @@ -103,7 +103,7 @@ uint8_t ProcessConfigurationDescriptor(void) else DataOUTEndpoint = EndpointData; } - + /* Configure the Mass Storage data IN pipe */ Pipe_ConfigurePipe(MASS_STORE_DATA_IN_PIPE, EP_TYPE_BULK, PIPE_TOKEN_IN, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE); @@ -136,7 +136,7 @@ uint8_t DComp_NextMSInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + return DESCRIPTOR_SEARCH_NotFound; } @@ -167,3 +167,4 @@ uint8_t DComp_NextMSInterfaceBulkDataEndpoint(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } + diff --git a/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.h b/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.h index d75789192..92c984068 100644 --- a/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.h +++ b/Demos/Host/LowLevel/MassStorageHost/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,9 +38,9 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "MassStorageHost.h" - + /* Macros: */ /** Interface Class value for the Mass Storage Device class. */ #define MASS_STORE_CLASS 0x08 @@ -67,11 +67,12 @@ InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */ NoCompatibleInterfaceFound = 4, /**< A compatible interface with the required endpoints was not found */ }; - + /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); + uint8_t ProcessConfigurationDescriptor(void); uint8_t DComp_NextMSInterface(void* CurrentDescriptor); uint8_t DComp_NextMSInterfaceBulkDataEndpoint(void* CurrentDescriptor); - + #endif + diff --git a/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c b/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c index c86e51b0c..712589660 100644 --- a/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c +++ b/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -46,7 +46,7 @@ * larger value in the project makefile and passing it to the compiler * via the -D switch. */ - + #define INCLUDE_FROM_MASSSTORE_COMMANDS_C #include "MassStoreCommands.h" @@ -85,13 +85,13 @@ static uint8_t MassStore_SendCommand(CommandBlockWrapper_t* const SCSICommandBlo /* Send the data in the OUT pipe to the attached device */ Pipe_ClearOUT(); - + /* Wait until command has been sent */ Pipe_WaitUntilReady(); /* Freeze pipe after use */ Pipe_Freeze(); - + /* Send data if any */ if ((BufferPtr != NULL) && ((ErrorCode = MassStore_SendReceiveData(SCSICommandBlock, BufferPtr)) != PIPE_READYWAIT_NoError)) @@ -99,7 +99,7 @@ static uint8_t MassStore_SendCommand(CommandBlockWrapper_t* const SCSICommandBlo Pipe_Freeze(); return ErrorCode; } - + return ErrorCode; } @@ -116,12 +116,12 @@ static uint8_t MassStore_WaitForDataReceived(void) /* Select the IN data pipe for data reception */ Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE); Pipe_Unfreeze(); - + /* Wait until data received in the IN pipe */ while (!(Pipe_IsINReceived())) { uint16_t CurrentFrameNumber = USB_Host_GetFrameNumber(); - + /* Check to see if a new frame has been issued (1ms elapsed) */ if (CurrentFrameNumber != PreviousFrameNumber) { @@ -133,7 +133,7 @@ static uint8_t MassStore_WaitForDataReceived(void) if (!(TimeoutMSRem)) return PIPE_RWSTREAM_Timeout; } - + Pipe_Freeze(); Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE); Pipe_Unfreeze(); @@ -146,7 +146,7 @@ static uint8_t MassStore_WaitForDataReceived(void) return PIPE_RWSTREAM_PipeStalled; } - + Pipe_Freeze(); Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE); Pipe_Unfreeze(); @@ -159,15 +159,15 @@ static uint8_t MassStore_WaitForDataReceived(void) return PIPE_RWSTREAM_PipeStalled; } - + /* Check to see if the device was disconnected, if so exit function */ if (USB_HostState == HOST_STATE_Unattached) return PIPE_RWSTREAM_DeviceDisconnected; }; - + Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE); Pipe_Freeze(); - + Pipe_SelectPipe(MASS_STORE_DATA_OUT_PIPE); Pipe_Freeze(); @@ -194,11 +194,11 @@ static uint8_t MassStore_SendReceiveData(CommandBlockWrapper_t* const SCSIComman /* Wait until the device has replied with some data */ if ((ErrorCode = MassStore_WaitForDataReceived()) != PIPE_RWSTREAM_NoError) return ErrorCode; - + /* Select the IN data pipe for data reception */ Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE); Pipe_Unfreeze(); - + /* Read in the block data from the pipe */ if ((ErrorCode = Pipe_Read_Stream_LE(BufferPtr, BytesRem)) != PIPE_RWSTREAM_NoError) return ErrorCode; @@ -218,14 +218,14 @@ static uint8_t MassStore_SendReceiveData(CommandBlockWrapper_t* const SCSIComman /* Acknowledge the packet */ Pipe_ClearOUT(); - + while (!(Pipe_IsOUTReady())) { if (USB_HostState == HOST_STATE_Unattached) return PIPE_RWSTREAM_DeviceDisconnected; } } - + /* Freeze used pipe after use */ Pipe_Freeze(); @@ -249,21 +249,21 @@ static uint8_t MassStore_GetReturnedStatus(CommandStatusWrapper_t* const SCSICom /* Select the IN data pipe for data reception */ Pipe_SelectPipe(MASS_STORE_DATA_IN_PIPE); Pipe_Unfreeze(); - + /* Load in the CSW from the attached device */ if ((ErrorCode = Pipe_Read_Stream_LE(SCSICommandStatus, sizeof(CommandStatusWrapper_t))) != PIPE_RWSTREAM_NoError) return ErrorCode; - + /* Clear the data ready for next reception */ Pipe_ClearIN(); - + /* Freeze the IN pipe after use */ Pipe_Freeze(); - + /* Check to see if command failed */ if (SCSICommandStatus->Status != Command_Pass) ErrorCode = MASS_STORE_SCSI_COMMAND_FAILED; - + return ErrorCode; } @@ -282,7 +282,7 @@ uint8_t MassStore_MassStorageReset(void) .wIndex = 0, .wLength = 0, }; - + /* Select the control pipe for the request transfer */ Pipe_SelectPipe(PIPE_CONTROLPIPE); @@ -312,7 +312,7 @@ uint8_t MassStore_GetMaxLUN(uint8_t* const MaxLUNIndex) .wIndex = 0, .wLength = 1, }; - + /* Select the control pipe for the request transfer */ Pipe_SelectPipe(PIPE_CONTROLPIPE); @@ -320,14 +320,14 @@ uint8_t MassStore_GetMaxLUN(uint8_t* const MaxLUNIndex) { /* Clear the pipe stall */ Pipe_ClearStall(); - + /* Some faulty Mass Storage devices don't implement the GET_MAX_LUN request, so assume a single LUN */ *MaxLUNIndex = 0; - + /* Clear the error, and pretend the request executed correctly if the device STALLed it */ ErrorCode = HOST_SENDCONTROL_Successful; } - + return ErrorCode; } @@ -362,7 +362,7 @@ uint8_t MassStore_Inquiry(const uint8_t LUNIndex, 0x00 // Unused (control) } }; - + CommandStatusWrapper_t SCSICommandStatus; /* Send the command and any data to the attached device */ @@ -371,7 +371,7 @@ uint8_t MassStore_Inquiry(const uint8_t LUNIndex, Pipe_Freeze(); return ErrorCode; } - + /* Retrieve status information from the attached device */ if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError) { @@ -413,7 +413,7 @@ uint8_t MassStore_RequestSense(const uint8_t LUNIndex, 0x00 // Unused (control) } }; - + CommandStatusWrapper_t SCSICommandStatus; /* Send the command and any data to the attached device */ @@ -422,7 +422,7 @@ uint8_t MassStore_RequestSense(const uint8_t LUNIndex, Pipe_Freeze(); return ErrorCode; } - + /* Retrieve status information from the attached device */ if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError) { @@ -474,7 +474,7 @@ uint8_t MassStore_ReadDeviceBlock(const uint8_t LUNIndex, 0x00 // Unused (control) } }; - + CommandStatusWrapper_t SCSICommandStatus; /* Send the command and any data to the attached device */ @@ -483,7 +483,7 @@ uint8_t MassStore_ReadDeviceBlock(const uint8_t LUNIndex, Pipe_Freeze(); return ErrorCode; } - + /* Retrieve status information from the attached device */ if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError) { @@ -535,7 +535,7 @@ uint8_t MassStore_WriteDeviceBlock(const uint8_t LUNIndex, 0x00 // Unused (control) } }; - + CommandStatusWrapper_t SCSICommandStatus; /* Send the command and any data to the attached device */ @@ -544,7 +544,7 @@ uint8_t MassStore_WriteDeviceBlock(const uint8_t LUNIndex, Pipe_Freeze(); return ErrorCode; } - + /* Retrieve status information from the attached device */ if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError) { @@ -564,7 +564,7 @@ uint8_t MassStore_WriteDeviceBlock(const uint8_t LUNIndex, */ uint8_t MassStore_TestUnitReady(const uint8_t LUNIndex) { - uint8_t ErrorCode = PIPE_RWSTREAM_NoError; + uint8_t ErrorCode = PIPE_RWSTREAM_NoError; /* Create a CBW with a SCSI command to issue TEST UNIT READY command */ CommandBlockWrapper_t SCSICommandBlock = (CommandBlockWrapper_t) @@ -584,7 +584,7 @@ uint8_t MassStore_TestUnitReady(const uint8_t LUNIndex) 0x00 // Unused (control) } }; - + CommandStatusWrapper_t SCSICommandStatus; /* Send the command and any data to the attached device */ @@ -593,7 +593,7 @@ uint8_t MassStore_TestUnitReady(const uint8_t LUNIndex) Pipe_Freeze(); return ErrorCode; } - + /* Retrieve status information from the attached device */ if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError) { @@ -639,7 +639,7 @@ uint8_t MassStore_ReadCapacity(const uint8_t LUNIndex, 0x00 // Unused (control) } }; - + CommandStatusWrapper_t SCSICommandStatus; /* Send the command and any data to the attached device */ @@ -648,11 +648,11 @@ uint8_t MassStore_ReadCapacity(const uint8_t LUNIndex, Pipe_Freeze(); return ErrorCode; } - + /* Endian-correct the read data */ CapacityPtr->Blocks = SwapEndian_32(CapacityPtr->Blocks); CapacityPtr->BlockSize = SwapEndian_32(CapacityPtr->BlockSize); - + /* Retrieve status information from the attached device */ if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError) { @@ -695,7 +695,7 @@ uint8_t MassStore_PreventAllowMediumRemoval(const uint8_t LUNIndex, 0x00 // Unused (control) } }; - + CommandStatusWrapper_t SCSICommandStatus; /* Send the command and any data to the attached device */ @@ -704,7 +704,7 @@ uint8_t MassStore_PreventAllowMediumRemoval(const uint8_t LUNIndex, Pipe_Freeze(); return ErrorCode; } - + /* Retrieve status information from the attached device */ if ((ErrorCode = MassStore_GetReturnedStatus(&SCSICommandStatus)) != PIPE_RWSTREAM_NoError) { @@ -714,3 +714,4 @@ uint8_t MassStore_PreventAllowMediumRemoval(const uint8_t LUNIndex, return ErrorCode; } + diff --git a/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.h b/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.h index 628066363..8fcffe424 100644 --- a/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.h +++ b/Demos/Host/LowLevel/MassStorageHost/Lib/MassStoreCommands.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -32,7 +32,7 @@ * * Header file for MassStoreCommands.c. */ - + #ifndef _MASS_STORE_COMMANDS_H_ #define _MASS_STORE_COMMANDS_H_ @@ -56,16 +56,16 @@ /** Command Static Wrapper signature byte, for verification of valid CSW blocks. */ #define CSW_SIGNATURE 0x53425355UL - + /** Data direction mask for the Flags field of a CBW, indicating Host-to-Device transfer direction. */ #define COMMAND_DIRECTION_DATA_OUT (0 << 7) /** Data direction mask for the Flags field of a CBW, indicating Device-to-Host transfer direction. */ #define COMMAND_DIRECTION_DATA_IN (1 << 7) - + /** Timeout period between the issuing of a CBW to a device, and the reception of the first packet. */ #define COMMAND_DATA_TIMEOUT_MS 10000 - + /** Additional error code for Mass Storage functions when a device returns a logical command failure. */ #define MASS_STORE_SCSI_COMMAND_FAILED 0xC0 @@ -83,7 +83,7 @@ uint8_t SCSICommandLength; /**< Length of the SCSI command in the CBW */ uint8_t SCSICommandData[16]; /**< SCSI command to issue to the device */ } CommandBlockWrapper_t; - + /** Type define for a Mass Storage class Command Status Wrapper, used to wrap SCSI * responses for transport over the USB bulk endpoints from the device. */ @@ -94,7 +94,7 @@ uint32_t DataTransferResidue; /**< Length of data not transferred */ uint8_t Status; /**< Command status, a value from the MassStorageHost_CommandStatusCodes_t enum */ } CommandStatusWrapper_t; - + /** Type define for a SCSI Sense structure. Structures of this type are filled out by the * device via the \ref MassStore_RequestSense() function, indicating the current sense data of the * device (giving explicit error codes for the last issued command). For details of the @@ -105,13 +105,13 @@ uint8_t ResponseCode; uint8_t SegmentNumber; - + unsigned char SenseKey : 4; unsigned char Reserved : 1; unsigned char ILI : 1; unsigned char EOM : 1; unsigned char FileMark : 1; - + uint8_t Information[4]; uint8_t AdditionalLength; uint8_t CmdSpecificInformation[4]; @@ -129,12 +129,12 @@ { unsigned char DeviceType : 5; unsigned char PeripheralQualifier : 3; - + unsigned char Reserved : 7; unsigned char Removable : 1; - + uint8_t Version; - + unsigned char ResponseDataFormat : 4; unsigned char Reserved2 : 1; unsigned char NormACA : 1; @@ -152,12 +152,12 @@ unsigned char WideBus16Bit : 1; unsigned char WideBus32Bit : 1; unsigned char RelAddr : 1; - + uint8_t VendorID[8]; uint8_t ProductID[16]; uint8_t RevisionID[4]; } SCSI_Inquiry_Response_t; - + /** SCSI capacity structure, to hold the total capacity of the device in both the number * of blocks in the current LUN, and the size of each block. This structure is filled by * the device when the \ref MassStore_ReadCapacity() function is called. @@ -176,7 +176,7 @@ Command_Fail = 1, /**< Command failed to complete successfully */ Phase_Error = 2 /**< Phase error while processing the issued command */ }; - + /* Function Prototypes: */ #if defined(INCLUDE_FROM_MASSSTORE_COMMANDS_C) static uint8_t MassStore_SendCommand(CommandBlockWrapper_t* const SCSICommandBlock, @@ -186,7 +186,7 @@ void* BufferPtr) ATTR_NON_NULL_PTR_ARG(1); static uint8_t MassStore_GetReturnedStatus(CommandStatusWrapper_t* const SCSICommandStatus) ATTR_NON_NULL_PTR_ARG(1); #endif - + uint8_t MassStore_MassStorageReset(void); uint8_t MassStore_GetMaxLUN(uint8_t* const MaxLUNIndex); uint8_t MassStore_RequestSense(const uint8_t LUNIndex, @@ -210,3 +210,4 @@ const bool PreventRemoval); #endif + diff --git a/Demos/Host/LowLevel/MassStorageHost/Lib/SCSI_Codes.h b/Demos/Host/LowLevel/MassStorageHost/Lib/SCSI_Codes.h index a69aa56fe..6bcd5780f 100644 --- a/Demos/Host/LowLevel/MassStorageHost/Lib/SCSI_Codes.h +++ b/Demos/Host/LowLevel/MassStorageHost/Lib/SCSI_Codes.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -34,7 +34,7 @@ * the SCSI standard documentation for more information on each SCSI command and * the SENSE data. */ - + #ifndef _SCSI_CODES_H_ #define _SCSI_CODES_H_ @@ -84,3 +84,4 @@ #define SCSI_ASENSEQ_OPERATION_IN_PROGRESS 0x07 #endif + diff --git a/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c b/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c index 985aeeb08..93c62e74f 100644 --- a/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c +++ b/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -124,7 +124,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } @@ -139,7 +139,7 @@ void MassStorage_Task(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -149,7 +149,7 @@ void MassStorage_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -171,7 +171,7 @@ void MassStorage_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("Mass Storage Disk Enumerated.\r\n")); USB_HostState = HOST_STATE_Configured; @@ -179,28 +179,28 @@ void MassStorage_Task(void) case HOST_STATE_Configured: /* Indicate device busy via the status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_BUSY); - + /* Send the request, display error and wait for device detach if request fails */ if ((ErrorCode = MassStore_GetMaxLUN(&MassStore_MaxLUNIndex)) != HOST_SENDCONTROL_Successful) - { + { ShowDiskReadError(PSTR("Get Max LUN"), ErrorCode); USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Print number of LUNs detected in the attached device */ printf_P(PSTR("Total LUNs: %d - Using first LUN in device.\r\n"), (MassStore_MaxLUNIndex + 1)); - + /* Reset the Mass Storage device interface, ready for use */ if ((ErrorCode = MassStore_MassStorageReset()) != HOST_SENDCONTROL_Successful) { ShowDiskReadError(PSTR("Mass Storage Reset"), ErrorCode); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Get sense data from the device - many devices will not accept any other commands until the sense data * is read - both on start-up and after a failed command */ SCSI_Request_Sense_Response_t SenseData; @@ -210,12 +210,12 @@ void MassStorage_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Set the prevent removal flag for the device, allowing it to be accessed */ if ((ErrorCode = MassStore_PreventAllowMediumRemoval(0, true)) != 0) { ShowDiskReadError(PSTR("Prevent/Allow Medium Removal"), ErrorCode); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } @@ -225,14 +225,14 @@ void MassStorage_Task(void) if ((ErrorCode = MassStore_Inquiry(0, &InquiryData)) != 0) { ShowDiskReadError(PSTR("Inquiry"), ErrorCode); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } /* Print vendor and product names of attached device */ printf_P(PSTR("Vendor \"%.8s\", Product \"%.16s\"\r\n"), InquiryData.VendorID, InquiryData.ProductID); - + /* Wait until disk ready */ puts_P(PSTR("Waiting until ready..")); @@ -246,7 +246,7 @@ void MassStorage_Task(void) /* Check to see if the attached device is ready for new commands */ ErrorCode = MassStore_TestUnitReady(0); - + /* If attached device is ready, abort the loop */ if (!(ErrorCode)) break; @@ -270,11 +270,11 @@ void MassStorage_Task(void) if ((ErrorCode = MassStore_ReadCapacity(0, &DiskCapacity)) != 0) { ShowDiskReadError(PSTR("Read Capacity"), ErrorCode); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Display the disk capacity in blocks * block size bytes */ printf_P(PSTR("%lu blocks of %lu bytes.\r\n"), DiskCapacity.Blocks, DiskCapacity.BlockSize); @@ -285,11 +285,11 @@ void MassStorage_Task(void) if ((ErrorCode = MassStore_ReadDeviceBlock(0, 0x00000000, 1, DiskCapacity.BlockSize, BlockBuffer)) != 0) { ShowDiskReadError(PSTR("Read Device Block"), ErrorCode); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("\r\nContents of first block:\r\n")); /* Print out the first block in both HEX and ASCII, 16 bytes per line */ @@ -297,30 +297,30 @@ void MassStorage_Task(void) { /* Pointer to the start of the current 16-byte chunk in the read block of data */ uint8_t* ChunkPtr = &BlockBuffer[Chunk << 4]; - + /* Print out the 16 bytes of the chunk in HEX format */ for (uint8_t ByteOffset = 0; ByteOffset < (1 << 4); ByteOffset++) { char CurrByte = *(ChunkPtr + ByteOffset); - + printf_P(PSTR("%.2X "), CurrByte); } - + puts_P(PSTR(" ")); /* Print out the 16 bytes of the chunk in ASCII format */ for (uint8_t ByteOffset = 0; ByteOffset < (1 << 4); ByteOffset++) { char CurrByte = *(ChunkPtr + ByteOffset); - + putchar(isprint(CurrByte) ? CurrByte : '.'); } - + puts_P(PSTR("\r\n")); } - + puts_P(PSTR("\r\n\r\nPress board button to read entire ASCII contents of disk...\r\n\r\n")); - + /* Wait for the board button to be pressed */ while (!(Buttons_GetStatus() & BUTTONS_BUTTON1)) { @@ -332,7 +332,7 @@ void MassStorage_Task(void) /* Abort if device removed */ if (USB_HostState == HOST_STATE_Unattached) break; - + /* Print out the entire disk contents in ASCII format */ for (uint32_t CurrBlockAddress = 0; CurrBlockAddress < DiskCapacity.Blocks; CurrBlockAddress++) { @@ -340,7 +340,7 @@ void MassStorage_Task(void) if ((ErrorCode = MassStore_ReadDeviceBlock(0, CurrBlockAddress, 1, DiskCapacity.BlockSize, BlockBuffer)) != 0) { ShowDiskReadError(PSTR("Read Device Block"), ErrorCode); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } @@ -349,7 +349,7 @@ void MassStorage_Task(void) for (uint16_t Byte = 0; Byte < DiskCapacity.BlockSize; Byte++) { char CurrByte = BlockBuffer[Byte]; - + putchar(isprint(CurrByte) ? CurrByte : '.'); } @@ -357,10 +357,10 @@ void MassStorage_Task(void) if (USB_HostState == HOST_STATE_Unattached) break; } - + /* Indicate device no longer busy */ LEDs_SetAllLEDs(LEDMASK_USB_READY); - + /* Wait until USB device disconnected */ USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -386,7 +386,7 @@ void ShowDiskReadError(char* CommandString, { /* Display the error code */ printf_P(PSTR(ESC_FG_RED "Command error (%S).\r\n"), CommandString); - printf_P(PSTR(" -- Error Code: %d" ESC_FG_WHITE), ErrorCode); + printf_P(PSTR(" -- Error Code: %d" ESC_FG_WHITE), ErrorCode); } Pipe_Freeze(); @@ -394,3 +394,4 @@ void ShowDiskReadError(char* CommandString, /* Indicate device error via the status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } + diff --git a/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.h b/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.h index 7aabe9f7d..ef937b7be 100644 --- a/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.h +++ b/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -32,7 +32,7 @@ * * Header file for MassStoreHost.c. */ - + #ifndef _MASS_STORE_HOST_H_ #define _MASS_STORE_HOST_H_ @@ -72,11 +72,11 @@ /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ #define LEDMASK_USB_BUSY LEDS_LED2 - + /* Function Prototypes: */ void MassStorage_Task(void); void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); @@ -88,3 +88,4 @@ const uint8_t ErrorCode); #endif + diff --git a/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.txt b/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.txt index 23f083dea..45d78c43b 100644 --- a/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.txt +++ b/Demos/Host/LowLevel/MassStorageHost/MassStorageHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Mass Storage Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Mass Storage Device</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>Bulk Only</td> * </tr> @@ -42,12 +42,12 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Mass Storage host demonstration application. This gives a simple reference * application for implementing a USB Mass Storage host, for USB storage devices * using the standard Mass Storage USB profile. - * + * * The first 512 bytes (boot sector) of an attached disk's memory will be dumped * out of the serial port in HEX and ASCII form when it is attached to the AT90USB1287 * AVR. The device will then wait for HWB to be pressed, whereupon the entire ASCII contents @@ -65,3 +65,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/LowLevel/MassStorageHost/makefile b/Demos/Host/LowLevel/MassStorageHost/makefile index 15db4bd67..7d8352351 100644 --- a/Demos/Host/LowLevel/MassStorageHost/makefile +++ b/Demos/Host/LowLevel/MassStorageHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -136,7 +136,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -149,7 +149,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -263,7 +263,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -276,7 +276,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -288,7 +288,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -300,7 +300,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -323,7 +323,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -357,7 +357,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -391,7 +391,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -420,7 +420,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -439,10 +439,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -507,11 +507,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -538,9 +538,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -638,14 +638,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -667,7 +667,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -711,3 +711,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c b/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c index b5d62236e..83e0c5338 100644 --- a/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Interface_t* HIDInterface = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; @@ -88,7 +88,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Skip the remainder of the loop as we have not found an endpoint yet */ continue; } - + /* Retrieve the endpoint address from the endpoint descriptor */ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t); @@ -96,12 +96,12 @@ uint8_t ProcessConfigurationDescriptor(void) if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) DataINEndpoint = EndpointData; } - + /* Configure the HID data IN pipe */ Pipe_ConfigurePipe(MOUSE_DATA_IN_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE); Pipe_SetInterruptPeriod(DataINEndpoint->PollingIntervalMS); - + /* Valid data found, return success */ return SuccessfulConfigRead; } @@ -127,7 +127,7 @@ uint8_t DComp_NextMouseInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + /* Current descriptor does not match what this comparator is looking for */ return DESCRIPTOR_SEARCH_NotFound; } @@ -162,3 +162,4 @@ uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor) /* Current descriptor does not match what this comparator is looking for */ return DESCRIPTOR_SEARCH_NotFound; } + diff --git a/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.h b/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.h index 71fbadedd..57d71e692 100644 --- a/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.h +++ b/Demos/Host/LowLevel/MouseHost/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,19 +38,19 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "MouseHost.h" - + /* Macros: */ /** Interface Class value for the Human Interface Device class. */ #define MOUSE_CLASS 0x03 /** Interface Protocol value for a Boot Protocol Mouse compliant device. */ #define MOUSE_PROTOCOL 0x02 - + /** Pipe number for the mouse data IN pipe. */ #define MOUSE_DATA_IN_PIPE 1 - + /* Enums: */ /** Enum for the possible return codes of the \ref ProcessConfigurationDescriptor() function. */ enum MouseHost_GetConfigDescriptorDataCodes_t @@ -69,3 +69,4 @@ uint8_t DComp_NextMouseInterfaceDataEndpoint(void* CurrentDescriptor); #endif + diff --git a/Demos/Host/LowLevel/MouseHost/MouseHost.c b/Demos/Host/LowLevel/MouseHost/MouseHost.c index 05efa25c5..a7bda5ae5 100644 --- a/Demos/Host/LowLevel/MouseHost/MouseHost.c +++ b/Demos/Host/LowLevel/MouseHost/MouseHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the MouseHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "MouseHost.h" /** Main program entry point. This routine configures the hardware required by the application, then @@ -64,7 +64,7 @@ void SetupHardware(void) /* Disable clock division */ clock_prescale_set(clock_div_1); - + /* Hardware Initialization */ SerialStream_Init(9600, false); LEDs_Init(); @@ -132,7 +132,7 @@ void ReadNextReport(void) uint8_t LEDMask = LEDS_NO_LEDS; /* Select mouse data pipe */ - Pipe_SelectPipe(MOUSE_DATA_IN_PIPE); + Pipe_SelectPipe(MOUSE_DATA_IN_PIPE); /* Unfreeze keyboard data pipe */ Pipe_Unfreeze(); @@ -142,10 +142,10 @@ void ReadNextReport(void) { /* No packet received (no movement), turn off LEDs */ LEDs_SetAllLEDs(LEDS_NO_LEDS); - + /* Refreeze HID data IN pipe */ Pipe_Freeze(); - + return; } @@ -153,14 +153,14 @@ void ReadNextReport(void) if (Pipe_IsReadWriteAllowed()) { /* Read in mouse report data */ - Pipe_Read_Stream_LE(&MouseReport, sizeof(MouseReport)); + Pipe_Read_Stream_LE(&MouseReport, sizeof(MouseReport)); /* Alter status LEDs according to mouse X movement */ if (MouseReport.X > 0) LEDMask |= LEDS_LED1; else if (MouseReport.X < 0) LEDMask |= LEDS_LED2; - + /* Alter status LEDs according to mouse Y movement */ if (MouseReport.Y > 0) LEDMask |= LEDS_LED3; @@ -170,9 +170,9 @@ void ReadNextReport(void) /* Alter status LEDs according to mouse button position */ if (MouseReport.Button) LEDMask = LEDS_ALL_LEDS; - + LEDs_SetAllLEDs(LEDMask); - + /* Print mouse report data through the serial port */ printf_P(PSTR("dX:%2d dY:%2d Button:%d\r\n"), MouseReport.X, MouseReport.Y, @@ -198,7 +198,7 @@ void Mouse_HID_Task(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -208,7 +208,7 @@ void Mouse_HID_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error status */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -225,12 +225,12 @@ void Mouse_HID_Task(void) /* Indicate error status */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - + /* Wait until USB device disconnected */ USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* HID class request to set the mouse protocol to the Boot Protocol */ USB_ControlRequest = (USB_Request_Header_t) { @@ -252,7 +252,7 @@ void Mouse_HID_Task(void) /* Indicate error status */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - + /* Wait until USB device disconnected */ USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; @@ -269,3 +269,4 @@ void Mouse_HID_Task(void) break; } } + diff --git a/Demos/Host/LowLevel/MouseHost/MouseHost.h b/Demos/Host/LowLevel/MouseHost/MouseHost.h index 8947436e6..dc75013f8 100644 --- a/Demos/Host/LowLevel/MouseHost/MouseHost.h +++ b/Demos/Host/LowLevel/MouseHost/MouseHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -49,9 +49,9 @@ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Board/LEDs.h> - + #include "ConfigDescriptor.h" - + /* Macros: */ /** HID Class Specific request to set the report protocol mode. */ #define REQ_SetProtocol 0x0B @@ -76,11 +76,11 @@ int8_t X; /**< Current delta X movement of the mouse */ int8_t Y; /**< Current delta Y movement on the mouse */ } USB_MouseReport_Data_t; - + /* Function Prototypes: */ void Mouse_HID_Task(void); void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); @@ -89,5 +89,6 @@ void EVENT_USB_Host_DeviceEnumerationComplete(void); void ReadNextReport(void); - + #endif + diff --git a/Demos/Host/LowLevel/MouseHost/MouseHost.txt b/Demos/Host/LowLevel/MouseHost/MouseHost.txt index be608db2f..b659abada 100644 --- a/Demos/Host/LowLevel/MouseHost/MouseHost.txt +++ b/Demos/Host/LowLevel/MouseHost/MouseHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Mouse Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Human Interface Device (HID)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -41,23 +41,23 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Mouse host demonstration application. This gives a simple reference * application for implementing a USB Mouse host, for USB mice using * the standard mouse HID profile. - * + * * Mouse movement and button presses are displayed on the board LEDs, * as well as printed out the serial terminal as formatted dY, dY and * button status information. - * + * * This uses a naive method where the mouse is set to Boot Protocol mode, so * that the report structure is fixed and known. A better implementation * uses the HID report parser for correct report data processing across * all compatible mice with advanced characteristics, as shown in the * MouseHostWithParser demo application. - * - * Currently only single interface mice are supported. + * + * Currently only single interface mice are supported. * * \section SSec_Options Project Options * @@ -71,3 +71,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/LowLevel/MouseHost/makefile b/Demos/Host/LowLevel/MouseHost/makefile index 1369db77d..d35b1da5c 100644 --- a/Demos/Host/LowLevel/MouseHost/makefile +++ b/Demos/Host/LowLevel/MouseHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -134,7 +134,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -147,7 +147,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -261,7 +261,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -274,7 +274,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -286,7 +286,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -298,7 +298,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -321,7 +321,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -355,7 +355,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -389,7 +389,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -418,7 +418,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -437,10 +437,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -505,11 +505,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -536,9 +536,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -636,14 +636,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -665,7 +665,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -709,3 +709,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c b/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c index dc8ada879..7a1a6faaa 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Interface_t* HIDInterface = NULL; USB_Descriptor_HID_t* HIDDescriptor = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; @@ -67,7 +67,7 @@ uint8_t ProcessConfigurationDescriptor(void) default: return ControlError; } - + while (!(DataINEndpoint)) { /* See if we've found a likely compatible interface, and if there is an endpoint within that interface */ @@ -82,7 +82,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Descriptor not found, error out */ return NoCompatibleInterfaceFound; } - + /* Save the interface in case we need to refer back to it later */ HIDInterface = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Interface_t); @@ -93,14 +93,14 @@ uint8_t ProcessConfigurationDescriptor(void) /* Descriptor not found, error out */ return NoCompatibleInterfaceFound; } - + /* Save the HID descriptor for later use */ - HIDDescriptor = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t); - + HIDDescriptor = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t); + /* Skip the remainder of the loop as we have not found an endpoint yet */ continue; } - + /* Retrieve the endpoint address from the endpoint descriptor */ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t); @@ -108,7 +108,7 @@ uint8_t ProcessConfigurationDescriptor(void) if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) DataINEndpoint = EndpointData; } - + /* Configure the HID data IN pipe */ Pipe_ConfigurePipe(MOUSE_DATA_IN_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE); @@ -140,7 +140,7 @@ uint8_t DComp_NextMouseInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + return DESCRIPTOR_SEARCH_NotFound; } @@ -181,5 +181,6 @@ uint8_t DComp_NextHID(void* CurrentDescriptor) if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID) return DESCRIPTOR_SEARCH_Found; else - return DESCRIPTOR_SEARCH_NotFound; + return DESCRIPTOR_SEARCH_NotFound; } + diff --git a/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.h b/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.h index b2a2e3890..504bc0b76 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.h +++ b/Demos/Host/LowLevel/MouseHostWithParser/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,16 +38,16 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "HIDReport.h" - + /* Macros: */ /** Interface Class value for the Human Interface Device class. */ #define MOUSE_CLASS 0x03 /** Interface Protocol value for a Boot Protocol Mouse compliant device. */ #define MOUSE_PROTOCOL 0x02 - + /** Descriptor header type constant for a HID descriptor. */ #define DTYPE_HID 0x21 @@ -56,7 +56,7 @@ /** Pipe number for the mouse report data pipe. */ #define MOUSE_DATA_IN_PIPE 1 - + /* Enums: */ /** Enum for the possible return codes of the \ref ProcessConfigurationDescriptor() function. */ enum MouseHostWithParser_GetConfigDescriptorDataCodes_t @@ -76,3 +76,4 @@ uint8_t DComp_NextHID(void* CurrentDescriptor); #endif + diff --git a/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.c b/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.c index 327ae45ec..18799c27f 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.c +++ b/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -46,7 +46,7 @@ uint8_t GetHIDReportData(void) { /* Create a buffer big enough to hold the entire returned HID report */ uint8_t HIDReportData[HIDReportSize]; - + USB_ControlRequest = (USB_Request_Header_t) { .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE), @@ -66,7 +66,7 @@ uint8_t GetHIDReportData(void) /* Send the HID report to the parser for processing */ if (USB_ProcessHIDReport(HIDReportData, HIDReportSize, &HIDReportInfo) != HID_PARSE_Successful) return ParseError; - + return ParseSuccessful; } @@ -100,7 +100,7 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem) /* If a collection with the mouse usage was not found, indicate that we are not interested in this item */ if (!IsMouse) return false; - + /* Check the attributes of the current mouse item - see if we are interested in it or not; * only store BUTTON and GENERIC_DESKTOP_CONTROL items into the Processed HID Report * structure to save RAM and ignore the rest @@ -108,3 +108,4 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem) return ((CurrentItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) || (CurrentItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL)); } + diff --git a/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h b/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h index bd12a39c1..19cfd753c 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h +++ b/Demos/Host/LowLevel/MouseHostWithParser/HIDReport.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -39,7 +39,7 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/Class/Host/HIDParser.h> - + #include "MouseHostWithParser.h" /* Macros: */ @@ -60,7 +60,7 @@ /** HID Report Descriptor Usage value for a Scroll Wheel movement. */ #define USAGE_SCROLL_WHEEL 0x38 - + /* Enums: */ /** Enum for the possible return codes of the \ref GetHIDReportData() function. */ enum MouseHostWithParser_GetHIDReportDataCodes_t @@ -69,16 +69,16 @@ ParseError = 1, /**< Failed to fully process the HID report descriptor */ ParseControlError = 2, /**< Control error occurred while trying to read the device HID descriptor */ }; - + /* Type Defines: */ /** Type define for a HID descriptor. */ typedef struct { USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */ - + uint16_t HIDSpec; /**< Implemented HID class specification, in BCD encoded format */ uint8_t CountryCode; /**< Country code value for localized hardware */ - + uint8_t TotalHIDDescriptors; /**< Total number of HID report descriptors in the current interface */ uint8_t HIDReportType; /**< HID report type of the first HID report descriptor */ @@ -91,7 +91,8 @@ /* Function Prototypes: */ uint8_t GetHIDReportData(void); - + bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem); - + #endif + diff --git a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c index a0240b04a..185871d4a 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c +++ b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the MouseHostWithParser demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "MouseHostWithParser.h" /** Main program entry point. This routine configures the hardware required by the application, then @@ -64,7 +64,7 @@ void SetupHardware(void) /* Disable clock division */ clock_prescale_set(clock_div_1); - + /* Hardware Initialization */ SerialStream_Init(9600, false); LEDs_Init(); @@ -119,7 +119,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } @@ -135,7 +135,7 @@ void Mouse_HID_Task(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -145,7 +145,7 @@ void Mouse_HID_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -153,7 +153,7 @@ void Mouse_HID_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */ if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful) { @@ -162,12 +162,12 @@ void Mouse_HID_Task(void) /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - + /* Wait until USB device disconnected */ USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + printf_P(PSTR("Processing HID Report (Size %d Bytes).\r\n"), HIDReportSize); /* Get and process the device's first HID report descriptor */ @@ -179,21 +179,21 @@ void Mouse_HID_Task(void) puts_P(PSTR("Not a valid Mouse." ESC_FG_WHITE)); else printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - + /* Wait until USB device disconnected */ USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + printf("Total Reports: %d\r\n", HIDReportInfo.TotalDeviceReports); for (uint8_t i = 0; i < HIDReportInfo.TotalDeviceReports; i++) { HID_ReportSizeInfo_t* CurrReportIDInfo = &HIDReportInfo.ReportIDSizes[i]; - + uint8_t ReportSizeInBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_In]; uint8_t ReportSizeOutBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Out]; uint8_t ReportSizeFeatureBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Feature]; @@ -212,9 +212,9 @@ void Mouse_HID_Task(void) break; case HOST_STATE_Configured: /* Select and unfreeze mouse data pipe */ - Pipe_SelectPipe(MOUSE_DATA_IN_PIPE); + Pipe_SelectPipe(MOUSE_DATA_IN_PIPE); Pipe_Unfreeze(); - + /* Check to see if a packet has been received */ if (Pipe_IsINReceived()) { @@ -226,11 +226,11 @@ void Mouse_HID_Task(void) /* Load in the mouse report */ Pipe_Read_Stream_LE(MouseReport, Pipe_BytesInPipe()); - + /* Process the read in mouse report from the device */ ProcessMouseReport(MouseReport); } - + /* Clear the IN endpoint, ready for next data packet */ Pipe_ClearIN(); } @@ -255,7 +255,7 @@ void ProcessMouseReport(uint8_t* MouseReport) { /* Create a temporary item pointer to the next report item */ HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber]; - + bool FoundData; if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) && @@ -263,7 +263,7 @@ void ProcessMouseReport(uint8_t* MouseReport) { /* Get the mouse button value */ FoundData = USB_GetHIDReportItemInfo(MouseReport, ReportItem); - + /* For multi-report devices - if the requested data was not in the issued report, continue */ if (!(FoundData)) continue; @@ -276,14 +276,14 @@ void ProcessMouseReport(uint8_t* MouseReport) (ReportItem->Attributes.Usage.Usage == USAGE_SCROLL_WHEEL) && (ReportItem->ItemType == HID_REPORT_ITEM_In)) { - /* Get the mouse wheel value if it is contained within the current + /* Get the mouse wheel value if it is contained within the current * report, if not, skip to the next item in the parser list */ if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem))) - continue; + continue; int16_t WheelDelta = HID_ALIGN_DATA(ReportItem, int16_t); - + if (WheelDelta) LEDMask = (LEDS_LED1 | LEDS_LED2 | ((WheelDelta > 0) ? LEDS_LED3 : LEDS_LED4)); } @@ -294,13 +294,13 @@ void ProcessMouseReport(uint8_t* MouseReport) { /* Get the mouse relative position value */ FoundData = USB_GetHIDReportItemInfo(MouseReport, ReportItem); - + /* For multi-report devices - if the requested data was not in the issued report, continue */ if (!(FoundData)) continue; - + int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t); - + /* Check to see if a (non-zero) delta movement has been indicated */ if (DeltaMovement) { @@ -312,7 +312,7 @@ void ProcessMouseReport(uint8_t* MouseReport) } } } - + /* Display the button information on the board LEDs */ LEDs_SetAllLEDs(LEDMask); -}
\ No newline at end of file +} diff --git a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.h b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.h index a51b7a25d..4e492f61c 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.h +++ b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -49,7 +49,7 @@ #include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Board/LEDs.h> #include <LUFA/Drivers/USB/USB.h> - + #include "ConfigDescriptor.h" #include "HIDReport.h" @@ -69,7 +69,7 @@ /* Function Prototypes: */ void Mouse_HID_Task(void); void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); @@ -80,3 +80,4 @@ void ProcessMouseReport(uint8_t* MouseReport); #endif + diff --git a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt index febd4a939..fdcdb6153 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt +++ b/Demos/Host/LowLevel/MouseHostWithParser/MouseHostWithParser.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Mouse Host With HID Descriptor Parser Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Human Interface Device (HID)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -41,19 +41,19 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Mouse host demonstration application. This gives a simple reference * application for implementing a USB Mouse host, for USB mice using * the standard mouse HID profile. It uses a HID parser for the HID * reports, allowing for correct operation across all USB mice. This * demo supports mice with a single HID report. - * + * * Mouse and scroll wheel movement and button presses are displayed * on the board LEDs. On connection to a USB mouse, the report items * will be processed and printed as a formatted list through the USART * before the mouse is fully enumerated. - * + * * Currently only single interface mice are supported. * * \section SSec_Options Project Options @@ -68,3 +68,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/LowLevel/MouseHostWithParser/makefile b/Demos/Host/LowLevel/MouseHostWithParser/makefile index cd1907272..9ea09fa0c 100644 --- a/Demos/Host/LowLevel/MouseHostWithParser/makefile +++ b/Demos/Host/LowLevel/MouseHostWithParser/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -135,7 +135,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -148,7 +148,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -299,7 +299,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -322,7 +322,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -419,7 +419,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -506,11 +506,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -637,14 +637,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c b/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c index 89bf488be..b269820e4 100644 --- a/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -49,7 +49,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Interface_t* PrinterInterface = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; @@ -66,7 +66,7 @@ uint8_t ProcessConfigurationDescriptor(void) default: return ControlError; } - + while (!(DataINEndpoint) || !(DataOUTEndpoint)) { /* See if we've found a likely compatible interface, and if there is an endpoint within that interface */ @@ -81,7 +81,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Descriptor not found, error out */ return NoCompatibleInterfaceFound; } - + /* Save the interface in case we need to refer back to it later */ PrinterInterface = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Interface_t); @@ -92,7 +92,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Skip the remainder of the loop as we have not found an endpoint yet */ continue; } - + /* Retrieve the endpoint address from the endpoint descriptor */ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t); @@ -102,10 +102,10 @@ uint8_t ProcessConfigurationDescriptor(void) else DataOUTEndpoint = EndpointData; } - + /* Save Printer interface details for later use */ PrinterInterfaceNumber = PrinterInterface->InterfaceNumber; - PrinterAltSetting = PrinterInterface->AlternateSetting; + PrinterAltSetting = PrinterInterface->AlternateSetting; /* Configure the Printer data IN pipe */ Pipe_ConfigurePipe(PRINTER_DATA_IN_PIPE, EP_TYPE_BULK, PIPE_TOKEN_IN, @@ -140,7 +140,7 @@ uint8_t DComp_NextBidirectionalPrinterInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + return DESCRIPTOR_SEARCH_NotFound; } @@ -171,3 +171,4 @@ uint8_t DComp_NextPrinterInterfaceBulkDataEndpoint(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } + diff --git a/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.h b/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.h index b0cd56b19..b25f3bdc7 100644 --- a/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.h +++ b/Demos/Host/LowLevel/PrinterHost/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,10 +33,10 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "PrinterHost.h" #include "Lib/PrinterCommands.h" - + /* Macros: */ /** Interface Class value for the Printer Device class. */ #define PRINTER_CLASS 0x07 @@ -63,22 +63,23 @@ InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */ NoCompatibleInterfaceFound = 4, /**< A compatible interface with the required endpoints was not found */ }; - + /* External Variables: */ /** Interface index of the Bidirectional Printer interface within the device, once the Configuration * Descriptor has been processed. */ uint8_t PrinterInterfaceNumber; - + /** Interface Alternate Setting index of the Bidirectional Printer interface within the device, once * the Configuration Descriptor has been processed. */ uint8_t PrinterAltSetting; /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); + uint8_t ProcessConfigurationDescriptor(void); uint8_t DComp_NextBidirectionalPrinterInterface(void* CurrentDescriptor); uint8_t DComp_NextPrinterInterfaceBulkDataEndpoint(void* CurrentDescriptor); #endif + diff --git a/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c b/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c index 0b75d7507..da79e03cc 100644 --- a/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c +++ b/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -51,14 +51,14 @@ uint8_t Printer_SendData(const void* const PrinterCommands, Pipe_SelectPipe(PRINTER_DATA_OUT_PIPE); Pipe_Unfreeze(); - + if ((ErrorCode = Pipe_Write_Stream_LE(PrinterCommands, CommandSize)) != PIPE_RWSTREAM_NoError) return ErrorCode; Pipe_ClearOUT(); - + Pipe_WaitUntilReady(); - + Pipe_Freeze(); return PIPE_RWSTREAM_NoError; @@ -86,33 +86,33 @@ uint8_t Printer_GetDeviceID(char* DeviceIDString, .wIndex = PrinterInterfaceNumber, .wLength = sizeof(DeviceIDStringLength), }; - + Pipe_SelectPipe(PIPE_CONTROLPIPE); if ((ErrorCode = USB_Host_SendControlRequest(&DeviceIDStringLength)) != HOST_SENDCONTROL_Successful) return ErrorCode; - + if (!(DeviceIDStringLength)) { DeviceIDString[0] = 0x00; return HOST_SENDCONTROL_Successful; } - + DeviceIDStringLength = SwapEndian_16(DeviceIDStringLength); if (DeviceIDStringLength > BufferSize) DeviceIDStringLength = BufferSize; USB_ControlRequest.wLength = DeviceIDStringLength; - + if ((ErrorCode = USB_Host_SendControlRequest(DeviceIDString)) != HOST_SENDCONTROL_Successful) return ErrorCode; - + /* Move string back two characters to remove the string length value from the start of the array */ memmove(&DeviceIDString[0], &DeviceIDString[2], DeviceIDStringLength - 2); DeviceIDString[DeviceIDStringLength - 2] = 0x00; - + return HOST_SENDCONTROL_Successful; } diff --git a/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.h b/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.h index 9cd768efa..812ff7e5a 100644 --- a/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.h +++ b/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -32,7 +32,7 @@ * * Header file for PrinterCommands.c. */ - + #ifndef _PRINTER_COMMANDS_H_ #define _PRINTER_COMMANDS_H_ @@ -41,7 +41,7 @@ #include <string.h> #include <LUFA/Drivers/USB/USB.h> - + #include "../PrinterHost.h" /* Macros: */ @@ -53,7 +53,7 @@ /** Printer class-specific request to soft-reset the device. */ #define REQ_SoftReset 2 - + /* Function Prototypes: */ uint8_t Printer_SendData(const void* const PrinterCommands, const uint16_t CommandSize); @@ -61,5 +61,6 @@ const uint16_t BufferSize); uint8_t Printer_GetPortStatus(uint8_t* const PortStatus); uint8_t Printer_SoftReset(void); - + #endif + diff --git a/Demos/Host/LowLevel/PrinterHost/PrinterHost.c b/Demos/Host/LowLevel/PrinterHost/PrinterHost.c index f12c95ef9..88a1a8c43 100644 --- a/Demos/Host/LowLevel/PrinterHost/PrinterHost.c +++ b/Demos/Host/LowLevel/PrinterHost/PrinterHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -47,7 +47,7 @@ int main(void) puts_P(PSTR(ESC_FG_CYAN "Printer Host Demo running.\r\n" ESC_FG_WHITE)); sei(); - + for (;;) { USB_Printer_Host(); @@ -134,10 +134,10 @@ void USB_Printer_Host(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); - + /* Select the control pipe for the request transfer */ - Pipe_SelectPipe(PIPE_CONTROLPIPE); - + Pipe_SelectPipe(PIPE_CONTROLPIPE); + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -147,7 +147,7 @@ void USB_Printer_Host(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n"), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -155,7 +155,7 @@ void USB_Printer_Host(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */ if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful) { @@ -169,7 +169,7 @@ void USB_Printer_Host(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Some printers use alternate settings to determine the communication protocol used - if so, send a SetInterface * request to switch to the interface alternate setting with the Bidirectional protocol */ if (PrinterAltSetting) @@ -182,7 +182,7 @@ void USB_Printer_Host(void) .wIndex = PrinterInterfaceNumber, .wLength = 0, }; - + if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) { printf_P(PSTR(ESC_FG_RED "Control Error (Set Interface).\r\n" @@ -193,12 +193,12 @@ void USB_Printer_Host(void) /* Wait until USB device disconnected */ USB_HostState = HOST_STATE_WaitForDeviceRemoval; - break; + break; } } - + puts_P(PSTR("Retrieving Device ID...\r\n")); - + char DeviceIDString[300]; if ((ErrorCode = Printer_GetDeviceID(DeviceIDString, sizeof(DeviceIDString))) != HOST_SENDCONTROL_Successful) { @@ -222,10 +222,10 @@ void USB_Printer_Host(void) case HOST_STATE_Configured: /* Indicate device busy via the status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_BUSY); - + char TestPageData[] = "\033%-12345X\033E" "LUFA PCL Test Page" "\033E\033%-12345X"; uint16_t TestPageLength = strlen(TestPageData); - + printf_P(PSTR("Sending Test Page (%d bytes)...\r\n"), TestPageLength); if ((ErrorCode = Printer_SendData(&TestPageData, TestPageLength)) != PIPE_RWSTREAM_NoError) @@ -242,7 +242,7 @@ void USB_Printer_Host(void) } puts_P(PSTR("Test Page Sent.\r\n")); - + /* Indicate device no longer busy */ LEDs_SetAllLEDs(LEDMASK_USB_READY); @@ -250,3 +250,4 @@ void USB_Printer_Host(void) break; } } + diff --git a/Demos/Host/LowLevel/PrinterHost/PrinterHost.h b/Demos/Host/LowLevel/PrinterHost/PrinterHost.h index 2ba270f7d..1825d9f17 100644 --- a/Demos/Host/LowLevel/PrinterHost/PrinterHost.h +++ b/Demos/Host/LowLevel/PrinterHost/PrinterHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -32,7 +32,7 @@ * * Header file for PrinterHost.c. */ - + #ifndef _MASS_STORE_HOST_H_ #define _MASS_STORE_HOST_H_ @@ -66,13 +66,13 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ #define LEDMASK_USB_BUSY LEDS_LED2 - + /* External Variables: */ extern uint8_t PrinterInterfaceNumber; - + /* Function Prototypes: */ void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); @@ -86,3 +86,4 @@ void USB_Printer_Host(void); #endif + diff --git a/Demos/Host/LowLevel/PrinterHost/PrinterHost.txt b/Demos/Host/LowLevel/PrinterHost/PrinterHost.txt index 92d43310b..e6b810dbc 100644 --- a/Demos/Host/LowLevel/PrinterHost/PrinterHost.txt +++ b/Demos/Host/LowLevel/PrinterHost/PrinterHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Printer Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Printer Device</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>Bidirectional Protocol</td> * </tr> @@ -38,16 +38,16 @@ * Full Speed Mode</td> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Printer host demonstration application. This gives a simple reference * application for implementing a USB Printer host, for USB printers using * the bidirectional data encapsulation protocol and PCL language. - * + * * Upon connection of a compatible printer, the printer's device ID is sent * to the AVR's serial port, and a simple test page is printed using the PCL * printer language. - * + * * \section SSec_Options Project Options * * The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. @@ -60,3 +60,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/LowLevel/PrinterHost/makefile b/Demos/Host/LowLevel/PrinterHost/makefile index b8c162522..f64184ba0 100644 --- a/Demos/Host/LowLevel/PrinterHost/makefile +++ b/Demos/Host/LowLevel/PrinterHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -135,7 +135,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -148,7 +148,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -299,7 +299,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -322,7 +322,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -419,7 +419,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -506,11 +506,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -637,14 +637,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.c b/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.c index 58e1408c1..1190d28b7 100644 --- a/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -34,7 +34,7 @@ * needed to communication with an attached USB device. Descriptors are special computer-readable structures * which the host requests upon device enumeration, to determine the device's capabilities and functions. */ - + #include "ConfigDescriptor.h" /** Reads and processes an attached device's descriptors, to determine compatibility and pipe configurations. This @@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Interface_t* RNDISControlInterface = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; @@ -85,7 +85,7 @@ uint8_t ProcessConfigurationDescriptor(void) { /* Descriptor not found, error out */ return NoCompatibleInterfaceFound; - } + } /* Clear any found endpoints */ DataINEndpoint = NULL; @@ -111,7 +111,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Skip the remainder of the loop as we have not found an endpoint yet */ continue; } - + /* Retrieve the endpoint address from the endpoint descriptor */ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t); @@ -129,7 +129,7 @@ uint8_t ProcessConfigurationDescriptor(void) DataOUTEndpoint = EndpointData; } } - + /* Configure the RNDIS data IN pipe */ Pipe_ConfigurePipe(RNDIS_DATA_IN_PIPE, EP_TYPE_BULK, PIPE_TOKEN_IN, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE); @@ -167,7 +167,7 @@ uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + return DESCRIPTOR_SEARCH_NotFound; } @@ -191,7 +191,7 @@ uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + return DESCRIPTOR_SEARCH_NotFound; } @@ -211,7 +211,7 @@ uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor) { uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK); - + if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) return DESCRIPTOR_SEARCH_Found; } @@ -222,3 +222,4 @@ uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } + diff --git a/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.h b/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.h index 834493742..b4a056f85 100644 --- a/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.h +++ b/Demos/Host/LowLevel/RNDISEthernetHost/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,9 +38,9 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "RNDISEthernetHost.h" - + /* Macros: */ /** Interface Class value for the CDC class. */ #define CDC_CONTROL_CLASS 0x02 @@ -50,7 +50,7 @@ /** Interface Class value for the CDC RNDIS vendor specific protocol. */ #define CDC_CONTROL_PROTOCOL 0xFF - + /** Interface Class value for the CDC data class. */ #define CDC_DATA_CLASS 0x0A @@ -59,7 +59,7 @@ /** Interface Class value for the CDC data protocol. */ #define CDC_DATA_PROTOCOL 0x00 - + /** Pipe number for the RNDIS data IN pipe. */ #define RNDIS_DATA_IN_PIPE 1 @@ -81,10 +81,11 @@ }; /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); - + uint8_t ProcessConfigurationDescriptor(void); + uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor); uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor); uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor); - + #endif + diff --git a/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISCommands.c b/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISCommands.c index 64cfc3ce6..661762b8b 100644 --- a/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISCommands.c +++ b/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISCommands.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -83,7 +83,7 @@ uint8_t RNDIS_GetEncapsulatedResponse(void* const Buffer, .wIndex = 0, .wLength = Length, }; - + /* Select the control pipe for the request transfer */ Pipe_SelectPipe(PIPE_CONTROLPIPE); @@ -102,7 +102,7 @@ uint8_t RNDIS_SendKeepAlive(void) RNDIS_KeepAlive_Message_t KeepAliveMessage; RNDIS_KeepAlive_Complete_t KeepAliveMessageResponse; - + KeepAliveMessage.MessageType = REMOTE_NDIS_KEEPALIVE_MSG; KeepAliveMessage.MessageLength = sizeof(RNDIS_KeepAlive_Message_t); KeepAliveMessage.RequestId = RequestID++; @@ -112,13 +112,13 @@ uint8_t RNDIS_SendKeepAlive(void) { return ErrorCode; } - + if ((ErrorCode = RNDIS_GetEncapsulatedResponse(&KeepAliveMessageResponse, sizeof(RNDIS_KeepAlive_Complete_t))) != HOST_SENDCONTROL_Successful) { return ErrorCode; } - + return HOST_SENDCONTROL_Successful; } @@ -145,13 +145,13 @@ uint8_t RNDIS_InitializeDevice(const uint16_t HostMaxPacketSize, InitMessage.MajorVersion = REMOTE_NDIS_VERSION_MAJOR; InitMessage.MinorVersion = REMOTE_NDIS_VERSION_MINOR; InitMessage.MaxTransferSize = HostMaxPacketSize; - + if ((ErrorCode = RNDIS_SendEncapsulatedCommand(&InitMessage, sizeof(RNDIS_Initialize_Message_t))) != HOST_SENDCONTROL_Successful) { return ErrorCode; } - + if ((ErrorCode = RNDIS_GetEncapsulatedResponse(&InitMessageResponse, sizeof(RNDIS_Initialize_Complete_t))) != HOST_SENDCONTROL_Successful) { @@ -160,9 +160,9 @@ uint8_t RNDIS_InitializeDevice(const uint16_t HostMaxPacketSize, if (InitMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS) return RNDIS_COMMAND_FAILED; - + *DeviceMaxPacketSize = InitMessageResponse.MaxTransferSize; - + return HOST_SENDCONTROL_Successful; } @@ -186,18 +186,18 @@ uint8_t RNDIS_SetRNDISProperty(const uint32_t Oid, RNDIS_Set_Message_t SetMessage; uint8_t ContiguousBuffer[Length]; } SetMessageData; - + RNDIS_Set_Complete_t SetMessageResponse; - + SetMessageData.SetMessage.MessageType = REMOTE_NDIS_SET_MSG; SetMessageData.SetMessage.MessageLength = sizeof(RNDIS_Set_Message_t) + Length; SetMessageData.SetMessage.RequestId = RequestID++; - + SetMessageData.SetMessage.Oid = Oid; SetMessageData.SetMessage.InformationBufferLength = Length; SetMessageData.SetMessage.InformationBufferOffset = (sizeof(RNDIS_Set_Message_t) - sizeof(RNDIS_Message_Header_t)); SetMessageData.SetMessage.DeviceVcHandle = 0; - + memcpy(&SetMessageData.ContiguousBuffer, Buffer, Length); if ((ErrorCode = RNDIS_SendEncapsulatedCommand(&SetMessageData, @@ -205,7 +205,7 @@ uint8_t RNDIS_SetRNDISProperty(const uint32_t Oid, { return ErrorCode; } - + if ((ErrorCode = RNDIS_GetEncapsulatedResponse(&SetMessageResponse, sizeof(RNDIS_Set_Complete_t))) != HOST_SENDCONTROL_Successful) { @@ -214,7 +214,7 @@ uint8_t RNDIS_SetRNDISProperty(const uint32_t Oid, if (SetMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS) return RNDIS_COMMAND_FAILED; - + return HOST_SENDCONTROL_Successful; } @@ -244,7 +244,7 @@ uint8_t RNDIS_QueryRNDISProperty(const uint32_t Oid, QueryMessage.MessageType = REMOTE_NDIS_QUERY_MSG; QueryMessage.MessageLength = sizeof(RNDIS_Query_Message_t); QueryMessage.RequestId = RequestID++; - + QueryMessage.Oid = Oid; QueryMessage.InformationBufferLength = 0; QueryMessage.InformationBufferOffset = 0; @@ -255,7 +255,7 @@ uint8_t RNDIS_QueryRNDISProperty(const uint32_t Oid, { return ErrorCode; } - + if ((ErrorCode = RNDIS_GetEncapsulatedResponse(&QueryMessageResponseData, sizeof(QueryMessageResponseData))) != HOST_SENDCONTROL_Successful) { @@ -284,7 +284,7 @@ uint8_t RNDIS_GetPacketLength(uint16_t* const PacketLength) Pipe_SelectPipe(RNDIS_DATA_IN_PIPE); Pipe_SetPipeToken(PIPE_TOKEN_IN); Pipe_Unfreeze(); - + if (!(Pipe_IsReadWriteAllowed())) { *PacketLength = 0; @@ -293,17 +293,18 @@ uint8_t RNDIS_GetPacketLength(uint16_t* const PacketLength) } RNDIS_Packet_Message_t DeviceMessage; - + if ((ErrorCode = Pipe_Read_Stream_LE(&DeviceMessage, sizeof(RNDIS_Packet_Message_t))) != PIPE_RWSTREAM_NoError) { return ErrorCode; } *PacketLength = (uint16_t)DeviceMessage.DataLength; - + Pipe_Discard_Stream(DeviceMessage.DataOffset - (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t))); - + Pipe_Freeze(); - + return PIPE_RWSTREAM_NoError; } + diff --git a/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISCommands.h b/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISCommands.h index 56b4946e6..f474c9bd8 100644 --- a/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISCommands.h +++ b/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISCommands.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -40,9 +40,9 @@ #include <avr/io.h> #include <stdio.h> #include <string.h> - + #include <LUFA/Drivers/USB/USB.h> - + #include "RNDISConstants.h" #include "../RNDISEthernetHost.h" @@ -69,19 +69,19 @@ uint32_t VcHandle; uint32_t Reserved; } RNDIS_Packet_Message_t; - + /** Type define for a RNDIS Initialize command message. */ typedef struct { uint32_t MessageType; uint32_t MessageLength; uint32_t RequestId; - + uint32_t MajorVersion; uint32_t MinorVersion; uint32_t MaxTransferSize; } RNDIS_Initialize_Message_t; - + /** Type define for a RNDIS Initialize complete response message. */ typedef struct { @@ -89,7 +89,7 @@ uint32_t MessageLength; uint32_t RequestId; uint32_t Status; - + uint32_t MajorVersion; uint32_t MinorVersion; uint32_t DeviceFlags; @@ -100,7 +100,7 @@ uint32_t AFListOffset; uint32_t AFListSize; } RNDIS_Initialize_Complete_t; - + /** Type define for a RNDIS Keep-alive command message. */ typedef struct { @@ -127,14 +127,14 @@ uint32_t AddressingReset; } RNDIS_Reset_Complete_t; - + /** Type define for a RNDIS Set command message. */ typedef struct { uint32_t MessageType; uint32_t MessageLength; uint32_t RequestId; - + uint32_t Oid; uint32_t InformationBufferLength; uint32_t InformationBufferOffset; @@ -149,20 +149,20 @@ uint32_t RequestId; uint32_t Status; } RNDIS_Set_Complete_t; - + /** Type define for a RNDIS Query command message. */ typedef struct { uint32_t MessageType; uint32_t MessageLength; uint32_t RequestId; - + uint32_t Oid; uint32_t InformationBufferLength; uint32_t InformationBufferOffset; uint32_t DeviceVcHandle; } RNDIS_Query_Message_t; - + /** Type define for a RNDIS Query complete response message. */ typedef struct { @@ -170,7 +170,7 @@ uint32_t MessageLength; uint32_t RequestId; uint32_t Status; - + uint32_t InformationBufferLength; uint32_t InformationBufferOffset; } RNDIS_Query_Complete_t; @@ -187,7 +187,7 @@ /** Implemented RNDIS Version Minor. */ #define REMOTE_NDIS_VERSION_MINOR 0x00 - + /** Additional error code for RNDIS functions when a device returns a logical command failure. */ #define RNDIS_COMMAND_FAILED 0xC0 @@ -209,3 +209,4 @@ uint8_t RNDIS_GetPacketLength(uint16_t* const PacketLength); #endif + diff --git a/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISConstants.h b/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISConstants.h index efe22b699..273fdb81e 100644 --- a/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISConstants.h +++ b/Demos/Host/LowLevel/RNDISEthernetHost/Lib/RNDISConstants.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * RNDIS specification related constants. For more information on these * constants, please refer to the Microsoft RNDIS specification. */ - + #ifndef _RNDIS_CONSTANTS_DEVICE_H_ #define _RNDIS_CONSTANTS_DEVICE_H_ @@ -52,19 +52,19 @@ #define REMOTE_NDIS_SET_CMPLT 0x80000005UL #define REMOTE_NDIS_RESET_CMPLT 0x80000006UL #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008UL - + #define REMOTE_NDIS_STATUS_SUCCESS 0x00000000UL #define REMOTE_NDIS_STATUS_FAILURE 0xC0000001UL #define REMOTE_NDIS_STATUS_INVALID_DATA 0xC0010015UL #define REMOTE_NDIS_STATUS_NOT_SUPPORTED 0xC00000BBUL #define REMOTE_NDIS_STATUS_MEDIA_CONNECT 0x4001000BUL #define REMOTE_NDIS_STATUS_MEDIA_DISCONNECT 0x4001000CUL - + #define REMOTE_NDIS_MEDIA_STATE_CONNECTED 0x00000000UL #define REMOTE_NDIS_MEDIA_STATE_DISCONNECTED 0x00000001UL - + #define REMOTE_NDIS_MEDIUM_802_3 0x00000000UL - + #define REMOTE_NDIS_DF_CONNECTIONLESS 0x00000001UL #define REMOTE_NDIS_DF_CONNECTION_ORIENTED 0x00000002UL @@ -79,8 +79,8 @@ #define REMOTE_NDIS_PACKET_GROUP 0x00001000UL #define REMOTE_NDIS_PACKET_ALL_FUNCTIONAL 0x00002000UL #define REMOTE_NDIS_PACKET_FUNCTIONAL 0x00004000UL - #define REMOTE_NDIS_PACKET_MAC_FRAME 0x00008000UL - + #define REMOTE_NDIS_PACKET_MAC_FRAME 0x00008000UL + #define OID_GEN_SUPPORTED_LIST 0x00010101UL #define OID_GEN_HARDWARE_STATUS 0x00010102UL #define OID_GEN_MEDIA_SUPPORTED 0x00010103UL @@ -110,3 +110,4 @@ #define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103UL #endif + diff --git a/Demos/Host/LowLevel/RNDISEthernetHost/RNDISEthernetHost.c b/Demos/Host/LowLevel/RNDISEthernetHost/RNDISEthernetHost.c index 1da5b4dbf..302eddb66 100644 --- a/Demos/Host/LowLevel/RNDISEthernetHost/RNDISEthernetHost.c +++ b/Demos/Host/LowLevel/RNDISEthernetHost/RNDISEthernetHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the RNDISEthernetHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "RNDISEthernetHost.h" /** Main program entry point. This routine configures the hardware required by the application, then @@ -119,7 +119,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } @@ -133,13 +133,13 @@ void PrintIncomingPackets(void) if ((ErrorCode = RNDIS_GetPacketLength(&PacketLength)) != HOST_SENDCONTROL_Successful) { printf_P(PSTR(ESC_FG_RED "Packet Reception Error.\r\n" - " -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); + " -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); return; } - + if (!(PacketLength)) return; - + Pipe_Unfreeze(); printf_P(PSTR("***PACKET (Size %d)***\r\n"), PacketLength); @@ -152,13 +152,13 @@ void PrintIncomingPackets(void) else { uint8_t PacketBuffer[PacketLength]; - + Pipe_Read_Stream_LE(&PacketBuffer, PacketLength); - + for (uint16_t i = 0; i < PacketLength; i++) printf("0x%02x ", PacketBuffer[i]); } - + Pipe_ClearIN(); Pipe_Freeze(); @@ -178,7 +178,7 @@ void RNDIS_Host_Task(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -188,7 +188,7 @@ void RNDIS_Host_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -196,7 +196,7 @@ void RNDIS_Host_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */ if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful) { @@ -210,7 +210,7 @@ void RNDIS_Host_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + uint16_t DeviceMaxPacketSize; if ((ErrorCode = RNDIS_InitializeDevice(1024, &DeviceMaxPacketSize)) != HOST_SENDCONTROL_Successful) { @@ -222,11 +222,11 @@ void RNDIS_Host_Task(void) /* Wait until USB device disconnected */ USB_HostState = HOST_STATE_WaitForDeviceRemoval; - break; + break; } - + printf_P(PSTR("Device Max Transfer Size: %lu bytes.\r\n"), DeviceMaxPacketSize); - + /* We set the default filter to only receive packets we would be interested in */ uint32_t PacketFilter = (REMOTE_NDIS_PACKET_DIRECTED | REMOTE_NDIS_PACKET_BROADCAST | REMOTE_NDIS_PACKET_ALL_MULTICAST); if ((ErrorCode = RNDIS_SetRNDISProperty(OID_GEN_CURRENT_PACKET_FILTER, @@ -242,7 +242,7 @@ void RNDIS_Host_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + uint32_t VendorID; if ((ErrorCode = RNDIS_QueryRNDISProperty(OID_GEN_VENDOR_ID, &VendorID, sizeof(VendorID))) != HOST_SENDCONTROL_Successful) @@ -257,16 +257,16 @@ void RNDIS_Host_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + printf_P(PSTR("Device Vendor ID: 0x%08lX\r\n"), VendorID); - + puts_P(PSTR("RNDIS Device Enumerated.\r\n")); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: PrintIncomingPackets(); - + break; } } diff --git a/Demos/Host/LowLevel/RNDISEthernetHost/RNDISEthernetHost.h b/Demos/Host/LowLevel/RNDISEthernetHost/RNDISEthernetHost.h index 08187f9fa..c52fe6b9c 100644 --- a/Demos/Host/LowLevel/RNDISEthernetHost/RNDISEthernetHost.h +++ b/Demos/Host/LowLevel/RNDISEthernetHost/RNDISEthernetHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -49,11 +49,11 @@ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Board/LEDs.h> - + #include "Lib/RNDISCommands.h" #include "ConfigDescriptor.h" - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -66,7 +66,7 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ #define LEDMASK_USB_BUSY LEDS_LED2 @@ -87,12 +87,13 @@ void SetupHardware(void); void PrintIncomingPackets(void); void RNDIS_Host_Task(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + #endif + diff --git a/Demos/Host/LowLevel/RNDISEthernetHost/RNDISHost.txt b/Demos/Host/LowLevel/RNDISEthernetHost/RNDISHost.txt index 9fec00bec..a989bc51a 100644 --- a/Demos/Host/LowLevel/RNDISEthernetHost/RNDISHost.txt +++ b/Demos/Host/LowLevel/RNDISEthernetHost/RNDISHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage RNDIS Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Communications Device Class (CDC)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>Remote NDIS (Microsoft Proprietary CDC Class Networking Standard)</td> * </tr> @@ -39,12 +39,12 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * RNDIS host demonstration application. This gives a simple reference * application for implementing a RNDIS Ethernet host, for USB devices such as * modems. - * + * * This demo will enumerate an attached USB RNDIS device, print out its vendor ID * and any received packets in raw form through the serial USART. * @@ -60,3 +60,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/LowLevel/RNDISEthernetHost/makefile b/Demos/Host/LowLevel/RNDISEthernetHost/makefile index b2faa5be5..d9821c6db 100644 --- a/Demos/Host/LowLevel/RNDISEthernetHost/makefile +++ b/Demos/Host/LowLevel/RNDISEthernetHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -135,7 +135,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -148,7 +148,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -299,7 +299,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -322,7 +322,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -419,7 +419,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -506,11 +506,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -637,14 +637,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c b/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c index d11dee038..2a00a7361 100644 --- a/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Interface_t* StillImageInterface = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; @@ -113,7 +113,7 @@ uint8_t ProcessConfigurationDescriptor(void) DataOUTEndpoint = EndpointData; } } - + /* Configure the Still Image data IN pipe */ Pipe_ConfigurePipe(SIMAGE_DATA_IN_PIPE, EP_TYPE_BULK, PIPE_TOKEN_IN, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE); @@ -151,7 +151,7 @@ uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + return DESCRIPTOR_SEARCH_NotFound; } @@ -170,7 +170,7 @@ uint8_t DComp_NextStillImageInterfaceDataEndpoint(void* CurrentDescriptor) { uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK); - + if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) return DESCRIPTOR_SEARCH_Found; } @@ -181,3 +181,4 @@ uint8_t DComp_NextStillImageInterfaceDataEndpoint(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } + diff --git a/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.h b/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.h index 929d658cd..bd31c6bf2 100644 --- a/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.h +++ b/Demos/Host/LowLevel/StillImageHost/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,9 +38,9 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "StillImageHost.h" - + /* Macros: */ /** Interface Class value for the Still Image Device class. */ #define SIMAGE_CLASS 0x06 @@ -50,7 +50,7 @@ /** Interface Class value for the Still Image Device protocol. */ #define SIMAGE_PROTOCOL 0x01 - + /** Pipe number of the Still Image data IN pipe. */ #define SIMAGE_DATA_IN_PIPE 1 @@ -70,7 +70,7 @@ InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */ NoCompatibleInterfaceFound = 4, /**< A compatible interface with the required endpoints was not found */ }; - + /* Function Prototypes: */ uint8_t ProcessConfigurationDescriptor(void); @@ -78,3 +78,4 @@ uint8_t DComp_NextStillImageInterfaceDataEndpoint(void* CurrentDescriptor); #endif + diff --git a/Demos/Host/LowLevel/StillImageHost/Lib/PIMACodes.h b/Demos/Host/LowLevel/StillImageHost/Lib/PIMACodes.h index 7bd8d4fe8..692b1fae8 100644 --- a/Demos/Host/LowLevel/StillImageHost/Lib/PIMACodes.h +++ b/Demos/Host/LowLevel/StillImageHost/Lib/PIMACodes.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -40,7 +40,7 @@ #define PIMA_OPERATION_GETDEVICEINFO 0x1001 #define PIMA_OPERATION_OPENSESSION 0x1002 #define PIMA_OPERATION_CLOSESESSION 0x1003 - + #define PIMA_RESPONSE_OK 0x2001 #define PIMA_RESPONSE_GENERALERROR 0x2002 #define PIMA_RESPONSE_SESSIONNOTOPEN 0x2003 @@ -49,3 +49,4 @@ #define PIMA_RESPONSE_PARAMETERNOTSUPPORTED 0x2006 #endif + diff --git a/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c b/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c index 861f55b5d..9d6828e32 100644 --- a/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c +++ b/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -56,7 +56,7 @@ void SImage_SendBlockHeader(void) /* Write the PIMA block to the data OUT pipe */ Pipe_Write_Stream_LE(&PIMA_SendBlock, PIMA_COMMAND_SIZE(0)); - + /* If the block type is a command, send its parameters (if any) */ if (PIMA_SendBlock.Type == CType_CommandBlock) { @@ -69,11 +69,11 @@ void SImage_SendBlockHeader(void) /* Write the PIMA parameters to the data OUT pipe */ Pipe_Write_Stream_LE(&PIMA_SendBlock.Params, ParamBytes); } - + /* Send the PIMA command block to the attached device */ Pipe_ClearOUT(); } - + /* Freeze pipe after use */ Pipe_Freeze(); } @@ -89,16 +89,16 @@ uint8_t SImage_ReceiveEventHeader(void) /* Unfreeze the events pipe */ Pipe_SelectPipe(SIMAGE_EVENTS_PIPE); Pipe_Unfreeze(); - + /* Read in the event data into the global structure */ ErrorCode = Pipe_Read_Stream_LE(&PIMA_EventBlock, sizeof(PIMA_EventBlock)); - + /* Clear the pipe after read complete to prepare for next event */ Pipe_ClearIN(); - + /* Freeze the event pipe again after use */ Pipe_Freeze(); - + return ErrorCode; } @@ -114,7 +114,7 @@ uint8_t SImage_ReceiveBlockHeader(void) /* Unfreeze the data IN pipe */ Pipe_SelectPipe(SIMAGE_DATA_IN_PIPE); Pipe_Unfreeze(); - + /* Wait until data received on the IN pipe */ while (!(Pipe_IsINReceived())) { @@ -131,7 +131,7 @@ uint8_t SImage_ReceiveBlockHeader(void) if (!(TimeoutMSRem)) return PIPE_RWSTREAM_Timeout; } - + Pipe_Freeze(); Pipe_SelectPipe(SIMAGE_DATA_OUT_PIPE); Pipe_Unfreeze(); @@ -159,15 +159,15 @@ uint8_t SImage_ReceiveBlockHeader(void) /* Return error code */ return PIPE_RWSTREAM_PipeStalled; } - + /* Check to see if the device was disconnected, if so exit function */ if (USB_HostState == HOST_STATE_Unattached) return PIPE_RWSTREAM_DeviceDisconnected; } - + /* Load in the response from the attached device */ Pipe_Read_Stream_LE(&PIMA_ReceivedBlock, PIMA_COMMAND_SIZE(0)); - + /* Check if the returned block type is a response block */ if (PIMA_ReceivedBlock.Type == CType_ResponseBlock) { @@ -180,14 +180,14 @@ uint8_t SImage_ReceiveBlockHeader(void) /* Read the PIMA parameters from the data IN pipe */ Pipe_Read_Stream_LE(&PIMA_ReceivedBlock.Params, ParamBytes); } - + /* Clear pipe bank after use */ Pipe_ClearIN(); } - + /* Freeze the IN pipe after use */ Pipe_Freeze(); - + return PIPE_RWSTREAM_NoError; } @@ -206,7 +206,7 @@ uint8_t SImage_SendData(void* const Buffer, /* Unfreeze the data OUT pipe */ Pipe_SelectPipe(SIMAGE_DATA_OUT_PIPE); Pipe_Unfreeze(); - + /* Write the data contents to the pipe */ ErrorCode = Pipe_Write_Stream_LE(Buffer, Bytes); @@ -215,7 +215,7 @@ uint8_t SImage_SendData(void* const Buffer, /* Freeze the pipe again after use */ Pipe_Freeze(); - + return ErrorCode; } @@ -240,7 +240,7 @@ uint8_t SImage_ReadData(void* const Buffer, /* Freeze the pipe again after use */ Pipe_Freeze(); - + return ErrorCode; } @@ -255,13 +255,14 @@ bool SImage_IsEventReceived(void) /* Unfreeze the Event pipe */ Pipe_SelectPipe(SIMAGE_EVENTS_PIPE); Pipe_Unfreeze(); - + /* If the pipe contains data, an event has been received */ if (Pipe_BytesInPipe()) IsEventReceived = true; - + /* Freeze the pipe after use */ Pipe_Freeze(); - + return IsEventReceived; } + diff --git a/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.h b/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.h index f2bb18953..2ab36c2ba 100644 --- a/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.h +++ b/Demos/Host/LowLevel/StillImageHost/Lib/StillImageCommands.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -32,17 +32,17 @@ * * Header file for StillImageCommands.c. */ - + #ifndef _STILL_IMAGE_COMMANDS_H_ #define _STILL_IMAGE_COMMANDS_H_ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "PIMACodes.h" #include "../StillImageHost.h" - /* Macros: */ + /* Macros: */ /** Length in bytes of a given Unicode string's character length. * * \param[in] chars Total number of Unicode characters in the string @@ -51,7 +51,7 @@ /** Timeout period between the issuing of a command to a device, and the reception of the first packet. */ #define COMMAND_DATA_TIMEOUT_MS 10000 - + /** Used in the DataLength field of a PIMA container, to give the total container size in bytes for * a command container. * @@ -79,7 +79,7 @@ uint32_t TransactionID; /**< Unique container ID to link blocks together */ uint32_t Params[3]; /**< Block parameters to be issued along with the block code (command blocks only) */ } PIMA_Container_t; - + /* Enums: */ /** Enum for the possible PIMA contains types. */ enum PIMA_Container_Types_t @@ -90,12 +90,12 @@ CType_ResponseBlock = 3, /**< Response container type */ CType_EventBlock = 4, /**< Event Block container type */ }; - + /* External Variables: */ extern PIMA_Container_t PIMA_SendBlock; extern PIMA_Container_t PIMA_ReceivedBlock; extern PIMA_Container_t PIMA_EventBlock; - + /* Function Prototypes: */ void SImage_SendBlockHeader(void); uint8_t SImage_ReceiveBlockHeader(void); @@ -107,3 +107,4 @@ bool SImage_IsEventReceived(void); #endif + diff --git a/Demos/Host/LowLevel/StillImageHost/StillImageHost.c b/Demos/Host/LowLevel/StillImageHost/StillImageHost.c index 73f0c2c76..aa139e225 100644 --- a/Demos/Host/LowLevel/StillImageHost/StillImageHost.c +++ b/Demos/Host/LowLevel/StillImageHost/StillImageHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -120,7 +120,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } @@ -135,7 +135,7 @@ void StillImage_Task(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -145,7 +145,7 @@ void StillImage_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -167,16 +167,16 @@ void StillImage_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("Still Image Device Enumerated.\r\n")); USB_HostState = HOST_STATE_Configured; break; case HOST_STATE_Configured: /* Indicate device busy via the status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_BUSY); - + puts_P(PSTR("Retrieving Device Info...\r\n")); - + PIMA_SendBlock = (PIMA_Container_t) { .DataLength = PIMA_COMMAND_SIZE(0), @@ -185,34 +185,34 @@ void StillImage_Task(void) .TransactionID = 0x00000000, .Params = {}, }; - + /* Send the GETDEVICEINFO block */ SImage_SendBlockHeader(); - + /* Receive the response data block */ if ((ErrorCode = SImage_ReceiveBlockHeader()) != PIPE_RWSTREAM_NoError) { ShowCommandError(ErrorCode, false); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Calculate the size of the returned device info data structure */ uint16_t DeviceInfoSize = (PIMA_ReceivedBlock.DataLength - PIMA_COMMAND_SIZE(0)); - + /* Create a buffer large enough to hold the entire device info */ uint8_t DeviceInfo[DeviceInfoSize]; /* Read in the data block data (containing device info) */ SImage_ReadData(DeviceInfo, DeviceInfoSize); - + /* Once all the data has been read, the pipe must be cleared before the response can be sent */ Pipe_ClearIN(); - + /* Create a pointer for walking through the info dataset */ uint8_t* DeviceInfoPos = DeviceInfo; - + /* Skip over the data before the unicode device information strings */ DeviceInfoPos += 8; // Skip to VendorExtensionDesc String DeviceInfoPos += (1 + UNICODE_STRING_LENGTH(*DeviceInfoPos)); // Skip over VendorExtensionDesc String @@ -222,7 +222,7 @@ void StillImage_Task(void) DeviceInfoPos += (4 + (*(uint32_t*)DeviceInfoPos << 1)); // Skip over Supported Device Properties Array DeviceInfoPos += (4 + (*(uint32_t*)DeviceInfoPos << 1)); // Skip over Capture Formats Array DeviceInfoPos += (4 + (*(uint32_t*)DeviceInfoPos << 1)); // Skip over Image Formats Array - + /* Extract and convert the Manufacturer Unicode string to ASCII and print it through the USART */ char Manufacturer[*DeviceInfoPos]; UnicodeToASCII(DeviceInfoPos, Manufacturer); @@ -246,22 +246,22 @@ void StillImage_Task(void) if ((ErrorCode = SImage_ReceiveBlockHeader()) != PIPE_RWSTREAM_NoError) { ShowCommandError(ErrorCode, false); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Verify that the command completed successfully */ if ((PIMA_ReceivedBlock.Type != CType_ResponseBlock) || (PIMA_ReceivedBlock.Code != PIMA_RESPONSE_OK)) { ShowCommandError(PIMA_ReceivedBlock.Code, true); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + puts_P(PSTR("Opening Session...\r\n")); - + PIMA_SendBlock = (PIMA_Container_t) { .DataLength = PIMA_COMMAND_SIZE(1), @@ -270,24 +270,24 @@ void StillImage_Task(void) .TransactionID = 0x00000000, .Params = {0x00000001}, }; - + /* Send the OPENSESSION block, open a session with an ID of 0x0001 */ SImage_SendBlockHeader(); - + /* Receive the response block from the device */ if ((ErrorCode = SImage_ReceiveBlockHeader()) != PIPE_RWSTREAM_NoError) { ShowCommandError(ErrorCode, false); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Verify that the command completed successfully */ if ((PIMA_ReceivedBlock.Type != CType_ResponseBlock) || (PIMA_ReceivedBlock.Code != PIMA_RESPONSE_OK)) { ShowCommandError(PIMA_ReceivedBlock.Code, true); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } @@ -302,15 +302,15 @@ void StillImage_Task(void) .TransactionID = 0x00000001, .Params = {0x00000001}, }; - + /* Send the CLOSESESSION block, close the session with an ID of 0x0001 */ SImage_SendBlockHeader(); - + /* Receive the response block from the device */ if ((ErrorCode = SImage_ReceiveBlockHeader()) != PIPE_RWSTREAM_NoError) { ShowCommandError(ErrorCode, false); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } @@ -319,7 +319,7 @@ void StillImage_Task(void) if ((PIMA_ReceivedBlock.Type != CType_ResponseBlock) || (PIMA_ReceivedBlock.Code != PIMA_RESPONSE_OK)) { ShowCommandError(PIMA_ReceivedBlock.Code, true); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } @@ -328,7 +328,7 @@ void StillImage_Task(void) /* Indicate device no longer busy */ LEDs_SetAllLEDs(LEDMASK_USB_READY); - + USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } @@ -345,17 +345,17 @@ void UnicodeToASCII(uint8_t* UnicodeString, { /* Get the number of characters in the string, skip to the start of the string data */ uint8_t CharactersRemaining = *(UnicodeString++); - + /* Loop through the entire unicode string */ while (CharactersRemaining--) { /* Load in the next unicode character (only the lower byte, as only Unicode coded ASCII is supported) */ *(Buffer++) = *UnicodeString; - + /* Jump to the next unicode character */ UnicodeString += 2; } - + /* Null terminate the string */ *Buffer = 0; } @@ -372,7 +372,8 @@ void ShowCommandError(uint8_t ErrorCode, printf_P(PSTR(ESC_FG_RED "Command Error (%S).\r\n" " -- Error Code %d\r\n" ESC_FG_WHITE), FailureType, ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } + diff --git a/Demos/Host/LowLevel/StillImageHost/StillImageHost.h b/Demos/Host/LowLevel/StillImageHost/StillImageHost.h index 61e5eb5b5..9c88f71f0 100644 --- a/Demos/Host/LowLevel/StillImageHost/StillImageHost.h +++ b/Demos/Host/LowLevel/StillImageHost/StillImageHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -42,7 +42,7 @@ #include <avr/power.h> #include <avr/interrupt.h> #include <stdio.h> - + #include "ConfigDescriptor.h" #include "Lib/PIMACodes.h" @@ -52,7 +52,7 @@ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Board/LEDs.h> - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -68,11 +68,11 @@ /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ #define LEDMASK_USB_BUSY LEDS_LED2 - + /* Function Prototypes: */ void StillImage_Task(void); void SetupHardware(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); @@ -84,5 +84,6 @@ char* Buffer); void ShowCommandError(uint8_t ErrorCode, bool ResponseCodeError); - + #endif + diff --git a/Demos/Host/LowLevel/StillImageHost/StillImageHost.txt b/Demos/Host/LowLevel/StillImageHost/StillImageHost.txt index 95a2e14b5..2dc3b662b 100644 --- a/Demos/Host/LowLevel/StillImageHost/StillImageHost.txt +++ b/Demos/Host/LowLevel/StillImageHost/StillImageHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage Still Image Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Still Image Device</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>N/A</td> * </tr> @@ -40,12 +40,12 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * Still Image host demonstration application. This gives a simple reference * application for implementing a Still Image host, for USB devices such as * digital cameras. - * + * * This demo will enumerate an attached USB Still Image device, print out its * information structure, open a session with the device and finally close the * session. @@ -62,3 +62,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/LowLevel/StillImageHost/makefile b/Demos/Host/LowLevel/StillImageHost/makefile index 087802248..2947de859 100644 --- a/Demos/Host/LowLevel/StillImageHost/makefile +++ b/Demos/Host/LowLevel/StillImageHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -135,7 +135,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -148,7 +148,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -299,7 +299,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -322,7 +322,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -419,7 +419,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -506,11 +506,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -637,14 +637,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.c b/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.c index 7d9fb38c0..54eb99c84 100644 --- a/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.c +++ b/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -34,7 +34,7 @@ * needed to communication with an attached USB device. Descriptors are special computer-readable structures * which the host requests upon device enumeration, to determine the device's capabilities and functions. */ - + #include "ConfigDescriptor.h" /** Reads and processes an attached device's descriptors, to determine compatibility and pipe configurations. This @@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void) uint8_t ConfigDescriptorData[512]; void* CurrConfigLocation = ConfigDescriptorData; uint16_t CurrConfigBytesRem; - + USB_Descriptor_Interface_t* CDCControlInterface = NULL; USB_Descriptor_Endpoint_t* DataINEndpoint = NULL; USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL; @@ -85,7 +85,7 @@ uint8_t ProcessConfigurationDescriptor(void) { /* Descriptor not found, error out */ return NoCompatibleInterfaceFound; - } + } /* Clear any found endpoints */ DataINEndpoint = NULL; @@ -111,7 +111,7 @@ uint8_t ProcessConfigurationDescriptor(void) /* Skip the remainder of the loop as we have not found an endpoint yet */ continue; } - + /* Retrieve the endpoint address from the endpoint descriptor */ USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t); @@ -129,7 +129,7 @@ uint8_t ProcessConfigurationDescriptor(void) DataOUTEndpoint = EndpointData; } } - + /* Configure the CDC data IN pipe */ Pipe_ConfigurePipe(CDC_DATA_IN_PIPE, EP_TYPE_BULK, PIPE_TOKEN_IN, DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE); @@ -167,7 +167,7 @@ uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + return DESCRIPTOR_SEARCH_NotFound; } @@ -191,7 +191,7 @@ uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_Found; } } - + return DESCRIPTOR_SEARCH_NotFound; } @@ -211,7 +211,7 @@ uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor) { uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK); - + if ((EndpointType == EP_TYPE_BULK) || (EndpointType == EP_TYPE_INTERRUPT)) return DESCRIPTOR_SEARCH_Found; } @@ -222,3 +222,4 @@ uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor) return DESCRIPTOR_SEARCH_NotFound; } + diff --git a/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.h b/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.h index 2e4730c55..270e130ae 100644 --- a/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.h +++ b/Demos/Host/LowLevel/VirtualSerialHost/ConfigDescriptor.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -38,9 +38,9 @@ /* Includes: */ #include <LUFA/Drivers/USB/USB.h> - + #include "VirtualSerialHost.h" - + /* Macros: */ /** Interface Class value for the CDC class. */ #define CDC_CONTROL_CLASS 0x02 @@ -50,7 +50,7 @@ /** Interface Class value for the CDC protocol. */ #define CDC_CONTROL_PROTOCOL 0x01 - + /** Interface Class value for the CDC data class. */ #define CDC_DATA_CLASS 0x0A @@ -59,7 +59,7 @@ /** Interface Class value for the CDC data protocol. */ #define CDC_DATA_PROTOCOL 0x00 - + /** Pipe number for the CDC data IN pipe. */ #define CDC_DATA_IN_PIPE 1 @@ -81,10 +81,11 @@ }; /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); - + uint8_t ProcessConfigurationDescriptor(void); + uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor); uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor); uint8_t DComp_NextCDCDataInterfaceEndpoint(void* CurrentDescriptor); - + #endif + diff --git a/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.c b/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.c index 91775b7a4..f5fcdb10b 100644 --- a/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.c +++ b/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.c @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -33,7 +33,7 @@ * Main source file for the VirtualSerialHost demo. This file contains the main tasks of * the demo and is responsible for the initial application hardware configuration. */ - + #include "VirtualSerialHost.h" /** Main program entry point. This routine configures the hardware required by the application, then @@ -119,7 +119,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, " -- Error Code %d\r\n" " -- Sub Error Code %d\r\n" " -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState); - + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); } @@ -134,7 +134,7 @@ void CDC_Host_Task(void) { case HOST_STATE_Addressed: puts_P(PSTR("Getting Config Data.\r\n")); - + /* Get and process the configuration descriptor data */ if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead) { @@ -144,7 +144,7 @@ void CDC_Host_Task(void) puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n")); printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode); - + /* Indicate error via status LEDs */ LEDs_SetAllLEDs(LEDMASK_USB_ERROR); @@ -152,7 +152,7 @@ void CDC_Host_Task(void) USB_HostState = HOST_STATE_WaitForDeviceRemoval; break; } - + /* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */ if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful) { @@ -188,10 +188,10 @@ void CDC_Host_Task(void) /* Get the length of the pipe data, and create a new buffer to hold it */ uint16_t BufferLength = Pipe_BytesInPipe(); uint8_t Buffer[BufferLength]; - + /* Read in the pipe data to the temporary buffer */ Pipe_Read_Stream_LE(Buffer, BufferLength); - + /* Print out the buffer contents to the USART */ for (uint16_t BufferByte = 0; BufferByte < BufferLength; BufferByte++) putchar(Buffer[BufferByte]); @@ -207,17 +207,18 @@ void CDC_Host_Task(void) /* Select and unfreeze the notification pipe */ Pipe_SelectPipe(CDC_NOTIFICATION_PIPE); Pipe_Unfreeze(); - + /* Check if a packet has been received */ if (Pipe_IsINReceived()) { /* Discard the unused event notification */ Pipe_ClearIN(); } - + /* Freeze notification IN pipe after use */ Pipe_Freeze(); - + break; } } + diff --git a/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.h b/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.h index d55fa68af..fb3b3f187 100644 --- a/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.h +++ b/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.h @@ -1,7 +1,7 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ @@ -9,13 +9,13 @@ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -49,9 +49,9 @@ #include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/Peripheral/SerialStream.h> #include <LUFA/Drivers/Board/LEDs.h> - + #include "ConfigDescriptor.h" - + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -64,16 +64,17 @@ /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - + /* Function Prototypes: */ void SetupHardware(void); void CDC_Host_Task(void); - + void EVENT_USB_Host_HostError(const uint8_t ErrorCode); void EVENT_USB_Host_DeviceAttached(void); void EVENT_USB_Host_DeviceUnattached(void); void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8_t SubErrorCode); void EVENT_USB_Host_DeviceEnumerationComplete(void); - + #endif + diff --git a/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.txt b/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.txt index d771b7976..80a470818 100644 --- a/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.txt +++ b/Demos/Host/LowLevel/VirtualSerialHost/VirtualSerialHost.txt @@ -3,7 +3,7 @@ * This file contains special DoxyGen information for the generation of the main page and other special * documentation pages. It is not a project source file. */ - + /** \mainpage CDC Host Demo * * \section SSec_Compat Demo Compatibility: @@ -25,7 +25,7 @@ * <td><b>USB Class:</b></td> * <td>Communications Device Class (CDC)</td> * </tr> - * <tr> + * <tr> * <td><b>USB Subclass:</b></td> * <td>Abstract Control Model (ACM)</td> * </tr> @@ -39,13 +39,13 @@ * </tr> * </table> * - * \section SSec_Description Project Description: + * \section SSec_Description Project Description: * * CDC host demonstration application. This gives a simple reference application * for implementing a USB CDC host, for CDC devices using the standard ACM profile. - * + * * This demo prints out received CDC data through the serial port. - * + * * Not that this demo is only compatible with devices which report the correct CDC * and ACM class, subclass and protocol values. Most USB-Serial cables have vendor * specific features, thus use vendor-specific class/subclass/protocol codes to force @@ -63,3 +63,4 @@ * </tr> * </table> */ + diff --git a/Demos/Host/LowLevel/VirtualSerialHost/makefile b/Demos/Host/LowLevel/VirtualSerialHost/makefile index 43677949d..09a245808 100644 --- a/Demos/Host/LowLevel/VirtualSerialHost/makefile +++ b/Demos/Host/LowLevel/VirtualSerialHost/makefile @@ -47,7 +47,7 @@ # make doxygen = Generate DoxyGen documentation for the project (must have # DoxyGen installed) # -# make debug = Start either simulavr or avarice as specified for debugging, +# make debug = Start either simulavr or avarice as specified for debugging, # with avr-gdb or avr-insight as the front end for debugging. # # make filename.s = Just compile filename.c into the assembler code only. @@ -64,14 +64,14 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring -# LUFA board drivers). If USER is selected, put custom board drivers in a directory called +# LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. BOARD = USBKEY # Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to +# This will define a symbol, F_CPU, in all source code files equal to the +# processor frequency in Hz. You can then use this symbol in your source code to # calculate timings. Do NOT tack on a 'UL' at the end, this will be done # automatically to create a 32-bit value in your source code. # @@ -84,7 +84,7 @@ F_CPU = 8000000 # Input clock frequency. -# This will define a symbol, F_CLOCK, in all source code files equal to the +# This will define a symbol, F_CLOCK, in all source code files equal to the # input clock frequency (before any prescaling is performed) in Hz. This value may # differ from F_CPU if prescaling is used on the latter, and is required as the # raw input clock is fed directly to the PLL sections of the AVR for high speed @@ -134,7 +134,7 @@ SRC = $(TARGET).c \ # List C++ source files here. (C dependencies are automatically generated.) -CPPSRC = +CPPSRC = # List Assembler source files here. @@ -147,7 +147,7 @@ CPPSRC = ASRC = -# Optimization level, can be [0, 1, 2, 3, s]. +# Optimization level, can be [0, 1, 2, 3, s]. # 0 = turn off optimization. s = optimize for size. # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) OPT = s @@ -261,7 +261,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) # for use in COFF files, additional information about filenames # and function names needs to be present in the assembler source # files -- see avr-libc docs [FIXME: not yet described there] -# -listing-cont-lines: Sets the maximum number of continuation lines of hex +# -listing-cont-lines: Sets the maximum number of continuation lines of hex # dump that will be displayed for a given single line of source input. ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100 @@ -274,7 +274,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt # If this is left blank, then it will use the Standard printf version. -PRINTF_LIB = +PRINTF_LIB = #PRINTF_LIB = $(PRINTF_LIB_MIN) #PRINTF_LIB = $(PRINTF_LIB_FLOAT) @@ -286,7 +286,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt # If this is left blank, then it will use the Standard scanf version. -SCANF_LIB = +SCANF_LIB = #SCANF_LIB = $(SCANF_LIB_MIN) #SCANF_LIB = $(SCANF_LIB_FLOAT) @@ -298,7 +298,7 @@ MATH_LIB = -lm # Each directory must be seperated by a space. # Use forward slashes for directory separators. # For a directory that has spaces, enclose it in quotes. -EXTRALIBDIRS = +EXTRALIBDIRS = @@ -321,7 +321,7 @@ EXTMEMOPTS = # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) @@ -355,7 +355,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_NO_VERIFY = -V # Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> +# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude> # to submit bug reports. #AVRDUDE_VERBOSE = -v -v @@ -389,7 +389,7 @@ JTAG_DEV = /dev/com1 DEBUG_PORT = 4242 # Debugging host used to communicate between GDB / avarice / simulavr, normally -# just set to localhost unless doing some sort of crazy debugging when +# just set to localhost unless doing some sort of crazy debugging when # avarice is running on a different computer. DEBUG_HOST = localhost @@ -418,7 +418,7 @@ WINSHELL = cmd MSG_ERRORS_NONE = Errors: none MSG_BEGIN = -------- begin -------- MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: +MSG_SIZE_BEFORE = Size before: MSG_SIZE_AFTER = Size after: MSG_COFF = Converting to AVR COFF: MSG_EXTENDED_COFF = Converting to AVR Extended COFF: @@ -437,10 +437,10 @@ MSG_CREATING_LIBRARY = Creating library: # Define all object files. -OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) +OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o) # Define all listing files. -LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) +LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst) # Compiler flags to generate dependency files. @@ -505,11 +505,11 @@ sizeafter: # Display compiler version information. -gccversion : +gccversion : @$(CC) --version -# Program the device. +# Program the device. program: $(TARGET).hex $(TARGET).eep $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) @@ -536,9 +536,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep # Generate avr-gdb config/init file which does the following: -# define the reset signal, load the target file, connect to target, and set +# define the reset signal, load the target file, connect to target, and set # a breakpoint at main(). -gdb-config: +gdb-config: @$(REMOVE) $(GDBINIT_FILE) @echo define reset >> $(GDBINIT_FILE) @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) @@ -636,14 +636,14 @@ extcoff: $(TARGET).elf $(OBJDIR)/%.o : %.c @echo @echo $(MSG_COMPILING) $< - $(CC) -c $(ALL_CFLAGS) $< -o $@ + $(CC) -c $(ALL_CFLAGS) $< -o $@ # Compile: create object files from C++ source files. $(OBJDIR)/%.o : %.cpp @echo @echo $(MSG_COMPILING_CPP) $< - $(CC) -c $(ALL_CPPFLAGS) $< -o $@ + $(CC) -c $(ALL_CPPFLAGS) $< -o $@ # Compile: create assembler files from C source files. @@ -665,7 +665,7 @@ $(OBJDIR)/%.o : %.S # Create preprocessed source for use in sending a bug report. %.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ # Target: clean project. @@ -709,3 +709,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null) build elf hex eep lss sym coff extcoff doxygen clean \ clean_list clean_doxygen program dfu flip flip-ee dfu-ee \ debug gdb-config + diff --git a/Demos/Host/LowLevel/makefile b/Demos/Host/LowLevel/makefile index 2dec7c85b..9a7c46578 100644 --- a/Demos/Host/LowLevel/makefile +++ b/Demos/Host/LowLevel/makefile @@ -1,7 +1,7 @@ # # LUFA Library # Copyright (C) Dean Camera, 2010. -# +# # dean [at] fourwalledcubicle [dot] com # www.fourwalledcubicle.com # @@ -60,3 +60,4 @@ all: $(MAKE) -C RNDISEthernetHost $@ $(MAKE) -C StillImageHost $@ $(MAKE) -C VirtualSerialHost $@ + diff --git a/Demos/Host/makefile b/Demos/Host/makefile index ce80f4e96..f389781e5 100644 --- a/Demos/Host/makefile +++ b/Demos/Host/makefile @@ -1,7 +1,7 @@ # # LUFA Library # Copyright (C) Dean Camera, 2010. -# +# # dean [at] fourwalledcubicle [dot] com # www.fourwalledcubicle.com # @@ -18,3 +18,4 @@ all: %: $(MAKE) -C ClassDriver $@ $(MAKE) -C LowLevel $@ + |