audio_desc.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /**
  2. **************************************************************************
  3. * @file audio_desc.h
  4. * @version v2.0.6
  5. * @date 2021-12-31
  6. * @brief usb audio descriptor header file
  7. **************************************************************************
  8. * Copyright notice & Disclaimer
  9. *
  10. * The software Board Support Package (BSP) that is made available to
  11. * download from Artery official website is the copyrighted work of Artery.
  12. * Artery authorizes customers to use, copy, and distribute the BSP
  13. * software and its related documentation for the purpose of design and
  14. * development in conjunction with Artery microcontrollers. Use of the
  15. * software is governed by this copyright notice and the following disclaimer.
  16. *
  17. * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
  18. * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
  19. * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
  20. * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
  21. * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
  23. *
  24. **************************************************************************
  25. */
  26. /* define to prevent recursive inclusion -------------------------------------*/
  27. #ifndef __AUDIO_DESC_H
  28. #define __AUDIO_DESC_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #include "audio_class.h"
  33. #include "usbd_core.h"
  34. #include "audio_conf.h"
  35. /** @addtogroup AT32F403A_407_middlewares_usbd_class
  36. * @{
  37. */
  38. /** @addtogroup USB_audio_desc
  39. * @{
  40. */
  41. /** @defgroup USB_audio_desc_definition
  42. * @{
  43. */
  44. #define BCD_NUM 0x0100
  45. #define USBD_VENDOR_ID 0x2E3C
  46. #define USBD_PRODUCT_ID 0x5730
  47. #define USBD_SIZ_STRING_LANGID 4
  48. #define USBD_SIZ_STRING_SERIAL 0x1A
  49. #define USBD_DESC_MANUFACTURER_STRING "Artery"
  50. #define USBD_DESC_PRODUCT_STRING "AT32 Audio"
  51. #define USBD_DESC_CONFIGURATION_STRING "Audio Config"
  52. #define USBD_DESC_INTERFACE_STRING "Audio Interface"
  53. /**
  54. * @brief audio interface subclass codes
  55. */
  56. #define AUDIO_SUBCLASS_UNDEFINED 0x00
  57. #define AUDIO_SUBCLASS_AUDIOCONTROL 0x01
  58. #define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02
  59. #define AUDIO_SUBCLASS_MIDISTREMING 0x03
  60. /**
  61. * @brief audio class-specific descriptor types
  62. */
  63. #define AUDIO_CS_INTERFACE 0x24
  64. #define AUDIO_CS_ENDPOINT 0x25
  65. #define AUDIO_CS_STRING 0x23
  66. #define AUDIO_CS_CONFIGURATION 0x22
  67. #define AUDIO_CS_DEVICE 0x21
  68. #define AUDIO_CS_UNDEFINED 0x20
  69. /**
  70. * @brief audio interface protocol codes
  71. */
  72. #define AUDIO_PROTOCOL_UNDEFINED 0x00
  73. /**
  74. * @brief audio class-specific ac interface descriptor subtypes
  75. */
  76. #define AUDIO_AC_DESCRIPTOR_UNDEFINED 0x00
  77. #define AUDIO_AC_HEADER 0x01
  78. #define AUDIO_AC_INPUT_TERMINAL 0x02
  79. #define AUDIO_AC_OUTPUT_TERMINAL 0x03
  80. #define AUDIO_AC_MIXER_UNIT 0x04
  81. #define AUDIO_AC_SELECTOR_UNIT 0x05
  82. #define AUDIO_AC_FEATURE_UNIT 0x06
  83. #define AUDIO_AC_PROCESSING_UNIT 0x07
  84. #define AUDIO_AC_EXTENSION_UNIT 0x08
  85. /**
  86. * @brief audio class-specific as interface descriptor subtypes
  87. */
  88. #define AUDIO_AS_DESCRIPTOR_UNDEFINED 0x00
  89. #define AUDIO_AS_GENERAL 0x01
  90. #define AUDIO_AS_FORMAT_TYPE 0x02
  91. #define AUDIO_AS_FORMAT_SPECIFIC 0x03
  92. /**
  93. * @brief audio class-specific request codes
  94. */
  95. #define AUDIO_REQUEST_CODE_UNDEFINED 0x00
  96. #define AUDIO_REQ_SET_CUR 0x01
  97. #define AUDIO_REQ_GET_CUR 0x81
  98. #define AUDIO_REQ_SET_MIN 0x02
  99. #define AUDIO_REQ_GET_MIN 0x82
  100. #define AUDIO_REQ_SET_MAX 0x03
  101. #define AUDIO_REQ_GET_MAX 0x83
  102. #define AUDIO_REQ_SET_RES 0x04
  103. #define AUDIO_REQ_GET_RES 0x84
  104. #define AUDIO_REQ_SET_MEM 0x05
  105. #define AUDIO_REQ_GET_MEM 0x85
  106. #define AUDIO_REQ_GET_STAT 0xFF
  107. /**
  108. * @brief audio feature unit control selectors
  109. */
  110. #define AUDIO_FU_CONTROL_UNDEFINED 0x00
  111. #define AUDIO_FU_MUTE_CONTROL 0x01
  112. #define AUDIO_FU_VOLUME_CONTROL 0x02
  113. #define AUDIO_FU_BASS_CONTROL 0x03
  114. #define AUDIO_FU_MID_CONTROL 0x04
  115. #define AUDIO_FU_TREBLE_CONTROL 0x05
  116. /**
  117. * @brief audio terminal type
  118. */
  119. #define AUDIO_TERMINAL_TYPE_UNDEFINED 0x0100
  120. #define AUDIO_TERMINAL_TYPE_STREAMING 0x0101
  121. #define AUDIO_TERMINAL_TYPE_VENDOR 0x01FF
  122. #define AUDIO_INPUT_TERMINAL_UNDEFINED 0x0200
  123. #define AUDIO_INPUT_TERMINAL_MICROPHONE 0x0201
  124. #define AUDIO_OUTPUT_TERMINAL_UNDEFINED 0x0300
  125. #define AUDIO_OUTPUT_TERMINAL_SPEAKER 0x0301
  126. /**
  127. * @brief audio format type 1
  128. */
  129. #define AUDIO_FORMAT_TYPE_I 0x01
  130. /**
  131. * @brief audio interface config
  132. */
  133. #define AUDIO_INTERFACE_NUM (AUDIO_SUPPORT_SPK + AUDIO_SUPPORT_MIC)
  134. #define AUDIO_INTERFACE_LEN ((0x08 + AUDIO_INTERFACE_NUM) + AUDIO_INTERFACE_NUM * 0x1E)
  135. #define AUDIO_MIC_INTERFACE 0x01
  136. #define AUDIO_SPK_INTERFACE 0x02
  137. /**
  138. * @brief audio interface descriptor size define
  139. */
  140. #define AUDIO_INPUT_TERMINAL_SIZE 0x0C
  141. #define AUDIO_OUTPUT_TERMINAL_SIZE 0x09
  142. #define AUDIO_FEATURE_UNIT_SIZE 0x09
  143. /**
  144. * @brief audio terminal id define
  145. */
  146. #define AUDIO_MIC_INPUT_TERMINAL_ID 0x01
  147. #define AUDIO_MIC_FEATURE_UNIT_ID 0x02
  148. #define AUDIO_MIC_OUTPUT_TERMINAL_ID 0x03
  149. #define AUDIO_SPK_INPUT_TERMINAL_ID 0x04
  150. #define AUDIO_SPK_FEATURE_UNIT_ID 0x05
  151. #define AUDIO_SPK_OUTPUT_TERMINAL_ID 0x06
  152. /**
  153. * @brief audio interface number
  154. */
  155. #define AUDIO_MIC_INTERFACE_NUMBER 0x01
  156. #if (AUDIO_SUPPORT_MIC == 1)
  157. #define AUDIO_SPK_INTERFACE_NUMBER 0x02
  158. #else
  159. #define AUDIO_SPK_INTERFACE_NUMBER 0x01
  160. #endif
  161. /**
  162. * @brief audio support freq
  163. */
  164. #define AT32_AUDIO_FREQ_16K 16000
  165. #define AT32_AUDIO_FREQ_48K 48000
  166. /**
  167. * @brief audio microphone freq and channel config
  168. */
  169. #define AUDIO_MIC_FREQ_SIZE (AUDIO_SUPPORT_FREQ)
  170. #define AUDIO_MIC_CHR AUDIO_MIC_CHANEL_NUM
  171. #define AUDIO_MIC_BITW (AUDIO_MIC_DEFAULT_BITW)
  172. /**
  173. * @brief audio speaker freq and channel config
  174. */
  175. #define AUDIO_SPK_FREQ_SIZE (AUDIO_SUPPORT_FREQ)
  176. #define AUDIO_SPK_CHR AUDIO_SPK_CHANEL_NUM
  177. #define AUDIO_SPK_BITW (AUDIO_SPK_DEFAULT_BITW)
  178. #define HID_BINTERVAL_TIME 0x01
  179. #define USBD_CONFIG_DESC_SIZE ( 0x12 + AUDIO_INTERFACE_LEN + \
  180. + (0x31 + AUDIO_SPK_FREQ_SIZE * 3) \
  181. + (0x31 + AUDIO_MIC_FREQ_SIZE * 3) \
  182. + (9 * AUDIO_SUPPORT_FEEDBACK) \
  183. )
  184. #define SAMPLE_FREQ(frq) (uint8_t)(frq), (uint8_t)((frq >> 8)), (uint8_t)((frq >> 16))
  185. #define MCU_ID1 (0x1FFFF7E8)
  186. #define MCU_ID2 (0x1FFFF7EC)
  187. #define MCU_ID3 (0x1FFFF7F0)
  188. extern uint8_t g_usbd_descriptor[USB_DEVICE_DESC_LEN];
  189. extern uint8_t g_usbd_configuration[USBD_CONFIG_DESC_SIZE];
  190. extern usbd_desc_handler audio_desc_handler;
  191. /**
  192. * @}
  193. */
  194. /**
  195. * @}
  196. */
  197. /**
  198. * @}
  199. */
  200. #ifdef __cplusplus
  201. }
  202. #endif
  203. #endif