composite: Make the audio endpoints/interfaces optional
There's now a HAVE_AUDIO #define in usb_descriptors.h, and it's disabled by default for now.
This commit is contained in:
parent
2a186e4b9b
commit
0f84261d21
|
@ -7,6 +7,8 @@
|
|||
#include "usb_descriptors.h"
|
||||
#include "class/audio/audio_device.h"
|
||||
|
||||
#ifdef HAVE_AUDIO
|
||||
|
||||
/* could also be 16kHz for AMR-WB calls? */
|
||||
#define AUDIO_SAMPLE_RATE 8000
|
||||
|
||||
|
@ -328,4 +330,11 @@ bool tud_audio_set_itf_close_EP_cb(uint8_t rhport, tusb_control_request_t const
|
|||
return true;
|
||||
}
|
||||
|
||||
#else /* HAVE_AUDIO */
|
||||
|
||||
int audio_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_AUDIO */
|
||||
|
|
|
@ -40,16 +40,23 @@ uint8_t const* tud_descriptor_device_cb(void)
|
|||
|
||||
|
||||
/* Configuration Descriptor */
|
||||
#ifdef HAVE_AUDIO
|
||||
#define CONFIG_TOTAL_LEN \
|
||||
(TUD_CONFIG_DESC_LEN + TUD_CARDEM_DESCRIPTOR_LEN + TUD_AUDIO_PHONE_MONO_DESCRIPTOR_LEN)
|
||||
#else
|
||||
#define CONFIG_TOTAL_LEN \
|
||||
(TUD_CONFIG_DESC_LEN + TUD_CARDEM_DESCRIPTOR_LEN)
|
||||
#endif
|
||||
static uint8_t const desc_config[] = {
|
||||
// Config number, interface count, string index, total length, attribute, power in mA
|
||||
TUD_CONFIG_DESCRIPTOR(1, ITF_NUM_TOTAL, 0, CONFIG_TOTAL_LEN, TUSB_DESC_CONFIG_ATT_REMOTE_WAKEUP, 100),
|
||||
|
||||
TUD_CARDEM_DESCRIPTOR(ITF_NUM_CARDEM, 4, /*epout*/ 0x01, /*epin*/ 0x81, /*epirq*/ 0x82),
|
||||
|
||||
#ifdef HAVE_AUDIO
|
||||
// interface number, string index, epout, epin, epsize, epfb
|
||||
TUD_AUDIO_PHONE_MONO_DESCRIPTOR(ITF_NUM_AUDIO_CTRL, 5, 0x02, 0x83, CFG_TUD_AUDIO_EP_SZ, 0x84),
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Invoked when received GET CONFIGURATION DESCRIPTOR */
|
||||
|
@ -66,7 +73,9 @@ char const *string_desc_arr[] = {
|
|||
"pico-pcm-cardem", /* 2: Product */
|
||||
"12345", /* 3: Serial, should use chip ID */
|
||||
"SIMtrace2 compatible card-emulation", /* 4: CARDEM */
|
||||
#ifdef HAVE_AUDIO
|
||||
"Cellular Modem PCM Audio", /* 5: Audio Interface */
|
||||
#endif
|
||||
};
|
||||
|
||||
static uint16_t _desc_str[32];
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
//#define HAVE_AUDIO
|
||||
|
||||
/* TODO: put into tinyusb */
|
||||
#define AUDIO_TERM_TYPE_PH_PHONE_LINE 0x0501
|
||||
|
||||
|
@ -90,8 +92,10 @@
|
|||
/* Interface numbers */
|
||||
enum {
|
||||
ITF_NUM_CARDEM = 0,
|
||||
#ifdef HAVE_AUDIO
|
||||
ITF_NUM_AUDIO_CTRL,
|
||||
ITF_NUM_AUDIO_STREAM_OUT,
|
||||
ITF_NUM_AUDIO_STREAM_IN,
|
||||
#endif
|
||||
ITF_NUM_TOTAL
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue