2 ******************************************************************************
3 * @file usbd_audio_core.h
4 * @author MCD Application Team
7 * @brief header file for the usbd_audio_core.c file.
8 ******************************************************************************
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.
18 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
19 ******************************************************************************
22 /* Includes ------------------------------------------------------------------*/
24 #ifndef __USB_AUDIO_CORE_H_
25 #define __USB_AUDIO_CORE_H_
27 #include "usbd_ioreq.h"
29 #include "usbd_desc.h"
34 /** @addtogroup STM32_USB_OTG_DEVICE_LIBRARY
38 /** @defgroup usbd_audio
39 * @brief This file is the Header file for USBD_audio.c
44 /** @defgroup usbd_audio_Exported_Defines
48 /* AudioFreq * DataSize (2 bytes) * NumChannels (Stereo: 2) */
49 #define AUDIO_OUT_PACKET (uint32_t)(((USBD_AUDIO_FREQ * 2 * 2) /1000))
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))
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
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
71 /* Audio Descriptor Types */
72 #define AUDIO_INTERFACE_DESCRIPTOR_TYPE 0x24
73 #define AUDIO_ENDPOINT_DESCRIPTOR_TYPE 0x25
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
81 #define AUDIO_INPUT_TERMINAL_DESC_SIZE 0x0C
82 #define AUDIO_OUTPUT_TERMINAL_DESC_SIZE 0x09
83 #define AUDIO_STREAMING_INTERFACE_DESC_SIZE 0x07
85 #define AUDIO_CONTROL_MUTE 0x0001
87 #define AUDIO_FORMAT_TYPE_I 0x01
88 #define AUDIO_FORMAT_TYPE_III 0x03
90 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
91 #define AUDIO_ENDPOINT_GENERAL 0x01
93 #define AUDIO_REQ_GET_CUR 0x81
94 #define AUDIO_REQ_SET_CUR 0x01
96 #define AUDIO_OUT_STREAMING_CTRL 0x02
103 /** @defgroup USBD_CORE_Exported_TypesDefinitions
106 typedef struct _Audio_Fops
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);
122 /** @defgroup USBD_CORE_Exported_Macros
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))
132 /** @defgroup USBD_CORE_Exported_Variables
136 extern USBD_Class_cb_TypeDef AUDIO_cb;
142 /** @defgroup USB_CORE_Exported_Functions
149 #endif // __USB_AUDIO_CORE_H_
158 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/