I like to shutdown DFLL48M and USB module to put to deep sleep since USB (in CDC and later MSC) is disconnected. The aim is to minimise current much as possible when MCU doing nothing (Sleep Mode).
I also assigned PA03 to wakeup MCU when VBUS from USB is detected, how to correctly wake up the DFLL48M and USB module?, is there demo code that do that?
I found this snippet below, I guess I do this first to turn off USB and The MCU operates from OSC8M and then turn off DFLL48M clock and reverse for wakeup.
/*! \brief Stop the USB Device stack
I also found in Sleep Manager
Called when USB bus enter in suspend mode
Called when USB bus is wakeup
I unsure if this really disables DFLL48M clock.
Any input would be appreciated, did you managed to turn off USB when disconnected (via VBUS monitoring) and turn on USB when connected without issue?