Skip to content

Commit 2da89b1

Browse files
committed
Upgrade to latest TinyUSB
1 parent 3739fc9 commit 2da89b1

File tree

146 files changed

+10401
-3209
lines changed

Some content is hidden

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

146 files changed

+10401
-3209
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"files.associations": {
3+
"tusb_option.h": "c",
4+
"tusb_config.h": "c",
5+
"cdc_device.h": "c",
6+
"usbd_pvt.h": "c",
7+
"usbd.h": "c"
8+
}
9+
}
44 Bytes
Binary file not shown.
44 Bytes
Binary file not shown.
1.93 KB
Binary file not shown.

test-devices/composite-stm32/lib/tinyusb/class/audio/audio.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* The MIT License (MIT)
33
*
44
* Copyright (c) 2019 Ha Thach (tinyusb.org)
@@ -721,11 +721,13 @@ typedef struct TU_ATTR_PACKED
721721
uint8_t bLength ; ///< Size of this descriptor, in bytes: 17.
722722
uint8_t bDescriptorType ; ///< Descriptor Type. Value: TUSB_DESC_CS_INTERFACE.
723723
uint8_t bDescriptorSubType ; ///< Descriptor SubType. Value: AUDIO_CS_AC_INTERFACE_INPUT_TERMINAL.
724+
uint8_t bTerminalID ; ///< Constant uniquely identifying the Terminal within the audio function. This value is used in all requests to address this terminal.
724725
uint16_t wTerminalType ; ///< Constant characterizing the type of Terminal. See: audio_terminal_type_t for USB streaming and audio_terminal_input_type_t for other input types.
725726
uint8_t bAssocTerminal ; ///< ID of the Output Terminal to which this Input Terminal is associated.
726727
uint8_t bCSourceID ; ///< ID of the Clock Entity to which this Input Terminal is connected.
727728
uint8_t bNrChannels ; ///< Number of logical output channels in the Terminal’s output audio channel cluster.
728729
uint32_t bmChannelConfig ; ///< Describes the spatial location of the logical channels. See:audio_channel_config_t.
730+
uint8_t iChannelNames ; ///< Index of a string descriptor, describing the name of the first logical channel.
729731
uint16_t bmControls ; ///< See: audio_terminal_input_control_pos_t.
730732
uint8_t iTerminal ; ///< Index of a string descriptor, describing the Input Terminal.
731733
} audio_desc_input_terminal_t;
@@ -822,10 +824,10 @@ typedef struct TU_ATTR_PACKED
822824
uint8_t type : 2; ///< Request type tusb_request_type_t.
823825
uint8_t direction : 1; ///< Direction type. tusb_dir_t
824826
} bmRequestType_bit;
825-
827+
826828
uint8_t bmRequestType;
827829
};
828-
830+
829831
uint8_t bRequest; ///< Request type audio_cs_req_t
830832
uint8_t bChannelNumber;
831833
uint8_t bControlSelector;

test-devices/composite-stm32/lib/tinyusb/class/audio/audio_device.c

Lines changed: 259 additions & 167 deletions
Large diffs are not rendered by default.

test-devices/composite-stm32/lib/tinyusb/class/audio/audio_device.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* The MIT License (MIT)
33
*
44
* Copyright (c) 2020 Ha Thach (tinyusb.org)
@@ -473,7 +473,7 @@ TU_ATTR_WEAK void tud_audio_fb_done_cb(uint8_t func_id);
473473
// the choice of format is left to the caller and feedback argument is sent as-is. If CFG_TUD_AUDIO_ENABLE_FEEDBACK_FORMAT_CORRECTION is set, then tinyusb
474474
// expects 16.16 format and handles the conversion to 10.14 on FS.
475475
//
476-
// Note that due to a bug in its USB Audio 2.0 driver, Windows currently requires 16.16 format for _all_ USB 2.0 devices. On Linux and macOS it seems the
476+
// Note that due to a bug in its USB Audio 2.0 driver, Windows currently requires 16.16 format for _all_ USB 2.0 devices. On Linux and macOS it seems the
477477
// driver can work with either format. So a good compromise is to keep format correction disabled and stick to 16.16 format.
478478

479479
// Feedback value can be determined from within the SOF ISR of the audio driver. This should reduce jitter. If the feature is used, the user can not set the feedback value.

test-devices/composite-stm32/lib/tinyusb/class/bth/bth_device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* The MIT License (MIT)
33
*
44
* Copyright (c) 2020 Jerzy Kasenberg

