From 3ee0fa126506c623bf45ddcfccce1bf2abd2e41e Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Fri, 26 Jun 2015 15:05:57 +0200 Subject: Add support for waking up a host via USB HID this is a rework of commit fbcf94801b8bba7f1c8c79cc7ae402b6b9dbb2d3 --- cores/arduino/USBAPI.h | 1 + cores/arduino/USBCore.cpp | 161 +++++++++++++++++++++++++++++++++++++++------- cores/arduino/USBCore.h | 11 +++- 3 files changed, 150 insertions(+), 23 deletions(-) (limited to 'cores/arduino') diff --git a/cores/arduino/USBAPI.h b/cores/arduino/USBAPI.h index d8ad98d..251e4b9 100644 --- a/cores/arduino/USBAPI.h +++ b/cores/arduino/USBAPI.h @@ -58,6 +58,7 @@ public: void attach(); void detach(); // Serial port goes down too... void poll(); + bool wakeupHost(); // returns false, when wakeup cannot be processed }; extern USBDevice_ USBDevice; diff --git a/cores/arduino/USBCore.cpp b/cores/arduino/USBCore.cpp index b0160e2..9095d79 100644 --- a/cores/arduino/USBCore.cpp +++ b/cores/arduino/USBCore.cpp @@ -78,6 +78,8 @@ const DeviceDescriptor USB_DeviceDescriptorB = //================================================================== volatile u8 _usbConfiguration = 0; +volatile u8 _usbCurrentStatus = 0; // meaning of bits see usb_20.pdf, Figure 9-4. Information Returned by a GetStatus() Request to a Device +volatile u8 _usbSuspendState = 0; // copy of UDINT to check SUSPI and WAKEUPI bits static inline void WaitIN(void) { @@ -329,7 +331,7 @@ static void InitEP(u8 index, u8 type, u8 size) { UENUM = index; - UECONX = 1; + UECONX = (1<