Skip to content

Commit 35b6128

Browse files
committed
add thin wrapper for tud api
1 parent f8d309a commit 35b6128

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

cores/nRF5/usb/Adafruit_TinyUSB_core/Adafruit_USBD_Device.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ uint16_t const * const string_desc_arr [] =
5353
};
5454

5555
// tud_desc_set is required by tinyusb stack
56-
// since CFG_TUD_DESC_AUTO is enabled, we only need to set string_arr
5756
tud_desc_set_t tud_desc_set =
5857
{
5958
.device = NULL, // update later
@@ -134,10 +133,11 @@ Adafruit_USBD_Device::Adafruit_USBD_Device(void)
134133
bool Adafruit_USBD_Device::addInterface(Adafruit_USBD_Interface& itf)
135134
{
136135
uint8_t* desc = _desc_cfg+_desc_cfglen;
137-
uint16_t len = itf.getDescriptor(desc, sizeof(_desc_cfg)-_desc_cfglen);
138-
136+
uint16_t const len = itf.getDescriptor(desc, sizeof(_desc_cfg)-_desc_cfglen);
139137
uint8_t* desc_end = desc+len;
140138

139+
if ( !len ) return false;
140+
141141
// Handle IAD
142142
if ( desc[1] == TUSB_DESC_INTERFACE_ASSOCIATION )
143143
{

cores/nRF5/usb/Adafruit_TinyUSB_core/Adafruit_USBD_Device.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ class Adafruit_USBD_Device
5252
bool addInterface(Adafruit_USBD_Interface& itf);
5353

5454
bool begin(uint16_t vid, uint16_t pid);
55+
56+
bool mounted(void) { return tud_mounted(); }
57+
bool suspended(void) { return tud_suspended(); }
58+
bool ready(void) { return tud_ready(); }
59+
bool remoteWakeup(void) { return tud_remote_wakeup(); }
5560
};
5661

5762
extern Adafruit_USBD_Device USBDevice;

0 commit comments

Comments
 (0)