Skip to content

Commit 52b821d

Browse files
committed
update tinyusb to commit 89f8fbc
1 parent 737dfb2 commit 52b821d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4042
-3198
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Bug Report
2-
description: Report a problem with TinyUSB Library
2+
description: Report a problem
33
labels: 'Bug'
44
body:
55
- type: markdown
@@ -88,9 +88,9 @@ body:
8888

8989
- type: textarea
9090
attributes:
91-
label: Debug Log
91+
label: Debug Log as ATTACHED TXT
9292
placeholder: |
93-
TinyUSB debug log where the issue occurred as attached txt file, best with comments to explain the actual events.
93+
Debug log where the issue occurred as attached txt file, best with comments to explain the actual events.
9494
validations:
9595
required: false
9696

examples/MassStorage/msc_ramdisk/msc_ramdisk.ino

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ Adafruit_USBD_MSC usb_msc;
3535
#endif
3636

3737

38+
int32_t msc_read_callback(uint32_t lba, void* buffer, uint32_t bufsize);
39+
int32_t msc_write_callback(uint32_t lba, uint8_t* buffer, uint32_t bufsize);
40+
void msc_flush_callback(void);
41+
bool msc_start_stop_callback(uint8_t power_condition, bool start, bool load_eject);
42+
bool msc_ready_callback(void);
43+
44+
3845
// the setup function runs once when you press reset or power the board
3946
void setup() {
4047
// Manual begin() is required on core without built-in support e.g. mbed rp2040

src/class/audio/audio_device.c

Lines changed: 150 additions & 959 deletions
Large diffs are not rendered by default.

src/class/audio/audio_device.h

Lines changed: 44 additions & 285 deletions
Large diffs are not rendered by default.

src/class/cdc/cdc.h

Lines changed: 78 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,11 @@ typedef enum {
192192
CDC_LINE_CODING_STOP_BITS_2 = 2, // 2 bits
193193
} cdc_line_coding_stopbits_t;
194194

195+
#define CDC_LINE_CODING_STOP_BITS_TEXT(STOP_BITS) ( \
196+
STOP_BITS == CDC_LINE_CODING_STOP_BITS_1 ? "1" : \
197+
STOP_BITS == CDC_LINE_CODING_STOP_BITS_1_5 ? "1.5" : \
198+
STOP_BITS == CDC_LINE_CODING_STOP_BITS_2 ? "2" : "?" )
199+
195200
// TODO Backward compatible for typos. Maybe removed in the future release
196201
#define CDC_LINE_CONDING_STOP_BITS_1 CDC_LINE_CODING_STOP_BITS_1
197202
#define CDC_LINE_CONDING_STOP_BITS_1_5 CDC_LINE_CODING_STOP_BITS_1_5
@@ -205,22 +210,31 @@ typedef enum {
205210
CDC_LINE_CODING_PARITY_SPACE = 4,
206211
} cdc_line_coding_parity_t;
207212

213+
#define CDC_LINE_CODING_PARITY_CHAR(PARITY) ( \
214+
PARITY == CDC_LINE_CODING_PARITY_NONE ? 'N' : \
215+
PARITY == CDC_LINE_CODING_PARITY_ODD ? 'O' : \
216+
PARITY == CDC_LINE_CODING_PARITY_EVEN ? 'E' : \
217+
PARITY == CDC_LINE_CODING_PARITY_MARK ? 'M' : \
218+
PARITY == CDC_LINE_CODING_PARITY_SPACE ? 'S' : '?' )
219+
208220
//--------------------------------------------------------------------+
209221
// Management Element Notification (Notification Endpoint)
210222
//--------------------------------------------------------------------+
211223

