Skip to content

Commit

Permalink
Disable USB pullup when stopping USB
Browse files Browse the repository at this point in the history
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.

See: GrumpyOldPizza/ArduinoCore-stm32l0#171
  • Loading branch information
matthijskooijman committed Dec 5, 2020
1 parent d1ea86c commit c829151
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions system/STM32L0xx/Source/USB/HAL/Src/stm32l0xx_hal_pcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ HAL_StatusTypeDef HAL_PCD_DeInit(PCD_HandleTypeDef *hpcd)
hpcd->State = HAL_PCD_STATE_BUSY;

/* Stop Device */
(void)HAL_PCD_Stop(hpcd);
(void)USB_StopDevice(hpcd->Instance);

#if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
if (hpcd->MspDeInitCallback == NULL)
Expand Down Expand Up @@ -998,7 +998,7 @@ HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd)
__HAL_LOCK(hpcd);
__HAL_PCD_DISABLE(hpcd);

(void)USB_StopDevice(hpcd->Instance);
(void)USB_DevDisconnect(hpcd->Instance);

__HAL_UNLOCK(hpcd);

Expand Down

0 comments on commit c829151

Please sign in to comment.