Skip to content

Commit 6d2c8e3

Browse files
committed
update tinyusb to hathach/tinyusb@9c8c5c1
1 parent 9527382 commit 6d2c8e3

Some content is hidden

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

47 files changed

+863
-592
lines changed

src/Adafruit_TinyUSB.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
#if TUSB_OPT_DEVICE_ENABLED
3737

38+
3839
#include "arduino/Adafruit_USBD_Device.h"
3940
#if CFG_TUD_CDC
4041
#include "arduino/Adafruit_USBD_CDC.h"

src/class/audio/audio_device.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050

5151
#include "tusb_option.h"
5252

53-
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_AUDIO)
53+
#if (CFG_TUD_ENABLED && CFG_TUD_AUDIO)
5454

5555
//--------------------------------------------------------------------+
5656
// INCLUDE
@@ -2291,4 +2291,4 @@ uint8_t audiod_get_audio_fct_idx(audiod_function_t * audio)
22912291
return 0;
22922292
}
22932293

2294-
#endif //TUSB_OPT_DEVICE_ENABLED && CFG_TUD_AUDIO
2294+
#endif //CFG_TUD_ENABLED && CFG_TUD_AUDIO

src/class/bth/bth_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include "tusb_option.h"
2828

29-
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_BTH)
29+
#if (CFG_TUD_ENABLED && CFG_TUD_BTH)
3030

3131
//--------------------------------------------------------------------+
3232
// INCLUDE

src/class/cdc/cdc_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include "tusb_option.h"
2828

29-
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_CDC)
29+
#if (CFG_TUD_ENABLED && CFG_TUD_CDC)
3030

3131
#include "device/usbd.h"
3232
#include "device/usbd_pvt.h"

src/class/dfu/dfu_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include "tusb_option.h"
2828

29-
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU)
29+
#if (CFG_TUD_ENABLED && CFG_TUD_DFU)
3030

3131
#include "device/usbd.h"
3232
#include "device/usbd_pvt.h"

src/class/dfu/dfu_rt_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include "tusb_option.h"
2828

29-
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_DFU_RUNTIME)
29+
#if (CFG_TUD_ENABLED && CFG_TUD_DFU_RUNTIME)
3030

3131
#include "device/usbd.h"
3232
#include "device/usbd_pvt.h"

src/class/hid/hid.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
/** \defgroup ClassDriver_HID_Common Common Definitions
4444
* @{ */
4545

46-
/// USB HID Descriptor
46+
/// USB HID Descriptor
4747
typedef struct TU_ATTR_PACKED
4848
{
4949
uint8_t bLength; /**< Numeric expression that is the total size of the HID descriptor */
@@ -645,7 +645,7 @@ enum {
645645
#define HID_REPORT_SIZE_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_SIZE, RI_TYPE_GLOBAL, n)
646646

647647
#define HID_REPORT_ID(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_ID, RI_TYPE_GLOBAL, 1),
648-
#define HID_REPORT_ID_N(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_ID, RI_TYPE_GLOBAL, n),
648+
#define HID_REPORT_ID_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_ID, RI_TYPE_GLOBAL, n),
649649

650650
#define HID_REPORT_COUNT(x) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_COUNT, RI_TYPE_GLOBAL, 1)
651651
#define HID_REPORT_COUNT_N(x, n) HID_REPORT_ITEM(x, RI_GLOBAL_REPORT_COUNT, RI_TYPE_GLOBAL, n)
@@ -1106,7 +1106,10 @@ enum
11061106
{'8' , 0 }, /* 0x60 */ \
11071107
{'9' , 0 }, /* 0x61 */ \
11081108
{'0' , 0 }, /* 0x62 */ \
1109-
{'0' , 0 }, /* 0x63 */ \
1109+
{'.' , 0 }, /* 0x63 */ \
1110+
{0 , 0 }, /* 0x64 */ \
1111+
{0 , 0 }, /* 0x65 */ \
1112+
{0 , 0 }, /* 0x66 */ \
11101113
{'=' , '=' }, /* 0x67 */ \
11111114

11121115

src/class/hid/hid_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include "tusb_option.h"
2828

29-
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_HID)
29+
#if (CFG_TUD_ENABLED && CFG_TUD_HID)
3030

3131
//--------------------------------------------------------------------+
3232
// INCLUDE

src/class/midi/midi_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include "tusb_option.h"
2828

29-
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_MIDI)
29+
#if (CFG_TUD_ENABLED && CFG_TUD_MIDI)
3030

3131
//--------------------------------------------------------------------+
3232
// INCLUDE

src/class/msc/msc_device.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include "tusb_option.h"
2828

29-
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_MSC)
29+
#if (CFG_TUD_ENABLED && CFG_TUD_MSC)
3030

3131
#include "device/usbd.h"
3232
#include "device/usbd_pvt.h"
@@ -753,6 +753,7 @@ static int32_t proc_builtin_scsi(uint8_t lun, uint8_t const scsi_cmd[16], uint8_
753753
.is_removable = 1,
754754
.version = 2,
755755
.response_data_format = 2,
756+
.additional_length = sizeof(scsi_inquiry_resp_t) - 5,
756757
};
757758

758759
// vendor_id, product_id, product_rev is space padded string

src/class/net/ecm_rndis_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include "tusb_option.h"
2929

