Merge pull request #93 from zyp/master
[fw/stlink] / example / stm32f4 / STM32_USB_Device_Library / Class / audio / inc / usbd_audio_core.h
1 /**
2   ******************************************************************************
3   * @file    usbd_audio_core.h
4   * @author  MCD Application Team
5   * @version V1.0.0
6   * @date    22-July-2011
7   * @brief   header file for the usbd_audio_core.c file.
8   ******************************************************************************
9   * @attention
10   *
11   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17   *
18   * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
19   ******************************************************************************
20   */ 
21
22 /* Includes ------------------------------------------------------------------*/
23
24 #ifndef __USB_AUDIO_CORE_H_
25 #define __USB_AUDIO_CORE_H_
26
27 #include "usbd_ioreq.h"
28 #include "usbd_req.h"
29 #include "usbd_desc.h"
30
31
32
33
34 /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
35   * @{
36   */
37   
38 /** @defgroup usbd_audio
39   * @brief This file is the Header file for USBD_audio.c
40   * @{
41   */ 
42
43
44 /** @defgroup usbd_audio_Exported_Defines
45   * @{
46   */ 
47
48 /* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */
49 #define AUDIO_OUT_PACKET                              (uint32_t)(((USBD_AUDIO_FREQ * 2 * 2) /1000)) 
50
51 /* Number of sub-packets in the audio transfer buffer. You can modify this value but always make sure
52   that it is an even number and higher than 3 */
53 #define OUT_PACKET_NUM                                   4
54 /* Total size of the audio transfer buffer */
55 #define TOTAL_OUT_BUF_SIZE                           ((uint32_t)(AUDIO_OUT_PACKET * OUT_PACKET_NUM))
56
57 #define AUDIO_CONFIG_DESC_SIZE                        109
58 #define AUDIO_INTERFACE_DESC_SIZE                     9
59 #define USB_AUDIO_DESC_SIZ                            0x09
60 #define AUDIO_STANDARD_ENDPOINT_DESC_SIZE             0x09
61 #define AUDIO_STREAMING_ENDPOINT_DESC_SIZE            0x07
62
63 #define AUDIO_DESCRIPTOR_TYPE                         0x21
64 #define USB_DEVICE_CLASS_AUDIO                        0x01
65 #define AUDIO_SUBCLASS_AUDIOCONTROL                   0x01
66 #define AUDIO_SUBCLASS_AUDIOSTREAMING                 0x02
67 #define AUDIO_PROTOCOL_UNDEFINED                      0x00
68 #define AUDIO_STREAMING_GENERAL                       0x01
69 #define AUDIO_STREAMING_FORMAT_TYPE                   0x02
70
71 /* Audio Descriptor Types */
72 #define AUDIO_INTERFACE_DESCRIPTOR_TYPE               0x24
73 #define AUDIO_ENDPOINT_DESCRIPTOR_TYPE                0x25
74
75 /* Audio Control Interface Descriptor Subtypes */
76 #define AUDIO_CONTROL_HEADER                          0x01
77 #define AUDIO_CONTROL_INPUT_TERMINAL                  0x02
78 #define AUDIO_CONTROL_OUTPUT_TERMINAL                 0x03
79 #define AUDIO_CONTROL_FEATURE_UNIT                    0x06
80
81 #define AUDIO_INPUT_TERMINAL_DESC_SIZE                0x0C
82 #define AUDIO_OUTPUT_TERMINAL_DESC_SIZE               0x09
83 #define AUDIO_STREAMING_INTERFACE_DESC_SIZE           0x07
84
85 #define AUDIO_CONTROL_MUTE                            0x0001
86
87 #define AUDIO_FORMAT_TYPE_I                           0x01
88 #define AUDIO_FORMAT_TYPE_III                         0x03
89
90 #define USB_ENDPOINT_TYPE_ISOCHRONOUS                 0x01
91 #define AUDIO_ENDPOINT_GENERAL                        0x01
92
93 #define AUDIO_REQ_GET_CUR                             0x81
94 #define AUDIO_REQ_SET_CUR                             0x01
95
96 #define AUDIO_OUT_STREAMING_CTRL                      0x02
97
98 /**
99   * @}
100   */ 
101
102
103 /** @defgroup USBD_CORE_Exported_TypesDefinitions
104   * @{
105   */
106 typedef struct _Audio_Fops
107 {
108     uint8_t  (*Init)         (uint32_t  AudioFreq, uint32_t Volume, uint32_t options);
109     uint8_t  (*DeInit)       (uint32_t options);
110     uint8_t  (*AudioCmd)     (uint8_t* pbuf, uint32_t size, uint8_t cmd);
111     uint8_t  (*VolumeCtl)    (uint8_t vol);
112     uint8_t  (*MuteCtl)      (uint8_t cmd);
113     uint8_t  (*PeriodicTC)   (uint8_t cmd);
114     uint8_t  (*GetState)     (void);
115 }AUDIO_FOPS_TypeDef;
116 /**
117   * @}
118   */ 
119
120
121
122 /** @defgroup USBD_CORE_Exported_Macros
123   * @{
124   */ 
125 #define AUDIO_PACKET_SZE(frq)          (uint8_t)(((frq * 2 * 2)/1000) & 0xFF), \
126                                        (uint8_t)((((frq * 2 * 2)/1000) >> 8) & 0xFF)
127 #define SAMPLE_FREQ(frq)               (uint8_t)(frq), (uint8_t)((frq >> 8)), (uint8_t)((frq >> 16))
128 /**
129   * @}
130   */ 
131
132 /** @defgroup USBD_CORE_Exported_Variables
133   * @{
134   */ 
135
136 extern USBD_Class_cb_TypeDef  AUDIO_cb;
137
138 /**
139   * @}
140   */ 
141
142 /** @defgroup USB_CORE_Exported_Functions
143   * @{
144   */
145 /**
146   * @}
147   */ 
148
149 #endif  // __USB_AUDIO_CORE_H_
150 /**
151   * @}
152   */ 
153
154 /**
155   * @}
156   */ 
157   
158 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/