aboutsummaryrefslogtreecommitdiff
path: root/Demos/Host/ClassDriver/KeyboardHostWithParser
diff options
context:
space:
mode:
Diffstat (limited to 'Demos/Host/ClassDriver/KeyboardHostWithParser')
-rw-r--r--Demos/Host/ClassDriver/KeyboardHostWithParser/ConfigDescriptor.c172
-rw-r--r--Demos/Host/ClassDriver/KeyboardHostWithParser/ConfigDescriptor.h79
-rw-r--r--Demos/Host/ClassDriver/KeyboardHostWithParser/HIDReport.h2
-rw-r--r--Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h4
-rw-r--r--Demos/Host/ClassDriver/KeyboardHostWithParser/makefile1
5 files changed, 3 insertions, 255 deletions
diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/ConfigDescriptor.c b/Demos/Host/ClassDriver/KeyboardHostWithParser/ConfigDescriptor.c
deleted file mode 100644
index 4ee3b998f9..0000000000
--- a/Demos/Host/ClassDriver/KeyboardHostWithParser/ConfigDescriptor.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2009.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, and distribute this software
- and its documentation for any purpose and without fee is hereby
- granted, provided that the above copyright notice appear in all
- copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- *
- * USB Device Configuration Descriptor processing routines, to determine the correct pipe configurations
- * needed to communication with an attached USB device. Descriptors are special computer-readable structures
- * which the host requests upon device enumeration, to determine the device's capabilities and functions.
- */
-
-#include "ConfigDescriptor.h"
-
-/** Reads and processes an attached device's descriptors, to determine compatibility and pipe configurations. This
- * routine will read in the entire configuration descriptor, and configure the hosts pipes to correctly communicate
- * with compatible devices.
- *
- * This routine searches for a HID interface descriptor containing at least one Interrupt type IN endpoint and HID descriptor.
- *
- * \return An error code from the KeyboardHostWithParser_GetConfigDescriptorDataCodes_t enum.
- */
-uint8_t ProcessConfigurationDescriptor(void)
-{
- uint8_t* ConfigDescriptorData;
- uint16_t ConfigDescriptorSize;
-
- /* Get Configuration Descriptor size from the device */
- if (USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, NULL) != HOST_SENDCONTROL_Successful)
- return ControlError;
-
- /* Ensure that the Configuration Descriptor isn't too large */
- if (ConfigDescriptorSize > MAX_CONFIG_DESCRIPTOR_SIZE)
- return DescriptorTooLarge;
-
- /* Allocate enough memory for the entire config descriptor */
- ConfigDescriptorData = alloca(ConfigDescriptorSize);
-
- /* Retrieve the entire configuration descriptor into the allocated buffer */
- USB_GetDeviceConfigDescriptor(&ConfigDescriptorSize, ConfigDescriptorData);
-
- /* Validate returned data - ensure first entry is a configuration header descriptor */
- if (DESCRIPTOR_TYPE(ConfigDescriptorData) != DTYPE_Configuration)
- return InvalidConfigDataReturned;
-
- /* Get the keyboard interface from the configuration descriptor */
- if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
- DComp_NextKeyboardInterface) != DESCRIPTOR_SEARCH_COMP_Found)
- {
- /* Descriptor not found, error out */
- return NoHIDInterfaceFound;
- }
-
- /* Get the keyboard interface's HID descriptor */
- if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
- DComp_NextHID) != DESCRIPTOR_SEARCH_COMP_Found)
- {
- /* Descriptor not found, error out */
- return NoHIDDescriptorFound;
- }
-
- /* Save the HID report size for later use */
- HIDReportSize = DESCRIPTOR_CAST(ConfigDescriptorData, USB_Descriptor_HID_t).HIDReportLength;
-
- /* Get the keyboard interface's data endpoint descriptor */
- if (USB_GetNextDescriptorComp(&ConfigDescriptorSize, &ConfigDescriptorData,
- DComp_NextInterfaceKeyboardDataEndpoint) != DESCRIPTOR_SEARCH_COMP_Found)
- {
- /* Descriptor not found, error out */
- return NoEndpointFound;
- }
-
- /* Retrieve the endpoint address from the endpoint descriptor */
- USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(ConfigDescriptorData, USB_Descriptor_Endpoint_t);
-
- /* Configure the keyboard data pipe */
- Pipe_ConfigurePipe(KEYBOARD_DATAPIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
- EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
-
- Pipe_SetInfiniteINRequests();
-
- /* Valid data found, return success */
- return SuccessfulConfigRead;
-}
-
-/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
- * configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
- * descriptor processing if an incompatible descriptor configuration is found.
- *
- * This comparator searches for the next Interface descriptor of the correct Keyboard HID Class and Protocol values.
- *
- * \return A value from the DSEARCH_Return_ErrorCodes_t enum
- */
-uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)
-{
- if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
- {
- /* Check the HID descriptor class and protocol, break out if correct class/protocol interface found */
- if ((DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Class == KEYBOARD_CLASS) &&
- (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Interface_t).Protocol == KEYBOARD_PROTOCOL))
- {
- return DESCRIPTOR_SEARCH_Found;
- }
- }
-
- return DESCRIPTOR_SEARCH_NotFound;
-}
-
-/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
- * configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
- * descriptor processing if an incompatible descriptor configuration is found.
- *
- * This comparator searches for the next IN Endpoint descriptor inside the current interface descriptor,
- * aborting the search if another interface descriptor is found before the required endpoint.
- *
- * \return A value from the DSEARCH_Return_ErrorCodes_t enum
- */
-uint8_t DComp_NextInterfaceKeyboardDataEndpoint(void* CurrentDescriptor)
-{
- if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Endpoint)
- {
- if (DESCRIPTOR_CAST(CurrentDescriptor, USB_Descriptor_Endpoint_t).EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
- return DESCRIPTOR_SEARCH_Found;
- }
- else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
- {
- return DESCRIPTOR_SEARCH_Fail;
- }
-
- return DESCRIPTOR_SEARCH_NotFound;
-}
-
-/** Descriptor comparator function. This comparator function is can be called while processing an attached USB device's
- * configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
- * descriptor processing if an incompatible descriptor configuration is found.
- *
- * This comparator searches for the next HID descriptor within the current HID interface descriptor.
- *
- * \return A value from the DSEARCH_Return_ErrorCodes_t enum
- */
-uint8_t DComp_NextHID(void* CurrentDescriptor)
-{
- if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID)
- return DESCRIPTOR_SEARCH_Found;
- else
- return DESCRIPTOR_SEARCH_NotFound;
-}
diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/ConfigDescriptor.h b/Demos/Host/ClassDriver/KeyboardHostWithParser/ConfigDescriptor.h
deleted file mode 100644
index 338adc93bd..0000000000
--- a/Demos/Host/ClassDriver/KeyboardHostWithParser/ConfigDescriptor.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- LUFA Library
- Copyright (C) Dean Camera, 2009.
-
- dean [at] fourwalledcubicle [dot] com
- www.fourwalledcubicle.com
-*/
-
-/*
- Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
-
- Permission to use, copy, modify, and distribute this software
- and its documentation for any purpose and without fee is hereby
- granted, provided that the above copyright notice appear in all
- copies and that both that the copyright notice and this
- permission notice and warranty disclaimer appear in supporting
- documentation, and that the name of the author not be used in
- advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.
-
- The author disclaim all warranties with regard to this
- software, including all implied warranties of merchantability
- and fitness. In no event shall the author be liable for any
- special, indirect or consequential damages or any damages
- whatsoever resulting from loss of use, data or profits, whether
- in an action of contract, negligence or other tortious action,
- arising out of or in connection with the use or performance of
- this software.
-*/
-
-/** \file
- *
- * Header file for ConfigDescriptor.c.
- */
-
-#ifndef _CONFIGDESCRIPTOR_H_
-#define _CONFIGDESCRIPTOR_H_
-
- /* Includes: */
- #include <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
diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/HIDReport.h b/Demos/Host/ClassDriver/KeyboardHostWithParser/HIDReport.h
index a141ffb8ce..29fc848310 100644
--- a/Demos/Host/ClassDriver/KeyboardHostWithParser/HIDReport.h
+++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/HIDReport.h
@@ -38,7 +38,7 @@
/* Includes: */
#include <LUFA/Drivers/USB/USB.h>
- #include <LUFA/Drivers/USB/Class/Host/HIDParser.h>
+ #include <LUFA/Drivers/USB/Class/HID.h>
#include "KeyboardHostWithParser.h"
diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h
index 90db94a2aa..f5e1f740ea 100644
--- a/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h
+++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/KeyboardHostWithParser.h
@@ -40,11 +40,11 @@
#include <LUFA/Version.h>
#include <LUFA/Drivers/Misc/TerminalCodes.h>
- #include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
#include <LUFA/Drivers/Board/LEDs.h>
+ #include <LUFA/Drivers/USB/USB.h>
+ #include <LUFA/Drivers/USB/Class/HID.h>
- #include "ConfigDescriptor.h"
#include "HIDReport.h"
/* Macros: */
diff --git a/Demos/Host/ClassDriver/KeyboardHostWithParser/makefile b/Demos/Host/ClassDriver/KeyboardHostWithParser/makefile
index 8b1f08b79d..41e15fa83a 100644
--- a/Demos/Host/ClassDriver/KeyboardHostWithParser/makefile
+++ b/Demos/Host/ClassDriver/KeyboardHostWithParser/makefile
@@ -124,7 +124,6 @@ LUFA_PATH = ../../../..
# List C source files here. (C dependencies are automatically generated.)
SRC = $(TARGET).c \
- ConfigDescriptor.c \
HIDReport.c \
$(LUFA_PATH)/LUFA/Drivers/Peripheral/SerialStream.c \
$(LUFA_PATH)/LUFA/Drivers/Peripheral/Serial.c \