update(demo): use largest frequence from table

Signed-off-by: sakumisu <1203593632@qq.com>
This commit is contained in:
sakumisu
2025-04-12 16:50:25 +08:00
parent 364eb60396
commit e5989ee41a
3 changed files with 16 additions and 12 deletions

View File

@@ -22,9 +22,9 @@
#define AUDIO_IN_CLOCK_ID 0x01 #define AUDIO_IN_CLOCK_ID 0x01
#define AUDIO_IN_FU_ID 0x03 #define AUDIO_IN_FU_ID 0x03
#define AUDIO_FREQ 48000 #define AUDIO_IN_MAX_FREQ 16000
#define HALF_WORD_BYTES 2 //2 half word (one channel) #define HALF_WORD_BYTES 2 //2 half word (one channel)
#define SAMPLE_BITS 16 //16 bit per channel #define SAMPLE_BITS 16 //16 bit per channel
#define BMCONTROL (AUDIO_V2_FU_CONTROL_MUTE | AUDIO_V2_FU_CONTROL_VOLUME) #define BMCONTROL (AUDIO_V2_FU_CONTROL_MUTE | AUDIO_V2_FU_CONTROL_VOLUME)
@@ -56,7 +56,7 @@
#define INPUT_CH_ENABLE 0x000000ff #define INPUT_CH_ENABLE 0x000000ff
#endif #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 + \ #define USB_AUDIO_CONFIG_DESC_SIZ (9 + \
AUDIO_V2_AC_DESCRIPTOR_INIT_LEN + \ AUDIO_V2_AC_DESCRIPTOR_INIT_LEN + \

View File

@@ -30,7 +30,9 @@
#define AUDIO_IN_CLOCK_ID 0x05 #define AUDIO_IN_CLOCK_ID 0x05
#define AUDIO_IN_FU_ID 0x07 #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 HALF_WORD_BYTES 2 //2 half word (one channel)
#define SAMPLE_BITS 16 //16 bit per channel #define SAMPLE_BITS 16 //16 bit per channel
@@ -93,8 +95,8 @@
#endif #endif
/* AudioFreq * DataSize (2 bytes) * NumChannels */ /* AudioFreq * DataSize (2 bytes) * NumChannels */
#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))
#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))
#if USING_FEEDBACK == 0 #if USING_FEEDBACK == 0
#define USB_AUDIO_CONFIG_DESC_SIZ (9 + \ #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) 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 #if USING_FEEDBACK == 1

View File

@@ -27,9 +27,9 @@
#define AUDIO_OUT_CLOCK_ID 0x01 #define AUDIO_OUT_CLOCK_ID 0x01
#define AUDIO_OUT_FU_ID 0x03 #define AUDIO_OUT_FU_ID 0x03
#define AUDIO_FREQ 48000 #define AUDIO_OUT_MAX_FREQ 96000
#define HALF_WORD_BYTES 2 //2 half word (one channel) #define HALF_WORD_BYTES 2 //2 half word (one channel)
#define SAMPLE_BITS 16 //16 bit per channel #define SAMPLE_BITS 16 //16 bit per channel
#define BMCONTROL (AUDIO_V2_FU_CONTROL_MUTE | AUDIO_V2_FU_CONTROL_VOLUME) #define BMCONTROL (AUDIO_V2_FU_CONTROL_MUTE | AUDIO_V2_FU_CONTROL_VOLUME)
@@ -61,7 +61,7 @@
#define OUTPUT_CH_ENABLE 0x000000ff #define OUTPUT_CH_ENABLE 0x000000ff
#endif #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 #if USING_FEEDBACK == 0
#define USB_AUDIO_CONFIG_DESC_SIZ (9 + \ #define USB_AUDIO_CONFIG_DESC_SIZ (9 + \
@@ -228,7 +228,7 @@ const uint8_t audio_v2_descriptor[] = {
'0', 0x00, /* wcChar7 */ '0', 0x00, /* wcChar7 */
'0', 0x00, /* wcChar8 */ '0', 0x00, /* wcChar8 */
#if USING_FEEDBACK == 0 #if USING_FEEDBACK == 0
'3', 0x00, /* wcChar9 */ '3', 0x00, /* wcChar9 */
#else #else
'4', 0x00, /* wcChar9 */ '4', 0x00, /* wcChar9 */
#endif #endif