From e5989ee41ab03af92c6fa4c0c2d598dc892d3986 Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Sat, 12 Apr 2025 16:50:25 +0800 Subject: [PATCH] update(demo): use largest frequence from table Signed-off-by: sakumisu <1203593632@qq.com> --- demo/audio_v2_mic_multichan_template.c | 8 ++++---- demo/audio_v2_mic_speaker_multichan_template.c | 10 +++++++--- demo/audio_v2_speaker_multichan_template.c | 10 +++++----- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/demo/audio_v2_mic_multichan_template.c b/demo/audio_v2_mic_multichan_template.c index 81b8e230..8c25f25b 100644 --- a/demo/audio_v2_mic_multichan_template.c +++ b/demo/audio_v2_mic_multichan_template.c @@ -22,9 +22,9 @@ #define AUDIO_IN_CLOCK_ID 0x01 #define AUDIO_IN_FU_ID 0x03 -#define AUDIO_FREQ 48000 -#define HALF_WORD_BYTES 2 //2 half word (one channel) -#define SAMPLE_BITS 16 //16 bit per channel +#define AUDIO_IN_MAX_FREQ 16000 +#define HALF_WORD_BYTES 2 //2 half word (one channel) +#define SAMPLE_BITS 16 //16 bit per channel #define BMCONTROL (AUDIO_V2_FU_CONTROL_MUTE | AUDIO_V2_FU_CONTROL_VOLUME) @@ -56,7 +56,7 @@ #define INPUT_CH_ENABLE 0x000000ff #endif -#define AUDIO_IN_PACKET ((uint32_t)((AUDIO_FREQ * HALF_WORD_BYTES * IN_CHANNEL_NUM) / 1000)) +#define AUDIO_IN_PACKET ((uint32_t)((AUDIO_IN_MAX_FREQ * HALF_WORD_BYTES * IN_CHANNEL_NUM) / 1000)) #define USB_AUDIO_CONFIG_DESC_SIZ (9 + \ AUDIO_V2_AC_DESCRIPTOR_INIT_LEN + \ diff --git a/demo/audio_v2_mic_speaker_multichan_template.c b/demo/audio_v2_mic_speaker_multichan_template.c index 10322305..d96916c5 100644 --- a/demo/audio_v2_mic_speaker_multichan_template.c +++ b/demo/audio_v2_mic_speaker_multichan_template.c @@ -30,7 +30,9 @@ #define AUDIO_IN_CLOCK_ID 0x05 #define AUDIO_IN_FU_ID 0x07 -#define AUDIO_FREQ 48000 +#define AUDIO_OUT_MAX_FREQ 96000 +#define AUDIO_IN_MAX_FREQ 16000 + #define HALF_WORD_BYTES 2 //2 half word (one channel) #define SAMPLE_BITS 16 //16 bit per channel @@ -93,8 +95,8 @@ #endif /* AudioFreq * DataSize (2 bytes) * NumChannels */ -#define AUDIO_OUT_PACKET ((uint32_t)((AUDIO_FREQ * HALF_WORD_BYTES * OUT_CHANNEL_NUM) / 1000)) -#define AUDIO_IN_PACKET ((uint32_t)((AUDIO_FREQ * HALF_WORD_BYTES * IN_CHANNEL_NUM) / 1000)) +#define AUDIO_OUT_PACKET ((uint32_t)((AUDIO_OUT_MAX_FREQ * HALF_WORD_BYTES * OUT_CHANNEL_NUM) / 1000)) +#define AUDIO_IN_PACKET ((uint32_t)((AUDIO_IN_MAX_FREQ * HALF_WORD_BYTES * IN_CHANNEL_NUM) / 1000)) #if USING_FEEDBACK == 0 #define USB_AUDIO_CONFIG_DESC_SIZ (9 + \ @@ -418,6 +420,8 @@ void usbd_audio_iso_out_callback(uint8_t busid, uint8_t ep, uint32_t nbytes) void usbd_audio_iso_in_callback(uint8_t busid, uint8_t ep, uint32_t nbytes) { + USB_LOG_RAW("actual in len:%d\r\n", (unsigned int)nbytes); + ep_tx_busy_flag = false; } #if USING_FEEDBACK == 1 diff --git a/demo/audio_v2_speaker_multichan_template.c b/demo/audio_v2_speaker_multichan_template.c index 5fb5649a..9f0de4c7 100644 --- a/demo/audio_v2_speaker_multichan_template.c +++ b/demo/audio_v2_speaker_multichan_template.c @@ -27,9 +27,9 @@ #define AUDIO_OUT_CLOCK_ID 0x01 #define AUDIO_OUT_FU_ID 0x03 -#define AUDIO_FREQ 48000 -#define HALF_WORD_BYTES 2 //2 half word (one channel) -#define SAMPLE_BITS 16 //16 bit per channel +#define AUDIO_OUT_MAX_FREQ 96000 +#define HALF_WORD_BYTES 2 //2 half word (one channel) +#define SAMPLE_BITS 16 //16 bit per channel #define BMCONTROL (AUDIO_V2_FU_CONTROL_MUTE | AUDIO_V2_FU_CONTROL_VOLUME) @@ -61,7 +61,7 @@ #define OUTPUT_CH_ENABLE 0x000000ff #endif -#define AUDIO_OUT_PACKET ((uint32_t)((AUDIO_FREQ * HALF_WORD_BYTES * OUT_CHANNEL_NUM) / 1000)) +#define AUDIO_OUT_PACKET ((uint32_t)((AUDIO_OUT_MAX_FREQ * HALF_WORD_BYTES * OUT_CHANNEL_NUM) / 1000)) #if USING_FEEDBACK == 0 #define USB_AUDIO_CONFIG_DESC_SIZ (9 + \ @@ -228,7 +228,7 @@ const uint8_t audio_v2_descriptor[] = { '0', 0x00, /* wcChar7 */ '0', 0x00, /* wcChar8 */ #if USING_FEEDBACK == 0 - '3', 0x00, /* wcChar9 */ + '3', 0x00, /* wcChar9 */ #else '4', 0x00, /* wcChar9 */ #endif