From af8603411cc2c927de581bef0b9213b0a7b77cc1 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 31 Jul 2011 10:22:41 +0200 Subject: import usb-device-composide-cdchid-project --- .../cdc/CDCAbstractControlManagementDescriptor.h | 104 ++++++++ .../usb/common/cdc/CDCCallManagementDescriptor.h | 97 ++++++++ .../cdc/CDCCommunicationInterfaceDescriptor.h | 65 +++++ .../usb/common/cdc/CDCDataInterfaceDescriptor.h | 65 +++++ at91lib/usb/common/cdc/CDCDeviceDescriptor.h | 64 +++++ at91lib/usb/common/cdc/CDCGenericDescriptor.h | 91 +++++++ at91lib/usb/common/cdc/CDCGenericRequest.h | 63 +++++ at91lib/usb/common/cdc/CDCHeaderDescriptor.h | 77 ++++++ at91lib/usb/common/cdc/CDCLineCoding.c | 78 ++++++ at91lib/usb/common/cdc/CDCLineCoding.h | 136 ++++++++++ .../usb/common/cdc/CDCSetControlLineStateRequest.c | 84 +++++++ .../usb/common/cdc/CDCSetControlLineStateRequest.h | 59 +++++ at91lib/usb/common/cdc/CDCUnionDescriptor.h | 79 ++++++ .../core/USBInterfaceAssociationDescriptor.h | 86 +++++++ at91lib/usb/common/hid/HIDDescriptor.h | 93 +++++++ at91lib/usb/common/hid/HIDDeviceDescriptor.h | 68 +++++ at91lib/usb/common/hid/HIDGenericDescriptor.h | 63 +++++ at91lib/usb/common/hid/HIDGenericDesktop.h | 98 ++++++++ at91lib/usb/common/hid/HIDGenericRequest.h | 75 ++++++ at91lib/usb/common/hid/HIDIdleRequest.c | 56 +++++ at91lib/usb/common/hid/HIDIdleRequest.h | 68 +++++ at91lib/usb/common/hid/HIDInterfaceDescriptor.h | 77 ++++++ at91lib/usb/common/hid/HIDKeypad.c | 56 +++++ at91lib/usb/common/hid/HIDKeypad.h | 276 +++++++++++++++++++++ at91lib/usb/common/hid/HIDLeds.h | 79 ++++++ at91lib/usb/common/hid/HIDReport.h | 231 +++++++++++++++++ at91lib/usb/common/hid/HIDReportRequest.c | 68 +++++ at91lib/usb/common/hid/HIDReportRequest.h | 86 +++++++ 28 files changed, 2542 insertions(+) create mode 100644 at91lib/usb/common/cdc/CDCAbstractControlManagementDescriptor.h create mode 100644 at91lib/usb/common/cdc/CDCCallManagementDescriptor.h create mode 100644 at91lib/usb/common/cdc/CDCCommunicationInterfaceDescriptor.h create mode 100644 at91lib/usb/common/cdc/CDCDataInterfaceDescriptor.h create mode 100644 at91lib/usb/common/cdc/CDCDeviceDescriptor.h create mode 100644 at91lib/usb/common/cdc/CDCGenericDescriptor.h create mode 100644 at91lib/usb/common/cdc/CDCGenericRequest.h create mode 100644 at91lib/usb/common/cdc/CDCHeaderDescriptor.h create mode 100644 at91lib/usb/common/cdc/CDCLineCoding.c create mode 100644 at91lib/usb/common/cdc/CDCLineCoding.h create mode 100644 at91lib/usb/common/cdc/CDCSetControlLineStateRequest.c create mode 100644 at91lib/usb/common/cdc/CDCSetControlLineStateRequest.h create mode 100644 at91lib/usb/common/cdc/CDCUnionDescriptor.h create mode 100644 at91lib/usb/common/core/USBInterfaceAssociationDescriptor.h create mode 100644 at91lib/usb/common/hid/HIDDescriptor.h create mode 100644 at91lib/usb/common/hid/HIDDeviceDescriptor.h create mode 100644 at91lib/usb/common/hid/HIDGenericDescriptor.h create mode 100644 at91lib/usb/common/hid/HIDGenericDesktop.h create mode 100644 at91lib/usb/common/hid/HIDGenericRequest.h create mode 100644 at91lib/usb/common/hid/HIDIdleRequest.c create mode 100644 at91lib/usb/common/hid/HIDIdleRequest.h create mode 100644 at91lib/usb/common/hid/HIDInterfaceDescriptor.h create mode 100644 at91lib/usb/common/hid/HIDKeypad.c create mode 100644 at91lib/usb/common/hid/HIDKeypad.h create mode 100644 at91lib/usb/common/hid/HIDLeds.h create mode 100644 at91lib/usb/common/hid/HIDReport.h create mode 100644 at91lib/usb/common/hid/HIDReportRequest.c create mode 100644 at91lib/usb/common/hid/HIDReportRequest.h (limited to 'at91lib/usb/common') diff --git a/at91lib/usb/common/cdc/CDCAbstractControlManagementDescriptor.h b/at91lib/usb/common/cdc/CDCAbstractControlManagementDescriptor.h new file mode 100644 index 0000000..943204c --- /dev/null +++ b/at91lib/usb/common/cdc/CDCAbstractControlManagementDescriptor.h @@ -0,0 +1,104 @@ +/* ---------------------------------------------------------------------------- + * 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 CDC abstract control management + descriptors. + + !!!Usage + + Should be included in a list of USB configuration descriptors. +*/ + +#ifndef CDCABSTRACTCONTROLMANAGEMENTDESCRIPTOR_H +#define CDCABSTRACTCONTROLMANAGEMENTDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "CDC ACM Capabilities" +/// This page lists the capabilities of the CDC ACM. +/// +/// !Capabilities +/// - CDCAbstractControlManagementDescriptor_COMMFEATURE +/// - CDCAbstractControlManagementDescriptor_LINE +/// - CDCAbstractControlManagementDescriptor_SENDBREAK +/// - CDCAbstractControlManagementDescriptor_NETWORKCONNECTION + +/// Device supports the request combination of SetCommFeature, ClearCommFeature +/// and GetCommFeature. +#define CDCAbstractControlManagementDescriptor_COMMFEATURE (1 << 0) +/// Device supports the request combination of SetLineCoding, GetLineCoding and +/// SetControlLineState. +#define CDCAbstractControlManagementDescriptor_LINE (1 << 1) +/// Device supports the SendBreak request. +#define CDCAbstractControlManagementDescriptor_SENDBREAK (1 << 2) +/// Device supports the NetworkConnection notification. +#define CDCAbstractControlManagementDescriptor_NETWORKCONNECTION (1 << 3) +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// Describes the command supported by the communication interface class +/// with the Abstract Control Model subclass code. +//------------------------------------------------------------------------------ +typedef struct { + + /// Size of this descriptor in bytes. + unsigned char bFunctionLength; + /// Descriptor type (CDCDescriptors_INTERFACE). + unsigned char bDescriptorType; + /// Descriptor subtype (CDCDescriptors_ABSTRACTCONTROLMANAGEMENT). + unsigned char bDescriptorSubtype; + /// Configuration capabilities. + /// \sa "CDC ACM Capabilities". + unsigned char bmCapabilities; + +} __attribute__ ((packed)) CDCAbstractControlManagementDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef CDCABSTRACTCONTROLMANAGEMENTDESCRIPTOR_H + diff --git a/at91lib/usb/common/cdc/CDCCallManagementDescriptor.h b/at91lib/usb/common/cdc/CDCCallManagementDescriptor.h new file mode 100644 index 0000000..191ff61 --- /dev/null +++ b/at91lib/usb/common/cdc/CDCCallManagementDescriptor.h @@ -0,0 +1,97 @@ +/* ---------------------------------------------------------------------------- + * 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 managing CDC call management descriptors. + + !!!Usage + + Should be included in a list of configuration descriptors for a USB + device. +*/ + +#ifndef CDCCALLMANAGEMENTDESCRIPTOR_H +#define CDCCALLMANAGEMENTDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "CDC CallManagement Capabilities" +/// This page lists CDC CallManagement Capabilities. +/// +/// !Capabilities +/// - CDCCallManagementDescriptor_SELFCALLMANAGEMENT +/// - CDCCallManagementDescriptor_DATACALLMANAGEMENT + +/// Device handles call management itself. +#define CDCCallManagementDescriptor_SELFCALLMANAGEMENT (1 << 0) +/// Device can exchange call management information over a Data class interface. +#define CDCCallManagementDescriptor_DATACALLMANAGEMENT (1 << 1) +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// Describes the processing of calls for the communication class interface. +//------------------------------------------------------------------------------ +typedef struct { + + /// Size of this descriptor in bytes. + unsigned char bFunctionLength; + /// Descriptor type (CDCDescriptors_INTERFACE). + unsigned char bDescriptorType; + /// Descriptor sub-type (CDCDescriptors_CALLMANAGEMENT). + unsigned char bDescriptorSubtype; + /// Configuration capabilities ("CDC CallManagement Capabilities"). + unsigned char bmCapabilities; + /// Interface number of the data class interface used for call management + /// (optional). + unsigned char bDataInterface; + +} __attribute__ ((packed)) CDCCallManagementDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef CDCCALLMANAGEMENTDESCRIPTOR_H + diff --git a/at91lib/usb/common/cdc/CDCCommunicationInterfaceDescriptor.h b/at91lib/usb/common/cdc/CDCCommunicationInterfaceDescriptor.h new file mode 100644 index 0000000..aa13915 --- /dev/null +++ b/at91lib/usb/common/cdc/CDCCommunicationInterfaceDescriptor.h @@ -0,0 +1,65 @@ +/* ---------------------------------------------------------------------------- + * 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 several constants used when declaring a CDC communication + class interface descriptor. +*/ + +#ifndef CDCCOMMUNICATIONINTERFACEDESCRIPTOR_H +#define CDCCOMMUNICATIONINTERFACEDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "CDC Communication Interface Values" +/// This page lists the values for CDC Communication Interface Descriptor. +/// +/// !Values +/// - CDCCommunicationInterfaceDescriptor_CLASS +/// - CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL +/// - CDCCommunicationInterfaceDescriptor_NOPROTOCOL + +/// Interface class code for a CDC communication class interface. +#define CDCCommunicationInterfaceDescriptor_CLASS 0x02 +/// Interface subclass code for an Abstract Control Model interface descriptor. +#define CDCCommunicationInterfaceDescriptor_ABSTRACTCONTROLMODEL 0x02 +/// Interface protocol code when a CDC communication interface does not +/// implemenent any particular protocol. +#define CDCCommunicationInterfaceDescriptor_NOPROTOCOL 0x00 +//------------------------------------------------------------------------------ + +#endif //#ifndef CDCCOMMUNICATIONINTERFACEDESCRIPTOR_H + diff --git a/at91lib/usb/common/cdc/CDCDataInterfaceDescriptor.h b/at91lib/usb/common/cdc/CDCDataInterfaceDescriptor.h new file mode 100644 index 0000000..640f8dc --- /dev/null +++ b/at91lib/usb/common/cdc/CDCDataInterfaceDescriptor.h @@ -0,0 +1,65 @@ +/* ---------------------------------------------------------------------------- + * 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 used when declaring a CDC data class interface + descriptor. +*/ + +#ifndef CDCDATAINTERFACEDESCRIPTOR_H +#define CDCDATAINTERFACEDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "CDC Data Interface Values" +/// This page lists the values for CDC Data Interface Descriptor. +/// +/// !Values +/// - CDCDataInterfaceDescriptor_CLASS +/// - CDCDataInterfaceDescriptor_SUBCLASS +/// - CDCDataInterfaceDescriptor_NOPROTOCOL + +/// Interface class code for a data class interface. +#define CDCDataInterfaceDescriptor_CLASS 0x0A +/// Interface subclass code for a data class interface. +#define CDCDataInterfaceDescriptor_SUBCLASS 0x00 +/// Protocol code for a data class interface which does not implement any +/// particular protocol. +#define CDCDataInterfaceDescriptor_NOPROTOCOL 0x00 +//------------------------------------------------------------------------------ + +#endif //#ifndef CDCDATAINTERFACEDESCRIPTOR_H + diff --git a/at91lib/usb/common/cdc/CDCDeviceDescriptor.h b/at91lib/usb/common/cdc/CDCDeviceDescriptor.h new file mode 100644 index 0000000..b1bc177 --- /dev/null +++ b/at91lib/usb/common/cdc/CDCDeviceDescriptor.h @@ -0,0 +1,64 @@ +/* ---------------------------------------------------------------------------- + * 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 several constants used when declaring USB CDC device + descriptors. +*/ + +#ifndef CDCDEVICEDESCRIPTOR_H +#define CDCDEVICEDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "CDC Device Descriptor Values" +/// This page lists the values for CDC Device Descriptor. +/// +/// !Values +/// - CDCDeviceDescriptor_CLASS +/// - CDCDeviceDescriptor_SUBCLASS +/// - CDCDeviceDescriptor_PROTOCOL + +/// Device class code when using the CDC class. +#define CDCDeviceDescriptor_CLASS 0x02 +/// Device subclass code when using the CDC class. +#define CDCDeviceDescriptor_SUBCLASS 0x00 +/// Device protocol code when using the CDC class. +#define CDCDeviceDescriptor_PROTOCOL 0x00 +//------------------------------------------------------------------------------ + +#endif //#ifndef CDCDEVICEDESCRIPTOR_H + diff --git a/at91lib/usb/common/cdc/CDCGenericDescriptor.h b/at91lib/usb/common/cdc/CDCGenericDescriptor.h new file mode 100644 index 0000000..3d93656 --- /dev/null +++ b/at91lib/usb/common/cdc/CDCGenericDescriptor.h @@ -0,0 +1,91 @@ +/* ---------------------------------------------------------------------------- + * 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 several constants for declaring CDC descriptors. +*/ + +#ifndef CDCGENERICDESCRIPTOR_H +#define CDCGENERICDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "CDC Specification Release Numbers" +/// This page list the CDC Spec. Release Numbers. +/// +/// !Numbers +/// - CDCGenericDescriptor_CDC1_10 + +/// Identify CDC specification version 1.10. +#define CDCGenericDescriptor_CDC1_10 0x0110 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "CDC Descriptro Types" +/// This page lists CDC descriptor types. +/// +/// !Types +/// - CDCGenericDescriptor_INTERFACE +/// - CDCGenericDescriptor_ENDPOINT + +///Indicates that a CDC descriptor applies to an interface. +#define CDCGenericDescriptor_INTERFACE 0x24 +/// Indicates that a CDC descriptor applies to an endpoint. +#define CDCGenericDescriptor_ENDPOINT 0x25 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "CDC Descriptor Subtypes" +/// This page lists CDC descriptor sub types +/// +/// !Types +/// - CDCGenericDescriptor_HEADER +/// - CDCGenericDescriptor_CALLMANAGEMENT +/// - CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT +/// - CDCGenericDescriptor_UNION + +/// Header functional descriptor subtype. +#define CDCGenericDescriptor_HEADER 0x00 +/// Call management functional descriptor subtype. +#define CDCGenericDescriptor_CALLMANAGEMENT 0x01 +/// Abstract control management descriptor subtype. +#define CDCGenericDescriptor_ABSTRACTCONTROLMANAGEMENT 0x02 +/// Union descriptor subtype. +#define CDCGenericDescriptor_UNION 0x06 +//------------------------------------------------------------------------------ + +#endif //#ifndef CDCGENERICDESCRIPTOR_H + diff --git a/at91lib/usb/common/cdc/CDCGenericRequest.h b/at91lib/usb/common/cdc/CDCGenericRequest.h new file mode 100644 index 0000000..d6abd0b --- /dev/null +++ b/at91lib/usb/common/cdc/CDCGenericRequest.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 + + Various definitions used for characterizing USB CDC requests. +*/ + +#ifndef CDCGENERICREQUEST_H +#define CDCGENERICREQUEST_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "CDC Request Codes" +/// This page lists USB CDC Request Codes. +/// +/// !Codes +/// - CDCGenericRequest_SETLINECODING +/// - CDCGenericRequest_GETLINECODING +/// - CDCGenericRequest_SETCONTROLLINESTATE + +/// SetLineCoding request code. +#define CDCGenericRequest_SETLINECODING 0x20 +/// GetLineCoding request code. +#define CDCGenericRequest_GETLINECODING 0x21 +/// SetControlLineState request code. +#define CDCGenericRequest_SETCONTROLLINESTATE 0x22 +//------------------------------------------------------------------------------ + +#endif //#ifndef CDCGENERICREQUEST_H + diff --git a/at91lib/usb/common/cdc/CDCHeaderDescriptor.h b/at91lib/usb/common/cdc/CDCHeaderDescriptor.h new file mode 100644 index 0000000..b04926f --- /dev/null +++ b/at91lib/usb/common/cdc/CDCHeaderDescriptor.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 + + Definition of the CDCHeaderDescriptor class. + + !!!Usage + + Should be included in a USB configuration descriptor. +*/ + +#ifndef CDCHEADERDESCRIPTOR_H +#define CDCHEADERDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// Marks the beginning of the concatenated set of functional descriptors +/// for the interface. +//------------------------------------------------------------------------------ +typedef struct { + + /// Size of this descriptor in bytes. + unsigned char bFunctionLength; + /// Descriptor type (CDCDescriptors_INTERFACE). + unsigned char bDescriptorType; + /// Descriptor sub-type (CDCDescriptors_HEADER). + unsigned char bDescriptorSubtype; + /// USB CDC specification release number. + unsigned short bcdCDC; + +} __attribute__ ((packed)) CDCHeaderDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef CDCHEADERDESCRIPTOR_H + + diff --git a/at91lib/usb/common/cdc/CDCLineCoding.c b/at91lib/usb/common/cdc/CDCLineCoding.c new file mode 100644 index 0000000..4223fec --- /dev/null +++ b/at91lib/usb/common/cdc/CDCLineCoding.c @@ -0,0 +1,78 @@ +/* ---------------------------------------------------------------------------- + * 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: CDCLineCoding + + About: Purpose + Implementation of the CDCLineCoding class. +*/ + +//------------------------------------------------------------------------------ +// Headers +//------------------------------------------------------------------------------ + +#include "CDCLineCoding.h" +#include + +//------------------------------------------------------------------------------ +// Exported functions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// Initializes the bitrate, number of stop bits, parity checking and +/// number of data bits of a CDCLineCoding object. +/// \param lineCoding Pointer to a CDCLineCoding instance. +/// \param bitrate Bitrate of the virtual COM connection. +/// \param stopbits Number of stop bits ("CDC LineCoding StopBits"). +/// \param parity Parity check type ("CDC LineCoding ParityChecking"). +/// \param databits Number of data bits. +//------------------------------------------------------------------------------ +void CDCLineCoding_Initialize(CDCLineCoding *lineCoding, + unsigned int bitrate, + unsigned char stopbits, + unsigned char parity, + unsigned char databits) +{ + ASSERT(stopbits <= CDCLineCoding_TWOSTOPBITS, + "CDCLineCoding_Initialize: Invalid stopbits value (%d)\n\r", + stopbits); + ASSERT(parity <= CDCLineCoding_SPACEPARITY, + "CDCLineCoding_Initialize: Invalid parity value (%d)\n\r", + parity); + ASSERT(((databits >= 5) && (databits <= 8)) || (databits == 16), + "CDCLineCoding_Initialize: Invalid databits value (%d)\n\r", + databits); + + lineCoding->dwDTERate = bitrate; + lineCoding->bCharFormat = stopbits; + lineCoding->bParityType = parity; + lineCoding->bDataBits = databits; +} + diff --git a/at91lib/usb/common/cdc/CDCLineCoding.h b/at91lib/usb/common/cdc/CDCLineCoding.h new file mode 100644 index 0000000..dfe3c10 --- /dev/null +++ b/at91lib/usb/common/cdc/CDCLineCoding.h @@ -0,0 +1,136 @@ +/* ---------------------------------------------------------------------------- + * 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 + + Line coding structure used for by the CDC GetLineCoding and SetLineCoding + requests. + + !!!Usage + + -# Initialize a CDCLineCoding instance using CDCLineCoding_Initialize. + -# Send a CDCLineCoding object to the host in response to a GetLineCoding + request. + -# Receive a CDCLineCoding object from the host after a SetLineCoding + request. +*/ + +#ifndef CDCLINECODING_H +#define CDCLINECODING_H + +//------------------------------------------------------------------------------ +// Definitions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "CDC LineCoding StopBits" +/// This page lists Stop Bits for CDC Line Coding. +/// +/// !Stop bits +/// - CDCLineCoding_ONESTOPBIT +/// - CDCLineCoding_ONE5STOPBIT +/// - CDCLineCoding_TWOSTOPBITS + +/// The transmission protocol uses one stop bit. +#define CDCLineCoding_ONESTOPBIT 0 +/// The transmission protocol uses 1.5 stop bit. +#define CDCLineCoding_ONE5STOPBIT 1 +/// The transmissin protocol uses two stop bits. +#define CDCLineCoding_TWOSTOPBITS 2 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// \page "CDC LineCoding ParityCheckings" +/// This page lists Parity checkings for CDC Line Coding. +/// +/// !Parity checking +/// - CDCLineCoding_NOPARITY +/// - CDCLineCoding_ODDPARITY +/// - CDCLineCoding_EVENPARITY +/// - CDCLineCoding_MARKPARITY +/// - CDCLineCoding_SPACEPARITY + +/// No parity checking. +#define CDCLineCoding_NOPARITY 0 +/// Odd parity checking. +#define CDCLineCoding_ODDPARITY 1 +/// Even parity checking. +#define CDCLineCoding_EVENPARITY 2 +/// Mark parity checking. +#define CDCLineCoding_MARKPARITY 3 +/// Space parity checking. +#define CDCLineCoding_SPACEPARITY 4 +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// Format of the data returned when a GetLineCoding request is received. +//------------------------------------------------------------------------------ +typedef struct { + + /// Data terminal rate in bits per second. + unsigned int dwDTERate; + /// Number of stop bits. + /// \sa "CDC LineCoding StopBits". + char bCharFormat; + /// Type of parity checking used. + /// \sa "CDC LineCoding ParityCheckings". + char bParityType; + /// Number of data bits (5, 6, 7, 8 or 16). + char bDataBits; + +} __attribute__ ((packed)) CDCLineCoding; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +// Exported functions +//------------------------------------------------------------------------------ + +extern void CDCLineCoding_Initialize(CDCLineCoding *lineCoding, + unsigned int bitrate, + unsigned char stopbits, + unsigned char parity, + unsigned char databits); + +#endif //#ifndef CDCLINECODING_H + diff --git a/at91lib/usb/common/cdc/CDCSetControlLineStateRequest.c b/at91lib/usb/common/cdc/CDCSetControlLineStateRequest.c new file mode 100644 index 0000000..43079ca --- /dev/null +++ b/at91lib/usb/common/cdc/CDCSetControlLineStateRequest.c @@ -0,0 +1,84 @@ +/* ---------------------------------------------------------------------------- + * 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. + * ---------------------------------------------------------------------------- + */ + +/** + CDCSetControlLineStateRequest.c + + !!!Purpose + + Implementation of the CDCSetControlLineStateRequest class. +*/ + +//------------------------------------------------------------------------------ +// Headers +//------------------------------------------------------------------------------ + +#include "CDCSetControlLineStateRequest.h" + +//------------------------------------------------------------------------------ +// Exported functions +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +/// Notifies if the given request indicates that the DTE signal is present. +/// \param request Pointer to a USBGenericRequest instance. +/// \return 1 if the DTE signal is present, otherwise 0. +//------------------------------------------------------------------------------ +unsigned char CDCSetControlLineStateRequest_IsDtePresent( + const USBGenericRequest *request) +{ + if ((USBGenericRequest_GetValue(request) & 0x0001) != 0) { + + return 1; + } + else { + + return 0; + } +} + +//------------------------------------------------------------------------------ +/// Notifies if the given request indicates that the device carrier should +/// be activated. +/// \param request Pointer to a USBGenericRequest instance. +/// \return 1 is the device should activate its carrier, 0 otherwise. +//------------------------------------------------------------------------------ +unsigned char CDCSetControlLineStateRequest_ActivateCarrier( + const USBGenericRequest *request) +{ + if ((USBGenericRequest_GetValue(request) & 0x0002) != 0) { + + return 1; + } + else { + + return 0; + } +} + diff --git a/at91lib/usb/common/cdc/CDCSetControlLineStateRequest.h b/at91lib/usb/common/cdc/CDCSetControlLineStateRequest.h new file mode 100644 index 0000000..5d6c661 --- /dev/null +++ b/at91lib/usb/common/cdc/CDCSetControlLineStateRequest.h @@ -0,0 +1,59 @@ +/* ---------------------------------------------------------------------------- + * 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 SetControlLineState requests. +*/ + +#ifndef CDCSETCONTROLLINESTATE_H +#define CDCSETCONTROLLINESTATE_H + +//------------------------------------------------------------------------------ +// Headers +//------------------------------------------------------------------------------ + +#include + +//------------------------------------------------------------------------------ +// Exported functions +//------------------------------------------------------------------------------ + +extern unsigned char CDCSetControlLineStateRequest_IsDtePresent( + const USBGenericRequest *request); + + +extern unsigned char CDCSetControlLineStateRequest_ActivateCarrier( + const USBGenericRequest *request); + +#endif //#ifndef CDCSETCONTROLLINESTATE_H + diff --git a/at91lib/usb/common/cdc/CDCUnionDescriptor.h b/at91lib/usb/common/cdc/CDCUnionDescriptor.h new file mode 100644 index 0000000..0ba9eaa --- /dev/null +++ b/at91lib/usb/common/cdc/CDCUnionDescriptor.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 of a class for manipulating CDC union descriptors. + + !!!Usage + + Should be included in the list of USB descriptor used for a device + configuration. +*/ + +#ifndef CDCUNIONDESCRIPTOR_H +#define CDCUNIONDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +//------------------------------------------------------------------------------ +/// Describes the relationship between a group of interfaces that can +/// be considered to form a functional unit. +//------------------------------------------------------------------------------ +typedef struct { + + /// Size of the descriptor in bytes. + unsigned char bFunctionLength; + /// Descriptor type (CDCDescriptors_INTERFACE). + unsigned char bDescriptorType; + /// Descriptor subtype (CDCDescriptors_UNION). + unsigned char bDescriptorSubtype; + /// Number of the master interface for this union. + unsigned char bMasterInterface; + /// Number of the first slave interface for this union. + unsigned char bSlaveInterface0; + +} __attribute__ ((packed)) CDCUnionDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef CDCUNIONDESCRIPTOR_H + diff --git a/at91lib/usb/common/core/USBInterfaceAssociationDescriptor.h b/at91lib/usb/common/core/USBInterfaceAssociationDescriptor.h new file mode 100644 index 0000000..5f3dd21 --- /dev/null +++ b/at91lib/usb/common/core/USBInterfaceAssociationDescriptor.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. + * ---------------------------------------------------------------------------- + */ + +/** + * \page USBInterfaceAssociateDescriptor + * !!!Purpose + * + * Class for manipulating USB IAD descriptors. + * + * !!!Usage + * + * -# Test + */ + +#ifndef USBDIADDESCRIPTOR_H +#define USBDIADDESCRIPTOR_H + +//------------------------------------------------------------------------------ +// Types +//------------------------------------------------------------------------------ + +#ifdef __ICCARM__ // IAR +#pragma pack(1) // IAR +#define __attribute__(...) // IAR +#endif // IAR + +/* + Type: USBDeviceDescriptor + USB standard device descriptor structure. + + Variables: + bLength - Size of this descriptor in bytes. + bDescriptorType - Descriptor type (). + bFirstInterface - Interface number of the first interface that is + associated with this function. + bInterfaceCount - Number of contiguous interfaces that are + associated with this function. + bFunctionClass - Class code (assigned by USB-IF). + bFunctionSubClass - Subclass code (assigned by USB-IF). + bFunctionProtocol - Protocol code (assigned by USB-IF) + iFunction - Index of string descriptor describing this function. +*/ +typedef struct { + + unsigned char bLength; + unsigned char bDescriptorType; + unsigned char bFirstInterface; + unsigned char bInterfaceCount; + unsigned char bFunctionClass; + unsigned char bFunctionSubClass; + unsigned char bFunctionProtocol; + unsigned char iFunction; +} __attribute__ ((packed)) USBInterfaceAssociationDescriptor; // GCC + +#ifdef __ICCARM__ // IAR +#pragma pack() // IAR +#endif // IAR + +#endif //#ifndef USBDIADDESCRIPTOR_H + 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 + +//------------------------------------------------------------------------------ +// 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 + +//------------------------------------------------------------------------------ +// 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 + -- cgit v1.2.3