summaryrefslogtreecommitdiff
path: root/src/device/usbd.h
diff options
context:
space:
mode:
authorhathach <[email protected]>2019-04-01 21:11:06 -0700
committerGitHub <[email protected]>2019-04-01 21:11:06 -0700
commit0848c462b3e431a9da42e96537d2b597a4579636 (patch)
tree746d6642e22e3ecf30d4f4c5f830c2a155bb28d7 /src/device/usbd.h
parent86c24b310509a368cc6a9dfbec43ce531e71d598 (diff)
parent2c1072c0aba48a2e6cbe93118c286b7999b0db43 (diff)
Merge pull request #51 from hathach/develop
Add suspend, resume and remote wakeup support
Diffstat (limited to 'src/device/usbd.h')
-rw-r--r--src/device/usbd.h43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/device/usbd.h b/src/device/usbd.h
index 614b4f311..13c282e91 100644
--- a/src/device/usbd.h
+++ b/src/device/usbd.h
@@ -34,16 +34,9 @@
extern "C" {
#endif
-//--------------------------------------------------------------------+
-// INCLUDE
-//--------------------------------------------------------------------+
-#include <common/tusb_common.h>
+#include "common/tusb_common.h"
#include "device/dcd.h"
-//--------------------------------------------------------------------+
-// MACRO CONSTANT TYPEDEF
-//--------------------------------------------------------------------+
-
/// \brief Descriptor pointer collector to all the needed.
typedef struct {
void const * device; ///< pointer to device descriptor \ref tusb_desc_device_t
@@ -60,27 +53,47 @@ typedef struct {
}tud_desc_set_t;
-
// Must be defined by application
extern tud_desc_set_t tud_desc_set;
//--------------------------------------------------------------------+
-// APPLICATION API
+// Application API
//--------------------------------------------------------------------+
-bool tud_mounted(void);
+
+// Task function should be called in main/rtos loop
void tud_task (void);
+// Check if device is connected and configured
+bool tud_mounted(void);
+
+// Check if device is suspended
+bool tud_suspended(void);
+
+// Check if device is ready to transfer
+static inline bool tud_ready(void)
+{
+ return tud_mounted() && !tud_suspended();
+}
+
+// Remote wake up host, only if suspended and enabled by host
+bool tud_remote_wakeup(void);
+
//--------------------------------------------------------------------+
-// APPLICATION CALLBACK (WEAK is optional)
+// Application Callbacks (WEAK is optional)
//--------------------------------------------------------------------+
-// Callback invoked when device is mounted (configured)
+// Invoked when device is mounted (configured)
ATTR_WEAK void tud_mount_cb(void);
-// Callback invoked when device is unmounted (bus reset/unplugged)
+// Invoked when device is unmounted
ATTR_WEAK void tud_umount_cb(void);
-//void tud_device_suspended_cb(void);
+// Invoked when usb bus is suspended
+// Within 7ms, device must draw an average of current less than 2.5 mA from bus
+ATTR_WEAK void tud_suspend_cb(bool remote_wakeup_en);
+
+// Invoked when usb bus is resumed
+ATTR_WEAK void tud_resume_cb(void);
#ifdef __cplusplus
}