224+
#define CDC_REQ_TYPE_NOTIF 0xA1 ///< Direction IN; Type Class; Recipient Interface
225+
212226
/// 6.3 Notification Codes
213227
typedef enum {
214-
CDC_NOTIF_NETWORK_CONNECTION = 0x00, ///< This notification allows the device to notify the host about network connection status.
215-
CDC_NOTIF_RESPONSE_AVAILABLE = 0x01, ///< This notification allows the device to notify the hostthat a response is available. This response can be retrieved with a subsequent \ref CDC_REQUEST_GET_ENCAPSULATED_RESPONSE request.
228+
CDC_NOTIF_NETWORK_CONNECTION = 0x00, // notify the host about network connection status.
229+
CDC_NOTIF_RESPONSE_AVAILABLE = 0x01, // notify the host that a response is available.
216230
CDC_NOTIF_AUX_JACK_HOOK_STATE = 0x08,
217231
CDC_NOTIF_RING_DETECT = 0x09,
218232
CDC_NOTIF_SERIAL_STATE = 0x20,
219233
CDC_NOTIF_CALL_STATE_CHANGE = 0x28,
220234
CDC_NOTIF_LINE_STATE_CHANGE = 0x29,
221-
CDC_NOTIF_CONNECTION_SPEED_CHANGE = 0x2A, ///< This notification allows the device to inform the host-networking driver that a change in either the upstream or the downstream bit rate of the connection has occurred
235+
CDC_NOTIF_CONNECTION_SPEED_CHANGE = 0x2A, // notify the host-networking driver that a change in either the upstream or the downstream bit rate of the connection has occurred
222236
CDC_NOTIF_MDLM_SEMANTIC_MODEL_NOTIFICATION = 0x40,
223-
}cdc_notification_request_t;
237+
} cdc_notify_request_t;
224238

225239
//--------------------------------------------------------------------+
226240
// Class Specific Functional Descriptor (Communication Interface)
@@ -231,17 +245,15 @@ TU_ATTR_PACKED_BEGIN
231245
TU_ATTR_BIT_FIELD_ORDER_BEGIN
232246

