summaryrefslogtreecommitdiff
path: root/src/portable
diff options
context:
space:
mode:
authorHa Thach <[email protected]>2020-04-11 13:20:31 +0700
committerGitHub <[email protected]>2020-04-11 13:20:31 +0700
commit07809d03a728abff4c77f04fdf293eb29a0c109c (patch)
tree2d180c7228b34bd1845729a1231b78e6f433af16 /src/portable
parent2ff3f765db7e62201d0491093111b0d649446046 (diff)
parent5bd9d14fc14d9130d7d879800bd46e4ca08e3d5f (diff)
Merge pull request #332 from pigrew/stm32fsdev-dcdconnect
stm32fsdev: Implement dcd_connect.
Diffstat (limited to 'src/portable')
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c24
-rw-r--r--src/portable/template/dcd_template.c14
2 files changed, 32 insertions, 6 deletions
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
index f962a4bee..3cd35cca4 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
@@ -239,17 +239,29 @@ void dcd_init (uint8_t rhport)
}
USB->CNTR |= USB_CNTR_RESETM | USB_CNTR_SOFM | USB_CNTR_ESOFM | USB_CNTR_CTRM | USB_CNTR_SUSPM | USB_CNTR_WKUPM;
dcd_handle_bus_reset();
+
+ // Data-line pull-up is left disconnected.
+}
- // And finally enable pull-up, which may trigger the RESET IRQ if the host is connected.
- // (if this MCU has an internal pullup)
+// Define only on MCU with internal pull-up. BSP can define on MCU without internal PU.
#if defined(USB_BCDR_DPPU)
- USB->BCDR |= USB_BCDR_DPPU;
-#else
- // FIXME: callback to the user to ask them to twiddle a GPIO to disable/enable D+???
-#endif
+// Disable internal D+ PU
+void dcd_disconnect(uint8_t rhport)
+{
+ (void) rhport;
+ USB->BCDR &= ~(USB_BCDR_DPPU);
+}
+
+// Enable internal D+ PU
+void dcd_connect(uint8_t rhport)
+{
+ (void) rhport;
+ USB->BCDR |= USB_BCDR_DPPU;
}
+#endif
+
// Enable device interrupt
void dcd_int_enable (uint8_t rhport)
{
diff --git a/src/portable/template/dcd_template.c b/src/portable/template/dcd_template.c
index 102910509..d29c98e55 100644
--- a/src/portable/template/dcd_template.c
+++ b/src/portable/template/dcd_template.c
@@ -45,6 +45,20 @@ void dcd_init (uint8_t rhport)
(void) rhport;
}
+#if HAS_INTERNAL_PULLUP
+// Enable internal D+/D- pullup
+void dcd_connect(uint8_t rhport) TU_ATTR_WEAK
+{
+ (void) rhport;
+}
+
+// Disable internal D+/D- pullup
+void dcd_disconnect(uint8_t rhport) TU_ATTR_WEAK
+{
+ (void) rhport;
+}
+#endif
+
// Enable device interrupt
void dcd_int_enable (uint8_t rhport)
{