mirror of
https://github.com/hathach/tinyusb.git
synced 2025-05-09 07:11:16 +08:00
Update audio_test & audio_test_freertos examples to work with high-speed.
This commit is contained in:
parent
4f41e105b3
commit
7dd26877de
@ -42,10 +42,6 @@
|
|||||||
// MACRO CONSTANT TYPEDEF PROTYPES
|
// MACRO CONSTANT TYPEDEF PROTYPES
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
#ifndef AUDIO_SAMPLE_RATE
|
|
||||||
#define AUDIO_SAMPLE_RATE 48000
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Blink pattern
|
/* Blink pattern
|
||||||
* - 250 ms : device not mounted
|
* - 250 ms : device not mounted
|
||||||
* - 1000 ms : device mounted
|
* - 1000 ms : device mounted
|
||||||
@ -90,12 +86,12 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Init values
|
// Init values
|
||||||
sampFreq = AUDIO_SAMPLE_RATE;
|
sampFreq = CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE;
|
||||||
clkValid = 1;
|
clkValid = 1;
|
||||||
|
|
||||||
sampleFreqRng.wNumSubRanges = 1;
|
sampleFreqRng.wNumSubRanges = 1;
|
||||||
sampleFreqRng.subrange[0].bMin = AUDIO_SAMPLE_RATE;
|
sampleFreqRng.subrange[0].bMin = CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE;
|
||||||
sampleFreqRng.subrange[0].bMax = AUDIO_SAMPLE_RATE;
|
sampleFreqRng.subrange[0].bMax = CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE;
|
||||||
sampleFreqRng.subrange[0].bRes = 0;
|
sampleFreqRng.subrange[0].bRes = 0;
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
|
@ -106,6 +106,7 @@ extern "C" {
|
|||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// Have a look into audio_device.h for all configurations
|
// Have a look into audio_device.h for all configurations
|
||||||
|
#define CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE 48000
|
||||||
|
|
||||||
#define CFG_TUD_AUDIO_FUNC_1_DESC_LEN TUD_AUDIO_MIC_ONE_CH_DESC_LEN
|
#define CFG_TUD_AUDIO_FUNC_1_DESC_LEN TUD_AUDIO_MIC_ONE_CH_DESC_LEN
|
||||||
#define CFG_TUD_AUDIO_FUNC_1_N_AS_INT 1 // Number of Standard AS Interface Descriptors (4.9.1) defined per audio function - this is required to be able to remember the current alternate settings of these interfaces - We restrict us here to have a constant number for all audio functions (which means this has to be the maximum number of AS interfaces an audio function has and a second audio function with less AS interfaces just wastes a few bytes)
|
#define CFG_TUD_AUDIO_FUNC_1_N_AS_INT 1 // Number of Standard AS Interface Descriptors (4.9.1) defined per audio function - this is required to be able to remember the current alternate settings of these interfaces - We restrict us here to have a constant number for all audio functions (which means this has to be the maximum number of AS interfaces an audio function has and a second audio function with less AS interfaces just wastes a few bytes)
|
||||||
@ -114,9 +115,9 @@ extern "C" {
|
|||||||
#define CFG_TUD_AUDIO_ENABLE_EP_IN 1
|
#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_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_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 (48 + 1) * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX // 48 Samples (48 kHz) x 2 Bytes/Sample x CFG_TUD_AUDIO_N_CHANNELS_TX Channels - One extra sample is needed for asynchronous transfer adjustment, see feedback EP
|
#define CFG_TUD_AUDIO_EP_SZ_IN TUD_AUDIO_EP_SIZE(CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE, CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX, CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX)
|
||||||
#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_SZ_MAX CFG_TUD_AUDIO_EP_SZ_IN
|
||||||
#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 (TUD_OPT_HIGH_SPEED ? 8 : 1) * CFG_TUD_AUDIO_EP_SZ_IN // Example write FIFO every 1ms, so it should be 8 times larger for HS device
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -66,10 +66,6 @@
|
|||||||
// MACRO CONSTANT TYPEDEF PROTYPES
|
// MACRO CONSTANT TYPEDEF PROTYPES
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
||||||
#ifndef AUDIO_SAMPLE_RATE
|
|
||||||
#define AUDIO_SAMPLE_RATE 48000
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Blink pattern
|
/* Blink pattern
|
||||||
* - 250 ms : device not mounted
|
* - 250 ms : device not mounted
|
||||||
* - 1000 ms : device mounted
|
* - 1000 ms : device mounted
|
||||||
@ -117,12 +113,12 @@ int main(void)
|
|||||||
board_init();
|
board_init();
|
||||||
|
|
||||||
// Init values
|
// Init values
|
||||||
sampFreq = AUDIO_SAMPLE_RATE;
|
sampFreq = CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE;
|
||||||
clkValid = 1;
|
clkValid = 1;
|
||||||
|
|
||||||
sampleFreqRng.wNumSubRanges = 1;
|
sampleFreqRng.wNumSubRanges = 1;
|
||||||
sampleFreqRng.subrange[0].bMin = AUDIO_SAMPLE_RATE;
|
sampleFreqRng.subrange[0].bMin = CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE;
|
||||||
sampleFreqRng.subrange[0].bMax = AUDIO_SAMPLE_RATE;
|
sampleFreqRng.subrange[0].bMax = CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE;
|
||||||
sampleFreqRng.subrange[0].bRes = 0;
|
sampleFreqRng.subrange[0].bRes = 0;
|
||||||
|
|
||||||
#if configSUPPORT_STATIC_ALLOCATION
|
#if configSUPPORT_STATIC_ALLOCATION
|
||||||
|
@ -102,6 +102,7 @@ extern "C" {
|
|||||||
//--------------------------------------------------------------------
|
//--------------------------------------------------------------------
|
||||||
|
|
||||||
// Have a look into audio_device.h for all configurations
|
// Have a look into audio_device.h for all configurations
|
||||||
|
#define CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE 48000
|
||||||
|
|
||||||
#define CFG_TUD_AUDIO_FUNC_1_DESC_LEN TUD_AUDIO_MIC_ONE_CH_DESC_LEN
|
#define CFG_TUD_AUDIO_FUNC_1_DESC_LEN TUD_AUDIO_MIC_ONE_CH_DESC_LEN
|
||||||
#define CFG_TUD_AUDIO_FUNC_1_N_AS_INT 1 // Number of Standard AS Interface Descriptors (4.9.1) defined per audio function - this is required to be able to remember the current alternate settings of these interfaces - We restrict us here to have a constant number for all audio functions (which means this has to be the maximum number of AS interfaces an audio function has and a second audio function with less AS interfaces just wastes a few bytes)
|
#define CFG_TUD_AUDIO_FUNC_1_N_AS_INT 1 // Number of Standard AS Interface Descriptors (4.9.1) defined per audio function - this is required to be able to remember the current alternate settings of these interfaces - We restrict us here to have a constant number for all audio functions (which means this has to be the maximum number of AS interfaces an audio function has and a second audio function with less AS interfaces just wastes a few bytes)
|
||||||
@ -110,9 +111,9 @@ extern "C" {
|
|||||||
#define CFG_TUD_AUDIO_ENABLE_EP_IN 1
|
#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_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_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 48 * CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX * CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX // 48 Samples (48 kHz) x 2 Bytes/Sample x 1 Channel
|
#define CFG_TUD_AUDIO_EP_SZ_IN TUD_AUDIO_EP_SIZE(CFG_TUD_AUDIO_FUNC_1_SAMPLE_RATE, CFG_TUD_AUDIO_FUNC_1_N_BYTES_PER_SAMPLE_TX, CFG_TUD_AUDIO_FUNC_1_N_CHANNELS_TX)
|
||||||
#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_SZ_MAX CFG_TUD_AUDIO_EP_SZ_IN
|
||||||
#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 (TUD_OPT_HIGH_SPEED ? 8 : 1) * CFG_TUD_AUDIO_EP_SZ_IN // Example write FIFO every 1ms, so it should be 8 times larger for HS device
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user