summaryrefslogtreecommitdiff
path: root/at91lib/usb/common/hid
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2011-07-31 10:22:41 +0200
committerHarald Welte <laforge@gnumonks.org>2011-07-31 10:25:11 +0200
commitaf8603411cc2c927de581bef0b9213b0a7b77cc1 (patch)
tree1ef72986cd9913674346c00e606b5ca094c12424 /at91lib/usb/common/hid
parent63d587cf2ef26b5737f9293d03c86ffd183d5a04 (diff)
import usb-device-composide-cdchid-project
Diffstat (limited to 'at91lib/usb/common/hid')
-rw-r--r--at91lib/usb/common/hid/HIDDescriptor.h93
-rw-r--r--at91lib/usb/common/hid/HIDDeviceDescriptor.h68
-rw-r--r--at91lib/usb/common/hid/HIDGenericDescriptor.h63
-rw-r--r--at91lib/usb/common/hid/HIDGenericDesktop.h98
-rw-r--r--at91lib/usb/common/hid/HIDGenericRequest.h75
-rw-r--r--at91lib/usb/common/hid/HIDIdleRequest.c56
-rw-r--r--at91lib/usb/common/hid/HIDIdleRequest.h68
-rw-r--r--at91lib/usb/common/hid/HIDInterfaceDescriptor.h77
-rw-r--r--at91lib/usb/common/hid/HIDKeypad.c56
-rw-r--r--at91lib/usb/common/hid/HIDKeypad.h276
-rw-r--r--at91lib/usb/common/hid/HIDLeds.h79
-rw-r--r--at91lib/usb/common/hid/HIDReport.h231
-rw-r--r--at91lib/usb/common/hid/HIDReportRequest.c68
-rw-r--r--at91lib/usb/common/hid/HIDReportRequest.h86
14 files changed, 1394 insertions, 0 deletions
diff --git a/at91lib/usb/common/hid/HIDDescriptor.h b/at91lib/usb/common/hid/HIDDescriptor.h
new file mode 100644
index 0000000..ae00102
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDDescriptor.h
@@ -0,0 +1,93 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+ !!!Purpose
+
+ Methods and definitions for manipulating a HID descriptor.
+*/
+
+#ifndef HIDDESCRIPTOR_H
+#define HIDDESCRIPTOR_H
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Release Numbers"
+/// ...
+///
+/// !Numbers
+/// - HIDDescriptor_HID1_11
+
+/// Identifies version 1.11 of the HID specification.
+#define HIDDescriptor_HID1_11 0x0111
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Types
+//------------------------------------------------------------------------------
+
+#ifdef __ICCARM__ // IAR
+#pragma pack(1) // IAR
+#define __attribute__(...) // IAR
+#endif // IAR
+
+//------------------------------------------------------------------------------
+/// Identifies the length of type of subordinate descriptors of a HID
+/// device. This particular type only supports one subordinate descriptor.
+//------------------------------------------------------------------------------
+typedef struct {
+
+ /// Size of descriptor in bytes.
+ unsigned char bLength;
+ /// Descriptor type (HIDGenericDescriptor_HID).
+ unsigned char bDescriptorType;
+ /// HID class specification release number in BCD format.
+ unsigned short bcdHID;
+ /// Country code of the device if it is localized.
+ unsigned char bCountryCode;
+ /// Number of subordinate descriptors.
+ unsigned char bNumDescriptors;
+ /// Type of the first subordinate descriptor.
+ unsigned char bDescriptorType0;
+ /// Size in bytes of the first subordinate descriptor.
+ unsigned short wDescriptorLength0;
+
+} __attribute__ ((packed)) HIDDescriptor; // GCC
+
+#ifdef __ICCARM__ // IAR
+#pragma pack() // IAR
+#endif // IAR
+
+#endif //#ifndef HIDDESCRIPTOR_H
+
diff --git a/at91lib/usb/common/hid/HIDDeviceDescriptor.h b/at91lib/usb/common/hid/HIDDeviceDescriptor.h
new file mode 100644
index 0000000..267c73e
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDDeviceDescriptor.h
@@ -0,0 +1,68 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+ !!!Purpose
+
+ Definitions used for declaring the device descriptor of a HID device.
+
+ !!!Usage
+
+ Use this constants when defining an instance of USBDeviceDescriptor for
+ an HID device.
+*/
+
+#ifndef HIDDEVICEDESCRIPTOR_H
+#define HIDDEVICEDESCRIPTOR_H
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Device Descriptor Codes"
+/// This page lists HID device class, subclass and protocol codes.
+///
+/// !Codes
+/// - HIDDeviceDescriptor_CLASS
+/// - HIDDeviceDescriptor_SUBCLASS
+/// - HIDDeviceDescriptor_PROTOCOL
+
+/// Class code for a HID device.
+#define HIDDeviceDescriptor_CLASS 0
+/// Subclass code for a HID device.
+#define HIDDeviceDescriptor_SUBCLASS 0
+/// Protocol code for a HID device.
+#define HIDDeviceDescriptor_PROTOCOL 0
+//------------------------------------------------------------------------------
+
+#endif //#ifndef HIDDEVICEDESCRIPTOR_H
+
diff --git a/at91lib/usb/common/hid/HIDGenericDescriptor.h b/at91lib/usb/common/hid/HIDGenericDescriptor.h
new file mode 100644
index 0000000..2324d53
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDGenericDescriptor.h
@@ -0,0 +1,63 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+ !!!Purpose
+
+ Definitions for using HID-specific descriptors.
+*/
+
+#ifndef HIDGENERICDESCRIPTOR_H
+#define HIDGENERICDESCRIPTOR_H
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Descriptors Types"
+/// ...
+///
+/// !Types
+/// - HIDGenericDescriptor_HID
+/// - HIDGenericDescriptor_REPORT
+/// - HIDGenericDescriptor_PHYSICAL
+
+/// HID descriptor type.
+#define HIDGenericDescriptor_HID 0x21
+/// Report descriptor type.
+#define HIDGenericDescriptor_REPORT 0x22
+/// Physical descriptor type.
+#define HIDGenericDescriptor_PHYSICAL 0x23
+//------------------------------------------------------------------------------
+
+#endif //#ifndef HIDGENERICDESCRIPTOR_H
+
diff --git a/at91lib/usb/common/hid/HIDGenericDesktop.h b/at91lib/usb/common/hid/HIDGenericDesktop.h
new file mode 100644
index 0000000..ac1165c
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDGenericDesktop.h
@@ -0,0 +1,98 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+ !!!Purpose
+
+ Constants for using the HID generic desktop usage page.
+
+ !!!Usage
+
+ Use these constants when declaring a Report descriptor which references
+ the generic desktop page.
+*/
+
+#ifndef HIDGENERICDESKTOP_H
+#define HIDGENERICDESKTOP_H
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID GenericDesktop Page ID"
+/// ...
+///
+/// !ID
+/// - HIDGenericDesktop_PAGEID
+
+/// ID for the HID generic desktop usage page.
+#define HIDGenericDesktop_PAGEID 0x01
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID GenericDesktop Usages"
+/// ...
+///
+/// !Usages
+/// - HIDGenericDesktop_POINTER
+/// - HIDGenericDesktop_MOUSE
+/// - HIDGenericDesktop_JOYSTICK
+/// - HIDGenericDesktop_GAMEPAD
+/// - HIDGenericDesktop_KEYBOARD
+/// - HIDGenericDesktop_KEYPAD
+/// - HIDGenericDesktop_MULTIAXIS
+/// - HIDGenericDesktop_X
+/// - HIDGenericDesktop_Y
+
+/// Pointer usage ID.
+#define HIDGenericDesktop_POINTER 0x01
+/// Mouse usage ID.
+#define HIDGenericDesktop_MOUSE 0x02
+/// Joystick usage ID.
+#define HIDGenericDesktop_JOYSTICK 0x04
+/// Gamepad usage ID.
+#define HIDGenericDesktop_GAMEPAD 0x05
+/// Keyboard usage ID.
+#define HIDGenericDesktop_KEYBOARD 0x06
+/// Keypad usage ID.
+#define HIDGenericDesktop_KEYPAD 0x07
+/// Multi-axis controller usage ID.
+#define HIDGenericDesktop_MULTIAXIS 0x08
+
+/// Axis Usage X direction ID.
+#define HIDGenericDesktop_X 0x30
+/// Axis Usage Y direction ID.
+#define HIDGenericDesktop_Y 0x31
+//------------------------------------------------------------------------------
+
+#endif //#ifndef HIDGENERICDESKTOP_H
+
diff --git a/at91lib/usb/common/hid/HIDGenericRequest.h b/at91lib/usb/common/hid/HIDGenericRequest.h
new file mode 100644
index 0000000..356f498
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDGenericRequest.h
@@ -0,0 +1,75 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*
+ Title: HIDGenericRequest
+
+ About: Purpose
+ Definition of constants for using HID-specific requests.
+
+ About: Usage
+ When constructing or receiving an HID SETUP request, use the request
+ codes provided by this header file.
+*/
+
+#ifndef HIDGENERICREQUEST_H
+#define HIDGENERICREQUEST_H
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Request Codes"
+/// ...
+///
+/// !Codes
+/// - HIDGenericRequest_GETREPORT
+/// - HIDGenericRequest_GETIDLE
+/// - HIDGenericRequest_GETPROTOCOL
+/// - HIDGenericRequest_SETREPORT
+/// - HIDGenericRequest_SETIDLE
+/// - HIDGenericRequest_SETPROTOCOL
+
+/// GetReport request code.
+#define HIDGenericRequest_GETREPORT 0x01
+/// GetIdle request code.
+#define HIDGenericRequest_GETIDLE 0x02
+/// GetProtocol request code.
+#define HIDGenericRequest_GETPROTOCOL 0x03
+/// SetReport request code.
+#define HIDGenericRequest_SETREPORT 0x09
+/// SetIdle request code.
+#define HIDGenericRequest_SETIDLE 0x0A
+/// SetProtocol request code.
+#define HIDGenericRequest_SETPROTOCOL 0x0B
+//------------------------------------------------------------------------------
+
+#endif //#ifndef HIDGENERICREQUEST_H
+
diff --git a/at91lib/usb/common/hid/HIDIdleRequest.c b/at91lib/usb/common/hid/HIDIdleRequest.c
new file mode 100644
index 0000000..640f2d5
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDIdleRequest.c
@@ -0,0 +1,56 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*
+ Title: HIDIdleRequest implementation
+
+ About: Purpose
+ Implementation of the HIDIdleRequest methods.
+*/
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include "HIDIdleRequest.h"
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Retrieves the Idle rate (in milliseconds) indicated by a SET_IDLE
+/// request.
+/// \param request Pointer to a USBGenericRequest instance.
+/// \return New idle rate for the report.
+//------------------------------------------------------------------------------
+unsigned char HIDIdleRequest_GetIdleRate(const USBGenericRequest *request)
+{
+ return ((USBGenericRequest_GetValue(request) >> 8) & 0xFF);
+}
diff --git a/at91lib/usb/common/hid/HIDIdleRequest.h b/at91lib/usb/common/hid/HIDIdleRequest.h
new file mode 100644
index 0000000..1f9a361
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDIdleRequest.h
@@ -0,0 +1,68 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+ !!!Purpose
+
+ Methods and constants for manipulating HID-specific GET_IDLE and SET_IDLE
+ requests.
+
+ !!!Usage
+
+ -# Retrieve the idle rate indicated by a GET_IDLE or SET_IDLE request
+ with HIDIdleRequest_GetIdleRate.
+*/
+
+#ifndef HIDIDLEREQUEST_H
+#define HIDIDLEREQUEST_H
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include <usb/common/core/USBGenericRequest.h>
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+/// Infinite idle rate.
+#define HIDIdleRequest_INFINITE 0
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+extern unsigned char HIDIdleRequest_GetIdleRate(
+ const USBGenericRequest *request);
+
+#endif //#ifndef HIDIDLEREQUEST_H
+
diff --git a/at91lib/usb/common/hid/HIDInterfaceDescriptor.h b/at91lib/usb/common/hid/HIDInterfaceDescriptor.h
new file mode 100644
index 0000000..4ef1bc7
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDInterfaceDescriptor.h
@@ -0,0 +1,77 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+ !!!Purpose
+
+ Constants used when declaring an HID interface.
+
+ !!!Usage
+
+ Use the constants defined here when declaring a USBInterfaceDescriptor
+ instance for a HID interface.
+*/
+
+#ifndef HIDINTERFACEDESCRIPTOR_H
+#define HIDINTERFACEDESCRIPTOR_H
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Interface Descriptor Codes"
+/// This page lists HID Interface class, subclass and protocol codes.
+///
+/// !Codes
+/// - HIDInterfaceDescriptor_CLASS
+/// - HIDInterfaceDescriptor_SUBCLASS_NONE
+/// - HIDInterfaceDescriptor_SUBCLASS_BOOT
+/// - HIDInterfaceDescriptor_PROTOCOL_NONE
+/// - HIDInterfaceDescriptor_PROTOCOL_KEYBOARD
+/// - HIDInterfaceDescriptor_PROTOCOL_MOUSE
+
+/// HID interface class code.
+#define HIDInterfaceDescriptor_CLASS 0x03
+/// Indicates the interface does not implement a particular subclass.
+#define HIDInterfaceDescriptor_SUBCLASS_NONE 0x00
+/// Indicates the interface is compliant with the boot specification.
+#define HIDInterfaceDescriptor_SUBCLASS_BOOT 0x01
+/// Indicates the interface does not implement a particular protocol.
+#define HIDInterfaceDescriptor_PROTOCOL_NONE 0x00
+/// Indicates the interface supports the boot specification as a keyboard.
+#define HIDInterfaceDescriptor_PROTOCOL_KEYBOARD 0x01
+/// Indicates the interface supports the boot specification as a mouse.
+#define HIDInterfaceDescriptor_PROTOCOL_MOUSE 0x02
+//------------------------------------------------------------------------------
+
+#endif //#ifndef HIDINTERFACEDESCRIPTOR_H
+
diff --git a/at91lib/usb/common/hid/HIDKeypad.c b/at91lib/usb/common/hid/HIDKeypad.c
new file mode 100644
index 0000000..19f533e
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDKeypad.c
@@ -0,0 +1,56 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*
+ Title: HIDKeypad implementation
+
+ About: Purpose
+ Implementation of HID keypad usage page methods.
+*/
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include "HIDKeypad.h"
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Indicates if the given key code is associated with a modified key.
+/// \param key Key code.
+/// \return 1 if the key code represents a modifier key; otherwise 0.
+//------------------------------------------------------------------------------
+unsigned char HIDKeypad_IsModifierKey(unsigned char key)
+{
+ return ((key >= HIDKeypad_LEFTCONTROL) && (key <= HIDKeypad_RIGHTGUI));
+}
+
diff --git a/at91lib/usb/common/hid/HIDKeypad.h b/at91lib/usb/common/hid/HIDKeypad.h
new file mode 100644
index 0000000..06ad747
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDKeypad.h
@@ -0,0 +1,276 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+!!!Purpose
+
+ Definitions of constants and methods for the HID keypad usage page.
+
+ !!!Usage
+
+ -# Use the constants declared in this file when instanciating a
+ Report descriptor instance.
+ -# When implementing the functionality of an HID keyboard, use the
+ key codes defined here to indicate keys that are being pressed and
+ released.
+*/
+
+#ifndef HIDKEYPAD_H
+#define HIDKEYPAD_H
+
+//------------------------------------------------------------------------------
+// Constants
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Keypad Page ID"
+/// This page lists HID Keypad page ID.
+///
+/// !ID
+/// - HIDKeypad_PAGEID
+
+/// Identifier for the HID keypad usage page
+#define HIDKeypad_PAGEID 0x07
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Alphabetic Keys"
+/// ...
+///
+/// !Keys
+/// - HIDKeypad_A
+/// - HIDKeypad_B
+/// - HIDKeypad_C
+/// - HIDKeypad_D
+/// - HIDKeypad_E
+/// - HIDKeypad_F
+/// - HIDKeypad_G
+/// - HIDKeypad_H
+/// - HIDKeypad_I
+/// - HIDKeypad_J
+/// - HIDKeypad_K
+/// - HIDKeypad_L
+/// - HIDKeypad_M
+/// - HIDKeypad_N
+/// - HIDKeypad_O
+/// - HIDKeypad_P
+/// - HIDKeypad_Q
+/// - HIDKeypad_R
+/// - HIDKeypad_S
+/// - HIDKeypad_T
+/// - HIDKeypad_U
+/// - HIDKeypad_V
+/// - HIDKeypad_W
+/// - HIDKeypad_X
+/// - HIDKeypad_Y
+/// - HIDKeypad_Z
+
+/// Key code for 'a' and 'A'.
+#define HIDKeypad_A 4
+/// Key code for 'b' and 'B'.
+#define HIDKeypad_B 5
+/// Key code for 'c' and 'C'.
+#define HIDKeypad_C 6
+/// Key code for 'd' and 'D'.
+#define HIDKeypad_D 7
+/// Key code for 'e' and 'E'.
+#define HIDKeypad_E 8
+/// Key code for 'f' and 'F'.
+#define HIDKeypad_F 9
+/// Key code for 'g' and 'G'.
+#define HIDKeypad_G 10
+/// Key code for 'h' and 'H'.
+#define HIDKeypad_H 11
+/// Key code for 'i' and 'I'.
+#define HIDKeypad_I 12
+/// Key code for 'j' and 'J'.
+#define HIDKeypad_J 13
+/// Key code for 'k' and 'K'.
+#define HIDKeypad_K 14
+/// Key code for 'l' and 'L'.
+#define HIDKeypad_L 15
+/// Key code for 'm' and 'M'.
+#define HIDKeypad_M 16
+/// Key code for 'n' and 'N'.
+#define HIDKeypad_N 17
+/// Key code for 'o' and 'O'.
+#define HIDKeypad_O 18
+/// Key code for 'p' and 'P'.
+#define HIDKeypad_P 19
+/// Key code for 'q' and 'Q'.
+#define HIDKeypad_Q 20
+/// Key code for 'r' and 'R'.
+#define HIDKeypad_R 21
+/// Key code for 's' and 'S'.
+#define HIDKeypad_S 22
+/// Key code for 't' and 'T'.
+#define HIDKeypad_T 23
+/// Key code for 'u' and 'U'.
+#define HIDKeypad_U 24
+/// Key code for 'v' and 'V'.
+#define HIDKeypad_V 25
+/// Key code for 'w' and 'W'.
+#define HIDKeypad_W 26
+/// Key code for 'x' and 'X'.
+#define HIDKeypad_X 27
+/// Key code for 'y' and 'Y'.
+#define HIDKeypad_Y 28
+/// Key code for 'z' and 'Z'.
+#define HIDKeypad_Z 29
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Numeric Keys"
+/// ...
+///
+/// !Keys
+/// - HIDKeypad_1
+/// - HIDKeypad_2
+/// - HIDKeypad_3
+/// - HIDKeypad_4
+/// - HIDKeypad_5
+/// - HIDKeypad_6
+/// - HIDKeypad_7
+/// - HIDKeypad_8
+/// - HIDKeypad_9
+/// - HIDKeypad_0
+
+/// Key code for '1' and '!'.
+#define HIDKeypad_1 30
+/// Key code for '2' and '@'.
+#define HIDKeypad_2 31
+/// Key code for '3' and '#'.
+#define HIDKeypad_3 32
+/// Key code for '4' and '$'.
+#define HIDKeypad_4 33
+/// Key code for '5' and '%'.
+#define HIDKeypad_5 34
+/// Key code for '6' and '^'.
+#define HIDKeypad_6 35
+/// Key code for '7' and '&'.
+#define HIDKeypad_7 36
+/// Key code for '8' and '*'.
+#define HIDKeypad_8 37
+/// Key code for '9' and '('.
+#define HIDKeypad_9 38
+/// Key code for '0' and ')'.
+#define HIDKeypad_0 39
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Special Keys"
+/// ...
+///
+/// !Keys
+/// - HIDKeypad_ENTER
+/// - HIDKeypad_ESCAPE
+/// - HIDKeypad_BACKSPACE
+/// - HIDKeypad_TAB
+/// - HIDKeypad_SPACEBAR
+/// - HIDKeypad_PRINTSCREEN
+/// - HIDKeypad_SCROLLLOCK
+/// - HIDKeypad_NUMLOCK
+
+/// Enter key code.
+#define HIDKeypad_ENTER 40
+/// Escape key code.
+#define HIDKeypad_ESCAPE 41
+/// Backspace key code.
+#define HIDKeypad_BACKSPACE 42
+/// Tab key code.
+#define HIDKeypad_TAB 43
+/// Spacebar key code.
+#define HIDKeypad_SPACEBAR 44
+/// Printscreen key code.
+#define HIDKeypad_PRINTSCREEN 70
+/// Scroll lock key code.
+#define HIDKeypad_SCROLLLOCK 71
+/// Num lock key code.
+#define HIDKeypad_NUMLOCK 83
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Modified Keys"
+/// ...
+///
+/// !Keys
+/// - HIDKeypad_LEFTCONTROL
+/// - HIDKeypad_LEFTSHIFT
+/// - HIDKeypad_LEFTALT
+/// - HIDKeypad_LEFTGUI
+/// - HIDKeypad_RIGHTCONTROL
+/// - HIDKeypad_RIGHTSHIFT
+/// - HIDKeypad_RIGHTALT
+/// - HIDKeypad_RIGHTGUI
+
+/// Key code for the left 'Control' key.
+#define HIDKeypad_LEFTCONTROL 224
+/// Key code for the left 'Shift' key.
+#define HIDKeypad_LEFTSHIFT 225
+/// Key code for the left 'Alt' key.
+#define HIDKeypad_LEFTALT 226
+/// Key code for the left 'GUI' (e.g. Windows) key.
+#define HIDKeypad_LEFTGUI 227
+/// Key code for the right 'Control' key.
+#define HIDKeypad_RIGHTCONTROL 228
+/// Key code for the right 'Shift' key.
+#define HIDKeypad_RIGHTSHIFT 229
+/// Key code for the right 'Alt' key.
+#define HIDKeypad_RIGHTALT 230
+/// Key code for the right 'GUI' key.
+#define HIDKeypad_RIGHTGUI 231
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Error Codes"
+/// ...
+///
+/// !Codes
+/// - HIDKeypad_ERRORROLLOVER
+/// - HIDKeypad_POSTFAIL
+/// - HIDKeypad_ERRORUNDEFINED
+
+/// Indicates that too many keys have been pressed at the same time.
+#define HIDKeypad_ERRORROLLOVER 1
+/// ?
+#define HIDKeypad_POSTFAIL 2
+/// Indicates an undefined error.
+#define HIDKeypad_ERRORUNDEFINED 3
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+extern unsigned char HIDKeypad_IsModifierKey(unsigned char key);
+
+#endif //#ifndef HIDKEYPAD_H
+
diff --git a/at91lib/usb/common/hid/HIDLeds.h b/at91lib/usb/common/hid/HIDLeds.h
new file mode 100644
index 0000000..22ee54d
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDLeds.h
@@ -0,0 +1,79 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+ !!!Purpose
+
+ Definition for the HID LEDs usage page.
+
+ !!!Usage
+
+ Uses the constants defined in this header file when declaring a Report
+ descriptor which references the LEDs usage page.
+*/
+
+#ifndef HIDLEDS_H
+#define HIDLEDS_H
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID LEDs Page ID"
+/// This page lists the page ID of the HID LEDs usage page.
+///
+/// !ID
+/// - HIDLeds_PAGEID
+
+/// ID of the HID LEDs usage page.
+#define HIDLeds_PAGEID 0x08
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID LEDs Usages"
+/// This page lists the Usages of the HID LEDs.
+///
+/// !Usages
+/// - HIDLeds_NUMLOCK
+/// - HIDLeds_CAPSLOCK
+/// - HIDLeds_SCROLLLOCK
+
+/// Num lock LED usage.
+#define HIDLeds_NUMLOCK 0x01
+/// Caps lock LED usage.
+#define HIDLeds_CAPSLOCK 0x02
+/// Scroll lock LED usage.
+#define HIDLeds_SCROLLLOCK 0x03
+//------------------------------------------------------------------------------
+
+#endif //#ifndef HIDLEDS_H
+
diff --git a/at91lib/usb/common/hid/HIDReport.h b/at91lib/usb/common/hid/HIDReport.h
new file mode 100644
index 0000000..ec02ded
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDReport.h
@@ -0,0 +1,231 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+ !!!Purpose
+
+ Definitions used when declaring an HID report descriptor.
+
+ !!!Usage
+
+ Use the definitions provided here when declaring a report descriptor,
+ which shall be an unsigned char array.
+*/
+
+#ifndef HIDREPORT_H
+#define HIDREPORT_H
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Main Item Tags"
+/// This page lists the Main Item Tags defined for HID %device.
+/// ( HID Spec. 6.2.2 )
+///
+/// !Tags
+/// - HIDReport_INPUT
+/// - HIDReport_OUPUT
+/// - HIDReport_FEATURE
+/// - HIDReport_COLLECTION
+/// - HIDReport_ENDCOLLECTION
+
+/// Input item.
+#define HIDReport_INPUT 0x80
+/// Output item.
+#define HIDReport_OUTPUT 0x90
+/// Feature item.
+#define HIDReport_FEATURE 0xB0
+/// Collection item.
+#define HIDReport_COLLECTION 0xA0
+/// End of collection item.
+#define HIDReport_ENDCOLLECTION 0xC0
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Items for Data Fields"
+/// This page lists defintions for HID Input, Output and Feature items that
+/// are used to create the data fields within a report.
+/// ( HID Spec. 6.2.2.5 )
+///
+/// !Items
+/// - HIDReport_CONSTANT
+/// - HIDReport_VARIABLE
+/// - HIDReport_RELATIVE
+/// - HIDReport_WRAP
+/// - HIDReport_NONLINEAR
+/// - HIDReport_NOPREFERRED
+/// - HIDReport_NULLSTATE
+/// - HIDReport_VOLATILE
+/// - HIDReport_BUFFEREDBYTES
+
+/// The report value is constant (vs. variable).
+#define HIDReport_CONSTANT (1 << 0)
+/// Data reported is a variable (vs. array).
+#define HIDReport_VARIABLE (1 << 1)
+/// Data is relative (vs. absolute).
+#define HIDReport_RELATIVE (1 << 2)
+/// Value rolls over when it reach a maximum/minimum.
+#define HIDReport_WRAP (1 << 3)
+/// Indicates that the data reported has been processed and is no longuer
+/// linear with the original measurements.
+#define HIDReport_NONLINEAR (1 << 4)
+/// Device has no preferred state to which it automatically returns.
+#define HIDReport_NOPREFERRED (1 << 5)
+/// Device has a null state, in which it does not report meaningful
+/// information.
+#define HIDReport_NULLSTATE (1 << 6)
+/// Indicates data can change without the host intervention.
+#define HIDReport_VOLATILE (1 << 7)
+/// Indicates the device produces a fixed-length stream of bytes.
+#define HIDReport_BUFFEREDBYTES (1 << 8)
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Collection Items"
+/// This page lists definitions for HID Collection Items.
+/// ( HID Spec. 6.2.2.6 )
+///
+/// !Items
+/// - HIDReport_COLLECTION_PHYSICAL
+/// - HIDReport_COLLECTION_APPLICATION
+/// - HIDReport_COLLECTION_LOGICAL
+/// - HIDReport_COLLECTION_REPORT
+/// - HIDReport_COLLECTION_NAMEDARRAY
+/// - HIDReport_COLLECTION_USAGESWITCH
+/// - HIDReport_COLLECTION_USAGEMODIFIER
+
+/// Physical collection.
+#define HIDReport_COLLECTION_PHYSICAL 0x00
+/// Application collection.
+#define HIDReport_COLLECTION_APPLICATION 0x01
+/// Logical collection.
+#define HIDReport_COLLECTION_LOGICAL 0x02
+/// Report collection.
+#define HIDReport_COLLECTION_REPORT 0x03
+/// Named array collection.
+#define HIDReport_COLLECTION_NAMEDARRAY 0x04
+/// Usage switch collection.
+#define HIDReport_COLLECTION_USAGESWITCH 0x05
+/// Usage modifier collection
+#define HIDReport_COLLECTION_USAGEMODIFIER 0x06
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Global Items"
+/// This page lists HID Global Items.
+/// ( HID Spec. 6.2.2.7 )
+///
+/// !Items
+/// - HIDReport_GLOBAL_USAGEPAGE
+/// - HIDReport_GLOBAL_LOGICALMINIMUM
+/// - HIDReport_GLOBAL_LOGICALMAXIMUM
+/// - HIDReport_GLOBAL_PHYSICALMINIMUM
+/// - HIDReport_GLOBAL_PHYSICALMAXIMUM
+/// - HIDReport_GLOBAL_UNITEXPONENT
+/// - HIDReport_GLOBAL_UNIT
+/// - HIDReport_GLOBAL_REPORTSIZE
+/// - HIDReport_GLOBAL_REPORTID
+/// - HIDReport_GLOBAL_REPORTCOUNT
+/// - HIDReport_GLOBAL_PUSH
+/// - HIDReport_GLOBAL_POP
+
+/// Current usage page.
+#define HIDReport_GLOBAL_USAGEPAGE 0x04
+/// Minimum value that a variable or array item will report.
+#define HIDReport_GLOBAL_LOGICALMINIMUM 0x14
+/// Maximum value that a variable or array item will report.
+#define HIDReport_GLOBAL_LOGICALMAXIMUM 0x24
+/// Minimum value for the physical extent of a variable item.
+#define HIDReport_GLOBAL_PHYSICALMINIMUM 0x34
+/// Maximum value for the physical extent of a variable item.
+#define HIDReport_GLOBAL_PHYSICALMAXIMUM 0x44
+/// Value of the unit exponent in base 10.
+#define HIDReport_GLOBAL_UNITEXPONENT 0x54
+/// Unit values.
+#define HIDReport_GLOBAL_UNIT 0x64
+/// Size of the report fields in bits.
+#define HIDReport_GLOBAL_REPORTSIZE 0x74
+/// Specifies the report ID.
+#define HIDReport_GLOBAL_REPORTID 0x84
+/// Number of data fields for an item.
+#define HIDReport_GLOBAL_REPORTCOUNT 0x94
+/// Places a copy of the global item state table on the stack.
+#define HIDReport_GLOBAL_PUSH 0xA4
+/// Replaces the item state table with the top structure from the stack.
+#define HIDReport_GLOBAL_POP 0xB4
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Local Items"
+/// This page lists definitions for HID Local Items.
+///
+/// !Items
+/// - HIDReport_LOCAL_USAGE
+/// - HIDReport_LOCAL_USAGEMINIMUM
+/// - HIDReport_LOCAL_USAGEMAXIMUM
+/// - HIDReport_LOCAL_DESIGNATORINDEX
+/// - HIDReport_LOCAL_DESIGNATORMINIMUM
+/// - HIDReport_LOCAL_DESIGNATORMAXIMUM
+/// - HIDReport_LOCAL_STRINGINDEX
+/// - HIDReport_LOCAL_STRINGMINIMUM
+/// - HIDReport_LOCAL_STRINGMAXIMUM
+/// - HIDReport_LOCAL_DELIMITER
+
+/// Suggested usage for an item or collection.
+#define HIDReport_LOCAL_USAGE 0x08
+/// Defines the starting usage associated with an array or bitmap.
+#define HIDReport_LOCAL_USAGEMINIMUM 0x18
+/// Defines the ending usage associated with an array or bitmap.
+#define HIDReport_LOCAL_USAGEMAXIMUM 0x28
+/// Determines the body part used for a control.
+#define HIDReport_LOCAL_DESIGNATORINDEX 0x38
+/// Defines the index of the starting designator associated with an array or
+/// bitmap.
+#define HIDReport_LOCAL_DESIGNATORMINIMUM 0x48
+/// Defines the index of the ending designator associated with an array or
+/// bitmap.
+#define HIDReport_LOCAL_DESIGNATORMAXIMUM 0x58
+/// String index for a string descriptor.
+#define HIDReport_LOCAL_STRINGINDEX 0x78
+/// Specifies the first string index when assigning a group of sequential
+/// strings to controls in an array or bitmap.
+#define HIDReport_LOCAL_STRINGMINIMUM 0x88
+/// Specifies the last string index when assigning a group of sequential
+/// strings to controls in an array or bitmap.
+#define HIDReport_LOCAL_STRINGMAXIMUM 0x98
+/// Defines the beginning or end of a set of local items.
+#define HIDReport_LOCAL_DELIMITER 0xA8
+//------------------------------------------------------------------------------
+
+#endif //#ifndef HIDREPORT_H
+
diff --git a/at91lib/usb/common/hid/HIDReportRequest.c b/at91lib/usb/common/hid/HIDReportRequest.c
new file mode 100644
index 0000000..3e9d2e8
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDReportRequest.c
@@ -0,0 +1,68 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/*
+ Title: HIDReportRequest implementation
+
+ About: Purpose
+ Implementation of the HIDReportRequest methods.
+*/
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include "HIDReportRequest.h"
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// Indicates the type of report targetted by a SET_REPORT or GET_REPORT
+/// request.
+/// \param request Pointer to a USBGenericRequest instance.
+/// \return Requested report type (see "HID Report Types").
+//------------------------------------------------------------------------------
+unsigned char HIDReportRequest_GetReportType(const USBGenericRequest *request)
+{
+ return ((USBGenericRequest_GetValue(request) >> 8) & 0xFF);
+}
+
+//------------------------------------------------------------------------------
+/// Indicates the ID of the report targetted by a SET_REPORT or GET_REPORT
+/// request. This value should be 0 if report IDs are not used.
+/// \param request Pointer to a USBGenericRequest instance.
+/// \return Requested report ID.
+//------------------------------------------------------------------------------
+unsigned char HIDReportRequest_GetReportId(const USBGenericRequest *request)
+{
+ return (USBGenericRequest_GetValue(request) & 0xFF);
+}
+
diff --git a/at91lib/usb/common/hid/HIDReportRequest.h b/at91lib/usb/common/hid/HIDReportRequest.h
new file mode 100644
index 0000000..75ea379
--- /dev/null
+++ b/at91lib/usb/common/hid/HIDReportRequest.h
@@ -0,0 +1,86 @@
+/* ----------------------------------------------------------------------------
+ * ATMEL Microcontroller Software Support
+ * ----------------------------------------------------------------------------
+ * Copyright (c) 2008, Atmel Corporation
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the disclaimer below.
+ *
+ * Atmel's name may not be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
+ * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * ----------------------------------------------------------------------------
+ */
+
+/**
+ \unit
+
+ !!!Purpose
+
+ Definition of a class for manipulating HID-specific GET_REPORT and
+ SET_REPORT requests.
+
+ !!!Usage
+
+ -# Receive a GET_REPORT or SET_REPORT request from the host.
+ -# Retrieve the report type using HIDReportRequest_GetReportType.
+ -# Retrieve the report ID using HIDReportRequest_GetReportId.
+*/
+
+#ifndef HIDREPORTREQUEST_H
+#define HIDREPORTREQUEST_H
+
+//------------------------------------------------------------------------------
+// Headers
+//------------------------------------------------------------------------------
+
+#include <usb/common/core/USBGenericRequest.h>
+
+//------------------------------------------------------------------------------
+// Definitions
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+/// \page "HID Report Types"
+/// This page lists the types for USB HID Reports.
+///
+/// !Types
+/// - HIDReportRequest_INPUT
+/// - HIDReportRequest_OUTPUT
+/// - HIDReportRequest_FEATURE
+
+/// Input report.
+#define HIDReportRequest_INPUT 1
+/// Output report.
+#define HIDReportRequest_OUTPUT 2
+/// Feature report.
+#define HIDReportRequest_FEATURE 3
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+// Exported functions
+//------------------------------------------------------------------------------
+
+extern unsigned char HIDReportRequest_GetReportType(
+ const USBGenericRequest *request);
+
+extern unsigned char HIDReportRequest_GetReportId(
+ const USBGenericRequest *request);
+
+#endif //#ifndef HIDREPORTREQUEST_H
+
personal git repositories of Harald Welte. Your mileage may vary