summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2020-04-09 11:42:42 +0700
committerhathach <[email protected]>2020-04-09 11:42:42 +0700
commit11201f1a06396d4ab8302f2bb5ce579cb4ae7a6c (patch)
tree85e19c18e07954152f65fb160ea1801f4b732639
parent36b33ee775a02e1263f61bc4a82e58d8e8559734 (diff)
adding dcd_connect/disconnect
-rw-r--r--src/device/dcd.h6
-rw-r--r--src/device/usbd.h14
2 files changed, 20 insertions, 0 deletions
diff --git a/src/device/dcd.h b/src/device/dcd.h
index 143a2de34..487ddb3b6 100644
--- a/src/device/dcd.h
+++ b/src/device/dcd.h
@@ -106,6 +106,12 @@ void dcd_set_config (uint8_t rhport, uint8_t config_num);
// Wake up host
void dcd_remote_wakeup(uint8_t rhport);
+// disconnect by disabling internal pull-up resistor on D+/D-
+void dcd_disconnect(uint8_t rhport) TU_ATTR_WEAK;
+
+// connect by enabling internal pull-up resistor on D+/D-
+void dcd_connect(uint8_t rhport) TU_ATTR_WEAK;
+
//--------------------------------------------------------------------+
// Endpoint API
//--------------------------------------------------------------------+
diff --git a/src/device/usbd.h b/src/device/usbd.h
index beeec7e1c..817af20e3 100644
--- a/src/device/usbd.h
+++ b/src/device/usbd.h
@@ -65,6 +65,20 @@ static inline bool tud_ready(void)
// Remote wake up host, only if suspended and enabled by host
bool tud_remote_wakeup(void);
+static inline bool tud_disconnect(void)
+{
+ TU_VERIFY(dcd_disconnect);
+ dcd_disconnect(TUD_OPT_RHPORT);
+ return true;
+}
+
+static inline bool tud_connect(void)
+{
+ TU_VERIFY(dcd_connect);
+ dcd_connect(TUD_OPT_RHPORT);
+ return true;
+}
+
// Carry out Data and Status stage of control transfer
// - If len = 0, it is equivalent to sending status only
// - If len > wLength : it will be truncated