[sky9x] Massstorage (not finished at all!)

[stock] 180bytes flash saved
This commit is contained in:
bsongis
2012-09-11 19:58:49 +00:00
parent 91fbcb94d7
commit fcf6f436b0
702 changed files with 166014 additions and 441 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

@@ -0,0 +1,72 @@
/* ----------------------------------------------------------------------------
* 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 USB %audio control interfaces.
///
/// !!!Usage
///
/// -# When declaring a standard USB interface descriptor for an %audio control
/// interface, use the "USB Audio control interface codes" constants.
//------------------------------------------------------------------------------
#ifndef AUDCONTROLINTERFACEDESCRIPTOR_H
#define AUDCONTROLINTERFACEDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio control interface codes"
///
/// This page lists the class, subclass and protocol codes that a USB Audio
/// Control interface descriptor should display.
///
/// !Codes
/// - AUDControlInterfaceDescriptor_CLASS
/// - AUDControlInterfaceDescriptor_SUBCLASS
/// - AUDControlInterfaceDescriptor_PROTOCOL
/// Class code for an audio control interface.
#define AUDControlInterfaceDescriptor_CLASS 0x01
/// Subclass code for an audio control interface.
#define AUDControlInterfaceDescriptor_SUBCLASS 0x01
/// Protocol code for an audio control interface.
#define AUDControlInterfaceDescriptor_PROTOCOL 0x00
//------------------------------------------------------------------------------
#endif //#ifndef AUDCONTROLINTERFACEDESCRIPTOR_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 the USB audio-specific data endpoint descriptor.
///
/// !!!Usage
///
/// -# Declare an AUDDataEndpointDescriptor instance as part of the
/// configuration descriptors of a USB %audio %device.
//------------------------------------------------------------------------------
#ifndef AUDDATAENDPOINTDESCRIPTOR_H
#define AUDDATAENDPOINTDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
/// Descriptor subtype for an Audio data endpoint.
#define AUDDataEndpointDescriptor_SUBTYPE 0x01
//------------------------------------------------------------------------------
/// \page "USB Audio Lock delay units"
///
/// This page lists the valid lock delay unit types.
///
/// !Units
/// - AUDDataEndpointDescriptor_MILLISECONDS
/// - AUDDataEndpointDescriptor_PCMSAMPLES
/// Lock delay is expressed in milliseconds.
#define AUDDataEndpointDescriptor_MILLISECONDS 1
/// Lock delay is expressed in decoded PCM samples.
#define AUDDataEndpointDescriptor_PCMSAMPLES 2
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// Gives additional information about an USB endpoint used to transmit audio
/// data to or from the host.
//------------------------------------------------------------------------------
typedef struct {
/// Size of descriptor in bytes.
unsigned char bLength;
/// Descriptor type (AUDGenericDescriptor_ENDPOINT).
unsigned char bDescriptorType;
/// Descriptor subtype (AUDDataEndpointDescriptor_SUBTYPE).
unsigned char bDescriptorSubType;
/// Indicates available controls and requirement on packet sizes.
unsigned char bmAttributes;
/// Indicates the units of the wLockDelay fields.
/// \sa "USB Audio Lock delay units"
unsigned char bLockDelayUnits;
/// Time it takes for the endpoint to lock its internal clock circuitry.
unsigned short wLockDelay;
} __attribute__ ((packed)) AUDDataEndpointDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
#endif //#ifndef AUDDATAENDPOINTDESCRIPTOR_H
@@ -0,0 +1,72 @@
/* ----------------------------------------------------------------------------
* 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
///
/// Fields values for an USB Audio %device descriptor.
///
/// !!!Usage
///
/// -# When declaring the %device descriptor of a USB %audio %device, use
/// "USB Audio device descriptor values" defined here.
//------------------------------------------------------------------------------
#ifndef AUDDEVICEDESCRIPTOR_H
#define AUDDEVICEDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio device descriptor values"
///
/// This page lists the class, subclass & protocol codes that a USB audio
/// device should display in its device descriptor.
///
/// !Codes
/// - AUDDeviceDescriptor_CLASS
/// - AUDDeviceDescriptor_SUBCLASS
/// - AUDDeviceDescriptor_PROTOCOL
/// Class code for a USB audio device.
#define AUDDeviceDescriptor_CLASS 0x00
/// Subclass code for a USB audio device.
#define AUDDeviceDescriptor_SUBCLASS 0x00
/// Protocol code for a USB audio device.
#define AUDDeviceDescriptor_PROTOCOL 0x00
//------------------------------------------------------------------------------
#endif //#ifndef AUDDEVICEDESCRIPTOR_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
///
/// Re-definition of the standard USB endpoint descriptor with two additional
/// fields. This is required by the USB audio 1.00 specification.
///
/// !!!Usage
///
/// -# Declare an AUDEndpointDescriptor instance as part of the configuration
/// descriptors of an USB %audio %device.
//------------------------------------------------------------------------------
#ifndef AUDENDPOINTDESCRIPTOR_H
#define AUDENDPOINTDESCRIPTOR_H
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// Modified endpoint descriptor with two additional fields, with are
/// USB audio specific.
//------------------------------------------------------------------------------
typedef struct {
/// Size of the descriptor in bytes.
unsigned char bLength;
/// Descriptor type (USBGenericDescriptor_ENDPOINT).
unsigned char bDescriptorType;
/// Address and direction of the endpoint.
unsigned char bEndpointAddress;
/// Endpoint type and additional characteristics (for isochronous endpoints).
unsigned char bmAttributes;
/// Maximum packet size (in bytes) of the endpoint.
unsigned short wMaxPacketSize;
/// Polling rate of the endpoint.
unsigned char bInterval;
/// Refresh rate for a feedback endpoint.
unsigned char bRefresh;
/// Address of the associated feedback endpoint if any.
unsigned char bSyncAddress;
} __attribute__ ((packed)) AUDEndpointDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
#endif //#ifndef AUDENDPOINTDESCRIPTOR_H
@@ -0,0 +1,116 @@
/* ----------------------------------------------------------------------------
* 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
///
/// Class for manipulating USB %audio feature unit descriptor.
///
/// !!!Usage
///
/// -# Declare an AUDFeatureUnitDescriptor instance as part of the
/// configuration descriptors returned by a USB %audio %device.
//------------------------------------------------------------------------------
#ifndef AUDFEATUREUNITDESCRIPTOR_H
#define AUDFEATUREUNITDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio Channel controls"
///
/// This page lists the available controls for each channel of the audio
/// interface. Each channel can have any control combination; simply perform
/// a bitwise OR ('|') to combine several values.
///
/// !Controls
/// -# AUDFeatureUnitDescriptor_MUTE
/// -# AUDFeatureUnitDescriptor_VOLUME
/// -# AUDFeatureUnitDescriptor_BASS
/// -# AUDFeatureUnitDescriptor_MID
/// -# AUDFeatureUnitDescriptor_TREBLE
/// Channel mute control.
#define AUDFeatureUnitDescriptor_MUTE (1 << 0)
/// Channel volume control.
#define AUDFeatureUnitDescriptor_VOLUME (1 << 1)
/// Channel bass control.
#define AUDFeatureUnitDescriptor_BASS (1 << 2)
/// Channel middle control.
#define AUDFeatureUnitDescriptor_MID (1 << 3)
/// Channel treble control.
#define AUDFeatureUnitDescriptor_TREBLE (1 << 4)
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// Describes available controls for each channel of the unit or terminal
/// it is connected to. This type must be augmented with the relevant number
/// of bmaControls fields and the iFeature field.
//------------------------------------------------------------------------------
typedef struct {
/// Size of descriptor in bytes.
unsigned char bLength;
/// Descriptor type (AUDGenericDescriptor_INTERFACE).
unsigned char bDescriptorType;
/// Descriptor subtype (AUDGenericDescriptor_FEATURE).
unsigned char bDescriptorSubType;
/// Identifier of this feature unit.
unsigned char bUnitID;
/// Identifier of the unit or terminal this feature unit is connected to.
unsigned char bSourceID;
/// Size in bytes of a channel controls field.
unsigned char bControlSize;
} __attribute__ ((packed)) AUDFeatureUnitDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
#endif //#ifndef AUDFEATUREUNITDESCRIPTOR_H
@@ -0,0 +1,60 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "AUDFeatureUnitRequest.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Returns the control selector value indicating the target of a Feature Unit
/// request.
/// \param request Pointer to a USBGenericRequest instance.
/// \sa "USB Audio Control selector values"
//------------------------------------------------------------------------------
unsigned char AUDFeatureUnitRequest_GetControl(const USBGenericRequest *request)
{
return ((USBGenericRequest_GetValue(request) >> 8) & 0xFF);
}
//------------------------------------------------------------------------------
/// Returns the channel number of a Feature unit which should be altered by the
/// given request.
/// \param request Pointer to a USBGenericRequest instance.
//------------------------------------------------------------------------------
unsigned char AUDFeatureUnitRequest_GetChannel(const USBGenericRequest *request)
{
return (USBGenericRequest_GetValue(request) & 0xFF);
}
@@ -0,0 +1,81 @@
/* ----------------------------------------------------------------------------
* 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 using USB %audio requests
/// targetted at a Feature unit.
///
/// !!!Usage
///
/// - For a USB %device:
/// -# Use AUDFeatureUnitRequest_GetControl to determine which control
/// shall be tweaked following a host request.
// -# Use AUDFeatureUnitRequest_GetChannel to identify the channel which
// will have its control altered.
//------------------------------------------------------------------------------
#ifndef AUDFEATUREUNITREQUEST_H
#define AUDFEATUREUNITREQUEST_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <usb/common/core/USBGenericRequest.h>
//------------------------------------------------------------------------------
// Constants
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio Control selector values"
///
/// This page lists the available control selectors for a Feature Unit request.
///
/// !Controls
/// - AUDFeatureUnitRequest_MUTE
/// Mute control selector.
#define AUDFeatureUnitRequest_MUTE 0x01
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char AUDFeatureUnitRequest_GetControl(
const USBGenericRequest *request);
extern unsigned char AUDFeatureUnitRequest_GetChannel(
const USBGenericRequest *request);
#endif //#ifndef AUDFEATUREUNITREQUEST_H
@@ -0,0 +1,101 @@
/* ----------------------------------------------------------------------------
* 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 USB %audio format type I descriptors.
///
/// !!!Usage
///
/// -# Declare an instance of AUDFormatTypeOneDescriptor as part of the
/// configuration descriptors of an audio device.
//------------------------------------------------------------------------------
#ifndef AUDFORMATTYPEONEDESCRIPTOR_H
#define AUDFORMATTYPEONEDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
/// Format type for a format type I descriptor.
#define AUDFormatTypeOneDescriptor_FORMATTYPEONE 0x01
/// AUDFormatTypeOneDescriptor_PCM - PCM format.
#define AUDFormatTypeOneDescriptor_PCM 0x0001
/// Indicates the sampling frequency can have any value in the provided range.
#define AUDFormatTypeOneDescriptor_CONTINUOUS 0
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// Describes an audio data stream that is constructed on a sample-by-sample
/// basis. This type must be augmented with either the continuous sampling
/// frequency range (if bSamFreqType = <AUDFormatTypeOneDescriptor_CONTINUOUS>)
/// or with an array containing the possible discrete frequencies.
//------------------------------------------------------------------------------
typedef struct {
/// Size of descriptor in bytes.
unsigned char bLength;
/// Descriptor type (AUDGenericDescriptor_INTERFACE).
unsigned char bDescriptorType;
/// Descriptor subtype (AUDStreamingInterfaceDescriptor_FORMATTYPE).
unsigned char bDescriptorSubType;
/// Format type (AUDFormatTypeOneDescriptor_FORMATTYPEONE).
unsigned char bFormatType;
/// Number of physical channels in the audio stream.
unsigned char bNrChannels;
/// Number of bytes occupied by one audio subframe.
unsigned char bSubFrameSize;
/// Number of bits effectively used in an audio subframe.
unsigned char bBitResolution;
/// Number of supported discrete sampling frequencies, or
/// AUDFormatTypeOneDescriptor_CONTINUOUS.
unsigned char bSamFreqType;
} __attribute__ ((packed)) AUDFormatTypeOneDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
#endif //#ifndef AUDFORMATTYPEONEDESCRIPTOR_H
@@ -0,0 +1,121 @@
/* ----------------------------------------------------------------------------
* 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 manipulating USB audio-specific descriptors.
///
/// !!!Usage
///
/// - For a USB %device:
/// -# When declaring an Audio-specific descriptor, use the descriptor types
/// and subtypes defined in this unit (see "USB Audio descriptor types"
/// and "USB Audio descriptor subtypes").
//------------------------------------------------------------------------------
#ifndef AUDGENERICDESCRIPTOR_H
#define AUDGENERICDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio descriptor types"
///
/// This page lists the available types for USB audio-specific descriptors.
///
/// !Types
/// - AUDGenericDescriptor_DEVICE
/// - AUDGenericDescriptor_CONFIGURATION
/// - AUDGenericDescriptor_STRING
/// - AUDGenericDescriptor_INTERFACE
/// - AUDGenericDescriptor_ENDPOINT
/// Descriptor gives detail about the whole device.
#define AUDGenericDescriptor_DEVICE 0x21
/// Descriptor gives detail about a configuration.
#define AUDGenericDescriptor_CONFIGURATION 0x22
/// Descriptor gives detail about a string.
#define AUDGenericDescriptor_STRING 0x23
/// Descriptor gives detail about an interface.
#define AUDGenericDescriptor_INTERFACE 0x24
/// Descriptor gives detail about an endpoint.
#define AUDGenericDescriptor_ENDPOINT 0x25
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio descriptor subtypes"
///
/// This page lists the possible subtypes for USB audio-specific descriptors.
///
/// !Subtypes
/// - AUDGenericDescriptor_HEADER
/// - AUDGenericDescriptor_INPUTTERMINAL
/// - AUDGenericDescriptor_OUTPUTTERMINAL
/// - AUDGenericDescriptor_MIXERUNIT
/// - AUDGenericDescriptor_SELECTORUNIT
/// - AUDGenericDescriptor_FEATUREUNIT
/// - AUDGenericDescriptor_PROCESSINGUNIT
/// - AUDGenericDescriptor_EXTENSIONUNIT
/// Header descriptor subtype.
#define AUDGenericDescriptor_HEADER 0x01
/// Input terminal descriptor subtype.
#define AUDGenericDescriptor_INPUTTERMINAL 0x02
/// Output terminal descriptor subtype.
#define AUDGenericDescriptor_OUTPUTTERMINAL 0x03
/// Mixer unit descriptor subtype.
#define AUDGenericDescriptor_MIXERUNIT 0x04
/// Selector unit descriptor subtype.
#define AUDGenericDescriptor_SELECTORUNIT 0x05
/// Feature unit descriptor subtype.
#define AUDGenericDescriptor_FEATUREUNIT 0x06
/// Processing unit descriptor subtype.
#define AUDGenericDescriptor_PROCESSINGUNIT 0x07
///Extension unit descriptor subtype.
#define AUDGenericDescriptor_EXTENSIONUNIT 0x08
//------------------------------------------------------------------------------
#endif //#ifndef AUDGENERICDESCRIPTOR_H
@@ -0,0 +1,57 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "AUDGenericRequest.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Returns the ID of the unit or terminal targetted by an USB audio request.
/// \param request Pointer to a USBGenericRequest instance.
//------------------------------------------------------------------------------
unsigned char AUDGenericRequest_GetEntity(const USBGenericRequest *request)
{
return ((USBGenericRequest_GetIndex(request) >> 8) & 0xFF);
}
//------------------------------------------------------------------------------
/// Returns the ID of the interface targetted by an USB audio request.
/// \param request Pointer to a USBGenericRequest instance.
//------------------------------------------------------------------------------
unsigned char AUDGenericRequest_GetInterface(const USBGenericRequest *request)
{
return (USBGenericRequest_GetIndex(request) & 0xFF);
}
@@ -0,0 +1,94 @@
/* ----------------------------------------------------------------------------
* 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 USB %audio SETUP requests.
///
/// !!!Usage
///
/// - For a USB %device:
/// -# After receiving an Audio request from the host, use
/// AUDGenericRequest_GetEntity to determine the target Unit or Terminal.
/// -# After receiving an Audio request from the host, use
/// AUDGenericRequest_GetInterface to know which interface is referenced.
//------------------------------------------------------------------------------
#ifndef AUDGENERICREQUEST_H
#define AUDGENERICREQUEST_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <usb/common/core/USBGenericRequest.h>
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio request codes"
///
/// This page lists the codes of the existing Audio requests.
///
/// !Requests
/// - AUDGenericRequest_SETCUR
/// - AUDGenericRequest_GETCUR
/// SET_CUR request code.
#define AUDGenericRequest_SETCUR 0x01
/// GET_CUR request code.
#define AUDGenericRequest_GETCUR 0x81
/// GET_MIN request code.
#define AUDGenericRequest_GETMIN 0x82
/// GET_MAX request code.
#define AUDGenericRequest_GETMAX 0x83
/// GET_RES request code.
#define AUDGenericRequest_GETRES 0x84
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char AUDGenericRequest_GetEntity(
const USBGenericRequest *request);
extern unsigned char AUDGenericRequest_GetInterface(
const USBGenericRequest *request);
#endif //#ifndef AUDGENERICREQUEST_H
@@ -0,0 +1,100 @@
/* ----------------------------------------------------------------------------
* 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
///
/// Class for manipulating USB %audio header descriptors.
///
/// !!!Usage
///
/// - For a USB %device:
/// -# Declare a AUDHeaderDescriptor as part of the configuration
/// descriptors of the %device.
//------------------------------------------------------------------------------
#ifndef AUDHEADERDESCRIPTOR_H
#define AUDHEADERDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio class releases"
/// This page lists the existing versions of the Audio class specification.
///
///
/// !Versions
/// - AUDHeaderDescriptor_AUD1_00
/// Indentifies the USB audio specification release 1.00.
#define AUDHeaderDescriptor_AUD1_00 0x0100
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// Groups the various audio interfaces to display one single function to
/// the USB host. Subclass this structure to add a particular number of
/// slave interface descriptors.
//------------------------------------------------------------------------------
typedef struct {
/// Size of descriptor in bytes.
unsigned char bLength;
/// Descriptor type (AUDGenericDescriptor_INTERFACE).
unsigned char bDescriptorType;
/// Descriptor subtype (AUDGenericDescriptor_HEADER).
unsigned char bDescriptorSubType;
/// Audio class release number in BCD format
/// \sa "USB Audio class releases"
unsigned short bcdADC;
/// Length of all descriptors used to qualify the Audio Control interface.
unsigned short wTotalLength;
/// Number of Streaming interfaces contained in this collection.
unsigned char bInCollection;
} __attribute__ ((packed)) AUDHeaderDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
#endif //#ifndef AUDHEADERDESCRIPTOR_H
@@ -0,0 +1,139 @@
/* ----------------------------------------------------------------------------
* 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
///
/// Class for manipulating input terminal descriptors.
///
/// !!!Usage
///
/// - For a USB %device:
/// -# Declare an AUDInputTerminalDescriptor instance as part of the
/// configuration of the %device.
//------------------------------------------------------------------------------
#ifndef AUDINPUTTERMINALDESCRIPTOR_H
#define AUDINPUTTERMINALDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio Input terminal types"
///
/// This page lists the available types for an Input terminal.
///
/// !Types
///
/// - AUDInputTerminalDescriptor_USBSTREAMING
/// - AUDInputTerminalDescriptor_MICROPHONE
/// - AUDInputTerminalDescriptor_SPEAKERPHONE
/// - AUDInputTerminalDescriptor_LINEIN
/// A terminal receiving its data from a USB isochronous endpoint.
#define AUDInputTerminalDescriptor_USBSTREAMING 0x0101
/// A terminal sampling data from a microphone.
#define AUDInputTerminalDescriptor_MICROPHONE 0x0201
/// A terminal sampling data from a Handset In.
#define AUDInputTerminalDescriptor_HANDSETIN 0x0401
/// A terminal sampling data from a speakerphone
#define AUDInputTerminalDescriptor_SPEAKERPHONE 0x0403
/// A terminal sampling data from a Phone Line In.
#define AUDInputTerminalDescriptor_LINEIN 0x0501
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio Channel spatial locations"
///
/// This page lists the possible spatial locations for audio channels.
///
/// !Locations
///
/// - AUDInputTerminalDescriptor_LEFTFRONT
/// - AUDInputTerminalDescriptor_RIGHTFRONT
/// - AUDInputTerminalDescriptor_CENTERFRONT
/// Front left channel.
#define AUDInputTerminalDescriptor_LEFTFRONT (1 << 0)
/// Front right channel.
#define AUDInputTerminalDescriptor_RIGHTFRONT (1 << 1)
/// Front center channel.
#define AUDInputTerminalDescriptor_CENTERFRONT (1 << 2)
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// Describes an input of a USB audio device.
//------------------------------------------------------------------------------
typedef struct {
/// Size of descriptor in bytes.
unsigned char bLength;
/// Descriptor type (AUDGenericDescriptor_INTERFACE).
unsigned char bDescriptorType;
/// Descriptor subtype (AUDGenericDescriptor_INPUTTERMINAL).
unsigned char bDescriptorSubType;
/// ID of the terminal in the audio function.
unsigned char bTerminalID;
/// Terminal type.
/// \sa "USB Audio Input terminal types"
unsigned short wTerminalType;
/// ID of the output terminal to which this input terminal is associated.
unsigned char bAssocTerminal;
/// Number of logical output channels in this terminal.
unsigned char bNrChannels;
/// Spatial configuration of the logical channels.
unsigned short wChannelConfig;
/// Index of a string descriptor for the first logical channel.
unsigned char iChannelNames;
/// Index of a string descriptor for this terminal.
unsigned char iTerminal;
} __attribute__ ((packed)) AUDInputTerminalDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
#endif //#ifndef AUDINPUTTERMINALDESCRIPTOR_H
@@ -0,0 +1,112 @@
/* ----------------------------------------------------------------------------
* 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 using USB %audio output terminal descriptors.
///
/// !!!Usage
///
/// - For a USB %device:
/// -# Declare a AUDOutputTerminalDescriptor instance as part of the
/// configuration descriptors of a USB %audio %device.
//------------------------------------------------------------------------------
#ifndef AUDOUTPUTTERMINALDESCRIPTOR_H
#define AUDOUTPUTTERMINALDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio Output terminal types"
///
/// This page lists the available types for an output terminal.
///
/// !Types
/// - AUDOutputTerminalDescriptor_USBTREAMING
/// - AUDOutputTerminalDescriptor_SPEAKER
/// - AUDOutputTerminalDescriptor_HANDSETOUT
/// - AUDOutputTerminalDescriptor_LINEOUT
/// A terminal sending data through USB isochronous endpoint.
#define AUDOutputTerminalDescriptor_USBTREAMING 0x0101
/// A terminal sending data to a USB host through an Isochronous endpoint.
#define AUDOutputTerminalDescriptor_SPEAKER 0x0301
/// A terminal sending data to Handset Out.
#define AUDOutputTerminalDescriptor_HANDSETOUT 0x0401
/// A terminal sending data to Phone Line Out.
#define AUDOutputTerminalDescriptor_LINEOUT 0x0501
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// \typedef AUDOutputTerminalDescriptor
/// Describes an output of the USB audio function.
//------------------------------------------------------------------------------
typedef struct {
/// Size of descriptor in bytes.
unsigned char bLength;
/// Descriptor type (AUDGenericDescriptor_INTERFACE).
unsigned char bDescriptorType;
/// Descriptor subtype (AUDGenericDescriptor_OUTPUTTERMINAL).
unsigned char bDescriptorSubType;
/// Identifier for this terminal.
unsigned char bTerminalID;
/// Terminal type.
/// \sa "USB Audio Output terminal types"
unsigned short wTerminalType;
/// Identifier of the associated input terminal.
unsigned char bAssocTerminal;
/// Identifier of the unit or terminal to which this terminal is connected.
unsigned char bSourceID;
/// Index of a string descriptor for this terminal.
unsigned char iTerminal;
} __attribute__ ((packed)) AUDOutputTerminalDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
#endif //#ifndef AUDOUTPUTTERMINALDESCRIPTOR_H
@@ -0,0 +1,129 @@
/* ----------------------------------------------------------------------------
* 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 USB %audio streaming interface
/// descriptors.
///
/// !!!Usage
///
/// - For a USB %device:
/// -# Declare an AUDStreamingInterfaceDescriptor instance as part of the
/// configuration descriptors returned by a USB %audio %device.
//------------------------------------------------------------------------------
#ifndef AUDSTREAMINGINTERFACEDESCRIPTOR_H
#define AUDSTREAMINGINTERFACEDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio streaming interface codes"
///
/// This page lists the class, subclass and protocol codes that an Audio
/// Streaming interface should display in its descriptor.
///
/// !Codes
/// - AUDStreamingInterfaceDescriptor_CLASS
/// - AUDStreamingInterfaceDescriptor_SUBCLASS
/// - AUDStreamingInterfaceDescriptor_PROTOCOL
/// Class code for an USB audio streaming interface.
#define AUDStreamingInterfaceDescriptor_CLASS 0x01
/// Subclass code for an audio streaming interface.
#define AUDStreamingInterfaceDescriptor_SUBCLASS 0x02
/// Protocol code for an audio streaming interface.
#define AUDStreamingInterfaceDescriptor_PROTOCOL 0x00
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Audio streaming descriptor subtypes"
///
/// This page lists the possible subtypes for audio-specific descriptor appended
/// to an Audio Streaming interface.
///
/// !Subtypes
/// - AUDStreamingInterfaceDescriptor_GENERAL
/// - AUDStreamingInterfaceDescriptor_FORMATTYPE
/// - AUDStreamingInterfaceDescriptor_FORMATSPECIFIC
/// General descriptor subtype.
#define AUDStreamingInterfaceDescriptor_GENERAL 0x01
/// Format type descriptor subtype.
#define AUDStreamingInterfaceDescriptor_FORMATTYPE 0x02
/// Format specific descriptor subtype.
#define AUDStreamingInterfaceDescriptor_FORMATSPECIFIC 0x03
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// Provides additional information about an audio streaming interface to
/// the USB host.
//------------------------------------------------------------------------------
typedef struct {
/// Size of descriptor in bytes.
unsigned char bLength;
/// Descriptor type (AUDGenericDescriptor_INTERFACE).
unsigned char bDescriptorType;
/// Descriptor subtype (AUDStreamingInterfaceDescriptor_GENERAL).
unsigned char bDescriptorSubType;
/// Terminal ID to which the interface is connected.
unsigned char bTerminalLink;
/// Delay introduced by the data path, in number of frames.
unsigned char bDelay;
/// Audio data format used by this interface.
unsigned short wFormatTag;
} __attribute__ ((packed)) AUDStreamingInterfaceDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
#endif //#ifndef AUDSTREAMINGINTERFACEDESCRIPTOR_H
@@ -0,0 +1,40 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \dir
/// !!!Purpose
///
/// This directory contains definitions, structures and funcions related to the
/// USB Audio Class specification. They can be divided into two groups:
/// - Audio-specific descriptors, prefixed with AUD and suffixed with
/// Descriptor.
/// - Audio-specific requests, prefixed with AUD and suffixed with Request.
//------------------------------------------------------------------------------
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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 <utility/assert.h>
//------------------------------------------------------------------------------
// 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;
}
@@ -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
@@ -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;
}
}
@@ -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 <usb/common/core/USBGenericRequest.h>
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char CDCSetControlLineStateRequest_IsDtePresent(
const USBGenericRequest *request);
extern unsigned char CDCSetControlLineStateRequest_ActivateCarrier(
const USBGenericRequest *request);
#endif //#ifndef CDCSETCONTROLLINESTATE_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
@@ -0,0 +1,39 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \dir
/// !Purpose
///
/// This directory contains structures and definitions related to the USB CDC
/// specification. They can be divided into two groups:
/// - CDC-specific descriptors, prefixed with CDC and suffixed with Descriptor.
/// - CDC-specific requests, prefixed with CDC and suffixed with Request.
//------------------------------------------------------------------------------
@@ -0,0 +1,55 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \dir
/// !!!Purpose
///
/// This directory containes highly re-usable code from USB standard and some
/// classes specifications for general use.
///
/// !!!Contents
/// This dircetory provides two sections of definitions:
/// -# Definitions, structures and functions from USB specification,
/// commonly used for all USB classes and projects.
/// - core: for USB specification
/// -# Definitions, structures and functions from class-specific
/// specification commonly used for class related project ONLY.
/// - cdc: for USB Communication Devie Class (CDC)
/// - hid: for USB Humen Interface Device Class (HID)
/// - massstorage: for USB Mass Storage Class (MS)
/// - audio: for USB Audio Class (AUD)
///
/// For more information about what a particular group contains, please refer to
/// its documentation page.
///
/// \note
/// Depending on the project, not all the subdirectories will be available
/// (i.e. the #cdc# directory will not be in non-CDC projects).
//------------------------------------------------------------------------------
@@ -0,0 +1,162 @@
/* ----------------------------------------------------------------------------
* 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: USBConfigurationDescriptor implementation
About: Purpose
Implementation of the USBConfigurationDescriptor class.
*/
//-----------------------------------------------------------------------------
// Headers
//-----------------------------------------------------------------------------
#include "USBConfigurationDescriptor.h"
//-----------------------------------------------------------------------------
// Exported functions
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
/// Returns the total length of a configuration, i.e. including the
/// descriptors following it.
/// \param configuration Pointer to a USBConfigurationDescriptor instance.
/// \return Total length (in bytes) of the configuration.
//-----------------------------------------------------------------------------
unsigned int USBConfigurationDescriptor_GetTotalLength(
const USBConfigurationDescriptor *configuration)
{
return configuration->wTotalLength;
}
//-----------------------------------------------------------------------------
/// Returns the number of interfaces in a configuration.
/// \param configuration Pointer to a USBConfigurationDescriptor instance.
/// \return Number of interfaces in configuration.
//-----------------------------------------------------------------------------
unsigned char USBConfigurationDescriptor_GetNumInterfaces(
const USBConfigurationDescriptor *configuration)
{
return configuration->bNumInterfaces;
}
//-----------------------------------------------------------------------------
/// Indicates if the device is self-powered when in a given configuration.
/// \param configuration Pointer to a USBConfigurationDescriptor instance.
/// \return 1 if the device is self-powered when in the given configuration;
/// otherwise 0.
//-----------------------------------------------------------------------------
unsigned char USBConfigurationDescriptor_IsSelfPowered(
const USBConfigurationDescriptor *configuration)
{
if ((configuration->bmAttributes & (1 << 6)) != 0) {
return 1;
}
else {
return 0;
}
}
//-----------------------------------------------------------------------------
/// Parses the given Configuration descriptor (followed by relevant
/// interface, endpoint and class-specific descriptors) into three arrays.
/// *Each array must have its size equal or greater to the number of
/// descriptors it stores plus one*. A null-value is inserted after the last
/// descriptor of each type to indicate the array end.
///
/// Note that if the pointer to an array is null (0), nothing is stored in
/// it.
/// \param configuration Pointer to the start of the whole Configuration
/// descriptor.
/// \param interfaces Pointer to the Interface descriptor array.
/// \param endpoints Pointer to the Endpoint descriptor array.
/// \param others Pointer to the class-specific descriptor array.
//-----------------------------------------------------------------------------
void USBConfigurationDescriptor_Parse(
const USBConfigurationDescriptor *configuration,
USBInterfaceDescriptor **interfaces,
USBEndpointDescriptor **endpoints,
USBGenericDescriptor **others)
{
// Get size of configuration to parse
int size = USBConfigurationDescriptor_GetTotalLength(configuration);
size -= sizeof(USBConfigurationDescriptor);
// Start parsing descriptors
USBGenericDescriptor *descriptor = (USBGenericDescriptor *) configuration;
while (size > 0) {
// Get next descriptor
descriptor = USBGenericDescriptor_GetNextDescriptor(descriptor);
size -= USBGenericDescriptor_GetLength(descriptor);
// Store descriptor in correponding array
if (USBGenericDescriptor_GetType(descriptor)
== USBGenericDescriptor_INTERFACE) {
if (interfaces) {
*interfaces = (USBInterfaceDescriptor *) descriptor;
interfaces++;
}
}
else if (USBGenericDescriptor_GetType(descriptor)
== USBGenericDescriptor_ENDPOINT) {
if (endpoints) {
*endpoints = (USBEndpointDescriptor *) descriptor;
endpoints++;
}
}
else if (others) {
*others = descriptor;
others++;
}
}
// Null-terminate arrays
if (interfaces) {
*interfaces = 0;
}
if (endpoints) {
*endpoints = 0;
}
if (others) {
*others = 0;
}
}
@@ -0,0 +1,150 @@
/* ----------------------------------------------------------------------------
* 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 and methods for USB configuration descriptor structures
described by the USB specification.
!!!Usage
-# Declare USBConfigurationDescriptor instance as a part
of the configuration descriptors of a USB device.
-# To get useful information (field values) from the defined USB device
configuration descriptor, use
- USBConfigurationDescriptor_GetTotalLength
- USBConfigurationDescriptor_GetNumInterfaces
- USBConfigurationDescriptor_IsSelfPowered
-# To pase the defined USB device configuration descriptor, use
- USBConfigurationDescriptor_Parse
*/
#ifndef USBCONFIGURATIONDESCRIPTOR_H
#define USBCONFIGURATIONDESCRIPTOR_H
//-----------------------------------------------------------------------------
// Headers
//-----------------------------------------------------------------------------
#include "USBGenericDescriptor.h"
#include "USBInterfaceDescriptor.h"
#include "USBEndpointDescriptor.h"
//-----------------------------------------------------------------------------
// Definitions
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
/// \page "USB device Attributes"
///
/// This page lists the codes of the usb attributes.
///
/// !Attributes
/// - USBConfigurationDescriptor_BUSPOWERED_NORWAKEUP
/// - USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP
/// - USBConfigurationDescriptor_BUSPOWERED_RWAKEUP
/// - USBConfigurationDescriptor_SELFPOWERED_RWAKEUP
/// - USBConfigurationDescriptor_POWER
/// Device is bus-powered and not support remote wake-up.
#define USBConfigurationDescriptor_BUSPOWERED_NORWAKEUP 0x80
/// Device is self-powered and not support remote wake-up.
#define USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP 0xC0
/// Device is bus-powered and supports remote wake-up.
#define USBConfigurationDescriptor_BUSPOWERED_RWAKEUP 0xA0
/// Device is self-powered and supports remote wake-up.
#define USBConfigurationDescriptor_SELFPOWERED_RWAKEUP 0xE0
/// Calculates the value of the power consumption field given the value in mA.
/// \param power The power consumption value in mA
/// \return The value that should be set to the field in descriptor
#define USBConfigurationDescriptor_POWER(power) (power / 2)
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Types
//-----------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//-----------------------------------------------------------------------------
/// USB standard configuration descriptor structure.
//-----------------------------------------------------------------------------
typedef struct {
/// Size of the descriptor in bytes.
unsigned char bLength;
/// Descriptor type (USBDESC_CONFIGURATION of "USB Descriptor types").
unsigned char bDescriptorType;
/// Length of all descriptors returned along with this configuration
/// descriptor.
unsigned short wTotalLength;
/// Number of interfaces in this configuration.
unsigned char bNumInterfaces;
/// Value for selecting this configuration.
unsigned char bConfigurationValue;
/// Index of the configuration string descriptor.
unsigned char iConfiguration;
/// Configuration characteristics.
unsigned char bmAttributes;
/// Maximum power consumption of the device when in this configuration.
unsigned char bMaxPower;
} __attribute__ ((packed)) USBConfigurationDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
//-----------------------------------------------------------------------------
// Exported functions
//-----------------------------------------------------------------------------
extern unsigned int USBConfigurationDescriptor_GetTotalLength(
const USBConfigurationDescriptor *configuration);
extern unsigned char USBConfigurationDescriptor_GetNumInterfaces(
const USBConfigurationDescriptor *configuration);
extern unsigned char USBConfigurationDescriptor_IsSelfPowered(
const USBConfigurationDescriptor *configuration);
extern void USBConfigurationDescriptor_Parse(
const USBConfigurationDescriptor *configuration,
USBInterfaceDescriptor **interfaces,
USBEndpointDescriptor **endpoints,
USBGenericDescriptor **others);
#endif //#ifndef USBCONFIGURATIONDESCRIPTOR_H
@@ -0,0 +1,51 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include "USBConfigurationOTG.h"
USBGenericOTGDescriptor *pOTGDescriptor;
//-----------------------------------------------------------------------------
// Internal functions
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// External functions
//-----------------------------------------------------------------------------
void OTG_Initialize(USBGenericOTGDescriptor *pOTGDesc)
{
pOTGDescriptor = pOTGDesc;
}
@@ -0,0 +1,118 @@
/* ----------------------------------------------------------------------------
* 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 configuring OTG.
///
/// !Usage
///
/// -#
/// -#
///
//------------------------------------------------------------------------------
#ifndef USBCONFIGURATIONOTG_H
#define USBCONFIGURATIONOTG_H
#include <usb/otg/compiler.h>
/// OTG specific configuration
typedef struct {
/// USB MODE CONFIGURATION
/// ENABLE to activate the host software library support
/// Possible values ENABLE or DISABLE
unsigned char bOTGUsbHostFeature;
/// ENABLE to activate the device software library support
/// Possible values ENABLE or DISABLE
unsigned char bOTGUsbDeviceFeature;
/// OTG MODE CONFIGURATION
/// ENABLE to enable OTG module (support A- and B- Device roles)
/// Possible values ENABLE or DISABLE
unsigned char bOTGFeature;
/// For reduced host only allows to control VBUS generator with PIO PE.7
unsigned char bOTGSoftwareVbusCtrl;
/// Selects the messaging method for OTG No Silent Failure spec.
///
/// A compliant OTG device must at least handle 3 Failure messages :
/// "Device No Response", "Unsupported Device" and "Unsupported Hub"
/// Functions must be defined for communicating messages to user (LCD display,
/// LEDs...)
/// The values available for this parameter are :
/// - OTGMSG_ALL : all messages (events and failures) are displayed
/// In this case, the following functions must be defined in user application firmware :
/// # "void Otg_messaging_init(void)", this function is called at start up to initialize the messaging peripheral
/// # "void Otg_output_failure_msg(U8)", displays the failure message choosen by ID number (see "usb_task.h")
/// # "void Otg_output_failure_clear(void)", clears the current failure message
/// # "void Otg_output_event_msg(U8)", displays the event message choosen by ID number
/// # "void Otg_output_event_clear(void)", clears the current event message
/// - OTGMSG_FAIL : only failure messages are displayed
/// In this case, the following functions must be defined in user application firmware :
/// # "void Otg_messaging_init(void)", this function is called at start up to initialize the messaging peripheral
/// # "void Otg_output_failure_msg(U8)", displays the failure message choosen by ID number (see "usb_task.h")
/// # "void Otg_output_failure_clear(void)", clears the current failure message
/// - OTGMSG_NONE : messages are not displayed (not OTG compliant device)
unsigned char bOTGMessagingOutput;
/// ENABLE to make the A-Device send a SetFeature(b_hnp_enable) just after a SRP
/// has been received
/// This feature must be ENABLE to pass the OTG compliance program
/// Possible values ENABLE or DISABLE
unsigned char bOTGEnableHNPAfterSRP;
/// Selects the SRP pulse for which the A Device will react and rise Vbus
/// The value is VBUS_PULSE or DATA_PULSE
unsigned char bOTGADevSRPReaction;
} USBGenericOTGDescriptor;
#define OTGMSG_NONE 0 // no messages displayed
#define OTGMSG_FAIL 1 // only failure messages displayed
#define OTGMSG_ALL 2 // all messages displayed
#define VBUS_PULSE 1 // no more used
#define DATA_PULSE 0
extern USBGenericOTGDescriptor *pOTGDescriptor;
extern void OTG_Initialize(USBGenericOTGDescriptor *pOTGDesc);
#endif //#ifndef USBCONFIGURATIONOTG_H
@@ -0,0 +1,125 @@
/* ----------------------------------------------------------------------------
* 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
Class for manipulating USB device descriptors.
!!!Usage
- Declare a USBDeviceDescriptor instance as the device descriptor of a
USB device.
*/
#ifndef USBDEVICEDESCRIPTOR_H
#define USBDEVICEDESCRIPTOR_H
#include <board.h>
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB release numbers"
///
/// This page lists the codes of USB release numbers.
///
/// !Code
/// - USBDeviceDescriptor_USB2_00
/// The device supports USB 2.00.
#define USBDeviceDescriptor_USB2_00 0x0200
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// USB standard device descriptor structure.
//------------------------------------------------------------------------------
typedef struct {
/// Size of this descriptor in bytes.
unsigned char bLength;
/// Descriptor type (USBGenericDescriptor_DEVICE).
unsigned char bDescriptorType;
/// USB specification release number in BCD format.
unsigned short bcdUSB;
/// Device class code.
unsigned char bDeviceClass;
/// Device subclass code.
unsigned char bDeviceSubClass;
/// Device protocol code.
unsigned char bDeviceProtocol;
/// Maximum packet size of endpoint 0 (in bytes).
unsigned char bMaxPacketSize0;
/// Vendor ID.
unsigned short idVendor;
/// Product ID.
unsigned short idProduct;
/// Device release number in BCD format.
unsigned short bcdDevice;
/// Index of the manufacturer string descriptor.
unsigned char iManufacturer;
/// Index of the product string descriptor.
unsigned char iProduct;
/// Index of the serial number string descriptor.
unsigned char iSerialNumber;
/// Number of possible configurations for the device.
unsigned char bNumConfigurations;
} __attribute__ ((packed)) USBDeviceDescriptor; // GCC
#if defined(CHIP_USB_OTGHS)
typedef struct {
/// Size of this descriptor in bytes.
unsigned char bLength;
/// Descriptor type (USBGenericDescriptor_OTG).
unsigned char bDescriptorType;
/// Attribute Fields D7…2: Reserved D1: HNP support D0: SRP support
unsigned char bmAttributes;
} __attribute__ ((packed)) USBOtgDescriptor; // GCC
#endif
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
#endif //#ifndef USBDEVICEDESCRIPTOR_H
@@ -0,0 +1,89 @@
/* ----------------------------------------------------------------------------
* 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
Class for manipulating USB device qualifier descriptors.
!!!Usage
- Declare a USBDeviceQualifierDescriptor instance as the device qualifier
descriptor of a USB device.
*/
#ifndef USBDEVICEQUALIFIERDESCRIPTOR_H
#define USBDEVICEQUALIFIERDESCRIPTOR_H
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// Alternate device descriptor indicating the capabilities of the device
/// in full-speed, if currently in high-speed; or in high-speed, if it is
/// currently in full-speed. Only relevant for devices supporting the
/// high-speed mode.
//------------------------------------------------------------------------------
typedef struct {
/// Size of the descriptor in bytes.
unsigned char bLength;
/// Descriptor type (USBDESC_DEVICE_QUALIFIER or "USB device types").
unsigned char bDescriptorType;
/// USB specification release number (in BCD format).
unsigned short bcdUSB;
/// Device class code.
unsigned char bDeviceClass;
/// Device subclass code.
unsigned char bDeviceSubClass;
/// Device protocol code.
unsigned char bDeviceProtocol;
/// Maximum packet size of endpoint 0.
unsigned char bMaxPacketSize0;
/// Number of possible configurations for the device.
unsigned char bNumConfigurations;
/// Reserved.
unsigned char bReserved;
} __attribute__ ((packed)) USBDeviceQualifierDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
#endif //#ifndef USBDEVICEQUALIFIERDESCRIPTOR_H
@@ -0,0 +1,109 @@
/* ----------------------------------------------------------------------------
* 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: USBEndpointDescriptor implementation
About: Purpose
Implementation of the USBEndpointDescriptor class.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBEndpointDescriptor.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Returns the number of an endpoint given its descriptor.
/// \param endpoint Pointer to a USBEndpointDescriptor instance.
/// \return Endpoint number.
//------------------------------------------------------------------------------
unsigned char USBEndpointDescriptor_GetNumber(
const USBEndpointDescriptor *endpoint)
{
return endpoint->bEndpointAddress & 0xF;
}
//------------------------------------------------------------------------------
/// Returns the direction of an endpoint given its descriptor.
/// \param endpoint Pointer to a USBEndpointDescriptor instance.
/// \return Endpoint direction (see <Endpoint directions>).
//------------------------------------------------------------------------------
unsigned char USBEndpointDescriptor_GetDirection(
const USBEndpointDescriptor *endpoint)
{
if ((endpoint->bEndpointAddress & 0x80) != 0) {
return USBEndpointDescriptor_IN;
}
else {
return USBEndpointDescriptor_OUT;
}
}
//------------------------------------------------------------------------------
/// Returns the type of an endpoint given its descriptor.
/// \param endpoint Pointer to a USBEndpointDescriptor instance.
/// \return Endpoint type (see <Endpoint types>).
//------------------------------------------------------------------------------
unsigned char USBEndpointDescriptor_GetType(
const USBEndpointDescriptor *endpoint)
{
return endpoint->bmAttributes & 0x3;
}
//------------------------------------------------------------------------------
/// Returns the maximum size of a packet (in bytes) on an endpoint given
/// its descriptor.
/// \param endpoint - Pointer to a USBEndpointDescriptor instance.
/// \return Maximum packet size of endpoint.
//------------------------------------------------------------------------------
unsigned short USBEndpointDescriptor_GetMaxPacketSize(
const USBEndpointDescriptor *endpoint)
{
return endpoint->wMaxPacketSize;
}
//------------------------------------------------------------------------------
/// Returns the polling interval on an endpoint given its descriptor.
/// \param endpoint - Pointer to a USBEndpointDescriptor instance.
/// \return Polling interval of endpoint.
//------------------------------------------------------------------------------
unsigned char USBEndpointDescriptor_GetInterval(
const USBEndpointDescriptor *endpoint)
{
return endpoint->bInterval;
}
@@ -0,0 +1,224 @@
/* ----------------------------------------------------------------------------
* 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 handling USB endpoint descriptors.
!!!Usage
-# Declare USBEndpointDescriptor instance as a part of the
configuration descriptors of a USB device.
-# To get useful information (field values) from the defined USB device
endpoint descriptor (to configure hardware for endpoints, etc), use
- USBEndpointDescriptor_GetNumber
- USBEndpointDescriptor_GetDirection
- USBEndpointDescriptor_GetType
- USBEndpointDescriptor_GetMaxPacketSize
*/
#ifndef USBENDPOINTDESCRIPTOR_H
#define USBENDPOINTDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Endpoint definitions"
///
/// This page lists definitions and macro for endpoint descriptors.
///
/// - USB Endpoint directions
/// - USBEndpointDescriptor_OUT
/// - USBEndpointDescriptor_IN
///
/// - USB Endpoint types
/// - USBEndpointDescriptor_CONTROL
/// - USBEndpointDescriptor_ISOCHRONOUS
/// - USBEndpointDescriptor_BULK
/// - USBEndpointDescriptor_INTERRUPT
///
/// - USB Endpoint maximun sizes
/// - USBEndpointDescriptor_MAXCTRLSIZE_FS
/// - USBEndpointDescriptor_MAXCTRLSIZE_HS
/// - USBEndpointDescriptor_MAXBULKSIZE_FS
/// - USBEndpointDescriptor_MAXBULKSIZE_HS
/// - USBEndpointDescriptor_MAXINTERRUPTSIZE_FS
/// - USBEndpointDescriptor_MAXINTERRUPTSIZE_HS
/// - USBEndpointDescriptor_MAXISOCHRONOUSSIZE_FS
/// - USBEndpointDescriptor_MAXISOCHRONOUSSIZE_HS
///
/// - USB Endpoint address define
/// - USBEndpointDescriptor_ADDRESS
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Endpoint directions"
///
/// This page lists definitions of USB endpoint directions.
///
/// !Directions
/// - USBEndpointDescriptor_OUT
/// - USBEndpointDescriptor_IN
/// Endpoint receives data from the host.
#define USBEndpointDescriptor_OUT 0
/// Endpoint sends data to the host.
#define USBEndpointDescriptor_IN 1
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Endpoint types"
///
/// This page lists definitions of USB endpoint types.
///
/// !Types
/// - USBEndpointDescriptor_CONTROL
/// - USBEndpointDescriptor_ISOCHRONOUS
/// - USBEndpointDescriptor_BULK
/// - USBEndpointDescriptor_INTERRUPT
/// Control endpoint type.
#define USBEndpointDescriptor_CONTROL 0
/// Isochronous endpoint type.
#define USBEndpointDescriptor_ISOCHRONOUS 1
/// Bulk endpoint type.
#define USBEndpointDescriptor_BULK 2
/// Interrupt endpoint type.
#define USBEndpointDescriptor_INTERRUPT 3
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Endpoint maximun sizes"
///
/// This page lists definitions of USB endpoint maximun sizes.
///
/// !Sizes
/// - USBEndpointDescriptor_MAXCTRLSIZE_FS
/// - USBEndpointDescriptor_MAXCTRLSIZE_HS
/// - USBEndpointDescriptor_MAXBULKSIZE_FS
/// - USBEndpointDescriptor_MAXBULKSIZE_HS
/// - USBEndpointDescriptor_MAXINTERRUPTSIZE_FS
/// - USBEndpointDescriptor_MAXINTERRUPTSIZE_HS
/// - USBEndpointDescriptor_MAXISOCHRONOUSSIZE_FS
/// - USBEndpointDescriptor_MAXISOCHRONOUSSIZE_HS
/// Maximum size for a full-speed control endpoint.
#define USBEndpointDescriptor_MAXCTRLSIZE_FS 64
/// Maximum size for a high-speed control endpoint.
#define USBEndpointDescriptor_MAXCTRLSIZE_HS 64
/// Maximum size for a full-speed bulk endpoint.
#define USBEndpointDescriptor_MAXBULKSIZE_FS 64
/// Maximum size for a high-speed bulk endpoint.
#define USBEndpointDescriptor_MAXBULKSIZE_HS 512
/// Maximum size for a full-speed interrupt endpoint.
#define USBEndpointDescriptor_MAXINTERRUPTSIZE_FS 64
/// Maximum size for a high-speed interrupt endpoint.
#define USBEndpointDescriptor_MAXINTERRUPTSIZE_HS 1024
/// Maximum size for a full-speed isochronous endpoint.
#define USBEndpointDescriptor_MAXISOCHRONOUSSIZE_FS 1023
/// Maximum size for a high-speed isochronous endpoint.
#define USBEndpointDescriptor_MAXISOCHRONOUSSIZE_HS 1024
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Endpoint address define"
///
/// This page lists macro for USB endpoint address definition.
///
/// !Macro
/// - USBEndpointDescriptor_ADDRESS
/// Calculates the address of an endpoint given its number and direction
/// \param direction USB endpoint direction definition
/// \param number USB endpoint number
/// \return The value used to set the endpoint descriptor based on input number
/// and direction
#define USBEndpointDescriptor_ADDRESS(direction, number) \
(((direction & 0x01) << 7) | (number & 0xF))
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// USB standard endpoint descriptor structure.
//------------------------------------------------------------------------------
typedef struct {
/// Size of the descriptor in bytes.
unsigned char bLength;
/// Descriptor type (<USBGenericDescriptor_ENDPOINT>).
unsigned char bDescriptorType;
/// Address and direction of the endpoint.
unsigned char bEndpointAddress;
/// Endpoint type and additional characteristics (for isochronous endpoints).
unsigned char bmAttributes;
/// Maximum packet size (in bytes) of the endpoint.
unsigned short wMaxPacketSize;
/// Polling rate of the endpoint.
unsigned char bInterval;
} __attribute__ ((packed)) USBEndpointDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char USBEndpointDescriptor_GetNumber(
const USBEndpointDescriptor *endpoint);
extern unsigned char USBEndpointDescriptor_GetDirection(
const USBEndpointDescriptor *endpoint);
extern unsigned char USBEndpointDescriptor_GetType(
const USBEndpointDescriptor *endpoint);
extern unsigned short USBEndpointDescriptor_GetMaxPacketSize(
const USBEndpointDescriptor *endpoint);
extern unsigned char USBEndpointDescriptor_GetInterval(
const USBEndpointDescriptor *endpoint);
#endif //#ifndef USBENDPOINTDESCRIPTOR_H
@@ -0,0 +1,70 @@
/* ----------------------------------------------------------------------------
* 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: USBFeatureRequest implementation
About: Purpose
Implementation of the USBFeatureRequest class.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBFeatureRequest.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Returns the feature selector of a given CLEAR_FEATURE or SET_FEATURE
/// request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Feature selector.
//------------------------------------------------------------------------------
unsigned char USBFeatureRequest_GetFeatureSelector(
const USBGenericRequest *request)
{
return USBGenericRequest_GetValue(request);
}
//------------------------------------------------------------------------------
/// Indicates the test that the device must undertake following a
/// SET_FEATURE request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Test selector.
//------------------------------------------------------------------------------
unsigned char USBFeatureRequest_GetTestSelector(
const USBGenericRequest *request)
{
return (USBGenericRequest_GetIndex(request) >> 8) & 0xFF;
}
@@ -0,0 +1,146 @@
/* ----------------------------------------------------------------------------
* 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 CLEAR_FEATURE and SET_FEATURE
requests.
!!!Usage
- To get USB feature request information (field values) from the
USBGenericRequest instance, use
- USBFeatureRequest_GetFeatureSelector
- USBFeatureRequest_GetTestSelector
*/
#ifndef USBFEATUREREQUEST_H
#define USBFEATUREREQUEST_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBGenericRequest.h"
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Feature Request definitions"
///
/// This page lists codes of USB Feature Request
///
/// - USB Feature selectors
/// - USBFeatureRequest_ENDPOINTHALT
/// - USBFeatureRequest_DEVICEREMOTEWAKEUP
/// - USBFeatureRequest_TESTMODE
///
/// - USB Test mode selectors
/// - USBFeatureRequest_TESTJ
/// - USBFeatureRequest_TESTK
/// - USBFeatureRequest_TESTSE0NAK
/// - USBFeatureRequest_TESTPACKET
/// - USBFeatureRequest_TESTFORCEENABLE
/// - USBFeatureRequest_TESTSENDZLP
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Feature selectors"
///
/// This page lists codes of USB feature selectors.
///
/// !Selectors
/// - USBFeatureRequest_ENDPOINTHALT
/// - USBFeatureRequest_DEVICEREMOTEWAKEUP
/// - USBFeatureRequest_TESTMODE
/// Halt feature of an endpoint.
#define USBFeatureRequest_ENDPOINTHALT 0
/// Remote wake-up feature of the device.
#define USBFeatureRequest_DEVICEREMOTEWAKEUP 1
/// Test mode of the device.
#define USBFeatureRequest_TESTMODE 2
/// OTG set feature
#define USBFeatureRequest_OTG 0x0B
//------------------------------------------------------------------------------
/// On The Go Feature Selectors
/// b_hnp_enable 3
/// a_hnp_support 4
/// a_alt_hnp_support 5
#define USBFeatureRequest_OTG_B_HNP_ENABLE 3
#define USBFeatureRequest_OTG_A_HNP_SUPPORT 4
#define USBFeatureRequest_OTG_A_ALT_HNP_SUPPORT 5
//------------------------------------------------------------------------------
/// \page "USB Test mode selectors"
///
/// This page lists codes of USB high speed test mode selectors.
///
/// !Selectors
/// - USBFeatureRequest_TESTJ
/// - USBFeatureRequest_TESTK
/// - USBFeatureRequest_TESTSE0NAK
/// - USBFeatureRequest_TESTPACKET
/// - USBFeatureRequest_TESTFORCEENABLE
/// - USBFeatureRequest_TESTSENDZLP
/// Tests the high-output drive level on the D+ line.
#define USBFeatureRequest_TESTJ 1
/// Tests the high-output drive level on the D- line.
#define USBFeatureRequest_TESTK 2
/// Tests the output impedance, low-level output voltage and loading
/// characteristics.
#define USBFeatureRequest_TESTSE0NAK 3
/// Tests rise and fall times, eye patterns and jitter.
#define USBFeatureRequest_TESTPACKET 4
/// Tests the hub disconnect detection.
#define USBFeatureRequest_TESTFORCEENABLE 5
/// Send a ZLP in Test Mode.
#define USBFeatureRequest_TESTSENDZLP 6
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char USBFeatureRequest_GetFeatureSelector(
const USBGenericRequest *request);
extern unsigned char USBFeatureRequest_GetTestSelector(
const USBGenericRequest *request);
#endif //#ifndef USBFEATUREREQUEST_H
@@ -0,0 +1,80 @@
/* ----------------------------------------------------------------------------
* 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: USBGenericDescriptor implementation
About: Purpose
Implementation of the USBGenericDescriptor class.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBGenericDescriptor.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Returns the length of a descriptor.
/// \param descriptor Pointer to a USBGenericDescriptor instance.
/// \return Length of descriptor in bytes.
//------------------------------------------------------------------------------
unsigned int USBGenericDescriptor_GetLength(
const USBGenericDescriptor *descriptor)
{
return descriptor->bLength;
}
//------------------------------------------------------------------------------
/// Returns the type of a descriptor.
/// \param descriptor Pointer to a USBGenericDescriptor instance.
/// \return Type of descriptor.
//------------------------------------------------------------------------------
unsigned char USBGenericDescriptor_GetType(
const USBGenericDescriptor *descriptor)
{
return descriptor->bDescriptorType;
}
//------------------------------------------------------------------------------
/// Returns a pointer to the descriptor right after the given one, when
/// parsing a Configuration descriptor.
/// \param descriptor - Pointer to a USBGenericDescriptor instance.
/// \return Pointer to the next descriptor.
//------------------------------------------------------------------------------
USBGenericDescriptor *USBGenericDescriptor_GetNextDescriptor(
const USBGenericDescriptor *descriptor)
{
return (USBGenericDescriptor *)
(((char *) descriptor) + USBGenericDescriptor_GetLength(descriptor));
}
@@ -0,0 +1,133 @@
/* ----------------------------------------------------------------------------
* 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 generic USB descriptor class.
///
/// !!!Usage
///
/// -# Declare or access USB descriptors by USBGenericDescriptor instance.
/// -# To get usful information (field values) from the USB descriptors, use
/// - USBGenericDescriptor_GetLength
/// - USBGenericDescriptor_GetType
/// -# To scan the descriptors, use
/// - USBGenericDescriptor_GetNextDescriptor
//------------------------------------------------------------------------------
#ifndef USBGENERICDESCRIPTOR_H
#define USBGENERICDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Descriptor types"
///
/// This page lists the codes of the usb descriptor types
///
/// !Types
/// - USBGenericDescriptor_DEVICE
/// - USBGenericDescriptor_CONFIGURATION
/// - USBGenericDescriptor_STRING
/// - USBGenericDescriptor_INTERFACE
/// - USBGenericDescriptor_ENDPOINT
/// - USBGenericDescriptor_DEVICEQUALIFIER
/// - USBGenericDescriptor_OTHERSPEEDCONFIGURATION
/// - USBGenericDescriptor_INTERFACEPOWER
/// - USBGenericDescriptor_OTG
/// - USBGenericDescriptor_DEBUG
/// - USBGenericDescriptor_INTERFACEASSOCIATION
/// Device descriptor type.
#define USBGenericDescriptor_DEVICE 1
/// Configuration descriptor type.
#define USBGenericDescriptor_CONFIGURATION 2
/// String descriptor type.
#define USBGenericDescriptor_STRING 3
/// Interface descriptor type.
#define USBGenericDescriptor_INTERFACE 4
/// Endpoint descriptor type.
#define USBGenericDescriptor_ENDPOINT 5
/// Device qualifier descriptor type.
#define USBGenericDescriptor_DEVICEQUALIFIER 6
/// Other speed configuration descriptor type.
#define USBGenericDescriptor_OTHERSPEEDCONFIGURATION 7
/// Interface power descriptor type.
#define USBGenericDescriptor_INTERFACEPOWER 8
/// On-The-Go descriptor type.
#define USBGenericDescriptor_OTG 9
/// Debug descriptor type.
#define USBGenericDescriptor_DEBUG 10
/// Interface association descriptor type.
#define USBGenericDescriptor_INTERFACEASSOCIATION 11
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
/// Holds the few fields shared by all USB descriptors.
typedef struct {
/// Length of the descriptor in bytes.
unsigned char bLength;
/// Descriptor type.
unsigned char bDescriptorType;
} __attribute__ ((packed)) USBGenericDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned int USBGenericDescriptor_GetLength(
const USBGenericDescriptor *descriptor);
extern unsigned char USBGenericDescriptor_GetType(
const USBGenericDescriptor *descriptor);
extern USBGenericDescriptor *USBGenericDescriptor_GetNextDescriptor(
const USBGenericDescriptor *descriptor);
#endif //#ifndef USBGENERICDESCRIPTOR_H
@@ -0,0 +1,138 @@
/* ----------------------------------------------------------------------------
* 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: USBGenericRequest implementation
About: Purpose
Implementation of the USBGenericRequest class.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBGenericRequest.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Returns the type of the given request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return "USB Request Types"
//------------------------------------------------------------------------------
extern unsigned char USBGenericRequest_GetType(const USBGenericRequest *request)
{
return ((request->bmRequestType >> 5) & 0x3);
}
//------------------------------------------------------------------------------
/// Returns the request code of the given request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Request code.
/// \sa "USB Request Codes"
//------------------------------------------------------------------------------
unsigned char USBGenericRequest_GetRequest(const USBGenericRequest *request)
{
return request->bRequest;
}
//------------------------------------------------------------------------------
/// Returns the wValue field of the given request.
/// \param request - Pointer to a USBGenericRequest instance.
/// \return Request value.
//------------------------------------------------------------------------------
unsigned short USBGenericRequest_GetValue(const USBGenericRequest *request)
{
return request->wValue;
}
//------------------------------------------------------------------------------
/// Returns the wIndex field of the given request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Request index;
//------------------------------------------------------------------------------
unsigned short USBGenericRequest_GetIndex(const USBGenericRequest *request)
{
return request->wIndex;
}
//------------------------------------------------------------------------------
/// Returns the expected length of the data phase following a request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Length of data phase.
//------------------------------------------------------------------------------
unsigned short USBGenericRequest_GetLength(const USBGenericRequest *request)
{
return request->wLength;
}
//------------------------------------------------------------------------------
/// Returns the endpoint number targetted by a given request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Endpoint number.
//------------------------------------------------------------------------------
unsigned char USBGenericRequest_GetEndpointNumber(
const USBGenericRequest *request)
{
return USBGenericRequest_GetIndex(request) & 0xF;
}
//------------------------------------------------------------------------------
/// Returns the intended recipient of a given request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Request recipient.
/// \sa "USB Request Recipients"
//------------------------------------------------------------------------------
unsigned char USBGenericRequest_GetRecipient(const USBGenericRequest *request)
{
// Recipient is in bits [0..4] of the bmRequestType field
return request->bmRequestType & 0xF;
}
//------------------------------------------------------------------------------
/// Returns the direction of the data transfer following the given request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Transfer direction.
/// \sa "USB Request Directions"
//------------------------------------------------------------------------------
unsigned char USBGenericRequest_GetDirection(const USBGenericRequest *request)
{
// Transfer direction is located in bit D7 of the bmRequestType field
if ((request->bmRequestType & 0x80) != 0) {
return USBGenericRequest_IN;
}
else {
return USBGenericRequest_OUT;
}
}
@@ -0,0 +1,244 @@
/* ----------------------------------------------------------------------------
* 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 USBGenericRequest class and its methods.
!!!Usage
-# Declare or access USB requests by USBGenericRequest instance.
-# To get usful information (field values) from the USB requests, use
- USBGenericRequest_GetType
- USBGenericRequest_GetRequest
- USBGenericRequest_GetValue
- USBGenericRequest_GetIndex
- USBGenericRequest_GetLength
- USBGenericRequest_GetEndpointNumber
- USBGenericRequest_GetRecipient
- USBGenericRequest_GetDirection
*/
#ifndef USBGENERICREQUEST_H
#define USBGENERICREQUEST_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Generic Request definitions"
///
/// This page lists the codes of USB generic request.
///
/// - USB Request codes
/// - USBGenericRequest_GETSTATUS
/// - USBGenericRequest_CLEARFEATURE
/// - USBGenericRequest_SETFEATURE
/// - USBGenericRequest_SETADDRESS
/// - USBGenericRequest_GETDESCRIPTOR
/// - USBGenericRequest_SETDESCRIPTOR
/// - USBGenericRequest_GETCONFIGURATION
/// - USBGenericRequest_SETCONFIGURATION
/// - USBGenericRequest_GETINTERFACE
/// - USBGenericRequest_SETINTERFACE
/// - USBGenericRequest_SYNCHFRAME
///
/// - USB Request Recipients
/// - USBGenericRequest_DEVICE
/// - USBGenericRequest_INTERFACE
/// - USBGenericRequest_ENDPOINT
/// - USBGenericRequest_OTHER
///
/// - USB Request Types
/// - USBGenericRequest_STANDARD
/// - USBGenericRequest_CLASS
/// - USBGenericRequest_VENDOR
///
/// - USB Request Directions
/// - USBGenericRequest_IN
/// - USBGenericRequest_OUT
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Request codes"
///
/// This page lists the USB generic request codes.
///
/// !Codes
/// - USBGenericRequest_GETSTATUS
/// - USBGenericRequest_CLEARFEATURE
/// - USBGenericRequest_SETFEATURE
/// - USBGenericRequest_SETADDRESS
/// - USBGenericRequest_GETDESCRIPTOR
/// - USBGenericRequest_SETDESCRIPTOR
/// - USBGenericRequest_GETCONFIGURATION
/// - USBGenericRequest_SETCONFIGURATION
/// - USBGenericRequest_GETINTERFACE
/// - USBGenericRequest_SETINTERFACE
/// - USBGenericRequest_SYNCHFRAME
/// GET_STATUS request code.
#define USBGenericRequest_GETSTATUS 0
/// CLEAR_FEATURE request code.
#define USBGenericRequest_CLEARFEATURE 1
/// SET_FEATURE request code.
#define USBGenericRequest_SETFEATURE 3
/// SET_ADDRESS request code.
#define USBGenericRequest_SETADDRESS 5
/// GET_DESCRIPTOR request code.
#define USBGenericRequest_GETDESCRIPTOR 6
/// SET_DESCRIPTOR request code.
#define USBGenericRequest_SETDESCRIPTOR 7
/// GET_CONFIGURATION request code.
#define USBGenericRequest_GETCONFIGURATION 8
/// SET_CONFIGURATION request code.
#define USBGenericRequest_SETCONFIGURATION 9
/// GET_INTERFACE request code.
#define USBGenericRequest_GETINTERFACE 10
/// SET_INTERFACE request code.
#define USBGenericRequest_SETINTERFACE 11
/// SYNCH_FRAME request code.
#define USBGenericRequest_SYNCHFRAME 12
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Request Recipients"
///
/// This page lists codes of USB request recipients.
///
/// !Recipients
/// - USBGenericRequest_DEVICE
/// - USBGenericRequest_INTERFACE
/// - USBGenericRequest_ENDPOINT
/// - USBGenericRequest_OTHER
/// Recipient is the whole device.
#define USBGenericRequest_DEVICE 0
/// Recipient is an interface.
#define USBGenericRequest_INTERFACE 1
/// Recipient is an endpoint.
#define USBGenericRequest_ENDPOINT 2
/// Recipient is another entity.
#define USBGenericRequest_OTHER 3
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Request Types"
///
/// This page lists codes of USB request types.
///
/// !Types
/// - USBGenericRequest_STANDARD
/// - USBGenericRequest_CLASS
/// - USBGenericRequest_VENDOR
/// Request is standard.
#define USBGenericRequest_STANDARD 0
/// Request is class-specific.
#define USBGenericRequest_CLASS 1
/// Request is vendor-specific.
#define USBGenericRequest_VENDOR 2
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB Request Directions"
///
/// This page lists codes of USB request directions.
///
/// !Directions
/// - USBGenericRequest_IN
/// - USBGenericRequest_OUT
/// Transfer occurs from device to the host.
#define USBGenericRequest_OUT 0
/// Transfer occurs from the host to the device.
#define USBGenericRequest_IN 1
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Generic USB SETUP request sent over Control endpoints.
//------------------------------------------------------------------------------
typedef struct {
/// Type of request
/// \sa "USB Request Recipients"
/// \sa "USB Request Types"
/// \sa "USB Request Directions"
unsigned char bmRequestType:8;
/// Request code
/// \sa "USB Request Codes"
unsigned char bRequest:8;
/// Request-specific value parameter.
unsigned short wValue:16;
/// Request-specific index parameter.
unsigned short wIndex:16;
/// Expected length (in bytes) of the data phase.
unsigned short wLength:16;
} USBGenericRequest;
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char USBGenericRequest_GetType(
const USBGenericRequest *request);
extern unsigned char USBGenericRequest_GetRequest(
const USBGenericRequest *request);
extern unsigned short USBGenericRequest_GetValue(
const USBGenericRequest *request);
extern unsigned short USBGenericRequest_GetIndex(
const USBGenericRequest *request);
extern unsigned short USBGenericRequest_GetLength(
const USBGenericRequest *request);
extern unsigned char USBGenericRequest_GetEndpointNumber(
const USBGenericRequest *request);
extern unsigned char USBGenericRequest_GetRecipient(
const USBGenericRequest *request);
extern unsigned char USBGenericRequest_GetDirection(
const USBGenericRequest *request);
#endif //#ifndef USBGENERICREQUEST_H
@@ -0,0 +1,72 @@
/* ----------------------------------------------------------------------------
* 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: USBGetDescriptorRequest implementation
About: Purpose
Implementation of the USBGetDescriptorRequest class.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBGetDescriptorRequest.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Returns the type of the descriptor requested by the host given the
/// corresponding GET_DESCRIPTOR request.
/// \param request Pointer to a USBGenericDescriptor instance.
/// \return Type of the requested descriptor.
//------------------------------------------------------------------------------
unsigned char USBGetDescriptorRequest_GetDescriptorType(
const USBGenericRequest *request)
{
// Requested descriptor type is in the high-byte of the wValue field
return (USBGenericRequest_GetValue(request) >> 8) & 0xFF;
}
//------------------------------------------------------------------------------
/// Returns the index of the requested descriptor, given the corresponding
/// GET_DESCRIPTOR request.
/// \param request Pointer to a USBGenericDescriptor instance.
/// \return Index of the requested descriptor.
//------------------------------------------------------------------------------
unsigned char USBGetDescriptorRequest_GetDescriptorIndex(
const USBGenericRequest *request)
{
// Requested descriptor index if in the low byte of the wValue field
return USBGenericRequest_GetValue(request) & 0xFF;
}
@@ -0,0 +1,67 @@
/* ----------------------------------------------------------------------------
* 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 USBGetDescriptorRequest class.
!!!Usage
- After a GET_DESCRIPTOR request has been received, retrive the useful
values with following functions:
- USBGetDescriptorRequest_GetDescriptorType: the descriptor type
- USBGetDescriptorRequest_GetDescriptorIndex: the index of the requested
descriptor
*/
#ifndef USBGETDESCRIPTORREQUEST_H
#define USBGETDESCRIPTORREQUEST_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBGenericRequest.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char USBGetDescriptorRequest_GetDescriptorType(
const USBGenericRequest *request);
extern unsigned char USBGetDescriptorRequest_GetDescriptorIndex(
const USBGenericRequest *request);
#endif //#ifndef USBGETDESCRIPTORREQUEST_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 (<USBGenericDescriptor_IAD>).
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
@@ -0,0 +1,87 @@
/* ----------------------------------------------------------------------------
* 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 USB interface descriptors.
!!!Usage
- Declare USBInterfaceDescriptor instance as a part of the configuration
descriptors of a USB device.
*/
#ifndef USBINTERFACEDESCRIPTOR_H
#define USBINTERFACEDESCRIPTOR_H
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// USB standard interface descriptor structure.
//------------------------------------------------------------------------------
typedef struct {
/// Size of the descriptor in bytes.
unsigned char bLength;
/// Descriptor type (USBGenericDescriptor_INTERFACE).
unsigned char bDescriptorType;
/// Number of the interface in its configuration.
unsigned char bInterfaceNumber;
/// Value to select this alternate interface setting.
unsigned char bAlternateSetting;
/// Number of endpoints used by the inteface (excluding endpoint 0).
unsigned char bNumEndpoints;
/// Interface class code.
unsigned char bInterfaceClass;
/// Interface subclass code.
unsigned char bInterfaceSubClass;
/// Interface protocol code.
unsigned char bInterfaceProtocol;
/// Index of the interface string descriptor.
unsigned char iInterface;
} __attribute__ ((packed)) USBInterfaceDescriptor; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
#endif //#ifndef USBINTERFACEDESCRIPTOR_H
@@ -0,0 +1,69 @@
/* ----------------------------------------------------------------------------
* 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: USBInterfaceRequest
About: Purpose
Implementation of USBInterfaceRequest class methods.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBInterfaceRequest.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Indicates which interface is targetted by a GET_INTERFACE or
/// SET_INTERFACE request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Interface number.
//------------------------------------------------------------------------------
unsigned char USBInterfaceRequest_GetInterface(const USBGenericRequest *request)
{
return (USBGenericRequest_GetIndex(request) & 0xFF);
}
//------------------------------------------------------------------------------
/// Indicates the new alternate setting that the interface targetted by a
/// SET_INTERFACE request should use.
/// \param request Pointer to a USBGenericRequest instance.
/// \return New active setting for the interface.
//------------------------------------------------------------------------------
unsigned char USBInterfaceRequest_GetAlternateSetting(
const USBGenericRequest *request)
{
return (USBGenericRequest_GetValue(request) & 0xFF);
}
@@ -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 for manipulating SET_INTERFACE and GET_INTERFACE request.
!!!Usage
-# After a SET_INTERFACE request has been received, retrieve the
target interface using USBInterfaceRequest_GetInterface and its
new alternate setting with USBInterfaceRequest_GetAlternateSetting.
-# After a GET_INTERFACE request has been received, retrieve the target
interface using USBInterfaceRequest_GetInterface.
*/
#ifndef USBINTERFACEREQUEST_H
#define USBINTERFACEREQUEST_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBGenericRequest.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char USBInterfaceRequest_GetInterface(
const USBGenericRequest *request);
extern unsigned char USBInterfaceRequest_GetAlternateSetting(
const USBGenericRequest *request);
#endif //#ifndef USBINTERFACEREQUEST_H
@@ -0,0 +1,62 @@
/* ----------------------------------------------------------------------------
* 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: USBIrqHandler implementation
About: Purpose
Implementation of the USB Interrupt Handler.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <board.h>
#include <usb/device/core/USBD.h>
#include <exceptions.h>
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Call Arbitrer, device and host interrupt handler.
/// The IRQ functions are defined with weak and can be surcharged if needed.
//------------------------------------------------------------------------------
void USB_IrqHandler( void )
{
// Most arbitrer interrupt
usb_general_interrupt();
// Device interrupt
USBD_IrqHandler();
// Host interrupt
usb_pipe_interrupt();
}
@@ -0,0 +1,52 @@
/* ----------------------------------------------------------------------------
* 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
Implementation of the USB Interrupt Handler.
!!!Usage
-# The IRQ functions are defined with weak and can be surcharged if needed.
*/
#ifndef USBIRQHANDLER_H
#define USBIRQHANDLER_H
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern void USB_IrqHandler( void );
#endif //#ifndef USBIRQHANDLER_H
@@ -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: USBSetAddressRequest implementation
About: Purpose
Implementation of the USBSetAddressRequest class.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBSetAddressRequest.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Returns the address that the device must take in response to a
/// SET_ADDRESS request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return New device address.
//------------------------------------------------------------------------------
unsigned char USBSetAddressRequest_GetAddress(const USBGenericRequest *request)
{
return USBGenericRequest_GetValue(request) & 0x7F;
}
@@ -0,0 +1,60 @@
/* ----------------------------------------------------------------------------
* 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 SET_ADDRESS USB requests.
!!!Usage
- After a SET_ADDRESS request has been received, retrive the new address
value with USBSetAddressRequest_GetAddress.
*/
#ifndef USBSETADDRESSREQUEST_H
#define USBSETADDRESSREQUEST_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBGenericRequest.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char USBSetAddressRequest_GetAddress(
const USBGenericRequest *request);
#endif //#ifndef USBSETADDRESSREQUEST_H
@@ -0,0 +1,58 @@
/* ----------------------------------------------------------------------------
* 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: USBSetConfigurationRequest implementation
About: Purpose
Implementation of the USBSetConfigurationRequest class.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBSetConfigurationRequest.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Returns the number of the configuration that should be set in response
/// to the given SET_CONFIGURATION request.
/// \param request Pointer to a USBGenericRequest instance.
/// \return Number of the requested configuration.
//------------------------------------------------------------------------------
unsigned char USBSetConfigurationRequest_GetConfiguration(
const USBGenericRequest *request)
{
return USBGenericRequest_GetValue(request);
}
@@ -0,0 +1,61 @@
/* ----------------------------------------------------------------------------
* 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 the Set Configuration request.
!!!Usage
- After a SET_CONFIGURATION request has been received, retrive the new
configuration value with USBSetConfigurationRequest_GetConfiguration.
*/
#ifndef USBSETCONFIGURATIONREQUEST_H
#define USBSETCONFIGURATIONREQUEST_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "USBGenericRequest.h"
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char USBSetConfigurationRequest_GetConfiguration(
const USBGenericRequest *request);
#endif //#ifndef USBSETCONFIGURATIONREQUEST_H
@@ -0,0 +1,74 @@
/* ----------------------------------------------------------------------------
* 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 String descriptors.
//------------------------------------------------------------------------------
#ifndef USBSTRINGDESCRIPTOR_H
#define USBSTRINGDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "USB String Descriptor definitions"
///
/// This page lists the codes and macros for USB string descriptor definition.
///
/// !Language IDs
/// - USBStringDescriptor_ENGLISH_US
///
/// !String Descriptor Length
/// - USBStringDescriptor_LENGTH
///
/// !ASCII to UNICODE convertion
/// - USBStringDescriptor_UNICODE
/// Language ID for US english.
#define USBStringDescriptor_ENGLISH_US 0x09, 0x04
/// Calculates the length of a string descriptor given the number of ascii
/// characters/language IDs in it.
/// \param length The ascii format string length.
/// \return The actual data length in bytes.
#define USBStringDescriptor_LENGTH(length) ((length) * 2 + 2)
/// Converts an ascii character to its unicode representation.
/// \param ascii The ASCII character to convert
/// \return A 2-byte-array for the UNICODE based on given ASCII
#define USBStringDescriptor_UNICODE(ascii) (ascii), 0
//------------------------------------------------------------------------------
#endif //#ifndef USBSTRINGDESCRIPTOR_H
@@ -0,0 +1,53 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \dir
/// !!!Purpose
///
/// This directory contains definitions, structures and functions described by
/// USB specification. They can be divided into two groups:
/// - USB descriptors, prefixed with USB and suffixed with Descriptor.
/// - USB requests, prefixed with USB and suffixed with Request.
//------------------------------------------------------------------------------
/**
\page "Standard USB Structures"
!!!Standard USB Structures
The following standard structures is implemented in the USB framework:
- Setup request data: USBGenericRequest
- Descriptor header: USBGenericDescriptor
- Device descriptor: USBDeviceDescriptor
- Configuration descriptor: USBConfigurationDescriptor
- Interface descriptor: USBInterfaceDescriptor
- %Endpoint descriptor: USBEndpointDescriptor
- Device_Qualifier descriptor: USBDeviceQualifierDescriptor
*/
@@ -0,0 +1,55 @@
/* ----------------------------------------------------------------------------
* 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: HIDButton
About: Purpose
Definitions of constants and methods for the HID Button usage page.
About: Usage
1 - Use the constants declared in this file when instanciating a
Report descriptor instance.
2 - When implementing the functionality of an HID Mouse, use the
key codes defined here to indicate keys that are being pressed and
released.
*/
#ifndef _HIDBUTTON_H
#define _HIDBUTTON_H
//------------------------------------------------------------------------------
// Constants
//------------------------------------------------------------------------------
/// Identifier for the HID button usage page
#define HIDButton_PAGEID 0x09
#endif
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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);
}
@@ -0,0 +1,68 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
/**
\unit
!!!Purpose
Methods and constants for manipulating HID-specific GET_IDLE and SET_IDLE
requests.
!!!Usage
-# Retrieve the idle rate indicated by a GET_IDLE or SET_IDLE request
with HIDIdleRequest_GetIdleRate.
*/
#ifndef HIDIDLEREQUEST_H
#define HIDIDLEREQUEST_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <usb/common/core/USBGenericRequest.h>
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
/// Infinite idle rate.
#define HIDIdleRequest_INFINITE 0
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char HIDIdleRequest_GetIdleRate(
const USBGenericRequest *request);
#endif //#ifndef HIDIDLEREQUEST_H
@@ -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
@@ -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));
}
@@ -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
@@ -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
@@ -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
@@ -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);
}
@@ -0,0 +1,86 @@
/* ----------------------------------------------------------------------------
* ATMEL Microcontroller Software Support
* ----------------------------------------------------------------------------
* Copyright (c) 2008, Atmel Corporation
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
*
* Atmel's name may not be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ----------------------------------------------------------------------------
*/
/**
\unit
!!!Purpose
Definition of a class for manipulating HID-specific GET_REPORT and
SET_REPORT requests.
!!!Usage
-# Receive a GET_REPORT or SET_REPORT request from the host.
-# Retrieve the report type using HIDReportRequest_GetReportType.
-# Retrieve the report ID using HIDReportRequest_GetReportId.
*/
#ifndef HIDREPORTREQUEST_H
#define HIDREPORTREQUEST_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <usb/common/core/USBGenericRequest.h>
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "HID Report Types"
/// This page lists the types for USB HID Reports.
///
/// !Types
/// - HIDReportRequest_INPUT
/// - HIDReportRequest_OUTPUT
/// - HIDReportRequest_FEATURE
/// Input report.
#define HIDReportRequest_INPUT 1
/// Output report.
#define HIDReportRequest_OUTPUT 2
/// Feature report.
#define HIDReportRequest_FEATURE 3
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern unsigned char HIDReportRequest_GetReportType(
const USBGenericRequest *request);
extern unsigned char HIDReportRequest_GetReportId(
const USBGenericRequest *request);
#endif //#ifndef HIDREPORTREQUEST_H
@@ -0,0 +1,39 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \dir
/// !Purpose
///
/// This directory contains structures and definitions related to the USB HID
/// specification. They can be divided into two groups:
/// - HID-specific descriptors, prefixed with HID and suffixed with Descriptor.
/// - HID-specific requests, prefixed with HID and suffixed with Request.
//------------------------------------------------------------------------------
@@ -0,0 +1,73 @@
/* ----------------------------------------------------------------------------
* 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
///
/// Declaration of constants for using Device Descriptors with a Mass Storage
/// driver.
///
/// !Usage
///
/// - For a USB device:
/// -# When declaring a USBDeviceDescriptor instance, use the Mass Storage
/// codes defined in this file (see "MS device codes").
//------------------------------------------------------------------------------
#ifndef MSDEVICEDESCRIPTOR_H
#define MSDEVICEDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "MS device codes"
/// This page lists the class, subclass & protocol codes used by a device with
/// a Mass Storage driver.
///
/// !Codes
///
/// - MSDeviceDescriptor_CLASS
/// - MSDeviceDescriptor_SUBCLASS
/// - MSDeviceDescriptor_PROTOCOL
/// Class code for a Mass Storage device.
#define MSDeviceDescriptor_CLASS 0
/// Subclass code for a Mass Storage device.
#define MSDeviceDescriptor_SUBCLASS 0
/// Protocol code for a Mass Storage device.
#define MSDeviceDescriptor_PROTOCOL 0
//------------------------------------------------------------------------------
#endif //#ifndef MSDEVICEDESCRIPTOR_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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \unit
/// !Purpose
///
/// Definition of several constants used when manipulating Mass Storage interface
/// descriptors.
///
/// !Usage
///
/// - For a USB device:
/// -# When declaring an interface descriptor for a Mass Storage device, use
/// the class, subclass and protocol codes defined here (see
/// "MS interface codes").
//------------------------------------------------------------------------------
#ifndef MSINTERFACEDESCRIPTOR_H
#define MSINTERFACEDESCRIPTOR_H
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "MS interface codes"
/// This page lists the available class, subclass & protocol codes for a Mass
/// Storage interface.
///
/// !Codes
///
/// - MSInterfaceDescriptor_CLASS
/// - MSInterfaceDescriptor_SCSI
/// - MSInterfaceDescriptor_BULKONLY
/// Class code for a Mass Storage interface.
#define MSInterfaceDescriptor_CLASS 0x08
/// Subclass code for a Mass Storage interface using the SCSI protocol.
#define MSInterfaceDescriptor_SCSI 0x06
/// Protocol code for a Mass Storage interface using Bulk-Only Transport.
#define MSInterfaceDescriptor_BULKONLY 0x50
//------------------------------------------------------------------------------
#endif //#ifndef MSINTERFACEDESCRIPTOR_H
@@ -0,0 +1,39 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \dir
/// !Purpose
///
/// This directory contains structures and definitions related to the USB mass
/// storage specification.
/// - Mass-storage-specific descriptors, prefixed with MS and suffixed with
/// Descriptor.
//------------------------------------------------------------------------------
Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

@@ -0,0 +1,129 @@
/* ----------------------------------------------------------------------------
* 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: AUDDLoopRecChannel implementation
About: Purpose
Implementation of the AUDDLoopRecChannel functions.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "AUDDLoopRecChannel.h"
#include <utility/trace.h>
//------------------------------------------------------------------------------
// Callbacks
//------------------------------------------------------------------------------
/*
Function: AUDDLoopRecChannel_MuteChanged
Callback triggered when the mute status of a channel changes. This is
a default implementation which does nothing and must be overriden.
Parameters:
channel - Pointer to a AUDDLoopRecChannel instance.
muted - New mute status.
*/
//__attribute__ ((weak)) void AUDDLoopRecChannel_MuteChanged(
// AUDDLoopRecChannel *channel,
// unsigned char muted)
//{
// TRACE_DEBUG("MuteChanged(%d, %d) ", channel->number, muted);
//}
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Initializes the member variables of an AUDDLoopRecChannel object to the
/// given values.
/// \param channel Pointer to an AUDDLoopRecChannel instance.
/// \param number Channel number in the audio function.
/// \param muted Indicates if the channel is muted.
//------------------------------------------------------------------------------
void AUDDLoopRecChannel_Initialize(AUDDLoopRecChannel *channel,
unsigned char number,
unsigned char muted)
{
channel->number = number;
channel->muted = muted;
}
//------------------------------------------------------------------------------
/// Indicates the number of a channel.
/// \param channel Pointer to an AUDDLoopRecChannel instance.
/// \return Channel number.
//------------------------------------------------------------------------------
unsigned char AUDDLoopRecChannel_GetNumber(const AUDDLoopRecChannel *channel)
{
return channel->number;
}
//------------------------------------------------------------------------------
/// Mutes the given channel and triggers the MuteChanged callback if
/// necessary.
/// \param channel Pointer to an AUDDLoopRecChannelInstance.
//------------------------------------------------------------------------------
void AUDDLoopRecChannel_Mute(AUDDLoopRecChannel *channel)
{
if (!channel->muted) {
channel->muted = 1;
AUDDLoopRecChannel_MuteChanged(channel, 1);
}
}
//------------------------------------------------------------------------------
/// Unmutes the given channel and triggers the MuteChanged callback if
/// necessary.
/// \param channel Pointer to an AUDDLoopRecChannelInstance.
//------------------------------------------------------------------------------
void AUDDLoopRecChannel_Unmute(AUDDLoopRecChannel *channel)
{
if (channel->muted) {
channel->muted = 0;
AUDDLoopRecChannel_MuteChanged(channel, 0);
}
}
//------------------------------------------------------------------------------
/// Indicates if the given channel is currently muted or not.
/// \param channel Pointer an AUDDLoopRecChannel instance.
/// \return 1 if the channel is muted; otherwise 0.
//------------------------------------------------------------------------------
unsigned char AUDDLoopRecChannel_IsMuted(const AUDDLoopRecChannel *channel)
{
return channel->muted;
}
@@ -0,0 +1,92 @@
/* ----------------------------------------------------------------------------
* 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
Manipulation of the channels of an USB audio LoopRec device.
!Usage
-# Initialize a AUDDLoopRecChannel instance using
AUDDLoopRecChannel_Initialize.
-# Retrieves the current status of a channel with the
AUDDLoopRecChannel_IsMuted method.
-# Re-implement the AUDDLoopRecChannel_MuteChanged callback to get
notified when the status of a channel changes.
*/
#ifndef AUDDLOOPRECCHANNEL_H
#define AUDDLOOPRECCHANNEL_H
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Modelizes a channel of an USB audio LoopRec device.
//------------------------------------------------------------------------------
typedef struct {
/// Zero-based channel number in the audio function.
unsigned char number;
/// Indicates if the channel is currently muted.
unsigned char muted;
} AUDDLoopRecChannel;
//------------------------------------------------------------------------------
// Callbacks
//------------------------------------------------------------------------------
extern void AUDDLoopRecChannel_MuteChanged(AUDDLoopRecChannel *channel,
unsigned char muted);
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern void AUDDLoopRecChannel_Initialize(AUDDLoopRecChannel *channel,
unsigned char number,
unsigned char muted);
extern unsigned char AUDDLoopRecChannel_GetNumber(
const AUDDLoopRecChannel *channel);
extern void AUDDLoopRecChannel_Mute(AUDDLoopRecChannel *channel);
extern void AUDDLoopRecChannel_Unmute(AUDDLoopRecChannel *channel);
extern unsigned char AUDDLoopRecChannel_IsMuted(
const AUDDLoopRecChannel *channel);
#endif //#ifndef AUDDLOOPRECCHANNEL_H
@@ -0,0 +1,493 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "AUDDLoopRecDriver.h"
#include "AUDDLoopRecDriverDescriptors.h"
#include "AUDDLoopRecChannel.h"
#include <utility/trace.h>
#include <utility/assert.h>
#include <utility/led.h>
#include <usb/common/audio/AUDGenericRequest.h>
#include <usb/common/audio/AUDFeatureUnitRequest.h>
#include <usb/device/core/USBDDriver.h>
//------------------------------------------------------------------------------
// Internal types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Audio LoopRec driver internal state.
//------------------------------------------------------------------------------
typedef struct {
/// USB device driver instance.
USBDDriver usbdDriver;
#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
/// Multi-Buffer-Transfer List
USBDTransferBuffer * pMbl;
/// List Size
unsigned short listSize;
/// Current buffer
unsigned short currBuffer;
#endif
/// Callback for ISO IN
AUDDFrameTransferCallback fWrCallback;
/// List of AUDDLoopRecChannel instances for playback.
AUDDLoopRecChannel channels[AUDDLoopRecDriver_NUMCHANNELS+1];
/// List of AUDDLoopRecChannel instances for record.
AUDDLoopRecChannel recChannels[1];
} AUDDLoopRecDriver;
//------------------------------------------------------------------------------
// Internal variables
//------------------------------------------------------------------------------
/// Global USB audio LoopRec driver instance.
static AUDDLoopRecDriver auddLoopRecDriver;
/// Array for storing the current setting of each interface.
static unsigned char auddLoopRecDriverInterfaces[3];
/// Intermediate storage variable for the mute status of a channel.
static unsigned char muted;
//------------------------------------------------------------------------------
// Internal functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Callback triggered after the new mute status of a channel has been read
/// by AUDDLoopRecDriver_SetFeatureCurrentValue. Changes the mute status
/// of the given channel accordingly.
/// \param channel Number of the channel whose mute status has changed.
//------------------------------------------------------------------------------
static void AUDDLoopRecDriver_MuteReceived(unsigned int channel)
{
AUDDLoopRecChannel * pChannel;
if ((unsigned char)(channel >> 8) ==
AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC) {
pChannel = &auddLoopRecDriver.recChannels[0];
}
else {
pChannel = &auddLoopRecDriver.channels[channel];
}
if (muted) {
AUDDLoopRecChannel_Mute(pChannel);
}
else {
AUDDLoopRecChannel_Unmute(pChannel);
}
USBD_Write(0, 0, 0, 0, 0);
}
//------------------------------------------------------------------------------
/// Sets the current value of a particular Feature control of a channel.
/// \param entity Entity number.
/// \param channel Channel number.
/// \param control Control selector value (see TODO).
/// \param length Length of the data containing the new value.
//------------------------------------------------------------------------------
static void AUDDLoopRecDriver_SetFeatureCurrentValue(unsigned char entity,
unsigned char channel,
unsigned char control,
unsigned short length)
{
TRACE_INFO_WP("sFeature ");
TRACE_DEBUG("\b(E%d, CS%d, CN%d, L%d) ",
entity, control, channel, length);
// Check the the requested control is supported
// Control/channel combination not supported
if ((control != AUDFeatureUnitRequest_MUTE) ||
(length != 1) ||
((entity == AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL) &&
(channel > AUDDLoopRecDriver_NUMCHANNELS)) ||
((entity == AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC) &&
(channel > 0))) {
USBD_Stall(0);
}
// Mute control on master channel / speakerphone
else {
unsigned int argument = channel | (entity << 8);
USBD_Read(0, // Endpoint #0
&muted,
sizeof(muted),
(TransferCallback) AUDDLoopRecDriver_MuteReceived,
(void *) argument);
}
}
//------------------------------------------------------------------------------
/// Sends the current value of a particular channel Feature to the USB host.
/// \param entity Entity number.
/// \param channel Channel number.
/// \param control Control selector value (see TODO).
/// \param length Length of the data to return.
//------------------------------------------------------------------------------
static void AUDDLoopRecDriver_GetFeatureCurrentValue(unsigned char entity,
unsigned char channel,
unsigned char control,
unsigned char length)
{
TRACE_INFO_WP("gFeature ");
TRACE_DEBUG("\b(CS%d, CN%d, L%d) ", control, channel, length);
// Check that the requested control is supported
// Master channel mute control
if ((control == AUDFeatureUnitRequest_MUTE)
&& (channel < (AUDDLoopRecDriver_NUMCHANNELS+1))
&& (length == 1)) {
if (entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT) {
muted = auddLoopRecDriver.channels[channel].muted;
}
else {
muted = auddLoopRecDriver.recChannels[0].muted;
}
USBD_Write(0, &muted, sizeof(muted), 0, 0);
}
else {
USBD_Stall(0);
}
}
//------------------------------------------------------------------------------
/// Callback used by MBL transfer functions (USBD_Read & USBD_Write) to notify
/// that a transaction is complete.
/// \param pArg Pointer to callback arguments.
/// \param status USBD status.
/// \param nbBuffer Number of buffer that is processed.
//------------------------------------------------------------------------------
void AUDDLoopRecDriver_MblWriteCallback(void *pArg,
unsigned char status,
unsigned int nbBuffer)
{
char rc = 1;
if (auddLoopRecDriver.fWrCallback) {
rc = auddLoopRecDriver.fWrCallback(pArg, status);
}
if (rc && status == USBD_STATUS_PARTIAL_DONE) {
while(nbBuffer --) {
USBD_MblReuse(AUDDLoopRecDriverDescriptors_DATAIN,
0, 0);
}
}
}
//------------------------------------------------------------------------------
// Callback re-implementation
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Triggered when the USB host emits a new SETUP request. The request is
/// forward to <AUDDLoopRecDriver_RequestHandler>.
/// \param request Pointer to a USBGenericRequest instance.
//------------------------------------------------------------------------------
#if !defined(NOAUTOCALLBACK)
void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
{
AUDDLoopRecDriver_RequestHandler(request);
}
#endif
//------------------------------------------------------------------------------
/// Invoked whenever the active setting of an interface is changed by the
/// host. Changes the status of the third LED accordingly.
/// \param interface Interface number.
/// \param setting Newly active setting.
//------------------------------------------------------------------------------
void USBDDriverCallbacks_InterfaceSettingChanged(unsigned char interface,
unsigned char setting)
{
if ((interface == AUDDLoopRecDriverDescriptors_STREAMING)
&& (setting == 0)) {
LED_Clear(USBD_LEDOTHER);
}
else {
LED_Set(USBD_LEDOTHER);
}
}
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Initializes an USB audio LoopRec device driver, as well as the underlying
/// USB controller.
//------------------------------------------------------------------------------
void AUDDLoopRecDriver_Initialize()
{
// Reset callback function
auddLoopRecDriver.fWrCallback = 0;
// Initialize LoopRec channels
AUDDLoopRecChannel_Initialize(&(auddLoopRecDriver.channels[0]),
AUDDLoopRecDriver_MASTERCHANNEL,
0);
AUDDLoopRecChannel_Initialize(&(auddLoopRecDriver.channels[1]),
AUDDLoopRecDriver_LEFTCHANNEL,
0);
AUDDLoopRecChannel_Initialize(&(auddLoopRecDriver.channels[2]),
AUDDLoopRecDriver_RIGHTCHANNEL,
0);
AUDDLoopRecChannel_Initialize(&(auddLoopRecDriver.recChannels[0]),
AUDDLoopRecDriver_RECCHANNEL,
0);
// Initialize the USB driver
USBDDriver_Initialize(&(auddLoopRecDriver.usbdDriver),
&auddLoopRecDriverDescriptors,
auddLoopRecDriverInterfaces);
USBD_Init();
// Initialize the third LED to indicate when the audio interface is active
LED_Configure(USBD_LEDOTHER);
}
//------------------------------------------------------------------------------
/// Handles audio-specific USB requests sent by the host, and forwards
/// standard ones to the USB device driver.
/// \param request Pointer to a USBGenericRequest instance.
//------------------------------------------------------------------------------
void AUDDLoopRecDriver_RequestHandler(const USBGenericRequest *request)
{
unsigned char entity;
unsigned char interface;
TRACE_INFO_WP("NewReq ");
// Check if this is a class request
if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) {
// Check if the request is supported
switch (USBGenericRequest_GetRequest(request)) {
case AUDGenericRequest_SETCUR:
TRACE_INFO_WP(
"sCur(0x%04X) ",
USBGenericRequest_GetIndex(request));
// Check the target interface and entity
entity = AUDGenericRequest_GetEntity(request);
interface = AUDGenericRequest_GetInterface(request);
if (((entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT)
||(entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC))
&& (interface == AUDDLoopRecDriverDescriptors_CONTROL)) {
AUDDLoopRecDriver_SetFeatureCurrentValue(
entity,
AUDFeatureUnitRequest_GetChannel(request),
AUDFeatureUnitRequest_GetControl(request),
USBGenericRequest_GetLength(request));
}
else {
TRACE_WARNING(
"AUDDLoopRecDriver_RequestHandler: Unsupported entity/interface combination (0x%04X)\n\r",
USBGenericRequest_GetIndex(request));
USBD_Stall(0);
}
break;
case AUDGenericRequest_GETCUR:
TRACE_INFO_WP(
"gCur(0x%04X) ",
USBGenericRequest_GetIndex(request));
// Check the target interface and entity
entity = AUDGenericRequest_GetEntity(request);
interface = AUDGenericRequest_GetInterface(request);
if (((entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT)
||(entity == AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC))
&& (interface == AUDDLoopRecDriverDescriptors_CONTROL)) {
AUDDLoopRecDriver_GetFeatureCurrentValue(
entity,
AUDFeatureUnitRequest_GetChannel(request),
AUDFeatureUnitRequest_GetControl(request),
USBGenericRequest_GetLength(request));
}
else {
TRACE_WARNING(
"AUDDLoopRecDriver_RequestHandler: Unsupported entity/interface combination (0x%04X)\n\r",
USBGenericRequest_GetIndex(request));
USBD_Stall(0);
}
break;
default:
TRACE_WARNING(
"AUDDLoopRecDriver_RequestHandler: Unsupported request (%d)\n\r",
USBGenericRequest_GetRequest(request));
USBD_Stall(0);
}
}
// Check if this is a standard request
else if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) {
// Forward request to the standard handler
USBDDriver_RequestHandler(&(auddLoopRecDriver.usbdDriver), request);
}
// Unsupported request type
else {
TRACE_WARNING(
"AUDDLoopRecDriver_RequestHandler: Unsupported request type (%d)\n\r",
USBGenericRequest_GetType(request));
USBD_Stall(0);
}
}
//------------------------------------------------------------------------------
/// Reads incoming audio data sent by the USB host into the provided
/// buffer. When the transfer is complete, an optional callback function is
/// invoked.
/// \param buffer Pointer to the data storage buffer.
/// \param length Size of the buffer in bytes.
/// \param callback Optional callback function.
/// \param argument Optional argument to the callback function.
/// \return USBD_STATUS_SUCCESS if the transfer is started successfully;
/// otherwise an error code.
//------------------------------------------------------------------------------
unsigned char AUDDLoopRecDriver_Read(void *buffer,
unsigned int length,
TransferCallback callback,
void *argument)
{
return USBD_Read(AUDDLoopRecDriverDescriptors_DATAOUT,
buffer,
length,
callback,
argument);
}
//------------------------------------------------------------------------------
/// Initialize Frame List for sending audio data.
/// \param pMultiBufferList Pointer to the transfer list to initialize.
/// \param pBufferList Pointer list to the buffers used for frames sending.
/// \param listSize Number of frames.
/// \param frameSize Size in number of bytes of each frame.
//------------------------------------------------------------------------------
void AUDDLoopRecDriver_SetupWriteMbl(void * pMultiBufferList,
unsigned char **pBufferList,
unsigned short listSize,
unsigned short frameSize)
{
int i;
SANITY_CHECK(pMultiBufferList && pBufferList && listSize && frameSize);
#if (defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)) && defined(DMA)
// Initialize for circled DMA LLI
{
USBDDmaDescriptor * pLl = (USBDDmaDescriptor*)pMultiBufferList;
for (i = 0; ; i ++) {
pLl[i].pDataAddr = pBufferList[i];
pLl[i].bufferLength = frameSize;
if (i < listSize - 1) {
pLl[i].pNxtDesc = &pLl[i + 1];
}
else {
pLl[i].pNxtDesc = &pLl[0];
break;
}
}
}
#else
// Initialize for circled multi-buffer-list
{
USBDTransferBuffer * pMbl = (USBDTransferBuffer*)pMultiBufferList;
for (i = 0; i < listSize; i ++) {
pMbl[i].pBuffer = pBufferList[i];
pMbl[i].size = frameSize;
pMbl[i].transferred = 0;
pMbl[i].buffered = 0;
pMbl[i].remaining = frameSize;
}
}
#endif
}
//------------------------------------------------------------------------------
/// Start sending audio data, through MBL window.
/// When any frame is complete, an optional callback function is invoked, return
/// 1 of the callback cause the frame buffer re-used.
/// If callback not assigned, frames always reused.
/// \param buffer Pointer to the data storage buffer.
/// \param length Size of the buffer in bytes.
/// \param callback Optional callback function.
/// \param argument Optional argument to the callback function.
/// \return USBD_STATUS_SUCCESS if the transfer is started successfully;
/// otherwise an error code.
//------------------------------------------------------------------------------
unsigned char AUDDLoopRecDriver_Write(void * pMbl,
unsigned short listSize,
AUDDFrameTransferCallback callback,
void * argument)
{
auddLoopRecDriver.fWrCallback = callback;
return USBD_MblWrite(AUDDLoopRecDriverDescriptors_DATAIN,
pMbl,
listSize,
1,
0,
AUDDLoopRecDriver_MblWriteCallback,
argument);
}
//-----------------------------------------------------------------------------
/// Starts a remote wake-up sequence if the host has explicitely enabled it
/// by sending the appropriate SET_FEATURE request.
//-----------------------------------------------------------------------------
void AUDDLoopRecDriver_RemoteWakeUp(void)
{
// Remote wake-up has been enabled
if (USBDDriver_IsRemoteWakeUpEnabled(&auddLoopRecDriver.usbdDriver)) {
USBD_RemoteWakeUp();
}
}
@@ -0,0 +1,163 @@
/* ----------------------------------------------------------------------------
* 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 USB Audio Loop Record Driver with two playback channels
and one record channel.
!Usage
-# Enable and setup USB related pins (see pio & board.h).
-# Configure the USB Audio Loop Record driver using
AUDDLoopRecDriver_Initialize
-# To get %audio stream frames from host, use
AUDDLoopRecDriver_Read
-# To send %audio sampling stream to host, use
AUDDLoopRecDriver_Write
*/
#ifndef AUDDLoopRecDriver_H
#define AUDDLoopRecDriver_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <board.h>
#include <usb/common/core/USBGenericRequest.h>
#include <usb/device/core/USBD.h>
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "Audio Loop Record stream information"
///
/// This page lists codes for USB Audio Loop Record stream information.
///
/// !Code
/// - AUDDLoopRecDriver_SAMPLERATE
/// - AUDDLoopRecDriver_NUMCHANNELS
/// - AUDDLoopRecDriver_BYTESPERSAMPLE
/// - AUDDLoopRecDriver_BITSPERSAMPLE
/// - AUDDLoopRecDriver_SAMPLESPERFRAME
/// - AUDDLoopRecDriver_BYTESPERFRAME
#if defined(at91sam7s) || defined(at91sam9xe)
/// Sample rate in Hz.
#define AUDDLoopRecDriver_SAMPLERATE 32000
/// Number of channels in audio stream.
#define AUDDLoopRecDriver_NUMCHANNELS 1
/// Number of bytes in one sample.
#define AUDDLoopRecDriver_BYTESPERSAMPLE 2
#else
/// Sample rate in Hz.
#define AUDDLoopRecDriver_SAMPLERATE 48000
/// Number of channels in audio stream.
#define AUDDLoopRecDriver_NUMCHANNELS 2
/// Number of bytes in one sample.
#define AUDDLoopRecDriver_BYTESPERSAMPLE 2
#endif
/// Number of bits in one sample.
#define AUDDLoopRecDriver_BITSPERSAMPLE (AUDDLoopRecDriver_BYTESPERSAMPLE * 8)
/// Number of bytes in one USB subframe.
#define AUDDLoopRecDriver_BYTESPERSUBFRAME (AUDDLoopRecDriver_NUMCHANNELS * \
AUDDLoopRecDriver_BYTESPERSAMPLE)
/// Number of samples in one USB frame.
#define AUDDLoopRecDriver_SAMPLESPERFRAME (AUDDLoopRecDriver_SAMPLERATE / 1000 \
* AUDDLoopRecDriver_NUMCHANNELS)
/// Number of bytes in one USB frame.
#define AUDDLoopRecDriver_BYTESPERFRAME (AUDDLoopRecDriver_SAMPLESPERFRAME * \
AUDDLoopRecDriver_BYTESPERSAMPLE)
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "Audio Loop Record Channel Numbers"
///
/// This page lists codes for USB Audio Loop Record channel numbers.
///
/// !Playback channel numbers
/// - AUDDLoopRecDriver_MASTERCHANNEL
/// - AUDDLoopRecDriver_LEFTCHANNEL
/// - AUDDLoopRecDriver_RIGHTCHANNEL
///
/// !Record channel number
/// - AUDDLoopRecDriver_RECCHANNEL
/// Master channel of playback.
#define AUDDLoopRecDriver_MASTERCHANNEL 0
/// Front left channel of playback.
#define AUDDLoopRecDriver_LEFTCHANNEL 1
/// Front right channel of playback.
#define AUDDLoopRecDriver_RIGHTCHANNEL 2
/// Channel of record.
#define AUDDLoopRecDriver_RECCHANNEL 0
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Callback function for audio frames.
/// \param pArg Pointer to transfer arguments.
/// \param status Frame transfer status.
/// \return 1 to continue, 0 to stop frames.
//------------------------------------------------------------------------------
typedef char (*AUDDFrameTransferCallback)(void* pArg, char status);
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern void AUDDLoopRecDriver_Initialize();
extern void AUDDLoopRecDriver_RequestHandler(const USBGenericRequest *request);
extern unsigned char AUDDLoopRecDriver_Read(void *buffer,
unsigned int length,
TransferCallback callback,
void *argument);
extern void AUDDLoopRecDriver_SetupWriteMbl(void * pMultiBufferList,
unsigned char **pBufferList,
unsigned short listSize,
unsigned short frameSize);
extern unsigned char AUDDLoopRecDriver_Write(void * pMbl,
unsigned short listSize,
AUDDFrameTransferCallback callback,
void *argument);
extern void AUDDLoopRecDriver_RemoteWakeUp(void);
#endif //#ifndef AUDDLoopRecDriver_H
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,148 @@
/* ----------------------------------------------------------------------------
* 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
Declaration of the descriptors required by a USB audio speaker driver.
!!!Usage
-# Initialize a USBDDriver instance using the
auddSpeakerDriverDescriptors list.
*/
#ifndef AUDDLOOPRECDESCRIPTORS_H
#define AUDDLOOPRECDESCRIPTORS_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <board.h>
#include <usb/device/core/USBDDriverDescriptors.h>
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "Audio Speaker Endpoint Numbers"
///
/// This page lists the endpoint number settings for USB Audio Speaker device.
///
/// !Endpoints
/// - AUDDLoopRecDriverDescriptors_DATAOUT
/// - AUDDLoopRecDriverDescriptors_DATAIN
/// - AUDDLoopRecDriverDescriptors_HS_INTERVAL
/// - AUDDLoopRecDriverDescriptors_FS_INTERVAL
#if defined(at91sam7s) || defined(at91sam9xe)
/// Data out endpoint number, size 64B.
#define AUDDLoopRecDriverDescriptors_DATAOUT 0x01
/// Data in endpoint number, size 64B
#define AUDDLoopRecDriverDescriptors_DATAIN 0x02
#elif defined(CHIP_USB_UDP)
/// Data out endpoint number, size 192B.
#define AUDDLoopRecDriverDescriptors_DATAOUT 0x04
/// Data in endpoint number, size 192B.
#define AUDDLoopRecDriverDescriptors_DATAIN 0x05
#elif defined(at91sam9m10ek)
/// Data out endpoint number, size 192B.
#define AUDDLoopRecDriverDescriptors_DATAOUT 0x01
/// Data in endpoint number, size 192B
#define AUDDLoopRecDriverDescriptors_DATAIN 0x06
#else
/// Data out endpoint number, size 192B.
#define AUDDLoopRecDriverDescriptors_DATAOUT 0x05
/// Data in endpoint number, size 192B
#define AUDDLoopRecDriverDescriptors_DATAIN 0x06
#endif
/// Endpoint polling interval 2^(x-1) * 125us
#define AUDDLoopRecDriverDescriptors_HS_INTERVAL 0x04
/// Endpoint polling interval 2^(x-1) * ms
#define AUDDLoopRecDriverDescriptors_FS_INTERVAL 0x01
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "Audio Speaker Interface IDs"
///
/// This page lists the interface numbers for USB Audio Speaker device.
///
/// !Interfaces
/// - AUDDLoopRecDriverDescriptors_CONTROL
/// - AUDDLoopRecDriverDescriptors_STREAMING
/// - AUDDLoopRecDriverDescriptors_STREAMINGIN
/// Audio control interface ID.
#define AUDDLoopRecDriverDescriptors_CONTROL 0
/// Audio streaming interface ID (OUT, for playback).
#define AUDDLoopRecDriverDescriptors_STREAMING 1
/// Audio streaming interface ID (IN, for record).
#define AUDDLoopRecDriverDescriptors_STREAMINGIN 2
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "Audio Speaker Entity IDs"
///
/// This page lists the entity IDs for USB Audio Speaker device.
///
/// !Entities
/// - AUDDLoopRecDriverDescriptors_INPUTTERMINAL
/// - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL
/// - AUDDLoopRecDriverDescriptors_FEATUREUNIT
/// - AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC
/// - AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC
/// - AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC
/// Playback input terminal ID.
#define AUDDLoopRecDriverDescriptors_INPUTTERMINAL 0
/// Playback output terminal ID.
#define AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL 1
/// Playback feature unit ID.
#define AUDDLoopRecDriverDescriptors_FEATUREUNIT 2
/// Record input terminal ID.
#define AUDDLoopRecDriverDescriptors_INPUTTERMINAL_REC 3
/// Record output terminal ID.
#define AUDDLoopRecDriverDescriptors_OUTPUTTERMINAL_REC 4
/// Record feature unit ID
#define AUDDLoopRecDriverDescriptors_FEATUREUNIT_REC 5
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Exported variables
//------------------------------------------------------------------------------
extern const USBDDriverDescriptors auddLoopRecDriverDescriptors;
#endif //#ifndef AUDDLOOPRECDESCRIPTORS_H
@@ -0,0 +1,51 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \dir
///
/// !!!Purpose
///
/// This directory provides definitions, structs and functions for a USB Audio
/// Class device - USB audio-looprec demo, to implement an USB desktop speaker
/// which echos audio stream back to host.
///
/// !!!Contents
/// There are two things for the implement of the audio-speaker device driver:
/// - Implement the audio-looprec driver structs and functions for the device,
/// to initialize, to handle audio class specific requests and dispach
/// standard requests in USBD callbacks, to read/write through assigned USB
/// endpoints,
/// - Create the audio-speaker device's descriptors that should be passed to
/// the USBDDriver instance on initialization, so that the host can
/// recognize the device as a USB audio "desktop speaker" device.
///
/// This project is simply addon to the audio speaker demo. For more
/// information, please refer to "USB Audio Speaker Device".
//------------------------------------------------------------------------------
@@ -0,0 +1,129 @@
/* ----------------------------------------------------------------------------
* 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: AUDDSpeakerChannel implementation
About: Purpose
Implementation of the AUDDSpeakerChannel functions.
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "AUDDSpeakerChannel.h"
#include <utility/trace.h>
//------------------------------------------------------------------------------
// Callbacks
//------------------------------------------------------------------------------
/*
Function: AUDDSpeakerChannel_MuteChanged
Callback triggered when the mute status of a channel changes. This is
a default implementation which does nothing and must be overriden.
Parameters:
channel - Pointer to a AUDDSpeakerChannel instance.
muted - New mute status.
*/
//__attribute__ ((weak)) void AUDDSpeakerChannel_MuteChanged(
// AUDDSpeakerChannel *channel,
// unsigned char muted)
//{
// TRACE_DEBUG("MuteChanged(%d, %d) ", channel->number, muted);
//}
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Initializes the member variables of an AUDDSpeakerChannel object to the
/// given values.
/// \param channel Pointer to an AUDDSpeakerChannel instance.
/// \param number Channel number in the audio function.
/// \param muted Indicates if the channel is muted.
//------------------------------------------------------------------------------
void AUDDSpeakerChannel_Initialize(AUDDSpeakerChannel *channel,
unsigned char number,
unsigned char muted)
{
channel->number = number;
channel->muted = muted;
}
//------------------------------------------------------------------------------
/// Indicates the number of a channel.
/// \param channel Pointer to an AUDDSpeakerChannel instance.
/// \return Channel number.
//------------------------------------------------------------------------------
unsigned char AUDDSpeakerChannel_GetNumber(const AUDDSpeakerChannel *channel)
{
return channel->number;
}
//------------------------------------------------------------------------------
/// Mutes the given channel and triggers the MuteChanged callback if
/// necessary.
/// \param channel Pointer to an AUDDSpeakerChannelInstance.
//------------------------------------------------------------------------------
void AUDDSpeakerChannel_Mute(AUDDSpeakerChannel *channel)
{
if (!channel->muted) {
channel->muted = 1;
AUDDSpeakerChannel_MuteChanged(channel, 1);
}
}
//------------------------------------------------------------------------------
/// Unmutes the given channel and triggers the MuteChanged callback if
/// necessary.
/// \param channel Pointer to an AUDDSpeakerChannelInstance.
//------------------------------------------------------------------------------
void AUDDSpeakerChannel_Unmute(AUDDSpeakerChannel *channel)
{
if (channel->muted) {
channel->muted = 0;
AUDDSpeakerChannel_MuteChanged(channel, 0);
}
}
//------------------------------------------------------------------------------
/// Indicates if the given channel is currently muted or not.
/// \param channel Pointer an AUDDSpeakerChannel instance.
/// \return 1 if the channel is muted; otherwise 0.
//------------------------------------------------------------------------------
unsigned char AUDDSpeakerChannel_IsMuted(const AUDDSpeakerChannel *channel)
{
return channel->muted;
}
@@ -0,0 +1,92 @@
/* ----------------------------------------------------------------------------
* 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
Manipulation of the channels of an USB audio speaker device.
!Usage
-# Initialize a AUDDSpeakerChannel instance using
AUDDSpeakerChannel_Initialize.
-# Retrieves the current status of a channel with the
AUDDSpeakerChannel_IsMuted method.
-# Re-implement the AUDDSpeakerChannel_MuteChanged callback to get
notified when the status of a channel changes.
*/
#ifndef AUDDSPEAKERCHANNEL_H
#define AUDDSPEAKERCHANNEL_H
//------------------------------------------------------------------------------
// Types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Modelizes a channel of an USB audio speaker device.
//------------------------------------------------------------------------------
typedef struct {
/// Zero-based channel number in the audio function.
unsigned char number;
/// Indicates if the channel is currently muted.
unsigned char muted;
} AUDDSpeakerChannel;
//------------------------------------------------------------------------------
// Callbacks
//------------------------------------------------------------------------------
extern void AUDDSpeakerChannel_MuteChanged(AUDDSpeakerChannel *channel,
unsigned char muted);
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern void AUDDSpeakerChannel_Initialize(AUDDSpeakerChannel *channel,
unsigned char number,
unsigned char muted);
extern unsigned char AUDDSpeakerChannel_GetNumber(
const AUDDSpeakerChannel *channel);
extern void AUDDSpeakerChannel_Mute(AUDDSpeakerChannel *channel);
extern void AUDDSpeakerChannel_Unmute(AUDDSpeakerChannel *channel);
extern unsigned char AUDDSpeakerChannel_IsMuted(
const AUDDSpeakerChannel *channel);
#endif //#ifndef AUDDSPEAKERCHANNEL_H
@@ -0,0 +1,378 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "AUDDSpeakerDriver.h"
#include "AUDDSpeakerDriverDescriptors.h"
#include "AUDDSpeakerChannel.h"
#include <utility/trace.h>
#include <utility/led.h>
#include <usb/common/audio/AUDGenericRequest.h>
#include <usb/common/audio/AUDFeatureUnitRequest.h>
#include <usb/device/core/USBDDriver.h>
//------------------------------------------------------------------------------
// Internal types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Audio speaker driver internal state.
//------------------------------------------------------------------------------
typedef struct {
/// USB device driver instance.
USBDDriver usbdDriver;
/// List of AUDDSpeakerChannel instances for playback.
AUDDSpeakerChannel channels[AUDDSpeakerDriver_NUMCHANNELS+1];
} AUDDSpeakerDriver;
//------------------------------------------------------------------------------
// Internal variables
//------------------------------------------------------------------------------
/// Global USB audio speaker driver instance.
static AUDDSpeakerDriver auddSpeakerDriver;
/// Array for storing the current setting of each interface.
static unsigned char auddSpeakerDriverInterfaces[2];
/// Intermediate storage variable for the mute status of a channel.
static unsigned char muted;
//------------------------------------------------------------------------------
// Internal functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Callback triggered after the new mute status of a channel has been read
/// by AUDDSpeakerDriver_SetFeatureCurrentValue. Changes the mute status
/// of the given channel accordingly.
/// \param channel Number of the channel whose mute status has changed.
//------------------------------------------------------------------------------
static void AUDDSpeakerDriver_MuteReceived(unsigned int channel)
{
if (muted) {
AUDDSpeakerChannel_Mute(&(auddSpeakerDriver.channels[channel]));
}
else {
AUDDSpeakerChannel_Unmute(&(auddSpeakerDriver.channels[channel]));
}
USBD_Write(0, 0, 0, 0, 0);
}
//------------------------------------------------------------------------------
/// Sets the current value of a particular Feature control of a channel.
/// \param entity Entity number.
/// \param channel Channel number.
/// \param control Control selector value (see TODO).
/// \param length Length of the data containing the new value.
//------------------------------------------------------------------------------
static void AUDDSpeakerDriver_SetFeatureCurrentValue(unsigned char entity,
unsigned char channel,
unsigned char control,
unsigned short length)
{
TRACE_INFO_WP("sFeature ");
TRACE_DEBUG("\b(E%d, CS%d, CN%d, L%d) ",
entity, control, channel, length);
// Check the the requested control is supported
// Control/channel combination not supported
if ((control == AUDFeatureUnitRequest_MUTE)
&& (channel < (AUDDSpeakerDriver_NUMCHANNELS+1))
&& (length == 1)) {
unsigned int argument = channel; // Avoids compiler warning
USBD_Read(0, // Endpoint #0
&muted,
sizeof(muted),
(TransferCallback) AUDDSpeakerDriver_MuteReceived,
(void *) argument);
}
// Control/channel combination not supported
else {
USBD_Stall(0);
}
}
//------------------------------------------------------------------------------
/// Sends the current value of a particular channel Feature to the USB host.
/// \param entity Entity number.
/// \param channel Channel number.
/// \param control Control selector value (see TODO).
/// \param length Length of the data to return.
//------------------------------------------------------------------------------
static void AUDDSpeakerDriver_GetFeatureCurrentValue(unsigned char entity,
unsigned char channel,
unsigned char control,
unsigned char length)
{
TRACE_INFO_WP("gFeature ");
TRACE_DEBUG("\b(CS%d, CN%d, L%d) ", control, channel, length);
// Check that the requested control is supported
// Master channel mute control
if ((control == AUDFeatureUnitRequest_MUTE)
&& (channel < (AUDDSpeakerDriver_NUMCHANNELS+1))
&& (length == 1)) {
muted = AUDDSpeakerChannel_IsMuted(&(auddSpeakerDriver.channels[channel]));
USBD_Write(0, &muted, sizeof(muted), 0, 0);
}
else {
USBD_Stall(0);
}
}
///*
// Function: AUDDSpeakerDriver_SetInterface
// Changes the current active alternate setting of the given interface.
//
// Parameters:
//
//*/
//TRACE_DEBUG_M("SetInterface(%d,%d) ", setup->wIndex, setup->wValue);
//
// /* Check that interface is AudioStreaming OUT */
// if (setup->wIndex == INTERFACE_ID_AUDIOSTREAMING_OUT) {
//
// /* Check desired alternate setting */
// switch (setup->wValue) {
// case 0:
// case 1:
// if (speakerDriver->isOutStreamEnabled != setup->wValue) {
//
// speakerDriver->isOutStreamEnabled = setup->wValue;
// SPK_OutStreamStatusChanged(speakerDriver);
// LED_SetGlowing(LED_OTHER, setup->wValue);
// }
// USB_SendZLP0(usbDriver, 0, 0);
// break;
//
// default:
// USB_Stall(usbDriver, 0);
// }
// }
// else {
//
// USB_Stall(usbDriver, 0);
// }
//
//------------------------------------------------------------------------------
// Callback re-implementation
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Triggered when the USB host emits a new SETUP request. The request is
/// forward to <AUDDSpeakerDriver_RequestHandler>.
/// \param request Pointer to a USBGenericRequest instance.
//------------------------------------------------------------------------------
#if !defined(NOAUTOCALLBACK)
void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
{
AUDDSpeakerDriver_RequestHandler(request);
}
#endif
//------------------------------------------------------------------------------
/// Invoked whenever the active setting of an interface is changed by the
/// host. Changes the status of the third LED accordingly.
/// \param interface Interface number.
/// \param setting Newly active setting.
//------------------------------------------------------------------------------
void USBDDriverCallbacks_InterfaceSettingChanged(unsigned char interface,
unsigned char setting)
{
if ((interface == AUDDSpeakerDriverDescriptors_STREAMING)
&& (setting == 0)) {
LED_Clear(USBD_LEDOTHER);
}
else {
LED_Set(USBD_LEDOTHER);
}
}
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Initializes an USB audio speaker device driver, as well as the underlying
/// USB controller.
//------------------------------------------------------------------------------
void AUDDSpeakerDriver_Initialize()
{
// Initialize speaker channels
AUDDSpeakerChannel_Initialize(&(auddSpeakerDriver.channels[0]),
AUDDSpeakerDriver_MASTERCHANNEL,
0);
AUDDSpeakerChannel_Initialize(&(auddSpeakerDriver.channels[1]),
AUDDSpeakerDriver_LEFTCHANNEL,
0);
AUDDSpeakerChannel_Initialize(&(auddSpeakerDriver.channels[2]),
AUDDSpeakerDriver_RIGHTCHANNEL,
0);
// Initialize the USB driver
USBDDriver_Initialize(&(auddSpeakerDriver.usbdDriver),
&auddSpeakerDriverDescriptors,
auddSpeakerDriverInterfaces);
USBD_Init();
// Initialize the third LED to indicate when the audio interface is active
LED_Configure(USBD_LEDOTHER);
}
//------------------------------------------------------------------------------
/// Handles audio-specific USB requests sent by the host, and forwards
/// standard ones to the USB device driver.
/// \param request Pointer to a USBGenericRequest instance.
//------------------------------------------------------------------------------
void AUDDSpeakerDriver_RequestHandler(const USBGenericRequest *request)
{
unsigned char entity;
unsigned char interface;
TRACE_INFO_WP("NewReq ");
// Check if this is a class request
if (USBGenericRequest_GetType(request) == USBGenericRequest_CLASS) {
// Check if the request is supported
switch (USBGenericRequest_GetRequest(request)) {
case AUDGenericRequest_SETCUR:
TRACE_INFO_WP(
"sCur(0x%04X) ",
USBGenericRequest_GetIndex(request));
// Check the target interface and entity
entity = AUDGenericRequest_GetEntity(request);
interface = AUDGenericRequest_GetInterface(request);
if ((entity == AUDDSpeakerDriverDescriptors_FEATUREUNIT)
&& (interface == AUDDSpeakerDriverDescriptors_CONTROL)) {
AUDDSpeakerDriver_SetFeatureCurrentValue(
entity,
AUDFeatureUnitRequest_GetChannel(request),
AUDFeatureUnitRequest_GetControl(request),
USBGenericRequest_GetLength(request));
}
else {
TRACE_WARNING(
"AUDDSpeakerDriver_RequestHandler: Unsupported entity/interface combination (0x%04X)\n\r",
USBGenericRequest_GetIndex(request));
USBD_Stall(0);
}
break;
case AUDGenericRequest_GETCUR:
TRACE_INFO_WP(
"gCur(0x%04X) ",
USBGenericRequest_GetIndex(request));
// Check the target interface and entity
entity = AUDGenericRequest_GetEntity(request);
interface = AUDGenericRequest_GetInterface(request);
if ((entity == AUDDSpeakerDriverDescriptors_FEATUREUNIT)
&& (interface == AUDDSpeakerDriverDescriptors_CONTROL)) {
AUDDSpeakerDriver_GetFeatureCurrentValue(
entity,
AUDFeatureUnitRequest_GetChannel(request),
AUDFeatureUnitRequest_GetControl(request),
USBGenericRequest_GetLength(request));
}
else {
TRACE_WARNING(
"AUDDSpeakerDriver_RequestHandler: Unsupported entity/interface combination (0x%04X)\n\r",
USBGenericRequest_GetIndex(request));
USBD_Stall(0);
}
break;
default:
TRACE_WARNING(
"AUDDSpeakerDriver_RequestHandler: Unsupported request (%d)\n\r",
USBGenericRequest_GetRequest(request));
USBD_Stall(0);
}
}
// Check if this is a standard request
else if (USBGenericRequest_GetType(request) == USBGenericRequest_STANDARD) {
// Forward request to the standard handler
USBDDriver_RequestHandler(&(auddSpeakerDriver.usbdDriver), request);
}
// Unsupported request type
else {
TRACE_WARNING(
"AUDDSpeakerDriver_RequestHandler: Unsupported request type (%d)\n\r",
USBGenericRequest_GetType(request));
USBD_Stall(0);
}
}
//------------------------------------------------------------------------------
/// Reads incoming audio data sent by the USB host into the provided
/// buffer. When the transfer is complete, an optional callback function is
/// invoked.
/// \param buffer Pointer to the data storage buffer.
/// \param length Size of the buffer in bytes.
/// \param callback Optional callback function.
/// \param argument Optional argument to the callback function.
/// \return USBD_STATUS_SUCCESS if the transfer is started successfully;
/// otherwise an error code.
//------------------------------------------------------------------------------
unsigned char AUDDSpeakerDriver_Read(void *buffer,
unsigned int length,
TransferCallback callback,
void *argument)
{
return USBD_Read(AUDDSpeakerDriverDescriptors_DATAOUT,
buffer,
length,
callback,
argument);
}
@@ -0,0 +1,201 @@
/* ----------------------------------------------------------------------------
* 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 USB Audio Speaker Driver with two playback channels and one
record channel.
!Usage
-# Enable and setup USB related pins (see pio & board.h).
-# Configure the USB Audio Speaker driver using
AUDDSpeakerDriver_Initialize
-# To get %audio stream frames from host, use
AUDDSpeakerDriver_Read
-# To send %audio sampling stream to host, use
AUDDSpeakerDriver_Write
*/
#ifndef AUDDSPEAKERDRIVER_H
#define AUDDSPEAKERDRIVER_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <board.h>
#include <usb/common/core/USBGenericRequest.h>
#include <usb/device/core/USBD.h>
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "Audio Speaker stream information"
///
/// This page lists codes for USB Audio Speaker stream information.
///
/// !Code
/// - AUDDSpeakerDriver_SAMPLERATE
/// - AUDDSpeakerDriver_NUMCHANNELS
/// - AUDDSpeakerDriver_BYTESPERSAMPLE
/// - AUDDSpeakerDriver_BITSPERSAMPLE
/// - AUDDSpeakerDriver_SAMPLESPERFRAME
/// - AUDDSpeakerDriver_BYTESPERFRAME
#if defined(at91sam7s)
/// Sample rate in Hz.
#define AUDDSpeakerDriver_SAMPLERATE 32000
/// Number of channels in audio stream.
#define AUDDSpeakerDriver_NUMCHANNELS 1
/// Number of bytes in one sample.
#define AUDDSpeakerDriver_BYTESPERSAMPLE 2
#else
/// Sample rate in Hz.
#define AUDDSpeakerDriver_SAMPLERATE 48000
/// Number of channels in audio stream.
#define AUDDSpeakerDriver_NUMCHANNELS 2
/// Number of bytes in one sample.
#define AUDDSpeakerDriver_BYTESPERSAMPLE 2
#endif
/// Number of bits in one sample.
#define AUDDSpeakerDriver_BITSPERSAMPLE (AUDDSpeakerDriver_BYTESPERSAMPLE * 8)
/// Number of bytes in one USB subframe.
#define AUDDSpeakerDriver_BYTESPERSUBFRAME (AUDDSpeakerDriver_NUMCHANNELS * \
AUDDSpeakerDriver_BYTESPERSAMPLE)
/// Number of samples in one USB frame.
#define AUDDSpeakerDriver_SAMPLESPERFRAME (AUDDSpeakerDriver_SAMPLERATE / 1000 \
* AUDDSpeakerDriver_NUMCHANNELS)
/// Number of bytes in one USB frame.
#define AUDDSpeakerDriver_BYTESPERFRAME (AUDDSpeakerDriver_SAMPLESPERFRAME * \
AUDDSpeakerDriver_BYTESPERSAMPLE)
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "Audio Speaker Channel Numbers"
///
/// This page lists codes for USB Audio Speaker channel numbers.
///
/// !Playback channel numbers
/// - AUDDSpeakerDriver_MASTERCHANNEL
/// - AUDDSpeakerDriver_LEFTCHANNEL
/// - AUDDSpeakerDriver_RIGHTCHANNEL
///
/// !Record channel number
/// - AUDDSpeakerDriver_RECCHANNEL
/// Master channel of playback.
#define AUDDSpeakerDriver_MASTERCHANNEL 0
/// Front left channel of playback.
#define AUDDSpeakerDriver_LEFTCHANNEL 1
/// Front right channel of playback.
#define AUDDSpeakerDriver_RIGHTCHANNEL 2
/// Channel of record.
#define AUDDSpeakerDriver_RECCHANNEL 0
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
extern void AUDDSpeakerDriver_Initialize();
extern void AUDDSpeakerDriver_RequestHandler(const USBGenericRequest *request);
extern unsigned char AUDDSpeakerDriver_Read(void *buffer,
unsigned int length,
TransferCallback callback,
void *argument);
#endif //#ifndef AUDDSPEAKERDRIVER_H
//#ifndef SPEAKER_DRIVER_H
//#define SPEAKER_DRIVER_H
//
////------------------------------------------------------------------------------
//// Definitions
////------------------------------------------------------------------------------
//
///*! Sampling frequency in Hz */
//#define SPEAKER_SAMPLERATE 48000
///*! Number of samples in one isochronous packet (1ms frame) */
//#define SPEAKER_SAMPLESPERPACKET (SPEAKER_SAMPLERATE / 1000)
///*! Size of one sample (in bytes) */
//#define SPEAKER_SAMPLESIZE 2
///*! Number of channels */
//#define SPEAKER_NUMCHANNELS 2
///*! Size of one frame (number of bytes sent for one sample on all channels) */
//#define SPEAKER_FRAMESIZE (SPEAKER_SAMPLESIZE * SPEAKER_NUMCHANNELS)
///*! Required bit rate given the sample frequency, sample size and number of
// channels. */
//#define SPEAKER_BITRATE (SPEAKER_SAMPLERATE * SPEAKER_FRAMESIZE)
///*! Size of one isochronous packet */
//#define SPEAKER_PACKETSIZE (SPEAKER_SAMPLESPERPACKET * SPEAKER_FRAMESIZE)
//
////------------------------------------------------------------------------------
//// Structures
////------------------------------------------------------------------------------
///*!
// Holds the speaker driver state.
// */
//typedef struct {
//
// S_std_class standardDriver;
//
// unsigned char isOutStreamEnabled;
// unsigned char isChannelMuted[SPEAKER_NUMCHANNELS+1];
//
// Callback_f outStreamStatusChanged;
// Callback_f outStreamMuteChanged;
//
//} __attribute__((packed)) S_speaker;
//
////------------------------------------------------------------------------------
//// Exported functions
////------------------------------------------------------------------------------
//
//extern void SPK_Init(S_speaker *speakerDriver, const S_usb *usbDriver);
//extern void SPK_SetCallbacks(S_speaker *speakerDriver,
// Callback_f outStreamStatusChanged,
// Callback_f outStreamMuteChanged);
//extern void SPK_RequestHandler(S_speaker *speakerDriver);
//extern char SPK_Read(S_speaker *speakerDriver,
// void *buffer,
// unsigned int length,
// Callback_f callback,
// void *argument);
//
//#endif //#ifndef SPEAKER_DRIVER_H
//
@@ -0,0 +1,620 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include "AUDDSpeakerDriverDescriptors.h"
#include "AUDDSpeakerDriver.h"
#include <board.h>
#include <usb/common/core/USBGenericDescriptor.h>
#include <usb/common/core/USBDeviceDescriptor.h>
#include <usb/common/core/USBConfigurationDescriptor.h>
#include <usb/common/core/USBInterfaceDescriptor.h>
#include <usb/common/core/USBEndpointDescriptor.h>
#include <usb/common/core/USBStringDescriptor.h>
#include <usb/common/audio/AUDGenericDescriptor.h>
#include <usb/common/audio/AUDDeviceDescriptor.h>
#include <usb/common/audio/AUDControlInterfaceDescriptor.h>
#include <usb/common/audio/AUDStreamingInterfaceDescriptor.h>
#include <usb/common/audio/AUDEndpointDescriptor.h>
#include <usb/common/audio/AUDDataEndpointDescriptor.h>
#include <usb/common/audio/AUDFormatTypeOneDescriptor.h>
#include <usb/common/audio/AUDHeaderDescriptor.h>
#include <usb/common/audio/AUDFeatureUnitDescriptor.h>
#include <usb/common/audio/AUDInputTerminalDescriptor.h>
#include <usb/common/audio/AUDOutputTerminalDescriptor.h>
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "Audio Speaker Device Codes"
///
/// This page lists the %device IDs and release number of the USB Audio Speaker
/// %device.
///
/// !Codes
/// - AUDDSpeakerDriverDescriptors_VENDORID
/// - AUDDSpeakerDriverDescriptors_PRODUCTID
/// - AUDDSpeakerDriverDescriptors_RELEASE
/// Device vendor ID.
#define AUDDSpeakerDriverDescriptors_VENDORID 0x03EB
/// Device product ID.
#define AUDDSpeakerDriverDescriptors_PRODUCTID 0x6128
/// Device release number in BCD format.
#define AUDDSpeakerDriverDescriptors_RELEASE 0x0100
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Internal types
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// Audio control header descriptor with one slave interface.
//------------------------------------------------------------------------------
#ifdef __ICCARM__ // IAR
#pragma pack(1) // IAR
#define __attribute__(...) // IAR
#endif // IAR
//------------------------------------------------------------------------------
/// Header descriptor with 1 interface.
//------------------------------------------------------------------------------
typedef struct {
/// Header descriptor.
AUDHeaderDescriptor header;
/// Id of the first grouped interface - Speaker.
unsigned char bInterface0;
} __attribute__ ((packed)) AUDHeaderDescriptor1; // GCC
//------------------------------------------------------------------------------
/// Feature unit descriptor with 3 channel controls (master, right, left).
//------------------------------------------------------------------------------
typedef struct {
/// Feature unit descriptor.
AUDFeatureUnitDescriptor feature;
/// Available controls for each channel.
unsigned char bmaControls[3];
/// Index of a string descriptor for the feature unit.
unsigned char iFeature;
} __attribute__ ((packed)) AUDFeatureUnitDescriptor3; // GCC
//------------------------------------------------------------------------------
/// List of descriptors for detailling the audio control interface of a
/// device using a USB audio speaker driver.
//------------------------------------------------------------------------------
typedef struct {
/// Header descriptor (with one slave interface).
AUDHeaderDescriptor1 header;
/// Input terminal descriptor.
AUDInputTerminalDescriptor input;
/// Output terminal descriptor.
AUDOutputTerminalDescriptor output;
/// Feature unit descriptor.
AUDFeatureUnitDescriptor3 feature;
} __attribute__ ((packed)) AUDDSpeakerDriverAudioControlDescriptors; // GCC
//------------------------------------------------------------------------------
/// Format type I descriptor with one discrete sampling frequency.
//------------------------------------------------------------------------------
typedef struct {
/// Format type I descriptor.
AUDFormatTypeOneDescriptor formatType;
/// Sampling frequency in Hz.
unsigned char tSamFreq[3];
} __attribute__ ((packed)) AUDFormatTypeOneDescriptor1; // GCC
//------------------------------------------------------------------------------
/// Holds a list of descriptors returned as part of the configuration of
/// a USB audio speaker device.
//------------------------------------------------------------------------------
typedef struct {
/// Standard configuration.
USBConfigurationDescriptor configuration;
/// Audio control interface.
USBInterfaceDescriptor control;
/// Descriptors for the audio control interface.
AUDDSpeakerDriverAudioControlDescriptors controlDescriptors;
//- AUDIO OUT
/// Streaming out interface descriptor (with no endpoint, required).
USBInterfaceDescriptor streamingOutNoIsochronous;
/// Streaming out interface descriptor.
USBInterfaceDescriptor streamingOut;
/// Audio class descriptor for the streaming out interface.
AUDStreamingInterfaceDescriptor streamingOutClass;
/// Stream format descriptor.
AUDFormatTypeOneDescriptor1 streamingOutFormatType;
/// Streaming out endpoint descriptor.
AUDEndpointDescriptor streamingOutEndpoint;
/// Audio class descriptor for the streaming out endpoint.
AUDDataEndpointDescriptor streamingOutDataEndpoint;
} __attribute__ ((packed)) AUDDSpeakerDriverConfigurationDescriptors; // GCC
#ifdef __ICCARM__ // IAR
#pragma pack() // IAR
#endif // IAR
//------------------------------------------------------------------------------
// Exported variables
//------------------------------------------------------------------------------
/// Device descriptor for a USB audio speaker driver.
const USBDeviceDescriptor deviceDescriptor = {
sizeof(USBDeviceDescriptor),
USBGenericDescriptor_DEVICE,
USBDeviceDescriptor_USB2_00,
AUDDeviceDescriptor_CLASS,
AUDDeviceDescriptor_SUBCLASS,
AUDDeviceDescriptor_PROTOCOL,
CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
AUDDSpeakerDriverDescriptors_VENDORID,
AUDDSpeakerDriverDescriptors_PRODUCTID,
AUDDSpeakerDriverDescriptors_RELEASE,
1, // Manufacturer string descriptor index
2, // Product string descriptor index
3, // Index of serial number string descriptor
1 // One possible configuration
};
#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
/// USB device qualifier descriptor.
const USBDeviceQualifierDescriptor qualifierDescriptor = {
sizeof(USBDeviceDescriptor),
USBGenericDescriptor_DEVICE,
USBDeviceDescriptor_USB2_00,
AUDDeviceDescriptor_CLASS,
AUDDeviceDescriptor_SUBCLASS,
AUDDeviceDescriptor_PROTOCOL,
CHIP_USB_ENDPOINTS_MAXPACKETSIZE(0),
1, // Device has one possible configuration
0 // Reserved
};
#endif
/// Configuration descriptors for a USB audio speaker driver.
const AUDDSpeakerDriverConfigurationDescriptors fsConfigurationDescriptors = {
// Configuration descriptor
{
sizeof(USBConfigurationDescriptor),
USBGenericDescriptor_CONFIGURATION,
sizeof(AUDDSpeakerDriverConfigurationDescriptors),
2, // This configuration has 2 interfaces
1, // This is configuration #1
0, // No string descriptor
BOARD_USB_BMATTRIBUTES,
USBConfigurationDescriptor_POWER(100)
},
// Audio control interface standard descriptor
{
sizeof(USBInterfaceDescriptor),
USBGenericDescriptor_INTERFACE,
AUDDSpeakerDriverDescriptors_CONTROL,
0, // This is alternate setting #0
0, // This interface uses no endpoint
AUDControlInterfaceDescriptor_CLASS,
AUDControlInterfaceDescriptor_SUBCLASS,
AUDControlInterfaceDescriptor_PROTOCOL,
0 // No string descriptor
},
// Audio control interface descriptors
{
// Header descriptor
{
{
sizeof(AUDHeaderDescriptor1),
AUDGenericDescriptor_INTERFACE,
AUDGenericDescriptor_HEADER,
AUDHeaderDescriptor_AUD1_00,
sizeof(AUDDSpeakerDriverAudioControlDescriptors),
1 // One streaming interface
},
AUDDSpeakerDriverDescriptors_STREAMING
},
// Input terminal descriptor
{
sizeof(AUDInputTerminalDescriptor),
AUDGenericDescriptor_INTERFACE,
AUDGenericDescriptor_INPUTTERMINAL,
AUDDSpeakerDriverDescriptors_INPUTTERMINAL,
AUDInputTerminalDescriptor_USBSTREAMING,
AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL,
AUDDSpeakerDriver_NUMCHANNELS,
AUDInputTerminalDescriptor_LEFTFRONT
| AUDInputTerminalDescriptor_RIGHTFRONT,
0, // No string descriptor for channels
0 // No string descriptor for input terminal
},
// Output terminal descriptor
{
sizeof(AUDOutputTerminalDescriptor),
AUDGenericDescriptor_INTERFACE,
AUDGenericDescriptor_OUTPUTTERMINAL,
AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL,
AUDOutputTerminalDescriptor_SPEAKER,
AUDDSpeakerDriverDescriptors_INPUTTERMINAL,
AUDDSpeakerDriverDescriptors_FEATUREUNIT,
0 // No string descriptor
},
// Feature unit descriptor
{
{
sizeof(AUDFeatureUnitDescriptor3),
AUDGenericDescriptor_INTERFACE,
AUDGenericDescriptor_FEATUREUNIT,
AUDDSpeakerDriverDescriptors_FEATUREUNIT,
AUDDSpeakerDriverDescriptors_INPUTTERMINAL,
1, // 1 byte per channel for controls
},
{
AUDFeatureUnitDescriptor_MUTE, // Master channel controls
0, // Right channel controls
0 // Left channel controls
},
0 // No string descriptor
}
},
// Audio streaming interface with 0 endpoints
{
sizeof(USBInterfaceDescriptor),
USBGenericDescriptor_INTERFACE,
AUDDSpeakerDriverDescriptors_STREAMING,
0, // This is alternate setting #0
0, // This interface uses no endpoints
AUDStreamingInterfaceDescriptor_CLASS,
AUDStreamingInterfaceDescriptor_SUBCLASS,
AUDStreamingInterfaceDescriptor_PROTOCOL,
0 // No string descriptor
},
// Audio streaming interface with data endpoint
{
sizeof(USBInterfaceDescriptor),
USBGenericDescriptor_INTERFACE,
AUDDSpeakerDriverDescriptors_STREAMING,
1, // This is alternate setting #1
1, // This interface uses 1 endpoint
AUDStreamingInterfaceDescriptor_CLASS,
AUDStreamingInterfaceDescriptor_SUBCLASS,
AUDStreamingInterfaceDescriptor_PROTOCOL,
0 // No string descriptor
},
// Audio streaming class-specific descriptor
{
sizeof(AUDStreamingInterfaceDescriptor),
AUDGenericDescriptor_INTERFACE,
AUDStreamingInterfaceDescriptor_GENERAL,
AUDDSpeakerDriverDescriptors_INPUTTERMINAL,
0, // No internal delay because of data path
AUDFormatTypeOneDescriptor_PCM
},
// Format type I descriptor
{
{
sizeof(AUDFormatTypeOneDescriptor1),
AUDGenericDescriptor_INTERFACE,
AUDStreamingInterfaceDescriptor_FORMATTYPE,
AUDFormatTypeOneDescriptor_FORMATTYPEONE,
AUDDSpeakerDriver_NUMCHANNELS,
AUDDSpeakerDriver_BYTESPERSAMPLE,
AUDDSpeakerDriver_BYTESPERSAMPLE*8,
1 // One discrete frequency supported
},
{
AUDDSpeakerDriver_SAMPLERATE & 0xFF,
(AUDDSpeakerDriver_SAMPLERATE >> 8) & 0xFF,
(AUDDSpeakerDriver_SAMPLERATE >> 16) & 0xFF
}
},
// Audio streaming endpoint standard descriptor
{
sizeof(AUDEndpointDescriptor),
USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_OUT,
AUDDSpeakerDriverDescriptors_DATAOUT),
USBEndpointDescriptor_ISOCHRONOUS,
CHIP_USB_ENDPOINTS_MAXPACKETSIZE(AUDDSpeakerDriverDescriptors_DATAOUT),
AUDDSpeakerDriverDescriptors_FS_INTERVAL, // Polling interval = 1 ms
0, // This is not a synchronization endpoint
0 // No associated synchronization endpoint
},
// Audio streaming endpoint class-specific descriptor
{
sizeof(AUDDataEndpointDescriptor),
AUDGenericDescriptor_ENDPOINT,
AUDDataEndpointDescriptor_SUBTYPE,
0, // No attributes
0, // Endpoint is not synchronized
0 // Endpoint is not synchronized
}
};
#if defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
/// Configuration descriptors for a USB audio speaker driver.
const AUDDSpeakerDriverConfigurationDescriptors hsConfigurationDescriptors = {
// Configuration descriptor
{
sizeof(USBConfigurationDescriptor),
USBGenericDescriptor_CONFIGURATION,
sizeof(AUDDSpeakerDriverConfigurationDescriptors),
2, // This configuration has 2 interfaces
1, // This is configuration #1
0, // No string descriptor
BOARD_USB_BMATTRIBUTES,
USBConfigurationDescriptor_POWER(100)
},
// Audio control interface standard descriptor
{
sizeof(USBInterfaceDescriptor),
USBGenericDescriptor_INTERFACE,
AUDDSpeakerDriverDescriptors_CONTROL,
0, // This is alternate setting #0
0, // This interface uses no endpoint
AUDControlInterfaceDescriptor_CLASS,
AUDControlInterfaceDescriptor_SUBCLASS,
AUDControlInterfaceDescriptor_PROTOCOL,
0 // No string descriptor
},
// Audio control interface descriptors
{
// Header descriptor
{
{
sizeof(AUDHeaderDescriptor1),
AUDGenericDescriptor_INTERFACE,
AUDGenericDescriptor_HEADER,
AUDHeaderDescriptor_AUD1_00,
sizeof(AUDDSpeakerDriverAudioControlDescriptors),
1 // One streaming interface
},
AUDDSpeakerDriverDescriptors_STREAMING
},
// Input terminal descriptor
{
sizeof(AUDInputTerminalDescriptor),
AUDGenericDescriptor_INTERFACE,
AUDGenericDescriptor_INPUTTERMINAL,
AUDDSpeakerDriverDescriptors_INPUTTERMINAL,
AUDInputTerminalDescriptor_USBSTREAMING,
AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL,
AUDDSpeakerDriver_NUMCHANNELS,
AUDInputTerminalDescriptor_LEFTFRONT
| AUDInputTerminalDescriptor_RIGHTFRONT,
0, // No string descriptor for channels
0 // No string descriptor for input terminal
},
// Output terminal descriptor
{
sizeof(AUDOutputTerminalDescriptor),
AUDGenericDescriptor_INTERFACE,
AUDGenericDescriptor_OUTPUTTERMINAL,
AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL,
AUDOutputTerminalDescriptor_SPEAKER,
AUDDSpeakerDriverDescriptors_INPUTTERMINAL,
AUDDSpeakerDriverDescriptors_FEATUREUNIT,
0 // No string descriptor
},
// Feature unit descriptor
{
{
sizeof(AUDFeatureUnitDescriptor3),
AUDGenericDescriptor_INTERFACE,
AUDGenericDescriptor_FEATUREUNIT,
AUDDSpeakerDriverDescriptors_FEATUREUNIT,
AUDDSpeakerDriverDescriptors_INPUTTERMINAL,
1, // 1 byte per channel for controls
},
{
AUDFeatureUnitDescriptor_MUTE, // Master channel controls
0, // Right channel controls
0 // Left channel controls
},
0 // No string descriptor
}
},
// Audio streaming interface with 0 endpoints
{
sizeof(USBInterfaceDescriptor),
USBGenericDescriptor_INTERFACE,
AUDDSpeakerDriverDescriptors_STREAMING,
0, // This is alternate setting #0
0, // This interface uses no endpoints
AUDStreamingInterfaceDescriptor_CLASS,
AUDStreamingInterfaceDescriptor_SUBCLASS,
AUDStreamingInterfaceDescriptor_PROTOCOL,
0 // No string descriptor
},
// Audio streaming interface with data endpoint
{
sizeof(USBInterfaceDescriptor),
USBGenericDescriptor_INTERFACE,
AUDDSpeakerDriverDescriptors_STREAMING,
1, // This is alternate setting #1
1, // This interface uses 1 endpoint
AUDStreamingInterfaceDescriptor_CLASS,
AUDStreamingInterfaceDescriptor_SUBCLASS,
AUDStreamingInterfaceDescriptor_PROTOCOL,
0 // No string descriptor
},
// Audio streaming class-specific descriptor
{
sizeof(AUDStreamingInterfaceDescriptor),
AUDGenericDescriptor_INTERFACE,
AUDStreamingInterfaceDescriptor_GENERAL,
AUDDSpeakerDriverDescriptors_INPUTTERMINAL,
0, // No internal delay because of data path
AUDFormatTypeOneDescriptor_PCM
},
// Format type I descriptor
{
{
sizeof(AUDFormatTypeOneDescriptor1),
AUDGenericDescriptor_INTERFACE,
AUDStreamingInterfaceDescriptor_FORMATTYPE,
AUDFormatTypeOneDescriptor_FORMATTYPEONE,
AUDDSpeakerDriver_NUMCHANNELS,
AUDDSpeakerDriver_BYTESPERSAMPLE,
AUDDSpeakerDriver_BYTESPERSAMPLE*8,
1 // One discrete frequency supported
},
{
AUDDSpeakerDriver_SAMPLERATE & 0xFF,
(AUDDSpeakerDriver_SAMPLERATE >> 8) & 0xFF,
(AUDDSpeakerDriver_SAMPLERATE >> 16) & 0xFF
}
},
// Audio streaming endpoint standard descriptor
{
sizeof(AUDEndpointDescriptor),
USBGenericDescriptor_ENDPOINT,
USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_OUT,
AUDDSpeakerDriverDescriptors_DATAOUT),
USBEndpointDescriptor_ISOCHRONOUS,
CHIP_USB_ENDPOINTS_MAXPACKETSIZE(AUDDSpeakerDriverDescriptors_DATAOUT),
AUDDSpeakerDriverDescriptors_HS_INTERVAL, // Polling interval = 1 ms
0, // This is not a synchronization endpoint
0 // No associated synchronization endpoint
},
// Audio streaming endpoint class-specific descriptor
{
sizeof(AUDDataEndpointDescriptor),
AUDGenericDescriptor_ENDPOINT,
AUDDataEndpointDescriptor_SUBTYPE,
0, // No attributes
0, // Endpoint is not synchronized
0 // Endpoint is not synchronized
}
};
#endif // defined(CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
/// String descriptor with the supported languages.
const unsigned char languageIdDescriptor[] = {
USBStringDescriptor_LENGTH(1),
USBGenericDescriptor_STRING,
USBStringDescriptor_ENGLISH_US
};
/// Manufacturer name.
const unsigned char manufacturerDescriptor[] = {
USBStringDescriptor_LENGTH(5),
USBGenericDescriptor_STRING,
USBStringDescriptor_UNICODE('A'),
USBStringDescriptor_UNICODE('t'),
USBStringDescriptor_UNICODE('m'),
USBStringDescriptor_UNICODE('e'),
USBStringDescriptor_UNICODE('l')
};
/// Product name.
const unsigned char productDescriptor[] = {
USBStringDescriptor_LENGTH(15),
USBGenericDescriptor_STRING,
USBStringDescriptor_UNICODE('D'),
USBStringDescriptor_UNICODE('e'),
USBStringDescriptor_UNICODE('s'),
USBStringDescriptor_UNICODE('k'),
USBStringDescriptor_UNICODE('t'),
USBStringDescriptor_UNICODE('o'),
USBStringDescriptor_UNICODE('p'),
USBStringDescriptor_UNICODE(' '),
USBStringDescriptor_UNICODE('s'),
USBStringDescriptor_UNICODE('p'),
USBStringDescriptor_UNICODE('e'),
USBStringDescriptor_UNICODE('a'),
USBStringDescriptor_UNICODE('k'),
USBStringDescriptor_UNICODE('e'),
USBStringDescriptor_UNICODE('r')
};
/// Product serial number.
const unsigned char serialNumberDescriptor[] = {
USBStringDescriptor_LENGTH(4),
USBGenericDescriptor_STRING,
USBStringDescriptor_UNICODE('0'),
USBStringDescriptor_UNICODE('1'),
USBStringDescriptor_UNICODE('2'),
USBStringDescriptor_UNICODE('3')
};
/// Array of pointers to the four string descriptors.
const unsigned char *stringDescriptors[] = {
languageIdDescriptor,
manufacturerDescriptor,
productDescriptor,
serialNumberDescriptor,
};
//------------------------------------------------------------------------------
// Exported functions
//------------------------------------------------------------------------------
/// List of descriptors required by an USB audio speaker device driver.
const USBDDriverDescriptors auddSpeakerDriverDescriptors = {
&deviceDescriptor,
(const USBConfigurationDescriptor *) &fsConfigurationDescriptors,
#if defined (CHIP_USB_UDPHS) || defined(CHIP_USB_OTGHS)
&qualifierDescriptor,
(const USBConfigurationDescriptor *) &hsConfigurationDescriptors,
&deviceDescriptor,
(const USBConfigurationDescriptor *) &hsConfigurationDescriptors,
&qualifierDescriptor,
(const USBConfigurationDescriptor *) &hsConfigurationDescriptors,
#else
0, 0, 0, 0, 0, 0,
#endif
stringDescriptors,
4 // Number of string descriptors
};
@@ -0,0 +1,146 @@
/* ----------------------------------------------------------------------------
* 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
Declaration of the descriptors required by a USB audio speaker driver.
!!!Usage
-# Initialize a USBDDriver instance using the
auddSpeakerDriverDescriptors list.
*/
#ifndef AUDDSPEAKERDRIVERDESCRIPTORS_H
#define AUDDSPEAKERDRIVERDESCRIPTORS_H
//------------------------------------------------------------------------------
// Headers
//------------------------------------------------------------------------------
#include <board.h>
#include <usb/device/core/USBDDriverDescriptors.h>
//------------------------------------------------------------------------------
// Definitions
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "Audio Speaker Endpoint Numbers"
///
/// This page lists the endpoint number settings for USB Audio Speaker device.
///
/// !Endpoints
/// - AUDDSpeakerDriverDescriptors_DATAOUT
/// - AUDDSpeakerDriverDescriptors_DATAIN
/// - AUDDSpeakerDriverDescriptors_FS_INTERVAL
/// - AUDDSpeakerDriverDescriptors_HS_INTERVAL
///
/// \note for UDP, uses IN EPs that support double buffer; for UDPHS, uses
/// IN EPs that support DMA and High bandwidth.
#if defined(at91sam7s) || defined(at91sam9xe)
/// Data out endpoint number.
#define AUDDSpeakerDriverDescriptors_DATAOUT 0x01
/// Data in endpoint number.
#define AUDDSpeakerDriverDescriptors_DATAIN 0x02
#elif defined(CHIP_USB_UDP)
/// Data out endpoint number.
#define AUDDSpeakerDriverDescriptors_DATAOUT 0x04
/// Data in endpoint number.
#define AUDDSpeakerDriverDescriptors_DATAIN 0x05
#else
/// Data out endpoint number.
#define AUDDSpeakerDriverDescriptors_DATAOUT 0x05
/// Data in endpoint number.
#define AUDDSpeakerDriverDescriptors_DATAIN 0x06
#endif
/// Endpoint polling interval 2^(x-1) * 125us
#define AUDDSpeakerDriverDescriptors_HS_INTERVAL 0x04
/// Endpoint polling interval 2^(x-1) * ms
#define AUDDSpeakerDriverDescriptors_FS_INTERVAL 0x01
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "Audio Speaker Interface IDs"
///
/// This page lists the interface numbers for USB Audio Speaker device.
///
/// !Interfaces
/// - AUDDSpeakerDriverDescriptors_CONTROL
/// - AUDDSpeakerDriverDescriptors_STREAMING
/// - AUDDSpeakerDriverDescriptors_STREAMINGIN
/// Audio control interface ID.
#define AUDDSpeakerDriverDescriptors_CONTROL 0
/// Audio streaming interface ID (OUT, for playback).
#define AUDDSpeakerDriverDescriptors_STREAMING 1
/// Audio streaming interface ID (IN, for record).
#define AUDDSpeakerDriverDescriptors_STREAMINGIN 2
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
/// \page "Audio Speaker Entity IDs"
///
/// This page lists the entity IDs for USB Audio Speaker device.
///
/// !Entities
/// - AUDDSpeakerDriverDescriptors_INPUTTERMINAL
/// - AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL
/// - AUDDSpeakerDriverDescriptors_FEATUREUNIT
/// - AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC
/// - AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL_REC
/// - AUDDSpeakerDriverDescriptors_FEATUREUNIT_REC
/// Playback input terminal ID.
#define AUDDSpeakerDriverDescriptors_INPUTTERMINAL 0
/// Playback output terminal ID.
#define AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL 1
/// Playback feature unit ID.
#define AUDDSpeakerDriverDescriptors_FEATUREUNIT 2
/// Record input terminal ID.
#define AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC 3
/// Record output terminal ID.
#define AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL_REC 4
/// Record feature unit ID
#define AUDDSpeakerDriverDescriptors_FEATUREUNIT_REC 5
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Exported variables
//------------------------------------------------------------------------------
extern const USBDDriverDescriptors auddSpeakerDriverDescriptors;
#endif //#ifndef AUDDSPEAKERDRIVERDESCRIPTORS_H
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

