summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2022-04-13 11:14:18 +0800
committersakumisu <[email protected]>2022-04-13 11:14:18 +0800
commite2c401cebf8976f9400d62b9e6241ce95592e2d1 (patch)
treedbec2281569b9d5a2163414fc3e275ba6b742754
parente938e443203fe9f5feaa29844527aabc42b2d391 (diff)
add multi sampling rate control template
-rw-r--r--demo/audio_v2_mic_speaker_multichan_template.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/demo/audio_v2_mic_speaker_multichan_template.c b/demo/audio_v2_mic_speaker_multichan_template.c
index 6b292907..382a2ba6 100644
--- a/demo/audio_v2_mic_speaker_multichan_template.c
+++ b/demo/audio_v2_mic_speaker_multichan_template.c
@@ -59,7 +59,7 @@
AUDIO_V2_SIZEOF_AC_FEATURE_UNIT_DESC(IN_CHANNEL_NUM) + \
AUDIO_V2_SIZEOF_AC_OUTPUT_TERMINAL_DESC)
-const uint8_t audio_descriptor[] = {
+uint8_t audio_descriptor[] = {
USB_DEVICE_DESCRIPTOR_INIT(USB_2_0, 0x00, 0x00, 0x00, USBD_VID, USBD_PID, 0x0001, 0x01),
USB_CONFIG_DESCRIPTOR_INIT(USB_AUDIO_CONFIG_DESC_SIZ, 0x03, 0x01, USB_CONFIG_BUS_POWERED, USBD_MAX_POWER),
AUDIO_V2_AC_DESCRIPTOR_INIT(0x00, 0x03, AUDIO_AC_SIZ, AUDIO_CATEGORY_UNDEF, 0x00, 0x00),
@@ -171,6 +171,18 @@ void usbd_audio_close(uint8_t intf)
}
}
+void usbd_audio_set_sampling_freq(uint8_t entity_id, uint8_t ep_ch, uint32_t sampling_freq)
+{
+ uint16_t packet_size = ((sampling_freq * 2 * 2) / 1000);
+ if (entity_id == 1) {
+ audio_descriptor[18 + USB_AUDIO_CONFIG_DESC_SIZ - AUDIO_V2_AS_DESCRIPTOR_INIT_LEN - 11] = packet_size;
+ audio_descriptor[18 + USB_AUDIO_CONFIG_DESC_SIZ - AUDIO_V2_AS_DESCRIPTOR_INIT_LEN - 10] = packet_size >> 8;
+ } else if (entity_id == 5) {
+ audio_descriptor[18 + USB_AUDIO_CONFIG_DESC_SIZ - 11] = packet_size;
+ audio_descriptor[18 + USB_AUDIO_CONFIG_DESC_SIZ - 10] = packet_size >> 8;
+ }
+}
+
static usbd_class_t audio_class;
static usbd_interface_t audio_control_intf;
static usbd_interface_t audio_stream_intf;