mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-06-30 20:40:59 +02:00
IDF master cf457d412 (#5073)
esp-dsp: master 7cc5073 esp-face: master 420fc7e esp-rainmaker: f1b82c7 esp32-camera: master 2dded7c esp_littlefs: master d268e18
This commit is contained in:
@ -469,44 +469,28 @@ typedef enum
|
||||
/// Additional Audio Device Class Codes - Source: Audio Data Formats
|
||||
|
||||
/// A.1 - Audio Class-Format Type Codes UAC2
|
||||
//typedef enum
|
||||
//{
|
||||
// AUDIO_FORMAT_TYPE_UNDEFINED = 0x00,
|
||||
// AUDIO_FORMAT_TYPE_I = 0x01,
|
||||
// AUDIO_FORMAT_TYPE_II = 0x02,
|
||||
// AUDIO_FORMAT_TYPE_III = 0x03,
|
||||
// AUDIO_FORMAT_TYPE_IV = 0x04,
|
||||
// AUDIO_EXT_FORMAT_TYPE_I = 0x81,
|
||||
// AUDIO_EXT_FORMAT_TYPE_II = 0x82,
|
||||
// AUDIO_EXT_FORMAT_TYPE_III = 0x83,
|
||||
//} audio_format_type_t;
|
||||
typedef enum
|
||||
{
|
||||
AUDIO_FORMAT_TYPE_UNDEFINED = 0x00,
|
||||
AUDIO_FORMAT_TYPE_I = 0x01,
|
||||
AUDIO_FORMAT_TYPE_II = 0x02,
|
||||
AUDIO_FORMAT_TYPE_III = 0x03,
|
||||
AUDIO_FORMAT_TYPE_IV = 0x04,
|
||||
AUDIO_EXT_FORMAT_TYPE_I = 0x81,
|
||||
AUDIO_EXT_FORMAT_TYPE_II = 0x82,
|
||||
AUDIO_EXT_FORMAT_TYPE_III = 0x83,
|
||||
} audio_format_type_t;
|
||||
|
||||
#define AUDIO_FORMAT_TYPE_UNDEFINED 0x00
|
||||
#define AUDIO_FORMAT_TYPE_I 0x01
|
||||
#define AUDIO_FORMAT_TYPE_II 0x02
|
||||
#define AUDIO_FORMAT_TYPE_III 0x03
|
||||
#define AUDIO_FORMAT_TYPE_IV 0x04
|
||||
#define AUDIO_EXT_FORMAT_TYPE_I 0x81
|
||||
#define AUDIO_EXT_FORMAT_TYPE_II 0x82
|
||||
#define AUDIO_EXT_FORMAT_TYPE_III 0x83
|
||||
|
||||
/// A.2.1 - Audio Class-Audio Data Format Type I UAC2
|
||||
//typedef enum
|
||||
//{
|
||||
// AUDIO_DATA_FORMAT_TYPE_I_PCM = (uint32_t) (1 << 0),
|
||||
// AUDIO_DATA_FORMAT_TYPE_I_PCM8 = (uint32_t) (1 << 1),
|
||||
// AUDIO_DATA_FORMAT_TYPE_I_IEEE_FLOAT = (uint32_t) (1 << 2),
|
||||
// AUDIO_DATA_FORMAT_TYPE_I_ALAW = (uint32_t) (1 << 3),
|
||||
// AUDIO_DATA_FORMAT_TYPE_I_MULAW = (uint32_t) (1 << 4),
|
||||
// AUDIO_DATA_FORMAT_TYPE_I_RAW_DATA = 0x100000000,
|
||||
//} audio_data_format_type_I_t;
|
||||
|
||||
#define AUDIO_DATA_FORMAT_TYPE_I_PCM ((uint32_t) (1 << 0))
|
||||
#define AUDIO_DATA_FORMAT_TYPE_I_PCM8 ((uint32_t) (1 << 1))
|
||||
#define AUDIO_DATA_FORMAT_TYPE_I_IEEE_FLOAT ((uint32_t) (1 << 2))
|
||||
#define AUDIO_DATA_FORMAT_TYPE_I_ALAW ((uint32_t) (1 << 3))
|
||||
#define AUDIO_DATA_FORMAT_TYPE_I_MULAW ((uint32_t) (1 << 4))
|
||||
#define AUDIO_DATA_FORMAT_TYPE_I_RAW_DATA 0x100000000
|
||||
// A.2.1 - Audio Class-Audio Data Format Type I UAC2
|
||||
typedef enum
|
||||
{
|
||||
AUDIO_DATA_FORMAT_TYPE_I_PCM = (uint32_t) (1 << 0),
|
||||
AUDIO_DATA_FORMAT_TYPE_I_PCM8 = (uint32_t) (1 << 1),
|
||||
AUDIO_DATA_FORMAT_TYPE_I_IEEE_FLOAT = (uint32_t) (1 << 2),
|
||||
AUDIO_DATA_FORMAT_TYPE_I_ALAW = (uint32_t) (1 << 3),
|
||||
AUDIO_DATA_FORMAT_TYPE_I_MULAW = (uint32_t) (1 << 4),
|
||||
AUDIO_DATA_FORMAT_TYPE_I_RAW_DATA = 0x100000000,
|
||||
} audio_data_format_type_I_t;
|
||||
|
||||
/// All remaining definitions are taken from the descriptor descriptions in the UAC2 main specification
|
||||
|
||||
@ -901,7 +885,7 @@ typedef struct TU_ATTR_PACKED {
|
||||
} subrange[numSubRanges] ; \
|
||||
}
|
||||
|
||||
/// 5.2.3.2 2-byte Control RANGE Parameter Block
|
||||
/// 5.2.3.2 2-byte Control RANGE Parameter Block
|
||||
#define audio_control_range_2_n_t(numSubRanges) \
|
||||
struct TU_ATTR_PACKED { \
|
||||
uint16_t wNumSubRanges; \
|
||||
@ -912,7 +896,7 @@ typedef struct TU_ATTR_PACKED {
|
||||
} subrange[numSubRanges]; \
|
||||
}
|
||||
|
||||
// 5.2.3.3 4-byte Control RANGE Parameter Block
|
||||
// 5.2.3.3 4-byte Control RANGE Parameter Block
|
||||
#define audio_control_range_4_n_t(numSubRanges) \
|
||||
struct TU_ATTR_PACKED { \
|
||||
uint16_t wNumSubRanges; \
|
||||
@ -923,12 +907,12 @@ typedef struct TU_ATTR_PACKED {
|
||||
} subrange[numSubRanges]; \
|
||||
}
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
@ -38,116 +38,306 @@
|
||||
// Class Driver Configuration
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// 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 waste a few bytes)
|
||||
#ifndef CFG_TUD_AUDIO_N_AS_INT
|
||||
#define CFG_TUD_AUDIO_N_AS_INT 0
|
||||
// All sizes are in bytes!
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_DESC_LEN
|
||||
#error You must tell the driver the length of the audio function descriptor including IAD descriptor
|
||||
#endif
|
||||
#if CFG_TUD_AUDIO > 1
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_DESC_LEN
|
||||
#error You must tell the driver the length of the audio function descriptor including IAD descriptor
|
||||
#endif
|
||||
#endif
|
||||
#if CFG_TUD_AUDIO > 2
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_DESC_LEN
|
||||
#error You must tell the driver the length of the audio function descriptor including IAD descriptor
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// 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
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_N_AS_INT
|
||||
#error You must tell the driver the number of Standard AS Interface Descriptors you have defined in the audio function descriptor!
|
||||
#endif
|
||||
#if CFG_TUD_AUDIO > 1
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_N_AS_INT
|
||||
#error You must tell the driver the number of Standard AS Interface Descriptors you have defined in the audio function descriptor!
|
||||
#endif
|
||||
#endif
|
||||
#if CFG_TUD_AUDIO > 2
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_N_AS_INT
|
||||
#error You must tell the driver the number of Standard AS Interface Descriptors you have defined in the audio function descriptor!
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Size of control buffer used to receive and send control messages via EP0 - has to be big enough to hold your biggest request structure e.g. range requests with multiple intervals defined or cluster descriptors
|
||||
#ifndef CFG_TUD_AUDIO_CTRL_BUF_SIZE
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_CTRL_BUF_SZ
|
||||
#error You must define an audio class control request buffer size!
|
||||
#endif
|
||||
|
||||
// Use of TX/RX FIFOs - If sizes are not zero, audio.c implements FIFOs for RX and TX (whatever defined).
|
||||
// For RX: the input stream gets decoded into its corresponding channels, where for each channel a FIFO is setup to hold its data -> see: audio_rx_done_cb().
|
||||
// For TX: the output stream is composed from CFG_TUD_AUDIO_N_CHANNELS_TX channels, where for each channel a FIFO is defined.
|
||||
// Further, it implements encoding and decoding of the individual channels (parameterized by the defines below).
|
||||
// If you don't use the FIFOs you need to handle encoding and decoding on your own in audio_rx_done_cb() and audio_tx_done_cb(). This, however, allows for optimizations.
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_TX_FIFO_SIZE
|
||||
#define CFG_TUD_AUDIO_TX_FIFO_SIZE 0 // Buffer size per channel
|
||||
#if CFG_TUD_AUDIO > 1
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_CTRL_BUF_SZ
|
||||
#error You must define an audio class control request buffer size!
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_RX_FIFO_SIZE
|
||||
#define CFG_TUD_AUDIO_RX_FIFO_SIZE 0 // Buffer size per channel
|
||||
#if CFG_TUD_AUDIO > 2
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_CTRL_BUF_SZ
|
||||
#error You must define an audio class control request buffer size!
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// End point sizes - Limits: Full Speed <= 1023, High Speed <= 1024
|
||||
#ifndef CFG_TUD_AUDIO_EPSIZE_IN
|
||||
#define CFG_TUD_AUDIO_EPSIZE_IN 0 // TX
|
||||
// End point sizes IN BYTES - Limits: Full Speed <= 1023, High Speed <= 1024
|
||||
#ifndef CFG_TUD_AUDIO_ENABLE_EP_IN
|
||||
#define CFG_TUD_AUDIO_ENABLE_EP_IN 0 // TX
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_EPSIZE_OUT
|
||||
#define CFG_TUD_AUDIO_EPSIZE_OUT 0 // RX
|
||||
#ifndef CFG_TUD_AUDIO_ENABLE_EP_OUT
|
||||
#define CFG_TUD_AUDIO_ENABLE_EP_OUT 0 // RX
|
||||
#endif
|
||||
|
||||
// Maximum EP sizes for all alternate AS interface settings - used for checks and buffer allocation
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ_MAX
|
||||
#error You must tell the driver the biggest EP IN size!
|
||||
#endif
|
||||
#if CFG_TUD_AUDIO > 1
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_EP_IN_SZ_MAX
|
||||
#error You must tell the driver the biggest EP IN size!
|
||||
#endif
|
||||
#endif
|
||||
#if CFG_TUD_AUDIO > 2
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_EP_IN_SZ_MAX
|
||||
#error You must tell the driver the biggest EP IN size!
|
||||
#endif
|
||||
#endif
|
||||
#endif // CFG_TUD_AUDIO_ENABLE_EP_IN
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ_MAX
|
||||
#error You must tell the driver the biggest EP OUT size!
|
||||
#endif
|
||||
#if CFG_TUD_AUDIO > 1
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_EP_OUT_SZ_MAX
|
||||
#error You must tell the driver the biggest EP OUT size!
|
||||
#endif
|
||||
#endif
|
||||
#if CFG_TUD_AUDIO > 2
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_EP_OUT_SZ_MAX
|
||||
#error You must tell the driver the biggest EP OUT size!
|
||||
#endif
|
||||
#endif
|
||||
#endif // CFG_TUD_AUDIO_ENABLE_EP_OUT
|
||||
|
||||
// Software EP FIFO buffer sizes - must be >= max EP SIZEs!
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ
|
||||
#define CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ 0
|
||||
#endif
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_EP_IN_SW_BUF_SZ
|
||||
#define CFG_TUD_AUDIO_FUNC_2_EP_IN_SW_BUF_SZ 0
|
||||
#endif
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_EP_IN_SW_BUF_SZ
|
||||
#define CFG_TUD_AUDIO_FUNC_3_EP_IN_SW_BUF_SZ 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_EP_OUT_SW_BUF_SZ
|
||||
#define CFG_TUD_AUDIO_FUNC_1_EP_OUT_SW_BUF_SZ 0
|
||||
#endif
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_EP_OUT_SW_BUF_SZ
|
||||
#define CFG_TUD_AUDIO_FUNC_2_EP_OUT_SW_BUF_SZ 0
|
||||
#endif
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_EP_OUT_SW_BUF_SZ
|
||||
#define CFG_TUD_AUDIO_FUNC_3_EP_OUT_SW_BUF_SZ 0
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN
|
||||
#if CFG_TUD_AUDIO_FUNC_1_EP_IN_SW_BUF_SZ < CFG_TUD_AUDIO_FUNC_1_EP_IN_SZ_MAX
|
||||
#error EP software buffer size MUST BE at least as big as maximum EP size
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO > 1
|
||||
#if CFG_TUD_AUDIO_FUNC_2_EP_IN_SW_BUF_SZ < CFG_TUD_AUDIO_FUNC_2_EP_IN_SZ_MAX
|
||||
#error EP software buffer size MUST BE at least as big as maximum EP size
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO > 2
|
||||
#if CFG_TUD_AUDIO_FUNC_3_EP_IN_SW_BUF_SZ < CFG_TUD_AUDIO_FUNC_3_EP_IN_SZ_MAX
|
||||
#error EP software buffer size MUST BE at least as big as maximum EP size
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT
|
||||
#if CFG_TUD_AUDIO_FUNC_1_EP_OUT_SW_BUF_SZ < CFG_TUD_AUDIO_FUNC_1_EP_OUT_SZ_MAX
|
||||
#error EP software buffer size MUST BE at least as big as maximum EP size
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO > 1
|
||||
#if CFG_TUD_AUDIO_FUNC_2_EP_OUT_SW_BUF_SZ < CFG_TUD_AUDIO_FUNC_2_EP_OUT_SZ_MAX
|
||||
#error EP software buffer size MUST BE at least as big as maximum EP size
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO > 2
|
||||
#if CFG_TUD_AUDIO_FUNC_3_EP_OUT_SW_BUF_SZ < CFG_TUD_AUDIO_FUNC_3_EP_OUT_SZ_MAX
|
||||
#error EP software buffer size MUST BE at least as big as maximum EP size
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Enable/disable feedback EP (required for asynchronous RX applications)
|
||||
#ifndef CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
|
||||
#define CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP 0 // Feedback
|
||||
#define CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP 0 // Feedback - 0 or 1
|
||||
#endif
|
||||
|
||||
// Audio interrupt control EP size - disabled if 0
|
||||
#ifndef CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN
|
||||
#define CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN 0 // Audio interrupt control
|
||||
#define CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN 0 // Audio interrupt control - if required - 6 Bytes according to UAC 2 specification (p. 74)
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN
|
||||
#ifndef CFG_TUD_AUDIO_INT_CTR_BUFSIZE
|
||||
#define CFG_TUD_AUDIO_INT_CTR_BUFSIZE 6 // Buffer size of audio control interrupt EP - 6 Bytes according to UAC 2 specification (p. 74)
|
||||
#ifndef CFG_TUD_AUDIO_INT_CTR_EP_IN_SW_BUFFER_SIZE
|
||||
#define CFG_TUD_AUDIO_INT_CTR_EP_IN_SW_BUFFER_SIZE 6 // Buffer size of audio control interrupt EP - 6 Bytes according to UAC 2 specification (p. 74)
|
||||
#endif
|
||||
|
||||
// Use software encoding/decoding
|
||||
|
||||
// The software coding feature of the driver is not mandatory. It is useful if, for instance, you have two I2S streams which need to be interleaved
|
||||
// into a single PCM stream as SAMPLE_1 | SAMPLE_2 | SAMPLE_3 | SAMPLE_4.
|
||||
//
|
||||
// Currently, only PCM type I encoding/decoding is supported!
|
||||
//
|
||||
// If the coding feature is to be used, support FIFOs need to be configured. Their sizes and numbers are defined below.
|
||||
|
||||
// Encoding/decoding is done in software and thus time consuming. If you can encode/decode your stream more efficiently do not use the
|
||||
// support FIFOs but write/read directly into/from the EP_X_SW_BUFFER_FIFOs using
|
||||
// - tud_audio_n_write() or
|
||||
// - tud_audio_n_read().
|
||||
// To write/read to/from the support FIFOs use
|
||||
// - tud_audio_n_write_support_ff() or
|
||||
// - tud_audio_n_read_support_ff().
|
||||
//
|
||||
// The encoding/decoding format type done is defined below.
|
||||
//
|
||||
// The encoding/decoding starts when the private callback functions
|
||||
// - audio_tx_done_cb()
|
||||
// - audio_rx_done_cb()
|
||||
// are invoked. If support FIFOs are used, the corresponding encoding/decoding functions are called from there.
|
||||
// Once encoding/decoding is done the result is put directly into the EP_X_SW_BUFFER_FIFOs. You can use the public callback functions
|
||||
// - tud_audio_tx_done_pre_load_cb() or tud_audio_tx_done_post_load_cb()
|
||||
// - tud_audio_rx_done_pre_read_cb() or tud_audio_rx_done_post_read_cb()
|
||||
// if you want to get informed what happened.
|
||||
//
|
||||
// If you don't use the support FIFOs you may use the public callback functions
|
||||
// - tud_audio_tx_done_pre_load_cb() or tud_audio_tx_done_post_load_cb()
|
||||
// - tud_audio_rx_done_pre_read_cb() or tud_audio_rx_done_post_read_cb()
|
||||
// to write/read from/into the EP_X_SW_BUFFER_FIFOs at the right time.
|
||||
//
|
||||
// If you need a different encoding which is not support so far implement it in the
|
||||
// - audio_tx_done_cb()
|
||||
// - audio_rx_done_cb()
|
||||
// functions.
|
||||
|
||||
// Enable encoding/decodings - for these to work, support FIFOs need to be setup in appropriate numbers and size
|
||||
// The actual coding parameters of active AS alternate interface is parsed from the descriptors
|
||||
|
||||
// The item size of the FIFO is always fixed to one i.e. bytes! Furthermore, the actively used FIFO depth is reconfigured such that the depth is a multiple of the current sample size in order to avoid samples to get split up in case of a wrap in the FIFO ring buffer (depth = (max_depth / sampe_sz) * sampe_sz)!
|
||||
// This is important to remind in case you use DMAs! If the sample sizes changes, the DMA MUST BE RECONFIGURED just like the FIFOs for a different depth!!!
|
||||
|
||||
// For PCM encoding/decoding
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||
#define CFG_TUD_AUDIO_ENABLE_ENCODING 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_ENABLE_DECODING
|
||||
#define CFG_TUD_AUDIO_ENABLE_DECODING 0
|
||||
#endif
|
||||
|
||||
// This enabling allows to save the current coding parameters e.g. # of bytes per sample etc. - TYPE_I includes common PCM encoding
|
||||
#ifndef CFG_TUD_AUDIO_ENABLE_TYPE_I_ENCODING
|
||||
#define CFG_TUD_AUDIO_ENABLE_TYPE_I_ENCODING 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_ENABLE_TYPE_I_DECODING
|
||||
#define CFG_TUD_AUDIO_ENABLE_TYPE_I_DECODING 0
|
||||
#endif
|
||||
|
||||
// Type I Coding parameters not given within UAC2 descriptors
|
||||
// It would be possible to allow for a more flexible setting and not fix this parameter as done below. However, this is most often not needed and kept for later if really necessary. The more flexible setting could be implemented within set_interface(), however, how the values are saved per alternate setting is to be determined!
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_ENABLE_ENCODING && CFG_TUD_AUDIO_ENABLE_TYPE_I_ENCODING
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_CHANNEL_PER_FIFO_TX
|
||||
#error You must tell the driver the number of channels per FIFO for the interleaved encoding! E.g. for an I2S interface having two channels, CHANNEL_PER_FIFO = 2 as the I2S stream having two channels is usually saved within one FIFO
|
||||
#endif
|
||||
#if CFG_TUD_AUDIO > 1
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_CHANNEL_PER_FIFO_TX
|
||||
#error You must tell the driver the number of channels per FIFO for the interleaved encoding! E.g. for an I2S interface having two channels, CHANNEL_PER_FIFO = 2 as the I2S stream having two channels is usually saved within one FIFO
|
||||
#endif
|
||||
#endif
|
||||
#if CFG_TUD_AUDIO > 2
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_CHANNEL_PER_FIFO_TX
|
||||
#error You must tell the driver the number of channels per FIFO for the interleaved encoding! E.g. for an I2S interface having two channels, CHANNEL_PER_FIFO = 2 as the I2S stream having two channels is usually saved within one FIFO
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_N_CHANNELS_TX
|
||||
#define CFG_TUD_AUDIO_N_CHANNELS_TX 1
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_DECODING && CFG_TUD_AUDIO_ENABLE_TYPE_I_DECODING
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_CHANNEL_PER_FIFO_RX
|
||||
#error You must tell the driver the number of channels per FIFO for the interleaved encoding! E.g. for an I2S interface having two channels, CHANNEL_PER_FIFO = 2 as the I2S stream having two channels is usually saved within one FIFO
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_N_CHANNELS_RX
|
||||
#define CFG_TUD_AUDIO_N_CHANNELS_RX 1
|
||||
#if CFG_TUD_AUDIO > 1
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_CHANNEL_PER_FIFO_RX
|
||||
#error You must tell the driver the number of channels per FIFO for the interleaved encoding! E.g. for an I2S interface having two channels, CHANNEL_PER_FIFO = 2 as the I2S stream having two channels is usually saved within one FIFO
|
||||
#endif
|
||||
|
||||
// Audio data format types
|
||||
#ifndef CFG_TUD_AUDIO_FORMAT_TYPE_TX
|
||||
#define CFG_TUD_AUDIO_FORMAT_TYPE_TX AUDIO_FORMAT_TYPE_UNDEFINED // If this option is used, an encoding function has to be implemented in audio_device.c
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_FORMAT_TYPE_RX
|
||||
#define CFG_TUD_AUDIO_FORMAT_TYPE_RX AUDIO_FORMAT_TYPE_UNDEFINED // If this option is used, a decoding function has to be implemented in audio_device.c
|
||||
#if CFG_TUD_AUDIO > 2
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_CHANNEL_PER_FIFO_RX
|
||||
#error You must tell the driver the number of channels per FIFO for the interleaved encoding! E.g. for an I2S interface having two channels, CHANNEL_PER_FIFO = 2 as the I2S stream having two channels is usually saved within one FIFO
|
||||
#endif
|
||||
|
||||
// Audio data format type I specifications
|
||||
#if CFG_TUD_AUDIO_FORMAT_TYPE_TX == AUDIO_FORMAT_TYPE_I
|
||||
|
||||
// Type definitions - for possible formats see: audio_data_format_type_I_t and further in UAC2 specifications.
|
||||
#ifndef CFG_TUD_AUDIO_FORMAT_TYPE_I_TX
|
||||
#define CFG_TUD_AUDIO_FORMAT_TYPE_I_TX AUDIO_DATA_FORMAT_TYPE_I_PCM
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_TX // bSubslotSize
|
||||
#define CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_TX 1
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_TX_ITEMSIZE
|
||||
#if CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_TX == 1
|
||||
#define CFG_TUD_AUDIO_TX_ITEMSIZE 1
|
||||
#elif CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_TX == 2
|
||||
#define CFG_TUD_AUDIO_TX_ITEMSIZE 2
|
||||
#else
|
||||
#define CFG_TUD_AUDIO_TX_ITEMSIZE 4
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_TX_ITEMSIZE < CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_TX
|
||||
#error FIFO element size (ITEMSIZE) must not be smaller then sample size
|
||||
// Remaining types not support so far
|
||||
|
||||
// Number of support FIFOs to set up - multiple channels can be handled by one FIFO - very common is two channels per FIFO stemming from one I2S interface
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_N_TX_SUPP_SW_FIFO
|
||||
#define CFG_TUD_AUDIO_FUNC_1_N_TX_SUPP_SW_FIFO 0
|
||||
#endif
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_N_TX_SUPP_SW_FIFO
|
||||
#define CFG_TUD_AUDIO_FUNC_2_N_TX_SUPP_SW_FIFO 0
|
||||
#endif
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_N_TX_SUPP_SW_FIFO
|
||||
#define CFG_TUD_AUDIO_FUNC_3_N_TX_SUPP_SW_FIFO 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_N_RX_SUPP_SW_FIFO
|
||||
#define CFG_TUD_AUDIO_FUNC_1_N_RX_SUPP_SW_FIFO 0
|
||||
#endif
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_N_RX_SUPP_SW_FIFO
|
||||
#define CFG_TUD_AUDIO_FUNC_2_N_RX_SUPP_SW_FIFO 0
|
||||
#endif
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_N_RX_SUPP_SW_FIFO
|
||||
#define CFG_TUD_AUDIO_FUNC_3_N_RX_SUPP_SW_FIFO 0
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_FORMAT_TYPE_RX == AUDIO_FORMAT_TYPE_I
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_FORMAT_TYPE_I_RX
|
||||
#define CFG_TUD_AUDIO_FORMAT_TYPE_I_RX AUDIO_DATA_FORMAT_TYPE_I_PCM
|
||||
// Size of support FIFOs IN BYTES - if size > 0 there are as many FIFOs set up as CFG_TUD_AUDIO_FUNC_X_N_TX_SUPP_SW_FIFO and CFG_TUD_AUDIO_FUNC_X_N_RX_SUPP_SW_FIFO
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_TX_SUPP_SW_FIFO_SZ
|
||||
#define CFG_TUD_AUDIO_FUNC_1_TX_SUPP_SW_FIFO_SZ 0 // FIFO size - minimum size: ceil(f_s/1000) * max(# of TX channels) / (# of TX support FIFOs) * max(# of bytes per sample)
|
||||
#endif
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_TX_SUPP_SW_FIFO_SZ
|
||||
#define CFG_TUD_AUDIO_FUNC_2_TX_SUPP_SW_FIFO_SZ 0
|
||||
#endif
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_TX_SUPP_SW_FIFO_SZ
|
||||
#define CFG_TUD_AUDIO_FUNC_3_TX_SUPP_SW_FIFO_SZ 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_RX // bSubslotSize
|
||||
#define CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_RX 1
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_1_RX_SUPP_SW_FIFO_SZ
|
||||
#define CFG_TUD_AUDIO_FUNC_1_RX_SUPP_SW_FIFO_SZ 0 // FIFO size - minimum size: ceil(f_s/1000) * max(# of RX channels) / (# of RX support FIFOs) * max(# of bytes per sample)
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_RX == 1
|
||||
#define CFG_TUD_AUDIO_RX_ITEMSIZE 1
|
||||
#elif CFG_TUD_AUDIO_N_BYTES_PER_SAMPLE_RX == 2
|
||||
#define CFG_TUD_AUDIO_RX_ITEMSIZE 2
|
||||
#else
|
||||
#define CFG_TUD_AUDIO_RX_ITEMSIZE 4
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_2_RX_SUPP_SW_FIFO_SZ
|
||||
#define CFG_TUD_AUDIO_FUNC_2_RX_SUPP_SW_FIFO_SZ 0
|
||||
#endif
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_FUNC_3_RX_SUPP_SW_FIFO_SZ
|
||||
#define CFG_TUD_AUDIO_FUNC_3_RX_SUPP_SW_FIFO_SZ 0
|
||||
#endif
|
||||
|
||||
//static_assert(sizeof(tud_audio_desc_lengths) != CFG_TUD_AUDIO, "Supply audio function descriptor pack length!");
|
||||
@ -170,69 +360,70 @@ extern "C" {
|
||||
//--------------------------------------------------------------------+
|
||||
bool tud_audio_n_mounted (uint8_t itf);
|
||||
|
||||
#if CFG_TUD_AUDIO_EPSIZE_OUT && CFG_TUD_AUDIO_RX_FIFO_SIZE
|
||||
#if CFG_TUD_AUDIO_RX_FIFO_COUNT > 1
|
||||
uint16_t tud_audio_n_available (uint8_t itf, uint8_t channelId);
|
||||
uint16_t tud_audio_n_read (uint8_t itf, uint8_t channelId, void* buffer, uint16_t bufsize);
|
||||
void tud_audio_n_read_flush (uint8_t itf, uint8_t channelId);
|
||||
#else
|
||||
uint16_t tud_audio_n_available (uint8_t itf);
|
||||
uint16_t tud_audio_n_read (uint8_t itf, void* buffer, uint16_t bufsize);
|
||||
void tud_audio_n_read_flush (uint8_t itf);
|
||||
#endif
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && !CFG_TUD_AUDIO_ENABLE_DECODING
|
||||
uint16_t tud_audio_n_available (uint8_t itf);
|
||||
uint16_t tud_audio_n_read (uint8_t itf, void* buffer, uint16_t bufsize);
|
||||
bool tud_audio_n_clear_ep_out_ff (uint8_t itf); // Delete all content in the EP OUT FIFO
|
||||
#endif
|
||||
|
||||
/* This function is intended for later use once EP buffers (at least for ISO EPs) are implemented as ring buffers
|
||||
#if CFG_TUD_AUDIO_EPSIZE_IN && !CFG_TUD_AUDIO_TX_FIFO_SIZE
|
||||
uint16_t tud_audio_n_write_ep_in_buffer(uint8_t itf, const void * data, uint16_t len)
|
||||
#endif
|
||||
*/
|
||||
|
||||
#ifndef CFG_TUD_AUDIO_TX_FIFO_COUNT
|
||||
#define CFG_TUD_AUDIO_TX_FIFO_COUNT 1
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_DECODING
|
||||
bool tud_audio_n_clear_rx_support_ff (uint8_t itf, uint8_t channelId); // Delete all content in the support RX FIFOs
|
||||
uint16_t tud_audio_n_available_support_ff (uint8_t itf, uint8_t channelId);
|
||||
uint16_t tud_audio_n_read_support_ff (uint8_t itf, uint8_t channelId, void* buffer, uint16_t bufsize);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_EPSIZE_IN && CFG_TUD_AUDIO_TX_FIFO_SIZE
|
||||
#if CFG_TUD_AUDIO_TX_FIFO_COUNT > 1
|
||||
uint16_t tud_audio_n_write (uint8_t itf, uint8_t channelId, const void * data, uint16_t len);
|
||||
#else
|
||||
uint16_t tud_audio_n_write (uint8_t itf, const void * data, uint16_t len);
|
||||
#endif
|
||||
uint16_t tud_audio_n_write_flush(uint8_t itf);
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN && !CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||
uint16_t tud_audio_n_write (uint8_t itf, const void * data, uint16_t len);
|
||||
bool tud_audio_n_clear_ep_in_ff (uint8_t itf); // Delete all content in the EP IN FIFO
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN > 0
|
||||
uint16_t tud_audio_int_ctr_n_available (uint8_t itf);
|
||||
uint16_t tud_audio_int_ctr_n_read (uint8_t itf, void* buffer, uint16_t bufsize);
|
||||
void tud_audio_int_ctr_n_read_flush (uint8_t itf);
|
||||
uint16_t tud_audio_int_ctr_n_write (uint8_t itf, uint8_t const* buffer, uint16_t bufsize);
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||
uint16_t tud_audio_n_flush_tx_support_ff (uint8_t itf); // Force all content in the support TX FIFOs to be written into EP SW FIFO
|
||||
bool tud_audio_n_clear_tx_support_ff (uint8_t itf, uint8_t channelId);
|
||||
uint16_t tud_audio_n_write_support_ff (uint8_t itf, uint8_t channelId, const void * data, uint16_t len);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN
|
||||
uint16_t tud_audio_int_ctr_n_write (uint8_t itf, uint8_t const* buffer, uint16_t len);
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Application API (Interface0)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
static inline bool tud_audio_mounted (void);
|
||||
static inline bool tud_audio_mounted (void);
|
||||
|
||||
#if CFG_TUD_AUDIO_EPSIZE_OUT && CFG_TUD_AUDIO_RX_FIFO_SIZE
|
||||
static inline uint16_t tud_audio_available (void);
|
||||
static inline uint16_t tud_audio_read (void* buffer, uint16_t bufsize);
|
||||
static inline void tud_audio_read_flush (void);
|
||||
// RX API
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && !CFG_TUD_AUDIO_ENABLE_DECODING
|
||||
static inline uint16_t tud_audio_available (void);
|
||||
static inline bool tud_audio_clear_ep_out_ff (void); // Delete all content in the EP OUT FIFO
|
||||
static inline uint16_t tud_audio_read (void* buffer, uint16_t bufsize);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_EPSIZE_IN && CFG_TUD_AUDIO_TX_FIFO_SIZE
|
||||
#if CFG_TUD_AUDIO_TX_FIFO_COUNT > 1
|
||||
static inline uint16_t tud_audio_write (uint8_t channelId, uint8_t const* buffer, uint16_t bufsize);
|
||||
#else
|
||||
static inline uint16_t tud_audio_write (uint8_t const* buffer, uint16_t bufsize);
|
||||
#endif
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_DECODING
|
||||
static inline bool tud_audio_clear_rx_support_ff (uint8_t channelId);
|
||||
static inline uint16_t tud_audio_available_support_ff (uint8_t channelId);
|
||||
static inline uint16_t tud_audio_read_support_ff (uint8_t channelId, void* buffer, uint16_t bufsize);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN > 0
|
||||
static inline uint32_t tud_audio_int_ctr_available (void);
|
||||
static inline uint32_t tud_audio_int_ctr_read (void* buffer, uint32_t bufsize);
|
||||
static inline void tud_audio_int_ctr_read_flush (void);
|
||||
static inline uint32_t tud_audio_int_ctr_write (uint8_t const* buffer, uint32_t bufsize);
|
||||
// TX API
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN && !CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||
static inline uint16_t tud_audio_write (const void * data, uint16_t len);
|
||||
static inline bool tud_audio_clear_ep_in_ff (void);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||
static inline uint16_t tud_audio_flush_tx_support_ff (void);
|
||||
static inline uint16_t tud_audio_clear_tx_support_ff (uint8_t channelId);
|
||||
static inline uint16_t tud_audio_write_support_ff (uint8_t channelId, const void * data, uint16_t len);
|
||||
#endif
|
||||
|
||||
// INT CTR API
|
||||
|
||||
#if CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN
|
||||
static inline uint16_t tud_audio_int_ctr_write (uint8_t const* buffer, uint16_t len);
|
||||
#endif
|
||||
|
||||
// Buffer control EP data and schedule a transmit
|
||||
@ -247,26 +438,28 @@ bool tud_audio_buffer_and_schedule_control_xfer(uint8_t rhport, tusb_control_req
|
||||
// Application Callback API (weak is optional)
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
#if CFG_TUD_AUDIO_EPSIZE_IN
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN
|
||||
TU_ATTR_WEAK bool tud_audio_tx_done_pre_load_cb(uint8_t rhport, uint8_t itf, uint8_t ep_in, uint8_t cur_alt_setting);
|
||||
TU_ATTR_WEAK bool tud_audio_tx_done_post_load_cb(uint8_t rhport, uint16_t n_bytes_copied, uint8_t itf, uint8_t ep_in, uint8_t cur_alt_setting);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_EPSIZE_OUT
|
||||
TU_ATTR_WEAK bool tud_audio_rx_done_cb(uint8_t rhport, uint8_t * buffer, uint16_t bufsize);
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT
|
||||
TU_ATTR_WEAK bool tud_audio_rx_done_pre_read_cb(uint8_t rhport, uint16_t n_bytes_received, uint8_t itf, uint8_t ep_out, uint8_t cur_alt_setting);
|
||||
TU_ATTR_WEAK bool tud_audio_rx_done_post_read_cb(uint8_t rhport, uint16_t n_bytes_received, uint8_t itf, uint8_t ep_out, uint8_t cur_alt_setting);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_EPSIZE_OUT > 0 && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
|
||||
TU_ATTR_WEAK bool tud_audio_fb_done_cb(uint8_t rhport);
|
||||
// User code should call this function with feedback value in 16.16 format for FS and HS.
|
||||
// Value will be corrected for FS to 10.14 format automatically.
|
||||
// (see Universal Serial Bus Specification Revision 2.0 5.12.4.2).
|
||||
// Feedback value will be sent at FB endpoint interval till it's changed.
|
||||
bool tud_audio_fb_set(uint8_t rhport, uint32_t feedback);
|
||||
bool tud_audio_n_fb_set(uint8_t itf, uint32_t feedback);
|
||||
static inline bool tud_audio_fb_set(uint32_t feedback);
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN
|
||||
TU_ATTR_WEAK bool tud_audio_int_ctr_done_cb(uint8_t rhport, uint16_t * n_bytes_copied);
|
||||
TU_ATTR_WEAK bool tud_audio_int_ctr_done_cb(uint8_t rhport, uint16_t n_bytes_copied);
|
||||
#endif
|
||||
|
||||
// Invoked when audio set interface request received
|
||||
@ -302,93 +495,103 @@ static inline bool tud_audio_mounted(void)
|
||||
return tud_audio_n_mounted(0);
|
||||
}
|
||||
|
||||
#if CFG_TUD_AUDIO_EPSIZE_IN
|
||||
#if CFG_TUD_AUDIO_TX_FIFO_SIZE && CFG_TUD_AUDIO_TX_FIFO_COUNT > 1
|
||||
static inline uint16_t tud_audio_write (uint8_t channelId, uint8_t const* buffer, uint16_t n_bytes) // Short version if only one audio function is used
|
||||
{
|
||||
return tud_audio_n_write(0, channelId, buffer, n_bytes);
|
||||
}
|
||||
#else
|
||||
static inline uint16_t tud_audio_write (uint8_t const* buffer, uint16_t n_bytes) // Short version if only one audio function is used
|
||||
{
|
||||
return tud_audio_n_write(0, buffer, n_bytes);
|
||||
}
|
||||
#endif
|
||||
// RX API
|
||||
|
||||
static inline uint16_t tud_audio_write_flush (void) // Short version if only one audio function is used
|
||||
{
|
||||
#if CFG_TUD_AUDIO_TX_FIFO_SIZE
|
||||
return tud_audio_n_write_flush(0);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif // CFG_TUD_AUDIO_EPSIZE_IN && CFG_TUD_AUDIO_TX_FIFO_SIZE
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && !CFG_TUD_AUDIO_ENABLE_DECODING
|
||||
|
||||
#if CFG_TUD_AUDIO_EPSIZE_OUT && CFG_TUD_AUDIO_RX_FIFO_SIZE
|
||||
#if CFG_TUD_AUDIO_RX_FIFO_COUNT > 1
|
||||
static inline uint16_t tud_audio_available(uint8_t channelId)
|
||||
{
|
||||
return tud_audio_n_available(0, channelId);
|
||||
}
|
||||
|
||||
static inline uint16_t tud_audio_read(uint8_t channelId, void* buffer, uint16_t bufsize)
|
||||
{
|
||||
return tud_audio_n_read(0, channelId, buffer, bufsize);
|
||||
}
|
||||
|
||||
static inline void tud_audio_read_flush(uint8_t channelId)
|
||||
{
|
||||
tud_audio_n_read_flush(0, channelId);
|
||||
}
|
||||
#else
|
||||
static inline uint16_t tud_audio_available(void)
|
||||
{
|
||||
return tud_audio_n_available(0);
|
||||
}
|
||||
|
||||
static inline uint16_t tud_audio_read(void *buffer, uint16_t bufsize)
|
||||
static inline uint16_t tud_audio_read(void* buffer, uint16_t bufsize)
|
||||
{
|
||||
return tud_audio_n_read(0, buffer, bufsize);
|
||||
}
|
||||
|
||||
static inline void tud_audio_read_flush(void)
|
||||
static inline bool tud_audio_clear_ep_out_ff(void)
|
||||
{
|
||||
tud_audio_n_read_flush(0);
|
||||
return tud_audio_n_clear_ep_out_ff(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN > 0
|
||||
static inline uint16_t tud_audio_int_ctr_available(void)
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_DECODING
|
||||
|
||||
static inline bool tud_audio_clear_rx_support_ff(uint8_t channelId)
|
||||
{
|
||||
return tud_audio_int_ctr_n_available(0);
|
||||
return tud_audio_n_clear_rx_support_ff(0, channelId);
|
||||
}
|
||||
|
||||
static inline uint16_t tud_audio_int_ctr_read(void* buffer, uint16_t bufsize)
|
||||
static inline uint16_t tud_audio_available_support_ff(uint8_t channelId)
|
||||
{
|
||||
return tud_audio_int_ctr_n_read(0, buffer, bufsize);
|
||||
return tud_audio_n_available_support_ff(0, channelId);
|
||||
}
|
||||
|
||||
static inline void tud_audio_int_ctr_read_flush(void)
|
||||
static inline uint16_t tud_audio_read_support_ff(uint8_t channelId, void* buffer, uint16_t bufsize)
|
||||
{
|
||||
return tud_audio_int_ctr_n_read_flush(0);
|
||||
return tud_audio_n_read_support_ff(0, channelId, buffer, bufsize);
|
||||
}
|
||||
|
||||
static inline uint16_t tud_audio_int_ctr_write(uint8_t const* buffer, uint16_t bufsize)
|
||||
#endif
|
||||
|
||||
// TX API
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN && !CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||
|
||||
static inline uint16_t tud_audio_write(const void * data, uint16_t len)
|
||||
{
|
||||
return tud_audio_int_ctr_n_write(0, buffer, bufsize);
|
||||
return tud_audio_n_write(0, data, len);
|
||||
}
|
||||
|
||||
static inline bool tud_audio_clear_ep_in_ff(void)
|
||||
{
|
||||
return tud_audio_n_clear_ep_in_ff(0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_IN && CFG_TUD_AUDIO_ENABLE_ENCODING
|
||||
|
||||
static inline uint16_t tud_audio_flush_tx_support_ff(void)
|
||||
{
|
||||
return tud_audio_n_flush_tx_support_ff(0);
|
||||
}
|
||||
|
||||
static inline uint16_t tud_audio_clear_tx_support_ff(uint8_t channelId)
|
||||
{
|
||||
return tud_audio_n_clear_tx_support_ff(0, channelId);
|
||||
}
|
||||
|
||||
static inline uint16_t tud_audio_write_support_ff(uint8_t channelId, const void * data, uint16_t len)
|
||||
{
|
||||
return tud_audio_n_write_support_ff(0, channelId, data, len);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_INT_CTR_EPSIZE_IN
|
||||
static inline uint16_t tud_audio_int_ctr_write(uint8_t const* buffer, uint16_t len)
|
||||
{
|
||||
return tud_audio_int_ctr_n_write(0, buffer, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CFG_TUD_AUDIO_ENABLE_EP_OUT && CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
|
||||
static inline bool tud_audio_fb_set(uint32_t feedback)
|
||||
{
|
||||
return tud_audio_n_fb_set(0, feedback);
|
||||
}
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Internal Class Driver API
|
||||
//--------------------------------------------------------------------+
|
||||
void audiod_init (void);
|
||||
void audiod_reset (uint8_t rhport);
|
||||
uint16_t audiod_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
bool audiod_control_xfer_cb (uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
||||
bool audiod_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
void audiod_init (void);
|
||||
void audiod_reset (uint8_t rhport);
|
||||
uint16_t audiod_open (uint8_t rhport, tusb_desc_interface_t const * itf_desc, uint16_t max_len);
|
||||
bool audiod_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request);
|
||||
bool audiod_xfer_cb (uint8_t rhport, uint8_t edpt_addr, xfer_result_t result, uint32_t xferred_bytes);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Ha Thach (tinyusb.org)
|
||||
* Copyright (c) 2020 Reinhard Panhuber - rework to unmasked pointers
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@ -52,10 +53,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#if CFG_FIFO_MUTEX
|
||||
#include "osal/osal.h"
|
||||
#define tu_fifo_mutex_t osal_mutex_t
|
||||
#endif
|
||||
|
||||
|
||||
/** \struct tu_fifo_t
|
||||
* \brief Simple Circular FIFO
|
||||
*/
|
||||
@ -66,14 +67,15 @@ typedef struct
|
||||
uint16_t item_size ; ///< size of each item
|
||||
bool overwritable ;
|
||||
|
||||
uint16_t max_pointer_idx ; ///< maximum absolute pointer index
|
||||
uint16_t non_used_index_space ; ///< required for non-power-of-two buffer length
|
||||
uint16_t max_pointer_idx ; ///< maximum absolute pointer index
|
||||
|
||||
volatile uint16_t wr_idx ; ///< write pointer
|
||||
volatile uint16_t rd_idx ; ///< read pointer
|
||||
|
||||
#if CFG_FIFO_MUTEX
|
||||
tu_fifo_mutex_t mutex;
|
||||
tu_fifo_mutex_t mutex_wr;
|
||||
tu_fifo_mutex_t mutex_rd;
|
||||
#endif
|
||||
|
||||
} tu_fifo_t;
|
||||
@ -85,29 +87,33 @@ typedef struct
|
||||
.item_size = sizeof(_type), \
|
||||
.overwritable = _overwritable, \
|
||||
.max_pointer_idx = 2*(_depth)-1, \
|
||||
.non_used_index_space = UINT16_MAX - (2*(_depth)-1) \
|
||||
.non_used_index_space = UINT16_MAX - (2*(_depth)-1), \
|
||||
}
|
||||
|
||||
#define TU_FIFO_DEF(_name, _depth, _type, _overwritable) \
|
||||
uint8_t _name##_buf[_depth*sizeof(_type)]; \
|
||||
tu_fifo_t _name = TU_FIFO_INIT(_name##_buf, _depth, _type, _overwritable)
|
||||
|
||||
|
||||
bool tu_fifo_set_overwritable(tu_fifo_t *f, bool overwritable);
|
||||
bool tu_fifo_clear(tu_fifo_t *f);
|
||||
bool tu_fifo_config(tu_fifo_t *f, void* buffer, uint16_t depth, uint16_t item_size, bool overwritable);
|
||||
|
||||
#if CFG_FIFO_MUTEX
|
||||
static inline void tu_fifo_config_mutex(tu_fifo_t *f, tu_fifo_mutex_t mutex_hdl)
|
||||
static inline void tu_fifo_config_mutex(tu_fifo_t *f, tu_fifo_mutex_t write_mutex_hdl, tu_fifo_mutex_t read_mutex_hdl)
|
||||
{
|
||||
f->mutex = mutex_hdl;
|
||||
f->mutex_wr = write_mutex_hdl;
|
||||
f->mutex_rd = read_mutex_hdl;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool tu_fifo_write (tu_fifo_t* f, void const * p_data);
|
||||
uint16_t tu_fifo_write_n (tu_fifo_t* f, void const * p_data, uint16_t count);
|
||||
uint16_t tu_fifo_write_n (tu_fifo_t* f, void const * p_data, uint16_t n);
|
||||
uint16_t tu_fifo_write_n_const_addr_full_words (tu_fifo_t* f, const void * data, uint16_t n);
|
||||
|
||||
bool tu_fifo_read (tu_fifo_t* f, void * p_buffer);
|
||||
uint16_t tu_fifo_read_n (tu_fifo_t* f, void * p_buffer, uint16_t count);
|
||||
uint16_t tu_fifo_read_n (tu_fifo_t* f, void * p_buffer, uint16_t n);
|
||||
uint16_t tu_fifo_read_n_const_addr_full_words (tu_fifo_t* f, void * buffer, uint16_t n);
|
||||
|
||||
bool tu_fifo_peek_at (tu_fifo_t* f, uint16_t pos, void * p_buffer);
|
||||
uint16_t tu_fifo_peek_at_n (tu_fifo_t* f, uint16_t pos, void * p_buffer, uint16_t n);
|
||||
@ -116,7 +122,7 @@ uint16_t tu_fifo_count (tu_fifo_t* f);
|
||||
bool tu_fifo_empty (tu_fifo_t* f);
|
||||
bool tu_fifo_full (tu_fifo_t* f);
|
||||
uint16_t tu_fifo_remaining (tu_fifo_t* f);
|
||||
bool tu_fifo_overflowed (tu_fifo_t* f);
|
||||
bool tu_fifo_overflowed (tu_fifo_t* f);
|
||||
void tu_fifo_correct_read_pointer (tu_fifo_t* f);
|
||||
|
||||
// Pointer modifications intended to be used in combinations with DMAs.
|
||||
@ -124,6 +130,13 @@ void tu_fifo_correct_read_pointer (tu_fifo_t* f);
|
||||
void tu_fifo_advance_write_pointer (tu_fifo_t *f, uint16_t n);
|
||||
void tu_fifo_advance_read_pointer (tu_fifo_t *f, uint16_t n);
|
||||
|
||||
// If you want to read/write from/to the FIFO by use of a DMA, you may need to conduct two copies to handle a possible wrapping part
|
||||
// This functions deliver a pointer to start reading/writing from/to and a valid linear length along which no wrap occurs.
|
||||
// In case not all of your data is available within one read/write, update the read/write pointer by
|
||||
// tu_fifo_advance_read_pointer()/tu_fifo_advance_write_pointer and conduct a second read/write operation
|
||||
uint16_t tu_fifo_get_linear_read_info (tu_fifo_t *f, uint16_t offset, void **ptr, uint16_t n);
|
||||
uint16_t tu_fifo_get_linear_write_info (tu_fifo_t *f, uint16_t offset, void **ptr, uint16_t n);
|
||||
|
||||
static inline bool tu_fifo_peek(tu_fifo_t* f, void * p_buffer)
|
||||
{
|
||||
return tu_fifo_peek_at(f, 0, p_buffer);
|
||||
|
@ -32,6 +32,7 @@
|
||||
#define _TUSB_DCD_H_
|
||||
|
||||
#include "common/tusb_common.h"
|
||||
#include "common/tusb_fifo.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -124,20 +125,24 @@ void dcd_disconnect(uint8_t rhport) TU_ATTR_WEAK;
|
||||
void dcd_edpt0_status_complete(uint8_t rhport, tusb_control_request_t const * request) TU_ATTR_WEAK;
|
||||
|
||||
// Configure endpoint's registers according to descriptor
|
||||
bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc);
|
||||
bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc);
|
||||
|
||||
// Close an endpoint.
|
||||
// Since it is weak, caller must TU_ASSERT this function's existence before calling it.
|
||||
void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr) TU_ATTR_WEAK;
|
||||
void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr) TU_ATTR_WEAK;
|
||||
|
||||
// Submit a transfer, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
|
||||
bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
|
||||
|
||||
// Submit an transfer using fifo, When complete dcd_event_xfer_complete() is invoked to notify the stack
|
||||
// This API is optional, may be useful for register-based for transferring data.
|
||||
bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes) TU_ATTR_WEAK;
|
||||
|
||||
// Stall endpoint
|
||||
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr);
|
||||
void dcd_edpt_stall (uint8_t rhport, uint8_t ep_addr);
|
||||
|
||||
// clear stall, data toggle is also reset to DATA0
|
||||
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr);
|
||||
void dcd_edpt_clear_stall (uint8_t rhport, uint8_t ep_addr);
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Event API (implemented by stack)
|
||||
|
@ -353,6 +353,10 @@ TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb
|
||||
#define TUD_AUDIO_DESC_FEATURE_UNIT_TWO_CHANNEL_LEN (6+(2+1)*4)
|
||||
#define TUD_AUDIO_DESC_FEATURE_UNIT_TWO_CHANNEL(_unitid, _srcid, _ctrlch0master, _ctrlch1, _ctrlch2, _stridx) \
|
||||
TUD_AUDIO_DESC_FEATURE_UNIT_TWO_CHANNEL_LEN, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_FEATURE_UNIT, _unitid, _srcid, U32_TO_U8S_LE(_ctrlch0master), U32_TO_U8S_LE(_ctrlch1), U32_TO_U8S_LE(_ctrlch2), _stridx
|
||||
// 4 - Channels
|
||||
#define TUD_AUDIO_DESC_FEATURE_UNIT_FOUR_CHANNEL_LEN (6+(4+1)*4)
|
||||
#define TUD_AUDIO_DESC_FEATURE_UNIT_FOUR_CHANNEL(_unitid, _srcid, _ctrlch0master, _ctrlch1, _ctrlch2, _ctrlch3, _ctrlch4, _stridx) \
|
||||
TUD_AUDIO_DESC_FEATURE_UNIT_FOUR_CHANNEL_LEN, TUSB_DESC_CS_INTERFACE, AUDIO_CS_AC_INTERFACE_FEATURE_UNIT, _unitid, _srcid, U32_TO_U8S_LE(_ctrlch0master), U32_TO_U8S_LE(_ctrlch1), U32_TO_U8S_LE(_ctrlch2), U32_TO_U8S_LE(_ctrlch3), U32_TO_U8S_LE(_ctrlch4), _stridx
|
||||
|
||||
// For more channels, add definitions here
|
||||
|
||||
@ -389,7 +393,7 @@ TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb
|
||||
// AUDIO simple descriptor (UAC2) for 1 microphone input
|
||||
// - 1 Input Terminal, 1 Feature Unit (Mute and Volume Control), 1 Output Terminal, 1 Clock Source
|
||||
|
||||
#define TUD_AUDIO_MIC_DESC_LEN (TUD_AUDIO_DESC_IAD_LEN\
|
||||
#define TUD_AUDIO_MIC_ONE_CH_DESC_LEN (TUD_AUDIO_DESC_IAD_LEN\
|
||||
+ TUD_AUDIO_DESC_STD_AC_LEN\
|
||||
+ TUD_AUDIO_DESC_CS_AC_LEN\
|
||||
+ TUD_AUDIO_DESC_CLK_SRC_LEN\
|
||||
@ -403,9 +407,9 @@ TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb
|
||||
+ TUD_AUDIO_DESC_STD_AS_ISO_EP_LEN\
|
||||
+ TUD_AUDIO_DESC_CS_AS_ISO_EP_LEN)
|
||||
|
||||
#define TUD_AUDIO_MIC_DESC_N_AS_INT 1 // Number of AS interfaces
|
||||
#define TUD_AUDIO_MIC_ONE_CH_DESC_N_AS_INT 1 // Number of AS interfaces
|
||||
|
||||
#define TUD_AUDIO_MIC_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epin, _epsize) \
|
||||
#define TUD_AUDIO_MIC_ONE_CH_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epin, _epsize) \
|
||||
/* Standard Interface Association Descriptor (IAD) */\
|
||||
TUD_AUDIO_DESC_IAD(/*_firstitfs*/ _itfnum, /*_nitfs*/ 0x02, /*_stridx*/ 0x00),\
|
||||
/* Standard AC Interface Descriptor(4.7.1) */\
|
||||
@ -435,6 +439,55 @@ TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb
|
||||
/* Class-Specific AS Isochronous Audio Data Endpoint Descriptor(4.10.1.2) */\
|
||||
TUD_AUDIO_DESC_CS_AS_ISO_EP(/*_attr*/ AUDIO_CS_AS_ISO_DATA_EP_ATT_NON_MAX_PACKETS_OK, /*_ctrl*/ AUDIO_CTRL_NONE, /*_lockdelayunit*/ AUDIO_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_UNDEFINED, /*_lockdelay*/ 0x0000)
|
||||
|
||||
// AUDIO simple descriptor (UAC2) for 4 microphone input
|
||||
// - 1 Input Terminal, 1 Feature Unit (Mute and Volume Control), 1 Output Terminal, 1 Clock Source
|
||||
|
||||
#define TUD_AUDIO_MIC_FOUR_CH_DESC_LEN (TUD_AUDIO_DESC_IAD_LEN\
|
||||
+ TUD_AUDIO_DESC_STD_AC_LEN\
|
||||
+ TUD_AUDIO_DESC_CS_AC_LEN\
|
||||
+ TUD_AUDIO_DESC_CLK_SRC_LEN\
|
||||
+ TUD_AUDIO_DESC_INPUT_TERM_LEN\
|
||||
+ TUD_AUDIO_DESC_OUTPUT_TERM_LEN\
|
||||
+ TUD_AUDIO_DESC_FEATURE_UNIT_FOUR_CHANNEL_LEN\
|
||||
+ TUD_AUDIO_DESC_STD_AS_INT_LEN\
|
||||
+ TUD_AUDIO_DESC_STD_AS_INT_LEN\
|
||||
+ TUD_AUDIO_DESC_CS_AS_INT_LEN\
|
||||
+ TUD_AUDIO_DESC_TYPE_I_FORMAT_LEN\
|
||||
+ TUD_AUDIO_DESC_STD_AS_ISO_EP_LEN\
|
||||
+ TUD_AUDIO_DESC_CS_AS_ISO_EP_LEN)
|
||||
|
||||
#define TUD_AUDIO_MIC_FOUR_CH_DESC_N_AS_INT 1 // Number of AS interfaces
|
||||
|
||||
#define TUD_AUDIO_MIC_FOUR_CH_DESCRIPTOR(_itfnum, _stridx, _nBytesPerSample, _nBitsUsedPerSample, _epin, _epsize) \
|
||||
/* Standard Interface Association Descriptor (IAD) */\
|
||||
TUD_AUDIO_DESC_IAD(/*_firstitfs*/ _itfnum, /*_nitfs*/ 0x02, /*_stridx*/ 0x00),\
|
||||
/* Standard AC Interface Descriptor(4.7.1) */\
|
||||
TUD_AUDIO_DESC_STD_AC(/*_itfnum*/ _itfnum, /*_nEPs*/ 0x00, /*_stridx*/ _stridx),\
|
||||
/* Class-Specific AC Interface Header Descriptor(4.7.2) */\
|
||||
TUD_AUDIO_DESC_CS_AC(/*_bcdADC*/ 0x0200, /*_category*/ AUDIO_FUNC_MICROPHONE, /*_totallen*/ TUD_AUDIO_DESC_CLK_SRC_LEN+TUD_AUDIO_DESC_INPUT_TERM_LEN+TUD_AUDIO_DESC_OUTPUT_TERM_LEN+TUD_AUDIO_DESC_FEATURE_UNIT_FOUR_CHANNEL_LEN, /*_ctrl*/ AUDIO_CS_AS_INTERFACE_CTRL_LATENCY_POS),\
|
||||
/* Clock Source Descriptor(4.7.2.1) */\
|
||||
TUD_AUDIO_DESC_CLK_SRC(/*_clkid*/ 0x04, /*_attr*/ AUDIO_CLOCK_SOURCE_ATT_INT_FIX_CLK, /*_ctrl*/ (AUDIO_CTRL_R << AUDIO_CLOCK_SOURCE_CTRL_CLK_FRQ_POS), /*_assocTerm*/ 0x01, /*_stridx*/ 0x00),\
|
||||
/* Input Terminal Descriptor(4.7.2.4) */\
|
||||
TUD_AUDIO_DESC_INPUT_TERM(/*_termid*/ 0x01, /*_termtype*/ AUDIO_TERM_TYPE_IN_GENERIC_MIC, /*_assocTerm*/ 0x03, /*_clkid*/ 0x04, /*_nchannelslogical*/ 0x04, /*_channelcfg*/ AUDIO_CHANNEL_CONFIG_NON_PREDEFINED, /*_idxchannelnames*/ 0x00, /*_ctrl*/ AUDIO_CTRL_R << AUDIO_IN_TERM_CTRL_CONNECTOR_POS, /*_stridx*/ 0x00),\
|
||||
/* Output Terminal Descriptor(4.7.2.5) */\
|
||||
TUD_AUDIO_DESC_OUTPUT_TERM(/*_termid*/ 0x03, /*_termtype*/ AUDIO_TERM_TYPE_USB_STREAMING, /*_assocTerm*/ 0x01, /*_srcid*/ 0x02, /*_clkid*/ 0x04, /*_ctrl*/ 0x0000, /*_stridx*/ 0x00),\
|
||||
/* Feature Unit Descriptor(4.7.2.8) */\
|
||||
TUD_AUDIO_DESC_FEATURE_UNIT_FOUR_CHANNEL(/*_unitid*/ 0x02, /*_srcid*/ 0x01, /*_ctrlch0master*/ AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch1*/ AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch2*/ AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch3*/ AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS, /*_ctrlch4*/ AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_MUTE_POS | AUDIO_CTRL_RW << AUDIO_FEATURE_UNIT_CTRL_VOLUME_POS, /*_stridx*/ 0x00),\
|
||||
/* Standard AS Interface Descriptor(4.9.1) */\
|
||||
/* Interface 1, Alternate 0 - default alternate setting with 0 bandwidth */\
|
||||
TUD_AUDIO_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x00, /*_nEPs*/ 0x00, /*_stridx*/ 0x00),\
|
||||
/* Standard AS Interface Descriptor(4.9.1) */\
|
||||
/* Interface 1, Alternate 1 - alternate interface for data streaming */\
|
||||
TUD_AUDIO_DESC_STD_AS_INT(/*_itfnum*/ (uint8_t)((_itfnum)+1), /*_altset*/ 0x01, /*_nEPs*/ 0x01, /*_stridx*/ 0x00),\
|
||||
/* Class-Specific AS Interface Descriptor(4.9.2) */\
|
||||
TUD_AUDIO_DESC_CS_AS_INT(/*_termid*/ 0x03, /*_ctrl*/ AUDIO_CTRL_NONE, /*_formattype*/ AUDIO_FORMAT_TYPE_I, /*_formats*/ AUDIO_DATA_FORMAT_TYPE_I_PCM, /*_nchannelsphysical*/ 0x04, /*_channelcfg*/ AUDIO_CHANNEL_CONFIG_NON_PREDEFINED, /*_stridx*/ 0x00),\
|
||||
/* Type I Format Type Descriptor(2.3.1.6 - Audio Formats) */\
|
||||
TUD_AUDIO_DESC_TYPE_I_FORMAT(_nBytesPerSample, _nBitsUsedPerSample),\
|
||||
/* Standard AS Isochronous Audio Data Endpoint Descriptor(4.10.1.1) */\
|
||||
TUD_AUDIO_DESC_STD_AS_ISO_EP(/*_ep*/ _epin, /*_attr*/ (TUSB_XFER_ISOCHRONOUS | TUSB_ISO_EP_ATT_ASYNCHRONOUS | TUSB_ISO_EP_ATT_DATA), /*_maxEPsize*/ _epsize, /*_interval*/ (CFG_TUSB_RHPORT0_MODE & OPT_MODE_HIGH_SPEED) ? 0x04 : 0x01),\
|
||||
/* Class-Specific AS Isochronous Audio Data Endpoint Descriptor(4.10.1.2) */\
|
||||
TUD_AUDIO_DESC_CS_AS_ISO_EP(/*_attr*/ AUDIO_CS_AS_ISO_DATA_EP_ATT_NON_MAX_PACKETS_OK, /*_ctrl*/ AUDIO_CTRL_NONE, /*_lockdelayunit*/ AUDIO_CS_AS_ISO_DATA_EP_LOCK_DELAY_UNIT_UNDEFINED, /*_lockdelay*/ 0x0000)
|
||||
|
||||
// AUDIO simple descriptor (UAC2) for mono speaker
|
||||
// - 1 Input Terminal, 2 Feature Unit (Mute and Volume Control), 3 Output Terminal, 4 Clock Source
|
||||
|
||||
|
@ -72,6 +72,9 @@ void usbd_edpt_close(uint8_t rhport, uint8_t ep_addr);
|
||||
// Submit a usb transfer
|
||||
bool usbd_edpt_xfer(uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t total_bytes);
|
||||
|
||||
// Submit a usb ISO transfer by use of a FIFO (ring buffer) - all bytes in FIFO get transmitted
|
||||
bool usbd_edpt_iso_xfer(uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16_t total_bytes);
|
||||
|
||||
// Claim an endpoint before submitting a transfer.
|
||||
// If caller does not make any transfer, it must release endpoint for others.
|
||||
bool usbd_edpt_claim(uint8_t rhport, uint8_t ep_addr);
|
||||
|
@ -143,7 +143,7 @@ static inline bool osal_queue_receive(osal_queue_t qhdl, void* data)
|
||||
// TODO: revisit... docs say that mutexes are never used from IRQ context,
|
||||
// however osal_queue_recieve may be. therefore my assumption is that
|
||||
// the fifo mutex is not populated for queues used from an IRQ context
|
||||
assert(!qhdl->ff.mutex);
|
||||
//assert(!qhdl->ff.mutex);
|
||||
|
||||
_osal_q_lock(qhdl);
|
||||
bool success = tu_fifo_read(&qhdl->ff, data);
|
||||
@ -157,7 +157,7 @@ static inline bool osal_queue_send(osal_queue_t qhdl, void const * data, bool in
|
||||
// TODO: revisit... docs say that mutexes are never used from IRQ context,
|
||||
// however osal_queue_recieve may be. therefore my assumption is that
|
||||
// the fifo mutex is not populated for queues used from an IRQ context
|
||||
assert(!qhdl->ff.mutex);
|
||||
//assert(!qhdl->ff.mutex);
|
||||
|
||||
_osal_q_lock(qhdl);
|
||||
bool success = tu_fifo_write(&qhdl->ff, data);
|
||||
|
Reference in New Issue
Block a user