@@ -0,0 +1,617 @@
/* ----------------------------------------------------------------------------
* 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.
* ----------------------------------------------------------------------------
*/
//------------------------------------------------------------------------------
/// \dir
///
/// !!!Purpose
///
/// This directory provides definitions, structs and functions for a USB Audio
/// Class device - USB audio-speaker demo, to implement an USB desktop speaker.
///
/// !!!Contents
/// There are two things for the implement of the audio-speaker device driver:
/// - Implement the audio-speaker driver structs and functions for the device,
/// to initialize, to handle audio class specific requests and dispach
/// standard requests in USBD callbacks, to read/write through assigned USB
/// endpoints,
/// - Create the audio-speaker device's descriptors that should be passed to
/// the USBDDriver instance on initialization, so that the host can
/// recognize the device as a USB audio "desktop speaker" device.
///
/// For more information about what a particular group contains, please refer to
/// "USB Audio Speaker Device".
//------------------------------------------------------------------------------
/**
\page "USB Audio Speaker Device"
This page describes how to use the USB framework to produce a USB Audio Class
Device driver.
!!!References
- "AT91 USB device framework"
- "USB Device Enumeration"
- <a href="http://www.usb.org/developers/docs/usb_20_040908.zip">
Universal Serial Bus Revision 2.0 specification
</a> (.zip file format, size 9.80 MB)
- <a href="http://www.usb.org/developers/devclass_docs/audio10.pdf">
Audio Device Document 1.0</a>
- <a href="http://www.usb.org/developers/devclass_docs/frmts10.pdf">
Audio Data Formats 1.0</a>
- <a href="http://www.usb.org/developers/devclass_docs/termt10.pdf">
Autio Terminal Types 1.0</a>
!!!Audio Speaker Driver API
- AUDDSpeakerDriver_Initialize
- AUDDSpeakerDriver_RequestHandler
- AUDDSpeakerDriver_Read
!!!Audio Desktop Speaker Description
The %device described here is a USB desktop speaker. It receives a stero
%audio data stream from the Host over its Audio Streaming interface. The used
Audio Data Format is 16-bit 48KHz 2-channel PCM (or mono 16-bit 32KHz PCM for
sam7s chips). The following is the internal topology of the speaker.
\image USBAudioSpeaker.png "USB Desktop Speaker Topology"
The %audio function contains one Onput Terminal that represents the actual
speaker output element, followed by the Digital-to-Analog Converter (DAC).
The digital input stream of the host enters the %audio function through the
single Input %Pin of the Output terminal. There is a Feature Unit on the
%audio stream, to mute or unmute the speaker. The Input Terminal is the
representation within the %audio fucntion of the USB OUT endpoint that
eventually receives the %audio data stream from the Host. The internals of the
%audio function are presented to the Host through the (mandatory) AudioControl
interface wheras the USB OUT endpoint resides in the AudioStreaming interface.
!!!Descriptor Hierarchy
This USB Desktop Speaker %device includes the AudioControl interface
(interface 0) and a single AudioStreaming interface (interface 1). The
AudioStreaming interface features two alternate settings. The first alternate
setting (Alternate Setting 0) has zero bandwidth associated with it so that
switching to this alternate setting effectively frees all allocated bandwidth
on the USB for this device. Zero bandwidth is indicated by the lack of a
streaming endpoint. Alternate Setting 1 is the operational part of the
interface and it has one isochronous OUT endpoint. Figure presents the
descriptor hierarchy.
\image UsbAudioSpeakerDescriptors.png "USB Desktop Speaker Hierarchy"
!!!Descriptors
The following sections present all the descriptors that are used to describe
the %device.
All descriptors are combined into a list and pass to USBDDriver_Initialize
invoked in AUDDSpeakerDriver_Initialize.
\code
const USBDDriverDescriptors auddSpeakerDriverDescriptors;
\endcode
!!Device Descriptor
\code
const USBDeviceDescriptor deviceDescriptor;
\endcode
||Offset||Field||Size||Value||Description
|0|bLength|1|0x12|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x01|DEVICE descriptor (USBGenericDescriptor_DEVICE).
|2|bcdUSB|2|0x0200|2.00 - current revision of USB specification.
|4|bDeviceClass|1|0x00|Device defined at interface level.
|5|bDeviceSubClass|1|0x00|Unused.
|6|bDeviceProtocol|1|0x00|Unused.
|7|bMaxPacketSize0|1|0x08|8 bytes (BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0)).
|8|idVendor|2|0x03EB|Atmel Vendor ID (AUDDSpeakerDriverDescriptors_VENDORID).
|10|idProduct|2|0x6128|Product ID (AUDDSpeakerDriverDescriptors_PRODUCTID).
|12|bcdDevice|2|0x0100|Device Release Code\n
(AUDDSpeakerDriverDescriptors_RELEASE).
|14|iManufacturer|1|0x01|Index to manufacture name in Unicode\n
(manufacturerDescriptor).
|15|iProduct|1|0x02|Index to product name in Unicode (productDescriptor).
|16|iSerialNumber|1|0x03|Index to serial number in Unicode\n
(serialNumberDescriptor).
|17|bNumConfigurations|1|0x01|One configuration.
!!Configuration Descriptor
\code
const AUDDSpeakerDriverConfigurationDescriptors configurationDescriptors;
\endcode
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x02|CONFIGURATION descriptor\n
(USBGenericDescriptor_CONFIGURATION).
|2|wTotalLength|2|0x????|Length of the total configuration block in bytes\n
including this descriptor\n
(AUDDSpeakerDriverConfigurationDescriptors)
|4|bNumInterfaces|1|0x02|Two interfaces.
|5|bConfigurationValue|1|0x01|ID of this configuration.
|6|iConfiguration|1|0x00|Unused.
|7|bmAttributes|1|0x??|BOARD_USB_BMATTRIBUTES
|8|bMaxPower|1|0x32|100mA Max. %power consumption.\n
USBConfigurationDescriptor_POWER(100)
!!AudioControl Interface Descriptor
The AudioControl interface describes the %device structure (%audio function
topology) and is used to manipulate the Audio Controls.
!Standard AC Interface Descriptor
The AudioControl interface has no dedicated endpoints associated with it. It
uses the default pipe (endpoint 0) for all communication purposes. Class-
specific AudioControl Requests are sent using the default pipe. There is no
Status Interrupt endpoint provided.
See USBInterfaceDescriptor.
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x04|INTERFACE descriptor\n
(USBGenericDescriptor_INTERFACE).
|2|bInterfaceNumber|1|0x00|Index of this interface.
|3|bAlternateSetting|1|0x00|Index of this setting.
|4|bNumEndpoints|1|0x00|0 endpoints.
|5|bInterfaceClass|1|0x01|AUDIO (AUDControlInterfaceDescriptor_CLASS).
|6|bInterfaceSubClass|1|0x01|AUDIO_CONTROL\n
(AUDControlInterfaceDescriptor_SUBCLASS).
|7|bInterfaceProtocol|1|0x00|Unused.
|8|iInterface|1|0x00|Unused.
!Class-specific AC Interface Descriptor
The Class-specific AC interface descriptor is always headed by a Header
descriptor that contains general information about the AudioControl interface.
It contains all the pointers needed to describe the AudioInterface Collection,
associated with the described %audio function.
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubtype|1|0x01|HEADER subtype (AUDGenericDescriptor_HEADER).
|3|bcdADC|2|0x0100|Revision of class specification - 1.0
|5|wTotalLength|2|0x????|Total size of class specific descriptors\n
(AUDDSpeakerDriverAudioControlDescriptors).
|7|bInCollection|1|0x01|Number of streaming interfaces.
|8|baInterfaceNr(1)|1|0x01|AudioStreaming interface 1 belongs to this AudioControl interface.
!Input Terminal Descriptor for playback
This descriptor describes the Input Terminal that represents the USB pipe from
the Host PC. Its Output Pin is connected to the Input Pin of the Feature Unit
...
||Offset||Field||Size||Value||Description
|0|bLength|1|0x0C|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x02|INPUT_TERMINAL subtype\n
(AUDGenericDescriptor_INPUTTERMINAL).
|3|bTerminalID|1|0x00|ID of this Input Terminal\n
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL).
|4|wTerminalType|2|0x0101|Terminal is USB stream\n
(AUDInputTerminalDescriptor_USBSTREAMING).
|6|bAssocTerminal|1|0x01|Associated to Output Terminal\n
(AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL).
|7|bNrChannels|1|0x02|Two channel.
|8|wChannelConfig|2|0x0003|Left plus right front channel.
|10|iChannelNames|1|0x00|Unused.
|11|iTerminal|1|0x00|Unused.
!Output Terminal Descriptor for playback
...
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x03|OUTPUT_TERMINAL subtype\n
(AUDGenericDescriptor_OUTPUTTERMINAL).
|3|bTerminalID|1|0x01|ID of this Output Terminal\n
(AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL).
|4|wTerminalType|2|0x0301|Terminal is Desktop speaker.
|6|bAssocTerminal|1|0x01|Associated to Input Terminal\n
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL).
|7|bSourceID|1|0x02|From Feature Unit\n
(AUDDSpeakerDriverDescriptors_FEATUREUNIT).
|8|iTerminal|1|0x00|Unused.
!Feature Unit Descriptor for playback
...
||Offset||Field||Size||Value||Description
|0|bLength|1|0x0A|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x02|FEATURE_UNIT subtype\n
(AUDGenericDescriptor_FEATUREUNIT).
|3|bUnitID|1|0x02|ID of this Feature Unit\n
(AUDDSpeakerDriverDescriptors_FEATUREUNIT).
|4|bSourceID|1|0x00|From Input Terminal\n
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL).
|5|bControlSize|1|0x01|1 byte per channel for controls
|6|bmaControls|3|0x000001|Master channel mute control, no other controls.
|9|iFeature|1|0x00|Unused.
!!AudioStreaming Interface Descriptor
The AudioStreaming interface has two possible alternate settings.
!Zero-bandwidth Alternate Setting 0
Alternate setting 0 is a zero-bandwidth setting, used to relinquish the
claimed bandwidth on the bus when the microphone is not in use. It is the
default setting after power-up. The zero bandwidth is implemented by
specifying that this alternate setting of the interface has no endpoints
associated with it (bNumEndpoints=0). The collection of descriptors for this
alternate setting reduces to the standard interface descriptor.
Standard AS Interface Descriptor (USBInterfaceDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x04|INTERFACE descriptor\n
(USBGenericDescriptor_INTERFACE).
|2|bInterfaceNumber|1|0x01|Index of this interface.
|3|bAlternateSetting|1|0x00|Index of this setting.
|4|bNumEndpoints|1|0x00|0 endpoint.
|5|bInterfaceClass|1|0x01|AUDIO (AUDStreamingInterfaceDescriptor_CLASS).
|6|bInterfaceSubClass|1|0x02|AUDIO_STREAMING\n
(AUDStreamingInterfaceDescriptor_SUBCLASS).
|7|bInterfaceProtocol|1|0x00|Unused (AUDStreamingInterfaceDescriptor_PROTOCOL).
|8|iInterface|1|0x00|Unused.
!Operational Alternate Setting 1
Alternate setting 1 is the operational setting of the interface. It contains
the standard and class-specific interface and endpoint descriptors.
Standard AS Interface Descriptor (USBInterfaceDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of USBInterfaceDescriptor in bytes.
|1|bDescriptorType|1|0x04|INTERFACE descriptor\n
(USBGenericDescriptor_INTERFACE).
|2|bInterfaceNumber|1|0x01|Index of this interface.
|3|bAlternateSetting|1|0x01|Index of this setting.
|4|bNumEndpoints|1|0x01|1 endpoint.
|5|bInterfaceClass|1|0x01|AUDIO (AUDStreamingInterfaceDescriptor_CLASS).
|6|bInterfaceSubClass|1|0x02|AUDIO_STREAMING\n
(AUDStreamingInterfaceDescriptor_SUBCLASS).
|7|bInterfaceProtocol|1|0x00|Unused (AUDStreamingInterfaceDescriptor_PROTOCOL).
|8|iInterface|1|0x00|Unused.
Class-specific AS General Interface Descriptor (AUDStreamingInterfaceDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x06|Size of AUDStreamingInterfaceDescriptor in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x01|GENERAL subtype\n
(AUDStreamingInterfaceDescriptor_GENERAL).
|3|bTerminalLink|1|0x02|Unit ID of the Input Terminal\n
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL).
|4|bDelay|1|0x00|No interface delay.
|5|wFormatTag|2|0x0001|PCM Format (AUDFormatTypeOneDescriptor_PCM).
Type I Format Type Descriptor (AUDFormatTypeOneDescriptor1)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x0B|Size of AUDFormatTypeOneDescriptor1 in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x02|FORMAT_TYPE subtype\n
(AUDStreamingInterfaceDescriptor_FORMATTYPE).
|3|bFormatType|1|0x01|FORMAT_TYPE_I (AUDFormatTypeOneDescriptor_FORMATTYPEONE).
|4|bNrChannels|1|0x02|2 channels (AUDDSpeakerDriver_NUMCHANNELS).
|5|bSubFrameSize|1|0x02|Two bytes per audio subframe\n
(AUDDSpeakerDriver_BYTESPERSAMPLE).
|6|bBitResolution|1|0x10|16 bits per sample\n
(AUDDSpeakerDriver_BYTESPERSAMPLE * 2).
|7|bSamFreqType|1|0x01|One frequency supported.
|8|tSamFreq|3|4800|4800Hz (AUDDSpeakerDriver_SAMPLERATE).
Standard %Endpoint Descriptor (AUDEndpointDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of AUDFormatTypeOneDescriptor1 in bytes.
|1|bDescriptorType|1|0x24|ENDPOINT descriptor (USBGenericDescriptor_ENDPOINT).
|2|bEndpointAddress|1|0x04\nTest|OUT endpoint 4\n
See USBEndpointDescriptor_ADDRESS\n
See AUDDSpeakerDriverDescriptors_DATAOUT.
|3|bmAttributes|1|0x01|Isochronous, not shared\n
(USBEndpointDescriptor_ISOCHRONOUS).
|4|wMaxPacketSize|2|0x????|BOARD_USB_ENDPOINTS_MAXPACKETSIZE().
|6|bInterval|1|0x01|One packet per frame.
|7|bRefresh|1|0x00|Unused.
|8|bSynchAddress|1|0x00|Unused.
Class-specific Isochronous Audio Data Endpoint Descriptor
(AUDDataEndpointDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x07|Size of AUDDataEndpointDescriptor in bytes.
|1|bDescriptorType|1|0x25|CS_ENDPOINT descriptor\n
(AUDGenericDescriptor_ENDPOINT).
|2|bDescriptorSubType|1|0x01|GENERAL subtype\n
(AUDDataEndpointDescriptor_SUBTYPE).
|3|bmAttributes|1|0x00|No sampling frequency control\n
no pitch control\n
no packet padding.
|4|bLockDelayUnits|1|0x00|Unused.
|5|wLockDelay|2|0x0000|Unused.
!!String Descriptors
There are three string descriptors available. The Manufacturer, Product and
Serial Number descriptor.
See manufacturerDescriptor, productDescriptor, serialNumberDescriptor.
!!!Requests
The Audio Speaker Driver supports all necessary standard requests, and some
class-specific requests.
USBDCallbacks_RequestReceived is used to filter all requests,
AUDDSpeakerDriver_RequestHandler is invoked to handle Audio Class requests
and forward standard request to AUDDSpeakerDriver_RequestHandler.
!!Standard requests
Set Interface request should be processed to control bandwidth allocation.
!Set Interface
USBDDriverCallbacks_InterfaceSettingChanged is re-implemented to handle the
event.
||Offset||Field||Size||Value||Description
|0|bmRequestType|1|0x01|D7:0=Host to Device.\n
D6..5:00=Standard Request.\n
D4..0:00001=Recipient is interface.
|1|bRequest|1|0x0B|SET_INTERFACE.
|2|wValue|2|0x0000\n
or\n
0x0001|Zero bandwidth or normal isochronous operation.
|4|wIndex|2|0x0001|Interface number of the AudioStreaming interface.
|6|wLength|2|0x0000|No Parameter Block.
!!Class-specific requests
The only class-specific Request supported is the Set/Get Feature Unit Control
Request. For mute control of the Feature Unit.
!Set Feature Unit Control Request
||Offset||Field||Size||Value||Description
|0|bmRequestType|1|0x01|D7:0=Host to Device.\n
D6..5:01=Class Request.\n
D4..0:00001=Recipient is interface.
|1|bRequest|1|0x01|SET_CUR.
|2|wValue|2|0x0100|Mute control (AUDFeatureUnitRequest_MUTE) of\n
Master channel (AUDDSpeakerDriver_MASTERCHANNEL).
|4|wIndex|2|0x0200|Feature Unit (AUDDSpeakerDriverDescriptors_FEATUREUNIT)\n
and\n
AudioControl Interface (AUDDSpeakerDriverDescriptors_CONTROL).
|6|wLength|2|0x0001|Paramter Block Length
The one-byte Parameter Block contains the new bMuted value for Feature
Control.
!Get Feature Unit Control Request
||Offset||Field||Size||Value||Description
|0|bmRequestType|1|0x01|D7:0=Host to Device.\n
D6..5:01=Class Request.\n
D4..0:00001=Recipient is interface.
|1|bRequest|1|0x81|GET_CUR.
|2|wValue|2|0x0100|Mute control (AUDFeatureUnitRequest_MUTE) of\n
Master channel (AUDDSpeakerDriver_MASTERCHANNEL).
|4|wIndex|2|0x0200|Feature Unit (AUDDSpeakerDriverDescriptors_FEATUREUNIT)\n
and\n
AudioControl Interface (AUDDSpeakerDriverDescriptors_CONTROL).
|6|wLength|2|0x0001|Paramter Block Length
The one-byte Parameter Block contains the new bMuted value for Feature
Control.
!!!Modify the Device Driver
You can modify your project from the USB Audio Demoes:
- usb-device-audio-speaker-ac97-project
- usb-device-audio-speaker-project
!!Change Device ID and Display
All Device ID and Display Strings are in AUDDSpeakerDriverDescriptors.c.
!Device IDs
You can find "Audio Speaker Device Codes"
- AUDDSpeakerDriverDescriptors_VENDORID
- AUDDSpeakerDriverDescriptors_PRODUCTID
- AUDDSpeakerDriverDescriptors_RELEASE
!Display Strings
You can modify the string descriptors
- manufacturerDescriptor
- productDescriptor
- serialNumberDescriptor
!!!Add Recorder Function
See "USB Audio Recorder".
*/
/**
\page "USB Audio Recorder"
This page describes how to add recorder function into the
"USB Audio Speaker Device", So that you can learn how to extend your audio
device driver from current Audio Speaker demo.
!!!Description
To add %audio record function, new Input Terminal, Output Termnial and Feature
Unit is added.
\image UsbAudioSpeakerRecorder.png "USB Desktop Speaker Hierarchy"
!!!Modify the configuration descriptor:
New descriptor for the terminals and unit should be added, and according
interface, too.
\image UsbAudioSpeakerRecorderDescriptors.png "USB Desktop Speaker Descriptors"
!!Terminal Descriptors and Unit Descriptor
...
!Input Terminal Descriptor for recording
...
||Offset||Field||Size||Value||Description
|0|bLength|1|0x0C|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x03|INPUT_TERMINAL subtype\n
(AUDGenericDescriptor_INPUTTERMINAL).
|3|bTerminalID|1|0x03|ID of this Input Terminal\n
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC).
|4|wTerminalType|2|0x0403|Terminal is Speaker Phone\n
(AUDInputTerminalDescriptor_SPEAKERPHONE).
|6|bAssocTerminal|1|0x04|Associated to Output Terminal\n
(AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL_REC).
|7|bNrChannels|1|0x02|Two channel.
|8|wChannelConfig|2|0x0003|Left plus right front channel.
|10|iChannelNames|1|0x00|Unused.
|11|iTerminal|1|0x00|Unused.
!Output Terminal Descriptor for recording
...
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x04|OUTPUT_TERMINAL subtype\n
(AUDGenericDescriptor_OUTPUTTERMINAL).
|3|bTerminalID|1|0x04|ID of this Output Terminal\n
(AUDDSpeakerDriverDescriptors_OUTPUTTERMINAL_REC).
|4|wTerminalType|2|0x0301|Terminal is USB stream\n
(AUDOutputTerminalDescriptor_USBTREAMING).
|6|bAssocTerminal|1|0x03|Associated to Input Terminal\n
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC).
|7|bSourceID|1|0x05|From Feature Unit\n
(AUDDSpeakerDriverDescriptors_FEATUREUNIT_REC).
|8|iTerminal|1|0x00|Unused.
!Feature Unit Descriptor for recording
...
||Offset||Field||Size||Value||Description
|0|bLength|1|0x0A|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x02|FEATURE_UNIT subtype\n
(AUDGenericDescriptor_FEATUREUNIT).
|3|bUnitID|1|0x05|ID of this Feature Unit\n
(AUDDSpeakerDriverDescriptors_FEATUREUNIT_REC).
|4|bSourceID|1|0x03|From Input Terminal\n
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL_REC).
|5|bControlSize|1|0x01|1 byte per channel for controls
|6|bmaControls|3|0x000001|Master channel mute control, no other controls.
|9|iFeature|1|0x00|Unused.
!!Interface Descriptor and Endpoint Descriptor for recording
...
!Zero-bandwidth Alternate Setting 0
Standard AS Interface Descriptor (USBInterfaceDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of this descriptor, in bytes.
|1|bDescriptorType|1|0x04|INTERFACE descriptor\n
(USBGenericDescriptor_INTERFACE).
|2|bInterfaceNumber|1|0x02|Index of this interface.
|3|bAlternateSetting|1|0x00|Index of this setting.
|4|bNumEndpoints|1|0x00|0 endpoint.
|5|bInterfaceClass|1|0x01|AUDIO (AUDStreamingInterfaceDescriptor_CLASS).
|6|bInterfaceSubClass|1|0x02|AUDIO_STREAMING\n
(AUDStreamingInterfaceDescriptor_SUBCLASS).
|7|bInterfaceProtocol|1|0x00|Unused (AUDStreamingInterfaceDescriptor_PROTOCOL).
|8|iInterface|1|0x00|Unused.
!Operational Alternate Setting 1
Standard AS Interface Descriptor (USBInterfaceDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of USBInterfaceDescriptor in bytes.
|1|bDescriptorType|1|0x04|INTERFACE descriptor\n
(USBGenericDescriptor_INTERFACE).
|2|bInterfaceNumber|1|0x02|Index of this interface.
|3|bAlternateSetting|1|0x01|Index of this setting.
|4|bNumEndpoints|1|0x01|1 endpoint.
|5|bInterfaceClass|1|0x01|AUDIO (AUDStreamingInterfaceDescriptor_CLASS).
|6|bInterfaceSubClass|1|0x02|AUDIO_STREAMING\n
(AUDStreamingInterfaceDescriptor_SUBCLASS).
|7|bInterfaceProtocol|1|0x00|Unused (AUDStreamingInterfaceDescriptor_PROTOCOL).
|8|iInterface|1|0x00|Unused.
Class-specific AS General Interface Descriptor (AUDStreamingInterfaceDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x06|Size of AUDStreamingInterfaceDescriptor in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x01|GENERAL subtype\n
(AUDStreamingInterfaceDescriptor_GENERAL).
|3|bTerminalLink|1|0x02|Unit ID of the Input Terminal\n
(AUDDSpeakerDriverDescriptors_INPUTTERMINAL).
|4|bDelay|1|0x00|No interface delay.
|5|wFormatTag|2|0x0001|PCM Format (AUDFormatTypeOneDescriptor_PCM).
Type I Format Type Descriptor (AUDFormatTypeOneDescriptor1)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x0B|Size of AUDFormatTypeOneDescriptor1 in bytes.
|1|bDescriptorType|1|0x24|CS_INTERFACE descriptor\n
(AUDGenericDescriptor_INTERFACE).
|2|bDescriptorSubType|1|0x02|FORMAT_TYPE subtype\n
(AUDStreamingInterfaceDescriptor_FORMATTYPE).
|3|bFormatType|1|0x01|FORMAT_TYPE_I (AUDFormatTypeOneDescriptor_FORMATTYPEONE).
|4|bNrChannels|1|0x02|2 channels (AUDDSpeakerDriver_NUMCHANNELS).
|5|bSubFrameSize|1|0x02|Two bytes per audio subframe\n
(AUDDSpeakerDriver_BYTESPERSAMPLE).
|6|bBitResolution|1|0x10|16 bits per sample\n
(AUDDSpeakerDriver_BYTESPERSAMPLE * 2).
|7|bSamFreqType|1|0x01|One frequency supported.
|8|tSamFreq|3|4800|4800Hz (AUDDSpeakerDriver_SAMPLERATE).
Standard %Endpoint Descriptor (AUDEndpointDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x09|Size of AUDFormatTypeOneDescriptor1 in bytes.
|1|bDescriptorType|1|0x24|ENDPOINT descriptor (USBGenericDescriptor_ENDPOINT).
|2|bEndpointAddress|1|0x85|IN endpoint 5\n
USBEndpointDescriptor_ADDRESS()\n
AUDDSpeakerDriverDescriptors_DATAIN
|3|bmAttributes|1|0x01|Isochronous, not shared\n
(USBEndpointDescriptor_ISOCHRONOUS).
|4|wMaxPacketSize|2|0x????|BOARD_USB_ENDPOINTS_MAXPACKETSIZE(5).
|6|bInterval|1|0x01|One packet per frame.
|7|bRefresh|1|0x00|Unused.
|8|bSynchAddress|1|0x00|Unused.
Class-specific Isochronous Audio Data Endpoint Descriptor
(AUDDataEndpointDescriptor)
||Offset||Field||Size||Value||Description
|0|bLength|1|0x07|Size of AUDDataEndpointDescriptor in bytes.
|1|bDescriptorType|1|0x25|CS_ENDPOINT descriptor\n
(AUDGenericDescriptor_ENDPOINT).
|2|bDescriptorSubType|1|0x01|GENERAL subtype\n
(AUDDataEndpointDescriptor_SUBTYPE).
|3|bmAttributes|1|0x00|No sampling frequency control\n
no pitch control\n
no packet padding
|4|bLockDelayUnits|1|0x00|Unused.
|5|wLockDelay|2|0x0000|Unused.
!!!Modified methods for new function
Several methods modified for new recorder function.
!!Request handlers callbacks
Add handler for new Interface, Terminal and Unit IDs.
See AUDDSpeakerDriver_RequestHandler.
!!Add function for recording USB stream
See AUDDSpeakerDriver_Write.
*/
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More