233247
/// Header Functional Descriptor (Communication Interface)
234-
typedef struct TU_ATTR_PACKED
235-
{
248+
typedef struct TU_ATTR_PACKED {
236249
uint8_t bLength ; ///< Size of this descriptor in bytes.
237250
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
238251
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUNC_DESC_
239252
uint16_t bcdCDC ; ///< CDC release number in Binary-Coded Decimal
240253
}cdc_desc_func_header_t;
241254

242255
/// Union Functional Descriptor (Communication Interface)
243-
typedef struct TU_ATTR_PACKED
244-
{
256+
typedef struct TU_ATTR_PACKED {
245257
uint8_t bLength ; ///< Size of this descriptor in bytes.
246258
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
247259
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
@@ -259,14 +271,13 @@ typedef struct TU_ATTR_PACKED
259271
}
260272

261273
/// Country Selection Functional Descriptor (Communication Interface)
262-
typedef struct TU_ATTR_PACKED
263-
{
274+
typedef struct TU_ATTR_PACKED {
264275
uint8_t bLength ; ///< Size of this descriptor in bytes.
265276
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
266277
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
267278
uint8_t iCountryCodeRelDate ; ///< Index of a string giving the release date for the implemented ISO 3166 Country Codes.
268279
uint16_t wCountryCode ; ///< Country code in the format as defined in [ISO3166], release date as specified inoffset 3 for the first supported country.
269-
}cdc_desc_func_country_selection_t;
280+
} cdc_desc_func_country_selection_t;
270281

271282
#define cdc_desc_func_country_selection_n_t(no_country) \
272283
struct TU_ATTR_PACKED { \
@@ -283,8 +294,7 @@ typedef struct TU_ATTR_PACKED
283294

284295
/// \brief Call Management Functional Descriptor
285296
/// \details This functional descriptor describes the processing of calls for the Communications Class interface.
286-
typedef struct TU_ATTR_PACKED
287-
{
297+
typedef struct TU_ATTR_PACKED {
288298
uint8_t bLength ; ///< Size of this descriptor in bytes.
289299
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
290300
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
@@ -298,8 +308,7 @@ typedef struct TU_ATTR_PACKED
298308
uint8_t bDataInterface;
299309
}cdc_desc_func_call_management_t;
300310

301-
typedef struct TU_ATTR_PACKED
302-
{
311+
typedef struct TU_ATTR_PACKED {
303312
uint8_t support_comm_request : 1; ///< Device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and Get_Comm_Feature.
304313
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.
305314
uint8_t support_send_break : 1; ///< Device supports the request Send_Break
@@ -311,8 +320,7 @@ TU_VERIFY_STATIC(sizeof(cdc_acm_capability_t) == 1, "mostly problem with compile
311320

312321
/// Abstract Control Management Functional Descriptor
313322
/// This functional descriptor describes the commands supported by by the Communications Class interface with SubClass code of \ref CDC_COMM_SUBCLASS_ABSTRACT_CONTROL_MODEL
314-
typedef struct TU_ATTR_PACKED
315-
{
323+
typedef struct TU_ATTR_PACKED {
316324
uint8_t bLength ; ///< Size of this descriptor in bytes.
317325
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
318326
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
@@ -321,8 +329,7 @@ typedef struct TU_ATTR_PACKED
321329

322330
/// \brief Direct Line Management Functional Descriptor
323331
/// \details This functional descriptor describes the commands supported by the Communications Class interface with SubClass code of \ref CDC_FUNC_DESC_DIRECT_LINE_MANAGEMENT
324-
typedef struct TU_ATTR_PACKED
325-
{
332+
typedef struct TU_ATTR_PACKED {
326333
uint8_t bLength ; ///< Size of this descriptor in bytes.
327334
uint8_t bDescriptorType ; ///< Descriptor Type, must be Class-Specific
328335
uint8_t bDescriptorSubType ; ///< Descriptor SubType one of above CDC_FUCN_DESC_
@@ -384,16 +391,14 @@ typedef struct TU_ATTR_PACKED
384391
}cdc_desc_func_telephone_call_state_reporting_capabilities_t;
385392

386393
// TODO remove
387-
static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc)
388-
{
394+
TU_ATTR_ALWAYS_INLINE static inline uint8_t cdc_functional_desc_typeof(uint8_t const * p_desc) {
389395
return p_desc[2];
390396
}
391397

392398
//--------------------------------------------------------------------+
393399
// Requests
394400
//--------------------------------------------------------------------+
395-
typedef struct TU_ATTR_PACKED
396-
{
401+
typedef struct TU_ATTR_PACKED {
397402
uint32_t bit_rate;
398403
uint8_t stop_bits; ///< 0: 1 stop bit - 1: 1.5 stop bits - 2: 2 stop bits
399404
uint8_t parity; ///< 0: None - 1: Odd - 2: Even - 3: Mark - 4: Space
@@ -402,15 +407,58 @@ typedef struct TU_ATTR_PACKED
402407

403408
TU_VERIFY_STATIC(sizeof(cdc_line_coding_t) == 7, "size is not correct");
404409

405-
typedef struct TU_ATTR_PACKED
406-
{
407-
uint16_t dtr : 1;
408-
uint16_t rts : 1;
409-
uint16_t : 6;
410-
uint16_t : 8;
410+
typedef union TU_ATTR_PACKED {
411+
struct TU_ATTR_PACKED {
412+
uint8_t dtr : 1;
413+
uint8_t rts : 1;
414+
uint8_t : 6;
415+
};
416+
uint8_t value;
411417
} cdc_line_control_state_t;
412418

413-
TU_VERIFY_STATIC(sizeof(cdc_line_control_state_t) == 2, "size is not correct");
419+
TU_VERIFY_STATIC(sizeof(cdc_line_control_state_t) == 1, "size is not correct");
420+
421+
//--------------------------------------------------------------------+
422+
// Notifications
423+
//--------------------------------------------------------------------+
424+
// PSTN 1.2 section 6.5.4 table 31
425+
typedef union TU_ATTR_PACKED {
426+
struct TU_ATTR_PACKED {
427+
uint16_t bRxCarrier : 1; // DCD
428+
uint16_t bTxCarrier : 1; // DSR
429+
uint16_t bBreak : 1; // Break Detected
430+
uint16_t bRingSignal : 1;
431+
uint16_t bFraming : 1;
432+
uint16_t bParity : 1;
433+
uint16_t bOverRun : 1;
434+
uint16_t : 9;
435+
};
436+
struct TU_ATTR_PACKED {
437+
uint16_t dcd : 1;
438+
uint16_t dsr : 1;
439+
uint16_t brk : 1;
440+
uint16_t :13;
441+
};
442+
uint16_t value;
443+
} cdc_notify_uart_state_t;
444+
445+
TU_VERIFY_STATIC(sizeof(cdc_notify_uart_state_t) == 2, "size is not correct");
446+
447+
// CDC 1.2 section 6.3.3 table 21
448+
typedef struct TU_ATTR_PACKED {
449+
uint32_t upstream_bitrate;
450+
uint32_t downstream_bitrate;
451+
} cdc_notify_conn_speed_change_t;
452+
453+
typedef struct TU_ATTR_PACKED {
454+
tusb_control_request_t request;
455+
union {
456+
cdc_notify_uart_state_t serial_state;
457+
cdc_notify_conn_speed_change_t conn_speed_change;
458+
};
459+
} cdc_notify_msg_t;
460+
461+
TU_VERIFY_STATIC(sizeof(cdc_notify_msg_t) == 16, "size is not correct");
414462

415463
TU_ATTR_PACKED_END // End of all packed definitions
416464
TU_ATTR_BIT_FIELD_ORDER_END

0 commit comments

Comments
 (0)