mirror of
https://github.com/ArteryTek/AT32F415_Firmware_Library.git
synced 2026-05-21 01:12:20 +00:00
update version to v2.0.4
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
/**
|
||||
**************************************************************************
|
||||
* @file audio_desc.c
|
||||
* @version v2.0.3
|
||||
* @date 2022-02-11
|
||||
* @version v2.0.4
|
||||
* @date 2022-04-02
|
||||
* @brief usb audio device descriptor
|
||||
**************************************************************************
|
||||
* Copyright notice & Disclaimer
|
||||
*
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* The software Board Support Package (BSP) that is made available to
|
||||
* download from Artery official website is the copyrighted work of Artery.
|
||||
* Artery authorizes customers to use, copy, and distribute the BSP
|
||||
* software and its related documentation for the purpose of design and
|
||||
* development in conjunction with Artery microcontrollers. Use of the
|
||||
* software is governed by this copyright notice and the following disclaimer.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
|
||||
@@ -31,11 +31,11 @@
|
||||
/** @addtogroup AT32F415_middlewares_usbd_class
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @defgroup USB_audio_desc
|
||||
* @brief usb device audio descriptor
|
||||
* @{
|
||||
*/
|
||||
*/
|
||||
|
||||
/** @defgroup USB_audio_desc_private_functions
|
||||
* @{
|
||||
@@ -119,7 +119,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
the configuration */
|
||||
0xC0, /* bmAttributes: self powered */
|
||||
0x32, /* MaxPower 100 mA: this current is used for detecting vbus */
|
||||
|
||||
|
||||
USB_DEVICE_IF_DESC_LEN, /* bLength: interface descriptor size */
|
||||
USB_DESCIPTOR_TYPE_INTERFACE, /* bDescriptorType: interface descriptor type */
|
||||
0x00, /* bInterfaceNumber: number of interface */
|
||||
@@ -129,7 +129,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
AUDIO_SUBCLASS_AUDIOCONTROL, /* bInterfaceSubClass: audio control */
|
||||
AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol: undefined */
|
||||
0x00, /* iInterface: index of string descriptor */
|
||||
|
||||
|
||||
0x08+AUDIO_INTERFACE_NUM, /* bLength: size of this descriptor, in bytes 8+n */
|
||||
AUDIO_CS_INTERFACE, /* bDescriptorType: cs interface descriptor type */
|
||||
AUDIO_AC_HEADER, /* bDescriptorSubtype: Header function Descriptor*/
|
||||
@@ -164,7 +164,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
0x00, /* wChannelConfig */
|
||||
0x00, /* iChannelNames: unused */
|
||||
0x00, /* iTerminal: unused */
|
||||
|
||||
|
||||
AUDIO_FEATURE_UNIT_SIZE, /* bLength: descriptor size */
|
||||
AUDIO_CS_INTERFACE, /* bDescriptorType: configuration */
|
||||
AUDIO_AC_FEATURE_UNIT, /* bDescriptorSubtype: feature unit type*/
|
||||
@@ -174,7 +174,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
0x01, /* bmaControls0: mute */
|
||||
0x02, /* bmaControls1: volume */
|
||||
0x00, /* iFeature: unused */
|
||||
|
||||
|
||||
AUDIO_OUTPUT_TERMINAL_SIZE, /* bLength: descriptor size */
|
||||
AUDIO_CS_INTERFACE, /* bDescriptorType: configuration */
|
||||
AUDIO_AC_OUTPUT_TERMINAL, /* bDescriptorSubtype: output_terminal type*/
|
||||
@@ -184,8 +184,8 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
0x00, /* bAssocTerminal: unused */
|
||||
AUDIO_MIC_FEATURE_UNIT_ID, /* bSourceID: from feature unit terminal */
|
||||
0x00, /* iTerminal: unused */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if (AUDIO_SUPPORT_SPK == 1)
|
||||
/* speaker config */
|
||||
AUDIO_INPUT_TERMINAL_SIZE, /* bLength: descriptor size */
|
||||
@@ -205,7 +205,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
0x00, /* wChannelConfig */
|
||||
0x00, /* iChannelNames: unused */
|
||||
0x00, /* iTerminal: unused */
|
||||
|
||||
|
||||
AUDIO_FEATURE_UNIT_SIZE, /* bLength: descriptor size */
|
||||
AUDIO_CS_INTERFACE, /* bDescriptorType: configuration */
|
||||
AUDIO_AC_FEATURE_UNIT, /* bDescriptorSubtype: feature unit type*/
|
||||
@@ -215,7 +215,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
0x01, /* bmaControls0: mute*/
|
||||
0x02, /* bmaControls1: volume */
|
||||
0x00, /* iFeature: unused */
|
||||
|
||||
|
||||
AUDIO_OUTPUT_TERMINAL_SIZE, /* bLength: descriptor size */
|
||||
AUDIO_CS_INTERFACE, /* bDescriptorType: configuration */
|
||||
AUDIO_AC_OUTPUT_TERMINAL, /* bDescriptorSubtype: output_terminal type*/
|
||||
@@ -237,8 +237,8 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
USB_CLASS_CODE_AUDIO, /* bInterfaceClass: audio */
|
||||
AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubclass: audio streaming */
|
||||
0x00, /* bInterfaceProtocol: unused */
|
||||
0x00, /* iInterface: unused */
|
||||
|
||||
0x00, /* iInterface: unused */
|
||||
|
||||
0x09, /* bLength: descriptor size */
|
||||
USB_DESCIPTOR_TYPE_INTERFACE, /* bDescriptorType: interface descriptor type */
|
||||
AUDIO_MIC_INTERFACE_NUMBER, /* bInterfaceNumber: index of this interface */
|
||||
@@ -247,8 +247,8 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
USB_CLASS_CODE_AUDIO, /* bInterfaceClass: audio */
|
||||
AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubclass: audio streaming */
|
||||
0x00, /* bInterfaceProtocol: unused */
|
||||
0x00, /* iInterface: unused */
|
||||
|
||||
0x00, /* iInterface: unused */
|
||||
|
||||
0x07, /* bLength: configuration descriptor size */
|
||||
AUDIO_CS_INTERFACE, /* bDescriptorType: interface descriptor type */
|
||||
AUDIO_AS_GENERAL, /* bDescriptorSubtype: general sub type*/
|
||||
@@ -256,7 +256,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
0x01, /* bDelay: interface delay */
|
||||
0x01, /* wFormatTag: pcm format*/
|
||||
0x00, /* wFormatTag: pcm format*/
|
||||
|
||||
|
||||
0x08 + AUDIO_MIC_FREQ_SIZE * 3, /* bLength: descriptor size */
|
||||
AUDIO_CS_INTERFACE, /* bDescriptorType: interface descriptor type */
|
||||
AUDIO_AS_FORMAT_TYPE, /* bDescriptorSubtype: format subtype */
|
||||
@@ -265,10 +265,10 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
AUDIO_MIC_BITW / 8, /* bSubFrameSize: per audio subframe */
|
||||
AUDIO_MIC_BITW, /* bBitResolution: n bits per sample */
|
||||
AUDIO_MIC_FREQ_SIZE, /* bSamFreqType: n frequency supported */
|
||||
#if (AUDIO_SUPPORT_FREQ_16K == 1)
|
||||
#if (AUDIO_SUPPORT_FREQ_16K == 1)
|
||||
SAMPLE_FREQ(AT32_AUDIO_FREQ_16K), /* tSamFreq: 16000hz */
|
||||
#endif
|
||||
#if (AUDIO_SUPPORT_FREQ_48K == 1)
|
||||
#if (AUDIO_SUPPORT_FREQ_48K == 1)
|
||||
SAMPLE_FREQ(AT32_AUDIO_FREQ_48K), /* tSamFreq: 48000hz */
|
||||
#endif
|
||||
|
||||
@@ -281,7 +281,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
AUDIO_BINTERVAL_TIME, /* bInterval: interval for polling endpoint for data transfers */
|
||||
0x00, /* bRefresh: unused */
|
||||
0x00, /* bSynchAddress: unused */
|
||||
|
||||
|
||||
0x07, /* bLength: size of endpoint descriptor in bytes */
|
||||
AUDIO_CS_ENDPOINT, /* bDescriptorType: cs endpoint descriptor type */
|
||||
0x01, /* bDescriptorSubtype: general subtype */
|
||||
@@ -302,7 +302,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubclass: audio streaming */
|
||||
0x00, /* bInterfaceProtocol: unused */
|
||||
0x00, /* iInterface: unused */
|
||||
|
||||
|
||||
0x09, /* bLength: descriptor size */
|
||||
USB_DESCIPTOR_TYPE_INTERFACE, /* bDescriptorType: interface descriptor type */
|
||||
AUDIO_SPK_INTERFACE_NUMBER, /* bInterfaceNumber: index of this interface */
|
||||
@@ -311,8 +311,8 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
USB_CLASS_CODE_AUDIO, /* bInterfaceClass: audio */
|
||||
AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubclass: audio streaming */
|
||||
0x00, /* bInterfaceProtocol: unused */
|
||||
0x00, /* iInterface: unused */
|
||||
|
||||
0x00, /* iInterface: unused */
|
||||
|
||||
0x07, /* bLength: configuration descriptor size */
|
||||
AUDIO_CS_INTERFACE, /* bDescriptorType: interface descriptor type */
|
||||
AUDIO_AS_GENERAL, /* bDescriptorSubtype: general sub type*/
|
||||
@@ -320,7 +320,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
0x01, /* bDelay: interface delay */
|
||||
0x01, /* wFormatTag: pcm format*/
|
||||
0x00, /* wFormatTag: pcm format*/
|
||||
|
||||
|
||||
0x08 + AUDIO_SPK_FREQ_SIZE * 3, /* bLength: descriptor size */
|
||||
AUDIO_CS_INTERFACE, /* bDescriptorType: interface descriptor type */
|
||||
AUDIO_AS_FORMAT_TYPE, /* bDescriptorSubtype: format subtype */
|
||||
@@ -329,13 +329,13 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
AUDIO_SPK_BITW / 8, /* bSubFrameSize: per audio subframe */
|
||||
AUDIO_SPK_BITW, /* bBitResolution: n bits per sample */
|
||||
AUDIO_SPK_FREQ_SIZE, /* bSamFreqType: n frequency supported */
|
||||
#if (AUDIO_SUPPORT_FREQ_16K == 1)
|
||||
#if (AUDIO_SUPPORT_FREQ_16K == 1)
|
||||
SAMPLE_FREQ(AT32_AUDIO_FREQ_16K), /* tSamFreq: 16000hz */
|
||||
#endif
|
||||
#if (AUDIO_SUPPORT_FREQ_48K == 1)
|
||||
#if (AUDIO_SUPPORT_FREQ_48K == 1)
|
||||
SAMPLE_FREQ(AT32_AUDIO_FREQ_48K), /* tSamFreq: 48000hz */
|
||||
#endif
|
||||
|
||||
|
||||
0x09, /* bLength: size of endpoint descriptor in bytes */
|
||||
USB_DESCIPTOR_TYPE_ENDPOINT, /* bDescriptorType: endpoint descriptor type */
|
||||
USBD_AUDIO_SPK_OUT_EPT, /* bEndpointAddress: the address of endpoint on usb device described by this descriptor */
|
||||
@@ -357,7 +357,7 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
0x00, /* bLockDelayUnits: unused */
|
||||
0x00, /* wLockDelay: unused */
|
||||
0x00, /* wLockDelay: unused */
|
||||
|
||||
|
||||
#if (AUDIO_SUPPORT_FEEDBACK == 1)
|
||||
0x09, /* bLength: size of endpoint descriptor in bytes */
|
||||
USB_DESCIPTOR_TYPE_ENDPOINT, /* bDescriptorType: endpoint descriptor type */
|
||||
@@ -368,11 +368,11 @@ ALIGNED_HEAD static uint8_t g_usbd_configuration[USBD_AUDIO_CONFIG_DESC_SIZE] AL
|
||||
1, /* bInterval: interval for polling endpoint for data transfers */
|
||||
FEEDBACK_REFRESH_TIME, /* bRefresh: this field indicates the rate at which an iso syncronization
|
||||
pipe provides new syncronization feedback data. this rate must be a power of
|
||||
2, therefore only the power is reported back and the range of this field is from
|
||||
2, therefore only the power is reported back and the range of this field is from
|
||||
1(2ms) to 9(512ms) */
|
||||
0x00 /* bSynchAddress: 0x00*/
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -437,24 +437,24 @@ static usbd_desc_t vp_desc;
|
||||
* @brief standard usb unicode convert
|
||||
* @param string: source string
|
||||
* @param unicode_buf: unicode buffer
|
||||
* @retval length
|
||||
* @retval length
|
||||
*/
|
||||
static uint16_t usbd_unicode_convert(uint8_t *string, uint8_t *unicode_buf)
|
||||
{
|
||||
uint16_t str_len = 0, id_pos = 2;
|
||||
uint8_t *tmp_str = string;
|
||||
|
||||
|
||||
while(*tmp_str != '\0')
|
||||
{
|
||||
str_len ++;
|
||||
unicode_buf[id_pos ++] = *tmp_str ++;
|
||||
unicode_buf[id_pos ++] = 0x00;
|
||||
}
|
||||
|
||||
|
||||
str_len = str_len * 2 + 2;
|
||||
unicode_buf[0] = str_len;
|
||||
unicode_buf[1] = USB_DESCIPTOR_TYPE_STRING;
|
||||
|
||||
|
||||
return str_len;
|
||||
}
|
||||
|
||||
@@ -463,12 +463,12 @@ static uint16_t usbd_unicode_convert(uint8_t *string, uint8_t *unicode_buf)
|
||||
* @param value: int value
|
||||
* @param pbus: unicode buffer
|
||||
* @param len: length
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
static void usbd_int_to_unicode (uint32_t value , uint8_t *pbuf , uint8_t len)
|
||||
{
|
||||
uint8_t idx = 0;
|
||||
|
||||
|
||||
for( idx = 0 ; idx < len ; idx ++)
|
||||
{
|
||||
if( ((value >> 28)) < 0xA )
|
||||
@@ -477,11 +477,11 @@ static void usbd_int_to_unicode (uint32_t value , uint8_t *pbuf , uint8_t len)
|
||||
}
|
||||
else
|
||||
{
|
||||
pbuf[2 * idx] = (value >> 28) + 'A' - 10;
|
||||
pbuf[2 * idx] = (value >> 28) + 'A' - 10;
|
||||
}
|
||||
|
||||
|
||||
value = value << 4;
|
||||
|
||||
|
||||
pbuf[2 * idx + 1] = 0;
|
||||
}
|
||||
}
|
||||
@@ -489,18 +489,18 @@ static void usbd_int_to_unicode (uint32_t value , uint8_t *pbuf , uint8_t len)
|
||||
/**
|
||||
* @brief usb get serial number
|
||||
* @param none
|
||||
* @retval none
|
||||
* @retval none
|
||||
*/
|
||||
static void get_serial_num(void)
|
||||
{
|
||||
uint32_t serial0, serial1, serial2;
|
||||
|
||||
|
||||
serial0 = *(uint32_t*)MCU_ID1;
|
||||
serial1 = *(uint32_t*)MCU_ID2;
|
||||
serial2 = *(uint32_t*)MCU_ID3;
|
||||
|
||||
|
||||
serial0 += serial2;
|
||||
|
||||
|
||||
if (serial0 != 0)
|
||||
{
|
||||
usbd_int_to_unicode (serial0, &g_string_serial[2] ,8);
|
||||
@@ -511,7 +511,7 @@ static void get_serial_num(void)
|
||||
/**
|
||||
* @brief get device descriptor
|
||||
* @param none
|
||||
* @retval usbd_desc
|
||||
* @retval usbd_desc
|
||||
*/
|
||||
static usbd_desc_t *get_device_descriptor(void)
|
||||
{
|
||||
@@ -521,7 +521,7 @@ static usbd_desc_t *get_device_descriptor(void)
|
||||
/**
|
||||
* @brief get device qualifier
|
||||
* @param none
|
||||
* @retval usbd_desc
|
||||
* @retval usbd_desc
|
||||
*/
|
||||
static usbd_desc_t * get_device_qualifier(void)
|
||||
{
|
||||
@@ -531,7 +531,7 @@ static usbd_desc_t * get_device_qualifier(void)
|
||||
/**
|
||||
* @brief get config descriptor
|
||||
* @param none
|
||||
* @retval usbd_desc
|
||||
* @retval usbd_desc
|
||||
*/
|
||||
static usbd_desc_t *get_device_configuration(void)
|
||||
{
|
||||
@@ -541,7 +541,7 @@ static usbd_desc_t *get_device_configuration(void)
|
||||
/**
|
||||
* @brief get other speed descriptor
|
||||
* @param none
|
||||
* @retval usbd_desc
|
||||
* @retval usbd_desc
|
||||
*/
|
||||
static usbd_desc_t *get_device_other_speed(void)
|
||||
{
|
||||
@@ -551,7 +551,7 @@ static usbd_desc_t *get_device_other_speed(void)
|
||||
/**
|
||||
* @brief get lang id descriptor
|
||||
* @param none
|
||||
* @retval usbd_desc
|
||||
* @retval usbd_desc
|
||||
*/
|
||||
static usbd_desc_t *get_device_lang_id(void)
|
||||
{
|
||||
@@ -562,7 +562,7 @@ static usbd_desc_t *get_device_lang_id(void)
|
||||
/**
|
||||
* @brief get manufacturer descriptor
|
||||
* @param none
|
||||
* @retval usbd_desc
|
||||
* @retval usbd_desc
|
||||
*/
|
||||
static usbd_desc_t *get_device_manufacturer_string(void)
|
||||
{
|
||||
@@ -574,7 +574,7 @@ static usbd_desc_t *get_device_manufacturer_string(void)
|
||||
/**
|
||||
* @brief get product descriptor
|
||||
* @param none
|
||||
* @retval usbd_desc
|
||||
* @retval usbd_desc
|
||||
*/
|
||||
static usbd_desc_t *get_device_product_string(void)
|
||||
{
|
||||
@@ -586,7 +586,7 @@ static usbd_desc_t *get_device_product_string(void)
|
||||
/**
|
||||
* @brief get serial descriptor
|
||||
* @param none
|
||||
* @retval usbd_desc
|
||||
* @retval usbd_desc
|
||||
*/
|
||||
static usbd_desc_t *get_device_serial_string(void)
|
||||
{
|
||||
@@ -597,7 +597,7 @@ static usbd_desc_t *get_device_serial_string(void)
|
||||
/**
|
||||
* @brief get interface descriptor
|
||||
* @param none
|
||||
* @retval usbd_desc
|
||||
* @retval usbd_desc
|
||||
*/
|
||||
static usbd_desc_t *get_device_interface_string(void)
|
||||
{
|
||||
@@ -609,7 +609,7 @@ static usbd_desc_t *get_device_interface_string(void)
|
||||
/**
|
||||
* @brief get device config descriptor
|
||||
* @param none
|
||||
* @retval usbd_desc
|
||||
* @retval usbd_desc
|
||||
*/
|
||||
static usbd_desc_t *get_device_config_string(void)
|
||||
{
|
||||
@@ -620,7 +620,7 @@ static usbd_desc_t *get_device_config_string(void)
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
Reference in New Issue
Block a user