From eaea8dc12ce9e862b0276eb3a29add4a65e13ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=B6pfl?= Date: Mon, 5 Jun 2023 14:19:31 +0200 Subject: [PATCH] usb:st usbfs-v2: fix disconnect polarity Fixes issue #1482: Incorrect interpretation of disconnected parameter in st_usbfs_v2_disconnect The `disconnected` parameter was interpreted incorrectly: When set to true it connected but should disconnect. Reviewed-by: Karl Palsson --- lib/stm32/st_usbfs_v2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/stm32/st_usbfs_v2.c b/lib/stm32/st_usbfs_v2.c index f13134d4..a8ce1a83 100644 --- a/lib/stm32/st_usbfs_v2.c +++ b/lib/stm32/st_usbfs_v2.c @@ -90,9 +90,9 @@ static void st_usbfs_v2_disconnect(usbd_device *usbd_dev, bool disconnected) (void)usbd_dev; uint16_t reg = GET_REG(USB_BCDR_REG); if (disconnected) { - SET_REG(USB_BCDR_REG, reg | USB_BCDR_DPPU); - } else { SET_REG(USB_BCDR_REG, reg & ~USB_BCDR_DPPU); + } else { + SET_REG(USB_BCDR_REG, reg | USB_BCDR_DPPU); } }