update version to v2.0.4

This commit is contained in:
Artery-MCU
2022-04-11 19:27:58 +08:00
parent d2285506f0
commit eab9bf65de
1451 changed files with 221506 additions and 13129 deletions

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file audio_class.c
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb audio class type
**************************************************************************
* 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 AT32F413_middlewares_usbd_class
* @{
*/
/** @defgroup USB_audio_class
* @brief usb device class audio demo
* @{
*/
*/
/** @defgroup USB_audio_class_private_functions
* @{
@@ -62,7 +62,7 @@ static void audio_set_interface(void *udev, usb_setup_type *setup);
usb_audio_type audio_struct = {0, 0, 0, 0, 0, 0x1400, 0, 0, 0, {0x0000, 0x1400, 0x33}, {0x0000, 0x1400, 0x33}, 0, 0};
/* usb device class handler */
usbd_class_handler audio_class_handler =
usbd_class_handler audio_class_handler =
{
class_init_handler,
class_clear_handler,
@@ -79,7 +79,7 @@ usbd_class_handler audio_class_handler =
/**
* @brief initialize usb custom hid endpoint
* @param udev: usb device core handler type
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_init_handler(void *udev)
{
@@ -88,47 +88,47 @@ static usb_sts_type class_init_handler(void *udev)
usb_audio_type *paudio = (usb_audio_type *)pudev->class_handler->pdata;
/* enable microphone in endpoint double buffer mode */
usbd_ept_dbuffer_enable(pudev, USBD_AUDIO_MIC_IN_EPT);
/* open microphone in endpoint */
usbd_ept_open(pudev, USBD_AUDIO_MIC_IN_EPT, EPT_ISO_TYPE, AUDIO_MIC_IN_MAXPACKET_SIZE);
/* enable speaker out endpoint double buffer mode */
usbd_ept_dbuffer_enable(pudev, USBD_AUDIO_SPK_OUT_EPT);
/* open speaker out endpoint */
usbd_ept_open(pudev, USBD_AUDIO_SPK_OUT_EPT, EPT_ISO_TYPE, AUDIO_SPK_OUT_MAXPACKET_SIZE);
/* enable speaker feedback endpoint double buffer mode */
usbd_ept_dbuffer_enable(pudev, USBD_AUDIO_FEEDBACK_EPT);
/* open speaker feedback endpoint */
usbd_ept_open(pudev, USBD_AUDIO_FEEDBACK_EPT, EPT_ISO_TYPE, AUDIO_FEEDBACK_MAXPACKET_SIZE);
/* start receive speaker out data */
usbd_ept_recv(pudev, USBD_AUDIO_SPK_OUT_EPT, paudio->audio_spk_data, AUDIO_SPK_OUT_MAXPACKET_SIZE);
return status;
}
/**
* @brief clear endpoint or other state
* @param udev: usb device core handler type
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_clear_handler(void *udev)
{
usb_sts_type status = USB_OK;
usbd_core_type *pudev = (usbd_core_type *)udev;
/* close in endpoint */
usbd_ept_close(pudev, USBD_AUDIO_MIC_IN_EPT);
/* close in endpoint */
usbd_ept_close(pudev, USBD_AUDIO_FEEDBACK_EPT);
/* close out endpoint */
usbd_ept_close(pudev, USBD_AUDIO_SPK_OUT_EPT);
return status;
}
@@ -136,7 +136,7 @@ static usb_sts_type class_clear_handler(void *udev)
* @brief usb device class setup request handler
* @param udev: usb device core handler type
* @param setup: setup packet
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_setup_handler(void *udev, usb_setup_type *setup)
{
@@ -153,23 +153,23 @@ static usb_sts_type class_setup_handler(void *udev, usb_setup_type *setup)
case AUDIO_REQ_GET_CUR:
audio_req_get_cur(pudev, setup);
break;
case AUDIO_REQ_SET_CUR:
audio_req_set_cur(pudev, setup);
break;
case AUDIO_REQ_GET_MIN:
audio_req_get_min(pudev, setup);
break;
case AUDIO_REQ_GET_MAX:
audio_req_get_max(pudev, setup);
break;
case AUDIO_REQ_GET_RES:
audio_req_get_res(pudev, setup);
break;
default:
usbd_ctrl_unsupport(pudev);
break;
@@ -194,17 +194,17 @@ static usb_sts_type class_setup_handler(void *udev, usb_setup_type *setup)
case USB_STD_REQ_GET_INTERFACE:
audio_get_interface(udev, setup);
break;
case USB_STD_REQ_SET_INTERFACE:
audio_set_interface(udev, setup);
usbd_ctrl_send_status(pudev);
break;
default:
break;
}
break;
default:
usbd_ctrl_unsupport(pudev);
break;
@@ -215,21 +215,21 @@ static usb_sts_type class_setup_handler(void *udev, usb_setup_type *setup)
/**
* @brief usb device endpoint 0 in status stage complete
* @param udev: usb device core handler type
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_ept0_tx_handler(void *udev)
{
usb_sts_type status = USB_OK;
/* ...user code... */
return status;
}
/**
* @brief usb device endpoint 0 out status stage complete
* @param udev: usb device core handler type
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_ept0_rx_handler(void *udev)
{
@@ -246,16 +246,16 @@ static usb_sts_type class_ept0_rx_handler(void *udev)
case AUDIO_VOLUME_CONTROL:
if( paudio->interface == AUDIO_SPK_FEATURE_UNIT_ID)
{
paudio->spk_volume = (uint16_t)( paudio->g_audio_cur[0] |
paudio->spk_volume = (uint16_t)( paudio->g_audio_cur[0] |
( paudio->g_audio_cur[1] << 8));
/* set volume */
audio_codec_set_spk_volume(paudio->spk_volume*100/paudio->spk_volume_limits[1]);
}
else
{
paudio->mic_volume = (uint16_t)(paudio->g_audio_cur[0] |
paudio->mic_volume = (uint16_t)(paudio->g_audio_cur[0] |
(paudio->g_audio_cur[1] << 8));
audio_codec_set_mic_volume(paudio->mic_volume*256/paudio->mic_volume_limits[1]);
}
break;
@@ -270,19 +270,19 @@ static usb_sts_type class_ept0_rx_handler(void *udev)
paudio->mic_mute = paudio->g_audio_cur[0];
audio_codec_set_mic_mute(paudio->mic_mute);
}
break;
case AUDIO_FREQ_SET_CONTROL:
if(paudio->enpd == USBD_AUDIO_MIC_IN_EPT)
{
paudio->mic_freq = (paudio->g_audio_cur[0] |
paudio->mic_freq = (paudio->g_audio_cur[0] |
(paudio->g_audio_cur[1] << 8) |
(paudio->g_audio_cur[2] << 16));
audio_codec_set_mic_freq(paudio->mic_freq);
}
else
{
paudio->spk_freq = (paudio->g_audio_cur[0] |
paudio->spk_freq = (paudio->g_audio_cur[0] |
(paudio->g_audio_cur[1] << 8) |
(paudio->g_audio_cur[2] << 16));
audio_codec_set_spk_freq(paudio->spk_freq);
@@ -292,7 +292,7 @@ static usb_sts_type class_ept0_rx_handler(void *udev)
break;
}
}
return status;
}
@@ -300,7 +300,7 @@ static usb_sts_type class_ept0_rx_handler(void *udev)
* @brief usb device transmision complete handler
* @param udev: usb device core handler type
* @param ept_num: endpoint number
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
{
@@ -308,7 +308,7 @@ static usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
usbd_core_type *pudev = (usbd_core_type *)udev;
usb_audio_type *paudio = (usb_audio_type *)pudev->class_handler->pdata;
uint32_t len = 0;
/* ...user code...
trans next packet data
*/
@@ -317,13 +317,13 @@ static usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
len = audio_codec_mic_get_data(paudio->audio_mic_data);
usbd_ept_send(udev, USBD_AUDIO_MIC_IN_EPT, paudio->audio_mic_data, len);
}
else if((ept_num & 0x7F) == (USBD_AUDIO_FEEDBACK_EPT & 0x7F))
{
len = audio_codec_spk_feedback(paudio->audio_feed_back);
usbd_ept_send(udev, USBD_AUDIO_FEEDBACK_EPT, paudio->audio_feed_back, len);
}
return status;
}
@@ -331,7 +331,7 @@ static usb_sts_type class_in_handler(void *udev, uint8_t ept_num)
* @brief usb device endpoint receive data
* @param udev: usb device core handler type
* @param ept_num: endpoint number
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_out_handler(void *udev, uint8_t ept_num)
{
@@ -339,15 +339,15 @@ static usb_sts_type class_out_handler(void *udev, uint8_t ept_num)
usbd_core_type *pudev = (usbd_core_type *)udev;
usb_audio_type *paudio = (usb_audio_type *)pudev->class_handler->pdata;
uint16_t g_rxlen;
/* get endpoint receive data length */
g_rxlen = usbd_get_recv_len(pudev, ept_num);
if((ept_num & 0x7F) == (USBD_AUDIO_SPK_OUT_EPT & 0x7F))
{
/* speaker data*/
audio_codec_spk_fifo_write(paudio->audio_spk_data, g_rxlen);
/* get next data */
usbd_ept_recv(pudev, USBD_AUDIO_SPK_OUT_EPT, paudio->audio_spk_data, AUDIO_SPK_OUT_MAXPACKET_SIZE);
}
@@ -358,14 +358,14 @@ static usb_sts_type class_out_handler(void *udev, uint8_t ept_num)
/**
* @brief usb device sof handler
* @param udev: usb device core handler type
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
static usb_sts_type class_sof_handler(void *udev)
{
usb_sts_type status = USB_OK;
/* ...user code... */
return status;
}
@@ -373,7 +373,7 @@ static usb_sts_type class_sof_handler(void *udev)
* @brief usb device event handler
* @param udev: usb device core handler type
* @param event: usb device event
* @retval status of usb_sts_type
* @retval status of usb_sts_type
*/
usb_sts_type class_event_handler(void *udev, usbd_event_type event)
{
@@ -383,9 +383,9 @@ usb_sts_type class_event_handler(void *udev, usbd_event_type event)
switch(event)
{
case USBD_RESET_EVENT:
/* ...user code... */
break;
case USBD_SUSPEND_EVENT:
paudio->spk_alt_setting = 0;
@@ -393,11 +393,11 @@ usb_sts_type class_event_handler(void *udev, usbd_event_type event)
paudio->mic_alt_setting = 0;
audio_codec_mic_alt_setting(paudio->spk_alt_setting);
/* ...user code... */
break;
case USBD_WAKEUP_EVENT:
/* ...user code... */
break;
default:
break;
@@ -409,7 +409,7 @@ usb_sts_type class_event_handler(void *udev, usbd_event_type event)
* @brief usb audio request get cur
* @param udev: usb device core handler type
* @param setup: setup class
* @retval none
* @retval none
*/
static void audio_req_get_cur(void *udev, usb_setup_type *setup)
{
@@ -440,7 +440,7 @@ static void audio_req_get_cur(void *udev, usb_setup_type *setup)
*((uint16_t *)paudio->g_audio_cur) = paudio->mic_volume;
usbd_ctrl_send(pudev, paudio->g_audio_cur, setup->wLength);
}
}
}
@@ -448,7 +448,7 @@ static void audio_req_get_cur(void *udev, usb_setup_type *setup)
* @brief usb audio request set cur
* @param udev: usb device core handler type
* @param setup: setup class
* @retval none
* @retval none
*/
static void audio_req_set_cur(void *udev, usb_setup_type *setup)
{
@@ -457,10 +457,10 @@ static void audio_req_set_cur(void *udev, usb_setup_type *setup)
if(setup->wLength > 0)
{
usbd_ctrl_recv(pudev, paudio->g_audio_cur, setup->wLength);
paudio->audio_cmd = AUDIO_REQ_SET_CUR;
paudio->audio_cmd_len = setup->wLength;
switch(setup->bmRequestType & AUDIO_REQ_CONTROL_MASK)
{
case AUDIO_REQ_CONTROL_INTERFACE:
@@ -488,7 +488,7 @@ static void audio_req_set_cur(void *udev, usb_setup_type *setup)
* @brief usb audio request get min
* @param udev: usb device core handler type
* @param setup: setup class
* @retval none
* @retval none
*/
static void audio_req_get_min(void *udev, usb_setup_type *setup)
{
@@ -510,7 +510,7 @@ static void audio_req_get_min(void *udev, usb_setup_type *setup)
* @brief usb audio request get max
* @param udev: usb device core handler type
* @param setup: setup class
* @retval none
* @retval none
*/
static void audio_req_get_max(void *udev, usb_setup_type *setup)
{
@@ -532,7 +532,7 @@ static void audio_req_get_max(void *udev, usb_setup_type *setup)
* @brief usb audio request get res
* @param udev: usb device core handler type
* @param setup: setup class
* @retval none
* @retval none
*/
static void audio_req_get_res(void *udev, usb_setup_type *setup)
{
@@ -554,7 +554,7 @@ static void audio_req_get_res(void *udev, usb_setup_type *setup)
* @brief usb audio set interface
* @param udev: usb device core handler type
* @param setup: setup class
* @retval none
* @retval none
*/
static void audio_set_interface(void *udev, usb_setup_type *setup)
{
@@ -569,9 +569,9 @@ static void audio_set_interface(void *udev, usb_setup_type *setup)
{
int len = audio_codec_spk_feedback(paudio->audio_feed_back);
usbd_ept_recv(pudev, USBD_AUDIO_SPK_OUT_EPT, paudio->audio_spk_data, AUDIO_SPK_OUT_MAXPACKET_SIZE);
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, paudio->audio_feed_back, len);
usbd_ept_send(pudev, USBD_AUDIO_FEEDBACK_EPT, paudio->audio_feed_back, len);
}
}
else if(LBYTE(setup->wIndex) == AUDIO_MIC_INTERFACE_NUMBER)
{
@@ -583,7 +583,7 @@ static void audio_set_interface(void *udev, usb_setup_type *setup)
usbd_ept_send(pudev, USBD_AUDIO_MIC_IN_EPT, paudio->audio_mic_data, len);
}
}
}
@@ -591,7 +591,7 @@ static void audio_set_interface(void *udev, usb_setup_type *setup)
* @brief usb audio get interface
* @param udev: usb device core handler type
* @param setup: setup class
* @retval none
* @retval none
*/
static void audio_get_interface(void *udev, usb_setup_type *setup)
{
@@ -605,13 +605,13 @@ static void audio_get_interface(void *udev, usb_setup_type *setup)
{
usbd_ctrl_send(pudev, (uint8_t *)&paudio->mic_alt_setting, 1);
}
}
/**
* @}
*/
*/
/**
* @}

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file audio_class.h
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb audio class file
**************************************************************************
* 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,
@@ -23,7 +23,7 @@
*
**************************************************************************
*/
/* define to prevent recursive inclusion -------------------------------------*/
#ifndef __AUDIO_CLASS_H
#define __AUDIO_CLASS_H
@@ -31,7 +31,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "usb_std.h"
#include "usbd_core.h"
#include "audio_conf.h"
@@ -39,12 +39,12 @@ extern "C" {
/** @addtogroup AT32F413_middlewares_usbd_class
* @{
*/
/** @addtogroup USB_audio_class
* @{
*/
/** @defgroup USB_audio_class_definition
/** @defgroup USB_audio_class_definition
* @{
*/
@@ -99,7 +99,7 @@ typedef struct
uint32_t mic_freq;
uint16_t spk_volume_limits[3]; /*[0] is mininum value, [1] is maxnum value, [2] is volume resolution */
uint16_t mic_volume_limits[3]; /*[0] is mininum value, [1] is maxnum value, [2] is volume resolution */
uint8_t audio_cmd;
uint32_t audio_cmd_len;
uint32_t spk_alt_setting;
@@ -119,7 +119,7 @@ extern usbd_class_handler audio_class_handler;
/**
* @}
*/
/**
* @}
*/

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file audio_conf.h
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb audio config
**************************************************************************
* 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,
@@ -23,7 +23,7 @@
*
**************************************************************************
*/
/* define to prevent recursive inclusion -------------------------------------*/
#ifndef __AUDIO_CONF_H
#define __AUDIO_CONF_H
@@ -31,17 +31,17 @@
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup AT32F413_middlewares_usbd_class
* @{
*/
/** @addtogroup USB_audio_class
* @{
*/
/** @defgroup USB_device_audio_config_definition
/** @defgroup USB_device_audio_config_definition
* @{
*/
#define AUDIO_SUPPORT_SPK 1
@@ -55,7 +55,7 @@ extern "C" {
#define AUDIO_SUPPORT_FREQ (AUDIO_SUPPORT_FREQ_16K + \
AUDIO_SUPPORT_FREQ_48K \
)
#define AUDIO_FREQ_16K 16000
#define AUDIO_FREQ_48K 48000
#define AUDIO_BITW_16 16

View File

@@ -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 AT32F413_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)
/**
* @}
*/
*/
/**
* @}

View File

@@ -1,17 +1,17 @@
/**
**************************************************************************
* @file audio_desc.h
* @version v2.0.3
* @date 2022-02-11
* @version v2.0.4
* @date 2022-04-02
* @brief usb audio descriptor header file
**************************************************************************
* 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,
@@ -23,7 +23,7 @@
*
**************************************************************************
*/
/* define to prevent recursive inclusion -------------------------------------*/
#ifndef __AUDIO_DESC_H
#define __AUDIO_DESC_H
@@ -31,7 +31,7 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "audio_class.h"
#include "usbd_core.h"
#include "audio_conf.h"
@@ -39,12 +39,12 @@ extern "C" {
/** @addtogroup AT32F413_middlewares_usbd_class
* @{
*/
/** @addtogroup USB_audio_desc
* @{
*/
/** @defgroup USB_audio_desc_definition
/** @defgroup USB_audio_desc_definition
* @{
*/
@@ -70,7 +70,7 @@ extern "C" {
#define AUDIO_SUBCLASS_MIDISTREMING 0x03
/**
* @brief audio class-specific descriptor types
* @brief audio class-specific descriptor types
*/
#define AUDIO_CS_INTERFACE 0x24
#define AUDIO_CS_ENDPOINT 0x25
@@ -98,7 +98,7 @@ extern "C" {
#define AUDIO_AC_EXTENSION_UNIT 0x08
/**
* @brief audio class-specific as interface descriptor subtypes
* @brief audio class-specific as interface descriptor subtypes
*/
#define AUDIO_AS_DESCRIPTOR_UNDEFINED 0x00
#define AUDIO_AS_GENERAL 0x01
@@ -221,11 +221,11 @@ extern usbd_desc_handler audio_desc_handler;
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/