Skip to content

Commit 3d47e60

Browse files
Disable USB pullup when stopping USB
It turns out that stopping the USB peripheral does not automatically reset this pullup, so stopping USB (e.g. through USBDevice.detach()) would let the pullup enabled, making the USB host think the board was still connected (but any subsequent communication would fail). Additionally, this would use around 300μA of current. This is a bug in the USB HAL used. This commit backports a small change from the HAL v1.11.3 to fix this. This fixes GrumpyOldPizza#171
1 parent b1cf1cd commit 3d47e60

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

system/STM32L0xx/Source/USB/HAL/Src/stm32l0xx_hal_pcd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ HAL_StatusTypeDef HAL_PCD_DeInit(PCD_HandleTypeDef *hpcd)
240240
hpcd->State = HAL_PCD_STATE_BUSY;
241241

242242
/* Stop Device */
243-
(void)HAL_PCD_Stop(hpcd);
243+
(void)USB_StopDevice(hpcd->Instance);
244244

245245
#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
246246
if (hpcd->MspDeInitCallback == NULL)
@@ -998,7 +998,7 @@ HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd)
998998
__HAL_LOCK(hpcd);
999999
__HAL_PCD_DISABLE(hpcd);
10001000

1001-
(void)USB_StopDevice(hpcd->Instance);
1001+
(void)USB_DevDisconnect(hpcd->Instance);
10021002

10031003
__HAL_UNLOCK(hpcd);
10041004

0 commit comments

Comments
 (0)