Skip to content

Commit 429e228

Browse files
authored
Merge pull request #271 from adafruit/more-tinyusb-update
sync tinyusb to commit b05422978004f076de665f5101e5cc1bac34175c
2 parents f43338a + 962863b commit 429e228

File tree

18 files changed

+120
-214
lines changed

18 files changed

+120
-214
lines changed

src/class/audio/audio_device.c

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,8 @@
6262

6363
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
6464
#define tu_static static
65-
66-
// This is a backport of memset_s from c11
67-
TU_ATTR_ALWAYS_INLINE static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count)
68-
{
69-
// TODO may check if desst and src is not NULL
70-
if (count > destsz) {
71-
return -1;
72-
}
73-
memset(dest, ch, count);
74-
return 0;
75-
}
76-
77-
// This is a backport of memcpy_s from c11
78-
TU_ATTR_ALWAYS_INLINE static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count )
79-
{
80-
// TODO may check if desst and src is not NULL
81-
if (count > destsz) {
82-
return -1;
83-
}
84-
memcpy(dest, src, count);
85-
return 0;
86-
}
87-
88-
extern bool usbd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * desc_ep);
65+
static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count) { if (count > destsz) { return -1; } memset(dest, ch, count); return 0; }
66+
static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count ) { if (count > destsz) { return -1; } memcpy(dest, src, count); return 0; }
8967
#endif
9068

9169
//--------------------------------------------------------------------+
@@ -340,7 +318,7 @@ typedef struct
340318

341319
#if CFG_TUD_AUDIO_ENABLE_FEEDBACK_EP
342320
struct {
343-
uint32_t value; // Feedback value for asynchronous mode (in 16.16 format).
321+
CFG_TUSB_MEM_ALIGN uint32_t value; // Feedback value for asynchronous mode (in 16.16 format).
344322
uint32_t min_value; // min value according to UAC2 FMT-2.0 section 2.3.1.1.
345323
uint32_t max_value; // max value according to UAC2 FMT-2.0 section 2.3.1.1.
346324

src/class/cdc/cdc_device.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
3737
#define tu_static static
38+
static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count) { if (count > destsz) { return -1; } memset(dest, ch, count); return 0; }
39+
static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count ) { if (count > destsz) { return -1; } memcpy(dest, src, count); return 0; }
3840
#endif
3941

4042

src/class/cdc/cdc_host.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ typedef struct {
6262
tu_edpt_stream_t rx;
6363

6464
uint8_t tx_ff_buf[CFG_TUH_CDC_TX_BUFSIZE];
65-
CFG_TUSB_MEM_ALIGN uint8_t tx_ep_buf[CFG_TUH_CDC_TX_EPSIZE];
65+
CFG_TUH_MEM_ALIGN uint8_t tx_ep_buf[CFG_TUH_CDC_TX_EPSIZE];
6666

6767
uint8_t rx_ff_buf[CFG_TUH_CDC_TX_BUFSIZE];
68-
CFG_TUSB_MEM_ALIGN uint8_t rx_ep_buf[CFG_TUH_CDC_TX_EPSIZE];
68+
CFG_TUH_MEM_ALIGN uint8_t rx_ep_buf[CFG_TUH_CDC_TX_EPSIZE];
6969
} stream;
7070

7171
} cdch_interface_t;
@@ -74,7 +74,7 @@ typedef struct {
7474
// INTERNAL OBJECT & FUNCTION DECLARATION
7575
//--------------------------------------------------------------------+
7676

77-
CFG_TUSB_MEM_SECTION
77+
CFG_TUH_MEM_SECTION
7878
static cdch_interface_t cdch_data[CFG_TUH_CDC];
7979

8080
static inline cdch_interface_t* get_itf(uint8_t idx)
@@ -323,7 +323,8 @@ bool tuh_cdc_set_control_line_state(uint8_t idx, uint16_t line_state, tuh_xfer_c
323323
.user_data = user_data
324324
};
325325

326-
return tuh_control_xfer(&xfer);
326+
TU_ASSERT(tuh_control_xfer(&xfer));
327+
return true;
327328
}
328329

329330
bool tuh_cdc_set_line_coding(uint8_t idx, cdc_line_coding_t const* line_coding, tuh_xfer_cb_t complete_cb, uintptr_t user_data)
@@ -363,7 +364,8 @@ bool tuh_cdc_set_line_coding(uint8_t idx, cdc_line_coding_t const* line_coding,
363364
.user_data = user_data
364365
};
365366

