aboutsummaryrefslogtreecommitdiff
path: root/lib/usb/usb_f107.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/usb/usb_f107.c')
-rw-r--r--lib/usb/usb_f107.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/usb/usb_f107.c b/lib/usb/usb_f107.c
index 0797cba..1cd3eec 100644
--- a/lib/usb/usb_f107.c
+++ b/lib/usb/usb_f107.c
@@ -42,6 +42,7 @@ static void stm32f107_ep_nak_set(u8 addr, u8 nak);
static u16 stm32f107_ep_write_packet(u8 addr, const void *buf, u16 len);
static u16 stm32f107_ep_read_packet(u8 addr, void *buf, u16 len);
static void stm32f107_poll(void);
+static void stm32f107_disconnect(bool disconnected);
/*
* We keep a backup copy of the out endpoint size registers to restore them
@@ -60,6 +61,7 @@ const struct _usbd_driver stm32f107_usb_driver = {
.ep_write_packet = stm32f107_ep_write_packet,
.ep_read_packet = stm32f107_ep_read_packet,
.poll = stm32f107_poll,
+ .disconnect = stm32f107_disconnect,
};
/** Initialize the USB device controller hardware of the STM32. */
@@ -376,3 +378,12 @@ static void stm32f107_poll(void)
OTG_FS_GINTSTS = OTG_FS_GINTSTS_SOF;
}
}
+
+static void stm32f107_disconnect(bool disconnected)
+{
+ if (disconnected) {
+ OTG_FS_DCTL |= OTG_FS_DCTL_SDIS;
+ } else {
+ OTG_FS_DCTL &= ~OTG_FS_DCTL_SDIS;
+ }
+} \ No newline at end of file