Skip to content

Commit f820879

Browse files
committed
Merge branch 'master' into hallowings
2 parents 7024005 + 68e65f2 commit f820879

33 files changed

+922
-510
lines changed

cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_CDC.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ Adafruit_USBD_CDC::Adafruit_USBD_CDC(void)
3737

3838
}
3939

40-
uint16_t Adafruit_USBD_CDC::getDescriptor(uint8_t* buf, uint16_t bufsize)
40+
uint16_t Adafruit_USBD_CDC::getDescriptor(uint8_t itfnum, uint8_t* buf, uint16_t bufsize)
4141
{
4242
// CDC is mostly always existed for DFU
43-
uint8_t desc[] = { TUD_CDC_DESCRIPTOR(0, 0, EPIN, 8, EPOUT, EPIN, 64) };
43+
// usb core will automatically update endpoint number
44+
uint8_t desc[] = { TUD_CDC_DESCRIPTOR(itfnum, 0, EPIN, 8, EPOUT, EPIN, 64) };
4445
uint16_t const len = sizeof(desc);
4546

4647
if ( bufsize < len ) return 0;
@@ -52,9 +53,13 @@ uint16_t Adafruit_USBD_CDC::getDescriptor(uint8_t* buf, uint16_t bufsize)
5253
// Baud and config is ignore in CDC
5354
void Adafruit_USBD_CDC::begin (uint32_t baud)
5455
{
56+
(void) baud;
5557
}
58+
5659
void Adafruit_USBD_CDC::begin (uint32_t baud, uint8_t config)
5760
{
61+
(void) baud;
62+
(void) config;
5863
}
5964

6065
void Adafruit_USBD_CDC::end(void)
@@ -128,6 +133,7 @@ extern "C"
128133
void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts)
129134
{
130135
(void) itf; // interface ID, not used
136+
(void) rts;
131137

132138
// DTR = false is counted as disconnected
133139
if ( !dtr )

cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_CDC.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Adafruit_USBD_CDC : public Stream, Adafruit_USBD_Interface
3434
Adafruit_USBD_CDC(void);
3535

3636
// fron Adafruit_USBD_Interface
37-
virtual uint16_t getDescriptor(uint8_t* buf, uint16_t bufsize);
37+
virtual uint16_t getDescriptor(uint8_t itfnum, uint8_t* buf, uint16_t bufsize);
3838

3939
void setPins(uint8_t pin_rx, uint8_t pin_tx) { (void) pin_rx; (void) pin_tx; }
4040
void begin(uint32_t baud_count);

cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.cpp

+4-13
Original file line numberDiff line numberDiff line change
@@ -95,26 +95,17 @@ Adafruit_USBD_Device::Adafruit_USBD_Device(void)
9595
bool Adafruit_USBD_Device::addInterface(Adafruit_USBD_Interface& itf)
9696
{
9797
uint8_t* desc = _desc_cfg+_desc_cfglen;
98-
uint16_t const len = itf.getDescriptor(desc, sizeof(_desc_cfg)-_desc_cfglen);
98+
uint16_t const len = itf.getDescriptor(_itf_count, desc, sizeof(_desc_cfg)-_desc_cfglen);
9999
uint8_t* desc_end = desc+len;
100100

101101
if ( !len ) return false;
102102

103-
// Handle IAD
104-
if ( desc[1] == TUSB_DESC_INTERFACE_ASSOCIATION )
105-
{
106-
// update starting interface
107-
((tusb_desc_interface_assoc_t*) desc)->bFirstInterface = _itf_count;
108-
109-
desc += desc[0]; // next
110-
}
111-
112103
while (desc < desc_end)
113104
{
114105
if (desc[1] == TUSB_DESC_INTERFACE)
115106
{
116-
// No alternate interface support
117-
((tusb_desc_interface_t*) desc)->bInterfaceNumber = _itf_count++;
107+
tusb_desc_interface_t* desc_itf = (tusb_desc_interface_t*) desc;
108+
if (desc_itf->bAlternateSetting == 0) _itf_count++;
118109
}else if (desc[1] == TUSB_DESC_ENDPOINT)
119110
{
120111
tusb_desc_endpoint_t* desc_ep = (tusb_desc_endpoint_t*) desc;
@@ -127,7 +118,7 @@ bool Adafruit_USBD_Device::addInterface(Adafruit_USBD_Interface& itf)
127118

128119
_desc_cfglen += len;
129120

130-
// Update config descriptor
121+
// Update configuration descriptor
131122
tusb_desc_configuration_t* config = (tusb_desc_configuration_t*)_desc_cfg;
132123
config->wTotalLength = _desc_cfglen;
133124
config->bNumInterfaces = _itf_count;

cores/arduino/Adafruit_TinyUSB_Core/Adafruit_USBD_Device.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
class Adafruit_USBD_Interface
3131
{
3232
public:
33-
virtual uint16_t getDescriptor(uint8_t* buf, uint16_t bufsize) = 0;
33+
virtual uint16_t getDescriptor(uint8_t itfnum, uint8_t* buf, uint16_t bufsize) = 0;
3434
};
3535

3636
class Adafruit_USBD_Device

cores/arduino/Adafruit_TinyUSB_Core/tinyusb/src/class/audio/audio.h

+39-5
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
* Currently only MIDI subclass is supported
3030
* @{ */
3131

32-
#ifndef _TUSB_CDC_H__
33-
#define _TUSB_CDC_H__
32+
#ifndef _TUSB_AUDIO_H__
33+
#define _TUSB_AUDIO_H__
3434

3535
#include "common/tusb_common.h"
3636

@@ -41,9 +41,9 @@
4141
/// Audio Interface Subclass Codes
4242
typedef enum
4343
{
44-
AUDIO_SUBCLASS_AUDIO_CONTROL = 0x01 , ///< Audio Control
45-
AUDIO_SUBCLASS_AUDIO_STREAMING , ///< Audio Streaming
46-
AUDIO_SUBCLASS_MIDI_STREAMING , ///< MIDI Streaming
44+
AUDIO_SUBCLASS_CONTROL = 0x01 , ///< Audio Control
45+
AUDIO_SUBCLASS_STREAMING , ///< Audio Streaming
46+
AUDIO_SUBCLASS_MIDI_STREAMING , ///< MIDI Streaming
4747
} audio_subclass_type_t;
4848

4949
/// Audio Protocol Codes
@@ -54,6 +54,40 @@ typedef enum
5454
AUDIO_PROTOCOL_V3 = 0x30, ///< Version 3.0
5555
} audio_protocol_type_t;
5656

57+
/// Audio Function Category Codes
58+
typedef enum
59+
{
60+
AUDIO_FUNC_DESKTOP_SPEAKER = 0x01,
61+
AUDIO_FUNC_HOME_THEATER = 0x02,
62+
AUDIO_FUNC_MICROPHONE = 0x03,
63+
AUDIO_FUNC_HEADSET = 0x04,
64+
AUDIO_FUNC_TELEPHONE = 0x05,
65+
AUDIO_FUNC_CONVERTER = 0x06,
66+
AUDIO_FUNC_SOUND_RECODER = 0x07,
67+
AUDIO_FUNC_IO_BOX = 0x08,
68+
AUDIO_FUNC_MUSICAL_INSTRUMENT = 0x09,
69+
AUDIO_FUNC_PRO_AUDIO = 0x0A,
70+
AUDIO_FUNC_AUDIO_VIDEO = 0x0B,
71+
AUDIO_FUNC_CONTROL_PANEL = 0x0C
72+
} audio_function_t;
73+
74+
/// Audio Class-Specific AC Interface Descriptor Subtypes
75+
typedef enum
76+
{
77+
AUDIO_CS_INTERFACE_HEADER = 0x01,
78+
AUDIO_CS_INTERFACE_INPUT_TERMINAL = 0x02,
79+
AUDIO_CS_INTERFACE_OUTPUT_TERMINAL = 0x03,
80+
AUDIO_CS_INTERFACE_MIXER_UNIT = 0x04,
81+
AUDIO_CS_INTERFACE_SELECTOR_UNIT = 0x05,
82+
AUDIO_CS_INTERFACE_FEATURE_UNIT = 0x06,
83+
AUDIO_CS_INTERFACE_EFFECT_UNIT = 0x07,
84+
AUDIO_CS_INTERFACE_PROCESSING_UNIT = 0x08,
85+
AUDIO_CS_INTERFACE_EXTENSION_UNIT = 0x09,
86+
AUDIO_CS_INTERFACE_CLOCK_SOURCE = 0x0A,
87+
AUDIO_CS_INTERFACE_CLOCK_SELECTOR = 0x0B,
88+
AUDIO_CS_INTERFACE_CLOCK_MULTIPLIER = 0x0C,
89+
AUDIO_CS_INTERFACE_SAMPLE_RATE_CONVERTER = 0x0D,
90+
} audio_cs_interface_subtype_t;
5791

5892
/** @} */
5993

cores/arduino/Adafruit_TinyUSB_Core/tinyusb/src/class/cdc/cdc.h

+26-22
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
/** \defgroup ClassDriver_CDC_Common Common Definitions
4242
* @{ */
4343

44-
44+
// TODO remove
4545
/// CDC Pipe ID, used to indicate which pipe the API is addressing to (Notification, Out, In)
4646
typedef enum
4747
{
@@ -52,8 +52,9 @@ typedef enum
5252
}cdc_pipeid_t;
5353

5454
//--------------------------------------------------------------------+
55-
// CDC COMMUNICATION INTERFACE CLASS
55+
// CDC Communication Interface Class
5656
//--------------------------------------------------------------------+
57+
5758
/// Communication Interface Subclass Codes
5859
typedef enum
5960
{
@@ -117,7 +118,7 @@ typedef enum
117118
}cdc_func_desc_type_t;
118119

119120
//--------------------------------------------------------------------+
120-
// CDC DATA INTERFACE CLASS
121+
// CDC Data Interface Class
121122
//--------------------------------------------------------------------+
122123

123124
// SUBCLASS code of Data Interface is not used and should/must be zero
@@ -138,8 +139,9 @@ typedef enum{
138139
}cdc_data_protocol_type_t;
139140

140141
//--------------------------------------------------------------------+
141-
// MANAGEMENT ELEMENT REQUEST (CONTROL ENDPOINT)
142+
// Management Element Request (Control Endpoint)
142143
//--------------------------------------------------------------------+
144+
143145
/// Communication Interface Management Element Request Codes
144146
typedef enum
145147
{
@@ -189,8 +191,9 @@ typedef enum
189191
}cdc_management_request_t;
190192

191193
//--------------------------------------------------------------------+
192-
// MANAGEMENT ELEMENENT NOTIFICATION (NOTIFICATION ENDPOINT)
194+
// Management Elemenent Notification (Notification Endpoint)
193195
//--------------------------------------------------------------------+
196+
194197
/// Communication Interface Management Element Notification Codes
195198
typedef enum
196199
{
@@ -209,19 +212,20 @@ typedef enum
209212
}cdc_notification_request_t;
210213

211214
//--------------------------------------------------------------------+
212-
// FUNCTIONAL DESCRIPTOR (COMMUNICATION INTERFACE)
215+
// Class Specific Functional Descriptor (Communication Interface)
213216
//--------------------------------------------------------------------+
217+
214218
/// Header Functional Descriptor (Communication Interface)
215-
typedef struct ATTR_PACKED
219+
typedef struct TU_ATTR_PACKED
216220
{
217221
uint8_t bLength ; ///< Size of this descriptor in bytes.
218222
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
219-
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
223+
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUNC_DESC_
220224
uint16_t bcdCDC ; ///< CDC release number in Binary-Coded Decimal
221225
}cdc_desc_func_header_t;
222226

223227
/// Union Functional Descriptor (Communication Interface)
224-
typedef struct ATTR_PACKED
228+
typedef struct TU_ATTR_PACKED
225229
{
226230
uint8_t bLength ; ///< Size of this descriptor in bytes.
227231
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -231,7 +235,7 @@ typedef struct ATTR_PACKED
231235
}cdc_desc_func_union_t;
232236

233237
#define cdc_desc_func_union_n_t(no_slave)\
234-
struct ATTR_PACKED { \
238+
struct TU_ATTR_PACKED { \
235239
uint8_t bLength ;\
236240
uint8_t bDescriptorType ;\
237241
uint8_t bDescriptorSubType ;\
@@ -240,17 +244,17 @@ typedef struct ATTR_PACKED
240244
}
241245

242246
/// Country Selection Functional Descriptor (Communication Interface)
243-
typedef struct ATTR_PACKED
247+
typedef struct TU_ATTR_PACKED
244248
{
245249
uint8_t bLength ; ///< Size of this descriptor in bytes.
246250
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
247251
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
248252
uint8_t iCountryCodeRelDate ; ///< Index of a string giving the release date for the implemented ISO 3166 Country Codes.
249-
uint16_t wCountryCode[] ; ///< Country code in the format as defined in [ISO3166], release date as specified inoffset 3 for the first supported country.
253+
uint16_t wCountryCode ; ///< Country code in the format as defined in [ISO3166], release date as specified inoffset 3 for the first supported country.
250254
}cdc_desc_func_country_selection_t;
251255

252256
#define cdc_desc_func_country_selection_n_t(no_country) \
253-
struct ATTR_PACKED {\
257+
struct TU_ATTR_PACKED {\
254258
uint8_t bLength ;\
255259
uint8_t bDescriptorType ;\
256260
uint8_t bDescriptorSubType ;\
@@ -264,7 +268,7 @@ typedef struct ATTR_PACKED
264268

265269
/// \brief Call Management Functional Descriptor
266270
/// \details This functional descriptor describes the processing of calls for the Communications Class interface.
267-
typedef struct ATTR_PACKED
271+
typedef struct TU_ATTR_PACKED
268272
{
269273
uint8_t bLength ; ///< Size of this descriptor in bytes.
270274
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -280,7 +284,7 @@ typedef struct ATTR_PACKED
280284
}cdc_desc_func_call_management_t;
281285

282286

283-
typedef struct ATTR_PACKED
287+
typedef struct TU_ATTR_PACKED
284288
{
285289
uint8_t support_comm_request : 1; ///< Device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature.
286290
uint8_t support_line_request : 1; ///< Device supports the request combination of Set_Line_Coding, Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State.
@@ -293,7 +297,7 @@ TU_VERIFY_STATIC(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compile
293297

294298
/// \brief Abstract Control Management Functional Descriptor
295299
/// \details This functional descriptor describes the commands supported by by the Communications Class interface with SubClass code of \ref CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL
296-
typedef struct ATTR_PACKED
300+
typedef struct TU_ATTR_PACKED
297301
{
298302
uint8_t bLength ; ///< Size of this descriptor in bytes.
299303
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -303,7 +307,7 @@ typedef struct ATTR_PACKED
303307

304308
/// \brief Direct Line Management Functional Descriptor
305309
/// \details This functional descriptor describes the commands supported by the Communications Class interface with SubClass code of \ref CDC_FUNC_DESC_DIRECT_LINE_MANAGEMENT
306-
typedef struct ATTR_PACKED
310+
typedef struct TU_ATTR_PACKED
307311
{
308312
uint8_t bLength ; ///< Size of this descriptor in bytes.
309313
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -319,7 +323,7 @@ typedef struct ATTR_PACKED
319323
/// \brief Telephone Ringer Functional Descriptor
320324
/// \details The Telephone Ringer functional descriptor describes the ringer capabilities supported by the Communications Class interface,
321325
/// with the SubClass code of \ref CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL
322-
typedef struct ATTR_PACKED
326+
typedef struct TU_ATTR_PACKED
323327
{
324328
uint8_t bLength ; ///< Size of this descriptor in bytes.
325329
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -331,7 +335,7 @@ typedef struct ATTR_PACKED
331335
/// \brief Telephone Operational Modes Functional Descriptor
332336
/// \details The Telephone Operational Modes functional descriptor describes the operational modes supported by
333337
/// the Communications Class interface, with the SubClass code of \ref CDC_COMM_SUBCLASS_TELEPHONE_CONTROL_MODEL
334-
typedef struct ATTR_PACKED
338+
typedef struct TU_ATTR_PACKED
335339
{
336340
uint8_t bLength ; ///< Size of this descriptor in bytes.
337341
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -347,7 +351,7 @@ typedef struct ATTR_PACKED
347351
/// \brief Telephone Call and Line State Reporting Capabilities Descriptor
348352
/// \details The Telephone Call and Line State Reporting Capabilities functional descriptor describes the abilities of a
349353
/// telephone device to report optional call and line states.
350-
typedef struct ATTR_PACKED
354+
typedef struct TU_ATTR_PACKED
351355
{
352356
uint8_t bLength ; ///< Size of this descriptor in bytes.
353357
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
@@ -371,7 +375,7 @@ static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc)
371375
//--------------------------------------------------------------------+
372376
// Requests
373377
//--------------------------------------------------------------------+
374-
typedef struct ATTR_PACKED
378+
typedef struct TU_ATTR_PACKED
375379
{
376380
uint32_t bit_rate;
377381
uint8_t stop_bits; ///< 0: 1 stop bit - 1: 1.5 stop bits - 2: 2 stop bits
@@ -381,7 +385,7 @@ typedef struct ATTR_PACKED
381385

382386
TU_VERIFY_STATIC(sizeof(cdc_line_coding_t) == 7, "size is not correct");
383387

384-
typedef struct ATTR_PACKED
388+
typedef struct TU_ATTR_PACKED
385389
{
386390
uint16_t dte_is_present : 1; ///< Indicates to DCE if DTE is presentor not. This signal corresponds to V.24 signal 108/2 and RS-232 signal DTR.
387391
uint16_t half_duplex_carrier_control : 1;

0 commit comments

Comments
 (0)