Explorar el Código

update(demo): use largest frequence from table

Signed-off-by: sakumisu <1203593632@qq.com>
sakumisu hace 9 meses
padre
commit
e5989ee41a

+ 4 - 4
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 +                      \

+ 7 - 3
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

+ 5 - 5
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