From 84e48c4f03c4702e534e99c19dd5f6253f6364ab Mon Sep 17 00:00:00 2001 From: Sandeep Mistry Date: Thu, 23 Sep 2021 14:48:42 -0400 Subject: [PATCH] Add one extra sample to CFG_TUD_AUDIO_EP_SZ_IN As per https://github.com/hathach/tinyusb/blob/2eaf99e0aa9c10d62dd8d0a4e765f5941bfeaf98/examples/device/audio_4_channel_mic/src/tusb_config.h#L104 --- examples/usb_microphone/tusb_config.h | 4 ++-- examples/usb_microphone/usb_microphone.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/usb_microphone/tusb_config.h b/examples/usb_microphone/tusb_config.h index 2e909f8..21f52d1 100644 --- a/examples/usb_microphone/tusb_config.h +++ b/examples/usb_microphone/tusb_config.h @@ -100,9 +100,9 @@ extern "C" { #define CFG_TUD_AUDIO_ENABLE_EP_IN 1 #define CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX 2 // Driver gets this info from the descriptors - we define it here to use it to setup the descriptors and to do calculations with it below #define CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX 1 // Driver gets this info from the descriptors - we define it here to use it to setup the descriptors and to do calculations with it below - be aware: for different number of channels you need another descriptor! -#define CFG_TUD_AUDIO_EP_SZ_IN 16 * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX // 16 Samples (16 kHz) x 2 Bytes/Sample x 1 Channel +#define CFG_TUD_AUDIO_EP_SZ_IN (16 + 1) * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX // 16 Samples (16 kHz) x 2 Bytes/Sample x 1 Channel #define CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ_MAX CFG_TUD_AUDIO_EP_SZ_IN // Maximum EP IN size for all AS alternate settings used -#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ CFG_TUD_AUDIO_EP_SZ_IN + 1 +#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ CFG_TUD_AUDIO_EP_SZ_IN #ifdef __cplusplus } diff --git a/examples/usb_microphone/usb_microphone.h b/examples/usb_microphone/usb_microphone.h index 49db81a..cf45b9c 100644 --- a/examples/usb_microphone/usb_microphone.h +++ b/examples/usb_microphone/usb_microphone.h @@ -11,11 +11,11 @@ #include "tusb.h" #ifndef SAMPLE_RATE -#define SAMPLE_RATE (CFG_TUD_AUDIO_EP_SZ_IN / 2) * 1000 +#define SAMPLE_RATE ((CFG_TUD_AUDIO_EP_SZ_IN / 2) - 1) * 1000 #endif #ifndef SAMPLE_BUFFER_SIZE -#define SAMPLE_BUFFER_SIZE (CFG_TUD_AUDIO_EP_SZ_IN/2) +#define SAMPLE_BUFFER_SIZE ((CFG_TUD_AUDIO_EP_SZ_IN/2) - 1) #endif typedef void (*usb_microphone_tx_ready_handler_t)(void);