Skip to content

Commit ddde366

Browse files
authored
Merge pull request #224 from adafruit/update-tinyusb-48f4d8b7f7eda7ee4046c1c6cd9be2b5c0d81603
Update tinyusb to commit 48f4d8b7f7eda7ee4046c1c6cd9be2b5c0d81603
2 parents 91df381 + c58c6f2 commit ddde366

35 files changed

+1735
-540
lines changed

src/class/cdc/cdc.h

Lines changed: 25 additions & 13 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
@@ -390,8 +402,8 @@ TU_VERIFY_STATIC(sizeof(cdc_line_coding_t) == 7, "size is not correct");
390402

391403
typedef struct TU_ATTR_PACKED
392404
{
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;
405+
uint16_t dtr : 1;
406+
uint16_t rts : 1;
395407
uint16_t : 14;
396408
} cdc_line_control_state_t;
397409

src/class/cdc/cdc_device.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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];
@@ -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

@@ -435,7 +432,7 @@ 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);
435+
tu_fifo_write_n(&p_cdc->rx_ff, p_cdc->epout_buf, (uint16_t) xferred_bytes);
439436

440437
// Check for wanted char and invoke callback if needed
441438
if ( tud_cdc_rx_wanted_cb && (((signed char) p_cdc->wanted_char) != -1) )

src/class/cdc/cdc_device.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#ifndef _TUSB_CDC_DEVICE_H_
2828
#define _TUSB_CDC_DEVICE_H_
2929

30-
#include "common/tusb_common.h"
3130
#include "cdc.h"
3231

3332
//--------------------------------------------------------------------+
@@ -135,7 +134,7 @@ TU_ATTR_WEAK void tud_cdc_rx_cb(uint8_t itf);
135134
// Invoked when received `wanted_char`
136135
TU_ATTR_WEAK void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char);
137136

138-
// Invoked when space becomes available in TX buffer
137+
// Invoked when a TX is complete and therefore space becomes available in TX buffer
139138
TU_ATTR_WEAK void tud_cdc_tx_complete_cb(uint8_t itf);
140139

141140
// Invoked when line state DTR & RTS are changed via SET_CONTROL_LINE_STATE

0 commit comments

Comments
 (0)