Remove ConfigDescriptor.c/.h files from the ClassDriver Host demos, as they will be obsoleted when the Host mode class drivers are complete. Add new StillImage stub class driver common header.
parent
345506b11c
commit
84d7783350
@ -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;
|
|
||||||
}
|
|
@ -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 <LUFA/Drivers/USB/USB.h> // 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
|
|
@ -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;
|
|
||||||
}
|
|
@ -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 <LUFA/Drivers/USB/USB.h> // 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
|
|
@ -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;
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
LUFA Library
|
|
||||||
Copyright (C) Dean Camera, 2009.
|
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
|
||||||
www.fourwalledcubicle.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and distribute this software
|
|
||||||
and its documentation for any purpose and without fee is hereby
|
|
||||||
granted, provided that the above copyright notice appear in all
|
|
||||||
copies and that both that the copyright notice and this
|
|
||||||
permission notice and warranty disclaimer appear in supporting
|
|
||||||
documentation, and that the name of the author not be used in
|
|
||||||
advertising or publicity pertaining to distribution of the
|
|
||||||
software without specific, written prior permission.
|
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
|
||||||
software, including all implied warranties of merchantability
|
|
||||||
and fitness. In no event shall the author be liable for any
|
|
||||||
special, indirect or consequential damages or any damages
|
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
|
||||||
in an action of contract, negligence or other tortious action,
|
|
||||||
arising out of or in connection with the use or performance of
|
|
||||||
this software.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
*
|
|
||||||
* Header file for ConfigDescriptor.c.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _CONFIGDESCRIPTOR_H_
|
|
||||||
#define _CONFIGDESCRIPTOR_H_
|
|
||||||
|
|
||||||
/* Includes: */
|
|
||||||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
|
||||||
|
|
||||||
#include "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
|
|
@ -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;
|
|
||||||
}
|
|
@ -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 <LUFA/Drivers/USB/USB.h> // 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
|
|
@ -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;
|
|
||||||
}
|
|
@ -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 <LUFA/Drivers/USB/USB.h> // 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
|
|
@ -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;
|
|
||||||
}
|
|
@ -1,72 +0,0 @@
|
|||||||
/*
|
|
||||||
LUFA Library
|
|
||||||
Copyright (C) Dean Camera, 2009.
|
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
|
||||||
www.fourwalledcubicle.com
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and distribute this software
|
|
||||||
and its documentation for any purpose and without fee is hereby
|
|
||||||
granted, provided that the above copyright notice appear in all
|
|
||||||
copies and that both that the copyright notice and this
|
|
||||||
permission notice and warranty disclaimer appear in supporting
|
|
||||||
documentation, and that the name of the author not be used in
|
|
||||||
advertising or publicity pertaining to distribution of the
|
|
||||||
software without specific, written prior permission.
|
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
|
||||||
software, including all implied warranties of merchantability
|
|
||||||
and fitness. In no event shall the author be liable for any
|
|
||||||
special, indirect or consequential damages or any damages
|
|
||||||
whatsoever resulting from loss of use, data or profits, whether
|
|
||||||
in an action of contract, negligence or other tortious action,
|
|
||||||
arising out of or in connection with the use or performance of
|
|
||||||
this software.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** \file
|
|
||||||
*
|
|
||||||
* Header file for ConfigDescriptor.c.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef _CONFIGDESCRIPTOR_H_
|
|
||||||
#define _CONFIGDESCRIPTOR_H_
|
|
||||||
|
|
||||||
/* Includes: */
|
|
||||||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
|
||||||
|
|
||||||
#include "MouseHost.h"
|
|
||||||
|
|
||||||
/* Macros: */
|
|
||||||
/** Interface Class value for the Human Interface Device class */
|
|
||||||
#define MOUSE_CLASS 0x03
|
|
||||||
|
|
||||||
/** Interface Protocol value for a Boot Protocol Mouse compliant device */
|
|
||||||
#define MOUSE_PROTOCOL 0x02
|
|
||||||
|
|
||||||
/** Maximum size of a device configuration descriptor which can be processed by the host, in bytes */
|
|
||||||
#define MAX_CONFIG_DESCRIPTOR_SIZE 512
|
|
||||||
|
|
||||||
/* Enums: */
|
|
||||||
/** Enum for the possible return codes of the ProcessConfigurationDescriptor() function. */
|
|
||||||
enum MouseHost_GetConfigDescriptorDataCodes_t
|
|
||||||
{
|
|
||||||
SuccessfulConfigRead = 0, /**< Configuration Descriptor was processed successfully */
|
|
||||||
ControlError = 1, /**< A control request to the device failed to complete successfully */
|
|
||||||
DescriptorTooLarge = 2, /**< The device's Configuration Descriptor is too large to process */
|
|
||||||
InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */
|
|
||||||
NoHIDInterfaceFound = 4, /**< A compatible HID interface was not found in the device's Configuration Descriptor */
|
|
||||||
NoEndpointFound = 5, /**< A compatible HID IN endpoint was not found in the device's HID interface */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Function Prototypes: */
|
|
||||||
uint8_t ProcessConfigurationDescriptor(void);
|
|
||||||
|
|
||||||
uint8_t DComp_NextMouseInterface(void* CurrentDescriptor);
|
|
||||||
uint8_t DComp_NextInterfaceMouseDataEndpoint(void* CurrentDescriptor);
|
|
||||||
|
|
||||||
#endif
|
|
@ -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;
|
|
||||||
}
|
|
@ -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 <LUFA/Drivers/USB/USB.h> // 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
|
|
@ -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;
|
|
||||||
}
|
|
@ -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 <LUFA/Drivers/USB/USB.h> // 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
|
|
File diff suppressed because one or more lines are too long
@ -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 <string.h>
|
||||||
|
|
||||||
|
/* 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
|
||||||
|
|
||||||
|
/** @} */
|
Loading…
Reference in new issue