32
32
33
33
static Adafruit_USBD_MSC *_msc_dev = NULL ;
34
34
35
- #ifdef ARDUINO_ARCH_ESP32
36
- static uint16_t msc_load_descriptor (uint8_t *dst, uint8_t *itf) {
37
- // uint8_t str_index = tinyusb_add_string_descriptor("TinyUSB MSC");
38
- // uint8_t str_index = 0;
39
-
40
- uint8_t ep_in = tinyusb_get_free_in_endpoint ();
41
- uint8_t ep_out = tinyusb_get_free_out_endpoint ();
42
- TU_VERIFY (ep_in && ep_out);
43
- ep_in |= 0x80 ;
44
-
45
- uint16_t const desc_len =
46
- _msc_dev->makeItfDesc (*itf, dst, TUD_MSC_DESC_LEN, ep_in, ep_out);
47
- *itf += 1 ;
48
- return desc_len;
49
- }
50
- #endif
51
-
52
35
Adafruit_USBD_MSC::Adafruit_USBD_MSC (void ) {
53
36
_maxlun = 1 ;
54
37
memset (_lun_info, 0 , sizeof (_lun_info));
55
-
56
- #ifdef ARDUINO_ARCH_ESP32
57
- // ESP32 requires setup configuration descriptor on declaration
58
- _msc_dev = this ;
59
- tinyusb_enable_interface (USB_INTERFACE_MSC, TUD_MSC_DESC_LEN,
60
- msc_load_descriptor);
61
- #endif
62
- }
63
-
64
- uint16_t Adafruit_USBD_MSC::makeItfDesc (uint8_t itfnum, uint8_t *buf,
65
- uint16_t bufsize, uint8_t ep_in,
66
- uint8_t ep_out) {
67
- uint8_t const desc[] = {
68
- TUD_MSC_DESCRIPTOR (itfnum, _strid, ep_out, ep_in, EPSIZE)};
69
- uint16_t const len = sizeof (desc);
70
-
71
- if (bufsize < len) {
72
- return 0 ;
73
- }
74
- memcpy (buf, desc, len);
75
-
76
- return len;
77
38
}
78
39
79
40
uint16_t Adafruit_USBD_MSC::getInterfaceDescriptor (uint8_t itfnum_deprecated,
@@ -90,7 +51,16 @@ uint16_t Adafruit_USBD_MSC::getInterfaceDescriptor(uint8_t itfnum_deprecated,
90
51
uint8_t const ep_in = TinyUSBDevice.allocEndpoint (TUSB_DIR_IN);
91
52
uint8_t const ep_out = TinyUSBDevice.allocEndpoint (TUSB_DIR_OUT);
92
53
93
- return makeItfDesc (itfnum, buf, bufsize, ep_in, ep_out);
54
+ uint8_t const desc[] = {
55
+ TUD_MSC_DESCRIPTOR (itfnum, _strid, ep_out, ep_in, EPSIZE)};
56
+ uint16_t const len = sizeof (desc);
57
+
58
+ if (bufsize < len) {
59
+ return 0 ;
60
+ }
61
+ memcpy (buf, desc, len);
62
+
63
+ return len;
94
64
}
95
65
96
66
void Adafruit_USBD_MSC::setMaxLun (uint8_t maxlun) { _maxlun = maxlun; }
0 commit comments