diff options
Diffstat (limited to 'Demos/Host/LowLevel/MouseHost')
-rw-r--r-- | Demos/Host/LowLevel/MouseHost/ConfigDescriptor.c | 23 | ||||
-rw-r--r-- | Demos/Host/LowLevel/MouseHost/ConfigDescriptor.h | 21 | ||||
-rw-r--r-- | Demos/Host/LowLevel/MouseHost/MouseHost.c | 41 | ||||
-rw-r--r-- | Demos/Host/LowLevel/MouseHost/MouseHost.h | 23 | ||||
-rw-r--r-- | Demos/Host/LowLevel/MouseHost/MouseHost.txt | 15 | ||||
-rw-r--r-- | Demos/Host/LowLevel/MouseHost/makefile | 49 |
6 files changed, 89 insertions, 83 deletions
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 + |