366-
return tuh_control_xfer(&xfer);
367+
TU_ASSERT(tuh_control_xfer(&xfer));
368+
return true;
367369
}
368370

369371
//--------------------------------------------------------------------+
@@ -543,32 +545,36 @@ static void process_cdc_config(tuh_xfer_t* xfer)
543545
uintptr_t const state = xfer->user_data;
544546
uint8_t const itf_num = (uint8_t) tu_le16toh(xfer->setup->wIndex);
545547
uint8_t const idx = tuh_cdc_itf_get_index(xfer->daddr, itf_num);
546-
TU_ASSERT(idx != TUSB_INDEX_INVALID_8, );
548+
cdch_interface_t * p_cdc = get_itf(idx);
549+
TU_ASSERT(p_cdc, );
547550

548551
switch(state)
549552
{
550553
case CONFIG_SET_CONTROL_LINE_STATE:
551-
#if CFG_TUH_CDC_LINE_CONTROL_ON_ENUM
552-
TU_ASSERT( tuh_cdc_set_control_line_state(idx, CFG_TUH_CDC_LINE_CONTROL_ON_ENUM, process_cdc_config, CONFIG_SET_LINE_CODING), );
553-
break;
554-
#endif
555-
TU_ATTR_FALLTHROUGH;
554+
#if CFG_TUH_CDC_LINE_CONTROL_ON_ENUM
555+
if (p_cdc->acm_capability.support_line_request)
556+
{
557+
TU_ASSERT( tuh_cdc_set_control_line_state(idx, CFG_TUH_CDC_LINE_CONTROL_ON_ENUM, process_cdc_config, CONFIG_SET_LINE_CODING), );
558+
break;
559+
}
560+
#endif
561+
TU_ATTR_FALLTHROUGH;
556562

557563
case CONFIG_SET_LINE_CODING:
558-
#ifdef CFG_TUH_CDC_LINE_CODING_ON_ENUM
559-
{
560-
cdc_line_coding_t line_coding = CFG_TUH_CDC_LINE_CODING_ON_ENUM;
561-
TU_ASSERT( tuh_cdc_set_line_coding(idx, &line_coding, process_cdc_config, CONFIG_COMPLETE), );
562-
break;
563-
}
564-
#endif
565-
TU_ATTR_FALLTHROUGH;
564+
#ifdef CFG_TUH_CDC_LINE_CODING_ON_ENUM
565+
if (p_cdc->acm_capability.support_line_request)
566+
{
567+
cdc_line_coding_t line_coding = CFG_TUH_CDC_LINE_CODING_ON_ENUM;
568+
TU_ASSERT( tuh_cdc_set_line_coding(idx, &line_coding, process_cdc_config, CONFIG_COMPLETE), );
569+
break;
570+
}
571+
#endif
572+
TU_ATTR_FALLTHROUGH;
566573

567574
case CONFIG_COMPLETE:
568575
if (tuh_cdc_mount_cb) tuh_cdc_mount_cb(idx);
569576

570577
// Prepare for incoming data
571-
cdch_interface_t* p_cdc = get_itf(idx);
572578
tu_edpt_stream_read_xfer(&p_cdc->stream.rx);
573579

574580
// notify usbh that driver enumeration is complete

src/class/dfu/dfu_device.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@
3333

3434
#include "dfu_device.h"
3535

36-
//--------------------------------------------------------------------+
37-
// MACRO CONSTANT TYPEDEF
38-
//--------------------------------------------------------------------+
39-
4036
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
4137
#define tu_static static
38+
static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count) { if (count > destsz) { return -1; } memset(dest, ch, count); return 0; }
39+
static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count ) { if (count > destsz) { return -1; } memcpy(dest, src, count); return 0; }
4240
#endif
4341

42+
//--------------------------------------------------------------------+
43+
// MACRO CONSTANT TYPEDEF
44+
//--------------------------------------------------------------------+
45+
4446
//--------------------------------------------------------------------+
4547
// INTERNAL OBJECT & FUNCTION DECLARATION
4648
//--------------------------------------------------------------------+

src/class/dfu/dfu_rt_device.c

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,8 @@
3535