30-
#if ( TUSB_OPT_DEVICE_ENABLED && CFG_TUD_ECM_RNDIS )
30+
#if ( CFG_TUD_ENABLED && CFG_TUD_ECM_RNDIS )
3131

3232
#include "device/usbd.h"
3333
#include "device/usbd_pvt.h"

src/class/net/ncm_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include "tusb_option.h"
3030

31-
#if ( TUSB_OPT_DEVICE_ENABLED && CFG_TUD_NCM )
31+
#if ( CFG_TUD_ENABLED && CFG_TUD_NCM )
3232

3333
#include "device/usbd.h"
3434
#include "device/usbd_pvt.h"

src/class/usbtmc/usbtmc_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868

6969
#include "tusb_option.h"
7070

71-
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_USBTMC)
71+
#if (CFG_TUD_ENABLED && CFG_TUD_USBTMC)
7272

7373
#include "device/usbd.h"
7474
#include "device/usbd_pvt.h"

src/class/vendor/vendor_device.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include "tusb_option.h"
2828

29-
#if (TUSB_OPT_DEVICE_ENABLED && CFG_TUD_VENDOR)
29+
#if (CFG_TUD_ENABLED && CFG_TUD_VENDOR)
3030

3131
#include "device/usbd.h"
3232
#include "device/usbd_pvt.h"
@@ -113,7 +113,7 @@ void tud_vendor_n_read_flush (uint8_t itf)
113113
//--------------------------------------------------------------------+
114114
// Write API
115115
//--------------------------------------------------------------------+
116-
static bool maybe_transmit(vendord_interface_t* p_itf)
116+
static uint16_t maybe_transmit(vendord_interface_t* p_itf)
117117
{
118118
// skip if previous transfer not complete
119119
TU_VERIFY( !usbd_edpt_busy(TUD_OPT_RHPORT, p_itf->ep_in) );
@@ -123,14 +123,24 @@ static bool maybe_transmit(vendord_interface_t* p_itf)
123123
{
124124
TU_ASSERT( usbd_edpt_xfer(TUD_OPT_RHPORT, p_itf->ep_in, p_itf->epin_buf, count) );
125125
}
126-
return true;
126+
return count;
127127
}
128128

129129
uint32_t tud_vendor_n_write (uint8_t itf, void const* buffer, uint32_t bufsize)
130130
{
131131
vendord_interface_t* p_itf = &_vendord_itf[itf];
132132
uint16_t ret = tu_fifo_write_n(&p_itf->tx_ff, buffer, bufsize);
133-
maybe_transmit(p_itf);
133+
if (tu_fifo_count(&p_itf->tx_ff) >= CFG_TUD_VENDOR_EPSIZE) {
134+
maybe_transmit(p_itf);
135+
}
136+
return ret;
137+
}
138+
139+
uint32_t tud_vendor_n_flush (uint8_t itf)
140+
{
141+
vendord_interface_t* p_itf = &_vendord_itf[itf];
142+
uint32_t ret = maybe_transmit(p_itf);
143+
134144
return ret;
135145
}
136146

@@ -247,6 +257,7 @@ bool vendord_xfer_cb(uint8_t rhport, uint8_t ep_addr, xfer_result_t result, uint
247257
}
248258
else if ( ep_addr == p_itf->ep_in )
249259
{
260+
if (tud_vendor_tx_cb) tud_vendor_tx_cb(itf, xferred_bytes);
250261
// Send complete, try to send more if possible
251262
maybe_transmit(p_itf);
252263
}

src/class/vendor/vendor_device.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ uint32_t tud_vendor_n_write_available (uint8_t itf);
5252

5353
static inline
5454
uint32_t tud_vendor_n_write_str (uint8_t itf, char const* str);
55+
uint32_t tud_vendor_n_flush (uint8_t itf);
5556

5657
//--------------------------------------------------------------------+
5758
// Application API (Single Port)
@@ -64,13 +65,16 @@ static inline void tud_vendor_read_flush (void);
6465
static inline uint32_t tud_vendor_write (void const* buffer, uint32_t bufsize);
6566
static inline uint32_t tud_vendor_write_str (char const* str);
6667
static inline uint32_t tud_vendor_write_available (void);
68+
static inline uint32_t tud_vendor_flush (void);
6769

6870
//--------------------------------------------------------------------+
6971
// Application Callback API (weak is optional)
7072
//--------------------------------------------------------------------+
7173

7274
// Invoked when received new data
7375
TU_ATTR_WEAK void tud_vendor_rx_cb(uint8_t itf);
76+
// Invoked when last rx transfer finished
77+
TU_ATTR_WEAK void tud_vendor_tx_cb(uint8_t itf, uint32_t sent_bytes);
7478

7579
//--------------------------------------------------------------------+
7680
// Inline Functions
@@ -121,6 +125,11 @@ static inline uint32_t tud_vendor_write_available (void)
121125
return tud_vendor_n_write_available(0);
122126
}
123127

128+
static inline uint32_t tud_vendor_flush (void)
129+
{
130+
return tud_vendor_n_flush(0);
131+
}
132+
124133
//--------------------------------------------------------------------+
125134
// Internal Class Driver API
126135
//--------------------------------------------------------------------+

0 commit comments

Comments
 (0)