diff options
author | Dean Camera <dean@fourwalledcubicle.com> | 2009-06-15 13:42:34 +0000 |
---|---|---|
committer | Dean Camera <dean@fourwalledcubicle.com> | 2009-06-15 13:42:34 +0000 |
commit | 84d77833503151acffbdda6217fa8ce59c6b4b8a (patch) | |
tree | dc1c0d27066a640cb90c2460298bb60629a9021d /Demos/Host/ClassDriver/MouseHost | |
parent | 345506b11c6b816eaa7925ca115d75714d960249 (diff) | |
download | lufa-84d77833503151acffbdda6217fa8ce59c6b4b8a.tar.gz lufa-84d77833503151acffbdda6217fa8ce59c6b4b8a.tar.bz2 lufa-84d77833503151acffbdda6217fa8ce59c6b4b8a.zip |
Remove ConfigDescriptor.c/.h files from the ClassDriver Host demos, as they will be obsoleted when the Host mode class drivers are complete. Add new StillImage stub class driver common header.
Diffstat (limited to 'Demos/Host/ClassDriver/MouseHost')
-rw-r--r-- | Demos/Host/ClassDriver/MouseHost/ConfigDescriptor.c | 155 | ||||
-rw-r--r-- | Demos/Host/ClassDriver/MouseHost/ConfigDescriptor.h | 72 | ||||
-rw-r--r-- | Demos/Host/ClassDriver/MouseHost/MouseHost.h | 3 | ||||
-rw-r--r-- | Demos/Host/ClassDriver/MouseHost/makefile | 1 |
4 files changed, 2 insertions, 229 deletions
diff --git a/Demos/Host/ClassDriver/MouseHost/ConfigDescriptor.c b/Demos/Host/ClassDriver/MouseHost/ConfigDescriptor.c deleted file mode 100644 index 0f6ab59ae..000000000 --- a/Demos/Host/ClassDriver/MouseHost/ConfigDescriptor.c +++ /dev/null @@ -1,155 +0,0 @@ -/*
- LUFA Library
- Copyright (C) Dean Camera, 2009.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, and distribute this software
- and its documentation for any purpose and without fee is hereby
- granted, 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
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- *
- * USB Device Configuration Descriptor processing routines, to determine the correct pipe configurations
- * 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
- * routine will read in the entire configuration descriptor, and configure the hosts pipes to correctly communicate
- * with compatible devices.
- *
- * This routine searches for a HID interface descriptor containing at least one Interrupt type IN endpoint.
- *
- * \return An error code from the MouseHost_GetConfigDescriptorDataCodes_t enum.
- */
-uint8_t ProcessConfigurationDescriptor(void)
-{
- uint8_t* ConfigDescriptorData;
- uint16_t ConfigDescriptorSize;
-
- /* Get Configuration Descriptor size from the device */
- if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)
- return ControlError;
-
- /* Ensure that the Configuration Descriptor isn't too large */
- if (ConfigDescriptorSize > MAX_CONFIG_DESCRIPTOR_SIZE)
- return DescriptorTooLarge;
-
- /* Allocate enough memory for the entire config descriptor */
- ConfigDescriptorData = alloca(ConfigDescriptorSize);
-
- /* Retrieve the entire configuration descriptor into the allocated buffer */
- USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, ConfigDescriptorData);
-
- /* Validate returned data - ensure first entry is a configuration header descriptor */
- if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
- return InvalidConfigDataReturned;
-
- /* Get the mouse interface from the configuration descriptor */
- if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
- DComp_NextMouseInterface) != DESCRIPTOR_SEARCH_COMP_Found)
- {
- /* Descriptor not found, error out */
- return NoHIDInterfaceFound;
- }
-
- /* Get the mouse interface's data endpoint descriptor */
- if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
- DComp_NextInterfaceMouseDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
- {
- /* Descriptor not found, error out */
- return NoEndpointFound;
- }
-
- /* Retrieve the endpoint address from the endpoint descriptor */
- USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
-
- /* Configure the mouse data pipe */
- Pipe_ConfigurePipe(MOUSE_DATAPIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
- EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
-
- Pipe_SetInfiniteINRequests();
-
- /* Valid data found, return success */
- return SuccessfulConfigRead;
-}
-
-/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
- * 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 Interface descriptor of the correct Mouse HID Class and Protocol values.
- *
- * \return A value from the DSEARCH_Return_ErrorCodes_t enum
- */
-uint8_t DComp_NextMouseInterface(void* CurrentDescriptor)
-{
- /* Determine if the current descriptor is an interface descriptor */
- if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
- {
- /* Check the HID descriptor class and protocol, break out if correct class/protocol interface found */
- if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == MOUSE_CLASS) &&
- (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == MOUSE_PROTOCOL))
- {
- /* Indicate that the descriptor being searched for has been found */
- return DESCRIPTOR_SEARCH_Found;
- }
- }
-
- /* Current descriptor does not match what this comparator is looking for */
- return DESCRIPTOR_SEARCH_NotFound;
-}
-
-/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
- * 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 IN 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
- */
-uint8_t DComp_NextInterfaceMouseDataEndpoint(void* CurrentDescriptor)
-{
- /* Determine the type of the current descriptor */
- if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
- {
- /* Check if the current Endpoint descriptor is of type IN */
- if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
- {
- /* Indicate that the descriptor being searched for has been found */
- return DESCRIPTOR_SEARCH_Found;
- }
- }
- else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
- {
- /* Indicate that the search has failed prematurely and should be aborted */
- return DESCRIPTOR_SEARCH_Fail;
- }
-
- /* Current descriptor does not match what this comparator is looking for */
- return DESCRIPTOR_SEARCH_NotFound;
-}
diff --git a/Demos/Host/ClassDriver/MouseHost/ConfigDescriptor.h b/Demos/Host/ClassDriver/MouseHost/ConfigDescriptor.h deleted file mode 100644 index cb1ae63ad..000000000 --- a/Demos/Host/ClassDriver/MouseHost/ConfigDescriptor.h +++ /dev/null @@ -1,72 +0,0 @@ -/*
- LUFA Library
- Copyright (C) Dean Camera, 2009.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, and distribute this software
- and its documentation for any purpose and without fee is hereby
- granted, 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
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- *
- * Header file for ConfigDescriptor.c.
- */
-
-#ifndef _CONFIGDESCRIPTOR_H_
-#define _CONFIGDESCRIPTOR_H_
-
- /* Includes: */
- #include <LUFA/Drivers/USB/USB.h> // USB Functionality
-
- #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
-
- /** Maximum size of a device configuration descriptor which can be processed by the host, in bytes */
- #define MAX_CONFIG_DESCRIPTOR_SIZE 512
-
- /* Enums: */
- /** Enum for the possible return codes of the ProcessConfigurationDescriptor() function. */
- enum MouseHost_GetConfigDescriptorDataCodes_t
- {
- SuccessfulConfigRead = 0, /**< Configuration Descriptor was processed successfully */
- ControlError = 1, /**< A control request to the device failed to complete successfully */
- DescriptorTooLarge = 2, /**< The device's Configuration Descriptor is too large to process */
- InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */
- NoHIDInterfaceFound = 4, /**< A compatible HID interface was not found in the device's Configuration Descriptor */
- NoEndpointFound = 5, /**< A compatible HID IN endpoint was not found in the device's HID interface */
- };
-
- /* Function Prototypes: */
- uint8_t ProcessConfigurationDescriptor(void);
-
- uint8_t DComp_NextMouseInterface(void* CurrentDescriptor);
- uint8_t DComp_NextInterfaceMouseDataEndpoint(void* CurrentDescriptor);
-
-#endif
diff --git a/Demos/Host/ClassDriver/MouseHost/MouseHost.h b/Demos/Host/ClassDriver/MouseHost/MouseHost.h index 1abd56068..9e3087fb2 100644 --- a/Demos/Host/ClassDriver/MouseHost/MouseHost.h +++ b/Demos/Host/ClassDriver/MouseHost/MouseHost.h @@ -46,9 +46,10 @@ #include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
- #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h>
+ #include <LUFA/Drivers/USB/USB.h>
+ #include <LUFA/Drivers/USB/Class/HID.h>
#include "ConfigDescriptor.h"
diff --git a/Demos/Host/ClassDriver/MouseHost/makefile b/Demos/Host/ClassDriver/MouseHost/makefile index b3c62b0bd..367ad9fb4 100644 --- a/Demos/Host/ClassDriver/MouseHost/makefile +++ b/Demos/Host/ClassDriver/MouseHost/makefile @@ -124,7 +124,6 @@ LUFA_PATH = ../../../.. # List C source files here. (C dependencies are automatically generated.)
SRC = $(TARGET).c \
- ConfigDescriptor.c \
$(LUFA_PATH)/LUFA/Drivers/Peripheral/SerialStream.c \
$(LUFA_PATH)/LUFA/Drivers/Peripheral/Serial.c \
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c \
|