From 84d77833503151acffbdda6217fa8ce59c6b4b8a Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Mon, 15 Jun 2009 13:42:34 +0000 Subject: 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. --- .../MouseHostWithParser/ConfigDescriptor.c | 172 --------------------- .../MouseHostWithParser/ConfigDescriptor.h | 80 ---------- .../ClassDriver/MouseHostWithParser/HIDReport.h | 2 +- .../MouseHostWithParser/MouseHostWithParser.h | 4 +- .../Host/ClassDriver/MouseHostWithParser/makefile | 1 - 5 files changed, 3 insertions(+), 256 deletions(-) delete mode 100644 Demos/Host/ClassDriver/MouseHostWithParser/ConfigDescriptor.c delete mode 100644 Demos/Host/ClassDriver/MouseHostWithParser/ConfigDescriptor.h (limited to 'Demos/Host/ClassDriver/MouseHostWithParser') diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/ConfigDescriptor.c b/Demos/Host/ClassDriver/MouseHostWithParser/ConfigDescriptor.c deleted file mode 100644 index 5d9d3f04e..000000000 --- a/Demos/Host/ClassDriver/MouseHostWithParser/ConfigDescriptor.c +++ /dev/null @@ -1,172 +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 and HID descriptor. - * - * \return An error code from the MouseHostWithParser_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 HID descriptor */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextHID) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Descriptor not found, error out */ - return NoHIDDescriptorFound; - } - - /* Save the HID report size for later use */ - HIDReportSize = DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_HID_t).HIDReportLength; - - /* 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) -{ - 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)) - { - return DESCRIPTOR_SEARCH_Found; - } - } - - 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) -{ - if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) - { - if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) - return DESCRIPTOR_SEARCH_Found; - } - else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) - { - return DESCRIPTOR_SEARCH_Fail; - } - - 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 HID descriptor within the current HID interface descriptor. - * - * \return A value from the DSEARCH_Return_ErrorCodes_t enum - */ -uint8_t DComp_NextHID(void* CurrentDescriptor) -{ - if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID) - return DESCRIPTOR_SEARCH_Found; - else - return DESCRIPTOR_SEARCH_NotFound; -} diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/ConfigDescriptor.h b/Demos/Host/ClassDriver/MouseHostWithParser/ConfigDescriptor.h deleted file mode 100644 index 08400c50f..000000000 --- a/Demos/Host/ClassDriver/MouseHostWithParser/ConfigDescriptor.h +++ /dev/null @@ -1,80 +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 // USB Functionality - - #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 - - /** Maximum size of a device configuration descriptor which can be processed by the host, in bytes */ - #define MAX_CONFIG_DESCRIPTOR_SIZE 512 - - /** Descriptor header type constant for a HID descriptor */ - #define DTYPE_HID 0x21 - - /** Descriptor header type constant for a HID report descriptor */ - #define DTYPE_Report 0x22 - - /* Enums: */ - /** Enum for the possible return codes of the ProcessConfigurationDescriptor() function. */ - enum CDCHost_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 */ - NoHIDDescriptorFound = 5, /**< A compatible HID descriptor was not found in the device's HID interface */ - 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); - uint8_t DComp_NextHID(void* CurrentDescriptor); - -#endif diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/HIDReport.h b/Demos/Host/ClassDriver/MouseHostWithParser/HIDReport.h index f5429f0a9..acfbc8a8b 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/HIDReport.h +++ b/Demos/Host/ClassDriver/MouseHostWithParser/HIDReport.h @@ -38,7 +38,7 @@ /* Includes: */ #include - #include + #include #include "MouseHostWithParser.h" diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h index b91d6d1a8..cc539fbf2 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h +++ b/Demos/Host/ClassDriver/MouseHostWithParser/MouseHostWithParser.h @@ -40,11 +40,11 @@ #include #include - #include #include #include + #include + #include - #include "ConfigDescriptor.h" #include "HIDReport.h" /* Macros: */ diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/makefile b/Demos/Host/ClassDriver/MouseHostWithParser/makefile index 1ae74da5f..5c31fce9a 100644 --- a/Demos/Host/ClassDriver/MouseHostWithParser/makefile +++ b/Demos/Host/ClassDriver/MouseHostWithParser/makefile @@ -124,7 +124,6 @@ LUFA_PATH = ../../../.. # List C source files here. (C dependencies are automatically generated.) SRC = $(TARGET).c \ - ConfigDescriptor.c \ HIDReport.c \ $(LUFA_PATH)/LUFA/Drivers/Peripheral/SerialStream.c \ $(LUFA_PATH)/LUFA/Drivers/Peripheral/Serial.c \ -- cgit v1.2.3