After power-up and before using the usb, the STM32L4R9AI processor on our board goes to sleep and the current draw is as expected. But after using usb and removing cable, current consumption does not return to previous level.
As some background information, we used STM32CubeMX version 6.5.0 to generate the drivers for a custom hid device that runs on a STM32L4R9AI processor.
When the usb cable is inserted, MX_USB_DEVICE_Init() is called which is stm’s code in a file called usb_device.c.
When the usb cable is removed, MX_USB_DEVICE_DeInit() is called, also in the same file. I would expect that as a result, the sleep current would be the same as it was before inserting the cable. But instead, the current draw remains roughly double.
I have also noticed that when using the debugger, for both insertion and removal of the usb cable, HAL_PCD_IRQHandler triggers twice first to call a suspend callback and then to call a resume callback. And for both insertion and removal, the order is the same.
Why does the interrupt trigger twice, and why the same order, suspend then resume?
When measuring the current, I remove the debugger so that it is not the influencing the current draw.
