Skip to content

Commit d6c78d8

Browse files
committed
hack to build with esp32 s2/s3
1 parent ce7bffb commit d6c78d8

File tree

12 files changed

+213
-0
lines changed

12 files changed

+213
-0
lines changed

src/class/audio/audio_device.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,34 @@
6060

6161
#include "audio_device.h"
6262

63+
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
64+
#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);
89+
#endif
90+
6391
//--------------------------------------------------------------------+
6492
// MACRO CONSTANT TYPEDEF
6593
//--------------------------------------------------------------------+

src/class/cdc/cdc_device.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333

3434
#include "cdc_device.h"
3535

36+
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
37+
#define tu_static static
38+
#endif
39+
40+
3641
//--------------------------------------------------------------------+
3742
// MACRO CONSTANT TYPEDEF
3843
//--------------------------------------------------------------------+

src/class/dfu/dfu_device.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
// MACRO CONSTANT TYPEDEF
3838
//--------------------------------------------------------------------+
3939

40+
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
41+
#define tu_static static
42+
#endif
43+
4044
//--------------------------------------------------------------------+
4145
// INTERNAL OBJECT & FUNCTION DECLARATION
4246
//--------------------------------------------------------------------+

src/class/dfu/dfu_rt_device.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,32 @@
3333

3434
#include "dfu_rt_device.h"
3535

36+
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
37+
#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+
}
60+
#endif
61+
3662
//--------------------------------------------------------------------+
3763
// MACRO CONSTANT TYPEDEF
3864
//--------------------------------------------------------------------+

src/class/hid/hid_device.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,33 @@
3636

3737
#include "hid_device.h"
3838

39+
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
40+
#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+
64+
#endif
65+
3966
//--------------------------------------------------------------------+
4067
// MACRO CONSTANT TYPEDEF
4168
//--------------------------------------------------------------------+

src/class/midi/midi_device.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,33 @@
3636

3737
#include "midi_device.h"
3838

39+
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
40+
#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+
64+
#endif
65+
3966
//--------------------------------------------------------------------+
4067
// MACRO CONSTANT TYPEDEF
4168
//--------------------------------------------------------------------+

src/class/msc/msc_device.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,33 @@
3434

3535
#include "msc_device.h"
3636

37+
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
38+
#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+
62+
#endif
63+
3764
//--------------------------------------------------------------------+
3865
// MACRO CONSTANT TYPEDEF
3966
//--------------------------------------------------------------------+

src/class/vendor/vendor_device.c

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

3434
#include "vendor_device.h"
3535

36+
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
37+
#define tu_static static
38+
#endif
39+
3640
//--------------------------------------------------------------------+
3741
// MACRO CONSTANT TYPEDEF
3842
//--------------------------------------------------------------------+

src/class/video/video_device.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434

3535
#include "video_device.h"
3636

37+
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
38+
#define tu_static static
39+
#endif
40+
3741
//--------------------------------------------------------------------+
3842
// MACRO CONSTANT TYPEDEF
3943
//--------------------------------------------------------------------+

src/device/usbd.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
#include "device/usbd.h"
3636
#include "device/usbd_pvt.h"
3737

38+
#if defined(ARDUINO_ARCH_ESP32) && !defined(tu_static)
39+
#define tu_static static
40+
41+
TU_ATTR_WEAK bool dcd_edpt_iso_alloc(uint8_t rhport, uint8_t ep_addr, uint16_t largest_packet_size);
42+
TU_ATTR_WEAK bool dcd_edpt_iso_activate(uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc);
43+
#endif
44+
3845
//--------------------------------------------------------------------+
3946
// USBD Configuration
4047
//--------------------------------------------------------------------+

src/device/usbd_control.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,33 @@
3232
#include "tusb.h"
3333
#include "device/usbd_pvt.h"
3434

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

src/tusb.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,33 @@
3939
#include "host/usbh_classdriver.h"
4040
#endif
4141

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

0 commit comments

Comments
 (0)