diff options
author | Martino Facchin <m.facchin@arduino.cc> | 2016-07-14 18:43:43 +0200 |
---|---|---|
committer | Martino Facchin <m.facchin@arduino.cc> | 2016-07-14 18:43:43 +0200 |
commit | 7874386ce23a7b7383f587e6bf6ae665756024ba (patch) | |
tree | 169935a7c74be6eb0835c18a075f590119ab356f /cores | |
parent | 5e146c415d4b3e9006e21a94428a86320316aaf2 (diff) |
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.
Diffstat (limited to 'cores')
-rw-r--r-- | cores/arduino/USBCore.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index 6c8ae63..ddc4812 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -1,6 +1,7 @@ -/* Copyright (c) 2010, Peter Barrett +/* Copyright (c) 2010, Peter Barrett +** Sleep/Wakeup support added by Michael Dreher ** ** Permission to use, copy, modify, and/or distribute this software for ** 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) if (!_usbConfiguration) return -1; + if (_usbSuspendState & (1<<SUSPI)) { + //send a remote wakeup + UDCON |= (1 << RMWKUP); + } + int r = len; const u8* data = (const u8*)d; u8 timeout = 250; // 250ms timeout on send? TODO |