blob: d355e417a450986672d3c3203dd6a884f7a299da [file] [log] [blame]
Christina Quastb123d742014-12-23 13:03:36 +01001/* ----------------------------------------------------------------------------
2 * ATMEL Microcontroller Software Support
3 * ----------------------------------------------------------------------------
4 * Copyright (c) 2010, Atmel Corporation
5 *
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
10 *
11 * - Redistributions of source code must retain the above copyright notice,
12 * this list of conditions and the disclaimer below.
13 *
14 * Atmel's name may not be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 * ----------------------------------------------------------------------------
28 */
29
30/**
31 * \file
32 *
33 * \section Purpose
34 *
35 * Definitions and methods for USB composite device implement.
36 *
37 */
38
39#ifndef HIDAUDDDRIVER_H
40#define HIDAUDDDRIVER_H
41/** \addtogroup usbd_hid_aud
42 *@{
43 */
44
45/*---------------------------------------------------------------------------
46 * Headers
47 *---------------------------------------------------------------------------*/
48
49#include <USBRequests.h>
50#include <HIDDescriptors.h>
51#include <AUDDescriptors.h>
52#include <USBD.h>
53#include <USBDDriver.h>
54
55/*---------------------------------------------------------------------------
56 * Definitions
57 *---------------------------------------------------------------------------*/
58
59/** \addtogroup usbd_hid_aud_desc USB HID(Keyboard) + AUD(Speaker) Definitions
60 * @{
61 */
62/** Number of interfaces of the device 1+2 */
63#define HIDAUDDDriverDescriptors_NUMINTERFACE 3
64/** Number of the CDC interface. */
65#define HIDAUDDDriverDescriptors_HID_INTERFACE 0
66/** Number of the Audio interface. */
67#define HIDAUDDDriverDescriptors_AUD_INTERFACE 1
68/** @}*/
69
70/*---------------------------------------------------------------------------
71 * Types
72 *---------------------------------------------------------------------------*/
73
74#ifdef __ICCARM__ /* IAR */
75#pragma pack(1) /* IAR */
76#define __attribute__(...) /* IAR */
77#endif /* IAR */
78
79/** Structure of audio header descriptor*/
80typedef struct _AUDHeaderDescriptor1{
81
82 /** Header descriptor.*/
83 AUDHeaderDescriptor header;
84 /** Id of the first grouped interface.*/
85 unsigned char bInterface0;
86
87} __attribute__ ((packed)) AUDHeaderDescriptor1;
88
89/**
90 * Feature unit descriptor with 3 channel controls (master, right, left).
91 */
92typedef struct _AUDFeatureUnitDescriptor3{
93
94 /** Feature unit descriptor.*/
95 AUDFeatureUnitDescriptor feature;
96 /** Available controls for each channel.*/
97 unsigned char bmaControls[3];
98 /** Index of a string descriptor for the feature unit.*/
99 unsigned char iFeature;
100
101} __attribute__ ((packed)) AUDFeatureUnitDescriptor3;
102
103/**
104 * List of descriptors for detailling the audio control interface of a
105 * device using a USB audio speaker driver.
106 */
107typedef struct _AUDDSpeakerDriverAudioControlDescriptors{
108
109 /** Header descriptor (with one slave interface).*/
110 AUDHeaderDescriptor1 header;
111 /** Input terminal descriptor.*/
112 AUDInputTerminalDescriptor input;
113 /** Output terminal descriptor.*/
114 AUDOutputTerminalDescriptor output;
115 /** Feature unit descriptor.*/
116 AUDFeatureUnitDescriptor3 feature;
117
118} __attribute__ ((packed)) AUDDSpeakerDriverAudioControlDescriptors; // GCC
119
120/**
121 * Format type I descriptor with one discrete sampling frequency.
122 */
123typedef struct _AUDFormatTypeOneDescriptor1{
124
125 /** Format type I descriptor.*/
126 AUDFormatTypeOneDescriptor formatType;
127 /** Sampling frequency in Hz.*/
128 unsigned char tSamFreq[3];
129
130} __attribute__ ((packed)) AUDFormatTypeOneDescriptor1; // GCC
131
132/**
133 * \typedef CdcAudDriverConfigurationDescriptors
134 * \brief Configuration descriptor list for a device implementing a
135 * composite HID (Keyboard) + Audio (Speaker) driver.
136 */
137typedef struct _HidAuddDriverConfigurationDescriptors {
138
139 /** Standard configuration descriptor. */
140 USBConfigurationDescriptor configuration;
141
142 /* --- HID */
143 /** HID interface. */
144 USBInterfaceDescriptor hidInterface;
145 /** HID descriptor */
146 HIDDescriptor1 hid;
147 /** HID interrupt IN */
148 USBEndpointDescriptor hidInterruptIn;
149 /** HID interrupt OUT */
150 USBEndpointDescriptor hidInterruptOut;
151
152 /* --- AUDIO (AC) */
153 /** Audio IAD */
154 USBInterfaceAssociationDescriptor audIAD;
155 /** Audio control interface.*/
156 USBInterfaceDescriptor audInterface;
157 /** Descriptors for the audio control interface.*/
158 AUDDSpeakerDriverAudioControlDescriptors audControl;
159 /* -- AUDIO out (AS) */
160 /** Streaming out interface descriptor (with no endpoint, required).*/
161 USBInterfaceDescriptor audStreamingOutNoIsochronous;
162 /** Streaming out interface descriptor.*/
163 USBInterfaceDescriptor audStreamingOut;
164 /** Audio class descriptor for the streaming out interface.*/
165 AUDStreamingInterfaceDescriptor audStreamingOutClass;
166 /** Stream format descriptor.*/
167 AUDFormatTypeOneDescriptor1 audStreamingOutFormatType;
168 /** Streaming out endpoint descriptor.*/
169 AUDEndpointDescriptor audStreamingOutEndpoint;
170 /** Audio class descriptor for the streaming out endpoint.*/
171 AUDDataEndpointDescriptor audStreamingOutDataEndpoint;
172
173} __attribute__ ((packed)) HidAuddDriverConfigurationDescriptors;
174
175#ifdef __ICCARM__ /* IAR */
176#pragma pack() /* IAR */
177#endif /* IAR */
178
179/*---------------------------------------------------------------------------
180 * Exported functions
181 *---------------------------------------------------------------------------*/
182
183extern void HIDAUDDDriver_Initialize(const USBDDriverDescriptors * pDescriptors);
184extern void HIDAUDDDriver_ConfigurationChangedHandler(uint8_t cfgnum);
185extern void HIDAUDDDriver_InterfaceSettingChangedHandler(
186 uint8_t interface, uint8_t setting);
187extern void HIDAUDDDriver_RequestHandler(const USBGenericRequest *request);
188
189/**@}*/
190#endif //#ifndef CDCHIDDDRIVER_H
191