3636
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
3737
#define tu_static static
38-
39-
// This is a backport of memset_s from c11
40-
TU_ATTR_ALWAYS_INLINE static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count)
41-
{
42-
// TODO may check if desst and src is not NULL
43-
if (count > destsz) {
44-
return -1;
45-
}
46-
memset(dest, ch, count);
47-
return 0;
48-
}
49-
50-
// This is a backport of memcpy_s from c11
51-
TU_ATTR_ALWAYS_INLINE static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count )
52-
{
53-
// TODO may check if desst and src is not NULL
54-
if (count > destsz) {
55-
return -1;
56-
}
57-
memcpy(dest, src, count);
58-
return 0;
59-
}
38+
static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count) { if (count > destsz) { return -1; } memset(dest, ch, count); return 0; }
39+
static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count ) { if (count > destsz) { return -1; } memcpy(dest, src, count); return 0; }
6040
#endif
6141

6242
//--------------------------------------------------------------------+

src/class/hid/hid_device.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,8 @@
3838

3939
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
4040
#define tu_static static
41-
42-
// This is a backport of memset_s from c11
43-
TU_ATTR_ALWAYS_INLINE static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count)
44-
{
45-
// TODO may check if desst and src is not NULL
46-
if (count > destsz) {
47-
return -1;
48-
}
49-
memset(dest, ch, count);
50-
return 0;
51-
}
52-
53-
// This is a backport of memcpy_s from c11
54-
TU_ATTR_ALWAYS_INLINE static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count )
55-
{
56-
// TODO may check if desst and src is not NULL
57-
if (count > destsz) {
58-
return -1;
59-
}
60-
memcpy(dest, src, count);
61-
return 0;
62-
}
63-
41+
static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count) { if (count > destsz) { return -1; } memset(dest, ch, count); return 0; }
42+
static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count ) { if (count > destsz) { return -1; } memcpy(dest, src, count); return 0; }
6443
#endif
6544

6645
//--------------------------------------------------------------------+

src/class/hid/hid_host.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535

3636
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
3737
#define tu_static static
38+
static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count) { if (count > destsz) { return -1; } memset(dest, ch, count); return 0; }
39+
static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count ) { if (count > destsz) { return -1; } memcpy(dest, src, count); return 0; }
3840
#endif
3941

4042
//--------------------------------------------------------------------+
@@ -58,11 +60,11 @@ typedef struct
5860
uint16_t epin_size;
5961
uint16_t epout_size;
6062

61-
uint8_t epin_buf[CFG_TUH_HID_EPIN_BUFSIZE];
62-
uint8_t epout_buf[CFG_TUH_HID_EPOUT_BUFSIZE];
63+
CFG_TUH_MEM_ALIGN uint8_t epin_buf[CFG_TUH_HID_EPIN_BUFSIZE];
64+
CFG_TUH_MEM_ALIGN uint8_t epout_buf[CFG_TUH_HID_EPOUT_BUFSIZE];
6365
} hidh_interface_t;
6466

65-
CFG_TUSB_MEM_SECTION
67+
CFG_TUH_MEM_SECTION
6668
tu_static hidh_interface_t _hidh_itf[CFG_TUH_HID];
6769

6870
//--------------------------------------------------------------------+

src/class/midi/midi_device.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,8 @@
3838

3939
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
4040
#define tu_static static
41-
42-
// This is a backport of memset_s from c11
43-
TU_ATTR_ALWAYS_INLINE static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count)
44-
{
45-
// TODO may check if desst and src is not NULL
46-
if (count > destsz) {
47-
return -1;
48-
}
49-
memset(dest, ch, count);
50-
return 0;
51-
}
52-
53-
// This is a backport of memcpy_s from c11
54-
TU_ATTR_ALWAYS_INLINE static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count )
55-
{
56-
// TODO may check if desst and src is not NULL
57-
if (count > destsz) {
58-
return -1;
59-
}
60-
memcpy(dest, src, count);
61-
return 0;
62-
}
63-
41+
static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count) { if (count > destsz) { return -1; } memset(dest, ch, count); return 0; }
42+
static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count ) { if (count > destsz) { return -1; } memcpy(dest, src, count); return 0; }
6443
#endif
6544

6645
//--------------------------------------------------------------------+

src/class/msc/msc_device.c

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -36,29 +36,8 @@
3636