test-devices/composite-stm32/lib/tinyusb/class/cdc/cdc.h

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@
4141
/** \defgroup ClassDriver_CDC_Common Common Definitions
4242
* @{ */
4343

44-
// TODO remove
45-
/// CDC Pipe ID, used to indicate which pipe the API is addressing to (Notification, Out, In)
46-
typedef enum
47-
{
48-
CDC_PIPE_NOTIFICATION , ///< Notification pipe
49-
CDC_PIPE_DATA_IN , ///< Data in pipe
50-
CDC_PIPE_DATA_OUT , ///< Data out pipe
51-
CDC_PIPE_ERROR , ///< Invalid Pipe ID
52-
}cdc_pipeid_t;
53-
5444
//--------------------------------------------------------------------+
5545
// CDC Communication Interface Class
5646
//--------------------------------------------------------------------+
@@ -192,8 +182,30 @@ typedef enum
192182
CDC_REQUEST_MDLM_SEMANTIC_MODEL = 0x60,
193183
}cdc_management_request_t;
194184

185+
enum
186+
{
187+
CDC_CONTROL_LINE_STATE_DTR = 0x01,
188+
CDC_CONTROL_LINE_STATE_RTS = 0x02,
189+
};
190+
191+
enum
192+
{
193+
CDC_LINE_CONDING_STOP_BITS_1 = 0, // 1 bit
194+
CDC_LINE_CONDING_STOP_BITS_1_5 = 1, // 1.5 bits
195+
CDC_LINE_CONDING_STOP_BITS_2 = 2, // 2 bits
196+
};
197+
198+
enum
199+
{
200+
CDC_LINE_CODING_PARITY_NONE = 0,
201+
CDC_LINE_CODING_PARITY_ODD = 1,
202+
CDC_LINE_CODING_PARITY_EVEN = 2,
203+
CDC_LINE_CODING_PARITY_MARK = 3,
204+
CDC_LINE_CODING_PARITY_SPACE = 4,
205+
};
206+
195207
//--------------------------------------------------------------------+
196-
// Management Elemenent Notification (Notification Endpoint)
208+
// Management Element Notification (Notification Endpoint)
197209
//--------------------------------------------------------------------+
198210

199211
/// 6.3 Notification Codes
@@ -365,7 +377,9 @@ typedef struct TU_ATTR_PACKED
365377
uint32_t incoming_distinctive : 1; ///< 0 : Reports only incoming ringing. 1 : Reports incoming distinctive ringing patterns.
366378
uint32_t dual_tone_multi_freq : 1; ///< 0 : Cannot report dual tone multi-frequency (DTMF) digits input remotely over the telephone line. 1 : Can report DTMF digits input remotely over the telephone line.
367379
uint32_t line_state_change : 1; ///< 0 : Does not support line state change notification. 1 : Does support line state change notification
368-
uint32_t TU_RESERVED : 26;
380+
uint32_t TU_RESERVED0 : 2;
381+
uint32_t TU_RESERVED1 : 16;
382+
uint32_t TU_RESERVED2 : 8;
369383
} bmCapabilities;
370384
}cdc_desc_func_telephone_call_state_reporting_capabilities_t;
371385

@@ -390,9 +404,10 @@ TU_VERIFY_STATIC(sizeof(cdc_line_coding_t) == 7, "size is not correct");
390404

391405
typedef struct TU_ATTR_PACKED
392406
{
393-
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.
394-
uint16_t half_duplex_carrier_control : 1;
395-
uint16_t : 14;
407+
uint16_t dtr : 1;
408+
uint16_t rts : 1;
409+
uint16_t : 6;
410+
uint16_t : 8;
396411
} cdc_line_control_state_t;
397412

398413
TU_VERIFY_STATIC(sizeof(cdc_line_control_state_t) == 2, "size is not correct");

test-devices/composite-stm32/lib/tinyusb/class/cdc/cdc_device.c

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* The MIT License (MIT)
33
*
44
* Copyright (c) 2019 Ha Thach (tinyusb.org)
@@ -53,7 +53,7 @@ typedef struct
5353

5454
/*------------- From this point, data is not cleared by bus reset -------------*/
5555
char wanted_char;
56-
cdc_line_coding_t line_coding;
56+
TU_ATTR_ALIGNED(4) cdc_line_coding_t line_coding;
5757

5858
// FIFO
5959
tu_fifo_t rx_ff;
@@ -62,10 +62,8 @@ typedef struct
6262
uint8_t rx_ff_buf[CFG_TUD_CDC_RX_BUFSIZE];
6363
uint8_t tx_ff_buf[CFG_TUD_CDC_TX_BUFSIZE];
6464

