2
2
******************************************************************************
3
3
* @file usbd_audio.h
4
4
* @author MCD Application Team
5
- * @version V2.4.2
6
- * @date 11-December-2015
7
5
* @brief header file for the usbd_audio.c file.
8
6
******************************************************************************
9
7
* @attention
10
8
*
11
- * <h2><center>© COPYRIGHT 2015 STMicroelectronics</center></h2>
9
+ * <h2><center>© Copyright (c) 2015 STMicroelectronics.
10
+ * All rights reserved.</center></h2>
12
11
*
13
- * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14
- * You may not use this file except in compliance with the License.
15
- * You may obtain a copy of the License at:
16
- *
17
- * http://www.st.com/software_license_agreement_liberty_v2
18
- *
19
- * Unless required by applicable law or agreed to in writing, software
20
- * distributed under the License is distributed on an "AS IS" BASIS,
21
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
- * See the License for the specific language governing permissions and
23
- * limitations under the License.
12
+ * This software component is licensed by ST under Ultimate Liberty license
13
+ * SLA0044, the "License"; You may not use this file except in compliance with
14
+ * the License. You may obtain a copy of the License at:
15
+ * http://www.st.com/SLA0044
24
16
*
25
17
******************************************************************************
26
18
*/
27
-
19
+
28
20
/* Define to prevent recursive inclusion -------------------------------------*/
29
21
#ifndef __USB_AUDIO_H
30
22
#define __USB_AUDIO_H
39
31
/** @addtogroup STM32_USB_DEVICE_LIBRARY
40
32
* @{
41
33
*/
42
-
34
+
43
35
/** @defgroup USBD_AUDIO
44
36
* @brief This file is the Header file for usbd_audio.c
45
37
* @{
46
- */
38
+ */
47
39
48
40
49
41
/** @defgroup USBD_AUDIO_Exported_Defines
50
42
* @{
51
- */
52
- #define AUDIO_OUT_EP 0x01
53
- #define USB_AUDIO_CONFIG_DESC_SIZ 109
54
- #define AUDIO_INTERFACE_DESC_SIZE 9
55
- #define USB_AUDIO_DESC_SIZ 0x09
56
- #define AUDIO_STANDARD_ENDPOINT_DESC_SIZE 0x09
57
- #define AUDIO_STREAMING_ENDPOINT_DESC_SIZE 0x07
58
-
59
- #define AUDIO_DESCRIPTOR_TYPE 0x21
60
- #define USB_DEVICE_CLASS_AUDIO 0x01
61
- #define AUDIO_SUBCLASS_AUDIOCONTROL 0x01
62
- #define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02
63
- #define AUDIO_PROTOCOL_UNDEFINED 0x00
64
- #define AUDIO_STREAMING_GENERAL 0x01
65
- #define AUDIO_STREAMING_FORMAT_TYPE 0x02
43
+ */
44
+ #ifndef USBD_AUDIO_FREQ
45
+ /* AUDIO Class Config */
46
+ #define USBD_AUDIO_FREQ 48000U
47
+ #endif /* USBD_AUDIO_FREQ */
48
+
49
+ #ifndef USBD_MAX_NUM_INTERFACES
50
+ #define USBD_MAX_NUM_INTERFACES 1U
51
+ #endif /* USBD_AUDIO_FREQ */
52
+
53
+ #define AUDIO_OUT_EP 0x01U
54
+ #define USB_AUDIO_CONFIG_DESC_SIZ 0x6DU
55
+ #define AUDIO_INTERFACE_DESC_SIZE 0x09U
56
+ #define USB_AUDIO_DESC_SIZ 0x09U
57
+ #define AUDIO_STANDARD_ENDPOINT_DESC_SIZE 0x09U
58
+ #define AUDIO_STREAMING_ENDPOINT_DESC_SIZE 0x07U
59
+
60
+ #define AUDIO_DESCRIPTOR_TYPE 0x21U
61
+ #define USB_DEVICE_CLASS_AUDIO 0x01U
62
+ #define AUDIO_SUBCLASS_AUDIOCONTROL 0x01U
63
+ #define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02U
64
+ #define AUDIO_PROTOCOL_UNDEFINED 0x00U
65
+ #define AUDIO_STREAMING_GENERAL 0x01U
66
+ #define AUDIO_STREAMING_FORMAT_TYPE 0x02U
66
67
67
68
/* Audio Descriptor Types */
68
- #define AUDIO_INTERFACE_DESCRIPTOR_TYPE 0x24
69
- #define AUDIO_ENDPOINT_DESCRIPTOR_TYPE 0x25
69
+ #define AUDIO_INTERFACE_DESCRIPTOR_TYPE 0x24U
70
+ #define AUDIO_ENDPOINT_DESCRIPTOR_TYPE 0x25U
70
71
71
72
/* Audio Control Interface Descriptor Subtypes */
72
- #define AUDIO_CONTROL_HEADER 0x01
73
- #define AUDIO_CONTROL_INPUT_TERMINAL 0x02
74
- #define AUDIO_CONTROL_OUTPUT_TERMINAL 0x03
75
- #define AUDIO_CONTROL_FEATURE_UNIT 0x06
73
+ #define AUDIO_CONTROL_HEADER 0x01U
74
+ #define AUDIO_CONTROL_INPUT_TERMINAL 0x02U
75
+ #define AUDIO_CONTROL_OUTPUT_TERMINAL 0x03U
76
+ #define AUDIO_CONTROL_FEATURE_UNIT 0x06U
77
+
78
+ #define AUDIO_INPUT_TERMINAL_DESC_SIZE 0x0CU
79
+ #define AUDIO_OUTPUT_TERMINAL_DESC_SIZE 0x09U
80
+ #define AUDIO_STREAMING_INTERFACE_DESC_SIZE 0x07U
76
81
77
- #define AUDIO_INPUT_TERMINAL_DESC_SIZE 0x0C
78
- #define AUDIO_OUTPUT_TERMINAL_DESC_SIZE 0x09
79
- #define AUDIO_STREAMING_INTERFACE_DESC_SIZE 0x07
82
+ #define AUDIO_CONTROL_MUTE 0x0001U
80
83
81
- #define AUDIO_CONTROL_MUTE 0x0001
84
+ #define AUDIO_FORMAT_TYPE_I 0x01U
85
+ #define AUDIO_FORMAT_TYPE_III 0x03U
82
86
83
- #define AUDIO_FORMAT_TYPE_I 0x01
84
- #define AUDIO_FORMAT_TYPE_III 0x03
87
+ #define AUDIO_ENDPOINT_GENERAL 0x01U
85
88
86
- #define AUDIO_ENDPOINT_GENERAL 0x01
89
+ #define AUDIO_REQ_GET_CUR 0x81U
90
+ #define AUDIO_REQ_SET_CUR 0x01U
87
91
88
- #define AUDIO_REQ_GET_CUR 0x81
89
- #define AUDIO_REQ_SET_CUR 0x01
92
+ #define AUDIO_OUT_STREAMING_CTRL 0x02U
90
93
91
- #define AUDIO_OUT_STREAMING_CTRL 0x02
92
94
95
+ #define AUDIO_OUT_PACKET (uint16_t)(((USBD_AUDIO_FREQ * 2U * 2U) / 1000U))
96
+ #define AUDIO_DEFAULT_VOLUME 70U
93
97
94
- #define AUDIO_OUT_PACKET (uint32_t)(((USBD_AUDIO_FREQ * 2 * 2) /1000))
95
- #define AUDIO_DEFAULT_VOLUME 70
96
-
97
98
/* Number of sub-packets in the audio transfer buffer. You can modify this value but always make sure
98
99
that it is an even number and higher than 3 */
99
- #define AUDIO_OUT_PACKET_NUM 80
100
+ #define AUDIO_OUT_PACKET_NUM 80U
100
101
/* Total size of the audio transfer buffer */
101
- #define AUDIO_TOTAL_BUF_SIZE ((uint32_t )(AUDIO_OUT_PACKET * AUDIO_OUT_PACKET_NUM))
102
-
102
+ #define AUDIO_TOTAL_BUF_SIZE ((uint16_t )(AUDIO_OUT_PACKET * AUDIO_OUT_PACKET_NUM))
103
+
103
104
/* Audio Commands enumeration */
104
105
typedef enum
105
106
{
@@ -113,40 +114,40 @@ typedef enum
113
114
{
114
115
AUDIO_OFFSET_NONE = 0 ,
115
116
AUDIO_OFFSET_HALF ,
116
- AUDIO_OFFSET_FULL ,
117
- AUDIO_OFFSET_UNKNOWN ,
117
+ AUDIO_OFFSET_FULL ,
118
+ AUDIO_OFFSET_UNKNOWN ,
118
119
}
119
120
AUDIO_OffsetTypeDef ;
120
121
/**
121
122
* @}
122
- */
123
+ */
123
124
124
125
125
126
/** @defgroup USBD_CORE_Exported_TypesDefinitions
126
127
* @{
127
128
*/
128
129
typedef struct
129
130
{
130
- uint8_t cmd ;
131
- uint8_t data [USB_MAX_EP0_SIZE ];
132
- uint8_t len ;
133
- uint8_t unit ;
131
+ uint8_t cmd ;
132
+ uint8_t data [USB_MAX_EP0_SIZE ];
133
+ uint8_t len ;
134
+ uint8_t unit ;
134
135
}
135
- USBD_AUDIO_ControlTypeDef ;
136
+ USBD_AUDIO_ControlTypeDef ;
136
137
137
138
138
139
139
140
typedef struct
140
141
{
141
- __IO uint32_t alt_setting ;
142
+ uint32_t alt_setting ;
142
143
uint8_t buffer [AUDIO_TOTAL_BUF_SIZE ];
143
144
AUDIO_OffsetTypeDef offset ;
144
- uint8_t rd_enable ;
145
- uint16_t rd_ptr ;
146
- uint16_t wr_ptr ;
147
- USBD_AUDIO_ControlTypeDef control ;
145
+ uint8_t rd_enable ;
146
+ uint16_t rd_ptr ;
147
+ uint16_t wr_ptr ;
148
+ USBD_AUDIO_ControlTypeDef control ;
148
149
}
149
- USBD_AUDIO_HandleTypeDef ;
150
+ USBD_AUDIO_HandleTypeDef ;
150
151
151
152
152
153
typedef struct
@@ -161,38 +162,38 @@ typedef struct
161
162
}USBD_AUDIO_ItfTypeDef ;
162
163
/**
163
164
* @}
164
- */
165
+ */
165
166
166
167
167
168
168
169
/** @defgroup USBD_CORE_Exported_Macros
169
170
* @{
170
- */
171
+ */
171
172
172
173
/**
173
174
* @}
174
- */
175
+ */
175
176
176
177
/** @defgroup USBD_CORE_Exported_Variables
177
178
* @{
178
- */
179
+ */
179
180
180
181
extern USBD_ClassTypeDef USBD_AUDIO ;
181
182
#define USBD_AUDIO_CLASS &USBD_AUDIO
182
183
/**
183
184
* @}
184
- */
185
+ */
185
186
186
187
/** @defgroup USB_CORE_Exported_Functions
187
188
* @{
188
- */
189
- uint8_t USBD_AUDIO_RegisterInterface (USBD_HandleTypeDef * pdev ,
189
+ */
190
+ uint8_t USBD_AUDIO_RegisterInterface (USBD_HandleTypeDef * pdev ,
190
191
USBD_AUDIO_ItfTypeDef * fops );
191
192
192
193
void USBD_AUDIO_Sync (USBD_HandleTypeDef * pdev , AUDIO_OffsetTypeDef offset );
193
194
/**
194
195
* @}
195
- */
196
+ */
196
197
197
198
#ifdef __cplusplus
198
199
}
@@ -201,10 +202,10 @@ void USBD_AUDIO_Sync (USBD_HandleTypeDef *pdev, AUDIO_OffsetTypeDef offset);
201
202
#endif /* __USB_AUDIO_H */
202
203
/**
203
204
* @}
204
- */
205
+ */
205
206
206
207
/**
207
208
* @}
208
- */
209
-
209
+ */
210
+
210
211
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
0 commit comments