Skip to content

Commit 003d22f

Browse files
committedJul 14, 2016
Send an USB remote wakeup if data need to be written
On Linux, setting autosuspend_delay_ms to N and control to auto allows the host pc to suspend the peripheral. Some Linux distro (Ubuntu, Mint) apply this behaviour by default. If the sketch's prints where less frequent than N milliseconds the sketch prints would never arrive. This patch allows sending a remote wakeup event to unsuspend the peripheral and allow the serial prints to be received.
1 parent 28e10e9 commit 003d22f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎hardware/arduino/avr/cores/arduino/USBCore.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22

3-
/* Copyright (c) 2010, Peter Barrett
3+
/* Copyright (c) 2010, Peter Barrett
4+
** Sleep/Wakeup support added by Michael Dreher
45
**
56
** Permission to use, copy, modify, and/or distribute this software for
67
** any purpose with or without fee is hereby granted, provided that the
@@ -266,6 +267,11 @@ int USB_Send(u8 ep, const void* d, int len)
266267
if (!_usbConfiguration)
267268
return -1;
268269

270+
if (_usbSuspendState & (1<<SUSPI)) {
271+
//send a remote wakeup
272+
UDCON |= (1 << RMWKUP);
273+
}
274+
269275
int r = len;
270276
const u8* data = (const u8*)d;
271277
u8 timeout = 250; // 250ms timeout on send? TODO

0 commit comments

Comments
 (0)
Please sign in to comment.