ARMEBS4  revision-26.06.2015
usbd_audio_core.h
1 #include "heivs/config.h"
2 #if (USE_STM32_USB_HOST_MODE || USE_STM32_USB_USE_DEVICE_MODE || USE_STM32_USB_OTG_MODE)
3 /**
4  ******************************************************************************
5  * @file usbd_audio_core.h
6  * @author MCD Application Team
7  * @version V1.1.0
8  * @date 19-March-2012
9  * @brief header file for the usbd_audio_core.c file.
10  ******************************************************************************
11  * @attention
12  *
13  * <h2><center>&copy; COPYRIGHT 2012 STMicroelectronics</center></h2>
14  *
15  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
16  * You may not use this file except in compliance with the License.
17  * You may obtain a copy of the License at:
18  *
19  * http://www.st.com/software_license_agreement_liberty_v2
20  *
21  * Unless required by applicable law or agreed to in writing, software
22  * distributed under the License is distributed on an "AS IS" BASIS,
23  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24  * See the License for the specific language governing permissions and
25  * limitations under the License.
26  *
27  ******************************************************************************
28  */
29 
30 /* Includes ------------------------------------------------------------------*/
31 
32 #ifndef __USB_AUDIO_CORE_H_
33 #define __USB_AUDIO_CORE_H_
34 
35 #include "stm32/usbd_ioreq.h"
36 #include "stm32/usbd_req.h"
37 #include "stm32/usbd_desc.h"
38 
39 
40 
41 
42 /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
43  * @{
44  */
45 
46 /** @defgroup usbd_audio
47  * @brief This file is the Header file for USBD_audio.c
48  * @{
49  */
50 
51 
52 /** @defgroup usbd_audio_Exported_Defines
53  * @{
54  */
55 
56 /* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */
57 #define AUDIO_OUT_PACKET (uint32_t)(((USBD_AUDIO_FREQ * 2 * 2) /1000))
58 
59 /* Number of sub-packets in the audio transfer buffer. You can modify this value but always make sure
60  that it is an even number and higher than 3 */
61 #define OUT_PACKET_NUM 4
62 /* Total size of the audio transfer buffer */
63 #define TOTAL_OUT_BUF_SIZE ((uint32_t)(AUDIO_OUT_PACKET * OUT_PACKET_NUM))
64 
65 #define AUDIO_CONFIG_DESC_SIZE 109
66 #define AUDIO_INTERFACE_DESC_SIZE 9
67 #define USB_AUDIO_DESC_SIZ 0x09
68 #define AUDIO_STANDARD_ENDPOINT_DESC_SIZE 0x09
69 #define AUDIO_STREAMING_ENDPOINT_DESC_SIZE 0x07
70 
71 #define AUDIO_DESCRIPTOR_TYPE 0x21
72 #define USB_DEVICE_CLASS_AUDIO 0x01
73 #define AUDIO_SUBCLASS_AUDIOCONTROL 0x01
74 #define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02
75 #define AUDIO_PROTOCOL_UNDEFINED 0x00
76 #define AUDIO_STREAMING_GENERAL 0x01
77 #define AUDIO_STREAMING_FORMAT_TYPE 0x02
78 
79 /* Audio Descriptor Types */
80 #define AUDIO_INTERFACE_DESCRIPTOR_TYPE 0x24
81 #define AUDIO_ENDPOINT_DESCRIPTOR_TYPE 0x25
82 
83 /* Audio Control Interface Descriptor Subtypes */
84 #define AUDIO_CONTROL_HEADER 0x01
85 #define AUDIO_CONTROL_INPUT_TERMINAL 0x02
86 #define AUDIO_CONTROL_OUTPUT_TERMINAL 0x03
87 #define AUDIO_CONTROL_FEATURE_UNIT 0x06
88 
89 #define AUDIO_INPUT_TERMINAL_DESC_SIZE 0x0C
90 #define AUDIO_OUTPUT_TERMINAL_DESC_SIZE 0x09
91 #define AUDIO_STREAMING_INTERFACE_DESC_SIZE 0x07
92 
93 #define AUDIO_CONTROL_MUTE 0x0001
94 
95 #define AUDIO_FORMAT_TYPE_I 0x01
96 #define AUDIO_FORMAT_TYPE_III 0x03
97 
98 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
99 #define AUDIO_ENDPOINT_GENERAL 0x01
100 
101 #define AUDIO_REQ_GET_CUR 0x81
102 #define AUDIO_REQ_SET_CUR 0x01
103 
104 #define AUDIO_OUT_STREAMING_CTRL 0x02
105 
106 /**
107  * @}
108  */
109 
110 
111 /** @defgroup USBD_CORE_Exported_TypesDefinitions
112  * @{
113  */
114 typedef struct _Audio_Fops
115 {
116  uint8_t (*Init) (uint32_t AudioFreq, uint32_t Volume, uint32_t options);
117  uint8_t (*DeInit) (uint32_t options);
118  uint8_t (*AudioCmd) (uint8_t* pbuf, uint32_t size, uint8_t cmd);
119  uint8_t (*VolumeCtl) (uint8_t vol);
120  uint8_t (*MuteCtl) (uint8_t cmd);
121  uint8_t (*PeriodicTC) (uint8_t cmd);
122  uint8_t (*GetState) (void);
123 }AUDIO_FOPS_TypeDef;
124 /**
125  * @}
126  */
127 
128 
129 
130 /** @defgroup USBD_CORE_Exported_Macros
131  * @{
132  */
133 #define AUDIO_PACKET_SZE(frq) (uint8_t)(((frq * 2 * 2)/1000) & 0xFF), \
134  (uint8_t)((((frq * 2 * 2)/1000) >> 8) & 0xFF)
135 #define SAMPLE_FREQ(frq) (uint8_t)(frq), (uint8_t)((frq >> 8)), (uint8_t)((frq >> 16))
136 /**
137  * @}
138  */
139 
140 /** @defgroup USBD_CORE_Exported_Variables
141  * @{
142  */
143 
144 extern USBD_Class_cb_TypeDef AUDIO_cb;
145 
146 /**
147  * @}
148  */
149 
150 /** @defgroup USB_CORE_Exported_Functions
151  * @{
152  */
153 /**
154  * @}
155  */
156 
157 #endif // __USB_AUDIO_CORE_H_
158 /**
159  * @}
160  */
161 
162 /**
163  * @}
164  */
165 
166 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
167 #endif /* (USE_STM32_USB_HOST_MODE || USE_STM32_USB_USE_DEVICE_MODE || USE_STM32_USB_OTG_MODE) */
libheivs configuration file