Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 691b288

Browse filesBrowse files
authored
Merge pull request #352 from facchinm/fix_usb_ep_reconnect
Always call new DoubleBufferedEPOutHandler on reconnect
2 parents a8eec3b + f4dfac8 commit 691b288
Copy full SHA for 691b288

File tree

2 files changed

+9
-3
lines changed
Filter options

2 files changed

+9
-3
lines changed

‎cores/arduino/USB/SAMD21_USBDevice.h

Copy file name to clipboardExpand all lines: cores/arduino/USB/SAMD21_USBDevice.h
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,11 @@ class DoubleBufferedEPOutHandler : public EPHandler {
254254
release();
255255
}
256256

257+
~DoubleBufferedEPOutHandler() {
258+
free((void*)data0);
259+
free((void*)data1);
260+
}
261+
257262
virtual uint32_t recv(void *_data, uint32_t len)
258263
{
259264
uint8_t *data = reinterpret_cast<uint8_t *>(_data);

‎cores/arduino/USB/USBCore.cpp

Copy file name to clipboardExpand all lines: cores/arduino/USB/USBCore.cpp
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ uint8_t udd_ep_in_cache_buffer[7][64];
9191
// Some EP are handled using EPHanlders.
9292
// Possibly all the sparse EP handling subroutines will be
9393
// converted into reusable EPHandlers in the future.
94-
static EPHandler *epHandlers[7];
94+
static EPHandler *epHandlers[7] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL};
9595

9696
//==================================================================
9797

@@ -454,9 +454,10 @@ void USBDeviceClass::initEP(uint32_t ep, uint32_t config)
454454
}
455455
else if (config == (USB_ENDPOINT_TYPE_BULK | USB_ENDPOINT_OUT(0)))
456456
{
457-
if (epHandlers[ep] == NULL) {
458-
epHandlers[ep] = new DoubleBufferedEPOutHandler(usbd, ep, 256);
457+
if (epHandlers[ep] != NULL) {
458+
delete (DoubleBufferedEPOutHandler*)epHandlers[ep];
459459
}
460+
epHandlers[ep] = new DoubleBufferedEPOutHandler(usbd, ep, 256);
460461
}
461462
else if (config == (USB_ENDPOINT_TYPE_BULK | USB_ENDPOINT_IN(0)))
462463
{

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.