diff --git a/Demos/Host/ClassDriver/CDCHost/ConfigDescriptor.c b/Demos/Host/ClassDriver/CDCHost/ConfigDescriptor.c deleted file mode 100644 index baf02a2162..0000000000 --- a/Demos/Host/ClassDriver/CDCHost/ConfigDescriptor.c +++ /dev/null @@ -1,255 +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 CDC interface descriptor containing bulk data IN and OUT endpoints, and an interrupt event endpoint. - * - * \return An error code from the CDCHost_GetConfigDescriptorDataCodes_t enum. - */ -uint8_t ProcessConfigurationDescriptor(void) -{ - uint8_t* ConfigDescriptorData; - uint16_t ConfigDescriptorSize; - uint8_t FoundEndpoints = 0; - - /* 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 CDC control interface from the configuration descriptor */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Descriptor not found, error out */ - return NoCDCInterfaceFound; - } - - /* Get the IN and OUT data endpoints for the CDC interface */ - while (FoundEndpoints != ((1 << CDC_NOTIFICATIONPIPE) | (1 << CDC_DATAPIPE_IN) | (1 << CDC_DATAPIPE_OUT))) - { - /* Fetch the next bulk or interrupt endpoint from the current CDC interface */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Check to see if the control interface's notification pipe has been found, if so search for the data interface */ - if (FoundEndpoints & (1 << CDC_NOTIFICATIONPIPE)) - { - /* Get the next CDC data interface from the configuration descriptor (CDC class has two CDC interfaces) */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextCDCDataInterface) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Descriptor not found, error out */ - return NoCDCInterfaceFound; - } - } - else - { - /* Clear the found endpoints mask, since any already processed endpoints aren't in the CDC interface we need */ - FoundEndpoints = 0; - - /* Disable any already configured pipes from the invalid CDC interfaces */ - Pipe_SelectPipe(CDC_NOTIFICATIONPIPE); - Pipe_DisablePipe(); - Pipe_SelectPipe(CDC_DATAPIPE_IN); - Pipe_DisablePipe(); - Pipe_SelectPipe(CDC_DATAPIPE_OUT); - Pipe_DisablePipe(); - - /* Get the next CDC control interface from the configuration descriptor (CDC class has two CDC interfaces) */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextCDCControlInterface) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Descriptor not found, error out */ - return NoCDCInterfaceFound; - } - } - - /* Fetch the next bulk or interrupt endpoint from the current CDC interface */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextInterfaceCDCDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Descriptor not found, error out */ - return NoEndpointFound; - } - } - - USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); - - /* Check if the found endpoint is a interrupt or bulk type descriptor */ - if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT) - { - /* If the endpoint is a IN type interrupt endpoint */ - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) - { - /* Configure the notification pipe */ - Pipe_ConfigurePipe(CDC_NOTIFICATIONPIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, - EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE); - - Pipe_SetInfiniteINRequests(); - Pipe_SetInterruptPeriod(EndpointData->PollingIntervalMS); - - /* Set the flag indicating that the notification pipe has been found */ - FoundEndpoints |= (1 << CDC_NOTIFICATIONPIPE); - } - } - else - { - /* Check if the endpoint is a bulk IN or bulk OUT endpoint */ - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) - { - /* Configure the data IN pipe */ - Pipe_ConfigurePipe(CDC_DATAPIPE_IN, EP_TYPE_BULK, PIPE_TOKEN_IN, - EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE); - - Pipe_SetInfiniteINRequests(); - Pipe_Unfreeze(); - - /* Set the flag indicating that the data IN pipe has been found */ - FoundEndpoints |= (1 << CDC_DATAPIPE_IN); - } - else - { - /* Configure the data OUT pipe */ - Pipe_ConfigurePipe(CDC_DATAPIPE_OUT, EP_TYPE_BULK, PIPE_TOKEN_OUT, - EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE); - - Pipe_Unfreeze(); - - /* Set the flag indicating that the data OUT pipe has been found */ - FoundEndpoints |= (1 << CDC_DATAPIPE_OUT); - } - } - } - - /* 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 CDC control Class, Subclass and Protocol values. - * - * \return A value from the DSEARCH_Return_ErrorCodes_t enum - */ -uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor) -{ - if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) - { - /* Check the CDC descriptor class, subclass and protocol, break out if correct control interface found */ - if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == CDC_CONTROL_CLASS) && - (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == CDC_CONTROL_SUBCLASS) && - (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == CDC_CONTROL_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 Interface descriptor of the correct CDC data Class, Subclass and Protocol values. - * - * \return A value from the DSEARCH_Return_ErrorCodes_t enum - */ -uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor) -{ - if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) - { - /* Check the CDC descriptor class, subclass and protocol, break out if correct data interface found */ - if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == CDC_DATA_CLASS) && - (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == CDC_DATA_SUBCLASS) && - (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == CDC_DATA_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 bulk IN or OUT endpoint, or interrupt IN endpoint within the current interface, - * aborting the search if another interface descriptor is found before the required endpoint (so that it may be compared - * using a different comparator to determine if it is another CDC class interface). - * - * \return A value from the DSEARCH_Return_ErrorCodes_t enum - */ -uint8_t DComp_NextInterfaceCDCDataEndpoint(void* CurrentDescriptor) -{ - if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) - { - 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; - } - else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) - { - return DESCRIPTOR_SEARCH_Fail; - } - - return DESCRIPTOR_SEARCH_NotFound; -} diff --git a/Demos/Host/ClassDriver/CDCHost/ConfigDescriptor.h b/Demos/Host/ClassDriver/CDCHost/ConfigDescriptor.h deleted file mode 100644 index 1a118cad3e..0000000000 --- a/Demos/Host/ClassDriver/CDCHost/ConfigDescriptor.h +++ /dev/null @@ -1,85 +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 "CDCHost.h" - - /* Macros: */ - /** Interface Class value for the CDC class */ - #define CDC_CONTROL_CLASS 0x02 - - /** Interface Class value for the CDC Communication Interface subclass */ - #define CDC_CONTROL_SUBCLASS 0x02 - - /** 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 - - /** Interface Class value for the CDC data subclass (unused) */ - #define CDC_DATA_SUBCLASS 0x00 - - /** Interface Class value for the CDC data protocol */ - #define CDC_DATA_PROTOCOL 0x00 - - /** 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 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 */ - NoCDCInterfaceFound = 4, /**< A compatible CDC interface was not found in the device's Configuration Descriptor */ - NoEndpointFound = 5, /**< Compatible CDC endpoints were not found in the device's CDC interface */ - }; - - /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); - - uint8_t DComp_NextCDCControlInterface(void* CurrentDescriptor); - uint8_t DComp_NextCDCDataInterface(void* CurrentDescriptor); - uint8_t DComp_NextInterfaceCDCDataEndpoint(void* CurrentDescriptor); - -#endif diff --git a/Demos/Host/ClassDriver/GenericHIDHost/ConfigDescriptor.c b/Demos/Host/ClassDriver/GenericHIDHost/ConfigDescriptor.c deleted file mode 100644 index 29fa60ba38..0000000000 --- a/Demos/Host/ClassDriver/GenericHIDHost/ConfigDescriptor.c +++ /dev/null @@ -1,174 +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 GenericHIDHost_GetConfigDescriptorDataCodes_t enum. - */ -uint8_t ProcessConfigurationDescriptor(void) -{ - uint8_t* ConfigDescriptorData; - uint16_t ConfigDescriptorSize; - - uint8_t FoundEndpoints = 0; - - /* 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 HID interface from the configuration descriptor */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Descriptor not found, error out */ - return NoHIDInterfaceFound; - } - - while (FoundEndpoints != ((1 << HID_DATA_IN_PIPE) | (1 << HID_DATA_OUT_PIPE))) - { - /* Get the next HID interface's data endpoint descriptor */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextInterfaceHIDDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Not all HID devices have an OUT endpoint - if we've reached the end of the HID descriptor - * but only found the mandatory IN endpoint, it's safe to continue with the device enumeration */ - if (FoundEndpoints == (1 << HID_DATA_IN_PIPE)) - break; - - /* 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); - - /* If the endpoint is a IN type endpoint */ - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) - { - /* Configure the HID data IN pipe */ - Pipe_ConfigurePipe(HID_DATA_IN_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, - EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE); - - Pipe_SetInfiniteINRequests(); - - FoundEndpoints |= (1 << HID_DATA_IN_PIPE); - } - else - { - /* Configure the HID data OUT pipe */ - Pipe_ConfigurePipe(HID_DATA_OUT_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_OUT, - EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE); - - FoundEndpoints |= (1 << HID_DATA_OUT_PIPE); - } - } - - /* 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 HID Class value. - * - * \return A value from the DSEARCH_Return_ErrorCodes_t enum - */ -uint8_t DComp_NextHIDInterface(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 == HID_CLASS) - { - /* 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 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_NextInterfaceHIDDataEndpoint(void* CurrentDescriptor) -{ - /* Determine the type of the current descriptor */ - if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) - { - /* 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/GenericHIDHost/ConfigDescriptor.h b/Demos/Host/ClassDriver/GenericHIDHost/ConfigDescriptor.h deleted file mode 100644 index b58d44027a..0000000000 --- a/Demos/Host/ClassDriver/GenericHIDHost/ConfigDescriptor.h +++ /dev/null @@ -1,69 +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 "GenericHIDHost.h" - - /* Macros: */ - /** Interface Class value for the Human Interface Device class */ - #define HID_CLASS 0x03 - - /** 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 GenericHIDHost_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_NextHIDInterface(void* CurrentDescriptor); - uint8_t DComp_NextInterfaceHIDDataEndpoint(void* CurrentDescriptor); - -#endif diff --git a/Demos/Host/ClassDriver/GenericHIDHost/GenericHIDHost.h b/Demos/Host/ClassDriver/GenericHIDHost/GenericHIDHost.h index 415dae0231..74fb6f631f 100644 --- a/Demos/Host/ClassDriver/GenericHIDHost/GenericHIDHost.h +++ b/Demos/Host/ClassDriver/GenericHIDHost/GenericHIDHost.h @@ -46,11 +46,10 @@ #include #include - #include #include #include - - #include "ConfigDescriptor.h" + #include + #include /* Macros: */ /** Pipe number for the HID data IN pipe */ diff --git a/Demos/Host/ClassDriver/GenericHIDHost/makefile b/Demos/Host/ClassDriver/GenericHIDHost/makefile index 49f8bf2370..b41d93597a 100644 --- a/Demos/Host/ClassDriver/GenericHIDHost/makefile +++ b/Demos/Host/ClassDriver/GenericHIDHost/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 \ diff --git a/Demos/Host/ClassDriver/KeyboardHost/ConfigDescriptor.c b/Demos/Host/ClassDriver/KeyboardHost/ConfigDescriptor.c deleted file mode 100644 index e586ea5d35..0000000000 --- a/Demos/Host/ClassDriver/KeyboardHost/ConfigDescriptor.c +++ /dev/null @@ -1,145 +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 KeyboardHost_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 keyboard interface from the configuration descriptor */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Descriptor not found, error out */ - return NoHIDInterfaceFound; - } - - /* Get the keyboard interface's data endpoint descriptor */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextInterfaceKeyboardDataEndpoint) != 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 keyboard data pipe */ - Pipe_ConfigurePipe(KEYBOARD_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 Keyboard HID Class and Protocol values. - * - * \return A value from the DSEARCH_Return_ErrorCodes_t enum - */ -uint8_t DComp_NextKeyboardInterface(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 == KEYBOARD_CLASS) && - (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == KEYBOARD_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_NextInterfaceKeyboardDataEndpoint(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; -} diff --git a/Demos/Host/ClassDriver/KeyboardHost/ConfigDescriptor.h b/Demos/Host/ClassDriver/KeyboardHost/ConfigDescriptor.h deleted file mode 100644 index 425f0a4bef..0000000000 --- a/Demos/Host/ClassDriver/KeyboardHost/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 // USB Functionality - - #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 - - /** 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 KeyboardHost_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_NextKeyboardInterface(void* CurrentDescriptor); - uint8_t DComp_NextInterfaceKeyboardDataEndpoint(void* CurrentDescriptor); - -#endif diff --git a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.h b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.h index 4aa09e1b7a..883e0ca423 100644 --- a/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.h +++ b/Demos/Host/ClassDriver/KeyboardHost/KeyboardHost.h @@ -46,11 +46,10 @@ #include #include - #include #include #include - - #include "ConfigDescriptor.h" + #include + #include /* Macros: */ /** Pipe number for the keyboard data IN pipe */ diff --git a/Demos/Host/ClassDriver/KeyboardHost/makefile b/Demos/Host/ClassDriver/KeyboardHost/makefile index 9bc1e6af11..a30c145baa 100644 --- a/Demos/Host/ClassDriver/KeyboardHost/makefile +++ b/Demos/Host/ClassDriver/KeyboardHost/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 \ diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/ConfigDescriptor.c b/Demos/Host/ClassDriver/KeyboardHostWithParser/ConfigDescriptor.c deleted file mode 100644 index 4ee3b998f9..0000000000 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/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 KeyboardHostWithParser_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 keyboard interface from the configuration descriptor */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Descriptor not found, error out */ - return NoHIDInterfaceFound; - } - - /* Get the keyboard 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 keyboard interface's data endpoint descriptor */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextInterfaceKeyboardDataEndpoint) != 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 keyboard data pipe */ - Pipe_ConfigurePipe(KEYBOARD_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 Keyboard HID Class and Protocol values. - * - * \return A value from the DSEARCH_Return_ErrorCodes_t enum - */ -uint8_t DComp_NextKeyboardInterface(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 == KEYBOARD_CLASS) && - (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == KEYBOARD_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_NextInterfaceKeyboardDataEndpoint(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/KeyboardHostWithParser/ConfigDescriptor.h b/Demos/Host/ClassDriver/KeyboardHostWithParser/ConfigDescriptor.h deleted file mode 100644 index 338adc93bd..0000000000 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/ConfigDescriptor.h +++ /dev/null @@ -1,79 +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 KEYBOARD_CLASS 0x03 - - /** Interface Protocol value for a Boot Protocol Keyboard compliant device */ - #define KEYBOARD_PROTOCOL 0x01 - - /** 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 KeyboardHostWithParser_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_NextKeyboardInterface(void* CurrentDescriptor); - uint8_t DComp_NextInterfaceKeyboardDataEndpoint(void* CurrentDescriptor); - uint8_t DComp_NextHID(void* CurrentDescriptor); - -#endif diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/HIDReport.h b/Demos/Host/ClassDriver/KeyboardHostWithParser/HIDReport.h index a141ffb8ce..29fc848310 100644 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/HIDReport.h +++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/HIDReport.h @@ -38,7 +38,7 @@ /* Includes: */ #include - #include + #include #include "KeyboardHostWithParser.h" diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h index 90db94a2aa..f5e1f740ea 100644 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h +++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.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/KeyboardHostWithParser/makefile b/Demos/Host/ClassDriver/KeyboardHostWithParser/makefile index 8b1f08b79d..41e15fa83a 100644 --- a/Demos/Host/ClassDriver/KeyboardHostWithParser/makefile +++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/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 \ diff --git a/Demos/Host/ClassDriver/MassStorageHost/ConfigDescriptor.c b/Demos/Host/ClassDriver/MassStorageHost/ConfigDescriptor.c deleted file mode 100644 index c951c797e6..0000000000 --- a/Demos/Host/ClassDriver/MassStorageHost/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 MSD interface descriptor containing bulk IN and OUT data endpoints. - * - * \return An error code from the MassStorageHost_GetConfigDescriptorDataCodes_t enum. - */ -uint8_t ProcessConfigurationDescriptor(void) -{ - uint8_t* ConfigDescriptorData; - uint16_t ConfigDescriptorSize; - uint8_t FoundEndpoints = 0; - - /* 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 mass storage interface from the configuration descriptor */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextMassStorageInterface) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Descriptor not found, error out */ - return NoInterfaceFound; - } - - /* Get the IN and OUT data endpoints for the mass storage interface */ - while (FoundEndpoints != ((1 << MASS_STORE_DATA_IN_PIPE) | (1 << MASS_STORE_DATA_OUT_PIPE))) - { - /* Fetch the next bulk endpoint from the current mass storage interface */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextInterfaceBulkDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Descriptor not found, error out */ - return NoEndpointFound; - } - - USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); - - /* Check if the endpoint is a bulk IN or bulk OUT endpoint, set appropriate globals */ - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) - { - /* Configure the data IN pipe */ - Pipe_ConfigurePipe(MASS_STORE_DATA_IN_PIPE, EP_TYPE_BULK, PIPE_TOKEN_IN, - EndpointData->EndpointAddress, EndpointData->EndpointSize, - PIPE_BANK_DOUBLE); - - Pipe_SetInfiniteINRequests(); - - /* Set the flag indicating that the data IN pipe has been found */ - FoundEndpoints |= (1 << MASS_STORE_DATA_IN_PIPE); - } - else - { - /* Configure the data OUT pipe */ - Pipe_ConfigurePipe(MASS_STORE_DATA_OUT_PIPE, EP_TYPE_BULK, PIPE_TOKEN_OUT, - EndpointData->EndpointAddress, EndpointData->EndpointSize, - PIPE_BANK_DOUBLE); - - /* Set the flag indicating that the data OUT pipe has been found */ - FoundEndpoints |= (1 << MASS_STORE_DATA_OUT_PIPE); - } - } - - /* 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 Mass Storage Class, Subclass and Protocol values. - * - * \return A value from the DSEARCH_Return_ErrorCodes_t enum - */ -uint8_t DComp_NextMassStorageInterface(void* CurrentDescriptor) -{ - if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) - { - /* Check the descriptor class and protocol, break out if correct class/protocol interface found */ - if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == MASS_STORE_CLASS) && - (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == MASS_STORE_SUBCLASS) && - (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == MASS_STORE_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 Bulk Endpoint descriptor of the correct MSD interface, aborting the search if - * another interface descriptor is found before the next endpoint. - * - * \return A value from the DSEARCH_Return_ErrorCodes_t enum - */ -uint8_t DComp_NextInterfaceBulkDataEndpoint(void* CurrentDescriptor) -{ - if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) - { - 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; - } - else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) - { - return DESCRIPTOR_SEARCH_Fail; - } - - return DESCRIPTOR_SEARCH_NotFound; -} diff --git a/Demos/Host/ClassDriver/MassStorageHost/ConfigDescriptor.h b/Demos/Host/ClassDriver/MassStorageHost/ConfigDescriptor.h deleted file mode 100644 index 6c0b8e6f4e..0000000000 --- a/Demos/Host/ClassDriver/MassStorageHost/ConfigDescriptor.h +++ /dev/null @@ -1,75 +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 "MassStorageHost.h" - - /* Macros: */ - /** Interface Class value for the Mass Storage Device class */ - #define MASS_STORE_CLASS 0x08 - - /** Interface Class value for the Mass Storage Device subclass */ - #define MASS_STORE_SUBCLASS 0x06 - - /** Interface Protocol value for the Bulk Only transport protocol */ - #define MASS_STORE_PROTOCOL 0x50 - - /** 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 MassStorageHost_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 */ - NoInterfaceFound = 4, /**< A compatible MSD interface was not found in the device's Configuration Descriptor */ - NoEndpointFound = 5, /**< The correct MSD endpoint descriptors were not found in the device's MSD interface */ - }; - - /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); - - uint8_t DComp_NextMassStorageInterface(void* CurrentDescriptor); - uint8_t DComp_NextInterfaceBulkDataEndpoint(void* CurrentDescriptor); - -#endif diff --git a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h index a299b7008f..667f4edea3 100644 --- a/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h +++ b/Demos/Host/ClassDriver/MassStorageHost/MassStorageHost.h @@ -44,16 +44,15 @@ #include #include - #include "ConfigDescriptor.h" - #include "Lib/MassStoreCommands.h" - #include // Library Version Information - #include // ANSI Terminal Escape Codes - #include // USB Functionality - #include // Serial stream driver - #include // LEDs driver - #include // Board Buttons driver + #include + #include + #include + #include + #include + #include + #include /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ diff --git a/Demos/Host/ClassDriver/MassStorageHost/makefile b/Demos/Host/ClassDriver/MassStorageHost/makefile index 91eb302975..5adf3ca299 100644 --- a/Demos/Host/ClassDriver/MassStorageHost/makefile +++ b/Demos/Host/ClassDriver/MassStorageHost/makefile @@ -124,7 +124,6 @@ LUFA_PATH = ../../../.. # List C source files here. (C dependencies are automatically generated.) SRC = $(TARGET).c \ - ConfigDescriptor.c \ Lib/MassStoreCommands.c \ $(LUFA_PATH)/LUFA/Drivers/Peripheral/SerialStream.c \ $(LUFA_PATH)/LUFA/Drivers/Peripheral/Serial.c \ diff --git a/Demos/Host/ClassDriver/MouseHost/ConfigDescriptor.c b/Demos/Host/ClassDriver/MouseHost/ConfigDescriptor.c deleted file mode 100644 index 0f6ab59ae1..0000000000 --- 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 cb1ae63ade..0000000000 --- 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 // 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 1abd560687..9e3087fb2c 100644 --- a/Demos/Host/ClassDriver/MouseHost/MouseHost.h +++ b/Demos/Host/ClassDriver/MouseHost/MouseHost.h @@ -46,9 +46,10 @@ #include #include - #include #include #include + #include + #include #include "ConfigDescriptor.h" diff --git a/Demos/Host/ClassDriver/MouseHost/makefile b/Demos/Host/ClassDriver/MouseHost/makefile index b3c62b0bd9..367ad9fb4b 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 \ diff --git a/Demos/Host/ClassDriver/MouseHostWithParser/ConfigDescriptor.c b/Demos/Host/ClassDriver/MouseHostWithParser/ConfigDescriptor.c deleted file mode 100644 index 5d9d3f04e0..0000000000 --- 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 08400c50fc..0000000000 --- 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 f5429f0a96..acfbc8a8bb 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 b91d6d1a83..cc539fbf2f 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 1ae74da5f0..5c31fce9ad 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 \ diff --git a/Demos/Host/ClassDriver/StillImageHost/ConfigDescriptor.c b/Demos/Host/ClassDriver/StillImageHost/ConfigDescriptor.c deleted file mode 100644 index 1084969643..0000000000 --- a/Demos/Host/ClassDriver/StillImageHost/ConfigDescriptor.c +++ /dev/null @@ -1,192 +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 SI interface descriptor containing bulk IN and OUT data endpoints. - * - * \return An error code from the StillImageHost_GetConfigDescriptorDataCodes_t enum. - */ -uint8_t ProcessConfigurationDescriptor(void) -{ - uint8_t* ConfigDescriptorData; - uint16_t ConfigDescriptorSize; - uint8_t FoundEndpoints = 0; - - /* 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 Still Image interface from the configuration descriptor */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextStillImageInterface) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Descriptor not found, error out */ - return NoInterfaceFound; - } - - /* Get the IN and OUT data and event endpoints for the Still Image interface */ - while (FoundEndpoints != ((1 << SIMAGE_EVENTS_PIPE) | (1 << SIMAGE_DATA_IN_PIPE) | (1 << SIMAGE_DATA_OUT_PIPE))) - { - /* Fetch the next endpoint from the current Still Image interface */ - if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData, - DComp_NextSImageInterfaceDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found) - { - /* Descriptor not found, error out */ - return NoEndpointFound; - } - - USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t); - - /* Check if the found endpoint is a interrupt or bulk type descriptor */ - if ((EndpointData->Attributes & EP_TYPE_MASK) == EP_TYPE_INTERRUPT) - { - /* If the endpoint is a IN type interrupt endpoint */ - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) - { - /* Configure the events pipe */ - Pipe_ConfigurePipe(SIMAGE_EVENTS_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN, - EndpointData->EndpointAddress, EndpointData->EndpointSize, - PIPE_BANK_DOUBLE); - - Pipe_SetInfiniteINRequests(); - Pipe_SetInterruptPeriod(EndpointData->PollingIntervalMS); - - /* Set the flag indicating that the events pipe has been found */ - FoundEndpoints |= (1 << SIMAGE_EVENTS_PIPE); - } - } - else - { - /* Check if the endpoint is a bulk IN or bulk OUT endpoint */ - if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN) - { - /* Configure the data IN pipe */ - Pipe_ConfigurePipe(SIMAGE_DATA_IN_PIPE, EP_TYPE_BULK, PIPE_TOKEN_IN, - EndpointData->EndpointAddress, EndpointData->EndpointSize, - PIPE_BANK_DOUBLE); - - Pipe_SetInfiniteINRequests(); - - /* Set the flag indicating that the data IN pipe has been found */ - FoundEndpoints |= (1 << SIMAGE_DATA_IN_PIPE); - } - else - { - /* Configure the data OUT pipe */ - Pipe_ConfigurePipe(SIMAGE_DATA_OUT_PIPE, EP_TYPE_BULK, PIPE_TOKEN_OUT, - EndpointData->EndpointAddress, EndpointData->EndpointSize, - PIPE_BANK_DOUBLE); - - /* Set the flag indicating that the data OUT pipe has been found */ - FoundEndpoints |= (1 << SIMAGE_DATA_OUT_PIPE); - } - } - } - - /* 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 Still Image Class, Subclass and Protocol values. - * - * \return A value from the DSEARCH_Return_ErrorCodes_t enum - */ -uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor) -{ - if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) - { - /* Check the descriptor class and protocol, break out if correct class/protocol interface found */ - if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == SIMAGE_CLASS) && - (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).SubClass == SIMAGE_SUBCLASS) && - (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == SIMAGE_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 Interrupt or Bulk Endpoint descriptor of the current SI interface, aborting the - * search if another interface descriptor is found before the next endpoint. - * - * \return A value from the DSEARCH_Return_ErrorCodes_t enum - */ -uint8_t DComp_NextSImageInterfaceDataEndpoint(void* CurrentDescriptor) -{ - if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint) - { - 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; - } - else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface) - { - return DESCRIPTOR_SEARCH_Fail; - } - - return DESCRIPTOR_SEARCH_NotFound; -} diff --git a/Demos/Host/ClassDriver/StillImageHost/ConfigDescriptor.h b/Demos/Host/ClassDriver/StillImageHost/ConfigDescriptor.h deleted file mode 100644 index 29df30c0cb..0000000000 --- a/Demos/Host/ClassDriver/StillImageHost/ConfigDescriptor.h +++ /dev/null @@ -1,75 +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 "StillImageHost.h" - - /* Macros: */ - /** Interface Class value for the Still Image Device class */ - #define SIMAGE_CLASS 0x06 - - /** Interface Class value for the Still Image Device subclass */ - #define SIMAGE_SUBCLASS 0x01 - - /** Interface Class value for the Still Image Device protocol */ - #define SIMAGE_PROTOCOL 0x01 - - /** 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 MassStorageHost_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 */ - NoInterfaceFound = 4, /**< A compatible SI interface was not found in the device's Configuration Descriptor */ - NoEndpointFound = 5, /**< The correct SI endpoint descriptors were not found in the device's SI interface */ - }; - - /* Function Prototypes: */ - uint8_t ProcessConfigurationDescriptor(void); - - uint8_t DComp_NextStillImageInterface(void* CurrentDescriptor); - uint8_t DComp_NextSImageInterfaceDataEndpoint(void* CurrentDescriptor); - -#endif diff --git a/Demos/Host/ClassDriver/StillImageHost/StillImageHost.h b/Demos/Host/ClassDriver/StillImageHost/StillImageHost.h index 1896b8fe5a..1ad0278b53 100644 --- a/Demos/Host/ClassDriver/StillImageHost/StillImageHost.h +++ b/Demos/Host/ClassDriver/StillImageHost/StillImageHost.h @@ -48,9 +48,10 @@ #include "Lib/StillImageCommands.h" #include - #include #include #include + #include + #include /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ diff --git a/Demos/Host/ClassDriver/StillImageHost/makefile b/Demos/Host/ClassDriver/StillImageHost/makefile index 184f4f9bb4..4c0181b235 100644 --- a/Demos/Host/ClassDriver/StillImageHost/makefile +++ b/Demos/Host/ClassDriver/StillImageHost/makefile @@ -123,7 +123,6 @@ LUFA_PATH = ../../../.. # List C source files here. (C dependencies are automatically generated.) SRC = $(TARGET).c \ - ConfigDescriptor.c \ Lib/StillImageCommands.c \ $(LUFA_PATH)/LUFA/Drivers/Peripheral/SerialStream.c \ $(LUFA_PATH)/LUFA/Drivers/Peripheral/Serial.c \ diff --git a/LUFA.pnproj b/LUFA.pnproj index 801d87fa51..1a94c56de3 100644 --- a/LUFA.pnproj +++ b/LUFA.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/LUFA/Drivers/USB/Class/Common/StillImage.h b/LUFA/Drivers/USB/Class/Common/StillImage.h new file mode 100644 index 0000000000..dde7a74479 --- /dev/null +++ b/LUFA/Drivers/USB/Class/Common/StillImage.h @@ -0,0 +1,67 @@ +/* + 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. +*/ + +/** \ingroup Group_USBClassSI + * @{ + */ + +#ifndef _SI_CLASS_COMMON_H_ +#define _SI_CLASS_COMMON_H_ + + /* Includes: */ + #include "../../USB.h" + + #include + + /* Enable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + extern "C" { + #endif + + /* Macros: */ + + + /* Type defines: */ + + + /* Enums: */ + + + /* Type Defines: */ + + + /* Disable C linkage for C++ Compilers: */ + #if defined(__cplusplus) + } + #endif + +#endif + +/** @} */ diff --git a/LUFA/MigrationInformation.txt b/LUFA/MigrationInformation.txt index e00517b6b1..34a1f97faa 100644 --- a/LUFA/MigrationInformation.txt +++ b/LUFA/MigrationInformation.txt @@ -12,6 +12,12 @@ * * \section Sec_MigrationXXXXXX Migrating from 090605 to XXXXXX * + * All + * - The "simple scheduler" has been removed, as it was little more than an abtracted loop and caused much confusion. User + * applications using the scheduler should switch to regular loops instead. + * - The "Dynamic Memory Block Allocator" has been removed, as it was unused in (and unrelated to) the LUFA library and never + * used in user applications. The library is available from the author's website for those wishing to still use it in their + * applications. * * \section Sec_Migration090605 Migrating from 090510 to 090605 *