3737
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
3838
#define tu_static static
39-
40-
// This is a backport of memset_s from c11
41-
TU_ATTR_ALWAYS_INLINE static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count)
42-
{
43-
// TODO may check if desst and src is not NULL
44-
if (count > destsz) {
45-
return -1;
46-
}
47-
memset(dest, ch, count);
48-
return 0;
49-
}
50-
51-
// This is a backport of memcpy_s from c11
52-
TU_ATTR_ALWAYS_INLINE static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count )
53-
{
54-
// TODO may check if desst and src is not NULL
55-
if (count > destsz) {
56-
return -1;
57-
}
58-
memcpy(dest, src, count);
59-
return 0;
60-
}
61-
39+
static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count) { if (count > destsz) { return -1; } memset(dest, ch, count); return 0; }
40+
static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count ) { if (count > destsz) { return -1; } memcpy(dest, src, count); return 0; }
6241
#endif
6342

6443
//--------------------------------------------------------------------+

src/class/msc/msc_host.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ typedef struct
7171
tuh_msc_complete_cb_t complete_cb;
7272
uintptr_t complete_arg;
7373

74-
msc_cbw_t cbw;
75-
msc_csw_t csw;
74+
CFG_TUH_MEM_ALIGN msc_cbw_t cbw;
75+
CFG_TUH_MEM_ALIGN msc_csw_t csw;
7676
}msch_interface_t;
7777

78-
CFG_TUSB_MEM_SECTION static msch_interface_t _msch_itf[CFG_TUH_DEVICE_MAX];
78+
CFG_TUH_MEM_SECTION static msch_interface_t _msch_itf[CFG_TUH_DEVICE_MAX];
7979

8080
// buffer used to read scsi information when mounted
8181
// largest response data currently is inquiry TODO Inquiry is not part of enum anymore
82-
CFG_TUSB_MEM_SECTION TU_ATTR_ALIGNED(4)
82+
CFG_TUH_MEM_SECTION CFG_TUH_MEM_ALIGN
8383
static uint8_t _msch_buffer[sizeof(scsi_inquiry_resp_t)];
8484

8585
TU_ATTR_ALWAYS_INLINE

src/class/usbtmc/usbtmc.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -262,32 +262,32 @@ typedef struct TU_ATTR_PACKED
262262

263263
struct TU_ATTR_PACKED
264264
{
265-
unsigned int listenOnly :1;
266-
unsigned int talkOnly :1;
267-
unsigned int supportsIndicatorPulse :1;
265+
uint8_t listenOnly :1;
266+
uint8_t talkOnly :1;
267+
uint8_t supportsIndicatorPulse :1;
268268
} bmIntfcCapabilities;
269269

270270
struct TU_ATTR_PACKED
271271
{
272-
unsigned int canEndBulkInOnTermChar :1;
272+
uint8_t canEndBulkInOnTermChar :1;
273273
} bmDevCapabilities;
274274

275275
uint8_t _reserved2[6];
276276
uint16_t bcdUSB488;
277277

278278
struct TU_ATTR_PACKED
279279
{
280-
unsigned int is488_2 :1;
281-
unsigned int supportsREN_GTL_LLO :1;
282-
unsigned int supportsTrigger :1;
280+
uint8_t supportsTrigger :1;
281+
uint8_t supportsREN_GTL_LLO :1;
282+
uint8_t is488_2 :1;
283283
} bmIntfcCapabilities488;
284284

285285
struct TU_ATTR_PACKED
286286
{
287-
unsigned int SCPI :1;
288-
unsigned int SR1 :1;
289-
unsigned int RL1 :1;
290-
unsigned int DT1 :1;
287+
uint8_t DT1 :1;
288+
uint8_t RL1 :1;
289+
uint8_t SR1 :1;
290+
uint8_t SCPI :1;
291291
} bmDevCapabilities488;
292292
uint8_t _reserved3[8];
293293
} usbtmc_response_capabilities_488_t;

src/class/vendor/vendor_device.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@
3535

3636
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
3737
#define tu_static static
38+
static inline int tu_memset_s(void *dest, size_t destsz, int ch, size_t count) { if (count > destsz) { return -1; } memset(dest, ch, count); return 0; }
39+
static inline int tu_memcpy_s(void *dest, size_t destsz, const void * src, size_t count ) { if (count > destsz) { return -1; } memcpy(dest, src, count); return 0; }
3840
#endif
39-
4041
//--------------------------------------------------------------------+
4142
// MACRO CONSTANT TYPEDEF
4243
//--------------------------------------------------------------------+

0 commit comments

Comments
 (0)