65-
#if CFG_FIFO_MUTEX
66-
osal_mutex_def_t rx_ff_mutex;
67-
osal_mutex_def_t tx_ff_mutex;
68-
#endif
65+
OSAL_MUTEX_DEF(rx_ff_mutex);
66+
OSAL_MUTEX_DEF(tx_ff_mutex);
6967

7068
// Endpoint Transfer buffer
7169
CFG_TUSB_MEM_ALIGN uint8_t epout_buf[CFG_TUD_CDC_EP_BUFSIZE];
@@ -78,7 +76,7 @@ typedef struct
7876
//--------------------------------------------------------------------+
7977
// INTERNAL OBJECT & FUNCTION DECLARATION
8078
//--------------------------------------------------------------------+
81-
CFG_TUSB_MEM_SECTION static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC];
79+
CFG_TUSB_MEM_SECTION tu_static cdcd_interface_t _cdcd_itf[CFG_TUD_CDC];
8280

8381
static bool _prep_out_transaction (cdcd_interface_t* p_cdc)
8482
{
@@ -171,7 +169,8 @@ uint32_t tud_cdc_n_write(uint8_t itf, void const* buffer, uint32_t bufsize)
171169
uint16_t ret = tu_fifo_write_n(&p_cdc->tx_ff, buffer, (uint16_t) bufsize);
172170

173171
// flush if queue more than packet size
174-
if ( tu_fifo_count(&p_cdc->tx_ff) >= BULK_PACKET_SIZE )
172+
// may need to suppress -Wunreachable-code since most of the time CFG_TUD_CDC_TX_BUFSIZE < BULK_PACKET_SIZE
173+
if ( (tu_fifo_count(&p_cdc->tx_ff) >= BULK_PACKET_SIZE) || ((CFG_TUD_CDC_TX_BUFSIZE < BULK_PACKET_SIZE) && tu_fifo_full(&p_cdc->tx_ff)) )
175174
{
176175
tud_cdc_n_write_flush(itf);
177176
}
@@ -247,10 +246,8 @@ void cdcd_init(void)
247246
// In this way, the most current data is prioritized.
248247
tu_fifo_config(&p_cdc->tx_ff, p_cdc->tx_ff_buf, TU_ARRAY_SIZE(p_cdc->tx_ff_buf), 1, true);
249248

250-
#if CFG_FIFO_MUTEX
251249
tu_fifo_config_mutex(&p_cdc->rx_ff, NULL, osal_mutex_create(&p_cdc->rx_ff_mutex));
252250
tu_fifo_config_mutex(&p_cdc->tx_ff, osal_mutex_create(&p_cdc->tx_ff_mutex), NULL);
253-
#endif
254251
}
255252
}
256253

@@ -389,7 +386,7 @@ bool cdcd_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t
389386
bool const rts = tu_bit_test(request->wValue, 1);
390387

391388
p_cdc->line_state = (uint8_t) request->wValue;
392-
389+
393390
// Disable fifo overwriting if DTR bit is set
394391
tu_fifo_set_overwritable(&p_cdc->tx_ff, !dtr);
395392

@@ -435,8 +432,8 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
435432
// Received new data
436433
if ( ep_addr == p_cdc->ep_out )
437434
{
438-
tu_fifo_write_n(&p_cdc->rx_ff, &p_cdc->epout_buf, (uint16_t) xferred_bytes);
439-
435+
tu_fifo_write_n(&p_cdc->rx_ff, p_cdc->epout_buf, (uint16_t) xferred_bytes);
436+
440437
// Check for wanted char and invoke callback if needed
441438
if ( tud_cdc_rx_wanted_cb && (((signed char) p_cdc->wanted_char) != -1) )
442439
{
@@ -448,14 +445,14 @@ bool cdcd_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint32_
448445
}
449446
}
450447
}
451-
448+
452449
// invoke receive callback (if there is still data)
453450
if (tud_cdc_rx_cb && !tu_fifo_empty(&p_cdc->rx_ff) ) tud_cdc_rx_cb(itf);
454-
451+
455452
// prepare for OUT transaction
456453
_prep_out_transaction(p_cdc);
457454
}
458-
455+
459456
// Data sent to host, we continue to fetch from tx fifo to send.
460457
// Note: This will cause incorrect baudrate set in line coding.
461458
// Though maybe the baudrate is not really important !!!

0 commit comments

Comments
 (0)